//------------------------------------------------------------------------------------------- //Плоскость, проходящая через три заданные точки public static PlaneDescriptor GetPlaneByThreePoints( Point3D point1, Point3D point2, Point3D point3 ) { double subX2X1 = point2.X - point1.X; double subY2Y1 = point2.Y - point1.Y; double subZ2Z1 = point2.Z - point1.Z; double subX3X1 = point3.X - point1.X; double subY3Y1 = point3.Y - point1.Y; double subZ3Z1 = point3.Z - point1.Z; double coefficientOfX = subY2Y1 * subZ3Z1 - subZ2Z1 * subY3Y1; double coefficientOfY = subZ2Z1 * subX3X1 - subX2X1 * subZ3Z1; double coefficientOfZ = subX2X1 * subY3Y1 - subY2Y1 * subX3X1; double absoluteTerm = point1.X * subZ2Z1 * subY3Y1 - point1.X * subY2Y1 * subZ3Z1 + point1.Y * subX2X1 * subZ3Z1 - point1.Y * subZ2Z1 * subX3X1 + point1.Z * subY2Y1 * subX3X1 - point1.Z * subX2X1 * subY3Y1; PlaneDescriptor planeDescriptor = new PlaneDescriptor (coefficientOfX, coefficientOfY, coefficientOfZ, absoluteTerm); return(planeDescriptor); }
//---------------------------------------------------------------------------------------------- //Точка пересечения плоскости и прямой, заданной двумя точками public Point3D GetPlaneAndLineIntersectionPoint( PlaneDescriptor planeDescriptor, Point3D linePointOne, Point3D linePointTwo ) { double m = linePointTwo.X - linePointOne.X; double n = linePointTwo.Y - linePointOne.Y; double p = linePointTwo.Z - linePointOne.Z; double a = planeDescriptor.CoefficientOfX; double b = planeDescriptor.CoefficientOfY; double c = planeDescriptor.CoefficientOfZ; double d = planeDescriptor.AbsoluteTerm; double t = -(d + a * linePointOne.X + b * linePointOne.Y + c * linePointOne.Z) / (a * m + b * n + c * p); double x = m * t + linePointOne.X; double y = n * t + linePointOne.Y; double z = p * t + linePointOne.Z; return(new Point3D(x, y, z)); }