#### Archived

This topic is now archived and is closed to further replies.

# Matrix Math

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

## Recommended Posts

If I have a vector that is supposed to represent a rotation about an object''s x axis, how can I turn that into a rotation matrix?

##### Share on other sites
If you mean that the x rotation is the x value of the vector, etc. you would use the X rotation matrix:
{1,0 ,0 ,0
0, cos(x),sin(x),0
0,-sin(x),cos(x),0
0,0 ,0 ,1}

y:
{cos(y),0,-sin(y),0
0 ,1,0 ,0
sin(y),0, cos(y),0
0 ,0,0 1}

z: same as x, shift elements into the top 4 positions.

For the full rotation, multiply all together.

What is a man without goals? A dead man.

I don''t :p

##### Share on other sites
How does the vector represent the rotation? Is it a quaternion?

- WitchLord

##### Share on other sites
I''m trying to load a model from truespace, and I''ve almost got it, I just need to figure out how to use the vectors they have for the models local rotation with its transform matrix.
So each data object consists of:
center, 0,0,0
X Axis, 0,0,0
Y Axis, 0,0,0
Z Axis, 0,0,0
Transform, ..... A left-handed matrix with the columns and rows reversed.

If I just transform the model by the transform matrix it works fine most of the time...but some models come out rotated wrong, with body parts strewn all about And by looking at the data in the file I have to conclude that it''s because I''m not taking the X,Y, or Z axis vectors into account. But I''m not sure how I would apply them to the transform matrix.....Hope this comes out semi-coherent

##### Share on other sites
My guess is that you should first compute the vertex coordinates like this

V'' = V.x*XAxis + V.y*YAxis + V.z*ZAxis + Center

Then transform V'' with the transform matrix.

- WitchLord

• 15
• 13
• 35
• 39