return emptyVertex2DSupplier(); if (startIndex + numberOfVertices > vertices.length) throw new IllegalArgumentException("The array is too small. Array length = " + vertices.length + ", expected minimum length = "
return emptyVertex2DSupplier(); if (startIndex + numberOfVertices > vertices.size()) throw new IllegalArgumentException("The list is too small. List size = " + vertices.size() + ", expected minimum size = "
/** * Returns a fixed-size supplier backed by a portion of the given array specified by the first * index {@code startIndex} and the portion length {@code numberOfVertices}. * * @param vertices the array by which the supplier will be backed. * @param startIndex the first vertex index. * @param numberOfVertices the portion's length. * @return the supplier. */ public static Vertex2DSupplier asVertex2DSupplier(Point2DReadOnly[] vertices, int startIndex, int numberOfVertices) { if (numberOfVertices == 0) return emptyVertex2DSupplier(); if (startIndex + numberOfVertices > vertices.length) throw new IllegalArgumentException("The array is too small. Array length = " + vertices.length + ", expected minimum length = " + (startIndex + numberOfVertices)); return asVertex2DSupplier(Arrays.asList(vertices), startIndex, numberOfVertices); }
private YoGraphicPolygon(String name, YoFrameConvexPolygon2D yoFrameConvexPolygon2d, YoFramePoint3D framePoint, YoFrameYawPitchRoll yawPitchRoll, YoFrameQuaternion quaternion, double scale, double height, AppearanceDefinition appearance) { super(name, framePoint, yawPitchRoll, quaternion, scale); if (yoFrameConvexPolygon2d.getNumberOfVertices() <= 0) yoFrameConvexPolygon2d.set(Vertex2DSupplier.emptyVertex2DSupplier()); this.yoFrameConvexPolygon2d = yoFrameConvexPolygon2d; this.appearance = appearance; this.height = height; verticesToDisplay = new ArrayList<>(yoFrameConvexPolygon2d.getMaxNumberOfVertices()); graphics3dObject = new Graphics3DObject(); graphics3dObject.setChangeable(true); MeshDataHolder meshDataHolder = MeshDataGenerator.ExtrudedPolygon(yoFrameConvexPolygon2d, height); instruction = new Graphics3DAddMeshDataInstruction(meshDataHolder, appearance); graphics3dObject.addInstruction(instruction); }
@Test public void testCreatingEmptySupplier() { Vertex2DSupplier expected = Vertex2DSupplier.emptyVertex2DSupplier(); Vertex2DSupplier actual; actual = Vertex2DSupplier.asVertex2DSupplier(); assertEquals(expected, actual); assertTrue(expected.epsilonEquals(actual, EPSILON)); actual = Vertex2DSupplier.asVertex2DSupplier(new Point2DReadOnly[0], 0); assertEquals(expected, actual); assertTrue(expected.epsilonEquals(actual, EPSILON)); actual = Vertex2DSupplier.asVertex2DSupplier(new Point2DReadOnly[0], 0, 0); assertEquals(expected, actual); assertTrue(expected.epsilonEquals(actual, EPSILON)); actual = Vertex2DSupplier.asVertex2DSupplier(Collections.emptyList()); assertEquals(expected, actual); assertTrue(expected.epsilonEquals(actual, EPSILON)); actual = Vertex2DSupplier.asVertex2DSupplier(Collections.emptyList(), 0); assertEquals(expected, actual); assertTrue(expected.epsilonEquals(actual, EPSILON)); actual = Vertex2DSupplier.asVertex2DSupplier(Collections.emptyList(), 0, 0); assertEquals(expected, actual); assertTrue(expected.epsilonEquals(actual, EPSILON)); }