/** Return the next vertex from a counter clockwise ordered list */ public Point2d getNextVertexCCW(int index) { return getVertexCCW(getNextVertexIndex(index)); }
public void getNextFrameVertex(int vertexIndex, FramePoint2d vertexToPack) { getFrameVertex(convexPolygon.getNextVertexIndex(vertexIndex), vertexToPack); }
/** Return the next vertex from a clockwise ordered list */ public Point2d getNextVertex(int index) { return getVertex(getNextVertexIndex(index)); }
protected void getPointsInClockwiseOrder(int startIndexInclusive, int endIndexInclusive, ArrayList<Point2d> pointList) { checkIfUpToDate(); int index = startIndexInclusive; while (true) { pointList.add(getVertex(index)); if (index == endIndexInclusive) break; index = getNextVertexIndex(index); } }
protected void addVerticesInClockwiseOrderInPolygon(int startIndexInclusive, int endIndexInclusive, ConvexPolygon2d polygonToPack) { checkIfUpToDate(); int index = startIndexInclusive; while (true) { polygonToPack.addVertex(getVertex(index)); if (index == endIndexInclusive) break; index = getNextVertexIndex(index); } }
indexP = polygonP.getNextVertexIndex(indexP); indexQ = polygonQ.getNextVertexIndex(indexQ);
int nextVertexQIndex = polygonQ.getNextVertexIndex(leftMostIndexOnPolygonQ); Point2d nextVertexQ = polygonQ.getVertex(nextVertexQIndex); nextVertexQIndex = polygonQ.getNextVertexIndex(nextVertexQIndex); nextVertexQ = polygonQ.getVertex(nextVertexQIndex);
int nextVertexQIndex = polygonQ.getNextVertexIndex(leftMostIndexOnPolygonQ); Point2d nextVertexQ = polygonQ.getVertex(nextVertexQIndex); int nextVertexPIndex = polygonP.getNextVertexIndex(leftMostIndexOnPolygonP); Point2d nextVertexP = polygonP.getVertex(nextVertexPIndex); nextVertexQIndex = polygonQ.getNextVertexIndex(nextVertexQIndex); nextVertexQ = polygonQ.getVertex(nextVertexQIndex); nextVertexPIndex = polygonP.getNextVertexIndex(nextVertexPIndex); nextVertexP = polygonP.getVertex(nextVertexPIndex);
/** * Packs the point on the polygon that is closest to the given ray. If the ray is parallel to the * closest edge this will return the point on that edge closest to the ray origin. If the ray * intersects the polygon the result of this method will be wrong. If unsure check first using the * intersectionWithRay method. */ public static boolean getClosestPointToRay(Line2d ray, Point2d pointToPack, ConvexPolygon2d polygon) { if (!polygon.hasAtLeastOneVertex()) return false; Point2d rayStart = ray.getPoint(); Vector2d rayDirection = ray.getNormalizedVector(); int closestVertexIndex = getClosestVertexIndex(ray, polygon); Point2d closestVertexToLine = polygon.getVertex(closestVertexIndex); // validate the closest vertex is in front of the ray: boolean vertexValid = isPointInFrontOfRay(rayStart, rayDirection, closestVertexToLine); // check edges adjacent to the closest vertex to determine if they are parallel to the ray: boolean edge1Parallel = isEdgeParallel(closestVertexIndex, rayDirection, polygon); boolean edge2Parallel = isEdgeParallel(polygon.getNextVertexIndex(closestVertexIndex), rayDirection, polygon); boolean rayParallelToEdge = edge1Parallel || edge2Parallel; if (vertexValid && !rayParallelToEdge) pointToPack.set(closestVertexToLine); else { pointToPack.set(rayStart); orthogonalProjection(pointToPack, polygon); } return true; }
currentPPolygonPointIndex = polygonP.getNextVertexIndex(currentPPolygonPointIndex); currentPolygonPPoint = polygonP.getVertex(currentPPolygonPointIndex); currentQPolygonPointIndex = polygonQ.getNextVertexIndex(currentQPolygonPointIndex); currentPolygonQPoint = polygonQ.getVertex(currentQPolygonPointIndex);
edgeToPack2.set(endVertex, polygon.getNextVertex(polygon.getNextVertexIndex(i))); return 2;