/** * Adds N new vertices to this polygon using an array of {@code Point2f}. * Note that this method recycles memory. * @param vertices {@code Point2f[]} the list of new vertices. * @param numberOfVertices {@code int} that is used to determine the number of vertices to add to this polygon. Note the: {@code vertices.length} can be greater or equal to numberOfVertices. */ public void addVertices(Point2f[] vertices, int numberOfVertices) { isUpToDate = false; for (int i = 0; i < numberOfVertices; i++) addVertex(vertices[i]); }
/** * Adds N new vertices to this polygon using an array of {@code Point2d}. * Note that this method recycles memory. * @param vertices {@code Point2d[]} the list of new vertices. * @param numberOfVertices {@code int} that is used to determine the number of vertices to add to this polygon. Note the: {@code vertices.length} can be greater or equal to numberOfVertices. */ public void addVertices(Point2d[] vertices, int numberOfVertices) { isUpToDate = false; for (int i = 0; i < numberOfVertices; i++) addVertex(vertices[i]); }
/** * Adds N new vertices to this polygon using an array of {@code Point2d}. * Note that this method recycles memory. * @param vertices {@code double[>=numberOfVertices][>=2]} the array of new vertices. * @param numberOfVertices {@code int} that is used to determine the number of vertices to add to this polygon. Note the: {@code vertices.length} can be greater or equal to numberOfVertices. */ public void addVertices(double[][] vertices, int numberOfVertices) { isUpToDate = false; for (int i = 0; i < numberOfVertices; i++) addVertex(vertices[i][0], vertices[i][1]); }
public void addVertex(Point2d vertex) { convexPolygon.addVertex(vertex); }
/** * Adds N new vertices to this polygon using a list of {@code Point2d}. * Note that this method recycles memory. * @param vertices {@code List<Point2d>} the list of new vertices. * @param numberOfVertices {@code int} that is used to determine the number of vertices to add to this polygon. Note the: {@code vertices.size()} can be greater or equal to numberOfVertices. */ public void addVertices(List<Point2d> vertices, int numberOfVertices) { isUpToDate = false; for (int i = 0; i < numberOfVertices; i++) addVertex(vertices.get(i)); }
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 static ConvexPolygon2d createDefaultFootPolygon() { //TODO: Get this from the robot model itself. double footLength = 0.26; double footWidth = 0.18; 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; }
/** * Add a vertex to this polygon. * Note that this method recycles memory. * @param x {@code double} first coordinate of the new vertex. * @param y {@code double} second coordinate of the new vertex. * @throws ReferenceFrameMismatchException */ public void addVertex(ReferenceFrame referenceFrame, double x, double y) { this.referenceFrame.checkReferenceFrameMatch(referenceFrame); convexPolygon.addVertex(x, y); }
/** * Adds new vertices to this polygon from another convex polygon. * Note that this method recycles memory. * @param otherPolygon {@code ConvexPolygon2d} the other convex polygon that is used to add new vertices to this polygon. */ public void addVertices(ConvexPolygon2d otherPolygon) { isUpToDate = false; for (int i = 0; i < otherPolygon.getNumberOfVertices(); i++) addVertex(otherPolygon.getVertex(i)); }
/** * Add a vertex to this polygon after doing {@code newVertex.changeFrame(this.referenceFrame)}. * Note that this method recycles memory. * @param newVertex {@code FramePoint2d} the new vertex (it is not modified). */ public void addVertexAndChangeFrame(FramePoint2d newVertex) { tempPoint2d.setIncludingFrame(newVertex); tempPoint2d.changeFrame(referenceFrame); convexPolygon.addVertex(tempPoint2d.getPoint()); }
protected void addVerticesInClockwiseOrderInPolygon(int startIndexInclusive, int endIndexInclusive, ConvexPolygon2d polygonToPack) { checkIfUpToDate(); int index = startIndexInclusive; while (true) { polygonToPack.addVertex(getVertex(index)); if (index == endIndexInclusive) break; index = getNextVertexIndex(index); } }
/** * Add a vertex to this polygon after doing {@code newVertex.changeFrameAndProjectToXYPlane(this.referenceFrame)}. * Note that this method recycles memory. * @param newVertex {@code FramePoint2d} the new vertex (it is not modified). */ public void addVertexChangeFrameAndProjectToXYPlane(FramePoint2d newVertex) { tempPoint2d.setIncludingFrame(newVertex); tempPoint2d.changeFrameAndProjectToXYPlane(referenceFrame); convexPolygon.addVertex(tempPoint2d.getPoint()); }
private void updateConvexHull() { convexHull.clear(); for (int i = 0; i < this.getNumberOfConvexPolygons(); i++) { ConvexPolygon2d convexPolygon = this.getConvexPolygon(i); for (int j = 0; j < convexPolygon.getNumberOfVertices(); j++) convexHull.addVertex(convexPolygon.getVertex(j)); } convexHull.update(); }
public BasicFootstepMask(List<Point2d> footstepShape, double maskBufferSize) { this.safetyBuffer = maskBufferSize; footShapeWithBufferPolygon.clear(); for (Point2d vertex : footstepShape) { footShapeWithBufferPolygon.addVertex(inflate(vertex.getX()), inflate(vertex.getY())); } footShapeWithBufferPolygon.update(); }
public BasicFootstepMask(ContactablePlaneBody foot, double maskBufferSize) { this.safetyBuffer = maskBufferSize; footShapeWithBufferPolygon.clear(); for (FramePoint2d vertex : foot.getContactPoints2d()) { footShapeWithBufferPolygon.addVertex(inflate(vertex.getX()), inflate(vertex.getY())); } footShapeWithBufferPolygon.update(); }
public BasicFootstepMask(ConvexPolygon2d footstepShape, double maskBufferSize) { int numVertices = footstepShape.getNumberOfVertices(); Point2d vertex; for (int i = 0; i < numVertices; i++) { vertex = footstepShape.getVertex(i); footShapeWithBufferPolygon.addVertex(inflate(vertex.getX()), inflate(vertex.getY())); } footShapeWithBufferPolygon.update(); }
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); }