@vesium/geometry 1.0.1-beta.74 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,6 @@
1
1
  (function(exports) {
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- //#region src/helper.ts
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ //#region src/helper.ts
6
4
  const FITTING_COUNT = 100;
7
5
  const HALF_PI = Math.PI / 2;
8
6
  const ZERO_TOLERANCE = 1e-4;
@@ -178,7 +176,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
178
176
  const uY = normal[1] / dist;
179
177
  const d1 = mathDistance(coord1, coord2);
180
178
  const d2 = mathDistance(coord2, coord3);
181
- if (dist > ZERO_TOLERANCE) if (isClockWise(coord1, coord2, coord3)) {
179
+ if (dist > 1e-4) if (isClockWise(coord1, coord2, coord3)) {
182
180
  dt = t * d1;
183
181
  x = coord2[0] - dt * uY;
184
182
  y = coord2[1] + dt * uX;
@@ -241,7 +239,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
241
239
  ];
242
240
  const normalRight = getBisectorNormals(0, coord1, coord2, coord3)[0];
243
241
  const normal = getNormal(coord1, coord2, coord3);
244
- if (Math.hypot(normal[0], normal[1]) > ZERO_TOLERANCE) {
242
+ if (Math.hypot(normal[0], normal[1]) > 1e-4) {
245
243
  const midCoord = mid(coord1, coord2);
246
244
  const pX = coord1[0] - midCoord[0];
247
245
  const pY = coord1[1] - midCoord[1];
@@ -275,7 +273,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
275
273
  const normal = getNormal(coord1, coord2, coord3);
276
274
  const dist = Math.hypot(normal[0], normal[1]);
277
275
  let [controlX, controlY] = [0, 0];
278
- if (dist > ZERO_TOLERANCE) {
276
+ if (dist > 1e-4) {
279
277
  const midCoord = mid(coord2, coord3);
280
278
  const pX = coord3[0] - midCoord[0];
281
279
  const pY = coord3[1] - midCoord[1];
@@ -319,8 +317,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
319
317
  coord1 = controlCoords[i];
320
318
  coord2 = controlCoords[i + 1];
321
319
  coords.push(coord1);
322
- for (let j = 0; j < FITTING_COUNT; j++) {
323
- const coord = getCubicValue(j / FITTING_COUNT, coord1, normals[i * 2], normals[i * 2 + 1], coord2);
320
+ for (let j = 0; j < 100; j++) {
321
+ const coord = getCubicValue(j / 100, coord1, normals[i * 2], normals[i * 2 + 1], coord2);
324
322
  coords.push(coord);
325
323
  }
326
324
  coords.push(coord2);
@@ -418,10 +416,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
418
416
  else if (k === 2) res = t ** 2 / 2;
419
417
  return res;
420
418
  }
421
-
422
- //#endregion
423
- //#region src/arc.ts
424
- /**
419
+ //#endregion
420
+ //#region src/arc.ts
421
+ /**
425
422
  * 标绘画弓形算法,继承线要素相关方法和属性
426
423
  */
427
424
  function arc(coords) {
@@ -448,10 +445,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
448
445
  return getArcCoords(center, radius, startAngle, endAngle);
449
446
  }
450
447
  }
451
-
452
- //#endregion
453
- //#region src/arrowAttackDirection.ts
454
- /**
448
+ //#endregion
449
+ //#region src/arrowAttackDirection.ts
450
+ /**
455
451
  * 尖曲箭头
456
452
  */
457
453
  function arrowAttackDirection(coords, options = {}) {
@@ -610,10 +606,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
610
606
  }
611
607
  return symCoord;
612
608
  }
613
-
614
- //#endregion
615
- //#region src/arrowAttackDirectionTailed.ts
616
- /**
609
+ //#endregion
610
+ //#region src/arrowAttackDirectionTailed.ts
611
+ /**
617
612
  * 燕尾尖曲箭头
618
613
  */
619
614
  function arrowAttackDirectionTailed(coords, options = {}) {
@@ -650,10 +645,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
650
645
  return leftCoords.concat(headCoords, rightCoords.reverse(), [swallowTailCoord, leftCoords[0]]);
651
646
  } else return [];
652
647
  }
653
-
654
- //#endregion
655
- //#region src/arrowClamped.ts
656
- /**
648
+ //#endregion
649
+ //#region src/arrowClamped.ts
650
+ /**
657
651
  * 钳击箭头 有效点位长度3,4,5
658
652
  */
659
653
  function arrowClamped(coords) {
@@ -810,10 +804,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
810
804
  return getThirdCoord(midCoord, getThirdCoord(lineCoord1, midCoord, HALF_PI, distance1, true), HALF_PI, distance2, false);
811
805
  }
812
806
  }
813
-
814
- //#endregion
815
- //#region src/arrowStraightSharp.ts
816
- /**
807
+ //#endregion
808
+ //#region src/arrowStraightSharp.ts
809
+ /**
817
810
  * 尖箭头
818
811
  *
819
812
  */
@@ -839,10 +832,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
839
832
  tailRight
840
833
  ];
841
834
  }
842
-
843
- //#endregion
844
- //#region src/arrowStraight.ts
845
- /**
835
+ //#endregion
836
+ //#region src/arrowStraight.ts
837
+ /**
846
838
  * 直箭头
847
839
  */
848
840
  function arrowStraight(coords) {
@@ -854,10 +846,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
854
846
  neckAngle: Math.PI * .17741
855
847
  });
856
848
  }
857
-
858
- //#endregion
859
- //#region src/arrowStraightFine.ts
860
- /**
849
+ //#endregion
850
+ //#region src/arrowStraightFine.ts
851
+ /**
861
852
  * 细直箭头
862
853
  */
863
854
  function arrowStraightFine(coords) {
@@ -875,10 +866,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
875
866
  getThirdCoord(coord1, coord2, Math.PI / 6, len, true)
876
867
  ];
877
868
  }
878
-
879
- //#endregion
880
- //#region src/arrowUnitCombatOperation.ts
881
- /**
869
+ //#endregion
870
+ //#region src/arrowUnitCombatOperation.ts
871
+ /**
882
872
  * 分队战斗行动(尖曲箭头)
883
873
  */
884
874
  function arrowUnitCombatOperation(coords, options = {}) {
@@ -911,10 +901,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
911
901
  } else return [];
912
902
  }
913
903
  }
914
-
915
- //#endregion
916
- //#region src/arrowUnitCombatOperationTailed.ts
917
- /**
904
+ //#endregion
905
+ //#region src/arrowUnitCombatOperationTailed.ts
906
+ /**
918
907
  * 燕尾尖箭头
919
908
  */
920
909
  function arrowUnitCombatOperationTailed(coords, options = {}) {
@@ -952,10 +941,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
952
941
  }
953
942
  return [];
954
943
  }
955
-
956
- //#endregion
957
- //#region src/assemblingPlace.ts
958
- /**
944
+ //#endregion
945
+ //#region src/assemblingPlace.ts
946
+ /**
959
947
  * 集结地
960
948
  *
961
949
  */
@@ -979,18 +967,17 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
979
967
  const coord1 = coords[i];
980
968
  const coord2 = coords[i + 1];
981
969
  pList.push(coord1);
982
- for (let t = 0; t <= FITTING_COUNT; t++) {
983
- const coord = getCubicValue(t / FITTING_COUNT, coord1, normals[i * 2], normals[i * 2 + 1], coord2);
970
+ for (let t = 0; t <= 100; t++) {
971
+ const coord = getCubicValue(t / 100, coord1, normals[i * 2], normals[i * 2 + 1], coord2);
984
972
  pList.push(coord);
985
973
  }
986
974
  pList.push(coord2);
987
975
  }
988
976
  return pList;
989
977
  }
990
-
991
- //#endregion
992
- //#region src/circle.ts
993
- /**
978
+ //#endregion
979
+ //#region src/circle.ts
980
+ /**
994
981
  * 标绘画圆算法,继承面要素相关方法和属性
995
982
  */
996
983
  function circle(coords) {
@@ -1011,10 +998,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1011
998
  }
1012
999
  return _coords;
1013
1000
  }
1014
-
1015
- //#endregion
1016
- //#region src/closedCurve.ts
1017
- /**
1001
+ //#endregion
1002
+ //#region src/closedCurve.ts
1003
+ /**
1018
1004
  * 闭合曲面
1019
1005
  *
1020
1006
  */
@@ -1035,8 +1021,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1035
1021
  const coord1 = coords[i];
1036
1022
  const coord2 = coords[i + 1];
1037
1023
  pList.push(coord1);
1038
- for (let t = 0; t <= FITTING_COUNT; t++) {
1039
- const coord = getCubicValue(t / FITTING_COUNT, coord1, normals[i * 2], normals[i * 2 + 1], coord2);
1024
+ for (let t = 0; t <= 100; t++) {
1025
+ const coord = getCubicValue(t / 100, coord1, normals[i * 2], normals[i * 2 + 1], coord2);
1040
1026
  pList.push(coord);
1041
1027
  }
1042
1028
  pList.push(coord2);
@@ -1044,10 +1030,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1044
1030
  return pList;
1045
1031
  }
1046
1032
  }
1047
-
1048
- //#endregion
1049
- //#region src/curve.ts
1050
- /**
1033
+ //#endregion
1034
+ //#region src/curve.ts
1035
+ /**
1051
1036
  * 标绘曲线算法
1052
1037
  */
1053
1038
  function curve(coords) {
@@ -1055,10 +1040,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1055
1040
  if (coords.length < 3) throw new Error("coords.length must >= 2");
1056
1041
  else return getCurveCoords(t, coords);
1057
1042
  }
1058
-
1059
- //#endregion
1060
- //#region src/ellipse.ts
1061
- /**
1043
+ //#endregion
1044
+ //#region src/ellipse.ts
1045
+ /**
1062
1046
  * 标绘画椭圆算法,继承面要素相关方法和属性
1063
1047
  */
1064
1048
  function ellipse(coords) {
@@ -1073,18 +1057,17 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1073
1057
  0
1074
1058
  ];
1075
1059
  const _coords = [];
1076
- for (let i = 0; i <= FITTING_COUNT; i++) {
1077
- angle = Math.PI * 2 * i / FITTING_COUNT;
1060
+ for (let i = 0; i <= 100; i++) {
1061
+ angle = Math.PI * 2 * i / 100;
1078
1062
  x = center[0] + majorRadius * Math.cos(angle);
1079
1063
  y = center[1] + minorRadius * Math.sin(angle);
1080
1064
  coords.push([x, y]);
1081
1065
  }
1082
1066
  return _coords;
1083
1067
  }
1084
-
1085
- //#endregion
1086
- //#region src/lune.ts
1087
- /**
1068
+ //#endregion
1069
+ //#region src/lune.ts
1070
+ /**
1088
1071
  * 弓形
1089
1072
  */
1090
1073
  function lune(coords) {
@@ -1119,10 +1102,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1119
1102
  coords.push(coords[0]);
1120
1103
  return coords;
1121
1104
  }
1122
-
1123
- //#endregion
1124
- //#region src/rectAngle.ts
1125
- /**
1105
+ //#endregion
1106
+ //#region src/rectAngle.ts
1107
+ /**
1126
1108
  * 规则矩形
1127
1109
  *
1128
1110
  */
@@ -1137,10 +1119,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1137
1119
  startCoord
1138
1120
  ];
1139
1121
  }
1140
-
1141
- //#endregion
1142
- //#region src/rectinclined1.ts
1143
- /**
1122
+ //#endregion
1123
+ //#region src/rectinclined1.ts
1124
+ /**
1144
1125
  * 斜矩形1
1145
1126
  *
1146
1127
  */
@@ -1224,59 +1205,133 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1224
1205
  }
1225
1206
  return [x, y];
1226
1207
  }
1227
-
1228
- //#endregion
1229
- exports.FITTING_COUNT = FITTING_COUNT;
1230
- exports.HALF_PI = HALF_PI;
1231
- exports.TWO_PI = TWO_PI;
1232
- exports.ZERO_TOLERANCE = ZERO_TOLERANCE;
1233
- exports.arc = arc;
1234
- exports.arrowAttackDirection = arrowAttackDirection;
1235
- exports.arrowAttackDirectionTailed = arrowAttackDirectionTailed;
1236
- exports.arrowClamped = arrowClamped;
1237
- exports.arrowStraight = arrowStraight;
1238
- exports.arrowStraightFine = arrowStraightFine;
1239
- exports.arrowStraightSharp = arrowStraightSharp;
1240
- exports.arrowUnitCombatOperation = arrowUnitCombatOperation;
1241
- exports.arrowUnitCombatOperationTailed = arrowUnitCombatOperationTailed;
1242
- exports.assemblingPlace = assemblingPlace;
1243
- exports.calculateFourthCoord = calculateFourthCoord;
1244
- exports.calculatePerpendicularCoord = calculatePerpendicularCoord;
1245
- exports.calculatePerpendicularDistance = calculatePerpendicularDistance;
1246
- exports.calculatePositionRelativeToLine = calculatePositionRelativeToLine;
1247
- exports.circle = circle;
1248
- exports.closedCurve = closedCurve;
1249
- exports.curve = curve;
1250
- exports.ellipse = ellipse;
1251
- exports.getAngleOfThreeCoords = getAngleOfThreeCoords;
1252
- exports.getArcCoords = getArcCoords;
1253
- exports.getArrowBodyCoords = getArrowBodyCoords;
1254
- exports.getArrowCoords = getArrowCoords;
1255
- exports.getArrowHeadCoords = getArrowHeadCoords;
1256
- exports.getAzimuth = getAzimuth;
1257
- exports.getBaseLength = getBaseLength;
1258
- exports.getBezierCoords = getBezierCoords;
1259
- exports.getBinomialFactor = getBinomialFactor;
1260
- exports.getBisectorNormals = getBisectorNormals;
1261
- exports.getCircleCenterOfThreeCoords = getCircleCenterOfThreeCoords;
1262
- exports.getCoordOnLine = getCoordOnLine;
1263
- exports.getCubicValue = getCubicValue;
1264
- exports.getCurveCoords = getCurveCoords;
1265
- exports.getFactorial = getFactorial;
1266
- exports.getIntersectCoord = getIntersectCoord;
1267
- exports.getLeftMostControlCoord = getLeftMostControlCoord;
1268
- exports.getNormal = getNormal;
1269
- exports.getQBSplineCoords = getQBSplineCoords;
1270
- exports.getQuadricBSplineFactor = getQuadricBSplineFactor;
1271
- exports.getRightMostControlCoord = getRightMostControlCoord;
1272
- exports.getTempCoord4 = getTempCoord4;
1273
- exports.getThirdCoord = getThirdCoord;
1274
- exports.isClockWise = isClockWise;
1275
- exports.lune = lune;
1276
- exports.mathDistance = mathDistance;
1277
- exports.mid = mid;
1278
- exports.rectAngle = rectAngle;
1279
- exports.rectinclined1 = rectinclined1;
1280
- exports.wholeDistance = wholeDistance;
1208
+ //#endregion
1209
+ //#region src/rectinclined2.ts
1210
+ /**
1211
+ * 斜矩形2
1212
+ *
1213
+ */
1214
+ function rectinclined2(coords) {
1215
+ if (coords.length < 3) throw new Error("coords.length must >= 3");
1216
+ else {
1217
+ const [coord1, coord2, mouse] = [
1218
+ coords[0],
1219
+ coords[1],
1220
+ coords[2]
1221
+ ];
1222
+ const intersect = calculateIntersectionCoord(coord1, coord2, mouse);
1223
+ const coord4 = calculateFourthCoord$1(coord1, intersect, mouse);
1224
+ const pList = [];
1225
+ pList.push(coord1, intersect, mouse, coord4, coord1);
1226
+ return pList;
1227
+ }
1228
+ }
1229
+ /**
1230
+ * 已知p1,p2,p3点求矩形的p4点
1231
+ * @param {*} p1
1232
+ * @param {*} p2
1233
+ * @param {*} p3
1234
+ */
1235
+ function calculateFourthCoord$1(p1, p2, p3) {
1236
+ return [p1[0] + p3[0] - p2[0], p1[1] + p3[1] - p2[1]];
1237
+ }
1238
+ /**
1239
+ * 已知p1点和p2点,求p3点到p1p2垂线的交点
1240
+ * @param {*} p1
1241
+ * @param {*} p2
1242
+ * @param {*} p3
1243
+ */
1244
+ function calculateIntersectionCoord(p1, p2, p3) {
1245
+ const v = {
1246
+ x: p2[0] - p1[0],
1247
+ y: p2[1] - p1[1]
1248
+ };
1249
+ const u = {
1250
+ x: p3[0] - p1[0],
1251
+ y: p3[1] - p1[1]
1252
+ };
1253
+ const projectionLength = (u.x * v.x + u.y * v.y) / (v.x * v.x + v.y * v.y);
1254
+ const intersectionCoord = {
1255
+ x: p1[0] + v.x * projectionLength,
1256
+ y: p1[1] + v.y * projectionLength
1257
+ };
1258
+ return [intersectionCoord.x, intersectionCoord.y];
1259
+ }
1260
+ //#endregion
1261
+ //#region src/sector.ts
1262
+ /**
1263
+ * 扇形
1264
+ *
1265
+ */
1266
+ function sector(coords) {
1267
+ if (coords.length < 3) throw new Error("coords.length must >= 2");
1268
+ else {
1269
+ const [center, coord2, coord3] = [
1270
+ coords[0],
1271
+ coords[1],
1272
+ coords[2]
1273
+ ];
1274
+ const pList = getArcCoords(center, mathDistance(coord2, center), getAzimuth(coord2, center), getAzimuth(coord3, center));
1275
+ pList.push(center, pList[0]);
1276
+ return pList;
1277
+ }
1278
+ }
1279
+ //#endregion
1280
+ exports.FITTING_COUNT = FITTING_COUNT;
1281
+ exports.HALF_PI = HALF_PI;
1282
+ exports.TWO_PI = TWO_PI;
1283
+ exports.ZERO_TOLERANCE = ZERO_TOLERANCE;
1284
+ exports.arc = arc;
1285
+ exports.arrowAttackDirection = arrowAttackDirection;
1286
+ exports.arrowAttackDirectionTailed = arrowAttackDirectionTailed;
1287
+ exports.arrowClamped = arrowClamped;
1288
+ exports.arrowStraight = arrowStraight;
1289
+ exports.arrowStraightFine = arrowStraightFine;
1290
+ exports.arrowStraightSharp = arrowStraightSharp;
1291
+ exports.arrowUnitCombatOperation = arrowUnitCombatOperation;
1292
+ exports.arrowUnitCombatOperationTailed = arrowUnitCombatOperationTailed;
1293
+ exports.assemblingPlace = assemblingPlace;
1294
+ exports.calculateFourthCoord = calculateFourthCoord;
1295
+ exports.calculateIntersectionCoord = calculateIntersectionCoord;
1296
+ exports.calculatePerpendicularCoord = calculatePerpendicularCoord;
1297
+ exports.calculatePerpendicularDistance = calculatePerpendicularDistance;
1298
+ exports.calculatePositionRelativeToLine = calculatePositionRelativeToLine;
1299
+ exports.circle = circle;
1300
+ exports.closedCurve = closedCurve;
1301
+ exports.curve = curve;
1302
+ exports.ellipse = ellipse;
1303
+ exports.getAngleOfThreeCoords = getAngleOfThreeCoords;
1304
+ exports.getArcCoords = getArcCoords;
1305
+ exports.getArrowBodyCoords = getArrowBodyCoords;
1306
+ exports.getArrowCoords = getArrowCoords;
1307
+ exports.getArrowHeadCoords = getArrowHeadCoords;
1308
+ exports.getAzimuth = getAzimuth;
1309
+ exports.getBaseLength = getBaseLength;
1310
+ exports.getBezierCoords = getBezierCoords;
1311
+ exports.getBinomialFactor = getBinomialFactor;
1312
+ exports.getBisectorNormals = getBisectorNormals;
1313
+ exports.getCircleCenterOfThreeCoords = getCircleCenterOfThreeCoords;
1314
+ exports.getCoordOnLine = getCoordOnLine;
1315
+ exports.getCubicValue = getCubicValue;
1316
+ exports.getCurveCoords = getCurveCoords;
1317
+ exports.getFactorial = getFactorial;
1318
+ exports.getIntersectCoord = getIntersectCoord;
1319
+ exports.getLeftMostControlCoord = getLeftMostControlCoord;
1320
+ exports.getNormal = getNormal;
1321
+ exports.getQBSplineCoords = getQBSplineCoords;
1322
+ exports.getQuadricBSplineFactor = getQuadricBSplineFactor;
1323
+ exports.getRightMostControlCoord = getRightMostControlCoord;
1324
+ exports.getTempCoord4 = getTempCoord4;
1325
+ exports.getThirdCoord = getThirdCoord;
1326
+ exports.isClockWise = isClockWise;
1327
+ exports.lune = lune;
1328
+ exports.mathDistance = mathDistance;
1329
+ exports.mid = mid;
1330
+ exports.rectAngle = rectAngle;
1331
+ exports.rectinclined1 = rectinclined1;
1332
+ exports.rectinclined2 = rectinclined2;
1333
+ exports.sector = sector;
1334
+ exports.wholeDistance = wholeDistance;
1281
1335
  })(this.Vesium = this.Vesium || {});
1336
+
1282
1337
  //# sourceMappingURL=index.iife.js.map