Transformations
How do I rotate an object around it's own local coordinate system rather than the world system?
i.e. if I have a plane flying up and to the right and I want it to pull up a bit, how do I rotate it around it's local x axis rather than the global one which will be completly different.
Thanks
Make sure you rotate the object before transforming it in the real world.
Translate x Rotate != Rotate x Translate
Translate x Rotate != Rotate x Translate
Quote:Make sure you rotate the object before transforming it in the real world.
Translate x Rotate != Rotate x Translate
Yeah I know, but I'm actually transforming a vector which is pointing in the direction of travel. so the vector always originates from (0,0,0) but just rotates. What I need is to rotate the vector coordinate system so that every time to object rotates, it rotates relative to it's last position.
You shouldn't be rotating the spaceship's position vector at all if it is to rotate about its local axes. If the only vector you're using is based around the global origin (it will be a position vector), you'll need to introduce another vector to represent the ship's orientation.
What are you using to render and how many dimensions are you working in?
If you're using a 3D API (or any matrix based geometry), make the translate call before the rotate call.
What are you using to render and how many dimensions are you working in?
If you're using a 3D API (or any matrix based geometry), make the translate call before the rotate call.
If you want to rotate some object around (x,y), instead of (0,0), you translate the object by (-x,-y), perform the rotation, then translate it by (x,y).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement