From 5ae9bbe3583384afab8eb95a134ccb74aee6487a Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期四, 25 十二月 2025 13:46:38 +0800
Subject: [PATCH] 曾加修改密码功能
---
src/lujing/AoxinglujingNoObstacle.java | 78 +++++++++++++++++++++++++++++++++++++++
1 files changed, 78 insertions(+), 0 deletions(-)
diff --git a/src/lujing/AoxinglujingNoObstacle.java b/src/lujing/AoxinglujingNoObstacle.java
index fe884f9..4bdf628 100644
--- a/src/lujing/AoxinglujingNoObstacle.java
+++ b/src/lujing/AoxinglujingNoObstacle.java
@@ -38,6 +38,14 @@
return planPathCore(originalPolygon, width, margin);
}
+ /**
+ * 鏍稿績璺緞瑙勫垝閫昏緫
+ *
+ * @param originalPolygon 鍘熷澶氳竟褰㈤《鐐瑰垪琛�
+ * @param width 鍓茶崏瀹藉害
+ * @param margin 瀹夊叏杈硅窛
+ * @return 瑙勫垝濂界殑璺緞娈靛垪琛�
+ */
private static List<PathSegment> planPathCore(List<Point> originalPolygon, double width, double margin) {
if (originalPolygon.size() < 3) return new ArrayList<>();
@@ -74,6 +82,11 @@
/**
* 瀵绘壘寮撳瓧褰㈢殑绗竴鏉$嚎鐨勮捣鐐�
+ *
+ * @param polygon 澶氳竟褰㈤《鐐瑰垪琛�
+ * @param angle 鎵弿瑙掑害
+ * @param width 鍓茶崏瀹藉害
+ * @return 鎵弿璧风偣鐨勫潗鏍�
*/
private static Point getFirstScanStartPoint(List<Point> polygon, double angle, double width) {
List<Point> rotated = rotatePolygon(polygon, -angle);
@@ -90,6 +103,10 @@
/**
* 閲嶇粍澶氳竟褰㈤《鐐癸紝浣垮緱绱㈠紩0鐨勭偣鏈�闈犺繎濉厖璧风偣
+ *
+ * @param polygon 澶氳竟褰㈤《鐐瑰垪琛�
+ * @param target 鐩爣鐐癸紙濉厖璧风偣锛�
+ * @return 閲嶇粍鍚庣殑澶氳竟褰㈤《鐐瑰垪琛�
*/
private static List<Point> alignBoundaryToStart(List<Point> polygon, Point target) {
int bestIdx = 0;
@@ -108,6 +125,15 @@
return aligned;
}
+ /**
+ * 鐢熸垚寮撳瓧褰㈡壂鎻忚矾寰�
+ *
+ * @param polygon 澶氳竟褰㈤《鐐瑰垪琛�
+ * @param angle 鎵弿瑙掑害
+ * @param width 鍓茶崏瀹藉害
+ * @param startPoint 璧峰鐐�
+ * @return 寮撳瓧褰㈣矾寰勬鍒楄〃
+ */
private static List<PathSegment> generateZigZagPath(List<Point> polygon, double angle, double width, Point startPoint) {
List<PathSegment> result = new ArrayList<>();
List<Point> rotated = rotatePolygon(polygon, -angle);
@@ -143,6 +169,13 @@
return result;
}
+ /**
+ * 鑾峰彇鎵弿绾夸笌澶氳竟褰㈢殑浜ょ偣X鍧愭爣鍒楄〃
+ *
+ * @param rotatedPoly 鏃嬭浆鍚庣殑澶氳竟褰�
+ * @param y 鎵弿绾跨殑Y鍧愭爣
+ * @return 浜ょ偣X鍧愭爣鍒楄〃
+ */
private static List<Double> getXIntersections(List<Point> rotatedPoly, double y) {
List<Double> xIntersections = new ArrayList<>();
int n = rotatedPoly.size();
@@ -159,6 +192,13 @@
// --- 鍑犱綍鍩虹宸ュ叿 ---
+ /**
+ * 澶氳竟褰㈠唴缂╋紙璁$畻瀹夊叏宸ヤ綔鍖哄煙锛�
+ *
+ * @param polygon 鍘熷澶氳竟褰�
+ * @param margin 鍐呯缉璺濈
+ * @return 鍐呯缉鍚庣殑澶氳竟褰�
+ */
private static List<Point> shrinkPolygon(List<Point> polygon, double margin) {
List<Point> result = new ArrayList<>();
int n = polygon.size();
@@ -187,6 +227,12 @@
return result;
}
+ /**
+ * 瀵绘壘鏈�浼樻壂鎻忚搴︼紙浣挎壂鎻忕嚎鏁伴噺鏈�灏戯級
+ *
+ * @param polygon 澶氳竟褰�
+ * @return 鏈�浼樿搴︼紙寮у害锛�
+ */
private static double findOptimalScanAngle(List<Point> polygon) {
double minH = Double.MAX_VALUE;
double bestA = 0;
@@ -199,6 +245,13 @@
return bestA;
}
+ /**
+ * 璁$畻澶氳竟褰㈠湪鐗瑰畾瑙掑害涓嬬殑楂樺害锛堟姇褰遍暱搴︼級
+ *
+ * @param poly 澶氳竟褰�
+ * @param angle 瑙掑害
+ * @return 楂樺害
+ */
private static double calculatePolygonHeightAtAngle(List<Point> poly, double angle) {
double minY = Double.MAX_VALUE, maxY = -Double.MAX_VALUE;
double sin = Math.sin(-angle), cos = Math.cos(-angle);
@@ -209,17 +262,36 @@
return maxY - minY;
}
+ /**
+ * 鏃嬭浆鐐�
+ *
+ * @param p 鐐�
+ * @param angle 鏃嬭浆瑙掑害
+ * @return 鏃嬭浆鍚庣殑鐐�
+ */
private static Point rotatePoint(Point p, double angle) {
double c = Math.cos(angle), s = Math.sin(angle);
return new Point(p.x * c - p.y * s, p.x * s + p.y * c);
}
+ /**
+ * 鏃嬭浆澶氳竟褰�
+ *
+ * @param poly 澶氳竟褰�
+ * @param angle 鏃嬭浆瑙掑害
+ * @return 鏃嬭浆鍚庣殑澶氳竟褰�
+ */
private static List<Point> rotatePolygon(List<Point> poly, double angle) {
List<Point> res = new ArrayList<>();
for (Point p : poly) res.add(rotatePoint(p, angle));
return res;
}
+ /**
+ * 纭繚澶氳竟褰㈤《鐐逛负閫嗘椂閽堥『搴�
+ *
+ * @param poly 澶氳竟褰�
+ */
private static void ensureCCW(List<Point> poly) {
double s = 0;
for (int i = 0; i < poly.size(); i++) {
@@ -229,6 +301,12 @@
if (s > 0) Collections.reverse(poly);
}
+ /**
+ * 瑙f瀽鍧愭爣瀛楃涓�
+ *
+ * @param s 鍧愭爣瀛楃涓� (鏍煎紡: "x1,y1;x2,y2;...")
+ * @return 鐐瑰垪琛�
+ */
private static List<Point> parseCoords(String s) {
List<Point> list = new ArrayList<>();
for (String p : s.split(";")) {
--
Gitblit v1.10.0