/// <summary>
 /// Tests whether a triangular ring would be eroded completely by the given
 /// buffer distance.
 /// This is a precise test.  It uses the fact that the inner buffer of a
 /// triangle converges on the inCentre of the triangle (the point
 /// equidistant from all sides).  If the buffer distance is greater than the
 /// distance of the inCentre from a side, the triangle will be eroded completely.
 /// This test is important, since it removes a problematic case where
 /// the buffer distance is slightly larger than the inCentre distance.
 /// In this case the triangle buffer curve "inverts" with incorrect topology,
 /// producing an incorrect hole in the buffer.
 /// </summary>
 /// <param name="triangleCoord"></param>
 /// <param name="bufferDistance"></param>
 /// <returns></returns>
 private static bool IsTriangleErodedCompletely(Coordinate[] triangleCoord, double bufferDistance)
 {
     var tri = new Triangle(triangleCoord[0], triangleCoord[1], triangleCoord[2]);
     var inCentre = tri.InCentre();
     var distToCentre = CGAlgorithms.DistancePointLine(inCentre, tri.P0, tri.P1);
     return distToCentre < Math.Abs(bufferDistance);
 }
 public static IGeometry Incentre(IGeometry g)
 {
     Coordinate[] pts = TrianglePts(g);
     Triangle t = new Triangle(pts[0], pts[1], pts[2]);
     Coordinate cc = t.InCentre();
     IGeometryFactory geomFact = FunctionsUtil.GetFactoryOrDefault(g);
     return geomFact.CreatePoint(cc);
 }
 public static IGeometry AngleBisectors(IGeometry g)
 {
     Coordinate[] pts = TrianglePts(g);
     Triangle t = new Triangle(pts[0], pts[1], pts[2]);
     Coordinate cc = t.InCentre();
     IGeometryFactory geomFact = FunctionsUtil.GetFactoryOrDefault(g);
     ILineString[] line = new ILineString[3];
     line[0] = geomFact.CreateLineString(new[] { pts[0], cc });
     line[1] = geomFact.CreateLineString(new[] { pts[1], cc });
     line[2] = geomFact.CreateLineString(new[] { pts[2], cc });
     return geomFact.CreateMultiLineString(line);
 }