/** * This method does: * 1- {@code clear()}; * 2- {@code addVertices(firstPolygon)}; * 2- {@code addVertices(secondPolygon)}; * 3- {@code update()}. * <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 void setAndUpdate(ConvexPolygon2d firstPolygon, ConvexPolygon2d secondPolygon) { clear(); addVertices(firstPolygon); addVertices(secondPolygon); update(); }
/** * This method does: * 1- {@code clear(referenceFrame)}; * 2- {@code addVertices(vertices)}; * 3- {@code update()}. * @param referenceFrame {@code ReferenceFrame} the new reference frame of this polygon. * @param vertices {@code List<Point2d>} the list of points that is used to creates the vertices. */ public void setIncludingFrameAndUpdate(ReferenceFrame referenceFrame, List<Point2d> vertices) { clear(referenceFrame); this.convexPolygon.addVertices(vertices, vertices.size()); update(); }
/** * 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 double[>=numberOfVertices][>=2]} the array of points that is used to creates the vertices. The each row contains one point whereas the (at least) two columns contains the coordinates x and y. * @param numberOfVertices {@code int} that is used to determine the number of vertices of the polygon. * Note the: {@code pointListArray.length} can be greater or equal to numberOfVertices. */ public ConvexPolygon2d(double[][] vertices, int numberOfVertices) { clear(); addVertices(vertices, numberOfVertices); update(); }
public void setIncludingFrameAndUpdate(ReferenceFrame referenceFrame, Point2d[] vertices) { clear(referenceFrame); this.convexPolygon.addVertices(vertices, vertices.length); update(); }
/** * This method does: * 1- {@code clear()}; * 2- {@code addVertices(vertices, numberOfVertices)}; * 3- {@code update()}. * @param vertices {@code Point2f[]} the list of points that is used to creates the vertices. * @param numberOfVertices {@code 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 void setAndUpdate(Point2f[] vertices, int numberOfVertices) { clear(); addVertices(vertices, numberOfVertices); update(); }
/** * This method does: * 1- {@code clear()}; * 2- {@code addVertices(vertices, numberOfVertices)}; * 3- {@code update()}. * @param vertices {@code List<Point2d>} the list of points that is used to creates the vertices. * @param numberOfVertices {@code int} that is used to determine the number of vertices of the polygon. Note the: {@code vertices.size()} can be greater or equal to numberOfVertices. */ public void setAndUpdate(List<Point2d> vertices, int numberOfVertices) { clear(); addVertices(vertices, numberOfVertices); update(); }
/** * This method does: * 1- {@code clear(referenceFrame)}; * 2- {@code addVertices(vertices)}; * 3- {@code update()}. * @param referenceFrame {@code ReferenceFrame} the new reference frame of this polygon. * @param vertices {@code double[>=numberOfVertices][>=2]} the array of points that is used to creates the vertices. */ public void setIncludingFrameAndUpdate(ReferenceFrame referenceFrame, double[][] vertices) { clear(referenceFrame); this.convexPolygon.addVertices(vertices, vertices.length); update(); }
/** * This method does: * 1- {@code clear()}; * 2- {@code addVertices(vertices, numberOfVertices)}; * 3- {@code update()}. * @param vertices {@code Point2d[]} the list of points that is used to creates the vertices. * @param numberOfVertices {@code 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 void setAndUpdate(Point2d[] vertices, int numberOfVertices) { clear(); addVertices(vertices, numberOfVertices); update(); }
/** * This method does: * 1- {@code clear()}; * 2- {@code addVertices(vertices, numberOfVertices)}; * 3- {@code update()}. * @param vertices {@code double[>=numberOfVertices][>=2]} * @param numberOfVertices {@code int} */ public void setAndUpdate(double[][] vertices, int numberOfVertices) { clear(); addVertices(vertices, numberOfVertices); update(); }
/** * This method does: * 1- clear(); * 2- addVertices(otherPolygon); * 3- update(). * <p/> TODO There is no need to call update() there, instead update everything from the other polygon to make it faster.<p/> * @param otherPolygon {@code ConvexPolygon2d} */ public void setAndUpdate(ConvexPolygon2d otherPolygon) { clear(); addVertices(otherPolygon); update(); }
/** * This method does: * 1- {@code clear(referenceFrame)}; * 2- {@code addVertices(otherPolygon)}; * 3- {@code update()}. * <p/> TODO There is no need to call update() there, instead update everything from the other polygon to make it faster.<p/> * @param referenceFrame {@code ReferenceFrame} the new reference frame of this polygon. * @param otherPolygon {@code ConvexPolygon2d} */ public void setIncludingFrameAndUpdate(ReferenceFrame referenceFrame, ConvexPolygon2d otherPolygon) { clear(referenceFrame); this.convexPolygon.addVertices(otherPolygon); update(); }
public static int cutPolygonWithLine(Line2d cuttingLine, ConvexPolygon2d polygonToCut, RobotSide sideOfLineToCut) { Point2d[] intersectionPoints = polygonToCut.intersectionWith(cuttingLine); if (intersectionPoints == null || intersectionPoints.length == 1) { return -1; } else { int numberOfVerticesRemoved = 0; int index = 0; while (index < polygonToCut.getNumberOfVertices()) { Point2d vertex = polygonToCut.getVertexUnsafe(index); if (cuttingLine.isPointOnSideOfLine(vertex, sideOfLineToCut)) { polygonToCut.removeVertex(index); numberOfVerticesRemoved++; } else { index++; } } polygonToCut.addVertices(intersectionPoints, intersectionPoints.length); polygonToCut.update(); return numberOfVerticesRemoved; } }
intersectionPolygonToPack.addVertices(intersectingPolygon);
partialFootholdPolygon.addVertices(footstep.getPredictedContactPoints(), footstep.getPredictedContactPoints().size()); partialFootholdPolygon.update();
convexPolygon2d.addVertices(bufferedPoints, bufferedPoints.size()); convexPolygon2d.update();