dgeoutils 2.2.1 → 2.2.5

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 CHANGED
@@ -3,7 +3,11 @@ import { DPolygon } from './DPolygon';
3
3
  export declare class DCircle {
4
4
  center: DPoint;
5
5
  r: number;
6
- constructor(center: DPoint, r: number);
6
+ /**
7
+ * @param [center=(0,0)]
8
+ * @param [r=0]
9
+ */
10
+ constructor(center?: DPoint, r?: number);
7
11
  toString(): string;
8
12
  getValue(): {
9
13
  center: DPoint;
@@ -13,7 +17,7 @@ export declare class DCircle {
13
17
  /**
14
18
  * Find intersection points with other circle.
15
19
  *
16
- * ![Example](/media/examples/findPoints.png)
20
+ * ![Example](https://edejin.github.io/DGeoUtils/media/examples/findPoints.png)
17
21
  * @param c
18
22
  */
19
23
  findPoints(c: DCircle): DPoint[] | number;
@@ -21,7 +25,7 @@ export declare class DCircle {
21
25
  /**
22
26
  * Transform circle to polygon
23
27
  *
24
- * ![Example](/media/examples/findPolygonInside.png)
28
+ * ![Example](https://edejin.github.io/DGeoUtils/media/examples/findPolygonInside.png)
25
29
  * @param [pointCount=64]
26
30
  */
27
31
  findPolygonInside(pointCount?: number): DPolygon;
@@ -34,7 +38,7 @@ export declare class DCircle {
34
38
  * @remarks
35
39
  * Radius should be in meters.
36
40
  *
37
- * ![Example](/media/examples/findPolygonInsideOnSphere.png)
41
+ * ![Example](https://edejin.github.io/DGeoUtils/media/examples/findPolygonInsideOnSphere.png)
38
42
  * @param [pointCount=64]
39
43
  */
40
44
  findPolygonInsideOnSphere(pointCount?: number): DPolygon;
package/dist/DCircle.js CHANGED
@@ -5,12 +5,16 @@ 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
8
9
  class DCircle {
9
- constructor(center, r) {
10
- this.center = DPoint_1.DPoint.Zero();
11
- this.r = 0;
12
- this.r = r;
10
+ /**
11
+ * @param [center=(0,0)]
12
+ * @param [r=0]
13
+ */
14
+ // eslint-disable-next-line no-useless-constructor,no-empty-function
15
+ constructor(center = DPoint_1.DPoint.zero(), r = 0) {
13
16
  this.center = center;
17
+ this.r = r;
14
18
  }
15
19
  toString() {
16
20
  return `(${this.center.toString()}, ${this.r})`;
@@ -24,7 +28,7 @@ class DCircle {
24
28
  /**
25
29
  * Find intersection points with other circle.
26
30
  *
27
- * ![Example](/media/examples/findPoints.png)
31
+ * ![Example](https://edejin.github.io/DGeoUtils/media/examples/findPoints.png)
28
32
  * @param c
29
33
  */
30
34
  findPoints(c) {
@@ -62,7 +66,7 @@ class DCircle {
62
66
  /**
63
67
  * Transform circle to polygon
64
68
  *
65
- * ![Example](/media/examples/findPolygonInside.png)
69
+ * ![Example](https://edejin.github.io/DGeoUtils/media/examples/findPolygonInside.png)
66
70
  * @param [pointCount=64]
67
71
  */
68
72
  findPolygonInside(pointCount = 64) {
@@ -85,7 +89,7 @@ class DCircle {
85
89
  * @remarks
86
90
  * Radius should be in meters.
87
91
  *
88
- * ![Example](/media/examples/findPolygonInsideOnSphere.png)
92
+ * ![Example](https://edejin.github.io/DGeoUtils/media/examples/findPolygonInsideOnSphere.png)
89
93
  * @param [pointCount=64]
90
94
  */
91
95
  findPolygonInsideOnSphere(pointCount = 64) {
package/dist/DLine.d.ts CHANGED
@@ -4,9 +4,16 @@ export declare class DLine {
4
4
  a: number;
5
5
  b: number;
6
6
  c: number;
7
- p1: DPoint;
8
- p2: DPoint;
9
- constructor(a?: number, b?: number, c?: number, p1?: DPoint, p2?: DPoint);
7
+ begin: DPoint;
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
+ constructor(a: number, b: number, c: number, begin?: DPoint, end?: DPoint);
10
17
  clone(): DLine;
11
18
  findPerpendicular(p: DPoint): DLine;
12
19
  perpendicularDistance(p: DPoint): number;
@@ -28,7 +35,7 @@ export declare class DLine {
28
35
  /**
29
36
  * Check if point below to line segment, but not equal star or end point.
30
37
  * @param p
31
- * @param d
38
+ * @param [d=0]
32
39
  */
33
40
  insideRange(p: DPoint, d?: number): boolean;
34
41
  get center(): DPoint;
@@ -80,10 +87,10 @@ export declare class DLine {
80
87
  * @param l
81
88
  * @param delta
82
89
  */
83
- findFi(l: DLine, delta?: number): number;
90
+ findFi({ a, b }: DLine, delta?: number): number;
84
91
  /**
85
92
  * [Cross product](https://en.wikipedia.org/wiki/Cross_product)
86
- * @param l
93
+ * @param l {DLine}
87
94
  */
88
- vectorProduct(l: DLine): DLine;
95
+ vectorProduct({ a, b, c }: DLine): DLine;
89
96
  }
package/dist/DLine.js CHANGED
@@ -3,38 +3,44 @@ 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
6
7
  class DLine {
7
- constructor(a = 0, b = 0, c = 0, p1 = DPoint_1.DPoint.Zero(), p2 = DPoint_1.DPoint.Zero()) {
8
- this.a = 0;
9
- this.b = 0;
10
- this.c = 0;
11
- this.p1 = DPoint_1.DPoint.Zero();
12
- this.p2 = DPoint_1.DPoint.Zero();
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
+ ) {
13
19
  this.a = a;
14
20
  this.b = b;
15
21
  this.c = c;
16
- this.p1 = p1;
17
- this.p2 = p2;
22
+ this.begin = begin;
23
+ this.end = end;
18
24
  }
19
25
  clone() {
20
- return new DLine(this.a, this.b, this.c, this.p1.clone(), this.p2.clone());
26
+ return new DLine(this.a, this.b, this.c, this.begin.clone(), this.end.clone());
21
27
  }
22
28
  findPerpendicular(p) {
23
29
  (0, utils_1.checkFunction)('findPerpendicular')
24
- .checkArgument('this.p1')
25
- .shouldBeMeters(this.p1)
26
- .checkArgument('this.p2')
27
- .shouldBeMeters(this.p2)
30
+ .checkArgument('this.begin')
31
+ .shouldBeMeters(this.begin)
32
+ .checkArgument('this.end')
33
+ .shouldBeMeters(this.end)
28
34
  .checkArgument('p')
29
35
  .shouldBeMeters(p);
30
36
  return new DLine(-this.b, this.a, this.b * p.x - this.a * p.y);
31
37
  }
32
38
  perpendicularDistance(p) {
33
39
  (0, utils_1.checkFunction)('perpendicularDistance')
34
- .checkArgument('this.p1')
35
- .shouldBeMeters(this.p1)
36
- .checkArgument('this.p2')
37
- .shouldBeMeters(this.p2)
40
+ .checkArgument('this.begin')
41
+ .shouldBeMeters(this.begin)
42
+ .checkArgument('this.end')
43
+ .shouldBeMeters(this.end)
38
44
  .checkArgument('p')
39
45
  .shouldBeMeters(p);
40
46
  const perpendicularLine = this.findPerpendicular(p);
@@ -63,10 +69,10 @@ class DLine {
63
69
  const per = this.findPerpendicular(center);
64
70
  const t = this.intersection(per, Infinity);
65
71
  let distance = t.distance(center);
66
- if (this.p1.equal(center)) {
72
+ if (this.begin.equal(center)) {
67
73
  distance = 0;
68
74
  }
69
- if (this.p2.equal(center)) {
75
+ if (this.end.equal(center)) {
70
76
  distance = 0;
71
77
  }
72
78
  if (distance < r) {
@@ -76,25 +82,25 @@ class DLine {
76
82
  const move = Math.sqrt(r * r - ct * ct);
77
83
  // Mean "|" x = const
78
84
  if (this.isParallelY) {
79
- t.x = this.p1.x;
85
+ t.x = this.begin.x;
80
86
  const r1 = t.clone().move(0, -move);
81
87
  const r2 = t.clone().move(0, move);
82
88
  return [r1, r2];
83
89
  }
84
90
  // Mean "-" y = const
85
91
  if (this.isParallelX) {
86
- t.y = this.p1.y;
92
+ t.y = this.begin.y;
87
93
  const r1 = t.clone().move(move, 0);
88
94
  const r2 = t.clone().move(-move, 0);
89
95
  return [r1, r2];
90
96
  }
91
97
  }
92
- if (this.p1.like(center)) {
93
- const p = this.p1.clone();
98
+ if (this.begin.like(center)) {
99
+ const p = this.begin.clone();
94
100
  return [this.movePoint(p, r), this.movePoint(p, -r)];
95
101
  }
96
- if (this.p2.like(center)) {
97
- const p = this.p2.clone();
102
+ if (this.end.like(center)) {
103
+ const p = this.end.clone();
98
104
  return [this.movePoint(p, r), this.movePoint(p, -r)];
99
105
  }
100
106
  const s = a * a + b * b;
@@ -124,23 +130,19 @@ class DLine {
124
130
  /**
125
131
  * Check if point below to line segment, but not equal star or end point.
126
132
  * @param p
127
- * @param d
133
+ * @param [d=0]
128
134
  */
129
135
  insideRange(p, d = 0) {
130
- const { minX, minY, maxX, maxY, p1, p2 } = this;
131
- const { x, y } = p;
132
- return this.inRange(p, d) && !p1.like(p, 0.00001) && !p2.like(p, 0.00001);
133
- const isInX = x > minX - d && x < maxX + d;
134
- const isInY = y > minY - d && y < maxY + d;
135
- return isInX && isInY && !p1.like(p, 0.00001) && !p2.like(p, 0.00001);
136
+ const { begin, end } = this;
137
+ return this.inRange(p, d) && !begin.like(p, 0.00001) && !end.like(p, 0.00001);
136
138
  }
137
139
  get center() {
138
- return this.p1
140
+ return this.begin
139
141
  .clone()
140
- .setIfLessThan(this.p2)
141
- .move(this.p2
142
+ .setIfLessThan(this.end)
143
+ .move(this.end
142
144
  .clone()
143
- .move(this.p1
145
+ .move(this.begin
144
146
  .clone()
145
147
  .minus())
146
148
  .abs()
@@ -148,16 +150,16 @@ class DLine {
148
150
  .divide(2));
149
151
  }
150
152
  get minX() {
151
- return Math.min(this.p1.x, this.p2.x);
153
+ return Math.min(this.begin.x, this.end.x);
152
154
  }
153
155
  get minY() {
154
- return Math.min(this.p1.y, this.p2.y);
156
+ return Math.min(this.begin.y, this.end.y);
155
157
  }
156
158
  get maxX() {
157
- return Math.max(this.p1.x, this.p2.x);
159
+ return Math.max(this.begin.x, this.end.x);
158
160
  }
159
161
  get maxY() {
160
- return Math.max(this.p1.y, this.p2.y);
162
+ return Math.max(this.begin.y, this.end.y);
161
163
  }
162
164
  toString() {
163
165
  return `(${this.a}, ${this.b}, ${this.c})`;
@@ -247,47 +249,26 @@ class DLine {
247
249
  * Get lines segment start and end points as array
248
250
  */
249
251
  get points() {
250
- return [this.p1, this.p2];
252
+ return [this.begin, this.end];
251
253
  }
252
254
  /**
253
255
  * Get line segment direction (from start point to end point)
254
256
  */
255
257
  getFi() {
256
258
  (0, utils_1.checkFunction)('getFi')
257
- .checkArgument('this.p1')
258
- .shouldBeMeters(this.p1)
259
- .checkArgument('this.p2')
260
- .shouldBeMeters(this.p2);
261
- const l = new DLine(0, 1, 0);
262
- const result = this.findFi(l);
263
- if (this.p1.x === this.p2.x) {
264
- if (this.p1.y === this.p2.y) {
265
- return 0;
266
- }
267
- else if (this.p1.y < this.p2.y) {
268
- return Math.PI + Math.PI / 2;
269
- }
270
- return Math.PI / 2;
259
+ .checkArgument('this.begin')
260
+ .shouldBeMeters(this.begin)
261
+ .checkArgument('this.end')
262
+ .shouldBeMeters(this.end);
263
+ const { x, y } = this.end.clone().move(this.begin.clone().minus());
264
+ let v = Math.atan2(y, x) - Math.PI;
265
+ if (v > 0) {
266
+ v = Math.PI - v;
271
267
  }
272
- else if (this.p1.x < this.p2.x) {
273
- if (this.p1.y === this.p2.y) {
274
- return 0;
275
- }
276
- else if (this.p1.y < this.p2.y) {
277
- return Math.PI - result + Math.PI;
278
- }
279
- return result;
280
- }
281
- if (this.p1.y === this.p2.y) {
282
- return Math.PI;
283
- }
284
- else if (this.p1.y < this.p2.y) {
285
- return Math.PI - result + Math.PI;
286
- }
287
- return result;
268
+ return (Math.PI - v) % (Math.PI * 2);
288
269
  }
289
270
  toWKT() {
290
- const { p1: { x: x1, y: y1 }, p2: { x: x2, y: y2 } } = this;
271
+ const { begin: { x: x1, y: y1 }, end: { x: x2, y: y2 } } = this;
291
272
  return `LINESTRING (${x1} ${y1}, ${x2} ${y2})`;
292
273
  }
293
274
  /**
@@ -297,7 +278,7 @@ class DLine {
297
278
  */
298
279
  movePoint(p, d) {
299
280
  const fi = this.findFi(new DLine(1, 0, 0));
300
- const td = this.p1.distance(this.p2) / 2;
281
+ const td = this.begin.distance(this.end) / 2;
301
282
  const dcosT = td * Math.cos(fi);
302
283
  const dsinT = td * Math.sin(fi);
303
284
  const p1T = new DPoint_1.DPoint(p.x - dsinT, p.y - dcosT);
@@ -316,8 +297,9 @@ class DLine {
316
297
  * @param l
317
298
  * @param delta
318
299
  */
319
- findFi(l, delta = 1.0001) {
320
- let val = (this.a * l.a + this.b * l.b) / (Math.sqrt(this.a * this.a + this.b * this.b) * Math.sqrt(l.a * l.a + l.b * l.b));
300
+ findFi({ a, b }, delta = 1.0001) {
301
+ const { a: q, b: w } = this;
302
+ let val = (q * a + w * b) / (Math.sqrt(q * q + w * w) * Math.sqrt(a * a + b * b));
321
303
  if (val > 1 && val < delta) {
322
304
  val = 1;
323
305
  }
@@ -328,13 +310,11 @@ class DLine {
328
310
  }
329
311
  /**
330
312
  * [Cross product](https://en.wikipedia.org/wiki/Cross_product)
331
- * @param l
313
+ * @param l {DLine}
332
314
  */
333
- vectorProduct(l) {
334
- const i = this.b * l.c - this.c * l.b;
335
- const j = this.c * l.a - this.a * l.c;
336
- const k = this.a * l.b - this.b * l.a;
337
- return new DLine(i, j, k);
315
+ vectorProduct({ a, b, c }) {
316
+ const { a: q, b: w, c: e } = this;
317
+ return new DLine(w * c - e * b, e * a - q * c, q * b - w * a);
338
318
  }
339
319
  }
340
320
  exports.DLine = DLine;
package/dist/DPoint.d.ts CHANGED
@@ -15,22 +15,36 @@ export declare type SetterFunction = (t: DPoint) => number;
15
15
  export declare class DPoint {
16
16
  x: number;
17
17
  y: number;
18
- z?: number;
18
+ z?: number | undefined;
19
19
  properties: {
20
20
  [key: string]: any;
21
21
  };
22
22
  /**
23
- *
23
+ * Create point with zero coords `(0, 0)`
24
+ */
25
+ constructor();
26
+ /**
27
+ * Create point
28
+ * @param xy - `x` and `y` value
29
+ */
30
+ 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
+ constructor(x: number, y: number);
37
+ /**
38
+ * Create point
24
39
  * @param x - lng, meters to East, radians to East or width
25
40
  * @param y - lat, meters to North, radians to North or height
26
41
  * @param z - height
27
42
  */
28
- constructor(x?: number, y?: number, z?: number);
29
- static Zero(): DPoint;
43
+ constructor(x: number, y: number, z?: number);
44
+ static zero(): DPoint;
30
45
  static parse(c: LatLng | number[] | DCoord): DPoint;
31
- static isPoint(p: unknown): boolean;
32
46
  static parseFromWKT(wkt: string): DPoint;
33
- static Random(): DPoint;
47
+ static random(): DPoint;
34
48
  /**
35
49
  * @remark Point should be Lng/Lat.
36
50
  *
@@ -59,8 +73,26 @@ export declare class DPoint {
59
73
  height(z: number): DPoint;
60
74
  toWKT(): string;
61
75
  distance(p: DPoint): number;
62
- setX(x: number | SetterFunction): DPoint;
63
- setY(y: number | SetterFunction): DPoint;
76
+ /**
77
+ * Set `x` value
78
+ * @param x
79
+ */
80
+ setX(x: number): DPoint;
81
+ /**
82
+ * Transform `x` value by function
83
+ * @param f
84
+ */
85
+ setX(f: SetterFunction): DPoint;
86
+ /**
87
+ * Set `y` value
88
+ * @param y
89
+ */
90
+ setY(y: number): DPoint;
91
+ /**
92
+ * Transform `y` value by function
93
+ * @param f
94
+ */
95
+ setY(f: SetterFunction): DPoint;
64
96
  clone(): DPoint;
65
97
  gt(p: DPoint): boolean;
66
98
  lt(p: DPoint): boolean;
@@ -71,7 +103,22 @@ export declare class DPoint {
71
103
  * @param a radians
72
104
  */
73
105
  rotate(a: number): DPoint;
74
- move(x?: number | DPoint, y?: number): DPoint;
106
+ /**
107
+ * Add `v` to `x` and `y`
108
+ * @param v
109
+ */
110
+ move(v: number): DPoint;
111
+ /**
112
+ * Add `p.x` to `x` field and `p.y` to `y` field.
113
+ * @param p
114
+ */
115
+ move(p: DPoint): DPoint;
116
+ /**
117
+ * Add `x` to `x` field and `y` to `y` field.
118
+ * @param x
119
+ * @param y
120
+ */
121
+ move(x: number, y: number): DPoint;
75
122
  degreeToMeters(): DPoint;
76
123
  metersToDegree(): DPoint;
77
124
  degreeToRadians(): DPoint;
@@ -81,13 +128,59 @@ export declare class DPoint {
81
128
  round(): DPoint;
82
129
  ceil(): DPoint;
83
130
  floor(): DPoint;
131
+ /**
132
+ * @param [n=2]
133
+ */
84
134
  toFixed(n?: number): DPoint;
85
135
  abs(): DPoint;
86
- scale(x?: number | DPoint, y?: number): DPoint;
87
- divide(x?: number | DPoint, y?: number): DPoint;
136
+ /**
137
+ * Multiply `v` to `x` and `y`
138
+ * @param v
139
+ */
140
+ scale(v: number): DPoint;
141
+ /**
142
+ * Multiply `p.x` to `x` field and `p.y` to `y` field.
143
+ * @param p
144
+ */
145
+ scale(p: DPoint): DPoint;
146
+ /**
147
+ * Multiply `x` to `x` field and `y` to `y` field.
148
+ * @param x
149
+ * @param y
150
+ */
151
+ scale(x: number, y: number): DPoint;
152
+ /**
153
+ * Divide `x` and `y` to `v`
154
+ * @param v
155
+ */
156
+ divide(v: number): DPoint;
157
+ /**
158
+ * Divide `x` field to `p.x` and `y` field to `p.y`.
159
+ * @param p
160
+ */
161
+ divide(p: DPoint): DPoint;
162
+ /**
163
+ * Divide `x` field to `x` and `y` field to `y`.
164
+ * @param x
165
+ * @param y
166
+ */
167
+ divide(x: number, y: number): DPoint;
88
168
  equal(p: DPoint): boolean;
169
+ /**
170
+ * @param p
171
+ * @param [d=0.001]
172
+ */
89
173
  like(p: DPoint, d?: number): boolean;
90
- flipVertically(size: DPoint | number): DPoint;
174
+ /**
175
+ * Flip vertically
176
+ * @param size canvas size
177
+ */
178
+ flipVertically(size: DPoint): DPoint;
179
+ /**
180
+ * Flip vertically
181
+ * @param height canvas height
182
+ */
183
+ flipVertically(height: number): DPoint;
91
184
  /**
92
185
  * Check if point looks like radians
93
186
  */
package/dist/DPoint.js CHANGED
@@ -19,23 +19,16 @@ exports.DOUBLE_PI_IN_DEGREE = 360;
19
19
  exports.PI_TO_DEGREE = Math.PI / exports.PI_IN_DEGREE;
20
20
  exports.DEGREE_TO_PI = exports.PI_IN_DEGREE / Math.PI;
21
21
  class DPoint {
22
- /**
23
- *
24
- * @param x - lng, meters to East, radians to East or width
25
- * @param y - lat, meters to North, radians to North or height
26
- * @param z - height
27
- */
28
- constructor(x = 0, y = 0, z) {
29
- this.x = 0;
30
- this.y = 0;
31
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
- this.properties = {};
22
+ // eslint-disable-next-line no-empty-function,no-useless-constructor
23
+ constructor(x = 0, y = x, z) {
33
24
  this.x = x;
34
25
  this.y = y;
35
26
  this.z = z;
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ this.properties = {};
36
29
  }
37
- static Zero() {
38
- return new DPoint(0, 0);
30
+ static zero() {
31
+ return new DPoint();
39
32
  }
40
33
  static parse(c) {
41
34
  const { lat, lng } = c;
@@ -45,9 +38,6 @@ class DPoint {
45
38
  const [x, y, z] = c;
46
39
  return new DPoint(x, y, z);
47
40
  }
48
- static isPoint(p) {
49
- return p instanceof DPoint;
50
- }
51
41
  static parseFromWKT(wkt) {
52
42
  const regexp = /POINT \((?<data>(?:(?!\)).)*?)\)$/miu;
53
43
  const data = wkt.trim().toUpperCase();
@@ -55,7 +45,7 @@ class DPoint {
55
45
  const [x, y, z] = res.groups.data.split(' ').map(Number);
56
46
  return new DPoint(x, y, z);
57
47
  }
58
- static Random() {
48
+ static random() {
59
49
  return new DPoint(Math.random(), Math.random());
60
50
  }
61
51
  /**
@@ -194,7 +184,7 @@ class DPoint {
194
184
  this.y = y;
195
185
  return this;
196
186
  }
197
- move(x = 0, y = x) {
187
+ move(x, y = x) {
198
188
  let xV = 0;
199
189
  let yV = 0;
200
190
  if (x instanceof DPoint) {
@@ -270,6 +260,9 @@ class DPoint {
270
260
  this.y = Math.floor(this.y);
271
261
  return this;
272
262
  }
263
+ /**
264
+ * @param [n=2]
265
+ */
273
266
  toFixed(n = 2) {
274
267
  this.x = parseFloat(this.x.toFixed(n));
275
268
  this.y = parseFloat(this.y.toFixed(n));
@@ -280,7 +273,7 @@ class DPoint {
280
273
  this.y = Math.abs(this.y);
281
274
  return this;
282
275
  }
283
- scale(x = 0, y = x) {
276
+ scale(x, y = x) {
284
277
  let xV = 0;
285
278
  let yV = 0;
286
279
  if (x instanceof DPoint) {
@@ -295,7 +288,7 @@ class DPoint {
295
288
  this.y = yV;
296
289
  return this;
297
290
  }
298
- divide(x = 0, y = x) {
291
+ divide(x, y = x) {
299
292
  let xV = 0;
300
293
  let yV = 0;
301
294
  if (x instanceof DPoint) {
@@ -313,10 +306,17 @@ class DPoint {
313
306
  equal(p) {
314
307
  return this.x === p.x && this.y === p.y && this.z === p.z;
315
308
  }
309
+ /**
310
+ * @param p
311
+ * @param [d=0.001]
312
+ */
316
313
  like(p, d = 0.001) {
314
+ if (this.equal(p)) {
315
+ return true;
316
+ }
317
317
  const likeX = Math.abs(this.x - p.x) < d;
318
318
  const likeY = Math.abs(this.y - p.y) < d;
319
- const likeZ = this.z === p.z || Math.abs(this.z - p.z) < d;
319
+ const likeZ = Math.abs((this.z || 0) - (p.z || 0)) < d;
320
320
  return likeX && likeY && likeZ;
321
321
  }
322
322
  flipVertically(size) {
@@ -436,7 +436,7 @@ class DPoint {
436
436
  const p = point.clone().degreeToRadians();
437
437
  const d = Math.sin(p.x - t.x);
438
438
  const step = (p.x - t.x) / (pointsCount - 1);
439
- return new DPolygon_1.DPolygon(Array.from(new Array(pointsCount))
439
+ return new DPolygon_1.DPolygon((0, utils_1.createArray)(pointsCount)
440
440
  .map((v, i) => {
441
441
  const x = t.x + step * i;
442
442
  const y = Math.atan((Math.tan(t.y) * Math.sin(p.x - x)) / d +