Пример #1
0
        /// <summary>
        /// Static version of InCentre function.
        /// </summary>
        public static C2DPoint GetInCentre(C2DPoint pt1, C2DPoint pt2, C2DPoint pt3)
        {
            // Set up a line to bisect the lines from 1 to 2 and 1 to 3
            var Line1 = new C2DLine(pt1, pt2);
            var Line2 = new C2DLine(pt1, pt3);

            Line1.SetLength(Line2.GetLength());
            var Line12Bisect = new C2DLine(pt1, pt3.GetMidPoint(Line1.GetPointTo()));

            // Set up a line to bisect the lines from 2 to 1 and 2 to 3
            var Line3 = new C2DLine(pt2, pt1);
            var Line4 = new C2DLine(pt2, pt3);

            Line3.SetLength(Line4.GetLength());
            var Line34Bisect = new C2DLine(pt2, pt3.GetMidPoint(Line3.GetPointTo()));

            // Now intersect the 2 lines and find the point.
            var Int = new List <C2DPoint>();

            // Add the intersection even if there isn't one (i.e. infinite lines)
            bool B1 = true, B2 = true;

            Line12Bisect.Crosses(Line34Bisect, Int, ref B1, ref B2, true);

            Debug.Assert(Int.Count == 1);

            return(Int[0]);
        }
Пример #2
0
        /// <summary>
        /// Static version of InCentre function.
        /// </summary>
        public static C2DPoint GetInCentre(C2DPoint pt1, C2DPoint pt2, C2DPoint pt3)
        {
	        // Set up a line to bisect the lines from 1 to 2 and 1 to 3
	        C2DLine Line1 = new C2DLine(pt1, pt2);
	        C2DLine Line2 = new C2DLine(pt1, pt3);
	        Line1.SetLength( Line2.GetLength() );
	        C2DLine Line12Bisect = new C2DLine(  pt1, pt3.GetMidPoint( Line1.GetPointTo()));

	        // Set up a line to bisect the lines from 2 to 1 and 2 to 3
	        C2DLine Line3 = new C2DLine(pt2, pt1);
	        C2DLine Line4 = new C2DLine(pt2, pt3);
	        Line3.SetLength( Line4.GetLength() );
            C2DLine Line34Bisect = new C2DLine(pt2, pt3.GetMidPoint(Line3.GetPointTo()));

	        // Now intersect the 2 lines and find the point.
	        List<C2DPoint> Int = new List<C2DPoint>();

	        // Add the intersection even if there isn't one (i.e. infinite lines)
            bool B1 = true, B2 = true;
	        Line12Bisect.Crosses(Line34Bisect,  Int, ref B1, ref B2, true);

	        Debug.Assert (Int.Count == 1);

	        return Int[0];
        }