/** * Tests whether this supplier is empty or not. * * @return {@code true} if this supplier has no vertices, {@code false} if it has at one vertex. */ default boolean isEmpty() { return getNumberOfVertices() == 0; }
@Override public int getNumberOfVertices() { return vertex2dSupplier.getNumberOfVertices(); }
/** * 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; }
/** * 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; }
/** * 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)); }
/** * 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; }
/** * 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)); } }
assertEquals(numberOfVertices, supplier.getNumberOfVertices()); for (int j = 0; j < numberOfVertices; j++) assertTrue(original.get(j) == supplier.getVertex(j)); assertEquals(numberOfVertices, supplier.getNumberOfVertices()); assertEquals(numberOfVertices, supplier.getNumberOfVertices()); assertEquals(numberOfVertices, supplier.getNumberOfVertices()); for (int j = 0; j < numberOfVertices; j++) assertTrue(original.get(j) == supplier.getVertex(j)); assertEquals(numberOfVertices, supplier.getNumberOfVertices()); assertEquals(numberOfVertices, supplier.getNumberOfVertices()); Vertex2DSupplier supplier = Vertex2DSupplier.asVertex2DSupplier(array); assertEquals(numberOfVertices, supplier.getNumberOfVertices()); for (int j = 0; j < numberOfVertices; j++) assertEquals(original.get(j), supplier.getVertex(j)); Vertex2DSupplier supplier = Vertex2DSupplier.asVertex2DSupplier(array, numberOfVertices); assertEquals(numberOfVertices, supplier.getNumberOfVertices()); assertEquals(numberOfVertices, supplier.getNumberOfVertices());
if (vertex2DSupplier.getNumberOfVertices() == 0) return -1; double bestCoord2 = vertex.getElement(coord2); for (int vertexIndex = 1; vertexIndex < vertex2DSupplier.getNumberOfVertices(); vertexIndex++)
int bestIndex = EuclidGeometryPolygonTools.findVertexIndex(supplier, isXPriority, xBound, yBound); for (int index = 0; index < supplier.getNumberOfVertices(); index++) int bestIndex = EuclidGeometryPolygonTools.findVertexIndex(supplier, isXPriority, xBound, yBound); for (int index = 0; index < supplier.getNumberOfVertices(); index++) int bestIndex = EuclidGeometryPolygonTools.findVertexIndex(supplier, isXPriority, xBound, yBound); for (int index = 0; index < supplier.getNumberOfVertices(); index++) int bestIndex = EuclidGeometryPolygonTools.findVertexIndex(supplier, isXPriority, xBound, yBound); for (int index = 0; index < supplier.getNumberOfVertices(); index++)