Esempio n. 1
0
        /// <summary>
        /// Computes the centre of the circumcircle of this vertex and two others.
        /// </summary>
        /// <param name="b" />
        /// <param name="c" />
        /// <returns>the Coordinate which is the circumcircle of the 3 points.</returns>
        public Vertex CircleCenter(Vertex b, Vertex c)
        {
            var a = new Vertex(X, Y);
            // compute the perpendicular bisector of cord ab
            var cab = Bisector(a, b);
            // compute the perpendicular bisector of cord bc
            var cbc = Bisector(b, c);
            // compute the intersection of the bisectors (circle radii)
            var    hcc = new HCoordinate(cab, cbc);
            Vertex cc  = null;

            try
            {
                cc = new Vertex(hcc.GetX(), hcc.GetY());
            }
            catch (NotRepresentableException nre)
            {
#if !PCL
                Debug.WriteLine("a: " + a + "  b: " + b + "  c: " + c);
                Debug.WriteLine(nre);
#endif
                //throw;
            }
            return(cc);
        }
Esempio n. 2
0
        ///<summary>Computes the circumcentre of a triangle.</summary>
        /// <remarks>
        /// The circumcentre is the centre of the circumcircle,
        /// the smallest circle which encloses the triangle.
        /// It is also the common intersection point of the
        /// perpendicular bisectors of the sides of the triangle,
        /// and is the only point which has equal distance to all three
        /// vertices of the triangle.
        /// </remarks>
        /// <param name="a">A vertex of the triangle</param>
        /// <param name="b">A vertex of the triangle</param>
        /// <param name="c">A vertex of the triangle</param>
        /// <returns>The circumcentre of the triangle</returns>
        public static Coordinate Circumcentre(Coordinate a, Coordinate b, Coordinate c)
        {
            // compute the perpendicular bisector of chord ab
            HCoordinate cab = PerpendicularBisector(a, b);
            // compute the perpendicular bisector of chord bc
            HCoordinate cbc = PerpendicularBisector(b, c);
            // compute the intersection of the bisectors (circle radii)
            HCoordinate hcc = new HCoordinate(cab, cbc);
            Coordinate  cc;

            try
            {
                cc = new Coordinate(hcc.GetX(), hcc.GetY());
            }
            catch (NotRepresentableException ex)
            {
                // MD - not sure what we can do to prevent this (robustness problem)
                // Idea - can we condition which edges we choose?
                throw new InvalidOperationException(ex.Message);
            }
            return(cc);
        }
Esempio n. 3
0
        /// <summary>
        /// Computes the centre of the circumcircle of this vertex and two others.
        /// </summary>
        /// <param name="b" />
        /// <param name="c" />
        /// <returns>the Coordinate which is the circumcircle of the 3 points.</returns>
        public Vertex CircleCenter(Vertex b, Vertex c)
        {
            Vertex a = new Vertex(this.X, this.Y);
            // compute the perpendicular bisector of cord ab
            HCoordinate cab = Bisector(a, b);
            // compute the perpendicular bisector of cord bc
            HCoordinate cbc = Bisector(b, c);
            // compute the intersection of the bisectors (circle radii)
            HCoordinate hcc = new HCoordinate(cab, cbc);
            Vertex      cc  = null;

            try
            {
                cc = new Vertex(hcc.GetX(), hcc.GetY());
            }
            catch (NotRepresentableException nre)
            {
                System.Console.WriteLine("a: " + a + "  b: " + b + "  c: " + c);
                System.Console.WriteLine(nre);
            }
            return(cc);
        }