4x4 matrix Q
I have a 4x4 matrix used for rotating a 3D object to rotate to face any point in one simple step, and looks something like:
This rotates in X, Y and Z simultaneously (no translation in these particular matrices).
Do any of you Maths whizzes know how to extract just the Y-rotation angle out of that?
a b c 0 e f g 0 h i j 0 0 0 0 1
This rotates in X, Y and Z simultaneously (no translation in these particular matrices).
Do any of you Maths whizzes know how to extract just the Y-rotation angle out of that?
Post edited by NickH on
Comments
You know you don't have to respond to every thread, right? ;)
i don't even look at the boring threads, but i thought this was going to be about the matrix film. you decived me, so i thought i'd spoil your thread. :lol:
For example, a 90-degree rotation about the Y axis is exactly equivalent to 90 degrees about X followed by 90 degrees about Z. I suspect there's an infinite number of ways to decompose any rotation, but don't quote me on that...
I had a feeling that would be the case... currently trying to figure it out myself, and it's a complete headflip[1]...
[1] Self-censorship is fun.
For background, I have a list of object positions over time (x,y,z) and a 4x4 rotation matrix.
For rotation matrices (from an FAQ):
| CE -CF D 0 | M = | BDE+AF -BDF+AE -BC 0 | | -ADE+BF ADF+BE AC 0 | | 0 0 0 1 | where A,B are the cosine and sine of the X-axis rotation axis, C,D are the cosine and sine of the Y-axis rotation axis, E,F are the cosine and sine of the Z-axis rotation axis.Now, sin(rotY) = matrix[0][2] - and of course, asin(matrix[0][2]) really returns two values.
(forgive the poor variable names)
lx = 0 lz = 0 for (n=0; n<len(list); n++) { d = matrix[0][2] a = rad2deg(asin(d)) # now find other solution if (a <= 180) { b = 180 -a } else { b = a -180 b = 180 -b b = b + 180 } if (n==0) { #guess roty = a } else { if (list[n].z < lz) { roty = a } else { roty = b } } lx = list[n].x lz = list[n].z }Very kludgy, but works for finding the Y-rotation angle, providing you have a stream of co-ordinates to work with (as I do).
If anyone's interesteg, I'm using all this for collision detection for positioning the elements of the 1989 chapter intro animation. (Teaser)