Ejemplo n.º 1
0
        public void Distant_Should()
        {
            var point1   = new PointB(1, 1, 1);
            var point3   = new PointB(3, 3, 3);
            var point123 = new PointB(1, 2, 3);

            Assert.AreEqual(0, point1.GetDistance(point1));

            Assert.AreEqual(2, point1.GetDistance(point3));

            Assert.AreEqual(point1.GetDistance(point123), point123.GetDistance(point1));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// override method get square for simple triangle
        /// </summary>
        /// <returns>Value of the square simple triangle</returns>
        public override double GetSquare()
        {
            double sizeSideAB = PointA.GetDistance(PointB);
            double sizeSideAC = PointA.GetDistance(PointC);
            double sizeSideBC = PointB.GetDistance(PointC);
            double poluPim    = (sizeSideAB + sizeSideAC + sizeSideBC) / 2;

            return(Math.Sqrt(poluPim * (poluPim - sizeSideAB) * (poluPim - sizeSideAC) * (poluPim - sizeSideBC)));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// override method get square for right triangle
        /// </summary>
        /// <returns>Value of the square right triangle</returns>
        public override double GetSquare()
        {
            double sizeSideAB = PointA.GetDistance(PointB);
            double sizeSideAC = PointA.GetDistance(PointC);
            double sizeSideBC = PointB.GetDistance(PointC);

            if (sizeSideAB < sizeSideBC && sizeSideAC < sizeSideBC)
            {
                return(sizeSideAB * sizeSideAC / 2);
            }
            else
            {
                if (sizeSideAB < sizeSideBC && sizeSideBC < sizeSideAC)
                {
                    return(sizeSideAB * sizeSideBC / 2);
                }
            }

            return(sizeSideAC * sizeSideBC / 2);
        }
Ejemplo n.º 4
0
        public override double GetArea()
        {
            double p = this.GetPerimeter() / 2.0;

            return(Math.Sqrt(p * (p - PointA.GetDistance(PointB)) * (p - PointA.GetDistance(PointC)) * (p - PointB.GetDistance(PointC))));
        }
Ejemplo n.º 5
0
 public override double GetPerimeter()
 {
     return(PointA.GetDistance(PointB) + PointA.GetDistance(PointC) + PointB.GetDistance(PointC));
 }