|
56 | 56 | * @author Michael Hoffer <[email protected]>
|
57 | 57 | */
|
58 | 58 | public class PolygonUtil {
|
59 |
| - |
| 59 | + private static final double triangleScale=1000.0; |
60 | 60 | /**
|
61 | 61 | * Instantiates a new polygon util.
|
62 | 62 | */
|
@@ -205,7 +205,7 @@ public static List<Polygon> concaveToConvex(Polygon incoming) {
|
205 | 205 | throw new RuntimeException("Failed to triangulate");
|
206 | 206 | for (int j = 0; j < 3; j++) {
|
207 | 207 | 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); |
209 | 209 | triPoints.add(new Vertex(pos, normal));
|
210 | 210 |
|
211 | 211 | if (counter == 2) {
|
@@ -281,10 +281,10 @@ private static Geometry makeTriangles(Polygon concave, boolean cw) {
|
281 | 281 | Coordinate[] coordinates = new Coordinate[toTri.getVertices().size() + 1];
|
282 | 282 | for (int i = 0; i < toTri.getVertices().size(); i++) {
|
283 | 283 | 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); |
285 | 285 | }
|
286 | 286 | 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); |
288 | 288 | // use the default factory, which gives full double-precision
|
289 | 289 | Geometry geom = new GeometryFactory().createPolygon(coordinates);
|
290 | 290 | triangles = ConstrainedDelaunayTriangulator.triangulate(geom);
|
|
0 commit comments