In 2D plane, I have a point and a line. How to get the mirror point along this line?
Suppose the equation of the line is ax + by + c = 0
. Now imagine a line perpendicular to it, which can be represented by -bx + ay + d = 0
(product of slopes of two perpendicular lines is -1). Now the problem is to find d
. Put the co-ordinate of the point on the second line, and you'll get the value of d
easily.
The second part is, to find a point on the second line which is equidistant as the first point from the first line. For that, you can find the intersection of the two lines. Calculate the differences in x
and y
of the given point and the intersection point. Now add those to the x
and y
value of the intersecting point. That gives the point you need (you may need to negate the differences - that's up to the order of subtraction you use).