Dear Math Stackexchange community, how can I compute $R$ rotation matrix in this equation ($P=Rp+t$)? (Please see the figure. More detailed explanation is under the figure.)
The equation is for the transformation of $p=p_1,p_2,p_3$ points. $p$ is in Oxyz (local) reference frame. $p$ consists of 3 points of $p_1,p_2,p_3$. And $p_1,p_2,p_3$ each has 3 coordinates of $x,y,z$. Therefore p is 3x3 matrix. $p=\begin{bmatrix} p_{1x} & p_{2x} & p_{3x} \\ p_{1y} & p_{2y} & p_{3y} \\ p_{1z} & p_{2z} & p_{3z} \end{bmatrix}$
$t$ is the distance between Oxyz(local) and OXYZ(global) reference frame. $t=\begin{bmatrix} t_x \\ t_y \\ t_z \end{bmatrix}$. To be able to do matrix operations, we can take $t$ as $t=\begin{bmatrix} t_x&t_x&t_x \\ t_y&t_y&t_y \\ t_z&t_z&t_z \end{bmatrix}$
$P$ is the coordinates of p_1, p_2, and p_3 in OXYZ global reference frame. $P$ is a 3x3 matrix. $P=\begin{bmatrix} P_{1x} & P_{2x} & P_{3x} \\ P_{1y} & P_{2y} & P_{3y} \\ P_{1z} & P_{2z} & P_{3z} \end{bmatrix}$
$R$ is the (orthogonal) rotation matrix. $R=\begin{bmatrix} r_{11}&r_{12}&r_{13} \\ r_{21}&r_{22}&r_{23} \\ r_{31}&r_{32}&r_{33} \end{bmatrix}$
Therefore, all in all: $P=Rp+t$
$\begin{bmatrix} P_{1x} & P_{2x} & P_{3x} \\ P_{1y} & P_{2y} & P_{3y} \\ P_{1z} & P_{2z} & P_{3z} \end{bmatrix} = \begin{bmatrix} r_{11}&r_{12}&r_{13} \\ r_{21}&r_{22}&r_{23} \\ r_{31}&r_{32}&r_{33} \end{bmatrix}.\begin{bmatrix} p_{1x} & p_{2x} & p_{3x} \\ p_{1y} & p_{2y} & p_{3y} \\ p_{1z} & p_{2z} & p_{3z} \end{bmatrix}+\begin{bmatrix} t_x&t_x&t_x \\ t_y&t_y&t_y \\ t_z&t_z&t_z \end{bmatrix}$
We can derive the following form of the equation of $P=Rp+t$
$(P-t)=R.p$
$(P-t).p^{-1}=R$
$p$ is an arbitrary matrix, and not always be taken of its inverse. I can't take the inverse of $p$, if last raw of $p$ is zero.
Let's look at an example to make it clear: $P=Rp+t$
$p_1=(1,1,0)$ , $p_2=(2,4,0)$ , $p_3=(5,10,0)$ is the coordinates of three points. So in matrix form: $p=\begin{bmatrix} 1 & 2 & 5 \\ 1 & 4 & 10 \\ 0 & 0 & 0 \end{bmatrix}$
$t=\begin{bmatrix} 0 \\ 0 \\ 50 \end{bmatrix}$
$\alpha=10^\circ $ (rotation around the x axis)
$\beta=15^\circ $ (rotation around the y axis)
$\gamma=20^\circ $ (rotation around the z axis)
$R_x=\begin{bmatrix} 1 & 0 & 0 \\ 0 & cos(\alpha) & -sin(\alpha) \\ 0 & sin(\alpha) & cos(\alpha) \end{bmatrix}$
$R_y=\begin{bmatrix} cos(\beta) & 0 & sin(\beta) \\ 0 & 1 & 0 \\ -sin(\beta) & 0 & cos(\beta) \end{bmatrix}$
$R_x=\begin{bmatrix} cos(\gamma) & -sin(\gamma) & 0 \\ sin(\gamma) & cos(\gamma) & 0 \\ 0 & 0 & 1 \end{bmatrix}$
$R=R_z.R_y.R_x$
Therefore, for $\alpha=10^\circ $, $\beta=15^\circ $, $\gamma=20^\circ $, the rotation matrix is :
$R=\begin{bmatrix} 0.9077 & -0.2946 & 0.2989 \\ 0.3304 & 0.9408 & -0.0760 \\ -0.2588 & 0.1677 & 0.9513 \end{bmatrix}$
$P=R.p+t$
$P=$$\begin{bmatrix} 0.9077 & -0.2946 & 0.2989 \\ 0.3304 & 0.9408 & -0.0760 \\ -0.2588 & 0.1677 & 0.9513 \end{bmatrix}$$.\begin{bmatrix} 1 & 2 & 5 \\ 1 & 4 & 10 \\ 0 & 0 & 0 \end{bmatrix}$ $+\begin{bmatrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 50 & 50 & 50 \end{bmatrix}$
$P=\begin{bmatrix} 0.6131 & 0.6370 & 1.5925 \\ 1.2712 & 4.4239 & 11.0597 \\ 49.9089 & 50.1533 & 50.3832 \end{bmatrix}$
$p_1=(0.6131,1.2712,49.90)$,$p_2=(0.6370,4.4239,50.1533)$,$p_3=(1.5925,11.0597,50.3832)$.
Now let's take opposite example with the same values to find $R$, with the values of $P,p,t$ as known.
$P=R.p+t$
$\begin{bmatrix} 0.6131 & 0.6370 & 1.5925 \\ 1.2712 & 4.4239 & 11.0597 \\ 49.9089 & 50.1533 & 50.3832 \end{bmatrix}=R.$ $\begin{bmatrix} 1 & 2 & 5 \\ 1 & 4 & 10 \\ 0 & 0 & 0 \end{bmatrix}+$ $\begin{bmatrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 50 & 50 & 50 \end{bmatrix}$
Could you find $R$ here in the above equation?
To repeat the formulation:
$P=Rp+t$
$(P-t)=Rp$
$(P-t).p^{-1}=R.p.p^{-1}$
$(P-t).p^{-1}=R$
For the inverse of $p$ (where $p$ is $\begin{bmatrix} 1 & 2 & 5 \\ 1 & 4 & 10 \\ 0 & 0 & 0 \end{bmatrix}$ ), I can't take the inverse of $p$.
Here I am stuck. It is interesting for me, because for the condition that $R,p,t$ is known, $P$ can be calculated(9 unknown elements in 3x3 matrix of $P$). However, for the condition that $P,p,t$ is known, I am having problem to compute $R$ (9 unknown elements in 3x3 matrix of $R$). I should be able to compute the equivalent $R$ matrix for that inverse problem.
Do you have any idea about how to find $R$ rotation matrix? Any suggestion would be appreciated.
Thanks in advance.