public void clearAndUpdate(ReferenceFrame referenceFrame) { convexPolygon.clearAndUpdate(); this.referenceFrame = referenceFrame; }
private static boolean buildCommonPolygonFromBridges(ArrayList<Integer> bridgeIndicesP, ArrayList<Integer> bridgeIndicesQ, ArrayList<Boolean> bridgeWasOnLeft, ConvexPolygon2d polygonP, ConvexPolygon2d polygonQ, ConvexPolygon2d intersectingPolygonToPack) { int[][][] crossingIndices = new int[bridgeIndicesP.size()][][]; for (int i = 0; i < crossingIndices.length; i++) { // find intersection for bridge int bridgeIndexForPolygonP = bridgeIndicesP.get(i); int bridgeIndexForPolygonQ = bridgeIndicesQ.get(i); // for each bridge, compute the intersection points crossingIndices[i] = findCrossingIndices(bridgeWasOnLeft.get(i), bridgeIndexForPolygonP, bridgeIndexForPolygonQ, polygonP, polygonQ); if (crossingIndices[i] == null) { intersectingPolygonToPack.clearAndUpdate(); return false; // No intersection. } } boolean success = constructPolygonForIntersection(bridgeWasOnLeft, crossingIndices, polygonP, polygonQ, intersectingPolygonToPack); return success; }
private static boolean computeIntersectionOfPolygonsIfOnePolygonHasExactlyOneVertex(ConvexPolygon2d polygonWithExactlyOneVertex, ConvexPolygon2d otherPolygon, ConvexPolygon2d intersectingPolygon) { if (otherPolygon.pointIsOnPerimeter(polygonWithExactlyOneVertex.getVertex(0))) { intersectingPolygon.setAndUpdate(polygonWithExactlyOneVertex); return false; } else { intersectingPolygon.clearAndUpdate(); return false; } }
private static boolean computeIntersectionOfPolygonsIfOnePolygonHasExactlyTwoVerticesAndTheOtherHasAtLeastTwoVertices( ConvexPolygon2d polygonWithExactlyTwoVertices, ConvexPolygon2d polygonWithAtLeastTwoVertices, ConvexPolygon2d intersectingPolygon) { LineSegment2d polygonWithTwoVerticesAsLineSegment = new LineSegment2d(polygonWithExactlyTwoVertices.getVertex(0), polygonWithExactlyTwoVertices.getVertex(1)); Point2d[] intersection = polygonWithAtLeastTwoVertices.intersectionWith(polygonWithTwoVerticesAsLineSegment); if (intersection == null) { intersectingPolygon.clearAndUpdate(); return false; } else { intersectingPolygon.setAndUpdate(intersection, intersection.length); return true; } }
if (!success) intersectingPolygonToPack.clearAndUpdate(); return false;