/** * Creates an empty convex polygon, adds N new vertices using a list of {@code Point2d}, updates the vertices so they are clockwise ordered, and initializes some essential numbers such as the centroid. * @param vertices {@code List<Point2d>} the list of points that is used to creates the vertices. * @param numberOfVertices int that is used to determine the number of vertices of the polygon. * Note the: {@code pointList.size()} can be greater or equal to numberOfVertices. */ public ConvexPolygon2d(List<Point2d> vertices, int numberOfVertices) { setAndUpdate(vertices, numberOfVertices); }
/** * Creates an empty convex polygon, adds N new vertices using an array of {@code Point2f}, updates the vertices so they are clockwise ordered, and initializes some essential numbers such as the centroid. * @param vertices {@code Point2f[]} the array of points that is used to creates the vertices. * @param numberOfVertices int that is used to determine the number of vertices of the polygon. * Note the: {@code vertices.length} can be greater or equal to numberOfVertices. */ public ConvexPolygon2d(Point2f[] vertices, int numberOfVertices) { setAndUpdate(vertices, numberOfVertices); }
@Override public void set(ConvexPolygon2d other) { setAndUpdate(other); }
/** * Creates a polygon with the same properties as the other polygon. * @param otherPolygon {@code ConvexPolygon2d} the other convex polygon. */ public ConvexPolygon2d(ConvexPolygon2d otherPolygon) { setAndUpdate(otherPolygon); }
/** * Creates an empty convex polygon, adds N new vertices using an array of {@code Point2d}, updates the vertices so they are clockwise ordered, and initializes some essential numbers such as the centroid. * @param vertices {@code Point2d[]} the array of points that is used to creates the vertices. * @param numberOfVertices int that is used to determine the number of vertices of the polygon. * Note the: {@code vertices.length} can be greater or equal to numberOfVertices. */ public ConvexPolygon2d(Point2d[] vertices, int numberOfVertices) { setAndUpdate(vertices, numberOfVertices); }
/** * Creates a new convex polygon by combining two other convex polygons. The result is the smallest convex hull that contains both polygons. * Then it updates the vertices so they are clockwise ordered, and initializes some essential numbers such as the centroid. * <p/> TODO: Make this more efficient by finding the rotating calipers, as in the intersection method.<p/> * * @param firstPolygon {@code ConvexPolygon2d} * @param secondPolygon {@code ConvexPolygon2d} */ public ConvexPolygon2d(ConvexPolygon2d firstPolygon, ConvexPolygon2d secondPolygon) { setAndUpdate(firstPolygon, secondPolygon); }
public void setFoothold(ConvexPolygon2d foothold) { this.foothold.setAndUpdate(foothold); }
public void getFoothold(ConvexPolygon2d footholdToPack) { if (!hasFoothold()) footholdToPack.setToNaN(); else footholdToPack.setAndUpdate(foothold); }
public void set(PlanarRegion other) { fromLocalToWorldTransform.set(other.fromLocalToWorldTransform); fromWorldToLocalTransform.set(other.fromWorldToLocalTransform); convexPolygons.clear(); for (int i = 0; i < other.getNumberOfConvexPolygons(); i++) convexPolygons.add(new ConvexPolygon2d(other.convexPolygons.get(i))); updateBoundingBox(); convexHull.setAndUpdate(other.convexHull); }
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; } }
public void update(Footstep footstep) { footstep.getSolePose(footstepPose); yoFootstepPose.setAndMatchFrame(footstepPose); List<Point2d> predictedContactPoints = footstep.getPredictedContactPoints(); List<Point2d> contactPointsToVisualize; if (predictedContactPoints == null || predictedContactPoints.isEmpty()) contactPointsToVisualize = defaultContactPointsInSoleFrame; else contactPointsToVisualize = predictedContactPoints; foothold.setAndUpdate(contactPointsToVisualize, contactPointsToVisualize.size()); yoFoothold.setConvexPolygon2d(foothold); poseViz.update(); footholdViz.update(); }
tempPolygon.setAndUpdate(pointsCopy, pointsCopy.size());
tempPolygon.setAndUpdate(pointsCopy, pointsCopy.size());
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; } }
polygonToPack.setAndUpdate(intersectionArrayList, intersectionArrayList.size());
polygonToPack.setAndUpdate(polygonQ); return true; newVertices.add(newVertex1); polygonToPack.setAndUpdate(newVertices, 2); polygonToPack.setAndUpdate(polygonQ);
intersectingPolygonToPack.setAndUpdate(polygonQ); intersectingPolygonToPack.setAndUpdate(polygonP);
footPolygonInRegion.setAndUpdate(footStepPolygon); footPolygonInRegion.applyTransformAndProjectToXYPlane(soleToRegion); ConvexPolygon2d foothold = regionToMoveTo.getConvexHull().intersectionWith(footPolygonInRegion);