I have two equilateral triangles with the same edge lengths, each defined by a set of three points: $(p_1, p_2, p_3)$ and $(q_1, q_2, q_3)$, respectively. Point $p_1$ overlaps with point $q_1$ and point $p_2$ overlaps with point $q_2$.

I would like to rotate $p_3$ so that it overlays $q_3$. Proceeding, let $p_{1,2}$ and $q_{1,2}$ be the mean of $p_1$ and $p_2$ and $q_1$ and $q_2$, respectively, allowing us to define direction vectors $v_p = (p_3 - p_{1,2})$ and $v_q = (q_3 - q_{1,2})$. We can then recover the angle $\theta$ between the two direction vectors using the relationship $\theta = ArcCos[\frac{Dot[v_p,v_q]}{||v_p||*||v_q||}]$, multiply by the appropriate rotation matrix, and we've overlayed $p_3$ and $q_3$.

But there's a problem - how can I determine the sign of the rotation angle $\theta$?

Is there some test involving the dot product or the sign of the cross product that allows me to decide on the appropriate sign? Or must I sort of do this by brute force - try both, and measure the distance between $p_3$ and $q_3$?

Update - The brute force approach works where we do a simple distance test and try both signs. No surprises there. But this seems like a really inelegant approach.

  • $\begingroup$ What do you mean by “points overlap”? Are the points identical? $\endgroup$ – MvG Mar 16 '13 at 15:26
  • $\begingroup$ @MvG yes, the triangles are identical, but rotated relative to one-another. $\endgroup$ – ERI Mar 17 '13 at 4:18

Your Answer

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

Browse other questions tagged or ask your own question.