From 7881cef5c3dcea8e6037101db2c3eeb2fd3ba5da Mon Sep 17 00:00:00 2001
From: 826220679@qq.com <826220679@qq.com>
Date: 星期六, 27 十二月 2025 23:42:36 +0800
Subject: [PATCH] 1211
---
src/lujing/YixinglujingHaveObstacel.java | 1003 ++++++++++++++++++++++++++++++++++++----------------------
1 files changed, 614 insertions(+), 389 deletions(-)
diff --git a/src/lujing/YixinglujingHaveObstacel.java b/src/lujing/YixinglujingHaveObstacel.java
index c864d3a..6a14dc4 100644
--- a/src/lujing/YixinglujingHaveObstacel.java
+++ b/src/lujing/YixinglujingHaveObstacel.java
@@ -1,458 +1,683 @@
package lujing;
+import java.util.*;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
/**
- * 寮傚舰鑽夊湴璺緞瑙勫垝 - 闅滅鐗╄鍓紭鍖栫増 V9.0
- * 鏍稿績閫昏緫锛氬厛鐢熸垚鍏ㄨ鐩栨壂鎻忚矾寰勶紝鍐嶅埄鐢ㄥ鎵╁悗鐨勯殰纰嶇墿瀵硅矾寰勮繘琛岃鍓��
+ * 寮傚舰鑽夊湴璺緞瑙勫垝 - 鍚殰纰嶇墿鐗�
+ * 鍔熻兘锛氬湪鍦板潡鍐呴儴閬垮紑闅滅鐗╋紝鐢熸垚杩炵画寮撳瓧褰㈠壊鑽夎矾寰�
*/
public class YixinglujingHaveObstacel {
-
- /**
- * 瑙勫垝璺緞涓诲叆鍙�
- */
- public static List<PathSegment> planPath(String coordinates, String obstaclesStr, String widthStr, String marginStr) {
+
+ public static List<PathSegment> planPath(String coordinates, String obstaclesStr,
+ String widthStr, String marginStr) {
// 1. 瑙f瀽鍙傛暟
List<Point> rawPoints = parseCoordinates(coordinates);
if (rawPoints.size() < 3) return new ArrayList<>();
-
+
double mowWidth = Double.parseDouble(widthStr);
double safeMargin = Double.parseDouble(marginStr);
-
- // 2. 棰勫鐞嗗湴鍧楄竟鐣� (纭繚閫嗘椂閽�)
+
+ // 瑙f瀽闅滅鐗�
+ List<Obstacle> obstacles = parseObstacles(obstaclesStr);
+
+ // 2. 棰勫鐞嗭細纭繚杈圭晫閫嗘椂閽�
ensureCounterClockwise(rawPoints);
- // 3. 鐢熸垚鍦板潡鍐呯缉鐨勫畨鍏ㄤ綔涓氳竟鐣� (Inset)
- List<Point> mowingBoundary = getOffsetPolygon(rawPoints, safeMargin); // 姝f暟鍐呯缉
- if (mowingBoundary.size() < 3) return new ArrayList<>();
-
- // 4. 绗竴姝ワ細鐢熸垚鈥滄棤瑙嗛殰纰嶇墿鈥濈殑鍏ㄨ鐩栨壂鎻忚矾寰�
- // 鐩存帴浣跨敤鎵弿绾跨畻娉曠敓鎴愬~婊℃暣涓唴缂╄竟鐣岀殑璺緞
- List<PathSegment> rawPath = generateFullCoveragePath(mowingBoundary, mowWidth);
-
- // 5. 瑙f瀽闅滅鐗╁苟杩涜澶栨墿 (Outset)
- // 娉ㄦ剰锛氶殰纰嶇墿澶栨墿璺濈 = 鍓茶崏鏈哄畨鍏ㄨ竟璺濓紝纭繚涓嶅彂鐢熺鎾�
- List<Obstacle> obstacles = parseObstacles(obstaclesStr, safeMargin);
-
- // 6. 绗簩姝ワ細浣跨敤闅滅鐗╄鍓矾寰� (鏍稿績姝ラ)
- return clipPathWithObstacles(rawPath, obstacles);
- }
-
- /**
- * 浣跨敤闅滅鐗╅泦鍚堣鍓師濮嬭矾寰�
- */
- private static List<PathSegment> clipPathWithObstacles(List<PathSegment> rawPath, List<Obstacle> obstacles) {
+ // 3. 鐢熸垚鍐呯缉澶氳竟褰紙瀹夊叏杈圭晫锛�
+ List<Point> boundary = getInsetPolygon(rawPoints, safeMargin);
+ if (boundary.size() < 3) return new ArrayList<>();
+
+ // 4. 澶栨墿闅滅鐗╋紙瀹夊叏杈硅窛锛�
+ List<Obstacle> expandedObstacles = expandObstacles(obstacles, safeMargin);
+
+ // 5. 纭畾鏈�浼樹綔涓氳搴�
+ double bestAngle = findOptimalAngle(boundary);
+
+ // 6. 鑾峰彇棣栦釜浣滀笟鐐癸紝鐢ㄤ簬瀵归綈鍥磋竟璧风偣
+ Point firstScanStart = getFirstScanPoint(boundary, mowWidth, bestAngle);
+
+ // 7. 瀵归綈鍥磋竟
+ List<Point> alignedBoundary = alignBoundaryStart(boundary, firstScanStart);
+
+ // 8. 绗竴闃舵锛氬洿杈硅矾寰�
List<PathSegment> finalPath = new ArrayList<>();
- Point currentPos = (rawPath.isEmpty()) ? new Point(0,0) : rawPath.get(0).start;
-
- for (PathSegment segment : rawPath) {
- // 灏嗗綋鍓嶈繖涓�娈佃矾寰勶紝鎷垮幓璺熸墍鏈夐殰纰嶇墿杩涜纰版挒妫�娴嬪拰瑁佸壀
- // 鍒濆鏃讹紝杩欎竴娈垫槸瀹屾暣鐨�
- List<PathSegment> segmentsToProcess = new ArrayList<>();
- segmentsToProcess.add(segment);
-
- for (Obstacle obs : obstacles) {
- List<PathSegment> nextIterSegments = new ArrayList<>();
- for (PathSegment seg : segmentsToProcess) {
- // 濡傛灉鏄壊鑽夎矾寰勶紝闇�瑕佽鍓紱濡傛灉鏄┖璧拌矾寰勶紝閫氬父涔熼渶瑕侀伩闅滐紝
- // 浣嗚繖閲屼富瑕佸鐞嗘壂鎻忕嚎鐨勮鍓��
- if (seg.isMowing) {
- nextIterSegments.addAll(obs.clip(seg));
- } else {
- // 绌鸿蛋璺緞鏆傛椂淇濈暀锛堥珮绾ч伩闅滈渶瑕丄*绠楁硶锛屾澶勭畝鍖栦负淇濈暀锛�
- nextIterSegments.add(seg);
- }
- }
- segmentsToProcess = nextIterSegments;
- }
-
- // 灏嗚鍓悗鍓╀綑鐨勭嚎娈靛姞鍏ユ渶缁堣矾寰�
- for (PathSegment s : segmentsToProcess) {
- // 杩囨护鎺夊洜涓鸿鍓骇鐢熺殑鏋佺煭绾挎
- if (distance(s.start, s.end) < 0.05) continue;
-
- // 濡傛灉褰撳墠鐐瑰拰绾挎璧风偣涓嶈繛璐紝鍔犲叆杩炴帴璺緞锛堢┖璧帮級
- if (distance(currentPos, s.start) > 0.05) {
- finalPath.add(new PathSegment(currentPos, s.start, false));
- }
-
- finalPath.add(s);
- currentPos = s.end;
- }
+ for (int i = 0; i < alignedBoundary.size(); i++) {
+ Point pStart = alignedBoundary.get(i);
+ Point pEnd = alignedBoundary.get((i + 1) % alignedBoundary.size());
+ finalPath.add(new PathSegment(pStart, pEnd, true));
}
+
+ // 9. 绗簩闃舵锛氱敓鎴愬唴閮ㄦ壂鎻忚矾寰勶紙鑰冭檻闅滅鐗╋級
+ Point lastEdgePos = alignedBoundary.get(0);
+ List<PathSegment> scanPath = generateGlobalScanPathWithObstacles(
+ boundary, expandedObstacles, mowWidth, bestAngle, lastEdgePos);
+
+ finalPath.addAll(scanPath);
+
+ // 10. 鏍煎紡鍖栧潗鏍囷細淇濈暀涓や綅灏忔暟
+ for (PathSegment segment : finalPath) {
+ segment.start.x = Math.round(segment.start.x * 100.0) / 100.0;
+ segment.start.y = Math.round(segment.start.y * 100.0) / 100.0;
+ segment.end.x = Math.round(segment.end.x * 100.0) / 100.0;
+ segment.end.y = Math.round(segment.end.y * 100.0) / 100.0;
+ }
+
+ // 11. 鎵撳嵃杈撳嚭璺緞鍧愭爣
+ printPathCoordinates(finalPath);
+
return finalPath;
}
-
- // --- 璺緞鐢熸垚鏍稿績绠楁硶 (绉绘鑷� NoObstacle 绫�) ---
-
- private static List<PathSegment> generateFullCoveragePath(List<Point> boundary, double width) {
- // 1. 瀵绘壘鏈�浼樿搴�
- double angle = findOptimalAngle(boundary);
+
+ /**
+ * 鐢熸垚甯﹂殰纰嶇墿鐨勬壂鎻忚矾寰�
+ */
+ private static List<PathSegment> generateGlobalScanPathWithObstacles(
+ List<Point> polygon, List<Obstacle> obstacles,
+ double width, double angle, Point startPos) {
- // 2. 鏃嬭浆澶氳竟褰互瀵归綈鍧愭爣杞�
+ // 1. 鐢熸垚鍘熷鎵弿绾匡紙鏃犻殰纰嶇墿锛�
+ List<PathSegment> originalSegments = generateGlobalScanPath(polygon, width, angle, startPos);
+
+ // 2. 绉婚櫎鍦ㄩ殰纰嶇墿鍐呴儴鐨勭嚎娈�
+ List<PathSegment> remainingSegments = new ArrayList<>();
+ for (PathSegment seg : originalSegments) {
+ if (!seg.isMowing) {
+ // 绌鸿蛋娈电洿鎺ヤ繚鐣�
+ remainingSegments.add(seg);
+ continue;
+ }
+
+ // 灏嗗壊鑽夋涓庢墍鏈夐殰纰嶇墿杩涜瑁佸壀
+ List<PathSegment> clippedSegments = new ArrayList<>();
+ clippedSegments.add(seg);
+
+ for (Obstacle obs : obstacles) {
+ List<PathSegment> newSegments = new ArrayList<>();
+ for (PathSegment s : clippedSegments) {
+ newSegments.addAll(clipSegmentWithObstacle(s, obs));
+ }
+ clippedSegments = newSegments;
+ }
+
+ remainingSegments.addAll(clippedSegments);
+ }
+
+ // 3. 閲嶆柊杩炴帴璺緞娈碉紙寮撳瓧褰㈣繛鎺ワ級
+ return reconnectSegments(remainingSegments);
+ }
+
+ /**
+ * 灏嗙嚎娈典笌闅滅鐗╄繘琛岃鍓�
+ * 杩斿洖涓嶅湪闅滅鐗╁唴閮ㄧ殑瀛愮嚎娈�
+ */
+ private static List<PathSegment> clipSegmentWithObstacle(PathSegment segment, Obstacle obstacle) {
+ List<PathSegment> result = new ArrayList<>();
+
+ // 妫�鏌ョ嚎娈垫槸鍚﹀畬鍏ㄥ湪闅滅鐗╁閮�
+ boolean startInside = obstacle.contains(segment.start);
+ boolean endInside = obstacle.contains(segment.end);
+
+ if (!startInside && !endInside) {
+ // 绾挎涓ょ閮藉湪澶栭儴锛屾鏌ユ槸鍚︾┛杩囬殰纰嶇墿
+ List<Point> intersections = obstacle.getIntersections(segment);
+ if (intersections.isEmpty()) {
+ // 瀹屽叏鍦ㄥ閮�
+ result.add(segment);
+ } else {
+ // 绌胯繃闅滅鐗╋紝鍒嗗壊绾挎
+ intersections.sort(Comparator.comparingDouble(p ->
+ distance(segment.start, p)));
+
+ Point prevPoint = segment.start;
+ for (Point inter : intersections) {
+ result.add(new PathSegment(prevPoint, inter, true));
+ prevPoint = inter;
+ }
+ result.add(new PathSegment(prevPoint, segment.end, true));
+
+ // 绉婚櫎鍦ㄩ殰纰嶇墿鍐呴儴鐨勬锛堝鏁扮储寮曠殑娈碉級
+ List<PathSegment> filtered = new ArrayList<>();
+ for (int i = 0; i < result.size(); i++) {
+ PathSegment s = result.get(i);
+ Point midPoint = new Point(
+ (s.start.x + s.end.x) / 2,
+ (s.start.y + s.end.y) / 2
+ );
+ if (!obstacle.contains(midPoint)) {
+ filtered.add(s);
+ }
+ }
+ return filtered;
+ }
+ } else if (startInside && endInside) {
+ // 瀹屽叏鍦ㄥ唴閮紝涓㈠純
+ return result;
+ } else {
+ // 涓�绔湪鍐呴儴锛屼竴绔湪澶栭儴
+ Point insidePoint = startInside ? segment.start : segment.end;
+ Point outsidePoint = startInside ? segment.end : segment.start;
+
+ List<Point> intersections = obstacle.getIntersections(segment);
+ if (!intersections.isEmpty()) {
+ // 鍙栫澶栭儴鐐规渶杩戠殑浜ょ偣
+ intersections.sort(Comparator.comparingDouble(p ->
+ distance(outsidePoint, p)));
+ Point inter = intersections.get(0);
+
+ // 鍙繚鐣欏閮ㄩ儴鍒�
+ if (startInside) {
+ result.add(new PathSegment(inter, outsidePoint, true));
+ } else {
+ result.add(new PathSegment(outsidePoint, inter, true));
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * 閲嶆柊杩炴帴璺緞娈碉紝褰㈡垚杩炵画寮撳瓧褰㈣矾寰�
+ */
+ private static List<PathSegment> reconnectSegments(List<PathSegment> segments) {
+ if (segments.isEmpty()) return new ArrayList<>();
+
+ List<PathSegment> reconnected = new ArrayList<>();
+ Point currentPos = segments.get(0).start;
+
+ for (PathSegment seg : segments) {
+ if (seg.isMowing) {
+ // 鍓茶崏娈碉細妫�鏌ユ槸鍚﹂渶瑕佹坊鍔犵┖璧版
+ if (distance(currentPos, seg.start) > 0.01) {
+ reconnected.add(new PathSegment(currentPos, seg.start, false));
+ }
+ reconnected.add(seg);
+ currentPos = seg.end;
+ } else {
+ // 绌鸿蛋娈电洿鎺ユ坊鍔�
+ reconnected.add(seg);
+ currentPos = seg.end;
+ }
+ }
+
+ return reconnected;
+ }
+
+ /**
+ * 鐢熸垚鍘熷鎵弿璺緞锛堟棤闅滅鐗╃増鏈級
+ */
+ private static List<PathSegment> generateGlobalScanPath(
+ List<Point> polygon, double width, double angle, Point currentPos) {
+
+ List<PathSegment> segments = new ArrayList<>();
List<Point> rotatedPoly = new ArrayList<>();
- for (Point p : boundary) rotatedPoly.add(rotatePoint(p, -angle));
-
+ for (Point p : polygon) rotatedPoly.add(rotatePoint(p, -angle));
+
double minY = Double.MAX_VALUE, maxY = -Double.MAX_VALUE;
for (Point p : rotatedPoly) {
minY = Math.min(minY, p.y);
maxY = Math.max(maxY, p.y);
}
-
- // 3. 鐢熸垚鎵弿绾�
- List<PathSegment> segments = new ArrayList<>();
- boolean l2r = true;
- // 鍥磋竟璺緞鍏堢敓鎴�
- Point scanStartPoint = null;
-
- // 杩欓噷鎴戜滑鍏堣绠楁壂鎻忕嚎锛屾渶鍚庡啀鍐冲畾鍥磋竟璧风偣浠ュ噺灏戠┖璧�
- List<List<PathSegment>> scanRows = new ArrayList<>();
-
+
+ boolean leftToRight = true;
for (double y = minY + width/2; y <= maxY - width/2; y += width) {
- List<Double> xInters = getXIntersections(rotatedPoly, y);
- if (xInters.size() < 2) continue;
- Collections.sort(xInters);
-
- List<PathSegment> row = new ArrayList<>();
- // 涓や袱閰嶅褰㈡垚绾挎
- for (int i = 0; i < xInters.size() - 1; i += 2) {
- Point s = rotatePoint(new Point(xInters.get(i), y), angle);
- Point e = rotatePoint(new Point(xInters.get(i + 1), y), angle);
- row.add(new PathSegment(s, e, true));
+ List<Double> xIntersections = getXIntersections(rotatedPoly, y);
+ if (xIntersections.size() < 2) continue;
+ Collections.sort(xIntersections);
+
+ List<PathSegment> lineSegmentsInRow = new ArrayList<>();
+ for (int i = 0; i < xIntersections.size() - 1; i += 2) {
+ Point pS = rotatePoint(new Point(xIntersections.get(i), y), angle);
+ Point pE = rotatePoint(new Point(xIntersections.get(i + 1), y), angle);
+ lineSegmentsInRow.add(new PathSegment(pS, pE, true));
}
-
- // 铔囧舰鎺掑簭
- if (!l2r) {
- Collections.reverse(row);
- for (PathSegment s : row) {
- Point tmp = s.start; s.start = s.end; s.end = tmp;
+
+ if (!leftToRight) {
+ Collections.reverse(lineSegmentsInRow);
+ for (PathSegment s : lineSegmentsInRow) {
+ Point temp = s.start;
+ s.start = s.end;
+ s.end = temp;
}
}
- scanRows.add(row);
- if (scanStartPoint == null && !row.isEmpty()) scanStartPoint = row.get(0).start;
- l2r = !l2r;
+
+ for (PathSegment s : lineSegmentsInRow) {
+ if (distance(currentPos, s.start) > 0.01) {
+ segments.add(new PathSegment(currentPos, s.start, false));
+ }
+ segments.add(s);
+ currentPos = s.end;
+ }
+ leftToRight = !leftToRight;
}
-
- // 4. 鐢熸垚鍥磋竟璺緞 (瀵归綈鍒扮涓�涓壂鎻忕偣)
- List<Point> alignedBoundary = alignBoundaryStart(boundary, scanStartPoint);
- for (int i = 0; i < alignedBoundary.size(); i++) {
- segments.add(new PathSegment(alignedBoundary.get(i), alignedBoundary.get((i+1)%alignedBoundary.size()), true));
- }
-
- // 5. 鍔犲叆鎵弿璺緞
- for (List<PathSegment> row : scanRows) {
- segments.addAll(row);
- }
-
+
return segments;
}
-
- // --- 闅滅鐗╁鐞嗙被 ---
-
- private static List<Obstacle> parseObstacles(String obsStr, double margin) {
- List<Obstacle> list = new ArrayList<>();
- if (obsStr == null || obsStr.trim().isEmpty()) return list;
-
- // 澶勭悊鏍煎紡 (x,y;...)(x,y;...) 鎴� $ 鍒嗛殧
- String cleanStr = obsStr.replaceAll("\\s+", "");
- String[] parts;
- if (cleanStr.contains("(") && cleanStr.contains(")")) {
- List<String> matches = new ArrayList<>();
- java.util.regex.Matcher m = java.util.regex.Pattern.compile("\\(([^)]+)\\)").matcher(cleanStr);
- while (m.find()) matches.add(m.group(1));
- parts = matches.toArray(new String[0]);
- } else {
- parts = cleanStr.split("\\$");
+
+ /**
+ * 瑙f瀽闅滅鐗╁瓧绗︿覆
+ * 鏍煎紡锛�"(x1,y1;x2,y2)(x1,y1;x2,y2;x3,y3)"
+ */
+ private static List<Obstacle> parseObstacles(String obstaclesStr) {
+ List<Obstacle> obstacles = new ArrayList<>();
+ if (obstaclesStr == null || obstaclesStr.trim().isEmpty()) {
+ return obstacles;
}
-
- for (String pStr : parts) {
- List<Point> pts = parseCoordinates(pStr);
- if (pts.isEmpty()) continue;
-
- if (pts.size() == 2) {
- // 鍦嗗舰闅滅鐗�
- double r = distance(pts.get(0), pts.get(1));
- list.add(new CircleObstacle(pts.get(0), r + margin)); // 鍗婂緞澧炲姞margin
- } else {
- // 澶氳竟褰㈤殰纰嶇墿
- ensureCounterClockwise(pts);
- // 澶栨墿闅滅鐗� (Offset Out)
- // 娉ㄦ剰锛氬湪閫氱敤鍋忕Щ绠楁硶涓紝閫嗘椂閽堝杈瑰舰锛岃礋鏁伴�氬父琛ㄧず澶栨墿锛屾垨鑰呬娇鐢ㄧ壒瀹氱畻娉�
- // 杩欓噷鎴戜滑澶嶇敤 getOffsetPolygon锛屽苟浼犲叆璐熺殑margin鏉ュ疄鐜板鎵�
- // *浣嗗湪鏈被鐩墠鐨� getOffsetPolygon 瀹炵幇涓紙鍩轰簬瑙掑钩鍒嗙嚎锛夛紝濡傛灉鏄�嗘椂閽堬細
- // 姝f暟鏄悜宸︼紙鍐呯缉锛夛紝璐熸暟鏄悜鍙筹紙澶栨墿锛�*
- List<Point> expanded = getOffsetPolygon(pts, -margin);
- list.add(new PolyObstacle(expanded));
- }
- }
- return list;
- }
-
- abstract static class Obstacle {
- // 杩斿洖瑁佸壀鍚庣殑绾挎鍒楄〃锛堝嵆淇濈暀鍦ㄩ殰纰嶇墿澶栭儴鐨勭嚎娈碉級
- abstract List<PathSegment> clip(PathSegment seg);
- }
-
- static class CircleObstacle extends Obstacle {
- Point c; double r;
- CircleObstacle(Point c, double r) { this.c = c; this.r = r; }
- @Override
- List<PathSegment> clip(PathSegment seg) {
- // 璁$畻鐩寸嚎涓庡渾鐨勪氦鐐� t鍊� (0..1)
- double dx = seg.end.x - seg.start.x;
- double dy = seg.end.y - seg.start.y;
- double fx = seg.start.x - c.x;
- double fy = seg.start.y - c.y;
+ String trimmed = obstaclesStr.trim();
+ List<String> obstacleStrs = new ArrayList<>();
+
+ // 鍒嗗壊姣忎釜闅滅鐗╋紙鐢ㄦ嫭鍙峰垎闅旓級
+ int start = trimmed.indexOf('(');
+ while (start != -1) {
+ int end = trimmed.indexOf(')', start);
+ if (end == -1) break;
- double A = dx*dx + dy*dy;
- double B = 2*(fx*dx + fy*dy);
- double C = (fx*fx + fy*fy) - r*r;
- double delta = B*B - 4*A*C;
-
- List<PathSegment> result = new ArrayList<>();
- if (delta < 0) {
- // 鏃犱氦鐐癸紝鍏ㄤ繚鐣欐垨鍏ㄥ墧闄�
- if (!isInside(seg.start)) result.add(seg);
- return result;
- }
-
- double t1 = (-B - Math.sqrt(delta)) / (2*A);
- double t2 = (-B + Math.sqrt(delta)) / (2*A);
+ String obsStr = trimmed.substring(start + 1, end);
+ obstacleStrs.add(obsStr);
+ start = trimmed.indexOf('(', end);
+ }
+
+ // 瑙f瀽姣忎釜闅滅鐗�
+ for (String obsStr : obstacleStrs) {
+ List<Point> points = new ArrayList<>();
+ String[] pairs = obsStr.split(";");
- List<Double> ts = new ArrayList<>();
- ts.add(0.0);
- if (t1 > 0 && t1 < 1) ts.add(t1);
- if (t2 > 0 && t2 < 1) ts.add(t2);
- ts.add(1.0);
- Collections.sort(ts);
-
- for (int i = 0; i < ts.size()-1; i++) {
- double midT = (ts.get(i) + ts.get(i+1)) / 2;
- Point mid = interpolate(seg.start, seg.end, midT);
- if (!isInside(mid)) {
- result.add(new PathSegment(interpolate(seg.start, seg.end, ts.get(i)),
- interpolate(seg.start, seg.end, ts.get(i+1)),
- seg.isMowing));
+ for (String pair : pairs) {
+ String[] xy = pair.split(",");
+ if (xy.length == 2) {
+ points.add(new Point(
+ Double.parseDouble(xy[0].trim()),
+ Double.parseDouble(xy[1].trim())
+ ));
}
}
- return result;
+
+ if (points.size() == 2) {
+ // 鍦嗗舰闅滅鐗╋細绗竴涓偣涓哄渾蹇冿紝绗簩涓偣涓哄渾涓婁竴鐐�
+ Point center = points.get(0);
+ Point onCircle = points.get(1);
+ double radius = distance(center, onCircle);
+ obstacles.add(new Obstacle(center, radius));
+ } else if (points.size() > 2) {
+ // 澶氳竟褰㈤殰纰嶇墿
+ obstacles.add(new Obstacle(points));
+ }
}
-
- boolean isInside(Point p) {
- return (p.x-c.x)*(p.x-c.x) + (p.y-c.y)*(p.y-c.y) < r*r;
- }
+
+ return obstacles;
}
-
- static class PolyObstacle extends Obstacle {
- List<Point> points;
- double minX, maxX, minY, maxY;
-
- PolyObstacle(List<Point> pts) {
- this.points = pts;
- updateBounds();
- }
-
- void updateBounds() {
- minX = minY = Double.MAX_VALUE;
- maxX = maxY = -Double.MAX_VALUE;
- for (Point p : points) {
- minX = Math.min(minX, p.x); maxX = Math.max(maxX, p.x);
- minY = Math.min(minY, p.y); maxY = Math.max(maxY, p.y);
+
+ /**
+ * 澶栨墿闅滅鐗╋紙澧炲姞瀹夊叏杈硅窛锛�
+ */
+ private static List<Obstacle> expandObstacles(List<Obstacle> obstacles, double margin) {
+ List<Obstacle> expanded = new ArrayList<>();
+
+ for (Obstacle obs : obstacles) {
+ if (obs.isCircle()) {
+ // 鍦嗗舰锛氬崐寰勫鍔犲畨鍏ㄨ竟璺�
+ expanded.add(new Obstacle(obs.center, obs.radius + margin));
+ } else {
+ // 澶氳竟褰細鍚戝鍋忕Щ锛堜笌杈圭晫鍐呯缉鏂瑰悜鐩稿弽锛�
+ List<Point> expandedPoints = getOutsetPolygon(obs.points, margin);
+ expanded.add(new Obstacle(expandedPoints));
}
}
-
- boolean isInside(Point p) {
- if (p.x < minX || p.x > maxX || p.y < minY || p.y > maxY) return false;
- boolean result = false;
- for (int i = 0, j = points.size() - 1; i < points.size(); j = i++) {
- if ((points.get(i).y > p.y) != (points.get(j).y > p.y) &&
- (p.x < (points.get(j).x - points.get(i).x) * (p.y - points.get(i).y) / (points.get(j).y - points.get(i).y) + points.get(i).x)) {
- result = !result;
- }
+
+ return expanded;
+ }
+
+ /**
+ * 澶氳竟褰㈠鎵╋紙涓庡唴缂╂柟鍚戠浉鍙嶏級
+ */
+ private static List<Point> getOutsetPolygon(List<Point> points, double margin) {
+ // 杩欓噷浣跨敤绠�鍖栫殑澶栨墿鏂规硶锛氭部娉曠嚎鍚戝绉诲姩
+ List<Point> outset = new ArrayList<>();
+ int n = points.size();
+
+ for (int i = 0; i < n; i++) {
+ Point pPrev = points.get((i - 1 + n) % n);
+ Point pCurr = points.get(i);
+ Point pNext = points.get((i + 1) % n);
+
+ // 璁$畻涓や釜杈圭殑鍚戦噺
+ double v1x = pCurr.x - pPrev.x, v1y = pCurr.y - pPrev.y;
+ double v2x = pNext.x - pCurr.x, v2y = pNext.y - pCurr.y;
+
+ // 璁$畻娉曠嚎锛堢‘淇濆悜澶栵級
+ double nx1 = -v1y, ny1 = v1x;
+ double nx2 = -v2y, ny2 = v2x;
+
+ // 褰掍竴鍖�
+ double len1 = Math.hypot(nx1, ny1);
+ double len2 = Math.hypot(nx2, ny2);
+ if (len1 > 1e-6) { nx1 /= len1; ny1 /= len1; }
+ if (len2 > 1e-6) { nx2 /= len2; ny2 /= len2; }
+
+ // 璁$畻骞冲潎娉曠嚎鏂瑰悜
+ double nx = (nx1 + nx2) / 2;
+ double ny = (ny1 + ny2) / 2;
+ double len = Math.hypot(nx, ny);
+ if (len > 1e-6) {
+ nx /= len;
+ ny /= len;
}
- return result;
+
+ // 鍚戝绉诲姩
+ outset.add(new Point(
+ pCurr.x + nx * margin,
+ pCurr.y + ny * margin
+ ));
}
-
- @Override
- List<PathSegment> clip(PathSegment seg) {
- List<Double> ts = new ArrayList<>();
- ts.add(0.0);
- ts.add(1.0);
-
- // 璁$畻绾挎涓庨殰纰嶇墿姣忎竴鏉¤竟鐨勪氦鐐�
- for (int i = 0; i < points.size(); i++) {
- Point p1 = points.get(i);
- Point p2 = points.get((i+1)%points.size());
- double t = getIntersectionT(seg.start, seg.end, p1, p2);
- if (t > 1e-6 && t < 1 - 1e-6) {
- ts.add(t);
- }
+
+ return outset;
+ }
+
+ /**
+ * 闅滅鐗╃被
+ */
+ private static class Obstacle {
+ List<Point> points; // 澶氳竟褰㈤《鐐癸紙瀵瑰渾褰负绌猴級
+ Point center; // 鍦嗗績锛堜粎瀵瑰渾褰㈡湁鏁堬級
+ double radius; // 鍗婂緞锛堜粎瀵瑰渾褰㈡湁鏁堬級
+ boolean isCircle;
+
+ // 澶氳竟褰㈡瀯閫犲嚱鏁�
+ Obstacle(List<Point> points) {
+ this.points = new ArrayList<>(points);
+ this.isCircle = false;
+ ensureCounterClockwise(this.points); // 纭繚椤烘椂閽堬紙瀵归殰纰嶇墿鏄唴閮ㄥ尯鍩燂級
+ }
+
+ // 鍦嗗舰鏋勯�犲嚱鏁�
+ Obstacle(Point center, double radius) {
+ this.center = new Point(center.x, center.y);
+ this.radius = radius;
+ this.isCircle = true;
+ this.points = new ArrayList<>();
+ }
+
+ // 鍒ゆ柇鐐规槸鍚﹀湪闅滅鐗╁唴閮�
+ boolean contains(Point p) {
+ if (isCircle) {
+ return distance(p, center) <= radius;
+ } else {
+ return isPointInPolygon(p, points);
}
- Collections.sort(ts);
-
- List<PathSegment> result = new ArrayList<>();
- // 妫�鏌ユ瘡涓�灏忔鐨勪腑鐐规槸鍚﹀湪闅滅鐗╁唴
- for (int i = 0; i < ts.size() - 1; i++) {
- double tMid = (ts.get(i) + ts.get(i+1)) / 2.0;
- // 濡傛灉涓ょ偣鏋佸叾鎺ヨ繎锛岃烦杩�
- if (ts.get(i+1) - ts.get(i) < 1e-6) continue;
+ }
+
+ // 鑾峰彇绾挎涓庨殰纰嶇墿鐨勪氦鐐�
+ List<Point> getIntersections(PathSegment segment) {
+ List<Point> intersections = new ArrayList<>();
+
+ if (isCircle) {
+ // 绾挎涓庡渾鐨勪氦鐐�
+ double dx = segment.end.x - segment.start.x;
+ double dy = segment.end.y - segment.start.y;
+ double a = dx * dx + dy * dy;
+ double b = 2 * (dx * (segment.start.x - center.x) +
+ dy * (segment.start.y - center.y));
+ double c = (segment.start.x - center.x) * (segment.start.x - center.x) +
+ (segment.start.y - center.y) * (segment.start.y - center.y) -
+ radius * radius;
- Point mid = interpolate(seg.start, seg.end, tMid);
- if (!isInside(mid)) {
- // 鍦ㄥ閮紝淇濈暀
- Point s = interpolate(seg.start, seg.end, ts.get(i));
- Point e = interpolate(seg.start, seg.end, ts.get(i+1));
- result.add(new PathSegment(s, e, seg.isMowing));
+ double discriminant = b * b - 4 * a * c;
+ if (discriminant >= 0) {
+ discriminant = Math.sqrt(discriminant);
+ for (int sign = -1; sign <= 1; sign += 2) {
+ double t = (-b + sign * discriminant) / (2 * a);
+ if (t >= 0 && t <= 1) {
+ intersections.add(new Point(
+ segment.start.x + t * dx,
+ segment.start.y + t * dy
+ ));
+ }
+ }
+ }
+ } else {
+ // 绾挎涓庡杈瑰舰鐨勪氦鐐�
+ for (int i = 0; i < points.size(); i++) {
+ Point p1 = points.get(i);
+ Point p2 = points.get((i + 1) % points.size());
+
+ Point inter = getLineIntersection(
+ segment.start, segment.end, p1, p2);
+ if (inter != null) {
+ intersections.add(inter);
+ }
}
}
- return result;
+
+ return intersections;
+ }
+
+ boolean isCircle() {
+ return isCircle;
}
}
-
- // --- 閫氱敤鍑犱綍绠楁硶 ---
-
- private static List<Point> getOffsetPolygon(List<Point> points, double offset) {
+
+ /**
+ * 鍒ゆ柇鐐规槸鍚﹀湪澶氳竟褰㈠唴閮紙灏勭嚎娉曪級
+ */
+ private static boolean isPointInPolygon(Point p, List<Point> polygon) {
+ boolean inside = false;
+ for (int i = 0, j = polygon.size() - 1; i < polygon.size(); j = i++) {
+ Point pi = polygon.get(i);
+ Point pj = polygon.get(j);
+
+ if (((pi.y > p.y) != (pj.y > p.y)) &&
+ (p.x < (pj.x - pi.x) * (p.y - pi.y) / (pj.y - pi.y) + pi.x)) {
+ inside = !inside;
+ }
+ }
+ return inside;
+ }
+
+ /**
+ * 璁$畻涓ゆ潯绾挎鐨勪氦鐐�
+ */
+ private static Point getLineIntersection(Point p1, Point p2, Point p3, Point p4) {
+ double denom = (p1.x - p2.x) * (p3.y - p4.y) - (p1.y - p2.y) * (p3.x - p4.x);
+ if (Math.abs(denom) < 1e-6) return null; // 骞宠
+
+ double t = ((p1.x - p3.x) * (p3.y - p4.y) - (p1.y - p3.y) * (p3.x - p4.x)) / denom;
+ double u = -((p1.x - p2.x) * (p1.y - p3.y) - (p1.y - p2.y) * (p1.x - p3.x)) / denom;
+
+ if (t >= 0 && t <= 1 && u >= 0 && u <= 1) {
+ return new Point(
+ p1.x + t * (p2.x - p1.x),
+ p1.y + t * (p2.y - p1.y)
+ );
+ }
+ return null;
+ }
+
+ /**
+ * 璁$畻涓ょ偣璺濈
+ */
+ private static double distance(Point p1, Point p2) {
+ return Math.hypot(p1.x - p2.x, p1.y - p2.y);
+ }
+
+ // ============ 浠ヤ笅鏄粠A浠g爜澶嶇敤鐨勬柟娉� ============
+
+ private static Point getFirstScanPoint(List<Point> polygon, double width, double angle) {
+ List<Point> rotatedPoly = new ArrayList<>();
+ for (Point p : polygon) rotatedPoly.add(rotatePoint(p, -angle));
+ double minY = Double.MAX_VALUE;
+ for (Point p : rotatedPoly) minY = Math.min(minY, p.y);
+
+ double firstY = minY + width/2;
+ List<Double> xInter = getXIntersections(rotatedPoly, firstY);
+ if (xInter.isEmpty()) return polygon.get(0);
+ Collections.sort(xInter);
+ return rotatePoint(new Point(xInter.get(0), firstY), angle);
+ }
+
+ private static List<Point> alignBoundaryStart(List<Point> boundary, Point targetStart) {
+ int bestIdx = 0;
+ double minDist = Double.MAX_VALUE;
+ for (int i = 0; i < boundary.size(); i++) {
+ double d = Math.hypot(boundary.get(i).x - targetStart.x, boundary.get(i).y - targetStart.y);
+ if (d < minDist) { minDist = d; bestIdx = i; }
+ }
+ List<Point> aligned = new ArrayList<>();
+ for (int i = 0; i < boundary.size(); i++) {
+ aligned.add(boundary.get((bestIdx + i) % boundary.size()));
+ }
+ return aligned;
+ }
+
+ private static List<Double> getXIntersections(List<Point> rotatedPoly, double y) {
+ List<Double> xIntersections = new ArrayList<>();
+ for (int i = 0; i < rotatedPoly.size(); i++) {
+ Point p1 = rotatedPoly.get(i);
+ Point p2 = rotatedPoly.get((i + 1) % rotatedPoly.size());
+ if ((p1.y <= y && p2.y > y) || (p2.y <= y && p1.y > y)) {
+ double x = p1.x + (y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y);
+ xIntersections.add(x);
+ }
+ }
+ return xIntersections;
+ }
+
+ private static double findOptimalAngle(List<Point> polygon) {
+ double bestAngle = 0;
+ double minHeight = Double.MAX_VALUE;
+ for (int i = 0; i < polygon.size(); i++) {
+ Point p1 = polygon.get(i), p2 = polygon.get((i + 1) % polygon.size());
+ double angle = Math.atan2(p2.y - p1.y, p2.x - p1.x);
+ double h = calculateHeightAtAngle(polygon, angle);
+ if (h < minHeight) { minHeight = h; bestAngle = angle; }
+ }
+ return bestAngle;
+ }
+
+ private static double calculateHeightAtAngle(List<Point> poly, double angle) {
+ double minY = Double.MAX_VALUE, maxY = -Double.MAX_VALUE;
+ for (Point p : poly) {
+ Point rp = rotatePoint(p, -angle);
+ minY = Math.min(minY, rp.y); maxY = Math.max(maxY, rp.y);
+ }
+ return maxY - minY;
+ }
+
+ private static List<Point> getInsetPolygon(List<Point> points, double margin) {
List<Point> result = new ArrayList<>();
int n = points.size();
for (int i = 0; i < n; i++) {
- Point p1 = points.get((i - 1 + n) % n);
- Point p2 = points.get(i);
- Point p3 = points.get((i + 1) % n);
+ Point pPrev = points.get((i - 1 + n) % n);
+ Point pCurr = points.get(i);
+ Point pNext = points.get((i + 1) % n);
+
+ double d1x = pCurr.x - pPrev.x, d1y = pCurr.y - pPrev.y;
+ double l1 = Math.hypot(d1x, d1y);
+ double d2x = pNext.x - pCurr.x, d2y = pNext.y - pCurr.y;
+ double l2 = Math.hypot(d2x, d2y);
+
+ if (l1 < 1e-6 || l2 < 1e-6) continue;
+
+ double n1x = -d1y / l1, n1y = d1x / l1;
+ double n2x = -d2y / l2, n2y = d2x / l2;
+
+ double bisectorX = n1x + n2x, bisectorY = n1y + n2y;
+ double bLen = Math.hypot(bisectorX, bisectorY);
+ if (bLen < 1e-6) { bisectorX = n1x; bisectorY = n1y; }
+ else { bisectorX /= bLen; bisectorY /= bLen; }
+
+ double cosHalfAngle = n1x * bisectorX + n1y * bisectorY;
+ double dist = margin / Math.max(cosHalfAngle, 0.1);
- // 鍚戦噺 p1->p2 鍜� p2->p3
- double v1x = p2.x - p1.x, v1y = p2.y - p1.y;
- double v2x = p3.x - p2.x, v2y = p3.y - p2.y;
- double l1 = Math.hypot(v1x, v1y), l2 = Math.hypot(v2x, v2y);
-
- if (l1 < 1e-5 || l2 < 1e-5) continue;
+ dist = Math.min(dist, margin * 5);
- // 娉曞悜閲� (鍚戝乏杞�90搴�: -y, x)
- double n1x = -v1y / l1, n1y = v1x / l1;
- double n2x = -v2y / l2, n2y = v2x / l2;
-
- // 瑙掑钩鍒嗙嚎
- double bx = n1x + n2x, by = n1y + n2y;
- double bl = Math.hypot(bx, by);
- if (bl < 1e-5) { bx = n1x; by = n1y; }
- else { bx /= bl; by /= bl; }
-
- // 淇闀垮害 offset / sin(theta/2) = offset / dot(n1, b)
- double dot = n1x * bx + n1y * by;
- double dist = offset / Math.max(Math.abs(dot), 0.1); // 闃叉灏栬杩囬暱
-
- // 闃堝�奸檺鍒讹紝闃叉鑷氦鎴栫暩鍙樿繃澶�
- dist = Math.signum(offset) * Math.min(Math.abs(dist), Math.abs(offset) * 3);
-
- result.add(new Point(p2.x + bx * dist, p2.y + by * dist));
+ result.add(new Point(pCurr.x + bisectorX * dist, pCurr.y + bisectorY * dist));
}
return result;
}
-
- private static double findOptimalAngle(List<Point> poly) {
- double bestA = 0, minH = Double.MAX_VALUE;
- for (int i = 0; i < poly.size(); i++) {
- Point p1 = poly.get(i), p2 = poly.get((i + 1) % poly.size());
- double a = Math.atan2(p2.y - p1.y, p2.x - p1.x);
- double h = calcHeight(poly, a);
- if (h < minH) { minH = h; bestA = a; }
- }
- return bestA;
- }
-
- private static double calcHeight(List<Point> poly, double ang) {
- double min = Double.MAX_VALUE, max = -Double.MAX_VALUE;
- for (Point p : poly) {
- Point r = rotatePoint(p, -ang);
- min = Math.min(min, r.y); max = Math.max(max, r.y);
- }
- return max - min;
- }
-
- private static double getIntersectionT(Point a, Point b, Point c, Point d) {
- double ux = b.x - a.x, uy = b.y - a.y;
- double vx = d.x - c.x, vy = d.y - c.y;
- double det = vx * uy - vy * ux;
- if (Math.abs(det) < 1e-8) return -1;
-
- double wx = c.x - a.x, wy = c.y - a.y;
- double t = (vx * wy - vy * wx) / det;
- double u = (ux * wy - uy * wx) / det;
-
- if (u >= 0 && u <= 1) return t; // 鍙繚璇佷氦鐐瑰湪绾挎CD涓婏紝t鏄疉B涓婄殑姣斾緥
- return -1;
- }
-
- private static List<Double> getXIntersections(List<Point> poly, double y) {
- List<Double> res = new ArrayList<>();
- for (int i = 0; i < poly.size(); i++) {
- Point p1 = poly.get(i), p2 = poly.get((i + 1) % poly.size());
- if ((p1.y <= y && p2.y > y) || (p2.y <= y && p1.y > y)) {
- res.add(p1.x + (y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y));
- }
- }
- return res;
- }
-
- private static List<Point> alignBoundaryStart(List<Point> poly, Point target) {
- if (target == null) return poly;
- int idx = 0; double minD = Double.MAX_VALUE;
- for (int i = 0; i < poly.size(); i++) {
- double d = distance(poly.get(i), target);
- if (d < minD) { minD = d; idx = i; }
- }
- List<Point> res = new ArrayList<>();
- for (int i = 0; i < poly.size(); i++) res.add(poly.get((idx + i) % poly.size()));
- return res;
- }
-
- private static void ensureCounterClockwise(List<Point> pts) {
- double s = 0;
- for (int i = 0; i < pts.size(); i++) {
- Point p1 = pts.get(i), p2 = pts.get((i + 1) % pts.size());
- s += (p2.x - p1.x) * (p2.y + p1.y);
- }
- if (s > 0) Collections.reverse(pts); // 鍋囪灞忓箷鍧愭爣绯籝鍚戜笅锛熼�氬父澶氳竟褰㈤潰绉叕寮弒>0鏄『鏃堕拡(Y鍚戜笅)鎴栭�嗘椂閽�(Y鍚戜笂)
- // 姝ゅ娌跨敤鎮ㄤ唬鐮佺殑閫昏緫锛氬鏋淪um>0 鍒欏弽杞��
- }
-
- private static Point rotatePoint(Point p, double a) {
- double c = Math.cos(a), s = Math.sin(a);
- return new Point(p.x * c - p.y * s, p.x * s + p.y * c);
+
+ private static Point rotatePoint(Point p, double angle) {
+ double cos = Math.cos(angle), sin = Math.sin(angle);
+ return new Point(p.x * cos - p.y * sin, p.x * sin + p.y * cos);
}
- private static Point interpolate(Point a, Point b, double t) {
- return new Point(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t);
- }
-
- private static double distance(Point a, Point b) {
- return Math.hypot(a.x - b.x, a.y - b.y);
- }
-
- private static List<Point> parseCoordinates(String s) {
- List<Point> pts = new ArrayList<>();
- if (s == null || s.isEmpty()) return pts;
- for (String p : s.split(";")) {
- String[] xy = p.split(",");
- if (xy.length >= 2) pts.add(new Point(Double.parseDouble(xy[0]), Double.parseDouble(xy[1])));
+ private static void ensureCounterClockwise(List<Point> points) {
+ double sum = 0;
+ for (int i = 0; i < points.size(); i++) {
+ Point p1 = points.get(i), p2 = points.get((i + 1) % points.size());
+ sum += (p2.x - p1.x) * (p2.y + p1.y);
}
- if (pts.size() > 1 && distance(pts.get(0), pts.get(pts.size() - 1)) < 1e-4) pts.remove(pts.size() - 1);
- return pts;
+ if (sum > 0) Collections.reverse(points);
}
-
- // --- 鏁版嵁缁撴瀯 ---
+
+ private static List<Point> parseCoordinates(String coordinates) {
+ List<Point> points = new ArrayList<>();
+ String[] pairs = coordinates.split(";");
+ for (String pair : pairs) {
+ String[] xy = pair.split(",");
+ if (xy.length == 2) points.add(new Point(Double.parseDouble(xy[0]), Double.parseDouble(xy[1])));
+ }
+ if (points.size() > 1 && points.get(0).equals(points.get(points.size()-1))) points.remove(points.size()-1);
+ return points;
+ }
+
+ /**
+ * 鎵撳嵃杈撳嚭璺緞鍧愭爣鍒版帶鍒跺彴
+ */
+ private static void printPathCoordinates(List<PathSegment> path) {
+ if (path == null || path.isEmpty()) {
+ System.out.println("璺緞涓虹┖");
+ return;
+ }
+
+ System.out.println("========== 璺緞鍧愭爣杈撳嚭 ==========");
+ System.out.println("鎬昏矾寰勬鏁�: " + path.size());
+ System.out.println();
+ System.out.println("璺緞鍧愭爣搴忓垪 (鏍煎紡: x,y;x,y;...):");
+
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < path.size(); i++) {
+ PathSegment segment = path.get(i);
+ if (i == 0) {
+ // 绗竴涓鐨勮捣鐐�
+ sb.append(String.format("%.2f,%.2f", segment.start.x, segment.start.y));
+ }
+ // 姣忎釜娈电殑缁堢偣
+ sb.append(";");
+ sb.append(String.format("%.2f,%.2f", segment.end.x, segment.end.y));
+ }
+
+ System.out.println(sb.toString());
+ System.out.println();
+ System.out.println("璇︾粏璺緞淇℃伅:");
+ for (int i = 0; i < path.size(); i++) {
+ PathSegment segment = path.get(i);
+ String type = segment.isMowing ? "鍓茶崏" : "绌鸿蛋";
+ System.out.println(String.format("娈� %d [%s]: (%.2f,%.2f) -> (%.2f,%.2f)",
+ i + 1, type, segment.start.x, segment.start.y, segment.end.x, segment.end.y));
+ }
+ System.out.println("==================================");
+ }
+
public static class Point {
public double x, y;
public Point(double x, double y) { this.x = x; this.y = y; }
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof Point)) return false;
+ Point p = (Point) o;
+ return Math.abs(x - p.x) < 1e-4 && Math.abs(y - p.y) < 1e-4;
+ }
}
-
+
public static class PathSegment {
public Point start, end;
public boolean isMowing;
- public PathSegment(Point s, Point e, boolean m) { this.start = s; this.end = e; this.isMowing = m; }
- @Override
- public String toString() { return String.format("%.6f,%.6f;%.6f,%.6f", start.x, start.y, end.x, end.y); }
+ public PathSegment(Point s, Point e, boolean m) {
+ this.start = s;
+ this.end = e;
+ this.isMowing = m;
+ }
}
-}
\ No newline at end of file
+}
+
--
Gitblit v1.10.0