Sign in to follow this  
elih1

some 3d questions

Recommended Posts

elih1    122
Hi
I am trying the grasp some concepts for very long time, but unfortunately the more I read the more confused I get. The following things are very unclear to me :

1) Does 3d rotation order matters? I read that the rotation order matters, but if the object is placed at the world origin then doesn't matter. Is this correct?

2) What does it mean to rotate object around global axis ? And what does it mean to rotate around its local axis?

Say if I have object that I want to rotate 90 degrees around global x, and 90 degrees around global z axis how should i write that code with opengl ?

And same question if I want to rotate the object 90 degrees around its local x axis, and 90 degrees around its local z axis how to write the code ?

Share this post


Link to post
Share on other sites
lauris71    841
[quote name='elih1' timestamp='1313748348' post='4851130']
Hi
I am trying the grasp some concepts for very long time, but unfortunately the more I read the more confused I get. The following things are very unclear to me :

1) Does 3d rotation order matters? I read that the rotation order matters, but if the object is placed at the world origin then doesn't matter. Is this correct?

2) What does it mean to rotate object around global axis ? And what does it mean to rotate around its local axis?

Say if I have object that I want to rotate 90 degrees around global x, and 90 degrees around global z axis how should i write that code with opengl ?

And same question if I want to rotate the object 90 degrees around its local x axis, and 90 degrees around its local z axis how to write the code ?
[/quote]

1. Yes it does, rotating first around X then Y gives different effect, than rotating first around Y, then X

2. Usually you have some "world" coodinate system for your game. Global axis the axis of such coordinate system - for example Z axis is vertical. Local axis is the local coordinate system of object. For example, local Z axis of a character may be the "vertical" axis of body (from head to feet). If character is standing, global and local axes coincide, but if character is lying on bed, local Z axis is horisontal.

The old (now deprecated) way to apply rotation in OpenGl is using glRotate* methods. But I'd suggest you to pick some matrix/vector library (you will need it anyways) and use the methods from there.

In most general way, the matrix math behind such transformations is:

Mo' = Mry * Mrx * Mo - rotates object first around global X, then around global Y
Mo' = Mrx * Mry * Mo - rotates object first around global Y, then around global X
Mo' = Mo * Mry * Mrx - rotates object forst around local X, then around (old) local Y
Mo - transformation of your object (local coordinate system)
Mrx - rotation matrix around X axis
Mry -rotation matrix around Y axis
Mo' - new transformed local coordinate system of object

All matrix libraries have some specific methods for doing these elemntary transformations, but the exact syntax varies

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this