py3dframe.matrix.is_O3#

is_O3(matrix, tolerance=1e-06)[source]#

Check if the given matrix is orthonormal (include on the orthogonal group \(O(3)\)).

A matrix is orthonormal if its transpose is equal to its inverse.

\[M^T = M^{-1}\]

See also

Parameters:
  • matrix (array_like) – The matrix with shape (3, 3).

  • tolerance (float, optional) – The tolerance for the comparison of the matrix with the identity matrix. Default is 1e-6.

Returns:

True if the matrix is in the orthogonal group, False otherwise.

Return type:

bool

Raises:

ValueError – If the matrix is not 3x3.

Examples

>>> import numpy
>>> from py3dframe.matrix import is_O3
>>> 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(is_O3(matrix))
False
>>> import numpy
>>> from py3dframe.matrix import is_O3
>>> e1 = numpy.array([1, 1, 0]) / numpy.sqrt(2)
>>> e2 = numpy.array([-1, 1, 0]) / numpy.sqrt(2)
>>> e3 = numpy.array([0, 0, 1])
>>> matrix = numpy.column_stack((e1, e2, e3))
>>> print(is_O3(matrix))
True
>>> import numpy
>>> from py3dframe.matrix import is_O3
>>> e1 = numpy.array([-1, 1, 0]) / numpy.sqrt(2)
>>> e2 = numpy.array([1, 1, 0]) / numpy.sqrt(2)
>>> e3 = numpy.array([0, 0, 1])
>>> matrix = numpy.column_stack((e1, e2, e3))
>>> print(is_O3(matrix))
True
>>> import numpy
>>> from py3dframe.matrix import is_O3
>>> e1 = numpy.array([1, 1, 1]) / numpy.sqrt(3)
>>> e2 = numpy.array([-1, 1, 0]) / numpy.sqrt(2)
>>> e3 = numpy.array([0, 0, 1])
>>> matrix = numpy.column_stack((e1, e2, e3))
>>> print(is_O3(matrix))
False