/// <summary> /// Returns the distance of a point from a plane. /// </summary> /// <param name="plane">The plane</param> /// <param name="p">The point</param> /// <returns>The distance of the point from the plane</returns> public static double DistanceFromPoint(this Plane3D plane, Point3D p) { var dominator = Vector3D.DotProduct(p - Origin, plane.Normal) - plane.D; var denominator = plane.Normal.Length; return(Math.Abs(dominator / denominator)); }
public static double IntersectLine(this Plane3D plane, Point3D p1, Point3D p2) { var l = p2 - p1; var t = (plane.D - Vector3D.DotProduct((Vector3D)p1, plane.Normal)) / Vector3D.DotProduct(l, plane.Normal); return(t); }
/// <summary> /// Projects a point on the given plane. /// </summary> /// <param name="plane">The plane to project on</param> /// <param name="p">The point to project</param> /// <returns>The projection of the point on the plane.</returns> public static Point3D ProjectPoint(this Plane3D plane, Point3D p) { var dominator = Vector3D.DotProduct(p - Origin, plane.Normal) - plane.D; var denumerator = plane.Normal.LengthSquared; var t = -dominator / denumerator; return(p - t * plane.Normal); }