quaternion_from_matrix

compas.geometry.quaternion_from_matrix(M)[source]

Returns the 4 quaternion coefficients from a rotation matrix.

Parameters

M (list of list of float) – The coefficients of the rotation matrix, row per row.

Returns

list of float – The quaternion coefficients.

Examples

>>> q1 = [0.945, -0.021, -0.125, 0.303]
>>> R = matrix_from_quaternion(q1)
>>> q2 = quaternion_from_matrix(R)
>>> allclose(q1, q2, tol=1e-03)
True