I'm having difficulty figuring this out...
Imagine a rod in 3-space. One end of the rod is fixed at the origin (Point A). The end that is free is (Point B). Point B is initially at <0,0,z> pointed in the positive z direction. The rod may only rotate about the x-axis by (theta) and y-axis by (phi). It cannot twist (no rotation about the z axis).
Point B has been displaced by some angle phi and some angle theta. Find these two angles.
Attach a new rod to the end of Rod-1. This is Rod-2 whose origin is at (Point B) and end is at (Point C). The same constraints follow as for Rod-1. Rod-2 is displaced. Find the angles phi' and theta' against the rotated axis x',y',z' where z' points in the direction of Rod-1.
To solve this problem I did this,
1) Project Rod-1 into the y-z plane and find the angle between the projection and y to find phi. Project Rod-1 into the x-z plane and find the angle between the projection and x to find theta.
2)
Rotate the x-axis by (90 - theta) along the y-axis to get x'.
Rotate the z-axis by the angle between Rod-1 and the z-axis along the negative x' axis to get z'.
Take the cross product of z' and x' to get y'
To check that this works, a) I take the dot product of Rod-1 with z' -> I should get 1. b) The dot product of Rod-1 and y' should be 0 and so should the dot product of Rod-1 and x'
This is not the case though. They are off. Is this the correct method for rotating this coordinate axis to the orientation of Rod-1? I need the axis to be rotated so that I can get the angles of Rod-2 against Rod-1.
First we need to find $\theta$ and $\phi$:
$$ \begin{align} \alpha&=\arccos{\left(\frac{\vec{B}’\cdot\vec{B}}{||B||^{2}}\right)}\\ \\ \theta&=\alpha\frac{\vec{B}\times\vec{B}’}{\left|\left|\vec{B}\times\vec{B}’\right|\right|}\cdot\hat{i}\\ \phi&=\alpha \frac{\vec{B}\times\vec{B}’}{\left|\left|\vec{B}\times\vec{B}’\right|\right|}\cdot\hat{j} \end{align} $$
Now define the rotational matrix
$$ \begin{align} G&= \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos{\left(\theta\right)} & -\sin{\left(\theta\right)} \\ 0 & \sin{\left(\theta\right)} & \cos{\left(\theta\right)} \end{bmatrix} \begin{bmatrix} \cos{\left(\phi\right)} & 0 & \sin{\left(\phi\right)} \\ 0 & 1 & 0 \\ -\sin{\left(\phi\right)} & 0 & \cos{\left(\phi\right)} \end{bmatrix} \end{align} $$
The rotated axis are:
$$ \begin{align} \begin{bmatrix} \hat{x}’ & \hat{y}’ & \hat{z}’ \end{bmatrix} &=\left[G\right] \end{align} $$