@@ -86,18 +86,18 @@ private CSG monotoneExtrude(Vector3d dir, Polygon polygon1) {
86
86
CSG extrude ;
87
87
//polygon1=polygon1.flipped();
88
88
newPolygons .addAll (PolygonUtil .concaveToConvex (polygon1 .flipped ()));
89
- Polygon polygon2 = polygon1 .translated ( dir );
89
+ Polygon polygon2 = polygon1 .transformed ( new Transform (). move ( dir ) );
90
90
91
- int numvertices = polygon1 .vertices .size ();
91
+ int numvertices = polygon1 .getVertices () .size ();
92
92
//com.neuronrobotics.sdk.common.Log.error("Building Polygon "+polygon1.getPoints().size());
93
93
for (int i = 0 ; i < numvertices ; i ++) {
94
94
95
95
int nexti = (i + 1 ) % numvertices ;
96
96
97
- Vector3d bottomV1 = polygon1 .vertices .get (i ).pos ;
98
- Vector3d topV1 = polygon2 .vertices .get (i ).pos ;
99
- Vector3d bottomV2 = polygon1 .vertices .get (nexti ).pos ;
100
- Vector3d topV2 = polygon2 .vertices .get (nexti ).pos ;
97
+ Vector3d bottomV1 = polygon1 .getVertices () .get (i ).pos ;
98
+ Vector3d topV1 = polygon2 .getVertices () .get (i ).pos ;
99
+ Vector3d bottomV2 = polygon1 .getVertices () .get (nexti ).pos ;
100
+ Vector3d topV2 = polygon2 .getVertices () .get (nexti ).pos ;
101
101
double distance = bottomV1 .minus (bottomV2 ).magnitude ();
102
102
if (Math .abs (distance )<Plane .getEPSILON ()) {
103
103
//com.neuronrobotics.sdk.common.Log.error("Skipping invalid polygon "+i+" to "+nexti);
@@ -149,19 +149,19 @@ public static CSG polygons(Polygon polygon1, Polygon polygon2) {
149
149
List <Polygon > newPolygons = new ArrayList <>();
150
150
CSG extrude ;
151
151
newPolygons .addAll (PolygonUtil .concaveToConvex (polygon1 .flipped ()));
152
- if (polygon1 .vertices .size () != polygon2 .vertices .size ()) {
152
+ if (polygon1 .getVertices () .size () != polygon2 .getVertices () .size ()) {
153
153
throw new RuntimeException ("These polygons do not match" );
154
154
}
155
155
156
- int numvertices = polygon1 .vertices .size ();
156
+ int numvertices = polygon1 .getVertices () .size ();
157
157
for (int i = 0 ; i < numvertices ; i ++) {
158
158
159
159
int nexti = (i + 1 ) % numvertices ;
160
160
161
- Vector3d bottomV1 = polygon1 .vertices .get (i ).pos ;
162
- Vector3d topV1 = polygon2 .vertices .get (i ).pos ;
163
- Vector3d bottomV2 = polygon1 .vertices .get (nexti ).pos ;
164
- Vector3d topV2 = polygon2 .vertices .get (nexti ).pos ;
161
+ Vector3d bottomV1 = polygon1 .getVertices () .get (i ).pos ;
162
+ Vector3d topV1 = polygon2 .getVertices () .get (i ).pos ;
163
+ Vector3d bottomV2 = polygon1 .getVertices () .get (nexti ).pos ;
164
+ Vector3d topV2 = polygon2 .getVertices () .get (nexti ).pos ;
165
165
166
166
List <Vector3d > pPoints = Arrays .asList (bottomV2 , topV2 , topV1 , bottomV1 );
167
167
@@ -266,15 +266,15 @@ public static boolean isCCW(Polygon polygon) {
266
266
267
267
// thanks to Sepp Reiter for explaining me the algorithm!
268
268
269
- if (polygon .vertices .size () < 3 ) {
269
+ if (polygon .getVertices () .size () < 3 ) {
270
270
throw new IllegalArgumentException ("Only polygons with at least 3 vertices are supported!" );
271
271
}
272
272
273
273
// search highest left vertex
274
274
int highestLeftVertexIndex = 0 ;
275
- Vertex highestLeftVertex = polygon .vertices .get (0 );
276
- for (int i = 0 ; i < polygon .vertices .size (); i ++) {
277
- Vertex v = polygon .vertices .get (i );
275
+ Vertex highestLeftVertex = polygon .getVertices () .get (0 );
276
+ for (int i = 0 ; i < polygon .getVertices () .size (); i ++) {
277
+ Vertex v = polygon .getVertices () .get (i );
278
278
279
279
if (v .pos .y > highestLeftVertex .pos .y ) {
280
280
highestLeftVertex = v ;
@@ -286,13 +286,13 @@ public static boolean isCCW(Polygon polygon) {
286
286
}
287
287
288
288
// determine next and previous vertex indices
289
- int nextVertexIndex = (highestLeftVertexIndex + 1 ) % polygon .vertices .size ();
289
+ int nextVertexIndex = (highestLeftVertexIndex + 1 ) % polygon .getVertices () .size ();
290
290
int prevVertexIndex = highestLeftVertexIndex - 1 ;
291
291
if (prevVertexIndex < 0 ) {
292
- prevVertexIndex = polygon .vertices .size () - 1 ;
292
+ prevVertexIndex = polygon .getVertices () .size () - 1 ;
293
293
}
294
- Vertex nextVertex = polygon .vertices .get (nextVertexIndex );
295
- Vertex prevVertex = polygon .vertices .get (prevVertexIndex );
294
+ Vertex nextVertex = polygon .getVertices () .get (nextVertexIndex );
295
+ Vertex prevVertex = polygon .getVertices () .get (prevVertexIndex );
296
296
297
297
// edge 1
298
298
double a1 = normalizedX (highestLeftVertex .pos , nextVertex .pos );
@@ -309,12 +309,12 @@ public static boolean isCCW(Polygon polygon) {
309
309
selectedVIndex = prevVertexIndex ;
310
310
}
311
311
312
- if (selectedVIndex == 0 && highestLeftVertexIndex == polygon .vertices .size () - 1 ) {
313
- selectedVIndex = polygon .vertices .size ();
312
+ if (selectedVIndex == 0 && highestLeftVertexIndex == polygon .getVertices () .size () - 1 ) {
313
+ selectedVIndex = polygon .getVertices () .size ();
314
314
}
315
315
316
- if (highestLeftVertexIndex == 0 && selectedVIndex == polygon .vertices .size () - 1 ) {
317
- highestLeftVertexIndex = polygon .vertices .size ();
316
+ if (highestLeftVertexIndex == 0 && selectedVIndex == polygon .getVertices () .size () - 1 ) {
317
+ highestLeftVertexIndex = polygon .getVertices () .size ();
318
318
}
319
319
320
320
// indicates whether edge points from highestLeftVertexIndex towards
@@ -605,16 +605,16 @@ public static CSG sweep(Polygon p, double angle, double z, double radius, int st
605
605
public static List <Polygon > monotoneExtrude (Polygon polygon2 , Polygon polygon1 ) {
606
606
List <Polygon > newPolygons = new ArrayList <>();
607
607
608
- int numvertices = polygon1 .vertices .size ();
608
+ int numvertices = polygon1 .getVertices () .size ();
609
609
610
610
for (int i = 0 ; i < numvertices ; i ++) {
611
611
612
612
int nexti = (i + 1 ) % numvertices ;
613
613
614
- Vector3d bottomV1 = polygon1 .vertices .get (i ).pos ;
615
- Vector3d topV1 = polygon2 .vertices .get (i ).pos ;
616
- Vector3d bottomV2 = polygon1 .vertices .get (nexti ).pos ;
617
- Vector3d topV2 = polygon2 .vertices .get (nexti ).pos ;
614
+ Vector3d bottomV1 = polygon1 .getVertices () .get (i ).pos ;
615
+ Vector3d topV1 = polygon2 .getVertices () .get (i ).pos ;
616
+ Vector3d bottomV2 = polygon1 .getVertices () .get (nexti ).pos ;
617
+ Vector3d topV2 = polygon2 .getVertices () .get (nexti ).pos ;
618
618
double distance = bottomV1 .minus (bottomV2 ).magnitude ();
619
619
if (Math .abs (distance ) < Plane .getEPSILON ()) {
620
620
continue ;
0 commit comments