Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Rotation Matrices

  1. Jan 19, 2009 #1


    User Avatar

    So, I've been fiddling around with a computer game (not the most productive use of my time, I know) and I've come across a problem that seems to have broader mathematical import, and most certainly has been found before, so I thought I'd ask about it here.

    Basically I need to rotate an object (well group of objects) using rotation around the X, Y, and Z axes, in that order) to match a rotation around the Z, X, and Y axes, also in that order. Now doing the brute force method of multiplying the matrices through and solving the resulting system of equations will work, but lacking access to mathematica or the like, it's going to kill a lot of trees. And considering my propensity for simple errors, cause a lot of frustration as well. But I'm guessing there's some sort of neat trick or higher level math way of looking at this that will make things a lot quicker and be a lot more insightful. Any ideas?

    Put more mathematically, I need to find [tex]\Theta_{1},\Theta_{2},\Theta_{3}[/tex] such that [tex]X(\Theta_{1})Y(\Theta_{2})Z(\Theta_{3})[/tex] equals [tex]Z(\Phi_{1})X(\Phi_{2})Y(\Phi_{3})[/tex] where [tex]\Phi_{i}[/tex] are constants.

    X, Y, Z are 3x3 rotation matrices around the given axis, i.e. the Z matrix would be:
    \[ \left( \begin{array}{ccc}
    cos(\Theta) & -sin(\Theta) & 0 \\
    sin(\Theta) & cos(\Theta) & 0 \\
    0 & 0 & 1 \end{array} \right)\]
  2. jcsd
  3. Jan 20, 2009 #2

    D H

    Staff: Mentor

    This paper, http://www.atacolorado.com/eulersequences.doc looks like it has what you want.

    Beware: There a lot of places to get mixed up here:
    • Rotation is the transpose of transformation. One consequence: Rotation sequences chain left to right, transformation matrices chain right to left.
    • Euler angles have singularities. The singularities are one reason why your desired simple trick is a bit of a challenge.
    • Why are you using Euler angles, anyhow? They're evil.
  4. Jan 20, 2009 #3
    Someone here finds them difficult?
    Last edited: Jan 20, 2009
  5. Jan 21, 2009 #4


    User Avatar
    Gold Member

  6. Jan 24, 2009 #5


    User Avatar

    Well I was using Euler matrices because I didn't know any better tool to use. But the link on quaternions you posted, Daniel, sure looks handy. Thank you. Between that and the Euler Secuences doc DH posted I should manage to figure out the proximate problem shortly. I'm wondering though if anyone knows of a good source for reading up on the theory behind them; I'm as interested in the mathematics as the implementation.
  7. Jan 24, 2009 #6

    D H

    Staff: Mentor

    This book is fairly good: Quaternions and Rotation Sequences: A Primer with Applications to Orbits, Aerospace, and Virtual Reality, Jack B. Kuipers.

    There are a number of gotchas with quaternions as well: scalar first or last, rotation versus transformation, left versus right.

    Scalar first or last: One way to look at quaternions is as a real scalar and an imaginary vector (think of them as an extension of complex numbers). Alternatively, you could represent them as an imaginary vector and a real scalar. I use the scalar+vector form:

    [tex]{\mathcal Q} = \bmatrix s \\ {\boldsymbol v} \endbmatrix[/tex]

    Others use the vector+scalar form:

    [tex]{\mathcal Q} = \bmatrix {\boldsymbol v} \\ s \endbmatrix[/tex]

    There's no reason to pick one convention over the other, and both are in use. It is important (*very important*) to determine which convention is in use when you are exchanging quaternions with some other organization.

    Rotation versus transformation: Imagine making two 2D coordinate system grids on two pieces of clear plastic. Mark a spot on a white sheet of paper. Put the plastic overlays on top of the paper so the origins are co-located and axes co-aligned and so that the marked spot is not at the common origin. Now rotate the top overlay. Imagine that instead of using two overlays you had used just one. A rotation matrix describes this physical rotation of an object to another orientation. With two sheets, you can read off the coordinates of the marked point in each of the two coordinate systems. A transformation matrix describes the mathematical transformation of a representation from one coordinate system to another. The rotation and transformation matrices in this example are transposes of one another. This concept extends to higher dimensions. Rotation and transformation quaternions are similarly conjugates of one another.

    Left versus right quaternions: A quaternion can be used to transform a 3-vector via

    \bmatrix 0 \\ {\boldsymbol x'} \endbmatrix =
    {\mathcal Q} \bmatrix 0 \\ {\boldsymbol x} \endbmatrix {\mathcal Q}^{\ast}

    or via

    \bmatrix 0 \\ {\boldsymbol x'} \endbmatrix =
    {\mathcal Q}^{\ast} \bmatrix 0 \\ {\boldsymbol x} \endbmatrix {\mathcal Q}

    The unconjugated quaternion is to the left of the vector to be transformed in the first form but to the right of the vector in the second form: left versus right. Left transformation quaternions chain like transformation matrices (right to left). Right transformation quaternions chain left to right. I've been involved in incredibly stupid arguments over which approach is correct. The math comes out fine either way; both are equally valid. The distinction becomes important if you are exchanging quaternions with some other group.
  8. Jan 31, 2009 #7
    There are some diagrams at the following site:

    Rotation Matrices Utility

    The Z-matrix looks like your result.
    Not sure about the others; you might have to alter them somewhat, but at least there are some nice diagrams to give you an idea how things are worked out. Plus the page outputs some numbers, so you could confirm your own results.

    If you get more seriously into game development, you might also want to check out gamedev.net.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Rotation Matrices
  1. Matrices ? (Replies: 6)

  2. Rotation Matrices (Replies: 1)

  3. On Matrices (Replies: 8)