I am sorry if this has been answered and I am not being able to find.

I have a triangle with vertices at $A(x_1, y_1, z_1), B(x_2,y_2,z_2)$ and $O(0,0,0)$. Now, the triangle is rotated about the fixed origin to another position $A'(x_1', y_1', z_1'), B'(x_2',y_2',z_2'), O(0,0,0)$.

with my little knowledge of Euler's rotation theorem, I think there should be a unique rotation matrix to map these two positions of the triangle but don't know how exactly to calculate the matrix.

Any help with an efficient algorithm to calculate the rotation matrix would be very very helpful.

  • $\begingroup$ Can you find the angle between $OA$ and $OA'$? $\endgroup$ – 1123581321 Feb 13 '18 at 19:07
  • $\begingroup$ Hint: 2D rotations matrices are of the form $\begin{bmatrix}\cos(\theta) & -\sin(\theta)\\ \sin(\theta) & \cos(\theta)\end{bmatrix}$ where $\theta$ is the angle of rotation. Apply this to a test vector and draw it, can you see why this is true? Can you calculate $\theta$? $\endgroup$ – user438666 Feb 13 '18 at 19:10
  • $\begingroup$ Because $A$ and $A'$ are known, the angle should be easily found using the dot product between $OA$ and $OA'$. I am not sure whether the ambiguity of $\theta$ and $360-\theta$ will be a problem. $\endgroup$ – DrBgyan Feb 13 '18 at 19:12

Assuming that these triangles aren’t degenerate, the vectors $A$, $B$ and $A\times B$ form a basis for $\mathbb R^3$, as do $A'$, $B'$ and $A'\times B'$. The rotation that takes the first triangle to the second also maps $A\times B$ to $A'\times B'$, so the matrix that maps the first basis onto the second will be the required rotation. The most straightforward way to find this matrix is to compute $$\begin{bmatrix} A' & B' & A'\times B'\end{bmatrix} \begin{bmatrix} A&B&A\times B \end{bmatrix}^{-1},$$ but this might not be the most efficient method.

Another way to go is to take advantage of the fact that the rotation axis must lie on the angle bisector of a point and its image. Thus, the required rotation axis is the intersection of the planes through the origin with normals $A'-A$ and $B'-B$. This line is perpendicular to both normals, so assuming that neither is zero (in which case the rotation is about that side of the triangle), this means that the rotation axis is parallel to $(A'-A)\times(B'-B)$. You can work out the rotation angle $\theta$ by using the inner product identity $\mathbf v\cdot \mathbf w = \|\mathbf v\|\|\mathbf w\|\cos\theta$ (in fact, you really only need $\cos\theta$ and not the angle itself) and then use Rodrigues’ formula.

  • $\begingroup$ "the matrix that maps..." There is not only just one such matrix. But there is just one that is orthogonal. The OP is asking for that one. $\endgroup$ – Arnaud Mortier Feb 13 '18 at 19:19
  • $\begingroup$ @ArnaudMortier The expression that I’ve written down is an orthogonal matrix, thank you very much. $\endgroup$ – amd Feb 13 '18 at 19:25
  • $\begingroup$ No worries. I just thought it was worth pointing it out as it might not be obvious. $\endgroup$ – Arnaud Mortier Feb 13 '18 at 19:26
  • $\begingroup$ @ArnaudMortier There are certainly many matrices that map the first triangle to the other, but the change of basis matrix between the bases that I’ve defined is unique. $\endgroup$ – amd Feb 13 '18 at 19:30
  • $\begingroup$ It is unique in many ways and I can clearly see why it is orthogonal, all I'm saying is that it might be worth mentioning in your answer since it may not be that obvious - and imho once you have seen that there is no need for a better answer. $\endgroup$ – Arnaud Mortier Feb 13 '18 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.