Search in sources :

Example 6 with TriangleImpl

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);
}
Also used : TriangleImpl(com.revolsys.geometry.model.util.TriangleImpl) Point(com.revolsys.geometry.model.Point)

Example 7 with TriangleImpl

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);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) TriangleImpl(com.revolsys.geometry.model.util.TriangleImpl)

Example 8 with TriangleImpl

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);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) TriangleImpl(com.revolsys.geometry.model.util.TriangleImpl)

Example 9 with TriangleImpl

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);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) TriangleImpl(com.revolsys.geometry.model.util.TriangleImpl)

Aggregations

TriangleImpl (com.revolsys.geometry.model.util.TriangleImpl)9 Geometry (com.revolsys.geometry.model.Geometry)6 Point (com.revolsys.geometry.model.Point)3 LineString (com.revolsys.geometry.model.LineString)1 Polygon (com.revolsys.geometry.model.Polygon)1