use of com.revolsys.geometry.model.util.TriangleImpl in project com.revolsys.open by revolsys.
the class OffsetCurveSetBuilder method isTriangleErodedCompletely.
/**
* 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(final LinearRing triangleCoord, final double bufferDistance) {
final TriangleImpl tri = new TriangleImpl(triangleCoord.getVertex(0), triangleCoord.getVertex(1), triangleCoord.getVertex(2));
final Point inCentre = tri.inCentre();
final double distToCentre = LineSegmentUtil.distanceLinePoint(tri.p0, tri.p1, inCentre);
return distToCentre < Math.abs(bufferDistance);
}
use of com.revolsys.geometry.model.util.TriangleImpl in project com.revolsys.open by revolsys.
the class TriangleTest method checkArea3D.
public void checkArea3D(final String wkt, final double expectedValue) throws Exception {
final Geometry g = this.geometryFactory.geometry(wkt);
final TriangleImpl t = newTriangle(g);
final double area3D = t.area3D();
// System.out.println("area3D = " + area3D);
assertEquals(expectedValue, area3D, TOLERANCE);
}
use of com.revolsys.geometry.model.util.TriangleImpl in project com.revolsys.open by revolsys.
the class TriangleTest method checkInterpolateZ.
public void checkInterpolateZ(final String wkt, final Point p, final double expectedValue) throws Exception {
final Geometry g = this.geometryFactory.geometry(wkt);
final TriangleImpl t = newTriangle(g);
final double z = t.interpolateZ(p);
// System.out.println("Z = " + z);
assertEquals(expectedValue, z, 0.000001);
}
use of com.revolsys.geometry.model.util.TriangleImpl in project com.revolsys.open by revolsys.
the class TriangleTest method checkArea.
public void checkArea(final String wkt, final double expectedValue) throws Exception {
final Geometry g = this.geometryFactory.geometry(wkt);
final TriangleImpl t = newTriangle(g);
final double signedArea = t.signedArea();
// System.out.println("signed area = " + signedArea);
assertEquals(expectedValue, signedArea, TOLERANCE);
final double area = t.area();
assertEquals(Math.abs(expectedValue), area, TOLERANCE);
}
Aggregations