dgeoutils 2.2.7 → 2.2.11
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/dist/DCircle.d.ts +0 -28
- package/dist/DCircle.js +0 -30
- package/dist/DLine.d.ts +0 -60
- package/dist/DLine.js +1 -67
- package/dist/DPlane.d.ts +25 -0
- package/dist/DPlane.js +109 -0
- package/dist/DPoint.d.ts +4 -137
- package/dist/DPoint.js +31 -52
- package/dist/DPolygon.d.ts +2 -212
- package/dist/DPolygon.js +27 -255
- package/dist/DPolygonLoop.d.ts +3 -80
- package/dist/DPolygonLoop.js +58 -34
- package/dist/TraceMatrix.js +0 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +47 -4
- package/package.json +1 -1
package/dist/DCircle.d.ts
CHANGED
|
@@ -3,10 +3,6 @@ import { DPolygon } from './DPolygon';
|
|
|
3
3
|
export declare class DCircle {
|
|
4
4
|
center: DPoint;
|
|
5
5
|
r: number;
|
|
6
|
-
/**
|
|
7
|
-
* @param [center=(0,0)]
|
|
8
|
-
* @param [r=0]
|
|
9
|
-
*/
|
|
10
6
|
constructor(center?: DPoint, r?: number);
|
|
11
7
|
toString(): string;
|
|
12
8
|
getValue(): {
|
|
@@ -14,33 +10,9 @@ export declare class DCircle {
|
|
|
14
10
|
r: number;
|
|
15
11
|
};
|
|
16
12
|
clone(): DCircle;
|
|
17
|
-
/**
|
|
18
|
-
* Find intersection points with other circle.
|
|
19
|
-
*
|
|
20
|
-
* 
|
|
21
|
-
* @param c
|
|
22
|
-
*/
|
|
23
13
|
findPoints(c: DCircle): DPoint[] | number;
|
|
24
14
|
equal({ center, r }: DCircle): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Transform circle to polygon
|
|
27
|
-
*
|
|
28
|
-
* 
|
|
29
|
-
* @param [pointCount=64]
|
|
30
|
-
*/
|
|
31
15
|
findPolygonInside(pointCount?: number): DPolygon;
|
|
32
|
-
/**
|
|
33
|
-
* Transform circle to polygon on sphere. It would be different for different latitude.
|
|
34
|
-
*
|
|
35
|
-
* @remarks
|
|
36
|
-
* Center should be Lng/Lat.
|
|
37
|
-
*
|
|
38
|
-
* @remarks
|
|
39
|
-
* Radius should be in meters.
|
|
40
|
-
*
|
|
41
|
-
* 
|
|
42
|
-
* @param [pointCount=64]
|
|
43
|
-
*/
|
|
44
16
|
findPolygonInsideOnSphere(pointCount?: number): DPolygon;
|
|
45
17
|
private sphereOffset;
|
|
46
18
|
}
|
package/dist/DCircle.js
CHANGED
|
@@ -5,13 +5,7 @@ const DPoint_1 = require("./DPoint");
|
|
|
5
5
|
const DPolygon_1 = require("./DPolygon");
|
|
6
6
|
const DNumbers_1 = require("./DNumbers");
|
|
7
7
|
const utils_1 = require("./utils");
|
|
8
|
-
// eslint-disable-next-line padded-blocks
|
|
9
8
|
class DCircle {
|
|
10
|
-
/**
|
|
11
|
-
* @param [center=(0,0)]
|
|
12
|
-
* @param [r=0]
|
|
13
|
-
*/
|
|
14
|
-
// eslint-disable-next-line no-useless-constructor,no-empty-function
|
|
15
9
|
constructor(center = DPoint_1.DPoint.zero(), r = 0) {
|
|
16
10
|
this.center = center;
|
|
17
11
|
this.r = r;
|
|
@@ -25,12 +19,6 @@ class DCircle {
|
|
|
25
19
|
clone() {
|
|
26
20
|
return new DCircle(this.center, this.r);
|
|
27
21
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Find intersection points with other circle.
|
|
30
|
-
*
|
|
31
|
-
* 
|
|
32
|
-
* @param c
|
|
33
|
-
*/
|
|
34
22
|
findPoints(c) {
|
|
35
23
|
if (this.equal(c)) {
|
|
36
24
|
return Infinity;
|
|
@@ -63,12 +51,6 @@ class DCircle {
|
|
|
63
51
|
equal({ center, r }) {
|
|
64
52
|
return this.center.equal(center) && this.r === r;
|
|
65
53
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Transform circle to polygon
|
|
68
|
-
*
|
|
69
|
-
* 
|
|
70
|
-
* @param [pointCount=64]
|
|
71
|
-
*/
|
|
72
54
|
findPolygonInside(pointCount = 64) {
|
|
73
55
|
const preAngle = 2 * Math.PI / pointCount;
|
|
74
56
|
const points = [];
|
|
@@ -80,18 +62,6 @@ class DCircle {
|
|
|
80
62
|
}
|
|
81
63
|
return new DPolygon_1.DPolygon([...points, points[0]]);
|
|
82
64
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Transform circle to polygon on sphere. It would be different for different latitude.
|
|
85
|
-
*
|
|
86
|
-
* @remarks
|
|
87
|
-
* Center should be Lng/Lat.
|
|
88
|
-
*
|
|
89
|
-
* @remarks
|
|
90
|
-
* Radius should be in meters.
|
|
91
|
-
*
|
|
92
|
-
* 
|
|
93
|
-
* @param [pointCount=64]
|
|
94
|
-
*/
|
|
95
65
|
findPolygonInsideOnSphere(pointCount = 64) {
|
|
96
66
|
(0, utils_1.checkFunction)('findPolygonInsideOnSphere')
|
|
97
67
|
.checkArgument('center')
|
package/dist/DLine.d.ts
CHANGED
|
@@ -6,37 +6,13 @@ export declare class DLine {
|
|
|
6
6
|
c: number;
|
|
7
7
|
begin: DPoint;
|
|
8
8
|
end: DPoint;
|
|
9
|
-
/**
|
|
10
|
-
* @param a
|
|
11
|
-
* @param b
|
|
12
|
-
* @param c
|
|
13
|
-
* @param [begin=DPoint.zero()]
|
|
14
|
-
* @param [end=DPoint.zero()]
|
|
15
|
-
*/
|
|
16
9
|
constructor(a: number, b: number, c: number, begin?: DPoint, end?: DPoint);
|
|
17
10
|
clone(): DLine;
|
|
18
11
|
findPerpendicular(p: DPoint): DLine;
|
|
19
12
|
perpendicularDistance(p: DPoint): number;
|
|
20
|
-
/**
|
|
21
|
-
* Find intersection of two lines segments.
|
|
22
|
-
* For intersection of two lines use [[findPoint]]
|
|
23
|
-
* @param l
|
|
24
|
-
* @param [d=0]
|
|
25
|
-
* @param [includeOnly=false]
|
|
26
|
-
*/
|
|
27
13
|
intersection(l: DLine, d?: number, includeOnly?: boolean): DPoint | null;
|
|
28
14
|
intersectionWithCircle(circle: DCircle): DPoint | [DPoint, DPoint] | null;
|
|
29
|
-
/**
|
|
30
|
-
* Check if point below to line segment
|
|
31
|
-
* @param p
|
|
32
|
-
* @param d
|
|
33
|
-
*/
|
|
34
15
|
inRange(p: DPoint, d?: number): boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Check if point below to line segment, but not equal star or end point.
|
|
37
|
-
* @param p
|
|
38
|
-
* @param [d=0]
|
|
39
|
-
*/
|
|
40
16
|
insideRange(p: DPoint, d?: number): boolean;
|
|
41
17
|
get center(): DPoint;
|
|
42
18
|
get minX(): number;
|
|
@@ -45,52 +21,16 @@ export declare class DLine {
|
|
|
45
21
|
get maxY(): number;
|
|
46
22
|
toString(): string;
|
|
47
23
|
getValue(): number[];
|
|
48
|
-
/**
|
|
49
|
-
* Find `x` from `y` value of point
|
|
50
|
-
* @param p
|
|
51
|
-
*/
|
|
52
24
|
x(p: DPoint): DPoint;
|
|
53
|
-
/**
|
|
54
|
-
* Find `y` from `x` value of point
|
|
55
|
-
* @param p
|
|
56
|
-
*/
|
|
57
25
|
y(p: DPoint): DPoint;
|
|
58
|
-
/**
|
|
59
|
-
* Find intersection of two lines.
|
|
60
|
-
* For intersection of two lines segments use [[intersection]]
|
|
61
|
-
* @param l
|
|
62
|
-
*/
|
|
63
26
|
findPoint(l: DLine): DPoint | null;
|
|
64
|
-
/**
|
|
65
|
-
* Check if line parallel to `x` or `y` axis
|
|
66
|
-
*/
|
|
67
27
|
get isParallel(): boolean;
|
|
68
28
|
get isParallelY(): boolean;
|
|
69
29
|
get isParallelX(): boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Get lines segment start and end points as array
|
|
72
|
-
*/
|
|
73
30
|
get points(): [DPoint, DPoint];
|
|
74
|
-
/**
|
|
75
|
-
* Get line segment direction (from start point to end point)
|
|
76
|
-
*/
|
|
77
31
|
getFi(): number;
|
|
78
32
|
toWKT(): string;
|
|
79
|
-
/**
|
|
80
|
-
* Move lines point to left or right
|
|
81
|
-
* @param p
|
|
82
|
-
* @param d
|
|
83
|
-
*/
|
|
84
33
|
movePoint(p: DPoint, d: number): DPoint;
|
|
85
|
-
/**
|
|
86
|
-
* Find angle between current line and line in argument
|
|
87
|
-
* @param l
|
|
88
|
-
* @param delta
|
|
89
|
-
*/
|
|
90
34
|
findFi({ a, b }: DLine, delta?: number): number;
|
|
91
|
-
/**
|
|
92
|
-
* [Cross product](https://en.wikipedia.org/wiki/Cross_product)
|
|
93
|
-
* @param l {DLine}
|
|
94
|
-
*/
|
|
95
35
|
vectorProduct({ a, b, c }: DLine): DLine;
|
|
96
36
|
}
|
package/dist/DLine.js
CHANGED
|
@@ -3,19 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DLine = void 0;
|
|
4
4
|
const DPoint_1 = require("./DPoint");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
|
-
// eslint-disable-next-line padded-blocks
|
|
7
6
|
class DLine {
|
|
8
|
-
|
|
9
|
-
* @param a
|
|
10
|
-
* @param b
|
|
11
|
-
* @param c
|
|
12
|
-
* @param [begin=DPoint.zero()]
|
|
13
|
-
* @param [end=DPoint.zero()]
|
|
14
|
-
*/
|
|
15
|
-
// eslint-disable-next-line no-useless-constructor
|
|
16
|
-
constructor(a, b, c, begin = DPoint_1.DPoint.zero(), end = DPoint_1.DPoint.zero()
|
|
17
|
-
// eslint-disable-next-line no-empty-function
|
|
18
|
-
) {
|
|
7
|
+
constructor(a, b, c, begin = DPoint_1.DPoint.zero(), end = DPoint_1.DPoint.zero()) {
|
|
19
8
|
this.a = a;
|
|
20
9
|
this.b = b;
|
|
21
10
|
this.c = c;
|
|
@@ -47,13 +36,6 @@ class DLine {
|
|
|
47
36
|
const targetPoint = perpendicularLine.findPoint(this);
|
|
48
37
|
return targetPoint.distance(p);
|
|
49
38
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Find intersection of two lines segments.
|
|
52
|
-
* For intersection of two lines use [[findPoint]]
|
|
53
|
-
* @param l
|
|
54
|
-
* @param [d=0]
|
|
55
|
-
* @param [includeOnly=false]
|
|
56
|
-
*/
|
|
57
39
|
intersection(l, d = 0, includeOnly = false) {
|
|
58
40
|
const p = this.findPoint(l);
|
|
59
41
|
if (p) {
|
|
@@ -80,14 +62,12 @@ class DLine {
|
|
|
80
62
|
if (this.isParallel) {
|
|
81
63
|
const ct = center.distance(t);
|
|
82
64
|
const move = Math.sqrt(r * r - ct * ct);
|
|
83
|
-
// Mean "|" x = const
|
|
84
65
|
if (this.isParallelY) {
|
|
85
66
|
t.x = this.begin.x;
|
|
86
67
|
const r1 = t.clone().move(0, -move);
|
|
87
68
|
const r2 = t.clone().move(0, move);
|
|
88
69
|
return [r1, r2];
|
|
89
70
|
}
|
|
90
|
-
// Mean "-" y = const
|
|
91
71
|
if (this.isParallelX) {
|
|
92
72
|
t.y = this.begin.y;
|
|
93
73
|
const r1 = t.clone().move(move, 0);
|
|
@@ -115,11 +95,6 @@ class DLine {
|
|
|
115
95
|
}
|
|
116
96
|
return null;
|
|
117
97
|
}
|
|
118
|
-
/**
|
|
119
|
-
* Check if point below to line segment
|
|
120
|
-
* @param p
|
|
121
|
-
* @param d
|
|
122
|
-
*/
|
|
123
98
|
inRange(p, d = 0) {
|
|
124
99
|
const { minX, minY, maxX, maxY } = this;
|
|
125
100
|
const { x, y } = p;
|
|
@@ -127,11 +102,6 @@ class DLine {
|
|
|
127
102
|
const isInY = y >= minY - d && y <= maxY + d;
|
|
128
103
|
return isInX && isInY;
|
|
129
104
|
}
|
|
130
|
-
/**
|
|
131
|
-
* Check if point below to line segment, but not equal star or end point.
|
|
132
|
-
* @param p
|
|
133
|
-
* @param [d=0]
|
|
134
|
-
*/
|
|
135
105
|
insideRange(p, d = 0) {
|
|
136
106
|
const { begin, end } = this;
|
|
137
107
|
return this.inRange(p, d) && !begin.like(p, 0.00001) && !end.like(p, 0.00001);
|
|
@@ -167,10 +137,6 @@ class DLine {
|
|
|
167
137
|
getValue() {
|
|
168
138
|
return [this.a, this.b, this.c];
|
|
169
139
|
}
|
|
170
|
-
/**
|
|
171
|
-
* Find `x` from `y` value of point
|
|
172
|
-
* @param p
|
|
173
|
-
*/
|
|
174
140
|
x(p) {
|
|
175
141
|
if (this.isParallelY) {
|
|
176
142
|
return new DPoint_1.DPoint(-this.c / this.a, p.y);
|
|
@@ -180,10 +146,6 @@ class DLine {
|
|
|
180
146
|
}
|
|
181
147
|
return new DPoint_1.DPoint(-this.b / this.a * p.y - this.c / this.a, p.y);
|
|
182
148
|
}
|
|
183
|
-
/**
|
|
184
|
-
* Find `y` from `x` value of point
|
|
185
|
-
* @param p
|
|
186
|
-
*/
|
|
187
149
|
y(p) {
|
|
188
150
|
if (this.isParallelY) {
|
|
189
151
|
return new DPoint_1.DPoint(-this.c / this.a, p.y);
|
|
@@ -193,11 +155,6 @@ class DLine {
|
|
|
193
155
|
}
|
|
194
156
|
return new DPoint_1.DPoint(p.x, -this.a / this.b * p.x - this.c / this.b);
|
|
195
157
|
}
|
|
196
|
-
/**
|
|
197
|
-
* Find intersection of two lines.
|
|
198
|
-
* For intersection of two lines segments use [[intersection]]
|
|
199
|
-
* @param l
|
|
200
|
-
*/
|
|
201
158
|
findPoint(l) {
|
|
202
159
|
if (this.isParallelY && l.isParallelY) {
|
|
203
160
|
return null;
|
|
@@ -233,9 +190,6 @@ class DLine {
|
|
|
233
190
|
}
|
|
234
191
|
return res;
|
|
235
192
|
}
|
|
236
|
-
/**
|
|
237
|
-
* Check if line parallel to `x` or `y` axis
|
|
238
|
-
*/
|
|
239
193
|
get isParallel() {
|
|
240
194
|
return this.isParallelX || this.isParallelY;
|
|
241
195
|
}
|
|
@@ -245,15 +199,9 @@ class DLine {
|
|
|
245
199
|
get isParallelX() {
|
|
246
200
|
return Math.abs(this.a) < 0.001;
|
|
247
201
|
}
|
|
248
|
-
/**
|
|
249
|
-
* Get lines segment start and end points as array
|
|
250
|
-
*/
|
|
251
202
|
get points() {
|
|
252
203
|
return [this.begin, this.end];
|
|
253
204
|
}
|
|
254
|
-
/**
|
|
255
|
-
* Get line segment direction (from start point to end point)
|
|
256
|
-
*/
|
|
257
205
|
getFi() {
|
|
258
206
|
(0, utils_1.checkFunction)('getFi')
|
|
259
207
|
.checkArgument('this.begin')
|
|
@@ -271,11 +219,6 @@ class DLine {
|
|
|
271
219
|
const { begin: { x: x1, y: y1 }, end: { x: x2, y: y2 } } = this;
|
|
272
220
|
return `LINESTRING (${x1} ${y1}, ${x2} ${y2})`;
|
|
273
221
|
}
|
|
274
|
-
/**
|
|
275
|
-
* Move lines point to left or right
|
|
276
|
-
* @param p
|
|
277
|
-
* @param d
|
|
278
|
-
*/
|
|
279
222
|
movePoint(p, d) {
|
|
280
223
|
const fi = this.findFi(new DLine(1, 0, 0));
|
|
281
224
|
const td = this.begin.distance(this.end) / 2;
|
|
@@ -292,11 +235,6 @@ class DLine {
|
|
|
292
235
|
}
|
|
293
236
|
return p3;
|
|
294
237
|
}
|
|
295
|
-
/**
|
|
296
|
-
* Find angle between current line and line in argument
|
|
297
|
-
* @param l
|
|
298
|
-
* @param delta
|
|
299
|
-
*/
|
|
300
238
|
findFi({ a, b }, delta = 1.0001) {
|
|
301
239
|
const { a: q, b: w } = this;
|
|
302
240
|
let val = (q * a + w * b) / (Math.sqrt(q * q + w * w) * Math.sqrt(a * a + b * b));
|
|
@@ -308,10 +246,6 @@ class DLine {
|
|
|
308
246
|
}
|
|
309
247
|
return Math.acos(val);
|
|
310
248
|
}
|
|
311
|
-
/**
|
|
312
|
-
* [Cross product](https://en.wikipedia.org/wiki/Cross_product)
|
|
313
|
-
* @param l {DLine}
|
|
314
|
-
*/
|
|
315
249
|
vectorProduct({ a, b, c }) {
|
|
316
250
|
const { a: q, b: w, c: e } = this;
|
|
317
251
|
return new DLine(w * c - e * b, e * a - q * c, q * b - w * a);
|
package/dist/DPlane.d.ts
ADDED
|
@@ -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
|
+
}
|
package/dist/DPlane.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DPlane = void 0;
|
|
4
|
+
const DPoint_1 = require("./DPoint");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
const DNumbers_1 = require("./DNumbers");
|
|
7
|
+
class DPlane {
|
|
8
|
+
constructor(a, b, c, d, p1 = DPoint_1.DPoint.zero(), p2 = DPoint_1.DPoint.zero(), p3 = DPoint_1.DPoint.zero()) {
|
|
9
|
+
this.a = a;
|
|
10
|
+
this.b = b;
|
|
11
|
+
this.c = c;
|
|
12
|
+
this.d = d;
|
|
13
|
+
this.p1 = p1;
|
|
14
|
+
this.p2 = p2;
|
|
15
|
+
this.p3 = p3;
|
|
16
|
+
}
|
|
17
|
+
static find(p1, p2, p3) {
|
|
18
|
+
if (p1.x === p2.x && p2.x === p3.x) {
|
|
19
|
+
return new DPlane(1, 0, 0, -p1.x, p1, p2, p3);
|
|
20
|
+
}
|
|
21
|
+
if (p1.y === p2.y && p2.y === p3.y) {
|
|
22
|
+
return new DPlane(0, 1, 0, -p1.y, p1, p2, p3);
|
|
23
|
+
}
|
|
24
|
+
if (p1.z === p2.z && p2.z === p3.z) {
|
|
25
|
+
return new DPlane(0, 0, 1, -p1.z, p1, p2, p3);
|
|
26
|
+
}
|
|
27
|
+
const d = 1;
|
|
28
|
+
const [a, b, c] = (0, utils_1.gaussianElimination)([
|
|
29
|
+
[p1.x, p1.y, p1.z, -d],
|
|
30
|
+
[p2.x, p2.y, p2.z, -d],
|
|
31
|
+
[p3.x, p3.y, p3.z, -d]
|
|
32
|
+
]);
|
|
33
|
+
return new DPlane(a, b, c, d, p1, p2, p3);
|
|
34
|
+
}
|
|
35
|
+
x(p) {
|
|
36
|
+
if (p instanceof DPoint_1.DPoint) {
|
|
37
|
+
const { a, b, c, d } = this;
|
|
38
|
+
const { y, z } = p;
|
|
39
|
+
p.x = -(b * y + c * z + d) / a;
|
|
40
|
+
return p;
|
|
41
|
+
}
|
|
42
|
+
return p.map((t) => this.x(t));
|
|
43
|
+
}
|
|
44
|
+
y(p) {
|
|
45
|
+
if (p instanceof DPoint_1.DPoint) {
|
|
46
|
+
const { a, b, c, d } = this;
|
|
47
|
+
const { x, z } = p;
|
|
48
|
+
p.y = -(a * x + c * z + d) / b;
|
|
49
|
+
return p;
|
|
50
|
+
}
|
|
51
|
+
return p.map((t) => this.y(t));
|
|
52
|
+
}
|
|
53
|
+
z(p) {
|
|
54
|
+
if (p instanceof DPoint_1.DPoint) {
|
|
55
|
+
const { a, b, c, d } = this;
|
|
56
|
+
const { x, y } = p;
|
|
57
|
+
p.z = -(a * x + b * y + d) / c;
|
|
58
|
+
return p;
|
|
59
|
+
}
|
|
60
|
+
return p.map((t) => this.z(t));
|
|
61
|
+
}
|
|
62
|
+
clone() {
|
|
63
|
+
const { a, b, c, d, p1, p2, p3 } = this;
|
|
64
|
+
return new DPlane(a, b, c, d, p1, p2, p3);
|
|
65
|
+
}
|
|
66
|
+
distance(p) {
|
|
67
|
+
if (p instanceof DPoint_1.DPoint) {
|
|
68
|
+
const { x, y, z } = p;
|
|
69
|
+
const { a, b, c, d } = this;
|
|
70
|
+
return Math.abs(a * x + b * y + c * z + d) / Math.sqrt(a * a + b * b + c * c);
|
|
71
|
+
}
|
|
72
|
+
const { a, b, c, d } = p;
|
|
73
|
+
const { d: r } = this;
|
|
74
|
+
return Math.abs(d - r) / Math.sqrt(a * a + b * b + c * c);
|
|
75
|
+
}
|
|
76
|
+
equal(p) {
|
|
77
|
+
const { a, b, c, d } = p;
|
|
78
|
+
const { a: q, b: w, c: e, d: r } = this;
|
|
79
|
+
return DNumbers_1.DNumbers.like(a, q) &&
|
|
80
|
+
DNumbers_1.DNumbers.like(b, w) &&
|
|
81
|
+
DNumbers_1.DNumbers.like(c, e) &&
|
|
82
|
+
DNumbers_1.DNumbers.like(d, r);
|
|
83
|
+
}
|
|
84
|
+
same(p) {
|
|
85
|
+
const { a, b, c, d } = p;
|
|
86
|
+
const { a: q, b: w, c: e, d: r } = this;
|
|
87
|
+
const t = a / q;
|
|
88
|
+
const y = b / w;
|
|
89
|
+
const u = c / e;
|
|
90
|
+
const i = d / r;
|
|
91
|
+
return DNumbers_1.DNumbers.like(t, y) &&
|
|
92
|
+
DNumbers_1.DNumbers.like(t, u) &&
|
|
93
|
+
DNumbers_1.DNumbers.like(t, c) &&
|
|
94
|
+
DNumbers_1.DNumbers.like(t, i);
|
|
95
|
+
}
|
|
96
|
+
parallel(p) {
|
|
97
|
+
const { a, b, c, d } = p;
|
|
98
|
+
const { a: q, b: w, c: e, d: r } = this;
|
|
99
|
+
const t = a / q;
|
|
100
|
+
const y = b / w;
|
|
101
|
+
const u = c / e;
|
|
102
|
+
const i = d / r;
|
|
103
|
+
return DNumbers_1.DNumbers.like(t, y) &&
|
|
104
|
+
DNumbers_1.DNumbers.like(t, u) &&
|
|
105
|
+
DNumbers_1.DNumbers.like(t, c) &&
|
|
106
|
+
!DNumbers_1.DNumbers.like(t, i);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.DPlane = DPlane;
|
package/dist/DPoint.d.ts
CHANGED
|
@@ -19,53 +19,17 @@ export declare class DPoint {
|
|
|
19
19
|
properties: {
|
|
20
20
|
[key: string]: any;
|
|
21
21
|
};
|
|
22
|
-
/**
|
|
23
|
-
* Create point with zero coords `(0, 0)`
|
|
24
|
-
*/
|
|
25
22
|
constructor();
|
|
26
|
-
/**
|
|
27
|
-
* Create point
|
|
28
|
-
* @param xy - `x` and `y` value
|
|
29
|
-
*/
|
|
30
23
|
constructor(xy: number);
|
|
31
|
-
/**
|
|
32
|
-
* Create point
|
|
33
|
-
* @param x - lng, meters to East, radians to East or width
|
|
34
|
-
* @param y - lat, meters to North, radians to North or height
|
|
35
|
-
*/
|
|
36
24
|
constructor(x: number, y: number);
|
|
37
|
-
/**
|
|
38
|
-
* Create point
|
|
39
|
-
* @param x - lng, meters to East, radians to East or width
|
|
40
|
-
* @param y - lat, meters to North, radians to North or height
|
|
41
|
-
* @param z - height
|
|
42
|
-
*/
|
|
43
25
|
constructor(x: number, y: number, z?: number);
|
|
44
26
|
static zero(): DPoint;
|
|
45
27
|
static parse(c: LatLng | number[] | DCoord): DPoint;
|
|
46
28
|
static parseFromWKT(wkt: string): DPoint;
|
|
47
29
|
static random(): DPoint;
|
|
48
|
-
/**
|
|
49
|
-
* @remark Point should be Lng/Lat.
|
|
50
|
-
*
|
|
51
|
-
* @remark `z` value default for `zoom` argument.
|
|
52
|
-
*
|
|
53
|
-
* @param [zoom=this.z]
|
|
54
|
-
*/
|
|
55
30
|
getTileFromCoords(zoom?: number): DPoint;
|
|
56
|
-
/**
|
|
57
|
-
* Result would be Lng/Lat.
|
|
58
|
-
*
|
|
59
|
-
* @remark `z` value default for `zoom` argument.
|
|
60
|
-
*
|
|
61
|
-
* @param [zoom=this.z]
|
|
62
|
-
*/
|
|
63
31
|
getCoordsFromTile(zoom?: number): DPoint;
|
|
64
32
|
toCoords(): DCoord;
|
|
65
|
-
/**
|
|
66
|
-
* Find line between two points.
|
|
67
|
-
* @param p
|
|
68
|
-
*/
|
|
69
33
|
findLine(p: DPoint): DLine;
|
|
70
34
|
findInnerAngle(p1: DPoint, p3: DPoint): number;
|
|
71
35
|
toString(): string;
|
|
@@ -73,62 +37,25 @@ export declare class DPoint {
|
|
|
73
37
|
height(z: number): DPoint;
|
|
74
38
|
toWKT(): string;
|
|
75
39
|
distance(p: DPoint): number;
|
|
76
|
-
/**
|
|
77
|
-
* Set `x` value
|
|
78
|
-
* @param x
|
|
79
|
-
*/
|
|
80
40
|
setX(x: number): DPoint;
|
|
81
|
-
/**
|
|
82
|
-
* Transform `x` value by function
|
|
83
|
-
* @param f
|
|
84
|
-
*/
|
|
85
41
|
setX(f: SetterFunction): DPoint;
|
|
86
|
-
/**
|
|
87
|
-
* Set `z` value
|
|
88
|
-
* @param z
|
|
89
|
-
*/
|
|
90
42
|
setZ(z: number): DPoint;
|
|
91
|
-
/**
|
|
92
|
-
* Transform `z` value by function
|
|
93
|
-
* @param f
|
|
94
|
-
*/
|
|
95
43
|
setZ(f: SetterFunction): DPoint;
|
|
96
|
-
/**
|
|
97
|
-
* Set `y` value
|
|
98
|
-
* @param y
|
|
99
|
-
*/
|
|
100
44
|
setY(y: number): DPoint;
|
|
101
|
-
/**
|
|
102
|
-
* Transform `y` value by function
|
|
103
|
-
* @param f
|
|
104
|
-
*/
|
|
105
45
|
setY(f: SetterFunction): DPoint;
|
|
106
46
|
clone(): DPoint;
|
|
107
47
|
gt(p: DPoint): boolean;
|
|
108
48
|
lt(p: DPoint): boolean;
|
|
109
49
|
gtOrEqual(p: DPoint): boolean;
|
|
110
50
|
ltOrEqual(p: DPoint): boolean;
|
|
111
|
-
/**
|
|
112
|
-
* Clockwise rotation
|
|
113
|
-
* @param a radians
|
|
114
|
-
*/
|
|
115
51
|
rotate(a: number): DPoint;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
*/
|
|
52
|
+
rotate3dX(a: number): DPoint;
|
|
53
|
+
rotate3dY(a: number): DPoint;
|
|
54
|
+
rotate3dZ(a: number): DPoint;
|
|
120
55
|
move(v: number): DPoint;
|
|
121
|
-
/**
|
|
122
|
-
* Add `p.x` to `x` field and `p.y` to `y` field.
|
|
123
|
-
* @param p
|
|
124
|
-
*/
|
|
125
56
|
move(p: DPoint): DPoint;
|
|
126
|
-
/**
|
|
127
|
-
* Add `x` to `x` field and `y` to `y` field.
|
|
128
|
-
* @param x
|
|
129
|
-
* @param y
|
|
130
|
-
*/
|
|
131
57
|
move(x: number, y: number): DPoint;
|
|
58
|
+
move(x: number, y: number, z: number): DPoint;
|
|
132
59
|
degreeToMeters(): DPoint;
|
|
133
60
|
metersToDegree(): DPoint;
|
|
134
61
|
degreeToRadians(): DPoint;
|
|
@@ -138,70 +65,20 @@ export declare class DPoint {
|
|
|
138
65
|
round(): DPoint;
|
|
139
66
|
ceil(): DPoint;
|
|
140
67
|
floor(): DPoint;
|
|
141
|
-
/**
|
|
142
|
-
* @param [n=2]
|
|
143
|
-
*/
|
|
144
68
|
toFixed(n?: number): DPoint;
|
|
145
69
|
abs(): DPoint;
|
|
146
|
-
/**
|
|
147
|
-
* Multiply `v` to `x` and `y`
|
|
148
|
-
* @param v
|
|
149
|
-
*/
|
|
150
70
|
scale(v: number): DPoint;
|
|
151
|
-
/**
|
|
152
|
-
* Multiply `p.x` to `x` field and `p.y` to `y` field.
|
|
153
|
-
* @param p
|
|
154
|
-
*/
|
|
155
71
|
scale(p: DPoint): DPoint;
|
|
156
|
-
/**
|
|
157
|
-
* Multiply `x` to `x` field and `y` to `y` field.
|
|
158
|
-
* @param x
|
|
159
|
-
* @param y
|
|
160
|
-
*/
|
|
161
72
|
scale(x: number, y: number): DPoint;
|
|
162
|
-
/**
|
|
163
|
-
* Divide `x` and `y` to `v`
|
|
164
|
-
* @param v
|
|
165
|
-
*/
|
|
166
73
|
divide(v: number): DPoint;
|
|
167
|
-
/**
|
|
168
|
-
* Divide `x` field to `p.x` and `y` field to `p.y`.
|
|
169
|
-
* @param p
|
|
170
|
-
*/
|
|
171
74
|
divide(p: DPoint): DPoint;
|
|
172
|
-
/**
|
|
173
|
-
* Divide `x` field to `x` and `y` field to `y`.
|
|
174
|
-
* @param x
|
|
175
|
-
* @param y
|
|
176
|
-
*/
|
|
177
75
|
divide(x: number, y: number): DPoint;
|
|
178
76
|
equal(p: DPoint): boolean;
|
|
179
|
-
/**
|
|
180
|
-
* @param p
|
|
181
|
-
* @param [d=0.001]
|
|
182
|
-
*/
|
|
183
77
|
like(p: DPoint, d?: number): boolean;
|
|
184
|
-
/**
|
|
185
|
-
* Flip vertically
|
|
186
|
-
* @param size canvas size
|
|
187
|
-
*/
|
|
188
78
|
flipVertically(size: DPoint): DPoint;
|
|
189
|
-
/**
|
|
190
|
-
* Flip vertically
|
|
191
|
-
* @param height canvas height
|
|
192
|
-
*/
|
|
193
79
|
flipVertically(height: number): DPoint;
|
|
194
|
-
/**
|
|
195
|
-
* Check if point looks like radians
|
|
196
|
-
*/
|
|
197
80
|
get likeRadians(): boolean;
|
|
198
|
-
/**
|
|
199
|
-
* Check if point looks like `EPSG:4326` (degrees)
|
|
200
|
-
*/
|
|
201
81
|
get likeWorldGeodeticSystem(): boolean;
|
|
202
|
-
/**
|
|
203
|
-
* Check if point looks like `EPSG:3857` (meters)
|
|
204
|
-
*/
|
|
205
82
|
get likePseudoMercator(): boolean;
|
|
206
83
|
get w(): number;
|
|
207
84
|
set w(x: number);
|
|
@@ -221,15 +98,5 @@ export declare class DPoint {
|
|
|
221
98
|
};
|
|
222
99
|
setIfLessThan(p: DPoint): DPoint;
|
|
223
100
|
minus(): DPoint;
|
|
224
|
-
/**
|
|
225
|
-
* Find [orthodromic path](https://en.wikipedia.org/wiki/Great-circle_navigation) between to points.
|
|
226
|
-
*
|
|
227
|
-
* @remark Points should be Lng/Lat.
|
|
228
|
-
*
|
|
229
|
-
* 
|
|
230
|
-
*
|
|
231
|
-
* @param point
|
|
232
|
-
* @param [pointsCount=360]
|
|
233
|
-
*/
|
|
234
101
|
orthodromicPath(point: DPoint, pointsCount?: number): DPolygon;
|
|
235
102
|
}
|