py3dframe.matrix.O3_project#

O3_project(matrix)[source]#

Project a matrix to the orthogonal group \(O(3)\) using SVD and minimisation of the frobenius norm.

The orthogonal group O(3) is the set of 3x3 orthonormal matrices with determinant equal to 1 or -1.

To project a matrix to O(3), the SVD is computed and the orthogonal matrix is obtained by:

\[\mathbf{O} = \mathbf{U} \mathbf{V}^T\]

where \(\mathbf{U}\) and \(\mathbf{V}\) are the left and right singular vectors of the matrix such as:

\[\mathbf{M} = \mathbf{U} \mathbf{\Sigma} \mathbf{V}^T\]

See also

Parameters:

matrix (array_like) – A 3x3 matrix to be projected.

Returns:

The O(3) projection of the matrix.

Return type:

numpy.ndarray

Raises:

ValueError – If the matrix is not 3x3.

Examples

>>> import numpy
>>> from py3dframe import O3_project
>>> e1 = numpy.array([1, 1, 0])
>>> e2 = numpy.array([-1, 1, 0])
>>> e3 = numpy.array([0, 0, 1])
>>> matrix = numpy.column_stack((e1, e2, e3))
>>> print(O3_project(matrix))
[[ 0.70710678  -0.70710678  0.        ]
 [ 0.70710678  0.70710678  0.        ]
 [ 0.          0.          1.        ]]