geometrix 1.0.6 → 1.0.8
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/index.d.ts +43 -5
- package/dist/index.js +252 -23
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -294,21 +294,39 @@ declare class PaxPath {
|
|
|
294
294
|
}
|
|
295
295
|
declare function paxPath(): PaxPath;
|
|
296
296
|
|
|
297
|
+
interface tEnvelop {
|
|
298
|
+
xMin: number;
|
|
299
|
+
xMax: number;
|
|
300
|
+
yMin: number;
|
|
301
|
+
yMax: number;
|
|
302
|
+
orientation: boolean;
|
|
303
|
+
}
|
|
304
|
+
declare class Envelop {
|
|
305
|
+
/** @internal */
|
|
306
|
+
pEnvelop: tEnvelop;
|
|
307
|
+
constructor(iEnvelop: tEnvelop);
|
|
308
|
+
add(iEnvelop: tEnvelop): boolean;
|
|
309
|
+
check(iEnvelop: tEnvelop): boolean;
|
|
310
|
+
}
|
|
311
|
+
declare function envelop(iEnvelop: tEnvelop): Envelop;
|
|
312
|
+
|
|
297
313
|
declare abstract class AContour {
|
|
298
314
|
abstract circle: boolean;
|
|
299
315
|
abstract imposedColor: string;
|
|
300
316
|
abstract draw(ctx: CanvasRenderingContext2D, cAdjust: tCanvasAdjust, color: string): void;
|
|
301
317
|
abstract extractSkeleton(): AContour;
|
|
302
318
|
abstract generateContour(): AContour;
|
|
303
|
-
abstract generatePoints(): Point[];
|
|
319
|
+
abstract generatePoints(dnb: number): Point[];
|
|
320
|
+
abstract getEnvelop(): tEnvelop;
|
|
304
321
|
abstract generateLines(): Line[];
|
|
305
322
|
abstract check(): string;
|
|
306
323
|
abstract toSvg(yCeiling: number, color?: string): string;
|
|
307
324
|
abstract toDxfSeg(): DxfSeg[];
|
|
308
325
|
abstract toPax(): tPaxContour;
|
|
309
326
|
abstract getPerimeter(): number;
|
|
327
|
+
abstract generateRevertOrientation(): AContour;
|
|
310
328
|
}
|
|
311
|
-
declare function midArcPoint(px1: number, py1: number, seg: Segment1): Point;
|
|
329
|
+
declare function midArcPoint(px1: number, py1: number, seg: Segment1, dnb: number): Point[];
|
|
312
330
|
/**
|
|
313
331
|
* class `Contour`
|
|
314
332
|
*
|
|
@@ -365,7 +383,9 @@ declare class Contour extends AContour {
|
|
|
365
383
|
draw(ctx: CanvasRenderingContext2D, cAdjust: tCanvasAdjust, color?: string): void;
|
|
366
384
|
extractSkeleton(): Contour;
|
|
367
385
|
generateContour(): Contour;
|
|
368
|
-
generatePoints(): Point[];
|
|
386
|
+
generatePoints(dnb: number): Point[];
|
|
387
|
+
getOrientation(iPts: Point[], extremX: number): boolean;
|
|
388
|
+
getEnvelop(): tEnvelop;
|
|
369
389
|
generateLines(): Line[];
|
|
370
390
|
/** @internal */
|
|
371
391
|
checkContour(ctr: Contour): void;
|
|
@@ -374,6 +394,7 @@ declare class Contour extends AContour {
|
|
|
374
394
|
toDxfSeg(): DxfSeg[];
|
|
375
395
|
toPax(): tPaxContourPath;
|
|
376
396
|
getPerimeter(): number;
|
|
397
|
+
generateRevertOrientation(): Contour;
|
|
377
398
|
}
|
|
378
399
|
/**
|
|
379
400
|
* class `ContourCircle`
|
|
@@ -394,13 +415,15 @@ declare class ContourCircle extends AContour {
|
|
|
394
415
|
draw(ctx: CanvasRenderingContext2D, cAdjust: tCanvasAdjust, color?: string): void;
|
|
395
416
|
extractSkeleton(): ContourCircle;
|
|
396
417
|
generateContour(): ContourCircle;
|
|
397
|
-
generatePoints(): Point[];
|
|
418
|
+
generatePoints(dnb: number): Point[];
|
|
419
|
+
getEnvelop(): tEnvelop;
|
|
398
420
|
generateLines(): Line[];
|
|
399
421
|
check(): string;
|
|
400
422
|
toSvg(yCeiling: number, color?: string): string;
|
|
401
423
|
toDxfSeg(): DxfSeg[];
|
|
402
424
|
toPax(): tPaxContourCircle;
|
|
403
425
|
getPerimeter(): number;
|
|
426
|
+
generateRevertOrientation(): ContourCircle;
|
|
404
427
|
}
|
|
405
428
|
declare function contour(ix: number, iy: number, icolor?: string): Contour;
|
|
406
429
|
declare function contourCircle(ix: number, iy: number, iRadius: number, icolor?: string): ContourCircle;
|
|
@@ -634,6 +657,21 @@ interface tParamValInFile {
|
|
|
634
657
|
declare function createParamFile(lastModif: string, iPartName: string, idparams: tParamVal, comment: string): string;
|
|
635
658
|
declare function parseParamFile(fContentStr: string): [tParamValInFile, string];
|
|
636
659
|
|
|
660
|
+
type tVec2 = [number, number];
|
|
661
|
+
type tVec3$1 = [number, number, number];
|
|
662
|
+
type tT2dMatrix = [tVec3$1, tVec3$1, tVec3$1];
|
|
663
|
+
declare class Transform2d {
|
|
664
|
+
mmat: tT2dMatrix;
|
|
665
|
+
constructor(iMat: tT2dMatrix);
|
|
666
|
+
addRotation(az: number): this;
|
|
667
|
+
addTranslation(ax: number, ay: number): this;
|
|
668
|
+
getMatrix(): tT2dMatrix;
|
|
669
|
+
getRotation(): number;
|
|
670
|
+
getTranslation(): tVec2;
|
|
671
|
+
transform(iv: tVec2): tVec2;
|
|
672
|
+
}
|
|
673
|
+
declare function transform2d(initM?: tT2dMatrix): Transform2d;
|
|
674
|
+
|
|
637
675
|
type tVec3 = [number, number, number];
|
|
638
676
|
type tVec4 = [number, number, number, number];
|
|
639
677
|
type tT3dMatrix = [tVec4, tVec4, tVec4, tVec4];
|
|
@@ -687,4 +725,4 @@ declare function version_details(appPackage: tPackage): string[];
|
|
|
687
725
|
|
|
688
726
|
declare function checkImpPages(pages: tAllPageDef): [boolean, string];
|
|
689
727
|
|
|
690
|
-
export { Contour, ContourCircle, DesignParam, DxfSeg, DxfWrite, EBVolume, EExtrude, EFormat, Figure, Line, PSeg, PType, PaxPath, Point, SegDbg, SegEnum, Segment1, Segment2, ShapePoint, Transform3d, Vector, aBFromLaLbAa, aCFromAaAb, aCFromLaLbLc, adjustCenter, adjustCopy, adjustInit, adjustMini, adjustRect, adjustScale, adjustTranslate, adjustZero, arcSeg1To2, arcSeg2To1, bisector, canvas2point, canvasTranslatePolar, checkGeom, checkImpPages, circleCenter, colors, contour, contourCircle, copyLayers, createParamFile, ctrOblong, ctrRectRot, ctrRectRot2, ctrRectangle, ctrTrapezoid, ctrTrapezoidRot2, degToRad, designParam, dxfSegArc, dxfSegCircle, dxfSegLine, dxfWriter, ffix, figure, fileBin, fileBinContent, fileMime, fileSuffix, fileTextContent, fround, gSegDbg, initGeom, initLayers, isActiveCorner, isAddPoint, isCorner, isSeg, isWithin, lbFromLaAaAb, lcFromLaLbAc, line, linePP, makeCorner, mergeFaces, midArcPoint, oneDesignParam, orientedArc, pCheckbox, pDropdown, pNumber, pSectionSeparator, paramListToVal, parseParamFile, paxCircle, paxPath, point, point2canvas, pointCoord, pointMinMax, prefixLog, radToDeg, radius2canvas, rightTriLaFromLbLc, rightTriLbFromLaLc, roundZero, type tAffine, type tAllLink, type tAllPageDef, type tBVolume, type tCanvasAdjust, type tCartesian, type tContour, type tDependencies, type tDesignParamList, type tDesignParamOne, type tExtrude, type tFigures, type tGeom, type tGeomFunc, type tInherit, type tLayers, type tOuterInner, type tPackage, type tPageDef, type tParam, type tParamChanged, type tParamDef, type tParamVal, type tParamValInFile, type tPaxContour, type tPaxContourCircle, type tPaxContourPath, type tPaxFace, type tPaxSeg, type tPaxSegArc, type tPaxSegSt, type tPolar, type tPosiOrien, type tSimTime, type tSubDesign, type tSubInst, type tT3dMatrix, type tVec3, type tVec4, type tVolume, tolerance, transform3d, vector, version_details, withinHPiHPi, withinPiPi, withinZero2Pi, withinZeroPi, zeroPDef };
|
|
728
|
+
export { Contour, ContourCircle, DesignParam, DxfSeg, DxfWrite, EBVolume, EExtrude, EFormat, Figure, Line, PSeg, PType, PaxPath, Point, SegDbg, SegEnum, Segment1, Segment2, ShapePoint, Transform2d, Transform3d, Vector, aBFromLaLbAa, aCFromAaAb, aCFromLaLbLc, adjustCenter, adjustCopy, adjustInit, adjustMini, adjustRect, adjustScale, adjustTranslate, adjustZero, arcSeg1To2, arcSeg2To1, bisector, canvas2point, canvasTranslatePolar, checkGeom, checkImpPages, circleCenter, colors, contour, contourCircle, copyLayers, createParamFile, ctrOblong, ctrRectRot, ctrRectRot2, ctrRectangle, ctrTrapezoid, ctrTrapezoidRot2, degToRad, designParam, dxfSegArc, dxfSegCircle, dxfSegLine, dxfWriter, envelop, ffix, figure, fileBin, fileBinContent, fileMime, fileSuffix, fileTextContent, fround, gSegDbg, initGeom, initLayers, isActiveCorner, isAddPoint, isCorner, isSeg, isWithin, lbFromLaAaAb, lcFromLaLbAc, line, linePP, makeCorner, mergeFaces, midArcPoint, oneDesignParam, orientedArc, pCheckbox, pDropdown, pNumber, pSectionSeparator, paramListToVal, parseParamFile, paxCircle, paxPath, point, point2canvas, pointCoord, pointMinMax, prefixLog, radToDeg, radius2canvas, rightTriLaFromLbLc, rightTriLbFromLaLc, roundZero, type tAffine, type tAllLink, type tAllPageDef, type tBVolume, type tCanvasAdjust, type tCartesian, type tContour, type tDependencies, type tDesignParamList, type tDesignParamOne, type tEnvelop, type tExtrude, type tFigures, type tGeom, type tGeomFunc, type tInherit, type tLayers, type tOuterInner, type tPackage, type tPageDef, type tParam, type tParamChanged, type tParamDef, type tParamVal, type tParamValInFile, type tPaxContour, type tPaxContourCircle, type tPaxContourPath, type tPaxFace, type tPaxSeg, type tPaxSegArc, type tPaxSegSt, type tPolar, type tPosiOrien, type tSimTime, type tSubDesign, type tSubInst, type tT2dMatrix, type tT3dMatrix, type tVec2, type tVec3, type tVec4, type tVolume, tolerance, transform2d, transform3d, vector, version_details, withinHPiHPi, withinPiPi, withinZero2Pi, withinZeroPi, zeroPDef };
|
package/dist/index.js
CHANGED
|
@@ -1704,16 +1704,17 @@ function paxPath() {
|
|
|
1704
1704
|
// src/contour.ts
|
|
1705
1705
|
var AContour = class {
|
|
1706
1706
|
};
|
|
1707
|
-
function midArcPoint(px1, py1, seg) {
|
|
1707
|
+
function midArcPoint(px1, py1, seg, dnb) {
|
|
1708
1708
|
const seg2 = arcSeg1To2(px1, py1, seg);
|
|
1709
1709
|
const p3 = point(seg2.pc.cx, seg2.pc.cy);
|
|
1710
|
-
const a12h =
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1710
|
+
const a12h = withinZero2Pi(seg2.a2 - seg2.a1);
|
|
1711
|
+
const a12g = seg.arcCcw ? a12h : a12h - 2 * Math.PI;
|
|
1712
|
+
const a12f = a12g / dnb;
|
|
1713
|
+
const rPts = [];
|
|
1714
|
+
for (let idx = 1; idx < dnb; idx++) {
|
|
1715
|
+
rPts.push(p3.translatePolar(seg2.a1 + idx * a12f, seg.radius));
|
|
1714
1716
|
}
|
|
1715
|
-
|
|
1716
|
-
return p4;
|
|
1717
|
+
return rPts;
|
|
1717
1718
|
}
|
|
1718
1719
|
var Contour = class _Contour extends AContour {
|
|
1719
1720
|
/** @internal */
|
|
@@ -2245,18 +2246,15 @@ var Contour = class _Contour extends AContour {
|
|
|
2245
2246
|
}
|
|
2246
2247
|
return rContour;
|
|
2247
2248
|
}
|
|
2248
|
-
generatePoints() {
|
|
2249
|
+
generatePoints(dnb) {
|
|
2249
2250
|
const rPoints = [];
|
|
2250
|
-
rPoints.push(...this.debugPoints);
|
|
2251
|
-
const seg0 = this.segments[0];
|
|
2252
|
-
rPoints.push(point(seg0.px, seg0.py));
|
|
2253
2251
|
let px1 = 0;
|
|
2254
2252
|
let py1 = 0;
|
|
2255
2253
|
for (const seg of this.segments) {
|
|
2256
2254
|
if (seg.sType === 1 /* eArc */) {
|
|
2257
2255
|
try {
|
|
2258
|
-
const
|
|
2259
|
-
rPoints.push(
|
|
2256
|
+
const pts = midArcPoint(px1, py1, seg, dnb);
|
|
2257
|
+
rPoints.push(...pts);
|
|
2260
2258
|
} catch (emsg) {
|
|
2261
2259
|
console.log("err453: " + emsg);
|
|
2262
2260
|
}
|
|
@@ -2269,6 +2267,50 @@ var Contour = class _Contour extends AContour {
|
|
|
2269
2267
|
}
|
|
2270
2268
|
return rPoints;
|
|
2271
2269
|
}
|
|
2270
|
+
getOrientation(iPts, extremX) {
|
|
2271
|
+
const pts = iPts.slice(1);
|
|
2272
|
+
let sign = 0;
|
|
2273
|
+
let pt1 = pts.at(-3);
|
|
2274
|
+
let pt2 = pts.at(-2);
|
|
2275
|
+
let pt3 = pts.at(-1);
|
|
2276
|
+
for (const pt of pts) {
|
|
2277
|
+
pt1 = pt2;
|
|
2278
|
+
pt2 = pt3;
|
|
2279
|
+
pt3 = pt;
|
|
2280
|
+
if (pt2.cx === extremX) {
|
|
2281
|
+
const vx = pt1.cx - pt2.cx;
|
|
2282
|
+
const vy = pt1.cy - pt2.cy;
|
|
2283
|
+
const ux = pt3.cx - pt2.cx;
|
|
2284
|
+
const uy = pt3.cy - pt2.cy;
|
|
2285
|
+
const pv = ux * vy - uy * vx;
|
|
2286
|
+
sign = Math.sign(pv);
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
if (0 === sign) {
|
|
2290
|
+
throw `err299: Orientation hasn't been found with point number ${pts.length}`;
|
|
2291
|
+
}
|
|
2292
|
+
const rOrientation = sign > 0 ? true : false;
|
|
2293
|
+
return rOrientation;
|
|
2294
|
+
}
|
|
2295
|
+
getEnvelop() {
|
|
2296
|
+
const pts = this.generatePoints(24);
|
|
2297
|
+
const lx = [];
|
|
2298
|
+
const ly = [];
|
|
2299
|
+
for (const pt of pts) {
|
|
2300
|
+
lx.push(pt.cx);
|
|
2301
|
+
ly.push(pt.cy);
|
|
2302
|
+
}
|
|
2303
|
+
const rXmin = Math.min(...lx);
|
|
2304
|
+
const rXmax = Math.max(...lx);
|
|
2305
|
+
const rYmin = Math.min(...ly);
|
|
2306
|
+
const rYmax = Math.max(...ly);
|
|
2307
|
+
const rOrientation = this.getOrientation(pts, rXmin);
|
|
2308
|
+
const orient2 = this.getOrientation(pts, rXmax);
|
|
2309
|
+
if (orient2 !== rOrientation) {
|
|
2310
|
+
throw `err390: orientation unstable ${rOrientation} ${orient2} with ${pts.length} points`;
|
|
2311
|
+
}
|
|
2312
|
+
return { xMin: rXmin, xMax: rXmax, yMin: rYmin, yMax: rYmax, orientation: rOrientation };
|
|
2313
|
+
}
|
|
2272
2314
|
generateLines() {
|
|
2273
2315
|
const rLines = [];
|
|
2274
2316
|
rLines.push(...this.debugLines);
|
|
@@ -2391,6 +2433,16 @@ var Contour = class _Contour extends AContour {
|
|
|
2391
2433
|
}
|
|
2392
2434
|
return rPerimeter;
|
|
2393
2435
|
}
|
|
2436
|
+
generateRevertOrientation() {
|
|
2437
|
+
const seg0 = this.segments[0];
|
|
2438
|
+
const rContour = new _Contour(seg0.px, seg0.py);
|
|
2439
|
+
for (const seg of this.segments) {
|
|
2440
|
+
if (isSeg(seg.sType)) {
|
|
2441
|
+
rContour.addSeg(seg);
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
return rContour;
|
|
2445
|
+
}
|
|
2394
2446
|
};
|
|
2395
2447
|
var ContourCircle = class _ContourCircle extends AContour {
|
|
2396
2448
|
circle = true;
|
|
@@ -2443,16 +2495,26 @@ var ContourCircle = class _ContourCircle extends AContour {
|
|
|
2443
2495
|
const rContour = new _ContourCircle(this.px, this.py, this.radius, this.imposedColor);
|
|
2444
2496
|
return rContour;
|
|
2445
2497
|
}
|
|
2446
|
-
generatePoints() {
|
|
2498
|
+
generatePoints(dnb) {
|
|
2447
2499
|
const rPoints = [];
|
|
2448
2500
|
const p1 = point(this.px, this.py);
|
|
2501
|
+
const kp = dnb * 2;
|
|
2449
2502
|
rPoints.push(p1);
|
|
2450
|
-
for (let i = 0; i <
|
|
2451
|
-
const p2 = p1.translatePolar(i * Math.PI /
|
|
2503
|
+
for (let i = 0; i < kp; i++) {
|
|
2504
|
+
const p2 = p1.translatePolar(i * 2 * Math.PI / kp, this.radius);
|
|
2452
2505
|
rPoints.push(p2);
|
|
2453
2506
|
}
|
|
2454
2507
|
return rPoints;
|
|
2455
2508
|
}
|
|
2509
|
+
getEnvelop() {
|
|
2510
|
+
return {
|
|
2511
|
+
xMin: this.px - this.radius,
|
|
2512
|
+
xMax: this.px + this.radius,
|
|
2513
|
+
yMin: this.py - this.radius,
|
|
2514
|
+
yMax: this.py + this.radius,
|
|
2515
|
+
orientation: true
|
|
2516
|
+
};
|
|
2517
|
+
}
|
|
2456
2518
|
generateLines() {
|
|
2457
2519
|
return [];
|
|
2458
2520
|
}
|
|
@@ -2476,6 +2538,10 @@ var ContourCircle = class _ContourCircle extends AContour {
|
|
|
2476
2538
|
const rPerimeter = 2 * Math.PI * this.radius;
|
|
2477
2539
|
return rPerimeter;
|
|
2478
2540
|
}
|
|
2541
|
+
generateRevertOrientation() {
|
|
2542
|
+
const rContour = new _ContourCircle(this.px, this.py, this.radius, this.imposedColor);
|
|
2543
|
+
return rContour;
|
|
2544
|
+
}
|
|
2479
2545
|
};
|
|
2480
2546
|
function contour(ix, iy, icolor = "") {
|
|
2481
2547
|
return new Contour(ix, iy, icolor);
|
|
@@ -2537,7 +2603,7 @@ var Figure = class _Figure {
|
|
|
2537
2603
|
const oneFace = [];
|
|
2538
2604
|
for (const oneCtr of iFace) {
|
|
2539
2605
|
const roundedContour = oneCtr.generateContour();
|
|
2540
|
-
this.addPoints(roundedContour.generatePoints());
|
|
2606
|
+
this.addPoints(roundedContour.generatePoints(2));
|
|
2541
2607
|
this.addLines(roundedContour.generateLines());
|
|
2542
2608
|
oneFace.push(roundedContour);
|
|
2543
2609
|
this.mainBList.push(oneCtr.extractSkeleton());
|
|
@@ -2554,13 +2620,13 @@ var Figure = class _Figure {
|
|
|
2554
2620
|
}
|
|
2555
2621
|
addSecond(icontour) {
|
|
2556
2622
|
const roundedContour = icontour.generateContour();
|
|
2557
|
-
this.addPoints(roundedContour.generatePoints());
|
|
2623
|
+
this.addPoints(roundedContour.generatePoints(2));
|
|
2558
2624
|
this.addLines(roundedContour.generateLines());
|
|
2559
2625
|
this.secondList.push(roundedContour);
|
|
2560
2626
|
this.secondBList.push(icontour.extractSkeleton());
|
|
2561
2627
|
}
|
|
2562
2628
|
addDynamics(icontour) {
|
|
2563
|
-
this.addPoints(icontour.generatePoints());
|
|
2629
|
+
this.addPoints(icontour.generatePoints(2));
|
|
2564
2630
|
this.addLines(icontour.generateLines());
|
|
2565
2631
|
this.dynamicsList.push(icontour);
|
|
2566
2632
|
}
|
|
@@ -3786,7 +3852,7 @@ function fcFaceContour(paxCtr, outName) {
|
|
|
3786
3852
|
} else if (seg.typ === 2 /* eArc */) {
|
|
3787
3853
|
try {
|
|
3788
3854
|
const seg1 = convPaxToSeg1(seg);
|
|
3789
|
-
const p4 = midArcPoint(px1, py1, seg1);
|
|
3855
|
+
const p4 = midArcPoint(px1, py1, seg1, 2)[0];
|
|
3790
3856
|
rStr += ` P${fid3(pIdx)} = App.Vector(${ff6(p4.cx)}, ${ff6(p4.cy)}, 0)
|
|
3791
3857
|
`;
|
|
3792
3858
|
pIdx += 1;
|
|
@@ -4089,7 +4155,7 @@ var MinMaxPoint = class {
|
|
|
4089
4155
|
pts.push(point(this.xMax, this.yMax));
|
|
4090
4156
|
}
|
|
4091
4157
|
for (const ctr of aCtr) {
|
|
4092
|
-
pts.push(...ctr.generatePoints());
|
|
4158
|
+
pts.push(...ctr.generatePoints(2));
|
|
4093
4159
|
}
|
|
4094
4160
|
const [Xmin, Xmax, Ymin, Ymax] = pointMinMax(pts);
|
|
4095
4161
|
this.xMin = Xmin;
|
|
@@ -4417,6 +4483,166 @@ function parseParamFile(fContentStr) {
|
|
|
4417
4483
|
return [rObj, rlog];
|
|
4418
4484
|
}
|
|
4419
4485
|
|
|
4486
|
+
// src/envelop.ts
|
|
4487
|
+
var Envelop = class {
|
|
4488
|
+
/** @internal */
|
|
4489
|
+
pEnvelop = { xMin: 0, xMax: 0, yMin: 0, yMax: 0, orientation: true };
|
|
4490
|
+
constructor(iEnvelop) {
|
|
4491
|
+
this.pEnvelop.xMin = iEnvelop.xMin;
|
|
4492
|
+
this.pEnvelop.xMax = iEnvelop.xMax;
|
|
4493
|
+
this.pEnvelop.yMin = iEnvelop.yMin;
|
|
4494
|
+
this.pEnvelop.yMax = iEnvelop.yMax;
|
|
4495
|
+
this.pEnvelop.orientation = iEnvelop.orientation;
|
|
4496
|
+
}
|
|
4497
|
+
add(iEnvelop) {
|
|
4498
|
+
let rChange = false;
|
|
4499
|
+
if (iEnvelop.xMin < this.pEnvelop.xMin) {
|
|
4500
|
+
rChange = true;
|
|
4501
|
+
this.pEnvelop.xMin = iEnvelop.xMin;
|
|
4502
|
+
this.pEnvelop.orientation = iEnvelop.orientation;
|
|
4503
|
+
}
|
|
4504
|
+
if (iEnvelop.xMax > this.pEnvelop.xMax) {
|
|
4505
|
+
this.pEnvelop.xMax = iEnvelop.xMax;
|
|
4506
|
+
}
|
|
4507
|
+
if (iEnvelop.yMin < this.pEnvelop.yMin) {
|
|
4508
|
+
this.pEnvelop.yMin = iEnvelop.yMin;
|
|
4509
|
+
}
|
|
4510
|
+
if (iEnvelop.yMax > this.pEnvelop.yMax) {
|
|
4511
|
+
this.pEnvelop.yMax = iEnvelop.yMax;
|
|
4512
|
+
}
|
|
4513
|
+
return rChange;
|
|
4514
|
+
}
|
|
4515
|
+
check(iEnvelop) {
|
|
4516
|
+
let rOk = false;
|
|
4517
|
+
const epsilon = 10 ** -2;
|
|
4518
|
+
if (iEnvelop.xMin < this.pEnvelop.xMin + epsilon && iEnvelop.xMax > this.pEnvelop.xMax - epsilon && iEnvelop.yMin < this.pEnvelop.yMin + epsilon && iEnvelop.yMax > this.pEnvelop.yMax - epsilon) {
|
|
4519
|
+
rOk = true;
|
|
4520
|
+
}
|
|
4521
|
+
return rOk;
|
|
4522
|
+
}
|
|
4523
|
+
};
|
|
4524
|
+
function envelop(iEnvelop) {
|
|
4525
|
+
return new Envelop(iEnvelop);
|
|
4526
|
+
}
|
|
4527
|
+
|
|
4528
|
+
// src/transform2d.ts
|
|
4529
|
+
function t2dInitNull() {
|
|
4530
|
+
const rM = [
|
|
4531
|
+
[0, 0, 0],
|
|
4532
|
+
[0, 0, 0],
|
|
4533
|
+
[0, 0, 0]
|
|
4534
|
+
];
|
|
4535
|
+
return rM;
|
|
4536
|
+
}
|
|
4537
|
+
function t2dInitIdentity() {
|
|
4538
|
+
const rM = [
|
|
4539
|
+
[1, 0, 0],
|
|
4540
|
+
[0, 1, 0],
|
|
4541
|
+
[0, 0, 1]
|
|
4542
|
+
];
|
|
4543
|
+
return rM;
|
|
4544
|
+
}
|
|
4545
|
+
function t2dRotate(az) {
|
|
4546
|
+
const rM = t2dInitIdentity();
|
|
4547
|
+
const cos = Math.cos(az);
|
|
4548
|
+
const sin = Math.sin(az);
|
|
4549
|
+
rM[0][0] = cos;
|
|
4550
|
+
rM[1][1] = cos;
|
|
4551
|
+
rM[0][1] = -sin;
|
|
4552
|
+
rM[1][0] = sin;
|
|
4553
|
+
return rM;
|
|
4554
|
+
}
|
|
4555
|
+
function t2dMatMultiply(ma, mb) {
|
|
4556
|
+
const rM = t2dInitNull();
|
|
4557
|
+
for (let i = 0; i < 3; i++) {
|
|
4558
|
+
for (let j = 0; j < 3; j++) {
|
|
4559
|
+
let t = 0;
|
|
4560
|
+
for (let k = 0; k < 3; k++) {
|
|
4561
|
+
t += ma[i][k] * mb[k][j];
|
|
4562
|
+
}
|
|
4563
|
+
rM[i][j] = t;
|
|
4564
|
+
}
|
|
4565
|
+
}
|
|
4566
|
+
return rM;
|
|
4567
|
+
}
|
|
4568
|
+
function t2dCombine(tM) {
|
|
4569
|
+
let rM = t2dInitIdentity();
|
|
4570
|
+
for (const tmi of tM) {
|
|
4571
|
+
rM = t2dMatMultiply(tmi, rM);
|
|
4572
|
+
}
|
|
4573
|
+
return rM;
|
|
4574
|
+
}
|
|
4575
|
+
function t2dTranslate(ax, ay) {
|
|
4576
|
+
const rM = t2dInitIdentity();
|
|
4577
|
+
rM[0][2] = ax;
|
|
4578
|
+
rM[1][2] = ay;
|
|
4579
|
+
return rM;
|
|
4580
|
+
}
|
|
4581
|
+
function t2dCopyMatrix(tm) {
|
|
4582
|
+
const rM = t2dInitNull();
|
|
4583
|
+
for (let i = 0; i < 3; i++) {
|
|
4584
|
+
for (let j = 0; j < 3; j++) {
|
|
4585
|
+
rM[i][j] = tm[i][j];
|
|
4586
|
+
}
|
|
4587
|
+
}
|
|
4588
|
+
return rM;
|
|
4589
|
+
}
|
|
4590
|
+
function t2dApply(ma, va) {
|
|
4591
|
+
const vb = [va[0], va[1], 1];
|
|
4592
|
+
const rV = [0, 0];
|
|
4593
|
+
for (let i = 0; i < 2; i++) {
|
|
4594
|
+
let t = 0;
|
|
4595
|
+
for (let k = 0; k < 3; k++) {
|
|
4596
|
+
t += ma[i][k] * vb[k];
|
|
4597
|
+
}
|
|
4598
|
+
rV[i] = t;
|
|
4599
|
+
}
|
|
4600
|
+
return rV;
|
|
4601
|
+
}
|
|
4602
|
+
function t2dGetTranslation(tm) {
|
|
4603
|
+
const rVT = [tm[0][2], tm[1][2]];
|
|
4604
|
+
return rVT;
|
|
4605
|
+
}
|
|
4606
|
+
function t2dGetRotation(tm) {
|
|
4607
|
+
const rAz = Math.atan2(tm[1][0], tm[0][0]);
|
|
4608
|
+
return rAz;
|
|
4609
|
+
}
|
|
4610
|
+
var Transform2d = class {
|
|
4611
|
+
mmat;
|
|
4612
|
+
constructor(iMat) {
|
|
4613
|
+
this.mmat = t2dCopyMatrix(iMat);
|
|
4614
|
+
}
|
|
4615
|
+
addRotation(az) {
|
|
4616
|
+
const mR = t2dRotate(az);
|
|
4617
|
+
this.mmat = t2dCombine([this.mmat, mR]);
|
|
4618
|
+
return this;
|
|
4619
|
+
}
|
|
4620
|
+
addTranslation(ax, ay) {
|
|
4621
|
+
const mT = t2dTranslate(ax, ay);
|
|
4622
|
+
this.mmat = t2dCombine([this.mmat, mT]);
|
|
4623
|
+
return this;
|
|
4624
|
+
}
|
|
4625
|
+
getMatrix() {
|
|
4626
|
+
return this.mmat;
|
|
4627
|
+
}
|
|
4628
|
+
getRotation() {
|
|
4629
|
+
const rVR = t2dGetRotation(this.mmat);
|
|
4630
|
+
return rVR;
|
|
4631
|
+
}
|
|
4632
|
+
getTranslation() {
|
|
4633
|
+
const rVT = t2dGetTranslation(this.mmat);
|
|
4634
|
+
return rVT;
|
|
4635
|
+
}
|
|
4636
|
+
transform(iv) {
|
|
4637
|
+
const rV = t2dApply(this.mmat, iv);
|
|
4638
|
+
return rV;
|
|
4639
|
+
}
|
|
4640
|
+
};
|
|
4641
|
+
var initMid = t2dInitIdentity();
|
|
4642
|
+
function transform2d(initM = initMid) {
|
|
4643
|
+
return new Transform2d(initM);
|
|
4644
|
+
}
|
|
4645
|
+
|
|
4420
4646
|
// src/transform3d.ts
|
|
4421
4647
|
function t3dInitNull() {
|
|
4422
4648
|
const rM = [
|
|
@@ -4575,8 +4801,8 @@ var Transform3d = class {
|
|
|
4575
4801
|
return rV;
|
|
4576
4802
|
}
|
|
4577
4803
|
};
|
|
4578
|
-
var
|
|
4579
|
-
function transform3d(initM =
|
|
4804
|
+
var initMid2 = t3dInitIdentity();
|
|
4805
|
+
function transform3d(initM = initMid2) {
|
|
4580
4806
|
return new Transform3d(initM);
|
|
4581
4807
|
}
|
|
4582
4808
|
|
|
@@ -4672,6 +4898,7 @@ export {
|
|
|
4672
4898
|
Segment1,
|
|
4673
4899
|
Segment2,
|
|
4674
4900
|
ShapePoint,
|
|
4901
|
+
Transform2d,
|
|
4675
4902
|
Transform3d,
|
|
4676
4903
|
Vector,
|
|
4677
4904
|
aBFromLaLbAa,
|
|
@@ -4710,6 +4937,7 @@ export {
|
|
|
4710
4937
|
dxfSegCircle,
|
|
4711
4938
|
dxfSegLine,
|
|
4712
4939
|
dxfWriter,
|
|
4940
|
+
envelop,
|
|
4713
4941
|
ffix,
|
|
4714
4942
|
figure,
|
|
4715
4943
|
fileBin,
|
|
@@ -4754,6 +4982,7 @@ export {
|
|
|
4754
4982
|
rightTriLbFromLaLc,
|
|
4755
4983
|
roundZero,
|
|
4756
4984
|
tolerance,
|
|
4985
|
+
transform2d,
|
|
4757
4986
|
transform3d,
|
|
4758
4987
|
vector,
|
|
4759
4988
|
version_details,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "geometrix",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "The 2D geometry engine of the parametrix",
|
|
5
5
|
"private": false,
|
|
6
6
|
"repository": {
|
|
@@ -69,15 +69,15 @@
|
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@eslint/js": "^9.10.0",
|
|
71
71
|
"@types/eslint__js": "^8.42.3",
|
|
72
|
-
"@types/node": "^22.13.
|
|
73
|
-
"eslint": "^9.20.
|
|
72
|
+
"@types/node": "^22.13.4",
|
|
73
|
+
"eslint": "^9.20.1",
|
|
74
74
|
"eslint-config-prettier": "^10.0.1",
|
|
75
75
|
"npm-run-all2": "^7.0.2",
|
|
76
|
-
"prettier": "^3.5.
|
|
76
|
+
"prettier": "^3.5.1",
|
|
77
77
|
"rimraf": "^6.0.1",
|
|
78
78
|
"tsup": "^8.3.6",
|
|
79
79
|
"typescript": "^5.7.3",
|
|
80
|
-
"typescript-eslint": "^8.24.
|
|
81
|
-
"vitest": "^3.0.
|
|
80
|
+
"typescript-eslint": "^8.24.1",
|
|
81
|
+
"vitest": "^3.0.6"
|
|
82
82
|
}
|
|
83
83
|
}
|