/// <summary>
        /// Gets the intersection point of three planes.
        /// </summary>
        /// <param name="planeA">The first plane.</param>
        /// <param name="planeB">The second plane.</param>
        /// <param name="planeC">The third plane.</param>
        /// <returns>
        /// The point that touches all three planes. (<see cref="float.NaN"/>, <see cref="float.NaN"/>,
        /// <see cref="float.NaN"/>) is returned if there is no unique intersection point, for example,
        /// when two planes are parallel or the planes intersect in a line.
        /// </returns>
        public static Vector3F GetIntersection(Plane planeA, Plane planeB, Plane planeC)
        {
            // Get a point that meets this requirements: Dot(plane.Normal, point) == plane.DistanceFromOrigin
            Matrix33F matrix = new Matrix33F(planeA.Normal.X, planeA.Normal.Y, planeA.Normal.Z,
                                             planeB.Normal.X, planeB.Normal.Y, planeB.Normal.Z,
                                             planeC.Normal.X, planeC.Normal.Y, planeC.Normal.Z);
            Vector3F distances    = new Vector3F(planeA.DistanceFromOrigin, planeB.DistanceFromOrigin, planeC.DistanceFromOrigin);
            bool     isInvertible = matrix.TryInvert();

            if (isInvertible)
            {
                return(matrix * distances);
            }
            else
            {
                return(new Vector3F(float.NaN));
            }
        }
Пример #2
0
 /// <summary>
 /// Gets the intersection point of three planes.
 /// </summary>
 /// <param name="planeA">The first plane.</param>
 /// <param name="planeB">The second plane.</param>
 /// <param name="planeC">The third plane.</param>
 /// <returns>
 /// The point that touches all three planes. (<see cref="float.NaN"/>, <see cref="float.NaN"/>, 
 /// <see cref="float.NaN"/>) is returned if there is no unique intersection point, for example,
 /// when two planes are parallel or the planes intersect in a line.
 /// </returns>
 public static Vector3F GetIntersection(Plane planeA, Plane planeB, Plane planeC)
 {
     // Get a point that meets this requirements: Dot(plane.Normal, point) == plane.DistanceFromOrigin
       Matrix33F matrix = new Matrix33F(planeA.Normal.X, planeA.Normal.Y, planeA.Normal.Z,
                                planeB.Normal.X, planeB.Normal.Y, planeB.Normal.Z,
                                planeC.Normal.X, planeC.Normal.Y, planeC.Normal.Z);
       Vector3F distances = new Vector3F(planeA.DistanceFromOrigin, planeB.DistanceFromOrigin, planeC.DistanceFromOrigin);
       bool isInvertible = matrix.TryInvert();
       if (isInvertible)
     return matrix * distances;
       else
     return new Vector3F(float.NaN);
 }