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[] = { cycz , sxsycz-cxsz , cxsycz+sxsz , 0 ,
cy
sz , sxsysz+cxcz , cxsysz-sxcz , 0 ,
-sy , sxcy , cxcy , 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 );

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.

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.

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

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…

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

Everyday you learn something. THANKS TO NAPOLEON :slight_smile:

Thanks to you too.

Hello,

Hey JrbCast, where are u from?

Cya,
Matheus.

Originally posted by mathx:
[b]Hello,

Hey JrbCast, where are u from?

Cya,
Matheus.[/b]

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

Hello,

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

Cya,
Matheus.