/** * 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); }
/** * A factory to create a DTriangle from a Geometry * * @param geom * @return * @throws IllegalArgumentException * If there are not exactly 3 coordinates in geom. */ public static Triangle createTriangle(Geometry geom) throws IllegalArgumentException { Coordinate[] coordinates = geom.getCoordinates(); if (coordinates.length != 4) { throw new IllegalArgumentException("The geometry must be a triangle"); } return new Triangle(coordinates[0],coordinates[1],coordinates[2]); }
/** * A factory to create a DTriangle from a Geometry * * @param geom * @return * @throws DelaunayError * If the triangle can't be generated * @throws IllegalArgumentException * If there are not exactly 3 coordinates in geom. */ public static Triangle createTriangle(Geometry geom) throws IllegalArgumentException { Coordinate[] coordinates = geom.getCoordinates(); if (coordinates.length != 4) { throw new IllegalArgumentException("The geometry must be a triangle"); } return new Triangle(coordinates[0],coordinates[1],coordinates[2]); }
private Triangle getTriangle(int idTri) { Coordinate[] coordinates = inputTriangles.getGeometryN(idTri).getCoordinates(); return new Triangle(coordinates[0], coordinates[1], coordinates[2]); } private LineSegment getTriangleSegment(int idTri, int idSegment) {
private Triangle getTriangle(int idTri) { Coordinate[] coordinates = inputTriangles.getGeometryN(idTri).getCoordinates(); return new Triangle(coordinates[0], coordinates[1], coordinates[2]); } private LineSegment getTriangleSegment(int idTri, int idSegment) {
/** * 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); }