Esempio n. 1
0
        /// <summary>
        /// Returns the normal for the  triangle. (Costly method!)
        /// </summary>
        /// <remarks>
        /// <para>
        /// The normal of a triangle is the vector perpendicular to the triangle's plane
        /// with the direction determined by the
        /// <a href="http://en.wikipedia.org/wiki/Right-hand_rule" target="_blank">
        /// right-handed rule</a>.
        /// </para>
        /// </remarks>
        /// <param name="a">Vertex A of triangle ABC.</param>
        /// <param name="b">Vertex B of triangle ABC.</param>
        /// <param name="c">Vertex C of triangle ABC.</param>
        /// <returns>The normal of the  triangle.</returns>
        public static Vector3 GetNormal(Vector3 a, Vector3 b, Vector3 c)
        {
            // Reference:
            // http://en.wikipedia.org/wiki/Surface_normal#Calculating_a_surface_normal
            // N = (B - A) x (C - A) with the final result normalized.

            return(Vector3Util.Normalize(Vector3Util.Cross(b - a, c - a)));
        }