I have a line segment (x1, y1), (x2, y2) that i need “mirrored” so the new line becomes perpendicular to the first one and passes through its middle.
The line segment (0,0),(2,2) should return a new line segment (0,2),(2,0)
Can anyone help me with a function/formula to handle this?
The midpoint is (mx,my) = ((x1+x2)/2,(y1+y2)/2).
To rotate the endpoints 90 degrees about the middle, first compute a vector:
then rotate it 90 degrees:
Then the new point becomes:
Repeat for x2,y2.
You may also combine steps if you’re careful.