I have two line segments with points:
Line 1 is a line through $(x_1,y_1)$ and $(x_2,y_2)$ (smaller line)
Line 2 is a line through $(x_3,y_3)$ and $(x_4,y_4)$ (bigger line)
How can I make the Line 1 (smaller) to rotate and make it parallel to Line 2 (bigger) using either:
- $(x_1,y_1)$ as fixed point of rotation or
- $(x_2,y_2)$ as fixed point of rotation or
- center point as fixed point of rotation
You can get the angle of each line using $\text{Atan2}(x_2-x_1,y_2-y_1)$ and similar. Note that the result is radians, but you probably don't need to worry about that. Taking the difference of the angles will show how much you have to rotate, call it $\theta$. To rotate $\theta$ around $(x_1,y_1)$ you have $$x'=(x-x_1) \cos \theta+(y-y_1) \sin \theta+x_1\\ y'=(y-y_1) \cos \theta - (x-x_1) \sin \theta + y_1$$