PDA

View Full Version : Multiple Rotations fail...

jrbcast
08-29-2001, 08:27 AM
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 );

Coconut
08-29-2001, 10:51 AM
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.

08-29-2001, 11:39 AM
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.

shoot
08-31-2001, 09:38 AM
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

jrbcast
08-31-2001, 02:24 PM
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...

zed
08-31-2001, 03:23 PM
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

jrbcast
08-31-2001, 04:04 PM
Everyday you learn something. THANKS TO NAPOLEON :-)

Thanks to you too.

mathx
09-01-2001, 06:00 AM
Hello,

Hey JrbCast, where are u from?

Cya,
Matheus.

jrbcast
09-01-2001, 08:03 AM
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?.

mathx
09-02-2001, 04:15 AM
Hello,

Not really, I asked because of the names of the variables, I thought you`d maybe be from Brazil. http://www.opengl.org/discussion_boards/ubb/smile.gif

Cya,
Matheus.