Ok, I know that ob.getOrientation() returns a 3 x 3 matrix… and that somehow it defines the rotation of the object…
When the object has the following rotation: 0,0,0; i get this:
[1.0, 0.0, 0.0]
[0.0, 1.0, 0.0]
[0.0, 0.0, 1.0]
but when I rotate it say, 90º in the Z axys, I get THIS:
[-4.3711390001864437e-008, -0.999999999999999, 0.0]
[0.999999999999999, -4.3711390001864437e-008, 0.0]
[0.0, 0.0, 1.0]
I need to understand how this getOrientation() thing works… anyone who masters this aspect of blender can lend me a hand, please?
Thanks!
–EDIT–
As far as I know, those numbers are result of trigonometric functions… right?
It is usefull to find the global coordinates of a vertex when you know the local coordinates of that vertex.
Lets say a vertex has local coordinates [1 1 1].
If your object has orientation 0,0,0, the orientation matrix is the identity matrix (zero everywhere exept for the major diagonal).
To know the global coordinates of the vertex, multiply the vector by the matrix, and you get
[1 1 1] * [1 0 0] = [1 1 1]
[0 1 0]
[0 0 1]
So, the local and global coordinates of the vertex are the same, since the rotation of the object is zero
If you now rotate the object 90 degrees over the positive z-axis, the orientation matrix will be (as you indicated):
[0 -1 0]
[1 0 0]
[0 0 1]
Multiplying the local vertex coordinates [1 1 1] with this matrix will result in [1 -1 1], which is the global position of that vertex.
Thanks for the replies tuinbels and Egg, I’ve read your page tuinbels and… it sort of pointed me to the right direction, now at least I know what I’m working with!
Egg, I’ll read your links now…
Anyway, meanwhile I distract myself with 2d math and 3d math and matrices… I would like to know if there’s a method that calculates the orientation of an object and lays it out in a nice (x,y,z) manner, and not a chaotic 3x3 matrix :-?.
Ofcourse it’s possible to get the rotation with getEuler() and turn the values from radians to degrees, but I’ve read several times that these functions don’t always get the correct, updated info. Only the object’s matrix gives correct info. So you’ll somehow have to extract the rotation out of the matrix…
That happens to me for only searching for getOrientation()… I should’ve done a better search job… anyways, THANK you for uncovering that post from the winds of oblivion, and thanks theeth for that nice script, now comes the best part, understanding the script!