Sharp3D.Math.Geometry3D.Plane incorrect equation for _const (D)

Topics: Developer Forum
May 17, 2007 at 9:43 PM
Edited May 18, 2007 at 1:14 PM
I think I found a mistake in two of the overloaded constructors of the Sharp3D.Math.Geometry3D.Plane object. Looks like the sign on the equation for _const is wrong. For a plane _const, or D where Ax + By + Cz + D = 0, is equal to the negative of the dot product of the normal vector and a point on the plane, i.e. n dot p = -d. The negative sign is missing in two of the constructors. Check out http://en.wikipedia.org/wiki/Plane_(mathematics) for verification and further information on a plane.

The following are corrected constructor overloads:

// multi-line
        /// <summary>
        /// Initializes a new instance of the <see cref="Plane"/> class using given normal and a point.
        /// </summary>
        /// <param name="normal">The plane's normal vector.</param>
        /// <param name="point">A point on the plane in 3D space.</param>
        public Plane( Vector3F normal, Vector3F point )
        {
            _normal = normal;
            /*
             *                      | A |
             * Given the normal n = | B | and p as an (x,y,z) point on the plane, then d is the 
             *                      | C |
             * dot product, n dot p = -d.
             */
            _const = -Vector3F.DotProduct( normal, point );
        }
 
        /// <summary>
        /// Initializes a new instance of the <see cref="Plane"/> class using 3 given points.
        /// </summary>
        /// <param name="p0">A point on the plane in 3D space.</param>
        /// <param name="p1">A point on the plane in 3D space.</param>
        /// <param name="p2">A point on the plane in 3D space.</param>
        public Plane( Vector3F p0, Vector3F p1, Vector3F p2 )
        {
            _normal = Vector3F.CrossProduct( p1 - p0, p2 - p0 );
            _normal.Normalize( );
            /*
             *                      | A |
             * Given the normal n = | B | and p as an (x,y,z) point on the plane, then d is the 
             *                      | C |
             * dot product, n dot p = -d.
             */
            _const = -Vector3F.DotProduct( _normal, p0 );
        }