public static ConvexPolygon2d generateRandomConvexPolygon2d(Random random, double maxAbsoluteXY, int numberOfPossiblePoints) { ArrayList<Point2d> vertices = new ArrayList<Point2d>(); for (int i = 0; i < numberOfPossiblePoints; i++) { vertices.add(RandomTools.generateRandomPoint2d(random, maxAbsoluteXY, maxAbsoluteXY)); } ConvexPolygon2d polygonToReturn = new ConvexPolygon2d(vertices); return polygonToReturn; }
public ConvexPolygon2d getConvexPolygon2dCopy() { convexPolygon.checkIfUpToDate(); return new ConvexPolygon2d(convexPolygon); }
@Override public ConvexPolygon2d applyTransformCopy(RigidBodyTransform transform) { ConvexPolygon2d copy = new ConvexPolygon2d(this); copy.applyTransform(transform); return copy; }
public static ConvexPolygon2d translatePolygonCopy(Tuple2d translation, ConvexPolygon2d polygon) { ConvexPolygon2d ret = new ConvexPolygon2d(polygon); translatePolygon(translation, ret); return ret; }
@Override public ConvexPolygon2d applyTransformAndProjectToXYPlaneCopy(RigidBodyTransform transform) { ConvexPolygon2d copy = new ConvexPolygon2d(this); copy.applyTransformAndProjectToXYPlane(transform); return copy; }
/** * Creates an empty convex polygon attached to a reference frame, adds N new vertices using the vertices of another {code ConvexPolygon2d}, updates the vertices so they are clockwise ordered, and initializes some essential numbers such as the centroid. * @param referenceFrame {@code ReferenceFrame} reference frame to which this polygon will be attached. * @param otherPolygon {@code ConvexPolygon2d} the other convex polygon. */ public FrameConvexPolygon2d(ReferenceFrame referenceFrame, ConvexPolygon2d otherPolygon) { super(referenceFrame, new ConvexPolygon2d()); this.convexPolygon = this.getGeometryObject(); setIncludingFrameAndUpdate(referenceFrame, otherPolygon); }
@Override public ConvexPolygon2d intersectionWith(ConvexPolygon2d convexPolygon) { checkIfUpToDate(); ConvexPolygon2d ret = new ConvexPolygon2d(); boolean success = ConvexPolygonTools.computeIntersectionOfPolygons(this, convexPolygon, ret); if (!success) ret = null; return ret; }
/** * Creates an empty convex polygon attached to a reference frame. * @param referenceFrame {@code ReferenceFrame} reference frame to which this polygon will be attached. */ public FrameConvexPolygon2d(ReferenceFrame referenceFrame) { super(referenceFrame, new ConvexPolygon2d()); this.convexPolygon = this.getGeometryObject(); update(); }
private void addRock(Vector3d normal, double centroidHeight, double[][] vertices) { ArrayList<Point2d> vertexPoints = new ArrayList<Point2d>(); for (double[] point : vertices) { Point2d point2d = new Point2d(point); vertexPoints.add(point2d); } ConvexPolygon2d convexPolygon = new ConvexPolygon2d(vertexPoints); RotatableConvexPolygonTerrainObject rock = new RotatableConvexPolygonTerrainObject(normal, convexPolygon, centroidHeight, YoAppearance.Red()); this.combinedTerrainObject.addTerrainObject(rock); }
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 void addRock(CombinedTerrainObject3D combinedTerrainObject, Vector3d normal, double centroidHeight, double[][] vertices) { AppearanceDefinition color = YoAppearance.DarkGray(); ArrayList<Point2d> vertexPoints = new ArrayList<Point2d>(); for (double[] point : vertices) { Point2d point2d = new Point2d(point); vertexPoints.add(point2d); } ConvexPolygon2d convexPolygon = new ConvexPolygon2d(vertexPoints); RotatableConvexPolygonTerrainObject rock = new RotatableConvexPolygonTerrainObject(normal, convexPolygon, centroidHeight, color); combinedTerrainObject.addTerrainObject(rock); }
private static void addRock(CombinedTerrainObject3D combinedTerrainObject, Vector3d normal, double centroidHeight, double[][] vertices) { AppearanceDefinition color = YoAppearance.DarkGray(); ArrayList<Point2d> vertexPoints = new ArrayList<Point2d>(); for (double[] point : vertices) { Point2d point2d = new Point2d(point); vertexPoints.add(point2d); } ConvexPolygon2d convexPolygon = new ConvexPolygon2d(vertexPoints); RotatableConvexPolygonTerrainObject rock = new RotatableConvexPolygonTerrainObject(normal, convexPolygon, centroidHeight, color); combinedTerrainObject.addTerrainObject(rock); }
private static void addRock3D(CombinedTerrainObject3D combinedTerrainObject, Vector3d normal, double centroidHeight, double[][] vertices) { AppearanceDefinition color = YoAppearance.DarkGray(); ArrayList<Point2d> vertexPoints = new ArrayList<Point2d>(); for (double[] point : vertices) { Point2d point2d = new Point2d(point); vertexPoints.add(point2d); } ConvexPolygon2d convexPolygon = new ConvexPolygon2d(vertexPoints); RotatableConvexPolygonTerrainObject rock = new RotatableConvexPolygonTerrainObject(normal, convexPolygon, centroidHeight, color); combinedTerrainObject.addTerrainObject(rock); }
private boolean checkArea(FootstepDataMessage footstep, double percentageToCheckAgainst, SteppingParameters parameters){ if (footstep.predictedContactPoints == null) return true; ConvexPolygon2d convexPolygon2d = new ConvexPolygon2d(footstep.getPredictedContactPoints()); convexPolygon2d.update(); double area = convexPolygon2d.getArea(); double percentage = area / parameters.getFootstepArea(); if (percentage + EPSILON < percentageToCheckAgainst) return false; return true; } }
public FootstepDataListWithSwingOverTrajectoriesAssembler(HumanoidReferenceFrames humanoidReferenceFrames, WalkingControllerParameters walkingControllerParameters, YoVariableRegistry parentRegistry, YoGraphicsListRegistry graphicsListRegistry) { this.humanoidReferenceFrames = humanoidReferenceFrames; swingOverPlanarRegionsTrajectoryExpander = new SwingOverPlanarRegionsTrajectoryExpander(walkingControllerParameters, parentRegistry, graphicsListRegistry); stanceFootPose = new FramePose(); swingStartPose = new FramePose(); swingEndPose = new FramePose(); partialFootholdPolygon = new ConvexPolygon2d(); }
public static ConvexPolygon2d createDefaultFootPolygon() { double footLength = 0.2; double footWidth = 0.1; ConvexPolygon2d footPolygon = new ConvexPolygon2d(); footPolygon.addVertex(footLength / 2.0, footWidth / 2.0); footPolygon.addVertex(footLength / 2.0, -footWidth / 2.0); footPolygon.addVertex(-footLength / 2.0, footWidth / 2.0); footPolygon.addVertex(-footLength / 2.0, -footWidth / 2.0); footPolygon.update(); return footPolygon; }
private static ConvexPolygon2d createRectanglePolygon(double lengthX, double widthY) { ConvexPolygon2d convexPolygon = new ConvexPolygon2d(); convexPolygon.addVertex(lengthX / 2.0, widthY / 2.0); convexPolygon.addVertex(-lengthX / 2.0, widthY / 2.0); convexPolygon.addVertex(-lengthX / 2.0, -widthY / 2.0); convexPolygon.addVertex(lengthX / 2.0, -widthY / 2.0); convexPolygon.update(); return convexPolygon; }
public GenericFootstepSnappingParameters(){ super(null, null, 0.3, Math.PI/4, 0.0, 0.01, 0.025, Math.PI/24, 1); collisionPolygon = new ConvexPolygon2d(); collisionPolygon.addVertex(0.1, 0.05); collisionPolygon.addVertex(0.1, -0.05); collisionPolygon.addVertex(-0.05,-0.05); collisionPolygon.addVertex(-0.05, 0.05); collisionPolygon.update(); supportPolygon = collisionPolygon; }
private void drawSupportPolygon(QuadrupedSupportPolygon supportPolygon, YoFrameConvexPolygon2d yoFramePolygon) { ConvexPolygon2d polygon = new ConvexPolygon2d(); for(RobotQuadrant quadrant : supportPolygon.getSupportingQuadrantsInOrder()) { FramePoint footstep = supportPolygon.getFootstep(quadrant); polygon.addVertex(footstep.getX(), footstep.getY()); } polygon.update(); yoFramePolygon.setConvexPolygon2d(polygon); }
private void drawSupportPolygon(QuadrupedSupportPolygon supportPolygon, YoFrameConvexPolygon2d yoFramePolygon) { ConvexPolygon2d polygon = new ConvexPolygon2d(); for(RobotQuadrant quadrant : supportPolygon.getSupportingQuadrantsInOrder()) { FramePoint footstep = supportPolygon.getFootstep(quadrant); polygon.addVertex(footstep.getX(), footstep.getY()); } polygon.update(); yoFramePolygon.setConvexPolygon2d(polygon); } }