dgeoutils 2.2.24 → 2.3.3

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 (50) hide show
  1. package/README.md +7 -0
  2. package/dist/{DCircle.d.ts → cjs/DCircle.d.ts} +0 -0
  3. package/dist/cjs/DCircle.js +102 -0
  4. package/dist/{DLine.d.ts → cjs/DLine.d.ts} +0 -0
  5. package/dist/cjs/DLine.js +300 -0
  6. package/dist/{DNumbers.d.ts → cjs/DNumbers.d.ts} +0 -0
  7. package/dist/cjs/DNumbers.js +30 -0
  8. package/dist/{DPlane.d.ts → cjs/DPlane.d.ts} +0 -0
  9. package/dist/cjs/DPlane.js +132 -0
  10. package/dist/{DPoint.d.ts → cjs/DPoint.d.ts} +0 -0
  11. package/dist/cjs/DPoint.js +574 -0
  12. package/dist/{DPolygon.d.ts → cjs/DPolygon.d.ts} +1 -1
  13. package/dist/cjs/DPolygon.js +1555 -0
  14. package/dist/{DPolygonLoop.d.ts → cjs/DPolygonLoop.d.ts} +0 -0
  15. package/dist/cjs/DPolygonLoop.js +401 -0
  16. package/dist/{FastSearch.d.ts → cjs/FastSearch.d.ts} +0 -0
  17. package/dist/cjs/FastSearch.js +53 -0
  18. package/dist/{TraceMatrix.d.ts → cjs/TraceMatrix.d.ts} +1 -2
  19. package/dist/cjs/TraceMatrix.js +256 -0
  20. package/dist/{index.d.ts → cjs/index.d.ts} +1 -4
  21. package/dist/{index.js → cjs/index.js} +1 -3
  22. package/dist/{utils.d.ts → cjs/utils.d.ts} +3 -0
  23. package/dist/cjs/utils.js +193 -0
  24. package/dist/{DCircle.js → es2015/DCircle.js} +14 -18
  25. package/dist/{DLine.js → es2015/DLine.js} +24 -28
  26. package/dist/es2015/DNumbers.js +22 -0
  27. package/dist/{DPlane.js → es2015/DPlane.js} +22 -26
  28. package/dist/{DPoint.js → es2015/DPoint.js} +52 -56
  29. package/dist/{DPolygon.js → es2015/DPolygon.js} +71 -75
  30. package/dist/{DPolygonLoop.js → es2015/DPolygonLoop.js} +1 -5
  31. package/dist/{FastSearch.js → es2015/FastSearch.js} +1 -5
  32. package/dist/{TraceMatrix.js → es2015/TraceMatrix.js} +35 -39
  33. package/dist/es2015/index.js +10 -0
  34. package/dist/{utils.js → es2015/utils.js} +28 -36
  35. package/dist/esm/DCircle.js +99 -0
  36. package/dist/esm/DLine.js +297 -0
  37. package/dist/esm/DNumbers.js +27 -0
  38. package/dist/esm/DPlane.js +129 -0
  39. package/dist/esm/DPoint.js +571 -0
  40. package/dist/esm/DPolygon.js +1552 -0
  41. package/dist/esm/DPolygonLoop.js +398 -0
  42. package/dist/esm/FastSearch.js +50 -0
  43. package/dist/esm/TraceMatrix.js +253 -0
  44. package/dist/esm/index.js +10 -0
  45. package/dist/esm/utils.js +183 -0
  46. package/dist/umd/dgeoutils.js +3568 -0
  47. package/dist/umd/dgeoutils.min.js +1 -0
  48. package/dist/umd/dgeoutils.min.js.map +1 -0
  49. package/package.json +19 -12
  50. package/dist/DNumbers.js +0 -26
@@ -0,0 +1,99 @@
1
+ import { DPoint, EARTH_RADIUS_IN_METERS } from './DPoint';
2
+ import { DPolygon } from './DPolygon';
3
+ import { checkFunction } from './utils';
4
+ var DCircle = (function () {
5
+ function DCircle(center, r) {
6
+ if (center === void 0) { center = DPoint.zero(); }
7
+ if (r === void 0) { r = 0; }
8
+ this.center = center;
9
+ this.r = r;
10
+ }
11
+ DCircle.prototype.toString = function () {
12
+ return "(" + this.center.toString() + ", " + this.r + ")";
13
+ };
14
+ DCircle.prototype.getValue = function () {
15
+ return { center: this.center, r: this.r };
16
+ };
17
+ DCircle.prototype.clone = function () {
18
+ return new DCircle(this.center, this.r);
19
+ };
20
+ DCircle.prototype.findPoints = function (c) {
21
+ if (this.equal(c)) {
22
+ return Infinity;
23
+ }
24
+ var _a = this, _b = _a.center, x0 = _b.x, y0 = _b.y, r0 = _a.r;
25
+ var _c = c.center, x1 = _c.x, y1 = _c.y, r1 = c.r;
26
+ var r02 = r0 * r0;
27
+ var d = this.center.distance(c.center);
28
+ var a = (r02 - r1 * r1 + d * d) / (2 * d);
29
+ var h = Math.sqrt(r02 - a * a);
30
+ var ad = a / d;
31
+ var dy = y1 - y0;
32
+ var dx = x1 - x0;
33
+ var hd = h / d;
34
+ var x2 = x0 + ad * (x1 - x0);
35
+ var y2 = y0 + ad * (y1 - y0);
36
+ var x31 = x2 + hd * dy;
37
+ var y31 = y2 - hd * dx;
38
+ var x32 = x2 - hd * dy;
39
+ var y32 = y2 + hd * dx;
40
+ var res = [];
41
+ if (!isNaN(x31) && !isNaN(y31)) {
42
+ res.push(new DPoint(x31, y31));
43
+ }
44
+ if (!isNaN(x32) && !isNaN(y32) && !(x31 === x32 && y31 === y32)) {
45
+ res.push(new DPoint(x32, y32));
46
+ }
47
+ return res;
48
+ };
49
+ DCircle.prototype.equal = function (_a) {
50
+ var center = _a.center, r = _a.r;
51
+ return this.center.equal(center) && this.r === r;
52
+ };
53
+ DCircle.prototype.findPolygonInside = function (pointCount, startAngle, stopAngle) {
54
+ if (pointCount === void 0) { pointCount = 64; }
55
+ if (startAngle === void 0) { startAngle = 0; }
56
+ if (stopAngle === void 0) { stopAngle = 2 * Math.PI; }
57
+ var step = 2 * Math.PI / pointCount;
58
+ var points = [];
59
+ var angle = startAngle;
60
+ while (angle < stopAngle - step) {
61
+ points.push(new DPoint(this.r).scale(Math.cos(angle), Math.sin(angle))
62
+ .move(this.center));
63
+ angle += step;
64
+ }
65
+ var x = this.r * Math.cos(stopAngle) + this.center.x;
66
+ var y = this.r * Math.sin(stopAngle) + this.center.y;
67
+ points.push(new DPoint(x, y));
68
+ return new DPolygon(points);
69
+ };
70
+ DCircle.prototype.findPolygonInsideOnSphere = function (pointCount, startAngle, stopAngle) {
71
+ if (pointCount === void 0) { pointCount = 64; }
72
+ if (startAngle === void 0) { startAngle = 0; }
73
+ if (stopAngle === void 0) { stopAngle = 2 * Math.PI; }
74
+ checkFunction('findPolygonInsideOnSphere')
75
+ .checkArgument('center')
76
+ .shouldBeDegree(this.center);
77
+ var step = 2 * Math.PI / pointCount;
78
+ var points = [];
79
+ var angle = startAngle;
80
+ while (angle < stopAngle - step) {
81
+ points.push(this.sphereOffset(angle));
82
+ angle += step;
83
+ }
84
+ points.push(this.sphereOffset(stopAngle));
85
+ return new DPolygon(points);
86
+ };
87
+ DCircle.prototype.sphereOffset = function (bearing, earthRadius) {
88
+ if (earthRadius === void 0) { earthRadius = EARTH_RADIUS_IN_METERS; }
89
+ var _a = this.center.clone().degreeToRadians(), lon1 = _a.x, lat1 = _a.y;
90
+ var dByR = this.r / earthRadius;
91
+ var lat = Math.asin(Math.sin(lat1) * Math.cos(dByR) +
92
+ Math.cos(lat1) * Math.sin(dByR) * Math.cos(bearing));
93
+ var lon = lon1 +
94
+ Math.atan2(Math.sin(bearing) * Math.sin(dByR) * Math.cos(lat1), Math.cos(dByR) - Math.sin(lat1) * Math.sin(lat));
95
+ return new DPoint(lon, lat).radiansToDegrees();
96
+ };
97
+ return DCircle;
98
+ }());
99
+ export { DCircle };
@@ -0,0 +1,297 @@
1
+ import { DPoint } from './DPoint';
2
+ import { checkFunction } from './utils';
3
+ import { DNumbers } from './DNumbers';
4
+ var DLine = (function () {
5
+ function DLine(a, b, c, begin, end) {
6
+ if (begin === void 0) { begin = DPoint.zero(); }
7
+ if (end === void 0) { end = DPoint.zero(); }
8
+ this.a = a;
9
+ this.b = b;
10
+ this.c = c;
11
+ this.begin = begin;
12
+ this.end = end;
13
+ }
14
+ DLine.prototype.clone = function () {
15
+ return new DLine(this.a, this.b, this.c, this.begin.clone(), this.end.clone());
16
+ };
17
+ DLine.prototype.findPerpendicular = function (p) {
18
+ checkFunction('findPerpendicular')
19
+ .checkArgument('this.begin')
20
+ .shouldBeMeters(this.begin)
21
+ .checkArgument('this.end')
22
+ .shouldBeMeters(this.end)
23
+ .checkArgument('p')
24
+ .shouldBeMeters(p);
25
+ return new DLine(-this.b, this.a, this.b * p.x - this.a * p.y);
26
+ };
27
+ DLine.prototype.perpendicularDistance = function (p) {
28
+ checkFunction('perpendicularDistance')
29
+ .checkArgument('this.begin')
30
+ .shouldBeMeters(this.begin)
31
+ .checkArgument('this.end')
32
+ .shouldBeMeters(this.end)
33
+ .checkArgument('p')
34
+ .shouldBeMeters(p);
35
+ var perpendicularLine = this.findPerpendicular(p);
36
+ var targetPoint = perpendicularLine.findPoint(this);
37
+ return targetPoint.distance(p);
38
+ };
39
+ DLine.prototype.intersection = function (l, d, includeOnly) {
40
+ if (d === void 0) { d = 0; }
41
+ if (includeOnly === void 0) { includeOnly = false; }
42
+ var p = this.findPoint(l);
43
+ if (p) {
44
+ if (includeOnly) {
45
+ return this.insideRange(p, d) && l.insideRange(p, d) ? p : null;
46
+ }
47
+ return this.inRange(p, d) && l.inRange(p, d) ? p : null;
48
+ }
49
+ return null;
50
+ };
51
+ DLine.prototype.intersectionWithCircle = function (circle) {
52
+ var center = circle.center, r = circle.r;
53
+ var per = this.findPerpendicular(center);
54
+ var t = this.findPoint(per);
55
+ var distance = t.distance(center);
56
+ if (this.begin.equal(center)) {
57
+ distance = 0;
58
+ }
59
+ if (this.end.equal(center)) {
60
+ distance = 0;
61
+ }
62
+ if (distance < r) {
63
+ var _a = this, a = _a.a, b = _a.b, c = _a.c;
64
+ if (this.isParallel) {
65
+ var ct = center.distance(t);
66
+ var move = Math.sqrt(r * r - ct * ct);
67
+ if (this.isParallelY) {
68
+ t.x = this.begin.x;
69
+ var r1_1 = t.clone().move(0, -move);
70
+ var r2_1 = t.clone().move(0, move);
71
+ return [r1_1, r2_1];
72
+ }
73
+ if (this.isParallelX) {
74
+ t.y = this.begin.y;
75
+ var r1_2 = t.clone().move(move, 0);
76
+ var r2_2 = t.clone().move(-move, 0);
77
+ return [r1_2, r2_2];
78
+ }
79
+ }
80
+ if (this.begin.like(center)) {
81
+ var p = this.begin.clone();
82
+ return [this.movePoint(p, r), this.movePoint(p, -r)];
83
+ }
84
+ if (this.end.like(center)) {
85
+ var p = this.end.clone();
86
+ return [this.movePoint(p, r), this.movePoint(p, -r)];
87
+ }
88
+ var s = a * a + b * b;
89
+ var d = r * r - c * c / s;
90
+ var mult = Math.sqrt(d / s);
91
+ var r1 = t.clone().move(b * mult, -a * mult);
92
+ var r2 = t.clone().move(-b * mult, a * mult);
93
+ return [r1, r2];
94
+ }
95
+ if (distance === r) {
96
+ return t;
97
+ }
98
+ return null;
99
+ };
100
+ DLine.prototype.inRange = function (p, d) {
101
+ if (d === void 0) { d = 0; }
102
+ var _a = this, minX = _a.minX, minY = _a.minY, maxX = _a.maxX, maxY = _a.maxY;
103
+ var x = p.x, y = p.y;
104
+ var isInX = x >= minX - d && x <= maxX + d;
105
+ var isInY = y >= minY - d && y <= maxY + d;
106
+ return isInX && isInY;
107
+ };
108
+ DLine.prototype.insideRange = function (p, d) {
109
+ if (d === void 0) { d = 0; }
110
+ var _a = this, begin = _a.begin, end = _a.end;
111
+ return this.inRange(p, d) && !begin.like(p, 0.00001) && !end.like(p, 0.00001);
112
+ };
113
+ Object.defineProperty(DLine.prototype, "center", {
114
+ get: function () {
115
+ return this.begin
116
+ .clone()
117
+ .setIfLessThan(this.end)
118
+ .move(this.end
119
+ .clone()
120
+ .move(this.begin
121
+ .clone()
122
+ .minus())
123
+ .abs()
124
+ .minus()
125
+ .divide(2));
126
+ },
127
+ enumerable: false,
128
+ configurable: true
129
+ });
130
+ Object.defineProperty(DLine.prototype, "minX", {
131
+ get: function () {
132
+ return Math.min(this.begin.x, this.end.x);
133
+ },
134
+ enumerable: false,
135
+ configurable: true
136
+ });
137
+ Object.defineProperty(DLine.prototype, "minY", {
138
+ get: function () {
139
+ return Math.min(this.begin.y, this.end.y);
140
+ },
141
+ enumerable: false,
142
+ configurable: true
143
+ });
144
+ Object.defineProperty(DLine.prototype, "maxX", {
145
+ get: function () {
146
+ return Math.max(this.begin.x, this.end.x);
147
+ },
148
+ enumerable: false,
149
+ configurable: true
150
+ });
151
+ Object.defineProperty(DLine.prototype, "maxY", {
152
+ get: function () {
153
+ return Math.max(this.begin.y, this.end.y);
154
+ },
155
+ enumerable: false,
156
+ configurable: true
157
+ });
158
+ DLine.prototype.toString = function () {
159
+ return "(" + this.a + ", " + this.b + ", " + this.c + ")";
160
+ };
161
+ DLine.prototype.getValue = function () {
162
+ return [this.a, this.b, this.c];
163
+ };
164
+ DLine.prototype.x = function (p) {
165
+ if (this.isParallelY) {
166
+ return new DPoint(-this.c / this.a, p.y);
167
+ }
168
+ if (this.isParallelX) {
169
+ return new DPoint(p.x, -this.c / this.b);
170
+ }
171
+ return new DPoint(-this.b / this.a * p.y - this.c / this.a, p.y);
172
+ };
173
+ DLine.prototype.y = function (p) {
174
+ if (this.isParallelY) {
175
+ return new DPoint(-this.c / this.a, p.y);
176
+ }
177
+ if (this.isParallelX) {
178
+ return new DPoint(p.x, -this.c / this.b);
179
+ }
180
+ return new DPoint(p.x, -this.a / this.b * p.x - this.c / this.b);
181
+ };
182
+ DLine.prototype.findPoint = function (l) {
183
+ if (this.isParallelY && l.isParallelY) {
184
+ return null;
185
+ }
186
+ if (this.isParallelX && l.isParallelX) {
187
+ return null;
188
+ }
189
+ if (this.isParallelX && l.isParallelY) {
190
+ return new DPoint(-l.c / l.a, -this.c / this.b);
191
+ }
192
+ if (this.isParallelY && l.isParallelX) {
193
+ return new DPoint(-this.c / this.a, -l.c / l.b);
194
+ }
195
+ if (this.isParallelY) {
196
+ var x = -this.c / this.a;
197
+ return l.y(new DPoint(x));
198
+ }
199
+ if (this.isParallelX) {
200
+ var y = -this.c / this.b;
201
+ return l.x(new DPoint(0, y));
202
+ }
203
+ if (l.isParallelY) {
204
+ var x = -l.c / l.a;
205
+ return this.y(new DPoint(x));
206
+ }
207
+ if (l.isParallelX) {
208
+ var y = -l.c / l.b;
209
+ return this.x(new DPoint(0, y));
210
+ }
211
+ var res = this.y(new DPoint((l.c / l.b - this.c / this.b) / (this.a / this.b - l.a / l.b)));
212
+ if (!isFinite(res.x) && !isFinite(res.y)) {
213
+ return null;
214
+ }
215
+ return res;
216
+ };
217
+ Object.defineProperty(DLine.prototype, "isParallel", {
218
+ get: function () {
219
+ return this.isParallelX || this.isParallelY;
220
+ },
221
+ enumerable: false,
222
+ configurable: true
223
+ });
224
+ Object.defineProperty(DLine.prototype, "isParallelY", {
225
+ get: function () {
226
+ return Math.abs(this.b) < 0.001;
227
+ },
228
+ enumerable: false,
229
+ configurable: true
230
+ });
231
+ Object.defineProperty(DLine.prototype, "isParallelX", {
232
+ get: function () {
233
+ return Math.abs(this.a) < 0.001;
234
+ },
235
+ enumerable: false,
236
+ configurable: true
237
+ });
238
+ Object.defineProperty(DLine.prototype, "points", {
239
+ get: function () {
240
+ return [this.begin, this.end];
241
+ },
242
+ enumerable: false,
243
+ configurable: true
244
+ });
245
+ DLine.prototype.getFi = function () {
246
+ checkFunction('getFi')
247
+ .checkArgument('this.begin')
248
+ .shouldBeMeters(this.begin)
249
+ .checkArgument('this.end')
250
+ .shouldBeMeters(this.end);
251
+ var _a = this.end.clone().move(this.begin.clone().minus()), x = _a.x, y = _a.y;
252
+ var v = Math.atan2(y, x) - Math.PI;
253
+ if (v > 0) {
254
+ v = Math.PI - v;
255
+ }
256
+ return (Math.PI - v) % (Math.PI * 2);
257
+ };
258
+ DLine.prototype.toWKT = function () {
259
+ var _a = this, _b = _a.begin, x1 = _b.x, y1 = _b.y, _c = _a.end, x2 = _c.x, y2 = _c.y;
260
+ return "LINESTRING (" + x1 + " " + y1 + ", " + x2 + " " + y2 + ")";
261
+ };
262
+ DLine.prototype.movePoint = function (p, d) {
263
+ var fi = this.findFi(new DLine(1, 0, 0));
264
+ var td = this.x(new DPoint(1, 1)).distance(this.x(new DPoint(2, 2))) / 2;
265
+ var sinCos = new DPoint(Math.sin(fi), Math.cos(fi));
266
+ var dt = sinCos.clone().scale(td);
267
+ var p1T = p.clone().move(dt.clone().minus());
268
+ var p2T = p.clone().move(dt);
269
+ if (DNumbers.like(this.y(p1T).y, p1T.y) || DNumbers.like(this.y(p2T).y, p2T.y)) {
270
+ return p.clone().move(sinCos.scale(d));
271
+ }
272
+ return p.clone().move(sinCos.scale(d).setX(function (_a) {
273
+ var x = _a.x;
274
+ return -x;
275
+ }));
276
+ };
277
+ DLine.prototype.findFi = function (_a, delta) {
278
+ var a = _a.a, b = _a.b;
279
+ if (delta === void 0) { delta = 1.0001; }
280
+ var _b = this, q = _b.a, w = _b.b;
281
+ var val = (q * a + w * b) / (Math.sqrt(q * q + w * w) * Math.sqrt(a * a + b * b));
282
+ if (val > 1 && val < delta) {
283
+ val = 1;
284
+ }
285
+ else if (val < -1 && val > -delta) {
286
+ val = -1;
287
+ }
288
+ return Math.acos(val);
289
+ };
290
+ DLine.prototype.vectorProduct = function (_a) {
291
+ var a = _a.a, b = _a.b, c = _a.c;
292
+ var _b = this, q = _b.a, w = _b.b, e = _b.c;
293
+ return new DLine(w * c - e * b, e * a - q * c, q * b - w * a);
294
+ };
295
+ return DLine;
296
+ }());
297
+ export { DLine };
@@ -0,0 +1,27 @@
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 };
@@ -0,0 +1,129 @@
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 };