@pirireis/webglobeplugins 0.8.19 → 0.8.20

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.
package/Math/arc.ts CHANGED
@@ -79,8 +79,6 @@ export class Arc {
79
79
 
80
80
 
81
81
 
82
-
83
- // TODO: EDGE CASE: the points are on same location
84
82
  intersectionMedium(medium: Plane, target: Arc | null = null): Arc | null {
85
83
  // Orianted in right hand rule
86
84
  if (this.pointA.equals(this.pointB)) return null; // arc is too short
@@ -97,6 +95,10 @@ export class Arc {
97
95
  return null; // no intersection
98
96
  }
99
97
 
98
+ // think as this.pointA is on y=1 on a x-y space. this.pointB is on the x>0 part of the space.
99
+ // any point on x<0 is outside. Any point y<this._dot is outside.
100
+
101
+ // A is before B with right hand rule
100
102
  const [A, B] = (() => {
101
103
  Vector3D.crossVectors(...intersectionPoints, _AxB);
102
104
  if (_AxB.dot(this._AxB) >= 0) {
@@ -109,8 +111,7 @@ export class Arc {
109
111
 
110
112
  Vector3D.crossVectors(this.pointA, A, _A_x_otherA);
111
113
  Vector3D.crossVectors(this.pointA, B, _A_x_otherB);
112
- // think as this.pointA is on y=1 on a x-y space. this.pointB is on the x>0 part of the space.
113
- // any point on x<0 is outside. Any point y<this._dot is outside.
114
+
114
115
  const _yA = this.pointA.dot(A);
115
116
  const _yB = this.pointA.dot(B);
116
117
 
@@ -119,6 +120,9 @@ export class Arc {
119
120
 
120
121
 
121
122
  if (_xA < 0 && _xB < 0) {
123
+ if (_yA > _yB) {
124
+ throw new Error("A is before B with right hand rule but A is on the left side of the arc. This should not happen.");
125
+ }
122
126
  return null; // no intersection
123
127
  }
124
128
  if (_yA < this._dot && _yB < this._dot) {
@@ -131,8 +135,10 @@ export class Arc {
131
135
  ];
132
136
  if (target === null) {
133
137
  target = new Arc(...resultPoints);
134
- } else {
138
+ } else if (target instanceof Arc) {
135
139
  target.setFromUnitVectors(...resultPoints);
140
+ } else {
141
+ throw new Error("target is not null or an Arc instance");
136
142
  }
137
143
 
138
144
  return target;
package/Math/vector3d.ts CHANGED
@@ -224,7 +224,9 @@ export class Vector3D implements IVector3D {
224
224
  }
225
225
 
226
226
 
227
+
227
228
  static fromLonLatRadians(lon: Radians, lat: Radians): Vector3D {
228
229
  return new Vector3D().setFromLonLat(lon, lat);
229
230
  }
231
+
230
232
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pirireis/webglobeplugins",
3
- "version": "0.8.19",
3
+ "version": "0.8.20",
4
4
  "main": "index.js",
5
5
  "author": "Toprak Nihat Deniz Ozturk",
6
6
  "license": "MIT"
@@ -47,6 +47,28 @@ test("intersectionMedium 2 - single point arc", () => {
47
47
  });
48
48
 
49
49
 
50
+ describe(`intersectionMedium 3 - return full arc`, () => {
51
+
52
+ for (let i = 0; i < 100; i++) {
53
+ test(`intersectionMedium 3 - return full arc ${i} `, () => {
54
+ _medium.set(new Vector3D(0, 0, 1), 0.001);
55
+ _0vector.randomUnit();
56
+ _0vector.z = Math.abs(_0vector.z);
57
+ _1vector.randomUnit();
58
+ _1vector.z = Math.abs(_1vector.z);
59
+ _0arc.setFromUnitVectors(_0vector, _1vector);
60
+
61
+ const _1arc = _0arc.intersectionMedium(_medium)!;
62
+ if (_1arc === null) {
63
+ console.log(_0arc, _medium);
64
+ }
65
+ expect(_1arc !== null).toBeTruthy();
66
+ expect(_0arc.equals(_1arc)).toBeTruthy();
67
+ });
68
+ }
69
+ });
70
+
71
+
50
72
  test(" populatePoints3D", () => {
51
73
 
52
74
  });