Comparing version 2.2.10 to 2.2.11
@@ -52,5 +52,9 @@ import { DLine } from './DLine'; | ||
rotate(a: number): DPoint; | ||
rotate3dX(a: number): DPoint; | ||
rotate3dY(a: number): DPoint; | ||
rotate3dZ(a: number): DPoint; | ||
move(v: number): DPoint; | ||
move(p: DPoint): DPoint; | ||
move(x: number, y: number): DPoint; | ||
move(x: number, y: number, z: number): DPoint; | ||
degreeToMeters(): DPoint; | ||
@@ -57,0 +61,0 @@ metersToDegree(): DPoint; |
@@ -167,8 +167,30 @@ "use strict"; | ||
} | ||
move(x, y = x) { | ||
rotate3dX(a) { | ||
const { y, z } = this; | ||
this.y = y * Math.cos(a) + z * Math.sin(a); | ||
this.z = -y * Math.sin(a) + z * Math.cos(a); | ||
return this; | ||
} | ||
rotate3dY(a) { | ||
const { x, z } = this; | ||
this.x = x * Math.cos(a) + z * Math.sin(a); | ||
this.z = -x * Math.sin(a) + z * Math.cos(a); | ||
return this; | ||
} | ||
rotate3dZ(a) { | ||
const { x, y } = this; | ||
this.x = x * Math.cos(a) - y * Math.sin(a); | ||
this.y = -x * Math.sin(a) + y * Math.cos(a); | ||
return this; | ||
} | ||
move(x, y = x, z = x) { | ||
let xV = 0; | ||
let yV = 0; | ||
let zV = undefined; | ||
if (x instanceof DPoint) { | ||
xV = this.x + x.x; | ||
yV = this.y + x.y; | ||
if (this.z && x.z) { | ||
zV = this.z + x.z; | ||
} | ||
} | ||
@@ -178,5 +200,11 @@ else { | ||
yV = this.y + y; | ||
if (this.z && z) { | ||
zV = this.z + z; | ||
} | ||
} | ||
this.x = xV; | ||
this.y = yV; | ||
if (zV) { | ||
this.z = zV; | ||
} | ||
return this; | ||
@@ -183,0 +211,0 @@ } |
@@ -57,3 +57,3 @@ /// <reference types="offscreencanvas" /> | ||
static WKT_POLYGON: string; | ||
toWKT(type?: string): string; | ||
toWKT(type?: string, withZ?: boolean): string; | ||
filter(f: (p: DPoint) => boolean): DPolygon; | ||
@@ -60,0 +60,0 @@ map(f: (r: DPoint) => DPoint): DPolygon; |
@@ -329,3 +329,3 @@ "use strict"; | ||
} | ||
toWKT(type = DPolygon.WKT_POLYGON) { | ||
toWKT(type = DPolygon.WKT_POLYGON, withZ = false) { | ||
if (type === DPolygon.WKT_POLYGON) { | ||
@@ -337,6 +337,6 @@ let h = ''; | ||
} | ||
return `POLYGON ((${this.deintersection.pPoints.map((r) => `${r.x} ${r.y}`) | ||
return `POLYGON ((${this.deintersection.pPoints.map((r) => `${r.x} ${r.y}${withZ ? ` ${r.z}` : ''}`) | ||
.join(', ')})${h})`; | ||
} | ||
return `LINESTRING (${this.pPoints.map((r) => `${r.x} ${r.y}`) | ||
return `LINESTRING (${this.pPoints.map((r) => `${r.x} ${r.y}${withZ ? ` ${r.z}` : ''}`) | ||
.join(', ')})`; | ||
@@ -343,0 +343,0 @@ } |
@@ -20,2 +20,5 @@ import { DPolygon } from './DPolygon'; | ||
rotate(a: number): DPolygonLoop; | ||
rotate3dX(a: number): DPolygonLoop; | ||
rotate3dY(a: number): DPolygonLoop; | ||
rotate3dZ(a: number): DPolygonLoop; | ||
move(v: number): DPolygonLoop; | ||
@@ -22,0 +25,0 @@ move(p: DPoint): DPolygonLoop; |
@@ -13,24 +13,27 @@ "use strict"; | ||
LoopFunctions[LoopFunctions["rotate"] = 6] = "rotate"; | ||
LoopFunctions[LoopFunctions["move"] = 7] = "move"; | ||
LoopFunctions[LoopFunctions["round"] = 8] = "round"; | ||
LoopFunctions[LoopFunctions["ceil"] = 9] = "ceil"; | ||
LoopFunctions[LoopFunctions["floor"] = 10] = "floor"; | ||
LoopFunctions[LoopFunctions["toFixed"] = 11] = "toFixed"; | ||
LoopFunctions[LoopFunctions["abs"] = 12] = "abs"; | ||
LoopFunctions[LoopFunctions["scale"] = 13] = "scale"; | ||
LoopFunctions[LoopFunctions["divide"] = 14] = "divide"; | ||
LoopFunctions[LoopFunctions["degreeToRadians"] = 15] = "degreeToRadians"; | ||
LoopFunctions[LoopFunctions["radiansToDegrees"] = 16] = "radiansToDegrees"; | ||
LoopFunctions[LoopFunctions["radiansToMeters"] = 17] = "radiansToMeters"; | ||
LoopFunctions[LoopFunctions["metersToRadians"] = 18] = "metersToRadians"; | ||
LoopFunctions[LoopFunctions["hipPoint"] = 19] = "hipPoint"; | ||
LoopFunctions[LoopFunctions["xPoint"] = 20] = "xPoint"; | ||
LoopFunctions[LoopFunctions["yPoint"] = 21] = "yPoint"; | ||
LoopFunctions[LoopFunctions["wPoint"] = 22] = "wPoint"; | ||
LoopFunctions[LoopFunctions["hPoint"] = 23] = "hPoint"; | ||
LoopFunctions[LoopFunctions["setIfLessThan"] = 24] = "setIfLessThan"; | ||
LoopFunctions[LoopFunctions["minus"] = 25] = "minus"; | ||
LoopFunctions[LoopFunctions["degreeToMeters"] = 26] = "degreeToMeters"; | ||
LoopFunctions[LoopFunctions["metersToDegree"] = 27] = "metersToDegree"; | ||
LoopFunctions[LoopFunctions["flipVertically"] = 28] = "flipVertically"; | ||
LoopFunctions[LoopFunctions["rotate3dX"] = 7] = "rotate3dX"; | ||
LoopFunctions[LoopFunctions["rotate3dY"] = 8] = "rotate3dY"; | ||
LoopFunctions[LoopFunctions["rotate3dZ"] = 9] = "rotate3dZ"; | ||
LoopFunctions[LoopFunctions["move"] = 10] = "move"; | ||
LoopFunctions[LoopFunctions["round"] = 11] = "round"; | ||
LoopFunctions[LoopFunctions["ceil"] = 12] = "ceil"; | ||
LoopFunctions[LoopFunctions["floor"] = 13] = "floor"; | ||
LoopFunctions[LoopFunctions["toFixed"] = 14] = "toFixed"; | ||
LoopFunctions[LoopFunctions["abs"] = 15] = "abs"; | ||
LoopFunctions[LoopFunctions["scale"] = 16] = "scale"; | ||
LoopFunctions[LoopFunctions["divide"] = 17] = "divide"; | ||
LoopFunctions[LoopFunctions["degreeToRadians"] = 18] = "degreeToRadians"; | ||
LoopFunctions[LoopFunctions["radiansToDegrees"] = 19] = "radiansToDegrees"; | ||
LoopFunctions[LoopFunctions["radiansToMeters"] = 20] = "radiansToMeters"; | ||
LoopFunctions[LoopFunctions["metersToRadians"] = 21] = "metersToRadians"; | ||
LoopFunctions[LoopFunctions["hipPoint"] = 22] = "hipPoint"; | ||
LoopFunctions[LoopFunctions["xPoint"] = 23] = "xPoint"; | ||
LoopFunctions[LoopFunctions["yPoint"] = 24] = "yPoint"; | ||
LoopFunctions[LoopFunctions["wPoint"] = 25] = "wPoint"; | ||
LoopFunctions[LoopFunctions["hPoint"] = 26] = "hPoint"; | ||
LoopFunctions[LoopFunctions["setIfLessThan"] = 27] = "setIfLessThan"; | ||
LoopFunctions[LoopFunctions["minus"] = 28] = "minus"; | ||
LoopFunctions[LoopFunctions["degreeToMeters"] = 29] = "degreeToMeters"; | ||
LoopFunctions[LoopFunctions["metersToDegree"] = 30] = "metersToDegree"; | ||
LoopFunctions[LoopFunctions["flipVertically"] = 31] = "flipVertically"; | ||
})(LoopFunctions || (LoopFunctions = {})); | ||
@@ -68,2 +71,14 @@ const decodePoolRecord = (a, { functionName, pointArg, numberPointArg, numberArg, setterArg }) => { | ||
break; | ||
case LoopFunctions.rotate3dX: | ||
res = (k) => a(k) | ||
.rotate3dX(numberArg); | ||
break; | ||
case LoopFunctions.rotate3dY: | ||
res = (k) => a(k) | ||
.rotate3dY(numberArg); | ||
break; | ||
case LoopFunctions.rotate3dZ: | ||
res = (k) => a(k) | ||
.rotate3dZ(numberArg); | ||
break; | ||
case LoopFunctions.move: | ||
@@ -220,2 +235,23 @@ res = (k) => a(k) | ||
} | ||
rotate3dX(a) { | ||
this.pool.push({ | ||
functionName: LoopFunctions.rotate3dX, | ||
numberArg: a | ||
}); | ||
return this; | ||
} | ||
rotate3dY(a) { | ||
this.pool.push({ | ||
functionName: LoopFunctions.rotate3dY, | ||
numberArg: a | ||
}); | ||
return this; | ||
} | ||
rotate3dZ(a) { | ||
this.pool.push({ | ||
functionName: LoopFunctions.rotate3dZ, | ||
numberArg: a | ||
}); | ||
return this; | ||
} | ||
move(x, y = x) { | ||
@@ -222,0 +258,0 @@ this.pool.push({ |
@@ -9,4 +9,5 @@ export * from './DCircle'; | ||
export * from './DPolygonLoop'; | ||
export * from './DPlane'; | ||
export declare const DGeo: { | ||
DEBUG: boolean; | ||
}; |
@@ -22,4 +22,5 @@ "use strict"; | ||
__exportStar(require("./DPolygonLoop"), exports); | ||
__exportStar(require("./DPlane"), exports); | ||
exports.DGeo = { | ||
DEBUG: false | ||
}; |
@@ -16,2 +16,4 @@ import { DPoint } from './DPoint'; | ||
export declare const createArray: (v: number) => number[]; | ||
export declare const createMatrix: ({ h, w }: DPoint) => number[][]; | ||
export declare const gaussianElimination: (matrix: number[][]) => number[]; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createArray = exports.checkFunction = exports.warn = void 0; | ||
exports.gaussianElimination = exports.createMatrix = exports.createArray = exports.checkFunction = exports.warn = void 0; | ||
const index_1 = require("./index"); | ||
@@ -68,1 +68,47 @@ const DPoint_1 = require("./DPoint"); | ||
exports.createArray = createArray; | ||
const createMatrix = ({ h, w }) => (0, exports.createArray)(h).map(() => (0, exports.createArray)(w)); | ||
exports.createMatrix = createMatrix; | ||
const GAUSSIAN_ELIMINATION_MIN = 1e-10; | ||
const gaussianElimination = (matrix) => { | ||
const n = matrix.length; | ||
const matrixClone = (0, exports.createMatrix)(new DPoint_1.DPoint(n + 1, n)); | ||
for (let i = 0; i < n; i++) { | ||
for (let j = 0; j < n + 1; j++) { | ||
matrix[i][j] = matrix[i][j] === 0 ? GAUSSIAN_ELIMINATION_MIN : matrix[i][j]; | ||
matrixClone[i][j] = matrix[i][j]; | ||
} | ||
} | ||
for (let k = 0; k < n; k++) { | ||
for (let i = 0; i < n + 1; i++) { | ||
matrixClone[k][i] /= matrix[k][k]; | ||
} | ||
for (let i = k + 1; i < n; i++) { | ||
const K = matrixClone[i][k] / matrixClone[k][k]; | ||
for (let j = 0; j < n + 1; j++) { | ||
matrixClone[i][j] -= matrixClone[k][j] * K; | ||
} | ||
} | ||
for (let i = 0; i < n; i++) { | ||
for (let j = 0; j < n + 1; j++) { | ||
matrix[i][j] = matrixClone[i][j]; | ||
} | ||
} | ||
} | ||
for (let k = n - 1; k > -1; k--) { | ||
for (let i = n; i > -1; i--) { | ||
matrixClone[k][i] /= matrix[k][k]; | ||
} | ||
for (let i = k - 1; i > -1; i--) { | ||
const K = matrixClone[i][k] / matrixClone[k][k]; | ||
for (let j = n; j > -1; j--) { | ||
matrixClone[i][j] -= matrixClone[k][j] * K; | ||
} | ||
} | ||
} | ||
const answer = (0, exports.createArray)(n); | ||
for (let i = 0; i < n; i++) { | ||
answer[i] = matrixClone[i][n]; | ||
} | ||
return answer; | ||
}; | ||
exports.gaussianElimination = gaussianElimination; |
{ | ||
"name": "dgeoutils", | ||
"version": "2.2.10", | ||
"version": "2.2.11", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "scripts": { |
104510
24
3018