I am going crazy researching trigonometry, vectors, matrices, quaternions, Euler angles, etc. etc. in pursuit of an efficient, "best practice" solution to the problem of representing points in one 3D coordinate system as points in another 3D coordinate system. There are plenty of answers to this question already, but none that I can use because they are too high level, assuming the reader will know how to flesh out the described methods. So I'm looking for a specific, step by step, actual calculation that demonstrates how the job is done. I hope this approach will also help others who may be as confused by their research as I am.
Let's say we have object A in its own "right hand rule" 3D XYZ coordinate system, "floating in space" at no particular location or coordinates, with one point P defined in this object, at X=2, Y=4, Z=7. Let's say we have object B with its own 3D XYZ coordinate system, and this object initially was in the same position and the same orientation as A, their coordinate systems matched (and therefore P would have the same XYZ values in B as in A). But now B is separated from A, in A's coordinates, 10 units on X, 5 units on Y, and 4 on Z. B is additionally rotated, in order and in its own coordinates, 45 degrees on the Z axis, 225 degrees on the Y, and 3 on the X. What are the XYZ values of P in B's coordinates? Please provide the complete math that the reader may reproduce either by hand or programming.
I will be grateful for an answer based on any method, but it would be super cool if a number of answers are posted using different methods.
Let $p_0$ be the original point in frame A, in this problem, $ p_0 = (2, 4, 7) $.
Now, you shift frame B by $(10, 5, 4)$, so the coordinates in frame B after this origin shift will be $(-8, -1, 3) $. Next you want to rotate frame B, three rotations relative to its own axes, first about the $z$ axis by $45^\circ$, then about the new $y$ axis by $225^\circ$, then about the new $x$ axis by $30^\circ$. The overall rotation matrix is given by
$ R = R_z(45^\circ) R_y(225^\circ) R_x(30^\circ) $
The right hand side of the above equation are straight forward to compute, as follows,
$ R_x(30^\circ) = \begin{bmatrix} 1 && 0 && 0 \\ 0 && \cos 30^\circ && -\sin 30^\circ \\ 0 && \sin 30^\circ && \cos 30^\circ \end{bmatrix}$
$ R_y(225^\circ) = \begin{bmatrix} \cos 225^\circ && 0 && \sin 225^\circ \\ 0 && 1 && 0 \\ -\sin 225^\circ && 0 && \cos 225^\circ \end{bmatrix}$
$ R_z(45^\circ) = \begin{bmatrix} \cos 45^\circ && - \sin 45^\circ && 0 \\ \sin 45^\circ && \cos 45^\circ && 0 \\ 0 && 0 && 1 \end{bmatrix} $
Multiplying the above three matrices in the given order gives the rotation matrix $R$.
You can verify that $R$ is given by
$ R = \begin{bmatrix} -0.5 && -0.862372436 && -0.079459311 \\ -0.5 && 0.362372436 && -0.786566092 \\ 0.707106781 && -0.353553391 && -0.612372436 \end{bmatrix}$
Now the old coordinates $P $ (before rotation) and the new coordinates $P'$ (after rotation) are related by
$ P = R P' $
Hence,
$ P' = R^{-1} P = R^T P = R^T [-8, -1, 3]^T $
From this you can compute the coordinates of the original point $[2, 4, 7]^T$, in the final shifted/rotated frame B.
You can verify that the final coordinates in frame $B$ as given by the above formula are
$ P' = \begin{bmatrix} 6.621320344 \\ 5.475946878 \\ -0.414876724 \end{bmatrix} $