Introduction
Let \(\mathbf{P}\) be a generic matrix belonging to \(\mathbb{R}^{m\times n}\). SVD allows \(\mathbf{P}\) to be decomposed into the product of three matrices:
\[\mathbf{P} = \mathbf{U}\mathbf{S}\mathbf{V^\top},\]
where \(\mathbf{U}\in \mathbb{R}^{m\times m}\) , and \(\mathbf{V}^\top\in \mathbb{R}^{n\times n}\) are called respectively left- and right-principal matrix (both orthonormal), whereas \(\mathbf{S}\in \mathbb{R}^{m\times n}\) is the so-called Singular Value Matrix.
We do SVD via:
t.svd()
Using SVD
Suppose that the points of the topography are distributed according to three preferred directions, which are identifiable by visual inspection. Assume that these directions define a reference frame \(\{x_s,y_s,z_s\}\). Conversely, assume that the points forming the point topography have been acquired with respect to another (arbitrary) reference frame \(\{x,y,z\}\), which (unfortunately) is not aligned with \(\{x_s,y_s,z_s\}\). However, expressing the acquired points with respect to \(\{x_s,y_s,z_s\}\) would be of considerable interest, e.g. for further numerical computations. From a mathematical standpoint, a change of reference frame, i.e. change of basis, from \(\{x,y,z\}\) to \(\{x_s,y_s,z_s\}\) is sought as well as the associated matrix.
In this instance, it is therefore evident that finding this matrix by inspection, intuition or ‘trial & error’ becomes preposterous. SVD holds the potential to compute such a matrix almost automatically. Let \(\mathbf{P}\in\mathbb{R}^{N\times 3}\) be the matrix representing the topography. In order to apply the SVD and obtain satisfactory results, the whole point topography should be translated to \(-G\) (the centroid). Following, the SVD applied to \(\mathbf{P}\) provides \(\mathbf{U}\in \mathbb{R}^{N\times N}\) , \(\mathbf{S}\in \mathbb{R}^{N\times 3}\), and \(\mathbf{V}^\top\in \mathbb{R}^{3\times 3}\). In particular, \(\mathbf{V}\) realises the change of basis. Hence, each point of \(\mathbf{P}\), namely \(\mathbf{p}_i\), will be rotated according to \(\mathbf{V}^\top\):
\[\mathbf{p}_i \leftarrow \mathbf{V}^\top\mathbf{p}_i.\]
To perform this, just invoke:
t.rotate_by_svd()
which wraps rotate_about_centre.
Since \(\mathbf{V}^\top\) is orthonormal, the topography is subjected to a rigid rotation: neither stretching nor deformations occur. If the \(\det{V^\top} \simeq -1\), the transformed topography (through SVD) may need flipping. To overcome this, just use Flip.