dgeoutils 2.3.3 → 2.3.6
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/cjs/DLine.d.ts +2 -1
- package/dist/cjs/DLine.js +18 -8
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/utils.d.ts +3 -0
- package/dist/cjs/utils.js +10 -1
- package/dist/es2015/DLine.js +15 -5
- package/dist/es2015/index.js +1 -1
- package/dist/es2015/utils.js +2 -0
- package/dist/esm/DLine.js +18 -8
- package/dist/esm/index.js +1 -1
- package/dist/esm/utils.js +8 -0
- package/dist/umd/dgeoutils.js +28 -9
- package/dist/umd/dgeoutils.min.js +1 -1
- package/dist/umd/dgeoutils.min.js.map +1 -1
- package/package.json +4 -4
package/dist/cjs/DLine.d.ts
CHANGED
|
@@ -30,7 +30,8 @@ export declare class DLine {
|
|
|
30
30
|
get points(): [DPoint, DPoint];
|
|
31
31
|
getFi(): number;
|
|
32
32
|
toWKT(): string;
|
|
33
|
-
movePoint(
|
|
33
|
+
movePoint(point: DPoint, distance: number): DPoint;
|
|
34
|
+
movePoint(points: DPoint[], distances: number[]): DPoint[];
|
|
34
35
|
findFi({ a, b }: DLine, delta?: number): number;
|
|
35
36
|
vectorProduct({ a, b, c }: DLine): DLine;
|
|
36
37
|
}
|
package/dist/cjs/DLine.js
CHANGED
|
@@ -262,20 +262,30 @@ var DLine = (function () {
|
|
|
262
262
|
var _a = this, _b = _a.begin, x1 = _b.x, y1 = _b.y, _c = _a.end, x2 = _c.x, y2 = _c.y;
|
|
263
263
|
return "LINESTRING (" + x1 + " " + y1 + ", " + x2 + " " + y2 + ")";
|
|
264
264
|
};
|
|
265
|
-
DLine.prototype.movePoint = function (
|
|
265
|
+
DLine.prototype.movePoint = function (i, k) {
|
|
266
|
+
var isArray = Array.isArray(i);
|
|
267
|
+
var p = isArray ? i : [i];
|
|
268
|
+
var d = (isArray ? k : [k]);
|
|
266
269
|
var fi = this.findFi(new DLine(1, 0, 0));
|
|
267
270
|
var td = this.x(new DPoint_1.DPoint(1, 1)).distance(this.x(new DPoint_1.DPoint(2, 2))) / 2;
|
|
268
271
|
var sinCos = new DPoint_1.DPoint(Math.sin(fi), Math.cos(fi));
|
|
269
272
|
var dt = sinCos.clone().scale(td);
|
|
270
|
-
var p1T = p.clone().move(dt.clone().minus());
|
|
271
|
-
var p2T = p.clone().move(dt);
|
|
273
|
+
var p1T = p[0].clone().move(dt.clone().minus());
|
|
274
|
+
var p2T = p[0].clone().move(dt);
|
|
275
|
+
var res = [];
|
|
272
276
|
if (DNumbers_1.DNumbers.like(this.y(p1T).y, p1T.y) || DNumbers_1.DNumbers.like(this.y(p2T).y, p2T.y)) {
|
|
273
|
-
|
|
277
|
+
res = p.map(function (t, index) { return t.clone()
|
|
278
|
+
.move(sinCos.clone().scale(d[index])); });
|
|
274
279
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
280
|
+
else {
|
|
281
|
+
res = p.map(function (t, index) { return t.clone()
|
|
282
|
+
.move(sinCos.clone().scale(d[index])
|
|
283
|
+
.setX(function (_a) {
|
|
284
|
+
var x = _a.x;
|
|
285
|
+
return -x;
|
|
286
|
+
})); });
|
|
287
|
+
}
|
|
288
|
+
return isArray ? res : res[0];
|
|
279
289
|
};
|
|
280
290
|
DLine.prototype.findFi = function (_a, delta) {
|
|
281
291
|
var a = _a.a, b = _a.b;
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export * from './FastSearch';
|
|
|
7
7
|
export * from './TraceMatrix';
|
|
8
8
|
export * from './DPolygonLoop';
|
|
9
9
|
export * from './DPlane';
|
|
10
|
-
export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, DGeo } from './utils';
|
|
10
|
+
export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, cartesianProduct, DGeo } from './utils';
|
package/dist/cjs/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.DGeo = exports.isDefAndNotNull = exports.createMatrix = exports.createArray = exports.createCanvas = exports.gaussianElimination = void 0;
|
|
13
|
+
exports.DGeo = exports.cartesianProduct = exports.isDefAndNotNull = exports.createMatrix = exports.createArray = exports.createCanvas = exports.gaussianElimination = void 0;
|
|
14
14
|
__exportStar(require("./DCircle"), exports);
|
|
15
15
|
__exportStar(require("./DLine"), exports);
|
|
16
16
|
__exportStar(require("./DNumbers"), exports);
|
|
@@ -26,4 +26,5 @@ Object.defineProperty(exports, "createCanvas", { enumerable: true, get: function
|
|
|
26
26
|
Object.defineProperty(exports, "createArray", { enumerable: true, get: function () { return utils_1.createArray; } });
|
|
27
27
|
Object.defineProperty(exports, "createMatrix", { enumerable: true, get: function () { return utils_1.createMatrix; } });
|
|
28
28
|
Object.defineProperty(exports, "isDefAndNotNull", { enumerable: true, get: function () { return utils_1.isDefAndNotNull; } });
|
|
29
|
+
Object.defineProperty(exports, "cartesianProduct", { enumerable: true, get: function () { return utils_1.cartesianProduct; } });
|
|
29
30
|
Object.defineProperty(exports, "DGeo", { enumerable: true, get: function () { return utils_1.DGeo; } });
|
package/dist/cjs/utils.d.ts
CHANGED
package/dist/cjs/utils.js
CHANGED
|
@@ -25,7 +25,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
25
25
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.createCanvas = exports.gaussianElimination = exports.createMatrix = exports.createArray = exports.checkFunction = exports.isDefAndNotNull = exports.warn = exports.DGeo = void 0;
|
|
28
|
+
exports.cartesianProduct = exports.createCanvas = exports.gaussianElimination = exports.createMatrix = exports.createArray = exports.checkFunction = exports.isDefAndNotNull = exports.warn = exports.DGeo = void 0;
|
|
29
29
|
var DPoint_1 = require("./DPoint");
|
|
30
30
|
exports.DGeo = {
|
|
31
31
|
DEBUG: false
|
|
@@ -191,3 +191,12 @@ var createCanvas = function (a, b, c) {
|
|
|
191
191
|
return [canvas, canvas.getContext('2d')];
|
|
192
192
|
};
|
|
193
193
|
exports.createCanvas = createCanvas;
|
|
194
|
+
var f = function (a, b) { return [].concat.apply([], __spreadArray([], __read(a.map(function (c) { return b.map(function (d) { return [].concat(c, d); }); })), false)); };
|
|
195
|
+
var cartesianProduct = function (a, b) {
|
|
196
|
+
var c = [];
|
|
197
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
198
|
+
c[_i - 2] = arguments[_i];
|
|
199
|
+
}
|
|
200
|
+
return b ? exports.cartesianProduct.apply(void 0, __spreadArray([f(a, b)], __read(c), false)) : a;
|
|
201
|
+
};
|
|
202
|
+
exports.cartesianProduct = cartesianProduct;
|
package/dist/es2015/DLine.js
CHANGED
|
@@ -217,17 +217,27 @@ export class DLine {
|
|
|
217
217
|
const { begin: { x: x1, y: y1 }, end: { x: x2, y: y2 } } = this;
|
|
218
218
|
return `LINESTRING (${x1} ${y1}, ${x2} ${y2})`;
|
|
219
219
|
}
|
|
220
|
-
movePoint(
|
|
220
|
+
movePoint(i, k) {
|
|
221
|
+
const isArray = Array.isArray(i);
|
|
222
|
+
const p = isArray ? i : [i];
|
|
223
|
+
const d = (isArray ? k : [k]);
|
|
221
224
|
const fi = this.findFi(new DLine(1, 0, 0));
|
|
222
225
|
const td = this.x(new DPoint(1, 1)).distance(this.x(new DPoint(2, 2))) / 2;
|
|
223
226
|
const sinCos = new DPoint(Math.sin(fi), Math.cos(fi));
|
|
224
227
|
const dt = sinCos.clone().scale(td);
|
|
225
|
-
const p1T = p.clone().move(dt.clone().minus());
|
|
226
|
-
const p2T = p.clone().move(dt);
|
|
228
|
+
const p1T = p[0].clone().move(dt.clone().minus());
|
|
229
|
+
const p2T = p[0].clone().move(dt);
|
|
230
|
+
let res = [];
|
|
227
231
|
if (DNumbers.like(this.y(p1T).y, p1T.y) || DNumbers.like(this.y(p2T).y, p2T.y)) {
|
|
228
|
-
|
|
232
|
+
res = p.map((t, index) => t.clone()
|
|
233
|
+
.move(sinCos.clone().scale(d[index])));
|
|
229
234
|
}
|
|
230
|
-
|
|
235
|
+
else {
|
|
236
|
+
res = p.map((t, index) => t.clone()
|
|
237
|
+
.move(sinCos.clone().scale(d[index])
|
|
238
|
+
.setX(({ x }) => -x)));
|
|
239
|
+
}
|
|
240
|
+
return isArray ? res : res[0];
|
|
231
241
|
}
|
|
232
242
|
findFi({ a, b }, delta = 1.0001) {
|
|
233
243
|
const { a: q, b: w } = this;
|
package/dist/es2015/index.js
CHANGED
|
@@ -7,4 +7,4 @@ export * from './FastSearch';
|
|
|
7
7
|
export * from './TraceMatrix';
|
|
8
8
|
export * from './DPolygonLoop';
|
|
9
9
|
export * from './DPlane';
|
|
10
|
-
export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, DGeo } from './utils';
|
|
10
|
+
export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, cartesianProduct, DGeo } from './utils';
|
package/dist/es2015/utils.js
CHANGED
|
@@ -145,3 +145,5 @@ export const createCanvas = (a, b, c) => {
|
|
|
145
145
|
}
|
|
146
146
|
return [canvas, canvas.getContext('2d')];
|
|
147
147
|
};
|
|
148
|
+
const f = (a, b) => [].concat(...a.map((c) => b.map((d) => [].concat(c, d))));
|
|
149
|
+
export const cartesianProduct = (a, b, ...c) => b ? cartesianProduct(f(a, b), ...c) : a;
|
package/dist/esm/DLine.js
CHANGED
|
@@ -259,20 +259,30 @@ var DLine = (function () {
|
|
|
259
259
|
var _a = this, _b = _a.begin, x1 = _b.x, y1 = _b.y, _c = _a.end, x2 = _c.x, y2 = _c.y;
|
|
260
260
|
return "LINESTRING (" + x1 + " " + y1 + ", " + x2 + " " + y2 + ")";
|
|
261
261
|
};
|
|
262
|
-
DLine.prototype.movePoint = function (
|
|
262
|
+
DLine.prototype.movePoint = function (i, k) {
|
|
263
|
+
var isArray = Array.isArray(i);
|
|
264
|
+
var p = isArray ? i : [i];
|
|
265
|
+
var d = (isArray ? k : [k]);
|
|
263
266
|
var fi = this.findFi(new DLine(1, 0, 0));
|
|
264
267
|
var td = this.x(new DPoint(1, 1)).distance(this.x(new DPoint(2, 2))) / 2;
|
|
265
268
|
var sinCos = new DPoint(Math.sin(fi), Math.cos(fi));
|
|
266
269
|
var dt = sinCos.clone().scale(td);
|
|
267
|
-
var p1T = p.clone().move(dt.clone().minus());
|
|
268
|
-
var p2T = p.clone().move(dt);
|
|
270
|
+
var p1T = p[0].clone().move(dt.clone().minus());
|
|
271
|
+
var p2T = p[0].clone().move(dt);
|
|
272
|
+
var res = [];
|
|
269
273
|
if (DNumbers.like(this.y(p1T).y, p1T.y) || DNumbers.like(this.y(p2T).y, p2T.y)) {
|
|
270
|
-
|
|
274
|
+
res = p.map(function (t, index) { return t.clone()
|
|
275
|
+
.move(sinCos.clone().scale(d[index])); });
|
|
271
276
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
277
|
+
else {
|
|
278
|
+
res = p.map(function (t, index) { return t.clone()
|
|
279
|
+
.move(sinCos.clone().scale(d[index])
|
|
280
|
+
.setX(function (_a) {
|
|
281
|
+
var x = _a.x;
|
|
282
|
+
return -x;
|
|
283
|
+
})); });
|
|
284
|
+
}
|
|
285
|
+
return isArray ? res : res[0];
|
|
276
286
|
};
|
|
277
287
|
DLine.prototype.findFi = function (_a, delta) {
|
|
278
288
|
var a = _a.a, b = _a.b;
|
package/dist/esm/index.js
CHANGED
|
@@ -7,4 +7,4 @@ export * from './FastSearch';
|
|
|
7
7
|
export * from './TraceMatrix';
|
|
8
8
|
export * from './DPolygonLoop';
|
|
9
9
|
export * from './DPlane';
|
|
10
|
-
export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, DGeo } from './utils';
|
|
10
|
+
export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, cartesianProduct, DGeo } from './utils';
|
package/dist/esm/utils.js
CHANGED
|
@@ -181,3 +181,11 @@ export var createCanvas = function (a, b, c) {
|
|
|
181
181
|
}
|
|
182
182
|
return [canvas, canvas.getContext('2d')];
|
|
183
183
|
};
|
|
184
|
+
var f = function (a, b) { return [].concat.apply([], __spreadArray([], __read(a.map(function (c) { return b.map(function (d) { return [].concat(c, d); }); })), false)); };
|
|
185
|
+
export var cartesianProduct = function (a, b) {
|
|
186
|
+
var c = [];
|
|
187
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
188
|
+
c[_i - 2] = arguments[_i];
|
|
189
|
+
}
|
|
190
|
+
return b ? cartesianProduct.apply(void 0, __spreadArray([f(a, b)], __read(c), false)) : a;
|
|
191
|
+
};
|