Beispiel #1
0
 /// <summary>
 ///   Формула Герона для вычисления площади треугольника
 /// </summary>
 /// <param name="A"> Вершина А </param>
 /// <param name="B"> Вершина В </param>
 /// <param name="C"> Вершина С </param>
 /// <returns> </returns>
 public static double GetTriangleSquareByGeron(Point2D A, Point2D B, Point2D C)
 {
     if (!A.IsEmpty && !B.IsEmpty && !C.IsEmpty)
     {
         double a = Point2D.GetDistance(A, B);
         double b = Point2D.GetDistance(B, C);
         double c = Point2D.GetDistance(C, A);
         double p = (a + b + c) / 2;
         return(Math.Sqrt(p * (p - a) * (p - b) * (p - c)));
     }
     return(0);
 }
Beispiel #2
0
        public static double GetTriangleSquareByGeron(Frame2D A, Frame2D B, Frame2D C)
        {
            double a   = Point2D.GetDistance(A.ToPoint2D(), B.ToPoint2D());
            double b   = Point2D.GetDistance(B.ToPoint2D(), C.ToPoint2D());
            double c   = Point2D.GetDistance(C.ToPoint2D(), A.ToPoint2D());
            double p   = (a + b + c) / 2;
            double res = p;

            res *= (p - a);
            res *= (p - b);
            res *= (p - c);
            double result = Math.Sqrt(res);

            if (double.IsNaN(result))
            {
                return(0);
            }
            return(result);
        }