PDA

View Full Version : calculate up vector (rotation matrix)


losbellos
02-16-2009, 06:53 PM
Hi There,
I would like to ask, if anyone knows the magic equation of the transform matrix.
So lets say, I have a virtual object, which rotation transform I would like to output.
normally on a selected object it would look like:
x = $.transform[2][1]
y = $.transform[2][2]
z = $.transform[2][3]
Since this object doesn't exits, I will have two edittext field with variables
horizontal rotation (degree)
vertical rotation. (degree)
so the question is how to calculate the output x,y value as up vector or rotation matrix.
Thanks a bunch for this one.

PiXeL_MoNKeY
02-16-2009, 07:10 PM
Maxscript Help "How do I align the UVW_Modifier's Gizmo to a selected face?"

-Eric

losbellos
02-16-2009, 07:51 PM
I looked into it but I didnt find the corresponding part.

here is an example, I have a dummy object and it is rotated around its Z axis with 15 degrees, and I will get this

(matrix3 [0.965926,0.258819,0] [-0.258819,0.965926,0] [0,0,1] [5.78841,-5.14507,0])

I would like to know how to calculate the second part of the matrix3. (underlined) with simply degrees. That would be already a big help. THe best if someone would know with two parameters, the horizontal and vertical rotation.
This is basically a hdri map rotation for an external renderer.

losbellos
02-16-2009, 08:22 PM
I decided to calculate it through two point. So the vector of the two point will be the upvector. If anyone have better option please dont hesitate to write it.
THanks

PiXeL_MoNKeY
02-16-2009, 08:53 PM
A matrix3 uses the first 3 entries to define rotation and scale, and the 4th is position. You could try calling $.transform.rotationpart, but remember the only accurate rotation is a Quaterion, Eulers are always dependent on the rotation order and will change based on that setting.

-Eric

magicm
02-16-2009, 09:18 PM
I have a dummy object and it is rotated around its Z axis with 15 degrees, and I will get this

(matrix3 [0.965926,0.258819,0] [-0.258819,0.965926,0] [0,0,1] [5.78841,-5.14507,0])

I would like to know how to calculate the second part of the matrix3. (underlined) with simply degrees.
(rotatezmatrix 15).row2

Cheers,
Martijn

losbellos
02-16-2009, 10:22 PM
wow, thats simple. ;)
Thanks

CGTalk Moderation
02-16-2009, 10:22 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.