Trying to convert an objects coordinates from WCS to OCS. I am only interested in the mathematics of this problem and not using an existing library to do this for me.
I have an object that exists with a yaw, pitch, and roll angle applied to it (in that order). It is then inserted at a WCS coordinate of $(1,5,2)$.
To convert this to OCS, I first need to calculate the normal vector of this object. To do this, I take the z-axis vector (0, 0, 1) and apply the three rotations in the order above:
The cross product of the rotation and z-axis gives just the blue values give me the vector of my normal (top line x, middle, y, bottom, z).
I then need to translate my insertion point to OCS. For this I am not sure how to proceed. I can calculate the arbitrary axis by doing the following:
$N(x,y,z)$ = Normal vector $W_y$ = world y-axis $(0,1,0)$ $W_x$ = world x-axis $(1,0,0)$
If $|(N_x)| \lt 1/64$ and $|(N_y) \lt 1/64)$ then $A_x = W_y \otimes N$ (where "$\otimes$" is the cross-product operator). Otherwise,$A_x = W_z \otimes N$.
Scale $A_x$ to unit length. The method of getting the $A_y$ vector would be: $A_y = N \otimes A_x$. Scale $A_y$ to unit length.
Now I have the three OCS axis, I am not sure how to convert the world coordinates. I initially tried applying the rotations directly to the given coordinate which did not work, but I am not sure if my cross product was wrong. To do this, I did them one at a time:
coordinate to translate is in $(x,y,z)$
Using just the first rotation (about z axis / yaw) would give me:
$x = (in_x * \cos C) + (in_x * -\sin C)$
$y = (in_y * \sin C) + (in_y * \cos C)$
$z = (in_z * 1)$
I then repeat this with the second and third rotations replacing the input coordinate with the results from above, and the results from the second rotation.
This seems incorrect. Can anyone point me in the right direction?