#### Archived

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

# Basic transformation problem

This topic is 5571 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 problem where my model is defined at the coordinate origin and I want to translate it then rotate it about the coordinate origin. If I rotate then translate then obviously all rotations will have the affect of rotating the model about its centre wherever it is in the world. So naturally I reverse the order so I am translating then rotating the model. All is well apart from when I go to translate the model again after having it rotated, only to find the model moving in the wrong direction. For example, if I keep translating along the x axis then rotate 90 degress about the Y axis the model will move backwards instead of left. I know why this is happening but I can''t find a fix. I''m sure countless people have come up against this basic transformation problem. Any thoughts.

##### Share on other sites
To shed some light on my question, I should probably being asking how do I rotate an object about an arbitrary point that is defined in modelling coordinates at the world origin (its centre is being at the world origin), and have translations appear as expected. There is a D3D function called
D3DXMatrixTransformation() that might to the trick.

##### Share on other sites
i dont know anything about direct x but in opengl i would translate to where i wanted to draw it, rotate to the approppriate angle, draw it, then rotate back to where i was and continue with my transformations. the opengl code if this helps:

glMatrixMode(GL_MODELVIEW); //select the matrix to do with rotations and transformations
glLoadIdentity(); //move to the origin, looking in the negative z direction

glTranslatef(obj_x, obj_y, obj_z); //move to the object position
glPushMatrix() //remember my current transformations
glRotatef(axis_x, axis_y, axis_z, angle); //rotate however much you want

//draw the object, it will be rotated by angle about axis

//restore transformation matrix to what it was before the rotation and continue drawing
glPopMatrix();

HTH

##### Share on other sites
Just to state the obvious...
    T1, R1, T2, R2

do this...
    T1, T2, R1, R2

or this (ugly)...
    T1, R1, -R1, T2, R1, R2

It sounds to me like the problem is that all your transformations are in world space. If you "nest" your transformations (i.e. local vs global), you don't have to worry about reordering or undoing previous rotations.

[edited by - Jambolo on June 20, 2003 1:54:39 PM]

##### Share on other sites
I'll give that a try, thanks.

[edited by - level10boy on June 21, 2003 11:19:49 AM]

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
14
5. 5

• 12
• 9
• 17
• 19
• 9
• ### Forum Statistics

• Total Topics
632599
• Total Posts
3007335

×