Translation and Rotation
I have a set of position and rotation data of a model
and I need to rotate it 90 around the x axis.
I have an understanding of the concepts of what i need to do.
I need to translate to the origin, perform the rotation, and translate back to my position.
I have working translate and rotate functions from a math lib and they are defined as follows, they work in similar fashion to glrotate and gltranslatef
void mat4_Translate(float x, float y, float z, mat4_t m)
void mat4_Rotate(float angle, float x, float y, float z, mat4_t m)
My main problem is im not sure the sequence and usage of these functions
I copy all of my data into a matrix, like so.
m[0] = t.rot[0][0];
m[1] = t.rot[0][1];
m[2] = t.rot[0][2];
m[3] = 0;
m[4] = t.rot[1][0];
m[5] = t.rot[1][1];
m[6] = t.rot[1][2];
m[7] = 0;
m[8] = t.rot[2][0];
m[9] = t.rot[2][1];
m[10] = t.rot[2][2];
I assume in then simply use the functions in the following fashion
// Translate to Origin
mat4_Translate(t.pos[0]*-1, t.pos[1]*-1, t.pos[2]*-1, m);
// Perform rotation along X axis
mat4_Rotate(90, 1, 0, 0, m);
// Translate back to orginal position
mat4_Translate(t.pos[0], t.pos[1], t.pos[2], m);
The result i'm getting however, is that the objects seem to swing along a wide arc. Which make me think that they are not in fact being rotated about the origin.
So my problem is here
// Translate to Origin
mat4_Translate(t.pos[0], t.pos[1], t.pos[2], m);
What is the correct usage of this, in order to translate back to the origin
Thanks
[edited by - DMonaghan on November 26, 2003 3:36:33 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement