| | |
| | | */ |
| | | private static List<Point> computeWorkingArea(List<Point> boundary, List<Obstacle> obstacles, double margin) { |
| | | // 首先生成内缩边界 |
| | | List<Point> offsetBoundary = offsetPolygon(boundary, -margin); |
| | | List<Point> offsetBoundary = offsetPolygon(boundary, margin); |
| | | |
| | | if (obstacles.isEmpty()) { |
| | | return offsetBoundary; |
| | |
| | | |
| | | for (int pass = 0; pass < borderPasses; pass++) { |
| | | double offset = pass * width; |
| | | List<Point> offsetPoly = offsetPolygon(polygon, -offset); |
| | | List<Point> offsetPoly = offsetPolygon(polygon, offset); |
| | | |
| | | if (offsetPoly.size() < 3) break; |
| | | |
| | |
| | | } else if (points.size() >= 3) { |
| | | // 多边形障碍物 |
| | | makeCCW(points); |
| | | List<Point> expanded = offsetPolygon(points, margin); |
| | | List<Point> expanded = offsetPolygon(points, -margin); |
| | | obstacles.add(new PolygonalObstacle(expanded)); |
| | | } |
| | | } |