示例#1
0
        //Создаем треугольник по координатам трех точек
        public Triangle(Point pointA, Point pointB, Point pointC)
        {
            if (pointA is null || pointB is null || pointC is null)
            {
                throw new ArgumentNullException();
            }

            double aB = GeomUtils.CalcDistance(pointA, pointB);
            double bC = GeomUtils.CalcDistance(pointB, pointC);
            double aC = GeomUtils.CalcDistance(pointA, pointC);

            if (aB >= bC + aC || bC >= aB + aC || aC >= bC + aB)  //проверяем, может ли такой треугольник существовать
            {
                throw new ArgumentException("This triangle cant exist");
            }

            PointA = pointA;
            PointB = pointB;
            PointC = pointC;
        }
示例#2
0
 public override double CalcPerimeter()
 {
     return(GeomUtils.CalcDistance(PointA, PointB) + GeomUtils.CalcDistance(PointB, PointC) + GeomUtils.CalcDistance(PointA, PointC));
 }