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/DPolygonLoop.js
CHANGED
|
@@ -10,33 +10,34 @@ var LoopFunctions;
|
|
|
10
10
|
LoopFunctions[LoopFunctions["setY"] = 4] = "setY";
|
|
11
11
|
LoopFunctions[LoopFunctions["setZ"] = 5] = "setZ";
|
|
12
12
|
LoopFunctions[LoopFunctions["rotate"] = 6] = "rotate";
|
|
13
|
-
LoopFunctions[LoopFunctions["
|
|
14
|
-
LoopFunctions[LoopFunctions["
|
|
15
|
-
LoopFunctions[LoopFunctions["
|
|
16
|
-
LoopFunctions[LoopFunctions["
|
|
17
|
-
LoopFunctions[LoopFunctions["
|
|
18
|
-
LoopFunctions[LoopFunctions["
|
|
19
|
-
LoopFunctions[LoopFunctions["
|
|
20
|
-
LoopFunctions[LoopFunctions["
|
|
21
|
-
LoopFunctions[LoopFunctions["
|
|
22
|
-
LoopFunctions[LoopFunctions["
|
|
23
|
-
LoopFunctions[LoopFunctions["
|
|
24
|
-
LoopFunctions[LoopFunctions["
|
|
25
|
-
LoopFunctions[LoopFunctions["
|
|
26
|
-
LoopFunctions[LoopFunctions["
|
|
27
|
-
LoopFunctions[LoopFunctions["
|
|
28
|
-
LoopFunctions[LoopFunctions["
|
|
29
|
-
LoopFunctions[LoopFunctions["
|
|
30
|
-
LoopFunctions[LoopFunctions["
|
|
31
|
-
LoopFunctions[LoopFunctions["
|
|
32
|
-
LoopFunctions[LoopFunctions["
|
|
33
|
-
LoopFunctions[LoopFunctions["
|
|
34
|
-
LoopFunctions[LoopFunctions["
|
|
13
|
+
LoopFunctions[LoopFunctions["rotate3dX"] = 7] = "rotate3dX";
|
|
14
|
+
LoopFunctions[LoopFunctions["rotate3dY"] = 8] = "rotate3dY";
|
|
15
|
+
LoopFunctions[LoopFunctions["rotate3dZ"] = 9] = "rotate3dZ";
|
|
16
|
+
LoopFunctions[LoopFunctions["move"] = 10] = "move";
|
|
17
|
+
LoopFunctions[LoopFunctions["round"] = 11] = "round";
|
|
18
|
+
LoopFunctions[LoopFunctions["ceil"] = 12] = "ceil";
|
|
19
|
+
LoopFunctions[LoopFunctions["floor"] = 13] = "floor";
|
|
20
|
+
LoopFunctions[LoopFunctions["toFixed"] = 14] = "toFixed";
|
|
21
|
+
LoopFunctions[LoopFunctions["abs"] = 15] = "abs";
|
|
22
|
+
LoopFunctions[LoopFunctions["scale"] = 16] = "scale";
|
|
23
|
+
LoopFunctions[LoopFunctions["divide"] = 17] = "divide";
|
|
24
|
+
LoopFunctions[LoopFunctions["degreeToRadians"] = 18] = "degreeToRadians";
|
|
25
|
+
LoopFunctions[LoopFunctions["radiansToDegrees"] = 19] = "radiansToDegrees";
|
|
26
|
+
LoopFunctions[LoopFunctions["radiansToMeters"] = 20] = "radiansToMeters";
|
|
27
|
+
LoopFunctions[LoopFunctions["metersToRadians"] = 21] = "metersToRadians";
|
|
28
|
+
LoopFunctions[LoopFunctions["hipPoint"] = 22] = "hipPoint";
|
|
29
|
+
LoopFunctions[LoopFunctions["xPoint"] = 23] = "xPoint";
|
|
30
|
+
LoopFunctions[LoopFunctions["yPoint"] = 24] = "yPoint";
|
|
31
|
+
LoopFunctions[LoopFunctions["wPoint"] = 25] = "wPoint";
|
|
32
|
+
LoopFunctions[LoopFunctions["hPoint"] = 26] = "hPoint";
|
|
33
|
+
LoopFunctions[LoopFunctions["setIfLessThan"] = 27] = "setIfLessThan";
|
|
34
|
+
LoopFunctions[LoopFunctions["minus"] = 28] = "minus";
|
|
35
|
+
LoopFunctions[LoopFunctions["degreeToMeters"] = 29] = "degreeToMeters";
|
|
36
|
+
LoopFunctions[LoopFunctions["metersToDegree"] = 30] = "metersToDegree";
|
|
37
|
+
LoopFunctions[LoopFunctions["flipVertically"] = 31] = "flipVertically";
|
|
35
38
|
})(LoopFunctions || (LoopFunctions = {}));
|
|
36
|
-
// eslint-disable-next-line complexity
|
|
37
39
|
const decodePoolRecord = (a, { functionName, pointArg, numberPointArg, numberArg, setterArg }) => {
|
|
38
40
|
let res = a;
|
|
39
|
-
// eslint-disable-next-line default-case
|
|
40
41
|
switch (functionName) {
|
|
41
42
|
case LoopFunctions.getTileFromCoords:
|
|
42
43
|
res = (k) => a(k)
|
|
@@ -66,6 +67,18 @@ const decodePoolRecord = (a, { functionName, pointArg, numberPointArg, numberArg
|
|
|
66
67
|
res = (k) => a(k)
|
|
67
68
|
.rotate(numberArg);
|
|
68
69
|
break;
|
|
70
|
+
case LoopFunctions.rotate3dX:
|
|
71
|
+
res = (k) => a(k)
|
|
72
|
+
.rotate3dX(numberArg);
|
|
73
|
+
break;
|
|
74
|
+
case LoopFunctions.rotate3dY:
|
|
75
|
+
res = (k) => a(k)
|
|
76
|
+
.rotate3dY(numberArg);
|
|
77
|
+
break;
|
|
78
|
+
case LoopFunctions.rotate3dZ:
|
|
79
|
+
res = (k) => a(k)
|
|
80
|
+
.rotate3dZ(numberArg);
|
|
81
|
+
break;
|
|
69
82
|
case LoopFunctions.move:
|
|
70
83
|
res = (k) => a(k)
|
|
71
84
|
.move(numberPointArg, numberArg);
|
|
@@ -158,7 +171,6 @@ const decodePoolRecord = (a, { functionName, pointArg, numberPointArg, numberArg
|
|
|
158
171
|
return res;
|
|
159
172
|
};
|
|
160
173
|
class DPolygonLoop {
|
|
161
|
-
// eslint-disable-next-line no-empty-function,no-useless-constructor
|
|
162
174
|
constructor(parent) {
|
|
163
175
|
this.parent = parent;
|
|
164
176
|
this.pool = [];
|
|
@@ -166,15 +178,9 @@ class DPolygonLoop {
|
|
|
166
178
|
getLoopFunction() {
|
|
167
179
|
return this.pool.reduce(decodePoolRecord, (k) => k);
|
|
168
180
|
}
|
|
169
|
-
/**
|
|
170
|
-
* Run loop
|
|
171
|
-
*/
|
|
172
181
|
run() {
|
|
173
182
|
return this.parent.map(this.getLoopFunction());
|
|
174
183
|
}
|
|
175
|
-
/**
|
|
176
|
-
* @param zoom default value would be `z` of point
|
|
177
|
-
*/
|
|
178
184
|
getTileFromCoords(zoom) {
|
|
179
185
|
this.pool.push({
|
|
180
186
|
functionName: LoopFunctions.getTileFromCoords,
|
|
@@ -182,9 +188,6 @@ class DPolygonLoop {
|
|
|
182
188
|
});
|
|
183
189
|
return this;
|
|
184
190
|
}
|
|
185
|
-
/**
|
|
186
|
-
* @param zoom default value would be `z` of point
|
|
187
|
-
*/
|
|
188
191
|
getCoordsFromTile(zoom) {
|
|
189
192
|
this.pool.push({
|
|
190
193
|
functionName: LoopFunctions.getCoordsFromTile,
|
|
@@ -227,6 +230,27 @@ class DPolygonLoop {
|
|
|
227
230
|
});
|
|
228
231
|
return this;
|
|
229
232
|
}
|
|
233
|
+
rotate3dX(a) {
|
|
234
|
+
this.pool.push({
|
|
235
|
+
functionName: LoopFunctions.rotate3dX,
|
|
236
|
+
numberArg: a
|
|
237
|
+
});
|
|
238
|
+
return this;
|
|
239
|
+
}
|
|
240
|
+
rotate3dY(a) {
|
|
241
|
+
this.pool.push({
|
|
242
|
+
functionName: LoopFunctions.rotate3dY,
|
|
243
|
+
numberArg: a
|
|
244
|
+
});
|
|
245
|
+
return this;
|
|
246
|
+
}
|
|
247
|
+
rotate3dZ(a) {
|
|
248
|
+
this.pool.push({
|
|
249
|
+
functionName: LoopFunctions.rotate3dZ,
|
|
250
|
+
numberArg: a
|
|
251
|
+
});
|
|
252
|
+
return this;
|
|
253
|
+
}
|
|
230
254
|
move(x, y = x) {
|
|
231
255
|
this.pool.push({
|
|
232
256
|
functionName: LoopFunctions.move,
|
package/dist/TraceMatrix.js
CHANGED
|
@@ -96,7 +96,6 @@ class TraceMatrix {
|
|
|
96
96
|
let prevDirection = Infinity;
|
|
97
97
|
let p = group.at(0);
|
|
98
98
|
while (!p.equal(group.at(0)) || points.length < 2) {
|
|
99
|
-
// eslint-disable-next-line no-constant-condition
|
|
100
99
|
while (true) {
|
|
101
100
|
const nextValue = getByPosition(m, p.clone().move(traceDirections[direction]));
|
|
102
101
|
const nextNeighbourValue = getByPosition(m, p.clone().move(traceDirections[left(direction)]));
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./DPolygon"), exports);
|
|
|
19
19
|
__exportStar(require("./FastSearch"), exports);
|
|
20
20
|
__exportStar(require("./TraceMatrix"), exports);
|
|
21
21
|
__exportStar(require("./DPolygonLoop"), exports);
|
|
22
|
+
__exportStar(require("./DPlane"), exports);
|
|
22
23
|
exports.DGeo = {
|
|
23
24
|
DEBUG: false
|
|
24
25
|
};
|
package/dist/utils.d.ts
CHANGED
|
@@ -13,4 +13,6 @@ interface CheckFunction {
|
|
|
13
13
|
}
|
|
14
14
|
export declare const checkFunction: (funcName: string) => CheckFunction;
|
|
15
15
|
export declare const createArray: (v: number) => number[];
|
|
16
|
+
export declare const createMatrix: ({ h, w }: DPoint) => number[][];
|
|
17
|
+
export declare const gaussianElimination: (matrix: number[][]) => number[];
|
|
16
18
|
export {};
|
package/dist/utils.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createArray = exports.checkFunction = exports.warn = void 0;
|
|
3
|
+
exports.gaussianElimination = exports.createMatrix = exports.createArray = exports.checkFunction = exports.warn = void 0;
|
|
4
4
|
const index_1 = require("./index");
|
|
5
5
|
const DPoint_1 = require("./DPoint");
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
6
|
const warn = (...args) => {
|
|
8
7
|
if (index_1.DGeo.DEBUG) {
|
|
9
|
-
// eslint-disable-next-line no-console
|
|
10
8
|
console.warn(...args);
|
|
11
9
|
}
|
|
12
10
|
};
|
|
@@ -45,7 +43,6 @@ const shouldBeMeters = (scope, funcName, argName) => (p) => {
|
|
|
45
43
|
return scope;
|
|
46
44
|
};
|
|
47
45
|
const checkFunction = (funcName) => ({
|
|
48
|
-
// eslint-disable-next-line func-names, object-shorthand
|
|
49
46
|
checkArgument: function (argName) {
|
|
50
47
|
if (!index_1.DGeo.DEBUG) {
|
|
51
48
|
return {
|
|
@@ -68,3 +65,49 @@ const checkFunction = (funcName) => ({
|
|
|
68
65
|
exports.checkFunction = checkFunction;
|
|
69
66
|
const createArray = (v) => new Array(v).fill(0);
|
|
70
67
|
exports.createArray = createArray;
|
|
68
|
+
const createMatrix = ({ h, w }) => (0, exports.createArray)(h).map(() => (0, exports.createArray)(w));
|
|
69
|
+
exports.createMatrix = createMatrix;
|
|
70
|
+
const GAUSSIAN_ELIMINATION_MIN = 1e-10;
|
|
71
|
+
const gaussianElimination = (matrix) => {
|
|
72
|
+
const n = matrix.length;
|
|
73
|
+
const matrixClone = (0, exports.createMatrix)(new DPoint_1.DPoint(n + 1, n));
|
|
74
|
+
for (let i = 0; i < n; i++) {
|
|
75
|
+
for (let j = 0; j < n + 1; j++) {
|
|
76
|
+
matrix[i][j] = matrix[i][j] === 0 ? GAUSSIAN_ELIMINATION_MIN : matrix[i][j];
|
|
77
|
+
matrixClone[i][j] = matrix[i][j];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
for (let k = 0; k < n; k++) {
|
|
81
|
+
for (let i = 0; i < n + 1; i++) {
|
|
82
|
+
matrixClone[k][i] /= matrix[k][k];
|
|
83
|
+
}
|
|
84
|
+
for (let i = k + 1; i < n; i++) {
|
|
85
|
+
const K = matrixClone[i][k] / matrixClone[k][k];
|
|
86
|
+
for (let j = 0; j < n + 1; j++) {
|
|
87
|
+
matrixClone[i][j] -= matrixClone[k][j] * K;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
for (let i = 0; i < n; i++) {
|
|
91
|
+
for (let j = 0; j < n + 1; j++) {
|
|
92
|
+
matrix[i][j] = matrixClone[i][j];
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
for (let k = n - 1; k > -1; k--) {
|
|
97
|
+
for (let i = n; i > -1; i--) {
|
|
98
|
+
matrixClone[k][i] /= matrix[k][k];
|
|
99
|
+
}
|
|
100
|
+
for (let i = k - 1; i > -1; i--) {
|
|
101
|
+
const K = matrixClone[i][k] / matrixClone[k][k];
|
|
102
|
+
for (let j = n; j > -1; j--) {
|
|
103
|
+
matrixClone[i][j] -= matrixClone[k][j] * K;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const answer = (0, exports.createArray)(n);
|
|
108
|
+
for (let i = 0; i < n; i++) {
|
|
109
|
+
answer[i] = matrixClone[i][n];
|
|
110
|
+
}
|
|
111
|
+
return answer;
|
|
112
|
+
};
|
|
113
|
+
exports.gaussianElimination = gaussianElimination;
|