dgeoutils 2.4.47 → 2.4.52

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