Public Group

#### Archived

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

# Translation and Rotation

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

## Recommended Posts

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]

##### Share on other sites
you need to multiply your matrices locally.

##### Share on other sites
I'm not sure i understand, in fact i am sure i do not understand 8)

I dont actually use at maxtrices, except of course in this instance, since i need to do the rotation,.

[edited by - DMonaghan on November 26, 2003 3:20:57 PM]

1. 1
Rutin
31
2. 2
3. 3
4. 4
5. 5

• 13
• 53
• 11
• 10
• 14
• ### Forum Statistics

• Total Topics
632967
• Total Posts
3009553
• ### Who's Online (See full list)

There are no registered users currently online

×