I have 2 point and a line segment in 2d space. The line only rotates and translates using its mid point.
How do I calculate the translation and rotation required for the line to be touching the 2 points with center in the middle?
I know the initial state of the line, so calculating translation is easy $$ (x',y') = \frac{p_1+p_2}{2} -[\text{line center}] $$ Can you please tell me how to calculate the rotation?
Thanks!
It comes down to the following: we want to rotate the line so that it is parallel to the other segment. Once we have this, the translation will ensure that the lines overlap (since they both intersect and have the same slope).
In order to find the necessary angle of rotation, find the angles (relative to the $x$-axis) at which the starting line and the target line, then take the difference. If $m_1$ and $m_2$ are the respective slopes of the starting line and the target line, then the angle of rotation necessary is $$ \theta = \tan^{-1}(m_2) - \tan^{-1}(m_1) $$