How to calculate the mirror point along a line?

前端 未结 8 1680
灰色年华
灰色年华 2020-12-31 18:09

In 2D plane, I have a point and a line. How to get the mirror point along this line?

8条回答
  •  盖世英雄少女心
    2020-12-31 18:32

    The details depend on how your line is represented. If you represent it as an arbitrary point P on the line together with a unit column vector n along the line, then the mirror point Q' to any point Q is given by:

    Q' = Q + 2(I - nnT)(P - Q)

    (Here, I is the 2x2 identity matrix, nT is the transpose of n (treating n as a 2x1 matrix), and nnT is the 2x2 matrix formed by standard matrix multiplication of n with nT.) It's not too hard to show that Q' will not change if you move P anywhere on the line.

    It's not hard to convert other line representations into a point/unit vector representation.

提交回复
热议问题