3

I have two convex polygons, A and B. Given a specific side on each, I need to translate and rotate B so that the centerpoint of both lines coincide and the lines become parallel, giving the appearance of creating a new more complex polygon.

The translation is easy, but I can't figure out how to do the rotation. I thought just taking the angle between the vector between the center of A and the center of A's side, and the corresponding vector on B, and rotating B by the angle between them, but this doesn't work, and I'm out of ideas. Help?

For example: in this image, B's center is in the right place, but it needs to rotate 195 degrees so that its 0th side matches up to A's 0th side. I determined that answer through trial and error in this case; is there an analytic solution for any two polygons?

enter image description here

1 Answers1

0

Suppose we want the edge $e_A$ of $A$ with center $c_A$ to match up with the edge $e_B$ with center $c_B$ in the way you describe. Here's a way to construct a euclidean transformation that achieves this.

First, we translate $B$ by a translation $\tau$ such that $c_A$ and $c_B$ match up. You can do this easily with the translation $\tau(x) = x + (c_A - c_B)$. Then $\tau(c_B) = c_A$.

Next, we rotate $B$. However, we will not rotate $B$ around its center, but rather around $c_B$. You can get the correct angle $\theta$ by interpreting $v_A - c_A$ and $v_B - c_B$ as complex numbers and then taking the argument of their ratio, where $v_A$ is the vertex of $A$ that comes counter-clockwise before $c_A$, and $v_B$ is the vertex of $B$ that comes conter-clockwise after $c_B$ (this needs to be taken into consideration because otherwise the polygons might end up intersecting). In symbols:

$$\theta = \arg \frac{v_A - c_A}{v_B - c_B}.$$

Let $\rho$ be the rotation around $c_A$ by an angle of $\theta$. Then the composition $\rho \circ \tau$ should do what you want.

Levi
  • 4,766