/** * Computes the incentre of this triangle. The <i>incentre</i> of a triangle * is the point which is equidistant from the sides of the triangle. It is * also the point at which the bisectors of the triangle's angles meet. It is * the centre of the triangle's <i>incircle</i>, which is the unique circle * that is tangent to each of the triangle's three sides. * * @return the point which is the inCentre of this triangle */ public Coordinate inCentre() { return inCentre(p0, p1, p2); }
/** * 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 */ private boolean isTriangleErodedCompletely( Coordinate[] triangleCoord, double bufferDistance) { Triangle tri = new Triangle(triangleCoord[0], triangleCoord[1], triangleCoord[2]); Coordinate inCentre = tri.inCentre(); double distToCentre = CGAlgorithms.distancePointLine(inCentre, tri.p0, tri.p1); return distToCentre < Math.abs(bufferDistance); }
/** * Computes the incentre of this triangle. The <i>incentre</i> of a triangle * is the point which is equidistant from the sides of the triangle. It is * also the point at which the bisectors of the triangle's angles meet. It is * the centre of the triangle's <i>incircle</i>, which is the unique circle * that is tangent to each of the triangle's three sides. * * @return the point which is the inCentre of this triangle */ public Coordinate inCentre() { return inCentre(p0, p1, p2); }
/** * 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 */ private boolean isTriangleErodedCompletely( Coordinate[] triangleCoord, double bufferDistance) { Triangle tri = new Triangle(triangleCoord[0], triangleCoord[1], triangleCoord[2]); Coordinate inCentre = tri.inCentre(); double distToCentre = CGAlgorithms.distancePointLine(inCentre, tri.p0, tri.p1); return distToCentre < Math.abs(bufferDistance); }