Results 1 to 6 of 6

Thread: Rotations sequences

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2009
    Posts
    5

    Rotations sequences

    hello everyone, i got a problem with rotation matrices multiplication and i hope someone could help me tofigure that out...

    So say that i want to perform a sequence of rotation in order xyz. Since opengl pre-multiplied it means that it's multiplying in this way:

    Rz * Rx * Ry

    now i've implemented the matrix Rz * Ry * Rx on my own and it looks exactly like the xyz matrix in the Matrix Table at the bottom of this link:

    http://en.wikipedia.org/wiki/Euler_angles

    comparing the two rotations i figured out that this matrix perform the following opengl sequence of rotation:

    glRotated(az,0,0,1)
    glRotated(ay,0,1,0)
    glRotated(ax,1,0,0)


    How is this possible? Where am I wrong?
    thanks a lot

  2. #2
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,214

    Re: Rotations sequences

    Nothing is wrong!

    If we assume rotation matrices are denoted in the following way:

    glRotated(az,0,0,1) = Rz
    glRotated(ay,0,1,0) = Ry
    glRotated(ax,1,0,0) = Rx

    when you call glRotated(az,0,0,1) you, in fact, multiply matrix on the top of the current matrix stack (probably MODELVIEW) with your matrix Rz (right side multiplication)

    C' = C * Rz

    If you cumulatively multiply with Rz, Ry and Rx, respectively, the result is

    C" = (((C * Rz) * Ry) * Rx)

    So, new position of the vertex (i.e. resulting vector) after being transformed by resulting matrix is:

    v' = (((C * Rz) * Ry) * Rx) * v = (C * (Rz * (Ry * (Rx * v))))

    If you are "thinking in global coordinate-system", vertex is first rotated around X-axis (in global coordinate-system), than around Y and at last around Z-axis of global coordinate-system.

    If you are "thinking in local coordinate-system", local coordinate-system is first rotated around Z-axis (both global and local systems are the same at this moment), than around local Y and at last around local X-axis.

    The final result is the same. Only "the way of thinking" differs.

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2009
    Posts
    5

    Re: Rotations sequences

    thanks a lot you really helped me out with this...
    By the way I kind of don't understand why given a sequence xyz inverting the order to RzRyRx give a rotation around the global axis (axis that never change position right???) and RxRyRz produce a rotation around the local axis?

  4. #4
    Senior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Los Angeles
    Posts
    374

    Re: Rotations sequences

    Quote Originally Posted by memecs
    ... I kind of don't understand why given a sequence xyz inverting the order to RzRyRx give a rotation around the global axis (axis that never change position right???) and RxRyRz produce a rotation around the local axis?
    Neither of those statements is true. In both cases, you have Euler rotation sequences, which are neither global nor local. To achieve true global (which I call 'screen') or local rotations you have to take quite a different approach.
    Am I doing your homework for you?

  5. #5
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,214

    Re: Rotations sequences

    Let's make everything much clearer...

    When you draw your objects, coordinates of the vertices are usually defined in so called local coordinate-system. The center of the local coordinate-system is located in the center of the object, or at the lower-left corner of the bounding box, or at some vertex, or something like that. The point of this is that you can model your objects locally and then translate/rotate/scale so that they are placed at appropriate position on the scene. If there is no transformation, objects will reside in the center of global (world) coordinate-system.

    If we want to apply some transformations to the object, than we would write something like this:

    Transf1();
    Transf2();
    Transf3();
    DrawObject();

    Because of the right matrix multiplication (take a look at the previous post), object will be transformed by Transf3() firstly, if you think in terms of global coordinate-system, than by Transf2() and at last by Transf1(). So, transformations are applied in reverse order.

    But if we assume that transformations in fact transforms local coordinate-system, than local coordinate-system will be transformed by Transf1() firstly, than by Transf2(), and at the end by Transf3(). Now, transformations appear in the natural order. After all three transformations our local coordinate-system is transformed (translated/rotated/scaled) and will create/draw our object in such "awry" local coordinate-system. You can imagine the local coordinate-system as a coordinate-system tied to the object.

    In both cases the transformations are exactly the same!

  6. #6
    Junior Member Newbie
    Join Date
    Aug 2009
    Posts
    5

    Re: Rotations sequences

    thanks a lot everyone i think a got it now...

Similar Threads

  1. Loading image sequences in real time
    By saam_b in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-28-2012, 03:58 AM
  2. Image Sequences/Movies
    By Rasson in forum COLLADA
    Replies: 5
    Last Post: 10-28-2010, 02:26 PM
  3. Rotations- help?
    By cloudy in forum OpenGL: Linux
    Replies: 4
    Last Post: 08-07-2009, 10:52 PM
  4. VP rotations
    By MojoMagic in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 02-25-2004, 07:12 PM
  5. Rendering sequences other than lists....
    By Freelancer in forum OpenGL: General
    Replies: 0
    Last Post: 02-24-2004, 04:47 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