Can any programmers out there tell me how I can convert a transformation matrix into euler angles? I believe it is some simple math using atan2 of components within the rotational sub-matrix but I can't seem to figure it out.
Dim instance As IComponent2
Dim value As MathTransform
instance.Transform2 = value
value = instance.Transform2
now how would I turn that transformation matrix into euler angles or yaw,pitcha and roll angles.
Simplified interface for manipulating transformation matrix data:
|a b c . n |
|d e f . o |
|g h i . p |
|------. --|
|j k l . m |
The SolidWorks transformation matrix is stored as a homogeneous matrix of 16 elements, ordered as shown. The first 9 (a to i) are elements of a 3x3 rotational sub-matrix, the next 3 (j,k,l) define a translation vector, the next 1 (m) is a scaling factor. The last 3 elements (n,o,p) are unused in this context.
The 3X3 rotational sub-matrix represents 3 axis sets: row 1 for x-axis components of rotation, row 2 for y-axis components of rotation, and row 3 for z-axis components of rotations. The 3 axes are constrained to be orthogonal and unified so that they produce a pure rotational transformation. Reflections can also be added to these axes by setting the components to negative. The rotation sub-matrix coupled with the lower-left translation vector and the lower-right corner scaling factor creates an affine (a transformation that preserves lines and parallelism, i.e., maps parallel lines to parallel lines) transformation.
If the 3 axis sets of the 3x3 rotational sub-matrix are not orthogonal or unified, then they are automatically corrected according to the following rules:
- If any axis is 0, or any two axes are parallel, or all axes are coplanar, then an identity matrix replaces the rotational sub-matrix.
- All axes are corrected to be of unit length.
- The axes are built to be orthogonal to each other in the prioritized order of Z, X, Y (X is orthogonal to Z, Y is orthogonal to Z and X).