The Industry's Foundation for High Performance Graphics

1. Simple Rotation Problem

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:

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

2. Re: Simple Rotation Problem

You need to translate before you rotate, probably by half the width of the polygon.

3. Re: Simple Rotation Problem

Originally Posted by Pziko
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.

i doubt

5. Re: Simple Rotation Problem

Originally Posted by MSynth2000
Originally Posted by Pziko
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.

6. Re: Simple Rotation Problem

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.

7. Re: Simple Rotation Problem

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.

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•