public SteppingStone(String name, double baseZ, double height, ConvexPolygon2D convexPolygon2d, ConvexPolygon2D footPolygon) { this.name = name; this.baseZ = baseZ; this.height = height; this.convexPolygon2d = new ConvexPolygon2D(convexPolygon2d); polygonToShrink = new ConvexPolygon2D(footPolygon); new ConvexPolygonTools().shrinkInto(polygonToShrink, new Point2D(0.0, 0.0), convexPolygon2d, shrunkenPolygon); }
public SteppingStone(String name, double baseZ, double height, ArrayList<Point2D> points, ConvexPolygon2D footPolygon) { this.name = name; this.baseZ = baseZ; this.height = height; convexPolygon2d = new ConvexPolygon2D(Vertex2DSupplier.asVertex2DSupplier(points)); polygonToShrink = new ConvexPolygon2D(footPolygon); new ConvexPolygonTools().shrinkInto(polygonToShrink, new Point2D(0.0, 0.0), convexPolygon2d, shrunkenPolygon); }
boolean success = new ConvexPolygonTools().computeIntersectionOfPolygons(convexPolygon2ds.get(i), captureRegionPolygon, intersection); if (success)
@ContinuousIntegrationTest(estimatedDuration = 0.0) @Test(timeout = 30000) public void testIntersectionWhenFullyInsideWithRepeatedPoint() { ConvexPolygonTools convexPolygonTools = new ConvexPolygonTools(); ArrayList<Point2D> listOfPoints = new ArrayList<Point2D>(); listOfPoints.add(new Point2D(0.19, 0.0)); listOfPoints.add(new Point2D(0.192, 0.6)); listOfPoints.add(new Point2D(0.25, 0.5)); listOfPoints.add(new Point2D(0.19, 0.0)); ConvexPolygon2D convexPolygon2dA = new ConvexPolygon2D(Vertex2DSupplier.asVertex2DSupplier(listOfPoints)); listOfPoints.clear(); listOfPoints.add(new Point2D(-1.0, -1.0)); listOfPoints.add(new Point2D(2.0, -1.0)); listOfPoints.add(new Point2D(-1.0, 2.0)); listOfPoints.add(new Point2D(2.0, 2.0)); ConvexPolygon2D convexPolygon2dB = new ConvexPolygon2D(Vertex2DSupplier.asVertex2DSupplier(listOfPoints)); ConvexPolygon2D intersection = new ConvexPolygon2D(); convexPolygonTools.computeIntersectionOfPolygons(convexPolygon2dA, convexPolygon2dB, intersection); boolean epsilonEquals = intersection.epsilonEquals(convexPolygon2dA, 1e-14); assertTrue(epsilonEquals); convexPolygonTools.computeIntersectionOfPolygons(convexPolygon2dB, convexPolygon2dA, intersection); epsilonEquals = intersection.epsilonEquals(convexPolygon2dA, 1e-14); assertTrue(epsilonEquals); }
boolean success = new ConvexPolygonTools().computeIntersectionOfPolygons(convexPolygon2ds.get(i), captureRegionPolygon, intersection); if (success)
@ContinuousIntegrationTest(estimatedDuration = 0.0) @Test(timeout = 30000) public void testDistanceBetweenPolygonsIntersectingPolygons() { ConvexPolygon2D polygon1 = getPolygon(new double[] {0, 0, 0, 1, 1, 0, 2, 1, 1, 2}); ConvexPolygon2D polygon2 = getPolygon(new double[] {1, 1, 0, 3, 2, 2, 3, 0}); try { new ConvexPolygonTools().computeMinimumDistancePoints(polygon1, polygon2, new Point2D(), new Point2D()); fail(); } catch (RuntimeException re) { assertEquals(re.getMessage(), "Cannot compute minimum distance between intersecting polygons."); } try { new ConvexPolygonTools().computeMinimumDistancePoints(polygon2, polygon1, new Point2D(), new Point2D()); fail(); } catch (RuntimeException re) { assertEquals(re.getMessage(), "Cannot compute minimum distance between intersecting polygons."); } }
public void testIntersectionWhenFullyInside() ConvexPolygonTools convexPolygonTools = new ConvexPolygonTools();
public void testPolygonIntersections() ConvexPolygonTools convexPolygonTools = new ConvexPolygonTools(); Random random = new Random(1886L);
/** * Returns a transform that will move the given polygon into a planar region. Problematic if the planar region consists of * multiple sub convex polygons. The polygon to wiggle must have the same transform to world as the planar region. * * @param polygonToWiggleInRegionFrame * @param regionToWiggleInto * @param wiggleParameters * @return */ public static RigidBodyTransform wigglePolygonIntoRegion(ConvexPolygon2D polygonToWiggleInRegionFrame, PlanarRegion regionToWiggleInto, WiggleParameters parameters) { // find the part of the region that has the biggest intersection with the polygon ConvexPolygon2D bestMatch = null; double overlap = 0.0; ConvexPolygonTools convexPolygonTools = new ConvexPolygonTools(); for (int i = 0; i < regionToWiggleInto.getNumberOfConvexPolygons(); i++) { ConvexPolygon2D intersection = new ConvexPolygon2D(); convexPolygonTools.computeIntersectionOfPolygons(regionToWiggleInto.getConvexPolygon(i), polygonToWiggleInRegionFrame, intersection); if (intersection.getArea() > overlap) { overlap = intersection.getArea(); bestMatch = regionToWiggleInto.getConvexPolygon(i); } } if (bestMatch == null) return null; return findWiggleTransform(polygonToWiggleInRegionFrame, bestMatch, parameters); }
polygon2.update(); ConvexPolygonTools convexPolygonTools = new ConvexPolygonTools(); FrameConvexPolygon2D actualPolygon = new FrameConvexPolygon2D(); FrameLineSegment2D connectingEdge1 = new FrameLineSegment2D();
FrameConvexPolygon2D polygon2 = new FrameConvexPolygon2D(FrameVertex2DSupplier.asFrameVertex2DSupplier(points2)); ConvexPolygonTools convexPolygonTools = new ConvexPolygonTools(); FrameConvexPolygon2D combinedPolygon = new FrameConvexPolygon2D(zUpFrame); FrameLineSegment2D connectingEdge1 = new FrameLineSegment2D(zUpFrame);
private void assertPolygons(double[] p1, double[] p2, double[] expectedSolution, double epsilon) { if (expectedSolution.length != 4) { throw new RuntimeException("Invalid input."); } ConvexPolygon2D polygon1 = getPolygon(p1); ConvexPolygon2D polygon2 = getPolygon(p2); Point2D[] closestPoints = new Point2D[] {new Point2D(), new Point2D()}; Point2D[] closestPointsReversed = new Point2D[] {new Point2D(), new Point2D()}; ConvexPolygonTools convexPolygonTools = new ConvexPolygonTools(); convexPolygonTools.computeMinimumDistancePoints(polygon1, polygon2, closestPoints[0], closestPoints[1]); convexPolygonTools.computeMinimumDistancePoints(polygon2, polygon1, closestPointsReversed[0], closestPointsReversed[1]); assertEquals(closestPoints[0].distance(closestPoints[1]), closestPointsReversed[0].distance(closestPointsReversed[1]), epsilon); assertEquals(expectedSolution[0], closestPoints[0].getX(), epsilon); assertEquals(expectedSolution[1], closestPoints[0].getY(), epsilon); assertEquals(expectedSolution[2], closestPoints[1].getX(), epsilon); assertEquals(expectedSolution[3], closestPoints[1].getY(), epsilon); }
Random random = new Random(756483920L); ConvexPolygonTools convexPolygonTools = new ConvexPolygonTools();
Random random = new Random(756483920L); ConvexPolygonTools convexPolygonTools = new ConvexPolygonTools();