@pirireis/webglobeplugins 0.9.11 → 0.9.13

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.
Files changed (179) hide show
  1. package/Math/angle-calculation.js +9 -11
  2. package/Math/arc.js +38 -41
  3. package/Math/bounds/line-bbox.js +79 -83
  4. package/Math/constants.js +4 -9
  5. package/Math/frustum/types.js +1 -2
  6. package/Math/juction/arc-plane.js +33 -36
  7. package/Math/juction/line-sphere.js +15 -18
  8. package/Math/juction/plane-plane.js +20 -23
  9. package/Math/line.js +42 -47
  10. package/Math/methods.js +69 -92
  11. package/Math/plane.js +33 -38
  12. package/Math/quaternion.js +48 -55
  13. package/Math/types.js +1 -2
  14. package/Math/utils.js +2 -4
  15. package/Math/vec3.js +46 -52
  16. package/algorithms/search-binary.js +5 -8
  17. package/altitude-locator/draw-subset-obj.js +8 -11
  18. package/altitude-locator/plugin.js +114 -133
  19. package/altitude-locator/types.js +1 -3
  20. package/arrowfield/adaptor.js +3 -7
  21. package/arrowfield/index.js +3 -10
  22. package/arrowfield/plugin.js +63 -69
  23. package/bearing-line/index.js +2 -8
  24. package/bearing-line/plugin.js +218 -248
  25. package/circle-line-chain/chain-list-map.js +82 -92
  26. package/circle-line-chain/plugin.js +147 -182
  27. package/circle-line-chain/util.js +1 -5
  28. package/compass-rose/compass-rose-padding-flat.js +111 -140
  29. package/compass-rose/compass-text-writer.js +63 -75
  30. package/compass-rose/index.js +3 -7
  31. package/compassrose/compassrose.js +50 -57
  32. package/compassrose/index.js +2 -8
  33. package/heatwave/index.js +3 -10
  34. package/heatwave/isobar/objectarraylabels.js +50 -56
  35. package/heatwave/isobar/plugin.js +111 -170
  36. package/heatwave/isobar/quadtreecontours.js +78 -96
  37. package/heatwave/plugins/heatwaveglobeshell.js +73 -94
  38. package/index.js +12 -58
  39. package/package.json +1 -1
  40. package/partialrings/buffer-manager.js +32 -70
  41. package/partialrings/index.js +2 -41
  42. package/partialrings/plugin.js +55 -98
  43. package/partialrings/program.js +141 -59
  44. package/pin/pin-object-array.js +89 -97
  45. package/pin/pin-point-totem.js +21 -22
  46. package/point-heat-map/adaptors/timetracksplugin-format-to-this.js +11 -14
  47. package/point-heat-map/plugin-webworker.js +45 -53
  48. package/point-heat-map/point-to-heat-map-flow.js +46 -51
  49. package/point-tracks/key-methods.js +2 -5
  50. package/point-tracks/plugin.js +141 -170
  51. package/programs/arrowfield/index.js +2 -7
  52. package/programs/arrowfield/logic.js +172 -67
  53. package/programs/arrowfield/object.js +35 -43
  54. package/programs/data2legend/density-to-legend.js +47 -26
  55. package/programs/data2legend/point-to-density-texture.js +56 -34
  56. package/programs/float2legendwithratio/index.js +2 -8
  57. package/programs/float2legendwithratio/logic.js +88 -45
  58. package/programs/float2legendwithratio/object.js +45 -54
  59. package/programs/globe-util/is-globe-moved.js +10 -13
  60. package/programs/globeshell/index.js +2 -8
  61. package/programs/globeshell/wiggle/index.js +2 -8
  62. package/programs/globeshell/wiggle/logic.js +191 -101
  63. package/programs/globeshell/wiggle/object.js +35 -43
  64. package/programs/helpers/blender/program.js +36 -22
  65. package/programs/helpers/fadeaway/index.js +2 -7
  66. package/programs/helpers/fadeaway/logic.js +36 -17
  67. package/programs/helpers/fadeaway/object.js +11 -18
  68. package/programs/helpers/index.js +2 -8
  69. package/programs/index.js +9 -58
  70. package/programs/line-on-globe/angled-line.js +95 -39
  71. package/programs/line-on-globe/circle-accurate-3d.js +86 -39
  72. package/programs/line-on-globe/circle-accurate-flat.js +116 -64
  73. package/programs/line-on-globe/circle-accurate.js +113 -46
  74. package/programs/line-on-globe/circle.js +106 -44
  75. package/programs/line-on-globe/degree-padding-around-circle-3d.js +89 -42
  76. package/programs/line-on-globe/lines-color-instanced-flat.js +84 -43
  77. package/programs/line-on-globe/linestrip.js +126 -63
  78. package/programs/line-on-globe/naive-accurate-flexible.js +126 -59
  79. package/programs/line-on-globe/to-the-surface.js +62 -35
  80. package/programs/line-on-globe/util.js +2 -5
  81. package/programs/picking/pickable-renderer.js +127 -46
  82. package/programs/point-on-globe/element-globe-surface-glow.js +83 -46
  83. package/programs/point-on-globe/element-point-glow.js +112 -47
  84. package/programs/point-on-globe/square-pixel-point.js +80 -34
  85. package/programs/programcache.js +14 -19
  86. package/programs/rings/distancering/circleflatprogram.js +76 -70
  87. package/programs/rings/distancering/circlepaddingfreeangleprogram.js +168 -194
  88. package/programs/rings/distancering/circlepaddysharedbuffer.js +121 -200
  89. package/programs/rings/distancering/index.js +5 -14
  90. package/programs/rings/distancering/paddyflatprogram.js +87 -70
  91. package/programs/rings/distancering/paddyflatprogram2d.js +89 -72
  92. package/programs/rings/distancering/paddyflatprogram3d.js +87 -70
  93. package/programs/rings/index.js +1 -17
  94. package/programs/rings/partial-ring/piece-of-pie.js +144 -44
  95. package/programs/totems/camerauniformblock.js +65 -56
  96. package/programs/totems/canvas-webglobe-info.js +49 -45
  97. package/programs/totems/gpu-selection-uniform-block.js +45 -45
  98. package/programs/totems/index.js +2 -40
  99. package/programs/two-d/pixel-padding-for-compass.js +94 -36
  100. package/programs/util.js +7 -10
  101. package/programs/vectorfields/index.js +3 -23
  102. package/programs/vectorfields/logics/drawrectangleparticles.js +73 -35
  103. package/programs/vectorfields/logics/index.js +4 -12
  104. package/programs/vectorfields/logics/pixelbased.js +94 -41
  105. package/programs/vectorfields/logics/ubo.js +32 -32
  106. package/programs/vectorfields/pingpongbuffermanager.js +30 -37
  107. package/rangerings/enum.js +2 -5
  108. package/rangerings/index.js +5 -15
  109. package/rangerings/plugin.js +223 -286
  110. package/rangerings/rangeringangletext.js +122 -137
  111. package/rangerings/ring-account.js +53 -75
  112. package/shaders/fragment-toy/firework.js +55 -4
  113. package/shaders/fragment-toy/singularity.js +56 -5
  114. package/timetracks/adaptors-line-strip.js +27 -44
  115. package/timetracks/adaptors.js +48 -67
  116. package/timetracks/index.js +5 -19
  117. package/timetracks/plugin-line-strip.js +65 -79
  118. package/timetracks/plugin.js +71 -85
  119. package/timetracks/program-line-strip.js +297 -107
  120. package/timetracks/program.js +421 -118
  121. package/timetracks/programpoint-line-strip.js +98 -48
  122. package/timetracks/programpoint.js +91 -48
  123. package/util/account/bufferoffsetmanager.js +72 -98
  124. package/util/account/index.js +3 -23
  125. package/util/account/single-attribute-buffer-management/buffer-manager.js +44 -48
  126. package/util/account/single-attribute-buffer-management/buffer-orchestrator.js +68 -98
  127. package/util/account/single-attribute-buffer-management/index.js +4 -9
  128. package/util/account/single-attribute-buffer-management/object-store.js +29 -34
  129. package/util/account/single-attribute-buffer-management/types.js +1 -2
  130. package/util/account/util.js +2 -8
  131. package/util/algorithms/search-binary.js +5 -8
  132. package/util/check/get.js +5 -9
  133. package/util/check/typecheck.js +13 -24
  134. package/util/geometry/index.js +10 -18
  135. package/util/gl-util/buffer/attribute-loader.js +10 -26
  136. package/util/gl-util/buffer/index.js +2 -5
  137. package/util/gl-util/draw-options/methods.js +10 -15
  138. package/util/gl-util/uniform-block/manager.js +69 -72
  139. package/util/heatwavedatamanager/datamanager.js +56 -119
  140. package/util/heatwavedatamanager/index.js +3 -10
  141. package/util/heatwavedatamanager/pointcoordinatesdatacalculator.js +38 -47
  142. package/util/heatwavedatamanager/pointcoordsmeta.js +9 -13
  143. package/util/index.js +13 -57
  144. package/util/interpolation/timetrack/index.js +2 -5
  145. package/util/interpolation/timetrack/timetrack-interpolator.js +30 -36
  146. package/util/interpolation/timetrack/web-worker-str.js +180 -5
  147. package/util/interpolation/timetrack/web-worker.js +4 -6
  148. package/util/jshelpers/data-filler.js +8 -11
  149. package/util/jshelpers/equality.js +1 -3
  150. package/util/jshelpers/index.js +2 -37
  151. package/util/jshelpers/timefilters.js +8 -10
  152. package/util/picking/fence.js +8 -11
  153. package/util/picking/picker-displayer.js +49 -58
  154. package/util/programs/draw-texture-on-canvas.js +41 -26
  155. package/util/programs/index.js +1 -17
  156. package/util/programs/shapesonglobe.js +104 -68
  157. package/util/programs/supersampletotextures.js +45 -43
  158. package/util/programs/texturetoglobe.js +99 -52
  159. package/util/shaderfunctions/geometrytransformations.js +323 -35
  160. package/util/shaderfunctions/index.js +2 -18
  161. package/util/shaderfunctions/nodata.js +8 -5
  162. package/util/shaderfunctions/noisefunctions.js +40 -12
  163. package/util/surface-line-data/arcs-to-cuts.js +20 -23
  164. package/util/webglobe/gldefaultstates.js +1 -4
  165. package/util/webglobe/index.js +2 -18
  166. package/util/webglobe/rasteroverlay.js +36 -41
  167. package/util/webglobjectbuilders.js +70 -93
  168. package/util/webglobjectbuilders1.js +63 -82
  169. package/waveparticles/adaptor.js +7 -10
  170. package/waveparticles/index.js +3 -10
  171. package/waveparticles/plugin.js +82 -90
  172. package/wind/imagetovectorfieldandmagnitude.js +16 -19
  173. package/wind/index.js +5 -14
  174. package/wind/plugin.js +454 -291
  175. package/wind/vectorfieldimage.js +6 -8
  176. package/write-text/attached-text-writer.js +48 -54
  177. package/write-text/context-text.js +52 -63
  178. package/write-text/context-text3.js +71 -80
  179. package/write-text/index.js +1 -5
@@ -1,15 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bearingRealAngle = bearingRealAngle;
4
1
  function bearingRealAngle(long, lat, endLong, endLat) {
5
- var rLong = Radians * long;
6
- var rLat = Radians * lat;
7
- var rEndLong = Radians * endLong;
8
- var rEndLat = Radians * endLat;
9
- var delta_long = rEndLong - rLong;
10
- var x = Math.sin(delta_long) * Math.cos(rEndLat);
11
- var y = Math.cos(rLat) * Math.sin(rEndLat) - Math.sin(rLat) * Math.cos(rEndLat) * Math.cos(delta_long);
12
- var initialBearing = Math.atan2(x, y) / Radians;
2
+ const rLong = Radians * long;
3
+ const rLat = Radians * lat;
4
+ const rEndLong = Radians * endLong;
5
+ const rEndLat = Radians * endLat;
6
+ const delta_long = rEndLong - rLong;
7
+ const x = Math.sin(delta_long) * Math.cos(rEndLat);
8
+ const y = Math.cos(rLat) * Math.sin(rEndLat) - Math.sin(rLat) * Math.cos(rEndLat) * Math.cos(delta_long);
9
+ let initialBearing = Math.atan2(x, y) / Radians;
13
10
  initialBearing = (initialBearing + 360) % 360;
14
11
  return initialBearing;
15
12
  }
13
+ export { bearingRealAngle };
package/Math/arc.js CHANGED
@@ -1,64 +1,61 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.arc = void 0;
4
- var vec3_1 = require("./vec3");
5
- var constants_1 = require("./constants");
6
- var _0vector = /*@__PURE__*/ vec3_1.vec3.create(0, 0, 0);
7
- var _1vector = /*@__PURE__*/ vec3_1.vec3.create(1, 1, 1);
8
- exports.arc = Object.freeze({
9
- create: function (p0, p1) {
10
- var normal = vec3_1.vec3.create(0, 0, 0);
11
- vec3_1.vec3.cross(normal, p0, p1);
12
- var coverPlaneNormal = [p0[0] + p1[0], p0[1] + p1[1], p0[2] + p1[2]];
13
- vec3_1.vec3.normalize(coverPlaneNormal, coverPlaneNormal);
14
- var dot = vec3_1.vec3.dot(coverPlaneNormal, p0);
1
+ import { vec3 } from "./vec3";
2
+ import { EPSILON } from "./constants";
3
+ const _0vector = /*@__PURE__*/ vec3.create(0, 0, 0);
4
+ const _1vector = /*@__PURE__*/ vec3.create(1, 1, 1);
5
+ export const arc = Object.freeze({
6
+ create(p0, p1) {
7
+ const normal = vec3.create(0, 0, 0);
8
+ vec3.cross(normal, p0, p1);
9
+ const coverPlaneNormal = [p0[0] + p1[0], p0[1] + p1[1], p0[2] + p1[2]];
10
+ vec3.normalize(coverPlaneNormal, coverPlaneNormal);
11
+ const dot = vec3.dot(coverPlaneNormal, p0);
15
12
  return {
16
- p0: vec3_1.vec3.clone(p0),
17
- p1: vec3_1.vec3.clone(p1),
18
- normal: vec3_1.vec3.clone(normal),
13
+ p0: vec3.clone(p0),
14
+ p1: vec3.clone(p1),
15
+ normal: vec3.clone(normal),
19
16
  coverPlane: {
20
17
  normal: coverPlaneNormal,
21
18
  distance: dot
22
19
  }
23
20
  };
24
21
  },
25
- set: function (out, p0, p1) {
26
- vec3_1.vec3.copy(out.p0, p0);
27
- vec3_1.vec3.copy(out.p1, p1);
28
- vec3_1.vec3.cross(out.normal, p0, p1);
29
- var coverPlaneNormal = [p0[0] + p1[0], p0[1] + p1[1], p0[2] + p1[2]];
30
- vec3_1.vec3.normalize(coverPlaneNormal, coverPlaneNormal);
22
+ set(out, p0, p1) {
23
+ vec3.copy(out.p0, p0);
24
+ vec3.copy(out.p1, p1);
25
+ vec3.cross(out.normal, p0, p1);
26
+ const coverPlaneNormal = [p0[0] + p1[0], p0[1] + p1[1], p0[2] + p1[2]];
27
+ vec3.normalize(coverPlaneNormal, coverPlaneNormal);
31
28
  out.coverPlane.normal = coverPlaneNormal;
32
- out.coverPlane.distance = vec3_1.vec3.dot(coverPlaneNormal, p0);
29
+ out.coverPlane.distance = vec3.dot(coverPlaneNormal, p0);
33
30
  },
34
- copy: function (out, a) {
35
- vec3_1.vec3.copy(out.p0, a.p0);
36
- vec3_1.vec3.copy(out.p1, a.p1);
37
- vec3_1.vec3.copy(out.normal, a.normal);
38
- out.coverPlane.normal = vec3_1.vec3.clone(a.coverPlane.normal);
31
+ copy(out, a) {
32
+ vec3.copy(out.p0, a.p0);
33
+ vec3.copy(out.p1, a.p1);
34
+ vec3.copy(out.normal, a.normal);
35
+ out.coverPlane.normal = vec3.clone(a.coverPlane.normal);
39
36
  out.coverPlane.distance = a.coverPlane.distance;
40
37
  },
41
- clone: function (a) {
38
+ clone(a) {
42
39
  return {
43
- p0: vec3_1.vec3.clone(a.p0),
44
- p1: vec3_1.vec3.clone(a.p1),
45
- normal: vec3_1.vec3.clone(a.normal),
40
+ p0: vec3.clone(a.p0),
41
+ p1: vec3.clone(a.p1),
42
+ normal: vec3.clone(a.normal),
46
43
  coverPlane: {
47
- normal: vec3_1.vec3.clone(a.coverPlane.normal),
44
+ normal: vec3.clone(a.coverPlane.normal),
48
45
  distance: a.coverPlane.distance
49
46
  }
50
47
  };
51
48
  },
52
- isPointOn: function (arc, point) {
53
- var alignment = Math.abs(vec3_1.vec3.dot(point, arc.normal)) < constants_1.EPSILON;
54
- var distance = Math.abs(vec3_1.vec3.lengthSquared(point) - 1) < constants_1.EPSILON;
55
- var cover = vec3_1.vec3.dot(arc.coverPlane.normal, point) >= arc.coverPlane.distance;
49
+ isPointOn(arc, point) {
50
+ const alignment = Math.abs(vec3.dot(point, arc.normal)) < EPSILON;
51
+ const distance = Math.abs(vec3.lengthSquared(point) - 1) < EPSILON;
52
+ const cover = vec3.dot(arc.coverPlane.normal, point) >= arc.coverPlane.distance;
56
53
  return alignment || distance || cover;
57
54
  },
58
- equals: function (a, b) {
59
- return vec3_1.vec3.equals(a.p0, b.p0) && vec3_1.vec3.equals(a.p1, b.p1);
55
+ equals(a, b) {
56
+ return vec3.equals(a.p0, b.p0) && vec3.equals(a.p1, b.p1);
60
57
  },
61
- populatePoints: function (out, arc, count) {
58
+ populatePoints(out, arc, count) {
62
59
  // rotate p0 around normal vector with a quaternion
63
60
  // calculate angle
64
61
  }
@@ -1,9 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGreatCircleArcBBox = getGreatCircleArcBBox;
4
- function isClose(a, b, rtol, atol) {
5
- if (rtol === void 0) { rtol = 1e-5; }
6
- if (atol === void 0) { atol = 1e-8; }
1
+ function isClose(a, b, rtol = 1e-5, atol = 1e-8) {
7
2
  // JavaScript equivalent of NumPy's isclose
8
3
  return Math.abs(a - b) <= (atol + rtol * Math.abs(b));
9
4
  }
@@ -21,10 +16,10 @@ function calculateInitialBearing(phi1, lambda1, phi2, lambda2) {
21
16
  return 0; // Bearing is North
22
17
  }
23
18
  }
24
- var deltaLambda = lambda2 - lambda1;
25
- var y = Math.sin(deltaLambda) * Math.cos(phi2);
26
- var x = Math.cos(phi1) * Math.sin(phi2) - Math.sin(phi1) * Math.cos(phi2) * Math.cos(deltaLambda);
27
- var theta = Math.atan2(y, x);
19
+ const deltaLambda = lambda2 - lambda1;
20
+ const y = Math.sin(deltaLambda) * Math.cos(phi2);
21
+ const x = Math.cos(phi1) * Math.sin(phi2) - Math.sin(phi1) * Math.cos(phi2) * Math.cos(deltaLambda);
22
+ const theta = Math.atan2(y, x);
28
23
  return theta;
29
24
  }
30
25
  function getGreatCircleArcBBox(phi1Rad, lambda1Rad, phi2Rad, lambda2Rad) {
@@ -37,23 +32,23 @@ function getGreatCircleArcBBox(phi1Rad, lambda1Rad, phi2Rad, lambda2Rad) {
37
32
  return [phi1Rad, phi1Rad, lambda1Rad, lambda1Rad];
38
33
  }
39
34
  // === Edge Case: Antipodal Points ===
40
- var deltaLambdaNorm = mod(lambda1Rad - lambda2Rad + Math.PI, 2 * Math.PI) - Math.PI;
35
+ const deltaLambdaNorm = mod(lambda1Rad - lambda2Rad + Math.PI, 2 * Math.PI) - Math.PI;
41
36
  if (isClose(phi1Rad, -phi2Rad) && isClose(Math.abs(deltaLambdaNorm), Math.PI)) {
42
37
  // Path covers all longitudes and passes through poles
43
38
  return [-Math.PI / 2, Math.PI / 2, -Math.PI, Math.PI];
44
39
  }
45
40
  // === Longitude Bounds ===
46
- var lambda1Adj = lambda1Rad;
47
- var lambda2Adj = lambda2Rad;
41
+ let lambda1Adj = lambda1Rad;
42
+ let lambda2Adj = lambda2Rad;
48
43
  // Handle antimeridian crossing
49
- var deltaLambda = lambda2Rad - lambda1Rad;
44
+ let deltaLambda = lambda2Rad - lambda1Rad;
50
45
  if (deltaLambda > Math.PI) {
51
46
  deltaLambda -= 2 * Math.PI;
52
47
  }
53
48
  else if (deltaLambda <= -Math.PI) {
54
49
  deltaLambda += 2 * Math.PI;
55
50
  }
56
- var crossesAntimeridian = Math.abs(lambda2Rad - lambda1Rad) > Math.PI;
51
+ const crossesAntimeridian = Math.abs(lambda2Rad - lambda1Rad) > Math.PI;
57
52
  if (crossesAntimeridian) {
58
53
  // Add 2*pi to the smaller longitude
59
54
  if (lambda1Rad < lambda2Rad) {
@@ -63,20 +58,20 @@ function getGreatCircleArcBBox(phi1Rad, lambda1Rad, phi2Rad, lambda2Rad) {
63
58
  lambda2Adj += 2 * Math.PI;
64
59
  }
65
60
  }
66
- var lambdaMin = Math.min(lambda1Adj, lambda2Adj);
67
- var lambdaMax = Math.max(lambda1Adj, lambda2Adj);
61
+ const lambdaMin = Math.min(lambda1Adj, lambda2Adj);
62
+ const lambdaMax = Math.max(lambda1Adj, lambda2Adj);
68
63
  // === Latitude Bounds ===
69
- var phiMin = Math.min(phi1Rad, phi2Rad);
70
- var phiMax = Math.max(phi1Rad, phi2Rad);
64
+ let phiMin = Math.min(phi1Rad, phi2Rad);
65
+ let phiMax = Math.max(phi1Rad, phi2Rad);
71
66
  // === Vertex Check ===
72
67
  // Check the maximum/minimum latitude reached by the great circle
73
- var theta12 = calculateInitialBearing(phi1Rad, lambda1Rad, phi2Rad, lambda2Rad);
74
- var theta21 = calculateInitialBearing(phi2Rad, lambda2Rad, phi1Rad, lambda1Rad);
75
- var cosPhi1 = Math.cos(phi1Rad);
68
+ const theta12 = calculateInitialBearing(phi1Rad, lambda1Rad, phi2Rad, lambda2Rad);
69
+ const theta21 = calculateInitialBearing(phi2Rad, lambda2Rad, phi1Rad, lambda1Rad);
70
+ const cosPhi1 = Math.cos(phi1Rad);
76
71
  if (!isClose(cosPhi1, 0)) { // Starting point is not a pole
77
72
  // Compute the absolute latitude of the vertex
78
- var argAcos = Math.abs(Math.sin(theta12) * cosPhi1);
79
- var phiVtxAbs = Math.acos(Math.min(Math.max(argAcos, -1.0), 1.0));
73
+ const argAcos = Math.abs(Math.sin(theta12) * cosPhi1);
74
+ const phiVtxAbs = Math.acos(Math.min(Math.max(argAcos, -1.0), 1.0));
80
75
  // Check if the path crosses the northern vertex
81
76
  if (isClose(theta12, 0) && phiVtxAbs > phiMax) { // Starting due north
82
77
  phiMax = phiVtxAbs;
@@ -86,7 +81,7 @@ function getGreatCircleArcBBox(phi1Rad, lambda1Rad, phi2Rad, lambda2Rad) {
86
81
  }
87
82
  else {
88
83
  // General case: Check if the path crosses the vertex
89
- var finalBearingAtP2 = mod(theta21 + Math.PI + Math.PI, 2 * Math.PI) - Math.PI;
84
+ const finalBearingAtP2 = mod(theta21 + Math.PI + Math.PI, 2 * Math.PI) - Math.PI;
90
85
  // Northern vertex check
91
86
  if ((-Math.PI / 2 < theta12 && theta12 < Math.PI / 2) &&
92
87
  !(finalBearingAtP2 >= -Math.PI / 2 && finalBearingAtP2 <= Math.PI / 2)) {
@@ -112,79 +107,80 @@ function degreesToRadians(deg) {
112
107
  function radiansToDegrees(rad) {
113
108
  return rad * 180 / Math.PI;
114
109
  }
110
+ export { getGreatCircleArcBBox };
115
111
  // Test Case 1: London to Tokyo
116
- var lat1Deg = 51.5, lon1Deg = -0.1;
117
- var lat2Deg = 35.7, lon2Deg = 139.7;
118
- var phi1 = degreesToRadians(lat1Deg);
119
- var lambda1 = degreesToRadians(lon1Deg);
120
- var phi2 = degreesToRadians(lat2Deg);
121
- var lambda2 = degreesToRadians(lon2Deg);
122
- var _a = getGreatCircleArcBBox(phi1, lambda1, phi2, lambda2), phiMinRad = _a[0], phiMaxRad = _a[1], lambdaMinRad = _a[2], lambdaMaxRad = _a[3];
123
- var phiMinDeg = radiansToDegrees(phiMinRad);
124
- var phiMaxDeg = radiansToDegrees(phiMaxRad);
125
- var lambdaMinDeg = radiansToDegrees(lambdaMinRad);
126
- var lambdaMaxDeg = radiansToDegrees(lambdaMaxRad);
112
+ const lat1Deg = 51.5, lon1Deg = -0.1;
113
+ const lat2Deg = 35.7, lon2Deg = 139.7;
114
+ const phi1 = degreesToRadians(lat1Deg);
115
+ const lambda1 = degreesToRadians(lon1Deg);
116
+ const phi2 = degreesToRadians(lat2Deg);
117
+ const lambda2 = degreesToRadians(lon2Deg);
118
+ const [phiMinRad, phiMaxRad, lambdaMinRad, lambdaMaxRad] = getGreatCircleArcBBox(phi1, lambda1, phi2, lambda2);
119
+ const phiMinDeg = radiansToDegrees(phiMinRad);
120
+ const phiMaxDeg = radiansToDegrees(phiMaxRad);
121
+ const lambdaMinDeg = radiansToDegrees(lambdaMinRad);
122
+ const lambdaMaxDeg = radiansToDegrees(lambdaMaxRad);
127
123
  console.log("Input Points (Radians):");
128
- console.log(" P1: Latitude=".concat(lat1Deg, ", Longitude=").concat(lon1Deg));
129
- console.log(" P2: Latitude=".concat(lat2Deg, ", Longitude=").concat(lon2Deg));
130
- console.log(" P1: Latitude=".concat(phi1.toFixed(4), ", Longitude=").concat(lambda1.toFixed(4)));
131
- console.log(" P2: Latitude=".concat(phi2.toFixed(4), ", Longitude=").concat(lambda2.toFixed(4)));
124
+ console.log(` P1: Latitude=${lat1Deg}, Longitude=${lon1Deg}`);
125
+ console.log(` P2: Latitude=${lat2Deg}, Longitude=${lon2Deg}`);
126
+ console.log(` P1: Latitude=${phi1.toFixed(4)}, Longitude=${lambda1.toFixed(4)}`);
127
+ console.log(` P2: Latitude=${phi2.toFixed(4)}, Longitude=${lambda2.toFixed(4)}`);
132
128
  console.log("-".repeat(20));
133
129
  console.log("Bounding Box (Radians):");
134
130
  // console phys://console.log(` Minimum Latitude (phi_min): ${phiMinRad.toFixed(4)}`);
135
- console.log(" Maximum Latitude (phi_max): ".concat(phiMaxRad.toFixed(4)));
136
- console.log(" Minimum Longitude (lambda_min): ".concat(lambdaMinRad.toFixed(4)));
137
- console.log(" Maximum Longitude (lambda_max): ".concat(lambdaMaxRad.toFixed(4)));
131
+ console.log(` Maximum Latitude (phi_max): ${phiMaxRad.toFixed(4)}`);
132
+ console.log(` Minimum Longitude (lambda_min): ${lambdaMinRad.toFixed(4)}`);
133
+ console.log(` Maximum Longitude (lambda_max): ${lambdaMaxRad.toFixed(4)}`);
138
134
  console.log("-".repeat(20));
139
135
  console.log("Bounding Box (Degrees):");
140
- console.log(" Minimum Latitude: ".concat(phiMinDeg.toFixed(2), "\u00B0"));
141
- console.log(" Maximum Latitude: ".concat(phiMaxDeg.toFixed(2), "\u00B0"));
142
- console.log(" Minimum Longitude: ".concat(lambdaMinDeg.toFixed(2), "\u00B0"));
143
- console.log(" Maximum Longitude: ".concat(lambdaMaxDeg.toFixed(2), "\u00B0"));
136
+ console.log(` Minimum Latitude: ${phiMinDeg.toFixed(2)}°`);
137
+ console.log(` Maximum Latitude: ${phiMaxDeg.toFixed(2)}°`);
138
+ console.log(` Minimum Longitude: ${lambdaMinDeg.toFixed(2)}°`);
139
+ console.log(` Maximum Longitude: ${lambdaMaxDeg.toFixed(2)}°`);
144
140
  // --- Antimeridian Crossing Test ---
145
141
  console.log("\n" + "=".repeat(30));
146
142
  console.log("Antimeridian Crossing Test");
147
- var lat1DegAm = -18, lon1DegAm = 178;
148
- var lat2DegAm = -14, lon2DegAm = -172;
149
- var phi1Am = degreesToRadians(lat1DegAm);
150
- var lambda1Am = degreesToRadians(lon1DegAm);
151
- var phi2Am = degreesToRadians(lat2DegAm);
152
- var lambda2Am = degreesToRadians(lon2DegAm);
153
- var _b = getGreatCircleArcBBox(phi1Am, lambda1Am, phi2Am, lambda2Am), phiMinRadAm = _b[0], phiMaxRadAm = _b[1], lambdaMinRadAm = _b[2], lambdaMaxRadAm = _b[3];
154
- var phiMinDegAm = radiansToDegrees(phiMinRadAm);
155
- var phiMaxDegAm = radiansToDegrees(phiMaxRadAm);
156
- var lambdaMinDegAm = radiansToDegrees(lambdaMinRadAm);
157
- var lambdaMaxDegAm = radiansToDegrees(lambdaMaxRadAm);
158
- console.log("Input Points (Degrees): P1=(".concat(lat1DegAm, ", ").concat(lon1DegAm, "), P2=(").concat(lat2DegAm, ", ").concat(lon2DegAm, ")"));
143
+ const lat1DegAm = -18, lon1DegAm = 178;
144
+ const lat2DegAm = -14, lon2DegAm = -172;
145
+ const phi1Am = degreesToRadians(lat1DegAm);
146
+ const lambda1Am = degreesToRadians(lon1DegAm);
147
+ const phi2Am = degreesToRadians(lat2DegAm);
148
+ const lambda2Am = degreesToRadians(lon2DegAm);
149
+ const [phiMinRadAm, phiMaxRadAm, lambdaMinRadAm, lambdaMaxRadAm] = getGreatCircleArcBBox(phi1Am, lambda1Am, phi2Am, lambda2Am);
150
+ const phiMinDegAm = radiansToDegrees(phiMinRadAm);
151
+ const phiMaxDegAm = radiansToDegrees(phiMaxRadAm);
152
+ const lambdaMinDegAm = radiansToDegrees(lambdaMinRadAm);
153
+ const lambdaMaxDegAm = radiansToDegrees(lambdaMaxRadAm);
154
+ console.log(`Input Points (Degrees): P1=(${lat1DegAm}, ${lon1DegAm}), P2=(${lat2DegAm}, ${lon2DegAm})`);
159
155
  console.log("Bounding Box (Radians):");
160
- console.log(" phi_min=".concat(phiMinRadAm.toFixed(4), ", phi_max=").concat(phiMaxRadAm.toFixed(4)));
161
- console.log(" lambda_min=".concat(lambdaMinRadAm.toFixed(4), ", lambda_max=").concat(lambdaMaxRadAm.toFixed(4)));
156
+ console.log(` phi_min=${phiMinRadAm.toFixed(4)}, phi_max=${phiMaxRadAm.toFixed(4)}`);
157
+ console.log(` lambda_min=${lambdaMinRadAm.toFixed(4)}, lambda_max=${lambdaMaxRadAm.toFixed(4)}`);
162
158
  console.log("Bounding Box (Degrees):");
163
- console.log(" Min Latitude: ".concat(phiMinDegAm.toFixed(2), "\u00B0"));
164
- console.log(" Max Latitude: ".concat(phiMaxDegAm.toFixed(2), "\u00B0"));
165
- console.log(" Min Longitude: ".concat(lambdaMinDegAm.toFixed(2), "\u00B0 (178\u00B0 expected)"));
166
- console.log(" Max Longitude: ".concat(lambdaMaxDegAm.toFixed(2), "\u00B0 (188\u00B0 expected, which is -172\u00B0 + 360\u00B0)"));
159
+ console.log(` Min Latitude: ${phiMinDegAm.toFixed(2)}°`);
160
+ console.log(` Max Latitude: ${phiMaxDegAm.toFixed(2)}°`);
161
+ console.log(` Min Longitude: ${lambdaMinDegAm.toFixed(2) (178° expected)`);
162
+ console.log(` Max Longitude: ${lambdaMaxDegAm.toFixed(2) (188° expected, which is -172° + 360°)`);
167
163
  // --- Polar Crossing Test ---
168
164
  console.log("\n" + "=".repeat(30));
169
165
  console.log("Polar Crossing Test");
170
- var lat1DegP = 80, lon1DegP = 20;
171
- var lat2DegP = 80, lon2DegP = -100;
172
- var phi1P = degreesToRadians(lat1DegP);
173
- var lambda1P = degreesToRadians(lon1DegP);
174
- var phi2P = degreesToRadians(lat2DegP);
175
- var lambda2P = degreesToRadians(lon2DegP);
176
- var _c = getGreatCircleArcBBox(phi1P, lambda1P, phi2P, lambda2P), phiMinRadP = _c[0], phiMaxRadP = _c[1], lambdaMinRadP = _c[2], lambdaMaxRadP = _c[3];
177
- var phiMinDegP = radiansToDegrees(phiMinRadP);
178
- var phiMaxDegP = radiansToDegrees(phiMaxRadP);
179
- var lambdaMinDegP = radiansToDegrees(lambdaMinRadP);
180
- var lambdaMaxDegP = radiansToDegrees(lambdaMaxRadP);
181
- console.log("Input Points (Degrees): P1=(".concat(lat1DegP, ", ").concat(lon1DegP, "), P2=(").concat(lat2DegP, ", ").concat(lon2DegP, ")"));
166
+ const lat1DegP = 80, lon1DegP = 20;
167
+ const lat2DegP = 80, lon2DegP = -100;
168
+ const phi1P = degreesToRadians(lat1DegP);
169
+ const lambda1P = degreesToRadians(lon1DegP);
170
+ const phi2P = degreesToRadians(lat2DegP);
171
+ const lambda2P = degreesToRadians(lon2DegP);
172
+ const [phiMinRadP, phiMaxRadP, lambdaMinRadP, lambdaMaxRadP] = getGreatCircleArcBBox(phi1P, lambda1P, phi2P, lambda2P);
173
+ const phiMinDegP = radiansToDegrees(phiMinRadP);
174
+ const phiMaxDegP = radiansToDegrees(phiMaxRadP);
175
+ const lambdaMinDegP = radiansToDegrees(lambdaMinRadP);
176
+ const lambdaMaxDegP = radiansToDegrees(lambdaMaxRadP);
177
+ console.log(`Input Points (Degrees): P1=(${lat1DegP}, ${lon1DegP}), P2=(${lat2DegP}, ${lon2DegP})`);
182
178
  console.log("Bounding Box (Radians):");
183
- console.log(" phi_min=".concat(phiMinRadP.toFixed(4), ", phi_max=").concat(phiMaxRadP.toFixed(4)));
184
- console.log(" lambda_min=".concat(lambdaMinRadP.toFixed(4), ", lambda_max=").concat(lambdaMaxRadP.toFixed(4)));
179
+ console.log(` phi_min=${phiMinRadP.toFixed(4)}, phi_max=${phiMaxRadP.toFixed(4)}`);
180
+ console.log(` lambda_min=${lambdaMinRadP.toFixed(4)}, lambda_max=${lambdaMaxRadP.toFixed(4)}`);
185
181
  console.log("Bounding Box (Degrees):");
186
- console.log(" Min Latitude: ".concat(phiMinDegP.toFixed(2), "\u00B0"));
187
- console.log(" Max Latitude: ".concat(phiMaxDegP.toFixed(2), "\u00B0 (Should be close to North Pole > 80\u00B0)"));
188
- console.log(" Min Longitude: ".concat(lambdaMinDegP.toFixed(2), "\u00B0"));
189
- console.log(" Max Longitude: ".concat(lambdaMaxDegP.toFixed(2), "\u00B0"));
182
+ console.log(` Min Latitude: ${phiMinDegP.toFixed(2)}°`);
183
+ console.log(` Max Latitude: ${phiMaxDegP.toFixed(2) (Should be close to North Pole > 80°)`);
184
+ console.log(` Min Longitude: ${lambdaMinDegP.toFixed(2)}°`);
185
+ console.log(` Max Longitude: ${lambdaMaxDegP.toFixed(2)}°`);
190
186
  // --- line points intersection with bbox ---
package/Math/constants.js CHANGED
@@ -1,9 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EPSILON = exports.WORLD_RADIUS_MERCATOR = exports.WORLD_RADIUS_3D = void 0;
4
- var WORLD_RADIUS_3D = 6378.137;
5
- exports.WORLD_RADIUS_3D = WORLD_RADIUS_3D;
6
- var WORLD_RADIUS_MERCATOR = 6378136.99911;
7
- exports.WORLD_RADIUS_MERCATOR = WORLD_RADIUS_MERCATOR;
8
- var EPSILON = 1e-10; // Used for floating point comparisons
9
- exports.EPSILON = EPSILON;
1
+ const WORLD_RADIUS_3D = 6378.137;
2
+ const WORLD_RADIUS_MERCATOR = 6378136.99911;
3
+ const EPSILON = 1e-10; // Used for floating point comparisons
4
+ export { WORLD_RADIUS_3D, WORLD_RADIUS_MERCATOR, EPSILON };
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.arcSlice = arcSlice;
4
- var constants_1 = require("../constants");
5
- var vec3_1 = require("../vec3");
6
- var line_1 = require("../line");
7
- var plane_1 = require("../plane");
8
- var arc_1 = require("../arc");
9
- var plane_plane_1 = require("./plane-plane");
10
- var line_sphere_1 = require("./line-sphere");
11
- var _intersectionLine = /*@__PURE__*/ line_1.line.create();
12
- var _originPlane = /*@__PURE__*/ plane_1.plane.create();
1
+ import { EPSILON } from "../constants";
2
+ import { vec3 } from "../vec3";
3
+ import { line } from "../line";
4
+ import { plane } from "../plane";
5
+ import { arc } from "../arc";
6
+ import { planePlaneJuction } from "./plane-plane";
7
+ import { lineSphereIntersection } from "./line-sphere";
8
+ const _intersectionLine = /*@__PURE__*/ line.create();
9
+ const _originPlane = /*@__PURE__*/ plane.create();
13
10
  _originPlane.distance = 0;
14
- var _originSphere = /*@__PURE__*/ { center: vec3_1.vec3.create(0, 0, 0), radius: 1 };
15
- var _intersectionPoints = /*@__PURE__*/ [vec3_1.vec3.create(), vec3_1.vec3.create()];
11
+ const _originSphere = /*@__PURE__*/ { center: vec3.create(0, 0, 0), radius: 1 };
12
+ const _intersectionPoints = /*@__PURE__*/ [vec3.create(), vec3.create()];
16
13
  // TODO: out must be [Arc, Arc] there is a case where split into three arcs, visible by points or arcs but middle is not visible
17
14
  /**
18
15
  *
@@ -21,24 +18,24 @@ var _intersectionPoints = /*@__PURE__*/ [vec3_1.vec3.create(), vec3_1.vec3.creat
21
18
  * @param juctionPlane
22
19
  * @returns number of arcs segments in the junction divided by the junction plane.
23
20
  */
24
- function arcSlice(out, inArc, juctionPlane) {
21
+ export function arcSlice(out, inArc, juctionPlane) {
25
22
  // arc coverPlane and junctionPlane intersection exist in the range of unit sphere
26
- var coverRadiusAngle = plane_1.plane.getUnitSphereRadiusAngle(inArc.coverPlane);
27
- var visibleRadiusAngle = plane_1.plane.getUnitSphereRadiusAngle(juctionPlane);
23
+ const coverRadiusAngle = plane.getUnitSphereRadiusAngle(inArc.coverPlane);
24
+ const visibleRadiusAngle = plane.getUnitSphereRadiusAngle(juctionPlane);
28
25
  // TODO: RESEARCH efficient approach --
29
- var angleBetween_Cover_Visible = Math.acos(vec3_1.vec3.dot(inArc.coverPlane.normal, juctionPlane.normal));
30
- if (coverRadiusAngle + visibleRadiusAngle < angleBetween_Cover_Visible - constants_1.EPSILON) { // case A: out of range
26
+ const angleBetween_Cover_Visible = Math.acos(vec3.dot(inArc.coverPlane.normal, juctionPlane.normal));
27
+ if (coverRadiusAngle + visibleRadiusAngle < angleBetween_Cover_Visible - EPSILON) { // case A: out of range
31
28
  return 0; // No intersection
32
29
  }
33
30
  // ------------------------------------
34
31
  // the case when the arc is completely covered by the juction plane
35
- if (visibleRadiusAngle + constants_1.EPSILON >= angleBetween_Cover_Visible + coverRadiusAngle) { // case B: fully visible
36
- arc_1.arc.copy(out[0], inArc);
32
+ if (visibleRadiusAngle + EPSILON >= angleBetween_Cover_Visible + coverRadiusAngle) { // case B: fully visible
33
+ arc.copy(out[0], inArc);
37
34
  return 1;
38
35
  }
39
36
  // plane-plane intersection line should be calculated for the rest of the calculations
40
- vec3_1.vec3.copy(_originPlane.normal, inArc.normal);
41
- var isPlaneJunctions = (0, plane_plane_1.planePlaneJuction)(_intersectionLine, _originPlane, juctionPlane);
37
+ vec3.copy(_originPlane.normal, inArc.normal);
38
+ const isPlaneJunctions = planePlaneJuction(_intersectionLine, _originPlane, juctionPlane);
42
39
  if (!isPlaneJunctions) { // case C: planes are parallel.
43
40
  // case A covers opposite directions
44
41
  // case B Covers they face each other
@@ -46,38 +43,38 @@ function arcSlice(out, inArc, juctionPlane) {
46
43
  }
47
44
  // --- read until here ---
48
45
  // calculate the intersection points
49
- var isSphereIntersection = (0, line_sphere_1.lineSphereIntersection)(_intersectionPoints, _intersectionLine, _originSphere);
46
+ const isSphereIntersection = lineSphereIntersection(_intersectionPoints, _intersectionLine, _originSphere);
50
47
  if (!isSphereIntersection) {
51
48
  // other edge caes should be covered by now
52
49
  return 0; // No intersection
53
50
  }
54
- var i0IsCovered = plane_1.plane.distanceToPoint(inArc.coverPlane, _intersectionPoints[0]) > -constants_1.EPSILON;
55
- var i1IsCovered = plane_1.plane.distanceToPoint(inArc.coverPlane, _intersectionPoints[1]) > -constants_1.EPSILON;
56
- var p0IsVisible = plane_1.plane.distanceToPoint(juctionPlane, inArc.p0) > -constants_1.EPSILON;
57
- var p1IsVisible = plane_1.plane.distanceToPoint(juctionPlane, inArc.p1) > -constants_1.EPSILON;
51
+ const i0IsCovered = plane.distanceToPoint(inArc.coverPlane, _intersectionPoints[0]) > -EPSILON;
52
+ const i1IsCovered = plane.distanceToPoint(inArc.coverPlane, _intersectionPoints[1]) > -EPSILON;
53
+ const p0IsVisible = plane.distanceToPoint(juctionPlane, inArc.p0) > -EPSILON;
54
+ const p1IsVisible = plane.distanceToPoint(juctionPlane, inArc.p1) > -EPSILON;
58
55
  if (!p0IsVisible && !p1IsVisible && !i0IsCovered && !i1IsCovered) {
59
56
  return 0; // No intersection
60
57
  }
61
58
  if (i0IsCovered && i1IsCovered && p0IsVisible && p1IsVisible) {
62
59
  // calculate which points are closer
63
- var p0i0DistanceSquared = vec3_1.vec3.distanceSquared(inArc.p0, _intersectionPoints[0]);
64
- var p0i1DistanceSquared = vec3_1.vec3.distanceSquared(inArc.p0, _intersectionPoints[1]);
65
- var case0 = p0i0DistanceSquared < p0i1DistanceSquared;
66
- arc_1.arc.set(out[0], inArc.p0, case0 ? _intersectionPoints[0] : _intersectionPoints[1]);
67
- arc_1.arc.set(out[1], inArc.p1, !case0 ? _intersectionPoints[0] : _intersectionPoints[1]);
60
+ const p0i0DistanceSquared = vec3.distanceSquared(inArc.p0, _intersectionPoints[0]);
61
+ const p0i1DistanceSquared = vec3.distanceSquared(inArc.p0, _intersectionPoints[1]);
62
+ const case0 = p0i0DistanceSquared < p0i1DistanceSquared;
63
+ arc.set(out[0], inArc.p0, case0 ? _intersectionPoints[0] : _intersectionPoints[1]);
64
+ arc.set(out[1], inArc.p1, !case0 ? _intersectionPoints[0] : _intersectionPoints[1]);
68
65
  return 2;
69
66
  }
70
67
  if (i0IsCovered && i1IsCovered) {
71
- arc_1.arc.set(out[0], _intersectionPoints[0], _intersectionPoints[1]);
68
+ arc.set(out[0], _intersectionPoints[0], _intersectionPoints[1]);
72
69
  return 1;
73
70
  }
74
71
  if (p0IsVisible && p1IsVisible) {
75
- arc_1.arc.copy(out[0], inArc);
72
+ arc.copy(out[0], inArc);
76
73
  return 1;
77
74
  }
78
75
  if ((p0IsVisible || p1IsVisible) !== (i0IsCovered || i1IsCovered)) {
79
76
  throw new Error("Unexpected case: one covered and one visible point must be present");
80
77
  }
81
- arc_1.arc.set(out[0], p0IsVisible ? inArc.p0 : inArc.p1, i0IsCovered ? _intersectionPoints[0] : _intersectionPoints[1]);
78
+ arc.set(out[0], p0IsVisible ? inArc.p0 : inArc.p1, i0IsCovered ? _intersectionPoints[0] : _intersectionPoints[1]);
82
79
  return 1;
83
80
  }
@@ -1,25 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lineSphereIntersection = lineSphereIntersection;
4
- var vec3_1 = require("../vec3");
5
- var line_1 = require("../line");
6
- var _0vector = /*@__PURE__*/ vec3_1.vec3.create(0, 0, 0);
7
- function lineSphereIntersection(out, inLine, inSphere) {
8
- vec3_1.vec3.subtract(_0vector, inLine.origin, inSphere.center);
9
- var distanceSquared = vec3_1.vec3.lengthSquared(_0vector);
10
- var radiusSquared = inSphere.radius * inSphere.radius;
11
- var dot = vec3_1.vec3.dot(_0vector, inLine.direction);
12
- var dotSquared = dot * dot;
13
- var _a = dotSquared + radiusSquared - distanceSquared;
1
+ import { vec3 } from "../vec3";
2
+ import { line } from "../line";
3
+ const _0vector = /*@__PURE__*/ vec3.create(0, 0, 0);
4
+ export function lineSphereIntersection(out, inLine, inSphere) {
5
+ vec3.subtract(_0vector, inLine.origin, inSphere.center);
6
+ const distanceSquared = vec3.lengthSquared(_0vector);
7
+ const radiusSquared = inSphere.radius * inSphere.radius;
8
+ const dot = vec3.dot(_0vector, inLine.direction);
9
+ const dotSquared = dot * dot;
10
+ const _a = dotSquared + radiusSquared - distanceSquared;
14
11
  if (_a < 0) {
15
12
  return false; // no intersection
16
13
  }
17
14
  else {
18
- var a = Math.sqrt(_a);
19
- var t1 = dot - a;
20
- var t2 = dot + a;
21
- line_1.line.at(out[0], inLine, t1);
22
- line_1.line.at(out[1], inLine, t2);
15
+ const a = Math.sqrt(_a);
16
+ const t1 = dot - a;
17
+ const t2 = dot + a;
18
+ line.at(out[0], inLine, t1);
19
+ line.at(out[1], inLine, t2);
23
20
  return true;
24
21
  }
25
22
  }
@@ -1,34 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.planePlaneJuction = planePlaneJuction;
4
- var constants_1 = require("../constants");
5
- var vec3_1 = require("../vec3");
6
- var _normal1 = vec3_1.vec3.create();
7
- var _normal2 = vec3_1.vec3.create();
8
- function planePlaneJuction(out, plane1, plane2) {
9
- vec3_1.vec3.copy(_normal1, plane1.normal);
10
- vec3_1.vec3.copy(_normal2, plane2.normal);
11
- var distance1 = plane1.distance;
12
- var distance2 = plane2.distance;
13
- var origin = out.origin, direction = out.direction;
14
- var dot = vec3_1.vec3.dot(_normal1, _normal2);
15
- if (Math.abs(dot) > 1 - constants_1.EPSILON) {
1
+ import { EPSILON } from "../constants";
2
+ import { vec3 } from "../vec3";
3
+ const _normal1 = vec3.create();
4
+ const _normal2 = vec3.create();
5
+ export function planePlaneJuction(out, plane1, plane2) {
6
+ vec3.copy(_normal1, plane1.normal);
7
+ vec3.copy(_normal2, plane2.normal);
8
+ const distance1 = plane1.distance;
9
+ const distance2 = plane2.distance;
10
+ const { origin, direction } = out;
11
+ const dot = vec3.dot(_normal1, _normal2);
12
+ if (Math.abs(dot) > 1 - EPSILON) {
16
13
  return false; // Planes are parallel, no intersection
17
14
  }
18
- vec3_1.vec3.cross(direction, _normal1, _normal2);
19
- var magnitudeSquired = vec3_1.vec3.lengthSquared(out.direction);
20
- if (magnitudeSquired < constants_1.EPSILON) {
15
+ vec3.cross(direction, _normal1, _normal2);
16
+ const magnitudeSquired = vec3.lengthSquared(out.direction);
17
+ if (magnitudeSquired < EPSILON) {
21
18
  return false; // No valid intersection line
22
19
  }
23
- var magnitude = Math.sqrt(magnitudeSquired);
20
+ const magnitude = Math.sqrt(magnitudeSquired);
24
21
  direction[0] /= magnitude;
25
22
  direction[1] /= magnitude;
26
23
  direction[2] /= magnitude;
27
- var determinant;
24
+ let determinant;
28
25
  // Calculate the intersection point
29
26
  // set z = 0
30
27
  determinant = _normal1[0] * _normal2[1] - _normal1[1] * _normal2[0];
31
- if (Math.abs(determinant) > constants_1.EPSILON) {
28
+ if (Math.abs(determinant) > EPSILON) {
32
29
  origin[0] = (distance1 * _normal2[1] - distance2 * _normal1[1]) / determinant;
33
30
  origin[1] = (distance2 * _normal1[0] - distance1 * _normal2[0]) / determinant;
34
31
  origin[2] = 0;
@@ -36,7 +33,7 @@ function planePlaneJuction(out, plane1, plane2) {
36
33
  else {
37
34
  // set y = 0
38
35
  determinant = _normal1[0] * _normal2[2] - _normal1[2] * _normal2[0];
39
- if (Math.abs(determinant) > constants_1.EPSILON) {
36
+ if (Math.abs(determinant) > EPSILON) {
40
37
  origin[0] = (distance1 * _normal2[2] - distance2 * _normal1[2]) / determinant;
41
38
  origin[1] = 0;
42
39
  origin[2] = (distance2 * _normal1[0] - distance1 * _normal2[0]) / determinant;
@@ -44,7 +41,7 @@ function planePlaneJuction(out, plane1, plane2) {
44
41
  else {
45
42
  // set x = 0
46
43
  determinant = _normal1[1] * _normal2[2] - _normal1[2] * _normal2[1];
47
- if (Math.abs(determinant) > constants_1.EPSILON) {
44
+ if (Math.abs(determinant) > EPSILON) {
48
45
  origin[0] = 0;
49
46
  origin[1] = (distance1 * _normal2[2] - distance2 * _normal1[2]) / determinant;
50
47
  origin[2] = (distance2 * _normal1[1] - distance1 * _normal2[1]) / determinant;