1, the linear distance between the point of the plane:
Code:
struct Point{ double x; double y; } struct PlaneEquation{ double A; double B; double C; } //计算点到面距离 double dist(Point &pt, PlaneEquation &pe) //Distance between point and plane { double dt = 0.0; double mA, mB, mC, mX, mY; mA = pe.A; mB = pe.B; mC = pe.C; mX = pt.X; mY = Pt.Y; IF (mA + mA * * mB of mB of mC * + mC) // If mA * mA + mB * mB + mC * mC == 0 shrunk point described straight { dt = ABS (mX + mA * mC * + mY mB of) / sqrt (mA + mA * * mB of mB of); } the else { STD :: COUT << " equation :: input error coefficients are all zero !!!! " ; dt = pt.mod () ; } // of The IS reduced to Plane The Origin Point (Pt) to Point (ZERO) Distance.. return dt; }
2, the straight line distance between the point of space:
// use of space linear two-point (X0 Y0 Z0) for the straight outer point Xc = (X2-X1) * T + X1; YC = (Y2-Y1) * T + Y1; Zc = (Z2-Z1) * T + Z1; // pedal T = ((the X1-an X2) * (the X1-X0) + (Yl-Y2) * (Y0-Yl) + (Zl-Z2 of) * (Z0 of-Zl)) / ((X2- the X1) * (the X1-an X2) + (Yl-Y2) * (Yl-Y2) + (Zl-Z2 of) * (Z2- Zl)) D = sqrt ((X0-Xc) * (X0-Xc) + ( Yc-Y0) * (Y0-Yc) + (Z0 of-Zc) * (Z0 of-Zc)) // solving two-norm