Say we have a 4x4 matrix with indices like so:
00 01 02 03
10 11 12 13
20 21 22 23
30 31 32 33
How does one convert the rotation data (ignoring the z axis, if that helps) contained in this matrix into a single 2d rotational angle (in radians)?
Background: I have a 3D .dae animation exported from Blender into the Collada format. The animation is technically 2d, all of the z axis values are 0. I'm trying to convert the 4x4 matrices into 2d translation, rotation and scale data.
this library has routines for converting a 4x4 matrix into its 5 components - rotation, translation, scale, shear, and perspective. You should be able to take the formulas and just drop the 3rd component of the 3d vectors.
Scale matrix
S
looks like this:Translation matrix
T
looks like this:Z-axis rotation matrix
R
looks like this:If you have a transformation matrix
M
, it is a result of a number of multiplications ofR
,T
andS
matrices. Looking atM
, the order and number of those multiplications is unknown. However, if we assume thatM=S*R*T
we can decompose it into separate matrices. Firstly let's calculateS*R*T
:Since we know it's a 2D transformation, getting translation is straightforward:
To calculate rotation and scale, we can use
sin(a)^2+cos(a)^2=1
: