# Angle between two orthogonal coordinate systems

1. Jun 23, 2014

### fannyfanfanz

If two orthogonal coordinate systems (xyz and x'y'z') share a common origin, and the angles between x and x', y and y', and z and z' are known. What is angle between the projection of z' on the xy plane and the x axis?

2. Jun 24, 2014

### fannyfanfanz

I've been thinking about this question for a couple days now. I have a hard time imagining and deriving it. Any help will be appreciated!

3. Jun 24, 2014

### marcusl

Have you made a diagram? Draw your two coordinate systems and draw the projection onto x-y first. You should be able to find the length of the projection, and its lengths x' and y' in the x-y plane, using trigonometry. The needed angle is then found from x' and y'.

4. Jun 24, 2014

### fannyfanfanz

Are you saying that
[(the projection of x' on xy plane)^2 + (the projection of y' on xy plane)^2] = (the projection of z' on xy plane)^2?

5. Jun 24, 2014

### marcusl

I'm not sure about that. Certainly this is true:
[(the projection of z' on x axis)^2 + (the projection of z' on y axis)^2] = (the projection of z' on xy plane)^2

6. Jun 24, 2014

### fannyfanfanz

But the angles between z' and x, z' and y are unknown.

7. Jun 24, 2014

### marcusl

Is this a homework problem?

8. Jun 24, 2014

### fannyfanfanz

No, it's not. It's related to my research project on light polarization, and I am stuck on this...

9. Jun 24, 2014

### D H

Staff Emeritus
Unfortunately, what you want cannot be fully determined from the information provided. This is easiest to see if you look at things from the perspective of a single axis rotation. Any sequence of rotations in three dimensional space can always be represented by a single rotation by some angle $\phi$ about some axis $\hat u$. The information that you have on hand leads to eight distinct single axis rotations.

The cosines of your angles form the diagonal of the transformation matrix from the (x,y,z) system to the (x',y',z') system. This provides enough information to determine the single axis rotation angle and the magnitudes of the elements of the rotation axis unit vector. It does not provide enough information to determine the signs of those elements.

The problem is that the diagonal elements of the transformation matrix are given by $T_{ii} = \cos\phi + (1-\cos\phi)\,u_i^{\,2}$. Summing those three elements results in $\operatorname{tr}(T) = 2\cos\phi+1$, so you can determine the single axis rotation rotation angle from the trace. However, the individual diagonal elements involve $u_i^2$. This means you can determine the magnitude of each $u_i$ but you can't determine the sign.

10. Jun 24, 2014

### fannyfanfanz

Thank you for your reply. I don't really understand your answer. Just trying to imagine these two orthogonal coordinate systems in my head, and you would think one would be able to determine that angle. I don't know, maybe I am wrong...

11. Jun 24, 2014

### D H

Staff Emeritus
You can't. Your data are ambiguous. There are four possible values for the angle between the x axis and the projection of the z' onto the xy plane.

For example, suppose the angles between x and x', between y and y', and between z and z' are all 60 degrees. This represents a single axis rotation by $\arccos(1/4) \approx 75.52^{\circ}$ about any one of eight axes, $\pm \hat x \pm \hat y \pm \hat z$. Each ± operates independently, so there are 2^3=8 possibilities. With regard to your specific angle, two different rotation axes yield the same angle, so there are four possibilities. You don't know if the angle is 20.9052°, 69.0948°, 110.9052°, or 159.0948°.

12. Jun 24, 2014

### fannyfanfanz

Could you please show me in detail how you could get 20.9052°, 69.0948°, 110.9052°, and 159.0948°?

13. Jun 24, 2014

### D H

Staff Emeritus
Here are two of the eight transformation matrices that have angles of 60° between x and x', between y and y', and between z and z':

$$\begin{pmatrix} \frac 1 2 & \frac {1+\sqrt5} 4 & \frac{1-\sqrt5} 4 \\ \frac {1-\sqrt5} 4 & \frac 1 2 & \frac {1+\sqrt5} 4 \\ \frac{1+\sqrt5} 4 & \frac{1-\sqrt5} 4 & \frac 1 2 \end{pmatrix}$$

$$\begin{pmatrix} \frac 1 2 & \frac {1-\sqrt5} 4 & \frac{-1-\sqrt5} 4 \\ \frac {1+\sqrt5} 4 & \frac 1 2 & \frac {-1+\sqrt5} 4 \\ \frac{-1+\sqrt5} 4 & \frac{-1-\sqrt5} 4 & \frac 1 2 \end{pmatrix}$$

Both are special orthogonal. In fact, all eight are.

Look at the bottom row of the first matrix. Projecting that unit vector onto the xy plane yields $(\frac{1+\sqrt5} 4, \frac{1-\sqrt5} 4, 0)$. The magnitude of that vector is $\frac {\sqrt 3} 2$. The inner product with the x axis is $\frac{1+\sqrt5} 4$. Thus the angle between the projection onto the xy plane and the x axis is $\arccos\left(\frac{1+\sqrt5}{2\sqrt 3}\right) \approx 20.9052^{\circ}$. Following the same procedure with the second matrix yields an angle of $\arccos\left(\frac{-1+\sqrt5}{2\sqrt 3}\right) \approx 69.0948^{\circ}$. There are six matrices left, but only two more will yield unique angles. The other four will yield duplicate values.

14. Jun 24, 2014

### fannyfanfanz

Thank you for your help! I am still a little confused, and I have several more questions.
For the example that you gave above, you said that "this represents a single axis rotation by arccos(1/4)." Where does the 1/4 come from?
How did you get [+/-1+/-sqrt(5)] / 4 in the transformation matrix?
What other information do I need to define that specific angle?

15. Jun 24, 2014

### D H

Staff Emeritus
From the trace of the matrix.

Let T be the matrix that transforms a vector as represented in the (x,y,z) system to the vector's representation in the (x',y',z') system. One way to look at this transformation matrix is the direction cosine matrix:

$$T = \begin{pmatrix} \hat x \cdot \hat x' & \hat y \cdot \hat x' & \hat z \cdot \hat x' \\ \hat x \cdot \hat y' & \hat y \cdot \hat y' & \hat z \cdot \hat y' \\ \hat x \cdot \hat z' & \hat y \cdot \hat z' & \hat z \cdot \hat z' \end{pmatrix}$$

There are no cosines here, so why is this called the "direction cosine matrix"? The answer is simple. The inner product of two vectors $\vec a$ and $\vec b$ is $\vec a \cdot \vec b = ||\vec a|| \, ||\vec b|| \, \cos\theta$, where $\theta$ is the angle between the two vectors. If the two vectors are unit vectors, the magnitudes are just one and this simplifies to $\hat a \cdot \hat b = \cos \theta$.

There are a number of other ways of looking at rotations in three dimensional space. Euler angles, for example. Another is the single axis rotation (aka eigen rotation). Suppose frame B is generated by frame A by rotating frame A by an angle $\phi$ about some axis $\hat u = (u_x, u_y, u_z)$. Here, $\hat u$ is a unit vector and rotation is positive/negative per the right hand thumb convention. The transformation matrix given this single axis rotation is:

$$T = \begin{pmatrix} \cos\phi + u_x^{\,2} (1-\cos\phi) & u_x u_y (1-\cos\phi) + u_z \sin\phi & u_x u_z (1-\cos\phi) - u_y \sin\phi \\ u_y u_x (1-\cos\phi) - u_z \sin\phi & \cos\phi + u_y^{\,2} (1-\cos\phi) & u_y u_z (1-\cos\phi) + u_x \sin\phi \\ u_z u_x (1-\cos\phi) + u_y \sin\phi & u_z u_y (1-\cos\phi) - u_x \sin\phi & \cos\phi + u_z^{\,2} (1-\cos\phi) \end{pmatrix}$$

A much more compact representation is $T_{ij} = u_i u_j (1-\cos\phi) + \delta_{ij}\cos \phi + \epsilon_{ijk}u_k\sin\phi$. If you don't know what that means, don't worry about it.

So where did that 1/4 come from? The three angles you have specified, between x and x', y and y', and z and z', are the diagonal elements of the transformation matrix. I'll denote these angles $\alpha$, $\beta$, and $\gamma$. From the direction cosine matrix formulation, your information let's us fill in part of the transformation matrix:

$$T = \begin{pmatrix} \cos\alpha & ? & ? \\ ? & \cos \beta & ? \\ ? & ? & \cos \gamma \end{pmatrix}$$

There's not much information here, but there is enough to compute the trace of the matrix. That's just $\operatorname{tr}(T) = \cos\alpha + \cos\beta + \cos\gamma$. Now look at the single axis rotation formulation. From that, the trace of the matrix is $\operatorname{tr}(T) = 3\cos\phi + (u_x^{\,2}+u_y^{\,2}+u_z^{\,2})(1-\cos\phi)$, and since $\hat u$ is a unit vector, this reduces to $2\cos\phi + 1$.

Equating the two results, we get $2\cos\phi + 1 = \cos\alpha + \cos\beta + \cos\gamma$, so $\cos\phi = \frac {\cos\alpha + \cos\beta + \cos\gamma - 1} 2$. I picked simple values for those angles to make the numbers come out nice and clean. Choosing $\alpha=\beta=\gamma=60^{\circ}$ immediately leads to $\cos\phi = \frac 1 4$.

The upper left element of the transformation matrix is $T_{1,1} = \cos\alpha = \cos\phi + u_x^{\,2} (1-\cos\phi)$. Solving for $u_x^{\,2}$ yields $u_x^{\,2} = \frac {\cos \alpha - \cos \phi} {1 - \cos\phi}$. This gives the magnitude of $u_x$ but not the sign. We don't know the sign. With my nice-values example, we know that $u_x^{\,2} = \frac 1 3$ but we don't know if $u_x = \frac {\sqrt 3} 3$ or $-\,\frac {\sqrt 3} 3$. The same goes for the other two elements of the rotation axis.

This problem is not specific to my example. It is pervasive. You chose a poor representation.

You need to choose a better way of relating your two frames. There are a number of ways to represent rotations in three dimensional space. I've focused on direction cosine matrices and single axis rotations, but there are also Euler angles (actually a family of representations; there are 24 in total), quaternions, Rodrigues parameters, modified Rodrigues parameters, and others. You need to pick a good scheme. You picked a bad one.

One final point: You asked in the opening post "What is angle between the projection of z' on the xy plane and the x axis?" There's a potential problem here. You can calculate that angle, but that calculated value will be meaningless if the two frames are very close to being aligned with one another. You have experimental data "related to my research project on light polarization." That projection onto the xy plane will remove all signal from your data, leaving just random noise if the two frames aren't separated by much.

16. Jun 25, 2014

### fannyfanfanz

Is the direction cosines method you used based on Goldstein (Classical Mechanics)?

17. Jun 25, 2014

### D H

Staff Emeritus
It looks like Goldstein doesn't use that approach. He does use the term "direction cosine" a few times, but not in the context of the transformation matrix. From my experience, calling the transformation matrix the "direction cosine matrix" is much more common in engineering (particularly mechanical and aerospace) than it is in math or physics.