Rotation Matrices

  • Thread starter Zal
  • Start date
  • #1
Zal
2
0
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:
[tex]
\[ \left( \begin{array}{ccc}
cos(\Theta) & -sin(\Theta) & 0 \\
sin(\Theta) & cos(\Theta) & 0 \\
0 & 0 & 1 \end{array} \right)\]
[/tex]
 

Answers and Replies

  • #2
D H
Staff Emeritus
Science Advisor
Insights Author
15,393
685
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.
 
  • #3
MathematicalPhysicist
Gold Member
4,308
216
[*]Why are you using Euler angles, anyhow? They're evil.[/list]
Someone here finds them difficult?
[:-)]
 
Last edited:
  • #4
daniel_i_l
Gold Member
867
0
Try using quaternions:
http://www.cprogramming.com/tutorial/3d/quaternions.html" [Broken]
They let you interpolate more smoothly between rotations and save you from the notorious gimbal lock.
 
Last edited by a moderator:
  • #5
Zal
2
0
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.
 
  • #6
D H
Staff Emeritus
Science Advisor
Insights Author
15,393
685
This book is fairly good: Quaternions and Rotation Sequences: A Primer with Applications to Orbits, Aerospace, and Virtual Reality, Jack B. Kuipers.
http://books.google.com/books?hl=en...ts=yVnCatNtiT&sig=rIrbN6mfsClRAiHkma1BBGLosWs

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

[tex]
\bmatrix 0 \\ {\boldsymbol x'} \endbmatrix =
{\mathcal Q} \bmatrix 0 \\ {\boldsymbol x} \endbmatrix {\mathcal Q}^{\ast}
[/tex]

or via

[tex]
\bmatrix 0 \\ {\boldsymbol x'} \endbmatrix =
{\mathcal Q}^{\ast} \bmatrix 0 \\ {\boldsymbol x} \endbmatrix {\mathcal Q}
[/tex]

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.
 
  • #7
98
2
There are some diagrams at the following site:

http://www.akiti.ca/RotateTrans.html" [Broken]

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.
 
Last edited by a moderator:

Related Threads on Rotation Matrices

  • Last Post
Replies
1
Views
1K
Replies
16
Views
18K
  • Last Post
Replies
6
Views
2K
  • Last Post
Replies
8
Views
2K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
3
Views
2K
  • Last Post
Replies
4
Views
2K
  • Last Post
2
Replies
33
Views
7K
  • Last Post
Replies
1
Views
1K
Top