/// <summary>
        /// Gets intersection of two planes
        /// </summary>
        /// <param name="plane1">The first plane</param>
        /// <param name="plane2">The second plane</param>
        /// <param name="pointOnLine">Point on line where <paramref name="plane1"/> and <paramref name="plane1"/> are intersecting</param>
        /// <param name="dirVect">Direction vector of the intersection</param>
        /// <returns>True if intersection exists</returns>
        public static bool GetIntersection(Plane3D plane1, Plane3D plane2, out WM.Point3D pointOnLine, out WM.Vector3D dirVect)
        {
#if DEBUG
            // Normal vectors should be normalized
            WM.Vector3D testVect1 = plane1.NormalVector;
            testVect1.Normalize();
            WM.Vector3D testVect2 = plane2.NormalVector;
            testVect2.Normalize();
            Debug.Assert(WM.Vector3D.DotProduct(plane1.NormalVector, plane2.NormalVector).IsEqual(WM.Vector3D.DotProduct(testVect1, testVect2)));
#endif

            double normalDot = WM.Vector3D.DotProduct(plane1.NormalVector, plane2.NormalVector);
            double D         = (1 - normalDot * normalDot);
            if (D.IsZero())
            {
                pointOnLine = new WM.Point3D(double.NaN, double.NaN, double.NaN);
                dirVect     = new WM.Vector3D(double.NaN, double.NaN, double.NaN);
                return(false);
            }

            double h1 = -1 * plane1.GetD();
            double h2 = -1 * plane2.GetD();

            double c1 = (h1 - h2 * normalDot) / D;
            double c2 = (h2 - h1 * normalDot) / D;

            dirVect = WM.Vector3D.CrossProduct(plane1.NormalVector, plane2.NormalVector);
            dirVect.Normalize();
            pointOnLine = (WM.Point3D)(c1 * plane1.NormalVector + c2 * plane2.NormalVector);
            return(true);
        }
 /// <summary>
 /// Caluclates distance from a point to a plane
 /// </summary>
 /// <param name="src">Plane</param>
 /// <param name="p">Point</param>
 /// <returns>Distance from a point to a plane (positive value is in the direction of the normal vector)</returns>
 public static double GetPointDistance(this Plane3D src, IPoint3D p)
 {
     return((WM.Vector3D.DotProduct(src.NormalVector, new WM.Vector3D(p.X, p.Y, p.Z)) + src.GetD()) / src.NormalVector.Length);
 }
 /// <summary>
 /// Caluclates distance from a point to a plane
 /// </summary>
 /// <param name="src">Plane</param>
 /// <param name="p">Point</param>
 /// <returns>Distance from a point to a plane (positive value is in the direction of the normal vector)</returns>
 public static double GetPointDistance(this Plane3D src, ref WM.Point3D p)
 {
     return((WM.Vector3D.DotProduct(src.NormalVector, (WM.Vector3D)p) + src.GetD()) / src.NormalVector.Length);
 }