@Override public FramePoint2DReadOnly getVertex(int index) { return new FramePoint2D(referenceFrame, vertex2dSupplier.getVertex(index)); } };
/** * Updates this bounding box to be the smallest bounding box that includes this and the supplied * points. * * @param vertex2DSupplier the supply of points. */ default void updateToIncludePoints(Vertex2DSupplier vertex2DSupplier) { for (int index = 0; index < vertex2DSupplier.getNumberOfVertices(); index++) updateToIncludePoint(vertex2DSupplier.getVertex(index)); }
/** * Tests on a per-vertex basis if this supplier and {@code other} are equal to an * {@code epsilon}. * * @param other the other supplier to compare against this. * @param epsilon the tolerance to use. * @return {@code true} if the two suppliers are equal. */ default boolean epsilonEquals(Vertex2DSupplier other, double epsilon) { if (getNumberOfVertices() != other.getNumberOfVertices()) return false; for (int i = 0; i < getNumberOfVertices(); i++) { if (!getVertex(i).epsilonEquals(other.getVertex(i), epsilon)) return false; } return true; }
/** * Adds the vertices from the given vertex supplier. * <p> * Note that this polygon is marked as being out-of-date. The method {@link #update()} has to be * called afterward before being able to perform operations with this polygon. * </p> * * @param vertex2DSupplier the supplier of vertices. * @see Vertex2DSupplier */ default void addVertices(Vertex2DSupplier vertex2DSupplier) { for (int index = 0; index < vertex2DSupplier.getNumberOfVertices(); index++) { addVertex(vertex2DSupplier.getVertex(index)); } }
/** * Tests on a per-vertex basis if this supplier and {@code other} are equal. * * @param other the other supplier to compare against this. * @return {@code true} if the two suppliers are equal. */ default boolean equals(Vertex2DSupplier other) { if (other == null) return false; if (getNumberOfVertices() != other.getNumberOfVertices()) return false; for (int i = 0; i < getNumberOfVertices(); i++) { if (!getVertex(i).equals(other.getVertex(i))) return false; } return true; }
/** * Gets a representative {@code String} of {@code vertex2DSupplier} given a specific format to * use. * <p> * Using the default format {@link #DEFAULT_FORMAT}, this provides a {@code String} as follows: * * <pre> * Vertex 2D supplier: vertices = [ * ( 0.174, -0.452 ), * (-0.052, -0.173 ) ] * </pre> * </p> * * @param format the format to use for each number. * @param vertex2DSupplier the object to get the {@code String} of. Not modified. * @return the representative {@code String}. */ public static String getVertex2DSupplierString(String format, Vertex2DSupplier vertex2DSupplier) { if (vertex2DSupplier == null) return "null"; if (vertex2DSupplier.getNumberOfVertices() == 0) return "Vertex 2D supplier: vertices = []"; String string = "Vertex 2D supplier: vertices = [\n"; for (int i = 0; i < vertex2DSupplier.getNumberOfVertices() - 1; i++) string += getTuple2DString(format, vertex2DSupplier.getVertex(i)) + ",\n"; string += getTuple2DString(format, vertex2DSupplier.getVertex(vertex2DSupplier.getNumberOfVertices() - 1)) + " ]"; return string; }
assertTrue(original.get(j) == supplier.getVertex(j)); assertTrue(subList.get(j) == supplier.getVertex(j)); assertTrue(subList.get(j) == supplier.getVertex(j)); assertTrue(original.get(j) == supplier.getVertex(j)); assertTrue(subList.get(j) == supplier.getVertex(j)); assertTrue(subList.get(j) == supplier.getVertex(j)); assertEquals(original.get(j), supplier.getVertex(j)); assertEquals(subList.get(j), supplier.getVertex(j)); assertEquals(subList.get(j), supplier.getVertex(j));
assertTrue(supplier.getVertex(index).getX() <= supplier.getVertex(bestIndex).getX()); assertTrue(supplier.getVertex(index).getX() >= supplier.getVertex(bestIndex).getX()); assertTrue(supplier.getVertex(index).getY() <= supplier.getVertex(bestIndex).getY()); assertTrue(supplier.getVertex(index).getY() >= supplier.getVertex(bestIndex).getY());