Results 1 to 10 of 10

Thread: Multiple Rotations fail...

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2001
    Location
    Almeria, Spain
    Posts
    26

    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. #2
    Senior Member Regular Contributor
    Join Date
    Apr 2011
    Posts
    288

    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. #3
    Member Contributor
    Join Date
    Aug 2000
    Posts
    68

    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. #4
    Junior Member Newbie
    Join Date
    Oct 2000
    Location
    Barcelona
    Posts
    18

    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. #5
    Junior Member Newbie
    Join Date
    Aug 2001
    Location
    Almeria, Spain
    Posts
    26

    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. #6
    Senior Member OpenGL Guru zed's Avatar
    Join Date
    Nov 2010
    Posts
    2,466

    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. #7
    Junior Member Newbie
    Join Date
    Aug 2001
    Location
    Almeria, Spain
    Posts
    26

    Re: Multiple Rotations fail...

    Everyday you learn something. THANKS TO NAPOLEON

    Thanks to you too.

  8. #8
    Junior Member Newbie
    Join Date
    Jul 2001
    Location
    Brazil
    Posts
    16

    Re: Multiple Rotations fail...

    Hello,

    Hey JrbCast, where are u from?

    Cya,
    Matheus.

  9. #9
    Junior Member Newbie
    Join Date
    Aug 2001
    Location
    Almeria, Spain
    Posts
    26

    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. #10
    Junior Member Newbie
    Join Date
    Jul 2001
    Location
    Brazil
    Posts
    16

    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.

Similar Threads

  1. Replies: 1
    Last Post: 11-15-2017, 12:14 PM
  2. vkCreateSwapchainKHR Fail
    By Amir_KB in forum Vulkan
    Replies: 1
    Last Post: 09-15-2017, 04:51 AM
  3. Multisampling fail
    By dukey in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 12-15-2010, 07:36 AM
  4. Rotations in multiple axes
    By conormcc in forum OpenGL: General
    Replies: 2
    Last Post: 06-07-2009, 08:02 AM
  5. Mathematics of rotations, why does this fail?
    By ax_deimos in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-19-2001, 04:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean