dgeoutils 2.4.41 → 2.4.44

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 (52) hide show
  1. package/package.json +1 -4
  2. package/dist/cjs/DCircle.d.ts +0 -18
  3. package/dist/cjs/DCircle.js +0 -102
  4. package/dist/cjs/DLine.d.ts +0 -39
  5. package/dist/cjs/DLine.js +0 -343
  6. package/dist/cjs/DNumbers.d.ts +0 -8
  7. package/dist/cjs/DNumbers.js +0 -30
  8. package/dist/cjs/DPlane.d.ts +0 -25
  9. package/dist/cjs/DPlane.js +0 -132
  10. package/dist/cjs/DPoint.d.ts +0 -138
  11. package/dist/cjs/DPoint.js +0 -803
  12. package/dist/cjs/DPolygon.d.ts +0 -137
  13. package/dist/cjs/DPolygon.js +0 -1745
  14. package/dist/cjs/DPolygonLoop.d.ts +0 -60
  15. package/dist/cjs/DPolygonLoop.js +0 -439
  16. package/dist/cjs/FastSearch.d.ts +0 -6
  17. package/dist/cjs/FastSearch.js +0 -53
  18. package/dist/cjs/InterpolationMatrix.d.ts +0 -24
  19. package/dist/cjs/InterpolationMatrix.js +0 -173
  20. package/dist/cjs/TraceMatrix.d.ts +0 -22
  21. package/dist/cjs/TraceMatrix.js +0 -285
  22. package/dist/cjs/index.d.ts +0 -11
  23. package/dist/cjs/index.js +0 -37
  24. package/dist/cjs/utils.d.ts +0 -49
  25. package/dist/cjs/utils.js +0 -280
  26. package/dist/es2015/DCircle.js +0 -87
  27. package/dist/es2015/DLine.js +0 -290
  28. package/dist/es2015/DNumbers.js +0 -22
  29. package/dist/es2015/DPlane.js +0 -105
  30. package/dist/es2015/DPoint.js +0 -676
  31. package/dist/es2015/DPolygon.js +0 -1193
  32. package/dist/es2015/DPolygonLoop.js +0 -430
  33. package/dist/es2015/FastSearch.js +0 -25
  34. package/dist/es2015/InterpolationMatrix.js +0 -128
  35. package/dist/es2015/TraceMatrix.js +0 -229
  36. package/dist/es2015/index.js +0 -11
  37. package/dist/es2015/utils.js +0 -207
  38. package/dist/esm/DCircle.js +0 -99
  39. package/dist/esm/DLine.js +0 -340
  40. package/dist/esm/DNumbers.js +0 -27
  41. package/dist/esm/DPlane.js +0 -129
  42. package/dist/esm/DPoint.js +0 -800
  43. package/dist/esm/DPolygon.js +0 -1742
  44. package/dist/esm/DPolygonLoop.js +0 -436
  45. package/dist/esm/FastSearch.js +0 -50
  46. package/dist/esm/InterpolationMatrix.js +0 -170
  47. package/dist/esm/TraceMatrix.js +0 -282
  48. package/dist/esm/index.js +0 -11
  49. package/dist/esm/utils.js +0 -265
  50. package/dist/umd/dgeoutils.js +0 -4347
  51. package/dist/umd/dgeoutils.min.js +0 -1
  52. package/dist/umd/dgeoutils.min.js.map +0 -1
package/dist/esm/DLine.js DELETED
@@ -1,340 +0,0 @@
1
- import { DPoint } from './DPoint';
2
- import { checkFunction } from './utils';
3
- import { DNumbers } from './DNumbers';
4
- import { DPolygon } from './DPolygon';
5
- var DLine = (function () {
6
- function DLine(a, b, c, begin, end) {
7
- if (begin === void 0) { begin = DPoint.zero(); }
8
- if (end === void 0) { end = DPoint.zero(); }
9
- this.a = a;
10
- this.b = b;
11
- this.c = c;
12
- this.begin = begin;
13
- this.end = end;
14
- }
15
- DLine.prototype.clone = function () {
16
- return new DLine(this.a, this.b, this.c, this.begin.clone(), this.end.clone());
17
- };
18
- DLine.prototype.findPerpendicular = function (p) {
19
- checkFunction('findPerpendicular')
20
- .checkArgument('this.begin')
21
- .shouldBeMeters(this.begin)
22
- .checkArgument('this.end')
23
- .shouldBeMeters(this.end)
24
- .checkArgument('p')
25
- .shouldBeMeters(p);
26
- return new DLine(-this.b, this.a, this.b * p.x - this.a * p.y);
27
- };
28
- DLine.prototype.perpendicularDistance = function (p) {
29
- checkFunction('perpendicularDistance')
30
- .checkArgument('this.begin')
31
- .shouldBeMeters(this.begin)
32
- .checkArgument('this.end')
33
- .shouldBeMeters(this.end)
34
- .checkArgument('p')
35
- .shouldBeMeters(p);
36
- var perpendicularLine = this.findPerpendicular(p);
37
- var targetPoint = perpendicularLine.findPoint(this);
38
- return targetPoint.distance(p);
39
- };
40
- DLine.prototype.intersection = function (l, d, includeOnly) {
41
- if (d === void 0) { d = 0; }
42
- if (includeOnly === void 0) { includeOnly = false; }
43
- var p = this.findPoint(l);
44
- if (p) {
45
- if (includeOnly) {
46
- return this.insideRange(p, d) && l.insideRange(p, d) ? p : null;
47
- }
48
- return this.inRange(p, d) && l.inRange(p, d) ? p : null;
49
- }
50
- return null;
51
- };
52
- DLine.prototype.intersectionWithCircle = function (circle) {
53
- var center = circle.center, r = circle.r;
54
- var per = this.findPerpendicular(center);
55
- var t = this.findPoint(per);
56
- var distance = t.distance(center);
57
- if (this.begin.equal(center)) {
58
- distance = 0;
59
- }
60
- if (this.end.equal(center)) {
61
- distance = 0;
62
- }
63
- if (distance < r) {
64
- var _a = this, a = _a.a, b = _a.b, c = _a.c;
65
- if (this.isParallel) {
66
- var ct = center.distance(t);
67
- var move = Math.sqrt(r * r - ct * ct);
68
- if (this.isParallelY) {
69
- t.x = this.begin.x;
70
- var r1_1 = t.clone().move(0, -move);
71
- var r2_1 = t.clone().move(0, move);
72
- return [r1_1, r2_1];
73
- }
74
- if (this.isParallelX) {
75
- t.y = this.begin.y;
76
- var r1_2 = t.clone().move(move, 0);
77
- var r2_2 = t.clone().move(-move, 0);
78
- return [r1_2, r2_2];
79
- }
80
- }
81
- if (this.begin.like(center)) {
82
- var p = this.begin.clone();
83
- return [this.movePoint(p, r), this.movePoint(p, -r)];
84
- }
85
- if (this.end.like(center)) {
86
- var p = this.end.clone();
87
- return [this.movePoint(p, r), this.movePoint(p, -r)];
88
- }
89
- var s = a * a + b * b;
90
- var d = r * r - c * c / s;
91
- var mult = Math.sqrt(d / s);
92
- var r1 = t.clone().move(b * mult, -a * mult);
93
- var r2 = t.clone().move(-b * mult, a * mult);
94
- return [r1, r2];
95
- }
96
- if (distance === r) {
97
- return t;
98
- }
99
- return null;
100
- };
101
- DLine.prototype.inRange = function (p, d) {
102
- if (d === void 0) { d = 0; }
103
- var _a = this, minX = _a.minX, minY = _a.minY, maxX = _a.maxX, maxY = _a.maxY;
104
- var x = p.x, y = p.y;
105
- var isInX = x >= minX - d && x <= maxX + d;
106
- var isInY = y >= minY - d && y <= maxY + d;
107
- return isInX && isInY;
108
- };
109
- DLine.prototype.insideRange = function (p, d) {
110
- if (d === void 0) { d = 0; }
111
- var _a = this, begin = _a.begin, end = _a.end;
112
- return this.inRange(p, d) && !begin.like(p, 0.00001) && !end.like(p, 0.00001);
113
- };
114
- Object.defineProperty(DLine.prototype, "center", {
115
- get: function () {
116
- return this.begin
117
- .clone()
118
- .setIfLessThan(this.end)
119
- .move(this.end
120
- .clone()
121
- .move(this.begin
122
- .clone()
123
- .minus())
124
- .abs()
125
- .minus()
126
- .divide(2));
127
- },
128
- enumerable: false,
129
- configurable: true
130
- });
131
- Object.defineProperty(DLine.prototype, "minX", {
132
- get: function () {
133
- return Math.min(this.begin.x, this.end.x);
134
- },
135
- enumerable: false,
136
- configurable: true
137
- });
138
- Object.defineProperty(DLine.prototype, "minY", {
139
- get: function () {
140
- return Math.min(this.begin.y, this.end.y);
141
- },
142
- enumerable: false,
143
- configurable: true
144
- });
145
- Object.defineProperty(DLine.prototype, "maxX", {
146
- get: function () {
147
- return Math.max(this.begin.x, this.end.x);
148
- },
149
- enumerable: false,
150
- configurable: true
151
- });
152
- Object.defineProperty(DLine.prototype, "maxY", {
153
- get: function () {
154
- return Math.max(this.begin.y, this.end.y);
155
- },
156
- enumerable: false,
157
- configurable: true
158
- });
159
- DLine.prototype.toString = function () {
160
- return "(".concat(this.a, ", ").concat(this.b, ", ").concat(this.c, ")");
161
- };
162
- DLine.prototype.getValue = function () {
163
- return [this.a, this.b, this.c];
164
- };
165
- DLine.prototype.x = function (p) {
166
- if (this.isParallelY) {
167
- return new DPoint(-this.c / this.a, p.y);
168
- }
169
- if (this.isParallelX) {
170
- return new DPoint(p.x, -this.c / this.b);
171
- }
172
- return new DPoint(-this.b / this.a * p.y - this.c / this.a, p.y);
173
- };
174
- DLine.prototype.y = function (p) {
175
- if (this.isParallelY) {
176
- return new DPoint(-this.c / this.a, p.y);
177
- }
178
- if (this.isParallelX) {
179
- return new DPoint(p.x, -this.c / this.b);
180
- }
181
- return new DPoint(p.x, -this.a / this.b * p.x - this.c / this.b);
182
- };
183
- DLine.prototype.findPoint = function (l) {
184
- if (this.isParallelY && l.isParallelY) {
185
- return null;
186
- }
187
- if (this.isParallelX && l.isParallelX) {
188
- return null;
189
- }
190
- if (this.isParallelX && l.isParallelY) {
191
- return new DPoint(-l.c / l.a, -this.c / this.b);
192
- }
193
- if (this.isParallelY && l.isParallelX) {
194
- return new DPoint(-this.c / this.a, -l.c / l.b);
195
- }
196
- if (this.isParallelY) {
197
- var x = -this.c / this.a;
198
- return l.y(new DPoint(x));
199
- }
200
- if (this.isParallelX) {
201
- var y = -this.c / this.b;
202
- return l.x(new DPoint(0, y));
203
- }
204
- if (l.isParallelY) {
205
- var x = -l.c / l.a;
206
- return this.y(new DPoint(x));
207
- }
208
- if (l.isParallelX) {
209
- var y = -l.c / l.b;
210
- return this.x(new DPoint(0, y));
211
- }
212
- var res = this.y(new DPoint((l.c / l.b - this.c / this.b) / (this.a / this.b - l.a / l.b)));
213
- if (!isFinite(res.x) && !isFinite(res.y)) {
214
- return null;
215
- }
216
- return res;
217
- };
218
- Object.defineProperty(DLine.prototype, "isParallel", {
219
- get: function () {
220
- return this.isParallelX || this.isParallelY;
221
- },
222
- enumerable: false,
223
- configurable: true
224
- });
225
- Object.defineProperty(DLine.prototype, "isParallelY", {
226
- get: function () {
227
- return Math.abs(this.b) < 0.001;
228
- },
229
- enumerable: false,
230
- configurable: true
231
- });
232
- Object.defineProperty(DLine.prototype, "isParallelX", {
233
- get: function () {
234
- return Math.abs(this.a) < 0.001;
235
- },
236
- enumerable: false,
237
- configurable: true
238
- });
239
- Object.defineProperty(DLine.prototype, "points", {
240
- get: function () {
241
- return [this.begin, this.end];
242
- },
243
- enumerable: false,
244
- configurable: true
245
- });
246
- DLine.prototype.getFi = function () {
247
- checkFunction('getFi')
248
- .checkArgument('this.begin')
249
- .shouldBeMeters(this.begin)
250
- .checkArgument('this.end')
251
- .shouldBeMeters(this.end);
252
- var _a = this.end.clone().move(this.begin.clone().minus()), x = _a.x, y = _a.y;
253
- var v = Math.atan2(y, x) - Math.PI;
254
- if (v > 0) {
255
- v = Math.PI - v;
256
- }
257
- return (Math.PI - v) % (Math.PI * 2);
258
- };
259
- DLine.prototype.toWKT = function () {
260
- var _a = this, _b = _a.begin, x1 = _b.x, y1 = _b.y, _c = _a.end, x2 = _c.x, y2 = _c.y;
261
- return "LINESTRING (".concat(x1, " ").concat(y1, ", ").concat(x2, " ").concat(y2, ")");
262
- };
263
- DLine.prototype.movePoint = function (i, k) {
264
- var isArray = Array.isArray(i);
265
- var p = isArray ? i : [i];
266
- var d = (isArray ? k : [k]);
267
- var fi = this.findFi(new DLine(1, 0, 0));
268
- var td = this.x(new DPoint(1, 1)).distance(this.x(new DPoint(2, 2))) / 2;
269
- var sinCos = new DPoint(Math.sin(fi), Math.cos(fi));
270
- var dt = sinCos.clone().scale(td);
271
- var p1T = p[0].clone().move(dt.clone().minus());
272
- var p2T = p[0].clone().move(dt);
273
- var res = [];
274
- if (DNumbers.like(this.y(p1T).y, p1T.y) || DNumbers.like(this.y(p2T).y, p2T.y)) {
275
- res = p.map(function (t, index) { return t.clone()
276
- .move(sinCos.clone().scale(d[index])); });
277
- }
278
- else {
279
- res = p.map(function (t, index) { return t.clone()
280
- .move(sinCos.clone().scale(d[index])
281
- .setX(function (_a) {
282
- var x = _a.x;
283
- return -x;
284
- })); });
285
- }
286
- return isArray ? res : res[0];
287
- };
288
- DLine.prototype.findFi = function (_a, delta) {
289
- var a = _a.a, b = _a.b;
290
- if (delta === void 0) { delta = 1.0001; }
291
- var _b = this, q = _b.a, w = _b.b;
292
- var val = (q * a + w * b) / (Math.sqrt(q * q + w * w) * Math.sqrt(a * a + b * b));
293
- if (val > 1 && val < delta) {
294
- val = 1;
295
- }
296
- else if (val < -1 && val > -delta) {
297
- val = -1;
298
- }
299
- return Math.acos(val);
300
- };
301
- DLine.prototype.vectorProduct = function (_a) {
302
- var a = _a.a, b = _a.b, c = _a.c;
303
- var _b = this, q = _b.a, w = _b.b, e = _b.c;
304
- return new DLine(w * c - e * b, e * a - q * c, q * b - w * a);
305
- };
306
- DLine.prototype.bresenhamsLine = function () {
307
- var _a = this.begin, x0 = _a.x, y0 = _a.y;
308
- var _b = this.end, x1 = _b.x, y1 = _b.y;
309
- var dx = Math.abs(x1 - x0);
310
- var sx = x0 < x1 ? 1 : -1;
311
- var dy = -Math.abs(y1 - y0);
312
- var sy = y0 < y1 ? 1 : -1;
313
- var error = dx + dy;
314
- var res = new DPolygon();
315
- while (true) {
316
- res.push(new DPoint(x0, y0));
317
- if (x0 === x1 && y0 === y1) {
318
- break;
319
- }
320
- var e2 = 2 * error;
321
- if (e2 >= dy) {
322
- if (x0 === x1) {
323
- break;
324
- }
325
- error += dy;
326
- x0 += sx;
327
- }
328
- if (e2 <= dx) {
329
- if (y0 === y1) {
330
- break;
331
- }
332
- error += dx;
333
- y0 += sy;
334
- }
335
- }
336
- return res;
337
- };
338
- return DLine;
339
- }());
340
- export { DLine };
@@ -1,27 +0,0 @@
1
- import { DEGREE_TO_PI, DOUBLE_PI_IN_DEGREE, PI_IN_DEGREE, PI_TO_DEGREE } from './DPoint';
2
- var delta = 0.001;
3
- var DNumbers = (function () {
4
- function DNumbers() {
5
- }
6
- DNumbers.like = function (v, s, d) {
7
- if (d === void 0) { d = delta; }
8
- return Math.abs(v - s) < d;
9
- };
10
- DNumbers.likeZero = function (v) {
11
- return DNumbers.like(v, 0);
12
- };
13
- DNumbers.like2PI = function (v) {
14
- return DNumbers.like(DNumbers.rad2Deg(v), DOUBLE_PI_IN_DEGREE);
15
- };
16
- DNumbers.likePI = function (v) {
17
- return DNumbers.like(DNumbers.rad2Deg(v), PI_IN_DEGREE);
18
- };
19
- DNumbers.rad2Deg = function (v) {
20
- return v * DEGREE_TO_PI;
21
- };
22
- DNumbers.deg2Rad = function (v) {
23
- return v * PI_TO_DEGREE;
24
- };
25
- return DNumbers;
26
- }());
27
- export { DNumbers };
@@ -1,129 +0,0 @@
1
- var __read = (this && this.__read) || function (o, n) {
2
- var m = typeof Symbol === "function" && o[Symbol.iterator];
3
- if (!m) return o;
4
- var i = m.call(o), r, ar = [], e;
5
- try {
6
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
- }
8
- catch (error) { e = { error: error }; }
9
- finally {
10
- try {
11
- if (r && !r.done && (m = i["return"])) m.call(i);
12
- }
13
- finally { if (e) throw e.error; }
14
- }
15
- return ar;
16
- };
17
- import { DPoint } from './DPoint';
18
- import { gaussianElimination } from './utils';
19
- import { DNumbers } from './DNumbers';
20
- var DPlane = (function () {
21
- function DPlane(a, b, c, d, p1, p2, p3) {
22
- if (p1 === void 0) { p1 = DPoint.zero(); }
23
- if (p2 === void 0) { p2 = DPoint.zero(); }
24
- if (p3 === void 0) { p3 = DPoint.zero(); }
25
- this.a = a;
26
- this.b = b;
27
- this.c = c;
28
- this.d = d;
29
- this.p1 = p1;
30
- this.p2 = p2;
31
- this.p3 = p3;
32
- }
33
- DPlane.find = function (p1, p2, p3) {
34
- if (p1.x === p2.x && p2.x === p3.x) {
35
- return new DPlane(1, 0, 0, -p1.x, p1, p2, p3);
36
- }
37
- if (p1.y === p2.y && p2.y === p3.y) {
38
- return new DPlane(0, 1, 0, -p1.y, p1, p2, p3);
39
- }
40
- if (p1.z === p2.z && p2.z === p3.z) {
41
- return new DPlane(0, 0, 1, -p1.z, p1, p2, p3);
42
- }
43
- var d = 1;
44
- var _a = __read(gaussianElimination([
45
- [p1.x, p1.y, p1.z, -d],
46
- [p2.x, p2.y, p2.z, -d],
47
- [p3.x, p3.y, p3.z, -d]
48
- ]), 3), a = _a[0], b = _a[1], c = _a[2];
49
- return new DPlane(a, b, c, d, p1, p2, p3);
50
- };
51
- DPlane.prototype.x = function (p) {
52
- var _this = this;
53
- if (p instanceof DPoint) {
54
- var _a = this, a = _a.a, b = _a.b, c = _a.c, d = _a.d;
55
- var y = p.y, z = p.z;
56
- p.x = -(b * y + c * z + d) / a;
57
- return p;
58
- }
59
- return p.map(function (t) { return _this.x(t); });
60
- };
61
- DPlane.prototype.y = function (p) {
62
- var _this = this;
63
- if (p instanceof DPoint) {
64
- var _a = this, a = _a.a, b = _a.b, c = _a.c, d = _a.d;
65
- var x = p.x, z = p.z;
66
- p.y = -(a * x + c * z + d) / b;
67
- return p;
68
- }
69
- return p.map(function (t) { return _this.y(t); });
70
- };
71
- DPlane.prototype.z = function (p) {
72
- var _this = this;
73
- if (p instanceof DPoint) {
74
- var _a = this, a = _a.a, b = _a.b, c = _a.c, d = _a.d;
75
- var x = p.x, y = p.y;
76
- p.z = -(a * x + b * y + d) / c;
77
- return p;
78
- }
79
- return p.map(function (t) { return _this.z(t); });
80
- };
81
- DPlane.prototype.clone = function () {
82
- var _a = this, a = _a.a, b = _a.b, c = _a.c, d = _a.d, p1 = _a.p1, p2 = _a.p2, p3 = _a.p3;
83
- return new DPlane(a, b, c, d, p1, p2, p3);
84
- };
85
- DPlane.prototype.distance = function (p) {
86
- if (p instanceof DPoint) {
87
- var x = p.x, y = p.y, z = p.z;
88
- var _a = this, a_1 = _a.a, b_1 = _a.b, c_1 = _a.c, d_1 = _a.d;
89
- return Math.abs(a_1 * x + b_1 * y + c_1 * z + d_1) / Math.sqrt(a_1 * a_1 + b_1 * b_1 + c_1 * c_1);
90
- }
91
- var _b = p, a = _b.a, b = _b.b, c = _b.c, d = _b.d;
92
- var r = this.d;
93
- return Math.abs(d - r) / Math.sqrt(a * a + b * b + c * c);
94
- };
95
- DPlane.prototype.equal = function (p) {
96
- var a = p.a, b = p.b, c = p.c, d = p.d;
97
- var _a = this, q = _a.a, w = _a.b, e = _a.c, r = _a.d;
98
- return DNumbers.like(a, q) &&
99
- DNumbers.like(b, w) &&
100
- DNumbers.like(c, e) &&
101
- DNumbers.like(d, r);
102
- };
103
- DPlane.prototype.same = function (p) {
104
- var a = p.a, b = p.b, c = p.c, d = p.d;
105
- var _a = this, q = _a.a, w = _a.b, e = _a.c, r = _a.d;
106
- var t = a / q;
107
- var y = b / w;
108
- var u = c / e;
109
- var i = d / r;
110
- return DNumbers.like(t, y) &&
111
- DNumbers.like(t, u) &&
112
- DNumbers.like(t, c) &&
113
- DNumbers.like(t, i);
114
- };
115
- DPlane.prototype.parallel = function (p) {
116
- var a = p.a, b = p.b, c = p.c, d = p.d;
117
- var _a = this, q = _a.a, w = _a.b, e = _a.c, r = _a.d;
118
- var t = a / q;
119
- var y = b / w;
120
- var u = c / e;
121
- var i = d / r;
122
- return DNumbers.like(t, y) &&
123
- DNumbers.like(t, u) &&
124
- DNumbers.like(t, c) &&
125
- !DNumbers.like(t, i);
126
- };
127
- return DPlane;
128
- }());
129
- export { DPlane };