Rotate a line on a graph relative to line’s center

geometrystatistics

I am trying to figure out how to rotate a line relative to it's center.

Given two points $(x_1, y_1)$ and $(x_2, y_2)$ and the center of the line $(x_3, y_3)$, how do I rotate the the line 180 degrees?

For example if the line was $(1,1)$ and $(2,2)$, the calculated center will be $(1.5,1.5)$ and the rotated point will be $(1,2)$ and $(2,1)$.

I am not sure which formula to use to rotate the line by its center, the ones I found rotate the lines based on axes.

Best Answer

$$(x-x_{1})(y_{2}-y_{1})= (y-y_{1})(x_{2}-x_{1})$$

Is the equation for a line between $(x_{1},y_{1})$ and $(x_{2},y_{2})$

The equation:

$$(x+x_{3}-x_{1})(y_{2}-y_{1})= (y+y_{3}-y_{1})(x_{2}-x_{1})$$

Shifts the line so that $(x_{3},y_{3})$ is on the origin.

An angle which describes the line is given by the arctan(m) where m is the slope. In the case where the line is vertical choose $\frac{\pi}{2}$. Then we rotate by $\theta$ so the new slope is:

$$tan(\theta + arctan(\frac{y_{2}-y_{1}}{x_{2}-x_{1}}))$$

So we know the new slope, and the point $(x_{3},y_{3})$ must be in the new line so:

$$(x-x_{3})tan(\theta + arctan(\frac{y_{2}-y_{1}}{x_{2}-x_{1}}))=y-y_{3}$$

Using point slope form.