public static boolean findConnectingEdges(ConvexPolygon2d polygon1, ConvexPolygon2d polygon2, LineSegment2d connectingEdge1ToPack, LineSegment2d connectingEdge2Topack) { int[][] verticesIndices = new int[2][2]; boolean success = findConnectingEdgesVerticesIndexes(polygon1, polygon2, verticesIndices); if (!success) return false; getConnectingEdges(polygon1, polygon2, connectingEdge1ToPack, connectingEdge2Topack, verticesIndices); return true; }
public boolean findConnectingEdges(ConvexPolygon2DReadOnly polygon1, ConvexPolygon2DReadOnly polygon2, LineSegment2DBasics connectingEdge1ToPack, LineSegment2DBasics connectingEdge2Topack) { boolean success = findConnectingEdgesVerticesIndexes(polygon1, polygon2, verticesIndices); if (!success) return false; getConnectingEdges(polygon1, polygon2, connectingEdge1ToPack, connectingEdge2Topack, verticesIndices); return true; }
/** * Efficiently combines two Disjoint Polygons. Returns false if not disjoint. * * @param polygon1 ConvexPolygon2d * @param polygon2 ConvexPolygon2d * @param combinedPolygonToPack ConvexPolygon2d polygon in which we put the convex hull * containing polygon1 and polygon2. * @param connectingEdge1ToPack LineSegment2d first connecting edge between polygon1 and * polygon2. * @param connectingEdge2Topack LineSegment2d second connecting edge between polygon1 and * polygon2. * @return true if succeeded, false if failed */ public boolean combineDisjointPolygons(ConvexPolygon2DReadOnly polygon1, ConvexPolygon2DReadOnly polygon2, ConvexPolygon2DBasics combinedPolygonToPack, LineSegment2DBasics connectingEdge1ToPack, LineSegment2DBasics connectingEdge2Topack) { boolean success = findConnectingEdgesVerticesIndexes(polygon1, polygon2, verticesIndices); if (!success) return false; combinedPolygonToPack.clear(); polygon1.getVerticesInClockwiseOrder(verticesIndices[0][1], verticesIndices[0][0], combinedPolygonToPack); polygon2.getVerticesInClockwiseOrder(verticesIndices[1][0], verticesIndices[1][1], combinedPolygonToPack); combinedPolygonToPack.update(); getConnectingEdges(polygon1, polygon2, connectingEdge1ToPack, connectingEdge2Topack, verticesIndices); return true; }
/** * Efficiently combines two Disjoint Polygons. Returns false if not disjoint. * * @param polygon1 ConvexPolygon2d * @param polygon2 ConvexPolygon2d * @param combinedPolygonToPack ConvexPolygon2d polygon in which we put the convex hull containing polygon1 and polygon2. * @param connectingEdge1ToPack LineSegment2d first connecting edge between polygon1 and polygon2. * @param connectingEdge2Topack LineSegment2d second connecting edge between polygon1 and polygon2. * @return true if succeeded, false if failed */ public static boolean combineDisjointPolygons(ConvexPolygon2d polygon1, ConvexPolygon2d polygon2, ConvexPolygon2d combinedPolygonToPack, LineSegment2d connectingEdge1ToPack, LineSegment2d connectingEdge2Topack) { int[][] verticesIndices = new int[2][2]; boolean success = findConnectingEdgesVerticesIndexes(polygon1, polygon2, verticesIndices); if (!success) return false; combinedPolygonToPack.clear(); polygon1.addVerticesInClockwiseOrderInPolygon(verticesIndices[0][1], verticesIndices[0][0], combinedPolygonToPack); polygon2.addVerticesInClockwiseOrderInPolygon(verticesIndices[1][0], verticesIndices[1][1], combinedPolygonToPack); combinedPolygonToPack.update(); getConnectingEdges(polygon1, polygon2, connectingEdge1ToPack, connectingEdge2Topack, verticesIndices); return true; }