Skip to content

Commit e658c92

Browse files
committed
scale triangle generation to avoid internal epsilon unknown
1 parent a72f569 commit e658c92

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/eu/mihosoft/vrl/v3d/ext/org/poly2tri/PolygonUtil.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
* @author Michael Hoffer <[email protected]>
5757
*/
5858
public class PolygonUtil {
59-
59+
private static final double triangleScale=1000.0;
6060
/**
6161
* Instantiates a new polygon util.
6262
*/
@@ -205,7 +205,7 @@ public static List<Polygon> concaveToConvex(Polygon incoming) {
205205
throw new RuntimeException("Failed to triangulate");
206206
for (int j = 0; j < 3; j++) {
207207
Coordinate tp = coords[j];
208-
Vector3d pos = new Vector3d(tp.getX(), tp.getY(), zplane);
208+
Vector3d pos = new Vector3d(tp.getX()/triangleScale, tp.getY()/triangleScale, zplane);
209209
triPoints.add(new Vertex(pos, normal));
210210

211211
if (counter == 2) {
@@ -281,10 +281,10 @@ private static Geometry makeTriangles(Polygon concave, boolean cw) {
281281
Coordinate[] coordinates = new Coordinate[toTri.getVertices().size() + 1];
282282
for (int i = 0; i < toTri.getVertices().size(); i++) {
283283
Vector3d v = toTri.getVertices().get(i).pos;
284-
coordinates[i] = new Coordinate(v.x, v.y, v.z);
284+
coordinates[i] = new Coordinate(v.x*triangleScale, v.y*triangleScale, v.z*triangleScale);
285285
}
286286
Vector3d v = toTri.getVertices().get(0).pos;
287-
coordinates[toTri.getVertices().size()] = new Coordinate(v.x, v.y, v.z);
287+
coordinates[toTri.getVertices().size()] = new Coordinate(v.x*triangleScale, v.y*triangleScale, v.z*triangleScale);
288288
// use the default factory, which gives full double-precision
289289
Geometry geom = new GeometryFactory().createPolygon(coordinates);
290290
triangles = ConstrainedDelaunayTriangulator.triangulate(geom);

0 commit comments

Comments
 (0)