# The Matrix of an object

Hello again.

Can someone tell me what exactly can be foud in the 4x4 matrix of an object?
Just by looking at it, the Location is at the bottom an the cells of the 1st 3 rows and columns decribe the rotation…
But Where could i find what exactly is in each cell ?
I guess some have sin(RotX)xcos(RotY) or so… but i wasn’t able to deduce (is that english?) it all…

Hello Gwenouille,

in the 4x4 matrix the first part of the matrix is the rotation matrix, see http://en.wikipedia.org/wiki/Rotation_matrix for more details.
The content of the rotation matrix depends on the order the rotations around the axes is done - normal way should be X * Y * Z (with “*” as matrix multiplication)

The last column of the contains the translation information (position) in homogeneous coordinates.

What do you want to do? In the Python-API are already some functions to get the euler rotation and the position from a matrix.

Well… i writ e a script in which objects point to the 3D cursor, like they point to another object using the “track to constraint”.
But: while i understand the math for doing this 2 dimensionnal, i struggle to hve it work in 3D.
To sum it up:
I have the coordinates or the 3D cursor, those of an object. From that i don’t know how to calculate the 3 rotations to apply to the object so that it points to the Cursor…

Can’t you use:
AngleBetweenVecs
http://www.blender.org/documentation/244PythonDoc/Mathutils-module.html#AngleBetweenVecs

and than
RotationMatrix()
http://www.blender.org/documentation/244PythonDoc/Mathutils-module.html#RotationMatrix

Maybe i can… I just don’t know…
there is something i don’t grasp…
I can’t see a way to do what i want without knowing exactly what’s in this rotation matrix.
But my knowledge in matrices is close to inexistant so i don’t know how to multiply them for instance…
I ll find that on the Wiki.
I need to know how to convert these matrix to Euler (i mean without using the python tool): i like to understand !

a 4x4 matrix can store an objects loc/scale/rot, however this is not the same as having the loc/size/rot and once you have the matrix, you cant always KNOW what the loc/size/rot where.

• They are not interchangeable

For example, negative scales have no correct way of being converted back, and as for rotation, you cant tell if the object was rotated 1 or 2 times, its just the transforms applied into a structure computers can handle better.

Okok i see…
Basically we don’t need to know the single elements of a Matrix, but rather know how to manipulate the whole for our purposes…
There is one thing that was confusing me: the Rot attributes of any objects applies to the objects’ proper axis of rotation, don’t they ?
But rotating an object by having its matrix multiplicated by a rotation matrix is actually a rotation around (0,0,0)
True ?
The main problem is my lack of mathematical training with matrix i think…
I ve just learned how to add and multiply them but they still are a very very distant concept to me…

Thanks ideasman.

@ Semmelb: thanks for your links: this ANgle Between Vecs actually got my out of my misery…!