Пример #1
0
        /// <summary>
        /// Returns the aspect ratio of the triangle defined by 3 given points.
        /// This is defined as the longest edge / shortest altitude.
        /// </summary>
        /// <param name="points"></param>
        /// <returns></returns>
        public static double GetTriAspect(Vec3d p0, Vec3d p1, Vec3d p2)
        {
            double maxEdge = 0.0;                     // longest edge
            double minAlt  = Double.PositiveInfinity; // shortest altitude

            Vec3d v0 = p1 - p0;
            Vec3d v1 = p2 - p1;
            Vec3d v2 = p0 - p2;

            Sub(v0, v1);
            Sub(v1, v2);
            Sub(v2, v0);

            return(Math.Sqrt(maxEdge) / Math.Sqrt(minAlt));

            void Sub(Vec3d a, Vec3d b)
            {
                maxEdge = Math.Max(maxEdge, a.SquareLength);
                minAlt  = Math.Min(minAlt, Vec3d.Reject(b, a).SquareLength);
            }
        }