1. ## Multiple Rotations fail...

Hi everybody...

Here is my problem...

I have a cone in my 3d space pointing to Z positive axix.

I want to rotate it like that:
first i want to rotate 270 degrees around X axe.
Second I want to rotate 90 degrees around Y axe but using the original Y axe not the new axe resulting from the first rotation.

Ive tried next:

GlRotatef( figura->alfa() , 1.0 , 0.0 , 0.0 );
glRotatef( figura->beta() , 0.0 , 1.0 , 0.0 );
glRotatef( figura->gamma() , 0.0 , 0.0 , 1.0 );

but i get the problem with the Y axe rotated so I tried with basic Matrix:

GLfloat maux[] = { cy*cz , sx*sy*cz-cx*sz , cx*sy*cz+sx*sz , 0 ,
cy*sz , sx*sy*sz+cx*cz , cx*sy*sz-sx*cz , 0 ,
-sy , sx*cy , cx*cy , 0 ,
0 , 0 , 0 , 1 };

where cx,cy,cz are the cos() of x,y,z respectively and sx,sy,sz are the sin(). And Again I get the same problem...

What can I do to fix that?

Thkx

gluCylinder( obj , figura->_radio() , 0 , altura , 20 , 20 );
gluDisk( obj , 0 , figura->_radio() , 20 , 5 );

2. ## Re: Multiple Rotations fail...

I did not look into your matrix.
However, what you need to do is to figure out the direction of the old Y-axis in the coordination system after 270 degrees rotation about X-axis, and then you rotate 90 degrees about that direction.

3. ## Re: Multiple Rotations fail...

You'll have do do your own matrix maths if you want to do that. Its the order of the multipliction thats important and OpenGL allows for only one.

4. ## Re: Multiple Rotations fail...

Hello!!
Be aware that openGL multiply matrices in inverse order... that means... that you have to do any transformations in inverse order too.

That is... if you wants to transalte, and then rotate... the code it must be something like this:
glPushMatrix();
glRotated(....);
glTranslatef(..);
//geometry definition
glPopMatrix();

Now try to do your rotations but in inverse order:
glRotatef( figura->gamma() , 0.0 , 0.0 , 1.0 );
glRotatef( figura->beta() , 0.0 , 1.0 , 0.0 );
GlRotatef( figura->alfa() , 1.0 , 0.0 , 0.0 );

I think it'll work properlly now
MARC

5. ## Re: Multiple Rotations fail...

Thanks all of you. Its been very useful for me. Zadkiel, i had read something about the inverse order but i didnt understand it. Now its clear and it works so it was the trick about transformations under OpenGL.

Qhy the hell everything is upside down in OpenGL. Was it written by english people? (I said that because they drive the wrong side) . Thats only a joke.

Thanks again...

6. ## Re: Multiple Rotations fail...

http://web2.airmail.net/sjbaker1/omniv.html
check out eulars are evil

actually everyone used to driver/ride on the lefthand side of the road , until napoleon decree it to be the oppposite

7. ## Re: Multiple Rotations fail...

Everyday you learn something. THANKS TO NAPOLEON

Thanks to you too.

8. ## Re: Multiple Rotations fail...

Hello,

Hey JrbCast, where are u from?

Cya,
Matheus.

9. ## Re: Multiple Rotations fail...

Originally posted by mathx:
Hello,

Hey JrbCast, where are u from?

Cya,
Matheus.
Im from Spain. I Supouse you asked about it because my awful english, did you?.

10. ## Re: Multiple Rotations fail...

Hello,

Not really, I asked because of the names of the variables, I thought you`d maybe be from Brazil.

Cya,
Matheus.

#### Posting Permissions

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