/// <summary> /// Static version of circumcentre function. /// </summary> public static C2DPoint GetCircumCentre(C2DPoint pt1, C2DPoint pt2, C2DPoint pt3) { var Line12 = new C2DLine(pt1, pt2); var Line23 = new C2DLine(pt2, pt3); // Move the lines to start from the midpoint on them Line12.point.Set(Line12.GetMidPoint()); Line23.point.Set(Line23.GetMidPoint()); // Turn them right (left would work as well) Line12.vector.TurnRight(); Line23.vector.TurnRight(); // Find the intersection between them taking the intersect point even if they don't // intersect directly (i.e. where they would intersect because we may have turned them // the wrong way). var IntPt = new List <C2DPoint>(); bool B1 = true, B2 = true; Line12.Crosses(Line23, IntPt, ref B1, ref B2, true); var ptResult = new C2DPoint(0, 0); if (IntPt.Count == 1) { ptResult = IntPt[0]; } else { // co-linear so fail. Debug.Assert(false, "Colinnear triangle. Cannot calculate Circum Centre"); } return(ptResult); }
/// <summary> /// Static version of circumcentre function. /// </summary> public static C2DPoint GetCircumCentre(C2DPoint pt1, C2DPoint pt2, C2DPoint pt3) { C2DLine Line12 = new C2DLine (pt1, pt2); C2DLine Line23 = new C2DLine (pt2, pt3); // Move the lines to start from the midpoint on them Line12.point.Set( Line12.GetMidPoint()); Line23.point.Set( Line23.GetMidPoint()); // Turn them right (left would work as well) Line12.vector.TurnRight(); Line23.vector.TurnRight(); // Find the intersection between them taking the intersect point even if they don't // intersect directly (i.e. where they would intersect because we may have turned them // the wrong way). List<C2DPoint> IntPt = new List<C2DPoint>(); bool B1 = true , B2 = true; Line12.Crosses(Line23, IntPt,ref B1, ref B2, true); C2DPoint ptResult = new C2DPoint(0, 0); if (IntPt.Count == 1) { ptResult = IntPt[0]; } else { // co-linear so fail. Debug.Assert(false, "Colinnear triangle. Cannot calculate Circum Centre"); } return ptResult; }