/** * Find the deepest vertex in the given pocket. It updates {@link ConcaveHullPocket} fields * accordingly. The bridge indices are required to call this method. * * @param pocketToModify * @param concaveHullVertices * @return */ public static boolean findDeepestVertexInPocket(ConcaveHullPocket pocketToModify, List<? extends Point2DReadOnly> concaveHullVertices) { pocketToModify.clearDepthParameters(); int startBridgeIndex = pocketToModify.getStartBridgeIndex(); int endBridgeIndex = pocketToModify.getEndBridgeIndex(); Point2DReadOnly startBridgeVertex = concaveHullVertices.get(startBridgeIndex); Point2DReadOnly endBridgeVertex = concaveHullVertices.get(endBridgeIndex); for (int index = next(startBridgeIndex, concaveHullVertices); index != endBridgeIndex; index = next(index, concaveHullVertices)) { Point2DReadOnly vertex = concaveHullVertices.get(index); double depth = EuclidGeometryTools.distanceFromPoint2DToLine2D(vertex, startBridgeVertex, endBridgeVertex); if (depth > pocketToModify.getMaxDepth()) { pocketToModify.setDeepestVertexIndex(index); pocketToModify.setDeepestVertex(vertex); pocketToModify.setMaxDepth(depth); } } return pocketToModify.getDeepestVertexIndex() >= 0; }
pocket.setMaxDepth(pocketMaxDepth); pocket.setDeepestVertex(concaveHullVertices.get(deepestPocketVertexIndex)); pocket.setDeepestVertexIndex(deepestPocketVertexIndex);