From 28bde0bd83096c1c9588c5b098acdb02411ce560 Mon Sep 17 00:00:00 2001
From: lsh <lsh@163.com>
Date: 星期二, 04 三月 2025 13:59:26 +0800
Subject: [PATCH] *
---
src/main/java/com/zy/asrs/utils/Utils.java | 414 +++++++++++++++++++++++++++++++++-------------------------
1 files changed, 236 insertions(+), 178 deletions(-)
diff --git a/src/main/java/com/zy/asrs/utils/Utils.java b/src/main/java/com/zy/asrs/utils/Utils.java
index 07f4084..07c66a4 100644
--- a/src/main/java/com/zy/asrs/utils/Utils.java
+++ b/src/main/java/com/zy/asrs/utils/Utils.java
@@ -22,158 +22,6 @@
return (float) Arith.multiplys(2, f, 1);
}
- public static String zerofill(String msg, Integer count){
- if (msg.length() == count){
- return msg;
- } else if (msg.length() > count){
- return msg.substring(0, 16);
- } else {
- StringBuilder msgBuilder = new StringBuilder(msg);
- for (int i = 0; i<count-msg.length(); i++){
- msgBuilder.insert(0,"0");
- }
- return msgBuilder.toString();
- }
- }
-
- /**
- * 鍒ゆ柇鏄惁涓烘繁搴撲綅
- */
- public static boolean isDeepLoc(SlaveProperties slaveProperties, String locNo){
- if (slaveProperties.isDoubleDeep()) {
- int row = getRow(locNo);
- return slaveProperties.getDoubleLocs().contains(row);
- } else {
- return false;
- }
- }
-
- /**
- * 鍒ゆ柇鏄惁涓烘繁搴撲綅
- */
- public static boolean isDeepLoc(SlaveProperties slaveProperties, Integer row){
- if (slaveProperties.isDoubleDeep()) {
- return slaveProperties.getDoubleLocs().contains(row);
- } else {
- return false;
- }
- }
-
- /**
- * 鍒ゆ柇鏄惁涓烘祬搴撲綅 骞跺瓨鍦ㄦ繁搴撲綅
- */
- public static boolean isShallowLoc(SlaveProperties slaveProperties, String locNo) {
- if (slaveProperties.isDoubleDeep()) {
- int row = getRow(locNo);
- if (!slaveProperties.getDoubleLocs().contains(row)){
- boolean deepLocLeft = isDeepLocLeft(slaveProperties, row-1);//鍒ゆ柇鏄惁涓哄乏娴呭簱浣�
- if (deepLocLeft){
- return true;
- }
- return isDeepLocRight(slaveProperties, row+1);//鍒ゆ柇鏄惁涓哄彸娴呭簱浣�
- }
- }
- return false;
- }
-
- /**
- * 鍒ゆ柇鏄惁涓烘祬搴撲綅
- */
- public static boolean isShallowLoc(SlaveProperties slaveProperties, Integer row) {
- if (slaveProperties.isDoubleDeep()) {
- if (!slaveProperties.getDoubleLocs().contains(row)){
- boolean deepLocLeft = isDeepLocLeft(slaveProperties, row-1);//鍒ゆ柇鏄惁涓哄乏娴呭簱浣�
- if (deepLocLeft){
- return true;
- }
- return isDeepLocRight(slaveProperties, row+1);//鍒ゆ柇鏄惁涓哄彸娴呭簱浣�
- }
- }
- return false;
- }
-
- /**
- * 鑾峰彇 娣卞簱浣嶅搴旂殑娴呭簱浣嶅彿
- */
- public static String getShallowLoc(SlaveProperties slaveProperties, String deepLoc) {
- int row = getRow(deepLoc);
- boolean deepLocLeft = isDeepLocLeft(slaveProperties, row);//鍒ゆ柇鏄惁涓哄乏娣卞簱浣�
- int shallowRow = deepLocLeft? (row + 1) : (row - 1);
- return zerofill(String.valueOf(shallowRow), 2) + deepLoc.substring(2);
- }
-
- /**
- * 鑾峰彇 娣卞簱浣嶆帓瀵瑰簲鐨勬祬搴撲綅鎺�
- */
- public static Integer getShallowRow(SlaveProperties slaveProperties, Integer deepRow) {
-// int remainder = (int) Arith.remainder(deepRow, slaveProperties.getGroupCount());
-// return remainder == 1 ? (deepRow + 1) : (deepRow - 1);
- boolean deepLocLeft = isDeepLocLeft(slaveProperties, deepRow);//鍒ゆ柇鏄惁涓哄乏娣卞簱浣�
- return deepLocLeft ? (deepRow + 1) : (deepRow - 1);
- }
-
- /**
- * 鍒ゆ柇鏄惁涓哄乏娣卞簱浣�
- */
- public static boolean isDeepLocLeft(SlaveProperties slaveProperties, Integer row) {
- if (slaveProperties.isDoubleDeep()) {
- return slaveProperties.getDoubleLocsLeft().contains(row);
- } else {
- return false;
- }
- }
-
-
- /**
- * 鍒ゆ柇鏄惁涓哄彸娣卞簱浣�
- */
- public static boolean isDeepLocRight(SlaveProperties slaveProperties, Integer row) {
- if (slaveProperties.isDoubleDeep()) {
- return slaveProperties.getDoubleLocsRight().contains(row);
- } else {
- return false;
- }
- }
-
- /**
- * 鑾峰彇 娴呭簱浣嶅搴旂殑娣卞簱浣嶅彿
- */
- public static String getDeepLoc(SlaveProperties slaveProperties, String shallowLoc) {
-// int row = getRow(shallowLoc);
-// int remainder = (int) Arith.remainder(row, slaveProperties.getGroupCount());
-// int targetRow;
-// if (remainder == 2) {
-// targetRow = row - 1;
-// } else if (remainder == 3) {
-// targetRow = row + 1;
-// } else {
-// throw new RuntimeException(shallowLoc + "涓嶆槸娴呭簱浣嶏紝绯荤粺绻佸繖");
-// }
-// return zerofill(String.valueOf(targetRow), 2) + shallowLoc.substring(2);
- int row = getRow(shallowLoc);
- boolean deepLocLeft = isDeepLocLeft(slaveProperties, row-1);//鍒ゆ柇鏄惁涓哄乏娴呭簱浣�
- int shallowRow = deepLocLeft? (row - 1) : (row + 1);
- return zerofill(String.valueOf(shallowRow), 2) + shallowLoc.substring(2);
- }
-
- /**
- * 鑾峰彇 娴呭簱浣嶆帓瀵瑰簲鐨勬繁搴撲綅鎺�
- */
- public static Integer getDeepRow(SlaveProperties slaveProperties, Integer shallowRow) {
-// int remainder = (int) Arith.remainder(shallowRow, slaveProperties.getGroupCount());
-// int targetRow;
-// if (remainder == 2) {
-// targetRow = shallowRow - 1;
-// } else if (remainder == 3) {
-// targetRow = shallowRow + 1;
-// } else {
-// throw new RuntimeException(shallowRow + "涓嶆槸娴呭簱浣嶆帓锛岀郴缁熺箒蹇�");
-// }
-// return targetRow;
- boolean deepLocLeft = isDeepLocLeft(slaveProperties, shallowRow-1);//鍒ゆ柇鏄惁涓哄乏娴呭簱浣�
- return deepLocLeft? (shallowRow - 1) : (shallowRow + 1);
- }
-
/**
* 閫氳繃搴撲綅鍙疯幏鍙� 鎺�
*/
@@ -204,33 +52,243 @@
throw new RuntimeException("搴撲綅瑙f瀽寮傚父");
}
- /**
- * 褰撴绱㈠埌鍙屾繁搴撲綅鐨勬祬搴撲綅鏃讹紝濡傛灉娣卞簱浣嶆棤璐э紝鍒欐斁鍏ュ搴旂殑娣卞簱浣�
- */
- public static void toDeepIfEmptyByShallow(String shallowLoc) {
- int row = getRow(shallowLoc);
- int remainder = (int) Arith.remainder(row, 4);
- int targetRow = 0;
- if (remainder == 2) {
- targetRow = row - 1;
- } else if (remainder == 3) {
- targetRow = row + 1;
- } else {
- throw new RuntimeException(shallowLoc + "涓嶆槸娴呭簱浣嶏紝绯荤粺绻佸繖");
- }
- String targetLoc = zerofill(String.valueOf(targetRow), 2) + shallowLoc.substring(2);
-
- }
-
public static void main(String[] args) {
- SlaveProperties slaveProperties = new SlaveProperties();
- slaveProperties.setDoubleDeep(true);
- List<Integer> list = new ArrayList<>();
- list.add(1);list.add(4);list.add(5);list.add(8);list.add(9);list.add(12);
- slaveProperties.setDoubleLocs(list);
- slaveProperties.setGroupCount(4);
- Integer deepRow = getDeepRow(slaveProperties, 6);
- System.out.println(deepRow);
+ double[] lev = RingThroughXY(183.0, 1830.0);
+ System.out.printf("鐐圭殑鍧愭爣涓�: (%.2f, %.2f)%n", lev[0], lev[1]);
+ }
+
+ public static double[] RingThroughXY(double a,double b) {
+// while (true){
+// if (b>=a){
+// b=b-a;
+// }else {
+// break;
+// }
+// }
+ double l = b/a;
+ // 宸茬煡鏁版嵁
+ double circumference = 314; // 鍦嗗懆闀�
+ double arcLength = 314*l; // 缁欏嚭鐨勫姬闀�
+
+ // 璁$畻鍦嗙殑鍗婂緞
+ double radius = circumference / (2 * Math.PI);
+
+ // 鍦嗗績鍧愭爣
+ double centerX = 50;
+ double centerY = 50;
+
+ // 姹傚姬搴�
+ double theta = arcLength / radius;
+
+ // 璁$畻鐐圭殑鍧愭爣
+ double x = 100-(centerX + radius * Math.cos(theta));
+ double y = centerY + radius * Math.sin(theta);
+
+ return new double[]{x,y};
+ }
+
+ public static double[] RingThroughXYRgv(double a,double b) {
+ double l = b / a;
+
+ // 鍦嗙殑宸茬煡鍙傛暟
+ double radius = 47.52; // 鍗婂緞涓�48
+// double circumference = ; // 璁$畻鍦嗗懆闀�
+ double arcLength = 2 * Math.PI * radius * l; // 缁欏嚭鐨勫姬闀�
+
+ // 鍦嗗績鍧愭爣
+ double centerX = 50;
+ double centerY = 50;
+
+ // 姹傚姬搴�
+ double theta = arcLength / radius;
+
+ // 璁$畻鐐圭殑鍧愭爣
+ double x = 100-(centerX + radius * Math.cos(theta));
+ double y = centerY + radius * Math.sin(theta);
+
+ return new double[]{x, y};
+ }
+
+ public static double[] RingThroughXYSta(double a,double b) {
+ double l = b / a;
+
+ // 鍦嗙殑宸茬煡鍙傛暟
+ double radius = 50; // 鍗婂緞涓�48
+// double circumference = ; // 璁$畻鍦嗗懆闀�
+ double arcLength = 2 * Math.PI * radius * l; // 缁欏嚭鐨勫姬闀�
+
+ // 鍦嗗績鍧愭爣
+ double centerX = 55;
+ double centerY = 45;
+
+ // 姹傚姬搴�
+ double theta = arcLength / radius;
+
+ // 璁$畻鐐圭殑鍧愭爣
+ double x = 100-(centerX + radius * Math.cos(theta));
+ double y = centerY + radius * Math.sin(theta);
+
+ return new double[]{x, y};
+ }
+ public static double[] getRgvPosNew(Integer devNo,double a, double b) {
+ double[] rgvPosNew = getRgvPosNew(a, b);
+ switch (devNo){
+ case 101:
+ case 102:
+ case 103:
+ case 104:
+ case 105:
+ case 106:
+ case 107:
+ case 108:
+ case 109:
+ case 110:
+ case 111:
+ rgvPosNew[0] = rgvPosNew[0] - 30;
+ rgvPosNew[1] = rgvPosNew[1];
+ break;
+ case 112:
+ case 113:
+ case 114:
+ case 115:
+ rgvPosNew[0] = rgvPosNew[0] + 10;
+ rgvPosNew[1] = rgvPosNew[1];
+ break;
+ case 116:
+ case 117:
+ case 118:
+ case 119:
+ case 120:
+ case 121:
+ case 122:
+ case 123:
+ case 124:
+ case 125:
+ case 126:
+ case 127:
+ case 128:
+ case 129:
+ case 130:
+ case 131:
+ case 132:
+ case 133:
+ rgvPosNew[0] = rgvPosNew[0];
+ rgvPosNew[1] = rgvPosNew[1] + 30;
+ break;
+ case 134:
+ rgvPosNew[0] = rgvPosNew[0];
+ rgvPosNew[1] = rgvPosNew[1] - 10;
+ break;
+ }
+ return rgvPosNew;
}
+ public static double[] getRgvPosNew(double a, double b) {
+ // 瀹氫箟鍖洪棿鍙婂搴旂殑鍑犱綍鍙傛暟锛堟柊澧炲渾寮у弬鏁帮級
+ // 缁撴瀯锛歿start, end, 绫诲瀷, 鍙傛暟...}
+ // 绫诲瀷璇存槑锛�0-鐩寸嚎锛�1-鍦嗗姬锛堥渶瑕佸渾蹇冨潗鏍囷級
+ Object[][] intervals = {
+ // 鐩寸嚎鍖洪棿锛�0-134400锛�
+ {0.0, 134400.0, 0, 390.0, 775.0, 25.0, 775.0},
+
+ // 寮х嚎鍖洪棿锛堟嫄鐐�-杞集-133锛変繚鎸佽礉濉炲皵鏇茬嚎
+ {134400.0, 134900.0, 1, 25.0, 775.0, 65.0, 882.0, 25.0, 882.0},
+
+ // 鐩寸嚎鍖洪棿
+ {134900.0, 680103.0,0, 65.0, 885.0, 1115.0, 882.0},
+
+// // 寮х嚎鍖洪棿锛堟嫄鐐�116-115锛夛紝鎺у埗鐐瑰亣璁句负(1125, 882)
+// {680103, 731550, 1115, 882, 1215, 775, 1125, 882},
+
+ // 鍦嗗姬鍖洪棿锛堟嫄鐐�116-115锛夋柊鍙傛暟锛氬渾蹇�(1115,775)
+ {680103.0, 731550.0, 2, 1115.0, 882.0, 1215.0, 775.0, 1115.0, 775.0}, // 淇缁堢偣鍧愭爣
+
+ // 鐩寸嚎鍖洪棿
+ {731550.0, 972950.0,0, 1215.0, 775.0, 1215.0, 125.0},
+ // 寮х嚎鍖洪棿锛堟嫄鐐�112-椤剁偣锛夛紝鎺у埗鐐瑰亣璁句负(1215, 80)
+ {972950.0, 1016193.0,0, 1215.0, 125.0, 1164.0, 80.0},
+ // 寮х嚎鍖洪棿锛堟嫄鐐�-椤剁偣-111锛夛紝鎺у埗鐐瑰亣璁句负(1164, 125)
+ {1016193.0, 1063563.0,0, 1164.0, 80.0, 1115.0, 125.0},
+ // 鐩寸嚎鍖洪棿
+ {1063563.0, 1315250.0,0, 1115.0, 150.0, 1115.0, 720.0},
+ // 寮х嚎鍖洪棿锛堟嫄鐐�101-杞集锛夛紝鎺у埗鐐瑰亣璁句负(1115, 750)
+ {1315250.0, 1322829.0,0, 1115.0, 720.0, 1100.0, 750.0},
+ // 鐩寸嚎鍖洪棿
+ {1322829.0, 1737000.0,0, 1090.0, 775.0, 390.0, 775.0},
+ };
+
+ for (Object[] interval : intervals) {
+ double start = (Double) interval[0];
+ double end = (Double) interval[1];
+ int type = (Integer) interval[2];
+
+ if (b >= start && b <= end) {
+ double t = (b - start) / (end - start);
+
+ // 鏍规嵁涓嶅悓绫诲瀷璁$畻鍧愭爣
+ switch (type) {
+ case 0: // 鐩寸嚎
+ return linearInterpolation(interval, t);
+ case 1: // 璐濆灏旀洸绾�
+ return bezierInterpolation(interval, t);
+ case 2: // 鍦嗗姬
+ return circularInterpolation(interval, t);
+ }
+ }
+ }
+ return new double[]{0, 0};
+ }
+
+
+
+ // 鐩寸嚎鎻掑��
+ private static double[] linearInterpolation(Object[] interval, double t) {
+ double x1 = (Double) interval[3];
+ double y1 = (Double) interval[4];
+ double x2 = (Double) interval[5];
+ double y2 = (Double) interval[6];
+ return new double[]{
+ x1 + t * (x2 - x1),
+ y1 + t * (y2 - y1)
+ };
+ }
+
+ // 璐濆灏旀洸绾挎彃鍊�
+ private static double[] bezierInterpolation(Object[] interval, double t) {
+ double x0 = (Double) interval[3];
+ double y0 = (Double) interval[4];
+ double x2 = (Double) interval[5];
+ double y2 = (Double) interval[6];
+ double cx = (Double) interval[7];
+ double cy = (Double) interval[8];
+ return new double[]{
+ Math.pow(1-t, 2)*x0 + 2*(1-t)*t*cx + t*t*x2,
+ Math.pow(1-t, 2)*y0 + 2*(1-t)*t*cy + t*t*y2
+ };
+ }
+
+ // 鍦嗗姬鎻掑�硷紙鏂板锛�
+ private static double[] circularInterpolation(Object[] interval, double t) {
+ // 鍙傛暟瑙f瀽
+ double startX = (Double) interval[3];
+ double startY = (Double) interval[4];
+ double endX = (Double) interval[5];
+ double endY = (Double) interval[6];
+ double centerX = (Double) interval[7];
+ double centerY = (Double) interval[8];
+
+ // 璁$畻璧峰瑙掑害鍜岀粓姝㈣搴�
+ double startAngle = Math.atan2(startY - centerY, startX - centerX);
+ double endAngle = Math.atan2(endY - centerY, endX - centerX);
+
+ // 瑙掑害鎻掑��
+ double currentAngle = startAngle + t * (endAngle - startAngle);
+ double radius = Math.hypot(startX - centerX, startY - centerY);
+
+ return new double[]{
+ centerX + radius * Math.cos(currentAngle),
+ centerY + radius * Math.sin(currentAngle)
+ };
+ }
+
}
--
Gitblit v1.9.1