0

Dear Math Stackexchange community, how can I compute $R$ rotation matrix in this equation ($P=Rp+t$)?

$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 3x1 vector. $t=\begin{bmatrix} t_x \\ t_y \\ t_z \end{bmatrix}$

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 a 3x3 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_y \\ t_z \end{bmatrix}$

I tried to take the inverse and calculate R. However; when I put numeric values in it, that method doesn't work with numeric values.

Do you have any suggestion?

edit1: I did the following after DavidK, and Cryo's suggestion:

$P=Rp+t$

$(P-t)=R.p$

$(P-t).p^{-1}=R$

However there is a problem now: last raw of $p$ is always fully zero for my case. And I can't take the inverse of $p$.

Ercan
  • 41
  • Firstly, please use \begin{array}...\end{array} to type matricies. The current stuff is unreadable. Second, I think you may have lost something. If $P$ is a matrix then how can you have a $t$ - a vector on the other side of equation? How do you define adding-subtracting matrix from a vector? It looks like you are working in something like Matlab, surely it would complain? – Cryo Jan 23 '21 at 22:10
  • Dear @Cryo , I edited the text to be more readible. Sorry, I am new here and I didn't know how to write correctly. I mean vector as $t$ is 3x1 matrix(which has components of x,y,z). Is that wrong to call it like that? If so, should I call $t$ as matrix again? But I still couldn't find out how to find the matrix components of $R$. Do you have any suggestion? And yes, I am doing it in MATLAB. But I thought it is a math problem. However I also asked that question in MATLAB. link – Ercan Jan 24 '21 at 15:28
  • 2
    There is a relatively recent MATLAB feature that lets you write A + b where $A$ is (for example) a $3\times3$ matrix and $b$ is a $3$-element column vector. However, that's a MATLAB feature of convenience, not a conventional mathematical operation. To write the effect of this feature mathematically, write a $3\times3$ matrix containing $3$ copies of the column vector side by side. Instead of $\begin{bmatrix}t_x\t_y\t_z\end{bmatrix},$ write $\begin{bmatrix}t_x&t_x&t_x\t_y&t_y&t_y\t_z&t_z&t_z\end{bmatrix}.$ – David K Jan 24 '21 at 15:48
  • If you have all the $P$ values, all the $p$ values, and all the $t$ values, then you should be able to use a technique with matrix inversion to find all the $r$ values. Exactly how did you try to solve the problem? What is your formula for the solution? What numeric values did you put in it? How do you know it did not work correctly? Are you sure this is really a mathematics question and not actually just a question of how to program the math in MATLAB? – David K Jan 24 '21 at 15:53
  • Dear @DavidK , thank you for your explanation. Now I understand what Cryo meant. I can't directly add a column matrix (3x1) to a (3x3) matrix. How I wasn't aware of this? :( And yes, MATLAB has this new feature. But it is not mathematically correct. I see now. – Ercan Jan 24 '21 at 15:54
  • 1
    @DavidK , I see now I made mistake by taking $t$ as $\begin{bmatrix} t_{x} \ t_{y} \ t_{z} \end{bmatrix}$ . The problem is with that probably. Now I will try to do it by taking $t$ as $\begin{bmatrix} t_{x}&t_{x}&t_{x} \ t_{y}&t_{y}&t_{y} \ t_{z}&t_{z}&t_{z} \end{bmatrix}$ as you suggested. I didn't noticed that mathematically error at first, when MATLAB can do add matrix and column. Thank you for your reply and suggestion DavidK. Thank you Cryo to you too. I will try to do it again. – Ercan Jan 24 '21 at 16:15
  • 1
    Ahhh, I have this problem now: for the value of $p$ when its one row is fully zero 0, I can't take its inverse. For example, if $p=\begin{bmatrix} 1&2&5 \ 1&5&10 \ 0&0&0 \end{bmatrix}$ (which means it lies on a plane), the inverse of $p$ , $p^{-1}$ can't be taken. So what should I do when last row of $p$ is set to zero. – Ercan Jan 24 '21 at 16:24
  • 1
    I think I see the difficulty now. The matrix $R$ must be orthogonal (and therefore invertible) but the rotation should be possible to deduce from any three non-collinear points, which may not form an invertible matrix $p.$ You could edit the question to incorporate the things you discovered in the last couple of comments; maybe that would get some better attention. (People may not look at the comments.) – David K Jan 24 '21 at 16:50
  • @DavidK , ohh yes that's right. You described the situation better and clearly. Okay I will post the question in a better way including those. Thank you DavidK. – Ercan Jan 24 '21 at 17:05
  • Dear @DavidK , I created another question which has more explanation in it. The link is here: link – Ercan Jan 24 '21 at 19:29

1 Answers1

1

Thanks to @David K. I was suspecting that Matlab was doing something convenient, but I don't use it any more, so wanted to avoid guessing.

So you have

$\mathbf{Q}=\left[\mathbf{q}_1\,\mathbf{q_2}\,\mathbf{q_3}\right]=\mathbf{P}-\mathbf{t}=\mathbf{R}.\boldsymbol{\mathcal{P}}=\mathbf{R}.\left[\mathbf{p}_1\,\mathbf{p}_2\,\mathbf{p}_3\right]$

Where $\mathbf{Q}$ is some $3\times 3$ real-valued matrix, which we can also view as 3 column vectors $\mathbf{q}_{1,2,3}$. $\mathbf{R}$ is a real-valued rotation matrix, which means it is orthogonal ($\mathbf{R}^T\mathbf{R}=\mathbf{Id}=identity$) and has determinant of $det\left[\mathbf{R}\right]=+1$. Finally, matrix $\boldsymbol{\mathcal{P}}$ is made up from three 3d real-valued column vectors $\mathbf{p}_{1,2,3}$. The aim is to determine the rotation matrix by choosing the vectors $\mathbf{p}_{1,2,3}$.

If you can pick three linearly independent vectors $\mathbf{p}_{1,2,3}$ you can have a unique solution for $\mathbf{R}$ given $\mathbf{Q}$. You seem to say that all z-components all your three vectors are zero. Then the three vectors are not linearly independent.

Why can you not have three linearly independent vectors? Are there any limitations?

PS: This is not so much an answer as restatement of the problem, but I am still struggling to understand the question

Cryo
  • 778
  • Dear @Cryo , I posted a new question which I present my question better. The link is here – Ercan Jan 24 '21 at 19:31
  • Dear @Cryo, according to your question in "PS", I would like to explain it. I am working on a Stewart Platform parallel manipulator. In case of you are not familiar with it, please see this very brief introduction paper (link) . Stewart Platform has two platforms: base and moving platform. Assume that OXYZ global reference frame is fixed at the base middle point. And assume that local reference frame for the upper moving platform has Oxyz local reference frame. The coordinates of the ---(to be continued) – Ercan Jan 25 '21 at 14:11
  • Dear @Cryo , The coordinates of the moving platform vertices in Oxyz local reference frame are called $p_1$, $p_2$, $p_3$. And since it is a plane, they ($p_1$, $p_2$, $p_3$) has 0 zero as its z axis. Since the moving platform is planar, its z axis coordinates (in Oxyz local frame) are zero 0. Therefore its($p$'s) last raw is fully zero.

    The Stewart platform has 6 DOF (3DOF for rotation, 3DOF for translation). It has 3DOF for rotations (around x, around y, around z). Therefore its rotation matrix is 3x3. I mean; if it was only in 2D, not in3D, we could pick a 2x2 rotation matrix. But 3D

    – Ercan Jan 25 '21 at 14:15
  • I hope it is more understandable/clear now, with this explanation. – Ercan Jan 25 '21 at 14:22