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

This topic is 4230 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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 on other sites
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 on other sites
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 on other sites
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 on other sites
Or:
[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)

1. 1
Rutin
23
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 9
• 33
• 41
• 23
• 13
• ### Forum Statistics

• Total Topics
631745
• Total Posts
3002000
×