Solve the distance, vertical foot, and symmetrical point formula of a point about a line

 The following two equations of straight line are used to solve the formulas of distance, vertical foot, and symmetrical point of a point about a straight line.

Problem description 1:

Given the coordinates of the point (x0, y0), the equation of the line is Ax+By+C = 0;

Find the distance d from the point to the line, the vertical foot of the point on the line (x, y), and the symmetry point (x', y') of the point about the line.

Solution:

(1) Distance:

         d = ( Ax0 + By0 + C ) / sqrt ( A*A + B*B );

         This "distance" has a sign, indicating that the point is above or below the line, and the absolute value represents the Euclidean distance.

(2) Foot drop:

         Solve two equations:

  (a)  Ax + By + C = 0;

  (b) (y - y0) / (x - x0) = B / A;

         Solved, x = ( B*B*x0 - A*B*y0 - A*C ) / ( A*A + B*B );

                    y = ( -A*B*x0 + A*A*y0 - B*C ) / ( A*A + B*B );

(3) Symmetry point:

         Method 1: Solve two equations: (a), A*( x'+x0 ) / 2 + B*( y'+y0 ) / 2 + C = 0; (b), (y' - y0) / ( x' - x0) = B / A;

         Method 2: Transform the problem into solving the symmetry point of the known point about the vertical foot:

                First, find the foot drop; then x' = 2*x - x0; y' = 2*y - y0;

                解得,x’ = ( (B*B - A*A)*x0 - 2*A*B*y0 - 2*A*C ) / ( A*A + B*B );

                           y‘ = ( -2*A*B*x0 + (A*A - B*B) * y0 - 2*B*C ) / ( A*A+B*B );

         Method 3: First, find a coefficient k, k = - 2 * (A*x0 + B*y0 + C) / (A*A+B*B);

                 Then, x' = x0 + k * A;

                           y' = y0 + k * B;

                  See the source for this proof: http://download.csdn.net/detail/changbaolong/4196639

        

Problem description 2:

The coordinates of the known point (x0, y0), two points on the line (x1, y1), (x2, y2);

Find the distance d from the point to the line, the vertical foot of the point on the line (x, y), and the symmetry point (x', y') of the point about the line.

Solution:

        Method 1: Convert the linearized two-point formula into a general formula, then in the general formula A = y2 -y1; B = x1 - x2; C = x2*y1 - x1*y2; Corresponding distance, foot drop, symmetry point.

        Method Two:

(a) Distance:

         First, find the coordinates of the foot drop;

         then d = sqrt( (x - x0) * (x - x0) + (y - y0) * (y - y0));

(b) Foot drop:

         First, find a coefficient k: Let the starting point and end point of the straight line be A(x1, y1), B(x2, y2) respectively, the point outside the straight line is C(x0, y0), and the vertical foot is D; and let k = | AD|/|AB.

         则, k * AB = AD = AC + CD, and AB * CD = 0; therefore, k * AB * AB = AC * AB, the late k = AC * AB / (AB * AB).

         Bring in the coordinates, that is,

     k = ( (x0- x1) * (x2 - x1) + (y0 - y1) * (y2 - y1) )  / ( (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) ) ;

         则   x = x1 + k*(x2 - x1);      y = y1 + k*(y2 - y1);

(c) Symmetry point:

         Same as the method in question description 1.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324611251&siteId=291194637