[Closed] Rotation matricies
I have got some data which is a 3 x 3 rotation matrix that i would like to convert to either euler angles or and angle axis
However I have never used matricies before and I don’t understand how they work or how to convert them. All the tutorials i have found assume that you are experienced with matricies or are good with mathematics
Can anyone throw some light on these and explain it to me in laymans term ?
cheers
Dave
I am also beginner with matrix, but I think I can answer you all the same.
3dsmax use 4×3 3D transformation matrix object… (or 3×4 According to the agreement)
Open the listener and create a box:
mybox=box width:100.0 length:100.0 height:100.0
Apply a small rotation in a some axis:
myAngle=quat 30 [0,1,1]
rotate myBox myAngle
And move a little the box :
move myBox [10,20,30]
In the listener, type:
t=myBox.transform
—>
(matrix3 [0.748873,0.468609,-0.468609] [-0.468609,0.874437,0.125563] [0.468609,0.125563,0.874437] [10,20,30])
It’s the complete matrix of the object.
As you can see it, the last column is just the position of the object…
To know his rotation part, It’s easy:
t.rotationpart
—>
(quat 0 -0.250563 -0.250563 0.935113)
OR
t.rotationpart as matrix3
—>
(matrix3 [0.748873,0.468609,-0.468609] [-0.468609,0.874437,0.125563] [0.468609,0.125563,0.874437] [0,0,0])
So, you can add your data into the matrix of the object…
A easy way is to add a column [0,0,0] to your data and create a matrix 4×3 with this:
r=matrix3 [1,2,3] [4,5,6] [7,8,9] [0,0,0]
where 1,2,3,…,9 is your data
And apply a rotation to your object:
rotate myBox (r as quat)
but if your data have to replace and not modify the transform part, it’s a bit more complex.
to replace the rotation part:
mTP=transMatrix myBox.transform.translationpart
mRP=myBox.transform.rotationpart as matrix3
-- or replace by mRP=matrix3 [1,2,3] [4,5,6] [7,8,9] [0,0,0] using your data...
mSP=scaleMatrix (myBox.transform.scalepart)
m=mSP*mRP*mTP -- don't modify the order
myBox.transform=m
Don’t use Euler angles for rotation…
Use the quat… It’s not really complex: It’s just an axis of rotation and an rotation…
For example the axis Z is [0,0,1]
To make a rotation of 30 ° Z, it is just
rotate myBox (quat 30 [0,0,1])
So simple as that…
cheers,
prettyPixel
thanks for the help there i will get trying this when i get up tommorow. it certainly seems handy. Would i be right in thinking that handling rotations as matricies would help avoid gimball locking?
Also whats the difference between quat and angle axis? the syntax and structure is exaxctly the same
cheers
i cant see how handling the roatations any specific way will help avoid gimbal lock other than to not use euler controlllers
mark
That is almost similar but there is an important difference: the angles
make it possible to memorize a rotation with several revolutions.
a=angleaxis 720 [0,0,1]
That is useful for animation…
You can’t avoid gimble lock as long as you are using an euler_XYZ controller on the object. It is the interpolation of rotations that cause the problem not nessesarly the value you set at a key.
Quat values will solve this using a TCB controller but the problem there is you will not have usable function curves like you do with an euler.
Check out my site for some information about rotations that might help you.