PDA

View Full Version : Simple Rotation Problem



MSynth2000
03-12-2010, 10:32 AM
I would like to rotate a polygon (drawn by glutSolidCube) in a 3D enviroment. Suppose the white dot is the front view of X axis, my question is, I want to rotate it in this way:

http://img.photobucket.com/albums/v114/rexthk/Untitled-1.jpg

instead of in this way:

http://img.photobucket.com/albums/v114/rexthk/Untitled-2.jpg

just like the hour hand spinning around the clock center.

Maybe it is a simple question but I cannot figure it out. Hope you guys can help me. Thanks a lot:)

Pziko
03-12-2010, 01:52 PM
You need to translate before you rotate, probably by half the width of the polygon.

MSynth2000
03-12-2010, 06:15 PM
You need to translate before you rotate, probably by half the width of the polygon.

Thanks Pziko:) Would you please specify more? Since i am a newbie I don't understand this concept.

beginnertom
03-12-2010, 06:39 PM
i doubt
this problem is about scalef.

Ehsan Kamrani
03-13-2010, 02:40 AM
You need to translate before you rotate, probably by half the width of the polygon.

Thanks Pziko:) Would you please specify more? Since i am a newbie I don't understand this concept.

Actually you need to first rotate and then traslate your objects if you want to rotate around the world coordinate system.
You need to think about local coordinate system and move from top to bottom. For example:
R1
T1
rotates the coordinate system first and then translates it.However the following order:
T1
R1
translates the local coordinate and then rotates it around itself, so you don't get that desired effect.

MSynth2000
03-14-2010, 06:41 PM
Thanks for your kind help :) I will keep trying with the method you guys provided.

I have another problem. That is, when I rotate my polygon (drawn by glutSolidCube), the shape of the polygon has changed to parallelogram shape. How do I maintain the shape during rotation?
Please be reminded that it is a 3D world.

Ehsan Kamrani
03-14-2010, 08:05 PM
you need to specify the Projection Transform using gluPerspective() and pass correct aspect ratio to it.For example you can use:
gluPerspective( 45.f, double( m_width ) / double( m_height ), 1., 10000. );
m_width and m_height are the width and height of the window respectively.