isTriangleErodedCompletely method

bool isTriangleErodedCompletely(
  1. List<Coordinate> triangleCoord,
  2. double bufferDistance
)

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.

@param triangleCoord @param bufferDistance @return

Implementation

bool isTriangleErodedCompletely(
    List<Coordinate> triangleCoord, double bufferDistance) {
  Triangle tri =
      new Triangle(triangleCoord[0], triangleCoord[1], triangleCoord[2]);
  Coordinate inCentre = tri.inCentre();
  double distToCentre = Distance.pointToSegment(inCentre, tri.p0, tri.p1);
  return distToCentre < bufferDistance.abs();
}