protected int getPreviousVertexIndexUnsafe(int currentVertexIndex) { checkNonEmpty(); if (currentVertexIndex < 1) return numberOfVertices - 1; else return currentVertexIndex - 1; }
protected int getNextVertexIndexUnsafe(int currentVertexIndex) { checkNonEmpty(); if (currentVertexIndex < numberOfVertices - 1) return currentVertexIndex + 1; else return 0; }
/** Same as getVertex(vertexIndex) but without checking if the polygon has been updated. Be careful when using it! */ protected Point2d getVertexUnsafe(int vertexIndex) { checkNonEmpty(); checkIndexInBoundaries(vertexIndex); return clockwiseOrderedListOfPoints.get(vertexIndex); }
public void removeVertex(int indexOfVertexToRemove) { checkNonEmpty(); checkIndexInBoundaries(indexOfVertexToRemove); if (indexOfVertexToRemove == numberOfVertices - 1) { numberOfVertices--; return; } isUpToDate = false; Collections.swap(clockwiseOrderedListOfPoints, indexOfVertexToRemove, numberOfVertices - 1); numberOfVertices--; }
/** Return the vertex from a counter clockwise ordered list */ public Point2d getVertexCCW(int vertexIndex) { checkIfUpToDate(); checkNonEmpty(); checkIndexInBoundaries(vertexIndex); return clockwiseOrderedListOfPoints.get(numberOfVertices - 1 - vertexIndex); }
public void getFrameVertexXY(int vertexIndex, FramePoint vertexToPack) { convexPolygon.checkIfUpToDate(); convexPolygon.checkNonEmpty(); convexPolygon.checkIndexInBoundaries(vertexIndex); vertexToPack.setXYIncludingFrame(referenceFrame, convexPolygon.getVertex(vertexIndex)); }
public void getFrameVertex(int vertexIndex, FrameTuple2d<?, ?> vertexToPack) { convexPolygon.checkIfUpToDate(); convexPolygon.checkNonEmpty(); convexPolygon.checkIndexInBoundaries(vertexIndex); vertexToPack.setIncludingFrame(referenceFrame, convexPolygon.getVertex(vertexIndex)); }