PDA

View Full Version : Kinda difficult to rotate



04-13-2002, 08:43 AM
I'm trying to create a 90deg bend using glRotate and gluDisk. I'm rotating the plane about x-axis. The problem is, the disk is rotated about it's centre(centre of the disk is x=0). But I want to rotate the plane parallel to X-axis.

How to achieve this?

Source code follows

.......
for (theta=0; theta<=20; theta=theta+0.5)
{
glRotatef(0.5,1,0,0);
gluDisk(quadric,0.8,1,32,32);
}

Thanks in advance

V-man
04-13-2002, 12:07 PM
glRotatef(90.0, 1.0, 0.0, 0.0); or
glRotatef(90.0, 0.0, 1.0, 0.0); or
glRotatef(90.0, 0.0, 0.0, 1.0);

Did you try those?

V-man

04-14-2002, 10:45 PM
>glRotatef(90.0, 1.0, 0.0, 0.0); or
>glRotatef(90.0, 0.0, 1.0, 0.0); or
>glRotatef(90.0, 0.0, 0.0, 1.0);

>Did you try those?

All the above rotates the disk about it's centre. But I want to rotate the disk about a point which is on the cricumference of the disk

Bob
04-15-2002, 12:36 AM
First transate the disk so the point of rotation is located at the origin, then rotate, then translate back. If the point of rotation is (x, y, z), you should do something like this.



glTranslate(x, y, z);
glRotate(...);
glTranslate(-x, -y, -z);

04-15-2002, 02:02 AM
I guess it's like this. I'm rotating the drawing plane and then drawing the disk. gluDisk takes the origin from the current matrix(i think). I have given the code in my first posting. Hope it will throw some light.

Deiussum
04-15-2002, 04:30 AM
Bob's suggestion should work. Basically, you need to translate so that the point you want to rotate around is at 0,0,0, then rotate, then undo the translation you did. Keeping in mind that when you think it terms of world coordinates, what you do last is applied first. (i.e. glTranslate();glRotate(); // glRotate is applied first)