Solve Rotation Matrices w/ X, Y, Z Axes

In summary: They've got a lot of resources there, and even if you're not developing games, you might find tools there that are interesting.In summary, Fiddling with a computer game has led to a problem involving rotating an object using different axes. While the brute force method is possible, it is not efficient and may lead to errors. A potential solution is using quaternions, which allow for smoother interpolation and avoid gimbal lock, but there are also some challenges with different conventions and approaches. A recommended source for further reading is the book "Quaternions and Rotation Sequences: A Primer with Applications to Orbits, Aerospace, and Virtual Reality" by Jack B. Kuipers.
  • #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]
 
Mathematics news on Phys.org
  • #2
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
D H said:
[*]Why are you using Euler angles, anyhow? They're evil.[/list]
Someone here finds them difficult?
[:-)]
 
Last edited:
  • #4
Try using quaternions:
http://www.cprogramming.com/tutorial/3d/quaternions.html"
They let you interpolate more smoothly between rotations and save you from the notorious gimbal lock.
 
Last edited by a moderator:
  • #5
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
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
There are some diagrams at the following site:

http://www.akiti.ca/RotateTrans.html"

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:

What are rotation matrices?

Rotation matrices are mathematical representations of rotations in three-dimensional space. They are used to describe the orientation of an object relative to a fixed coordinate system.

What do X, Y, Z axes represent in rotation matrices?

X, Y, Z axes in rotation matrices represent the three perpendicular axes in three-dimensional space. X axis represents the horizontal axis, Y axis represents the vertical axis, and Z axis represents the depth or distance axis.

How are rotation matrices used to solve for rotations?

Rotation matrices are multiplied with the coordinates of an object to rotate it in three-dimensional space. By changing the values in the rotation matrix, different rotations can be achieved.

What is the order of rotation in rotation matrices?

The order of rotation in rotation matrices is important. The rotations are performed in the order of X, Y, and Z axes. This means that the object will first rotate around the X axis, then around the Y axis, and finally around the Z axis.

What are the properties of rotation matrices?

Rotation matrices have several important properties, including orthogonality, determinant of 1, and the fact that they preserve distances and angles. These properties make rotation matrices useful in various fields such as computer graphics, robotics, and physics.

Similar threads

  • General Math
Replies
2
Views
2K
Replies
2
Views
761
Replies
2
Views
1K
Replies
5
Views
2K
Replies
2
Views
635
Replies
7
Views
1K
Replies
1
Views
1K
Replies
6
Views
1K
  • Quantum Physics
Replies
1
Views
201
Back
Top