Sign in to follow this  

Confused on the use of 3x3 and 4x4 matrices for rotations,quaternions,inertia tensors

Recommended Posts

johnnyBravo    100
I'm a bit confused on which matrix size to use, eg 3x3 or 4x4. I'm learning about inertia tensor and rotation matrices which I am supposed to use a 3x3 matrix, but I am also learning about converting quaternions to a rotation matrix, which the tutorial i am looking at suggests I use a 4x4 matrix, that is I don't really know much about rotation matrices, but I always assumed they only needed to be 3x3. Whats with the 0's and 1 at the bottom, right?, and do I need to use them? thanks

Share this post

Link to post
Share on other sites
songho    268
The bottom row of 4x4 matrix is used for projective transformation. If you do only rigid body rotations, then you only need 3x3 part that you mentioned. Therefore, the last row can remain as (0,0,0,1).

Share this post

Link to post
Share on other sites
CheeseGrater    122
And the right column is used for translation.

In addition, if you plan to use these matrixes in a OpenGL or D3D they'll need to be 4x4.

If you're just using it as an interia tensor, you'll only need the 3x3. I tend to use a class for each, then a generic class for larger or non-square matrices.

Share this post

Link to post
Share on other sites
JoeJ    2572
The right column may be used or translation.
Be alarmed that different APIs or tutorials may require the matrix has swapped columns and rows.
I always think of an 3x3 rotation matrix as three 3d vectors. if you multiplicate each vector with the aproperiate xyz values from a 3d point an sum the result, its easy to imagine how the rotation works.

Share this post

Link to post
Share on other sites
remdul    176
[r 0 0][r 1 0][r 2 0][ p.x ]
[r 0 1][r 1 1][r 2 1][ p.y ]
[r 0 2][r 1 2][r 2 2][ p.z ]
[ 0 ][ 0 ][ 0 ][scale]
Where "r" is rotation 3x3 matrix, "p" is position and "scale" is uniform scale (X, Y and Z).

You can also store the scale for individual axis in the rotation diagonal, that is:
[ s.x ][  0  ][  0  ]
[ 0 ][ s.y ][ 0 ]
[ 0 ][ 0 ][ s.z ]
But is hard to do combine both rotation and scale this way in practice, better store scale seperately.

Also usefull are:

Up/down vector:
[  0  ][ v.x ][  0  ]
[ 0 ][ v.y ][ 0 ]
[ 0 ][ v.z ][ 0 ]
Right/left Vector:
[ v.x ][ v.y ][ v.z ]
[ 0 ][ 0 ][ 0 ]
[ 0 ][ 0 ][ 0 ]
Back/front Vector:
[  0  ][  0  ][ v.x ]
[ 0 ][ 0 ][ v.y ]
[ 0 ][ 0 ][ v.z ]

(Assuming OpenGL matrix orientation in this post)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this