decompose_matrix
- compas.geometry.decompose_matrix(M)[source]
Calculates the components of rotation, translation, scale, shear, and perspective of a given transformation matrix M. 1
- Parameters
M (
list
oflist
offloat
) – The square matrix of any dimension.- Raises
ValueError – If matrix is singular or degenerative.
- Returns
tuple (scale, shear, angles, translation, perspective) –
scale (
list
offloat
) - The 3 scale factors in x-, y-, and z-direction.shear (
list
offloat
) - The 3 shear factors for x-y, x-z, and y-z axes.angles (
list
offloat
) - The rotation specified through the 3 Euler angles about static x, y, z axes.perspective (
list
offloat
) - The 4 perspective entries of the matrix.
Examples
>>> trans1 = [1, 2, 3] >>> angle1 = [-2.142, 1.141, -0.142] >>> scale1 = [0.123, 2, 0.5] >>> T = matrix_from_translation(trans1) >>> R = matrix_from_euler_angles(angle1) >>> S = matrix_from_scale_factors(scale1) >>> M = multiply_matrices(multiply_matrices(T, R), S) >>> # M = compose_matrix(scale1, None, angle1, trans1, None) >>> scale2, shear2, angle2, trans2, persp2 = decompose_matrix(M) >>> allclose(scale1, scale2) True >>> allclose(angle1, angle2) True >>> allclose(trans1, trans2) True
References
- 1
Slabaugh, 1999. Computing Euler angles from a rotation matrix. Available at: http://www.gregslabaugh.net/publications/euler.pdf