Rotation transformation between two frames

My goal is to express the transformation between the black frame F1 and the other one F0 (Green, Red, Violet):

All what I know is the position X,Y Z of four points A, B, C, D wrt F0. My question is how can I know the transformation (3d rotation+ 3d translation) between the two frames?

• Are the coordinates of $A,B,C,D$ $(0,0,0),(1,0,0),(0,1,0),(0,0,1)$ respectively? – Parcly Taxel Oct 18 '18 at 14:53
• No, there are expressed with respect to the black frame, if you zoom in the first image you can read approximately their coordinates – Ja_cpp Oct 18 '18 at 14:55
• I meant, those coordinates in the black frame. – Parcly Taxel Oct 18 '18 at 14:55
• Oh yes that's correct, that's how I defined them wrt F1 – Ja_cpp Oct 18 '18 at 14:59

Translation + rotation can be expressed like this

$$M=\left[\begin{array}{cc}T&0\\0&1\end{array}\right]\left[\begin{array}{cc}R&0\\0&1\end{array}\right]\left[\begin{array}{cc}T^{-1}&x\\0&1\end{array}\right]$$

Where $$T$$ first is transform that takes us to coordinate system where we rotate. and $$R$$ is rotation matrix, for example

$$R=\left[\begin{array}{ccc}\cos(\alpha)&\sin(\alpha)&0\\-\sin(\alpha)&\cos(\alpha)&0\\0&0&1\end{array}\right]$$ $$T=\left[\begin{array}{ccc}v_1&v_2&v_P\end{array}\right]$$ Where $$v_P$$ is vector along axis or rotation and $$\{v_1,v_2\}$$ is a basis for plane of rotation.

So what you have is some equations $$Mw_1 = w_2$$ where vectors in $$w_2$$ are coordinates for frame 2 and $$w_1$$ are same points in first frame. $$w$$ should be filled like this $$w=[c_x,c_y,c_z,1]^T$$ coordinate $$x,y,z$$ and don't forget the 1 at the end of vector.

The sin:s and cos:s make this slightly nonlinear, but there still exist quite okay methods to solve it. I think a few iterations of refining linear solver with some kind of correction should work.

• Sorry I didn't get the meaning of the vector vP? and where should I use the coordinates of A, B, C, D because that's basically what I only know! – Ja_cpp Oct 18 '18 at 15:32
• @Ja_cpp $v_P$ is the vector perpendicular to the plane of rotation. Are A,B,C,D four different points you know? Then you put them in $w_1,w_2$. – mathreadler Oct 18 '18 at 16:17

Suppose you know that

• $$(0,0,0)$$ in the original $$F_0$$ frame is mapped to $$(x_0,y_0,z_0)$$ in the transformed $$F_1$$ frame
• $$(1,0,0)$$ in $$F_0$$ maps to $$(x_1,y_1,z_1)+(x_0,y_0,z_0)$$ (the first vector can be found from the raw coordinates of $$(1,0,0)$$'s image by subtraction)
• $$(0,1,0)$$ maps to $$(x_2,y_2,z_2)+(x_0,y_0,z_0)$$, $$(0,0,1)$$ maps to $$(x_3,y_3,z_3)+(x_0,y_0,z_0)$$

Then the transformation that takes a point expressed in $$F_1$$'s coordinates and returns it in $$F_0$$'s, or transforms $$F_0$$ to $$F_1$$, is $$\begin{bmatrix}x_1&x_2&x_2&x_0\\ y_1&y_2&y_3&y_0\\ z_1&z_2&z_3&z_0\\ 0&0&0&1\end{bmatrix}$$ using the homogenous coordinates trick of adding a fourth coordinate of 1 to each point to be transformed. To get the reverse transformation, simply invert this matrix.

• So what you're saying is I just have to put the coordinates of the four points expressed in F0 frame like so [A B C D;0 0 0 1] and I got my transformation? – Ja_cpp Oct 18 '18 at 15:28
• @Ja_cpp More like $[B-A,C-A,D-A,A;0,0,0,1]$ (assuming column vectors, that the mapping is as in the first comment I made on the question itself, and that the coordinates in this comment are those in the coloured $F_0$ frame). This is a generalisation of a neat trick I found for two-dimensional transformations. – Parcly Taxel Oct 18 '18 at 15:31
• Okay got it and what kind of transformation is it? because I want to extract the rotation vector from it as I stated in the title of the post – Ja_cpp Oct 18 '18 at 15:56
• Basically the translation will be the position of the origin of F1 in F0 (which is the point A) right? – Ja_cpp Oct 18 '18 at 16:06
• @Ja_cpp Yes, and the rotation matrix (which is applied before the translation) is the upper-left 3×3 block of the 4×4 matrix I gave you. This may be converted to axis/angle using well-known formulas; see here (section Rotation matrix $\leftrightarrow$ Euler axis/angle). – Parcly Taxel Oct 18 '18 at 16:09