PDA

View Full Version : Rotating around z-axis



glcrazy
12-10-2003, 09:57 AM
Hi http://www.opengl.org/discussion_boards/ubb/smile.gif

I wrote a code that let a certain shape to rotate a round z-axis. It works but I was confused Is What I see is really rotating around the z-axis ??!! how to make sure ?

the steps that I followed are as following:

1.set the angle to 0.
2. increase the value of the angle by 0.01 every frame.
3.Rotate the (sphere for example) by
angle = angle,
x = cos(angle)*(-0.5)-sing(angle)*(-0.5)
y = cos(angle)*(-0.5)+sing(angle)*(-0.5)
z = 1.
where the intial value for x = -0.5 & y = -0.5 .

Am I right so far ??

Thanks in advance for any help.

ZbuffeR
12-10-2003, 12:58 PM
Originally posted by glcrazy:
x = cos(angle)*(-0.5)-sing(angle)*(-0.5)
y = cos(angle)*(-0.5)+sing(angle)*(-0.5)
z = 1.

With that you rotate the axis around which you turn... well, a bit complex.
If you want to rotate around only z axis, just do :
glRotated(angle,0.0,0.0,1.0);

You will probably see the difference.

glcrazy
12-13-2003, 01:51 AM
Hi ZbuffeR

As I see both methods work in the same way I mean rotate the chosen object around z-axis ..

Thank you http://www.opengl.org/discussion_boards/ubb/smile.gif