geometrix 1.0.7 → 1.0.9

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 CHANGED
@@ -294,6 +294,22 @@ 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;
@@ -301,7 +317,7 @@ declare abstract class AContour {
301
317
  abstract extractSkeleton(): AContour;
302
318
  abstract generateContour(): AContour;
303
319
  abstract generatePoints(dnb: number): Point[];
304
- abstract getEnvelop(): [number, number, number, number, boolean];
320
+ abstract getEnvelop(): tEnvelop;
305
321
  abstract generateLines(): Line[];
306
322
  abstract check(): string;
307
323
  abstract toSvg(yCeiling: number, color?: string): string;
@@ -369,7 +385,7 @@ declare class Contour extends AContour {
369
385
  generateContour(): Contour;
370
386
  generatePoints(dnb: number): Point[];
371
387
  getOrientation(iPts: Point[], extremX: number): boolean;
372
- getEnvelop(): [number, number, number, number, boolean];
388
+ getEnvelop(): tEnvelop;
373
389
  generateLines(): Line[];
374
390
  /** @internal */
375
391
  checkContour(ctr: Contour): void;
@@ -378,7 +394,7 @@ declare class Contour extends AContour {
378
394
  toDxfSeg(): DxfSeg[];
379
395
  toPax(): tPaxContourPath;
380
396
  getPerimeter(): number;
381
- generateRevertOrientation(): AContour;
397
+ generateRevertOrientation(): Contour;
382
398
  }
383
399
  /**
384
400
  * class `ContourCircle`
@@ -400,14 +416,14 @@ declare class ContourCircle extends AContour {
400
416
  extractSkeleton(): ContourCircle;
401
417
  generateContour(): ContourCircle;
402
418
  generatePoints(dnb: number): Point[];
403
- getEnvelop(): [number, number, number, number, boolean];
419
+ getEnvelop(): tEnvelop;
404
420
  generateLines(): Line[];
405
421
  check(): string;
406
422
  toSvg(yCeiling: number, color?: string): string;
407
423
  toDxfSeg(): DxfSeg[];
408
424
  toPax(): tPaxContourCircle;
409
425
  getPerimeter(): number;
410
- generateRevertOrientation(): AContour;
426
+ generateRevertOrientation(): ContourCircle;
411
427
  }
412
428
  declare function contour(ix: number, iy: number, icolor?: string): Contour;
413
429
  declare function contourCircle(ix: number, iy: number, iRadius: number, icolor?: string): ContourCircle;
@@ -641,6 +657,21 @@ interface tParamValInFile {
641
657
  declare function createParamFile(lastModif: string, iPartName: string, idparams: tParamVal, comment: string): string;
642
658
  declare function parseParamFile(fContentStr: string): [tParamValInFile, string];
643
659
 
660
+ type tVec2 = [number, number];
661
+ type tVec3b = [number, number, number];
662
+ type tT2dMatrix = [tVec3b, tVec3b, tVec3b];
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
+
644
675
  type tVec3 = [number, number, number];
645
676
  type tVec4 = [number, number, number, number];
646
677
  type tT3dMatrix = [tVec4, tVec4, tVec4, tVec4];
@@ -694,4 +725,4 @@ declare function version_details(appPackage: tPackage): string[];
694
725
 
695
726
  declare function checkImpPages(pages: tAllPageDef): [boolean, string];
696
727
 
697
- 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, Envelop, 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 tVec3b, type tVec4, type tVolume, tolerance, transform2d, transform3d, vector, version_details, withinHPiHPi, withinPiPi, withinZero2Pi, withinZeroPi, zeroPDef };
package/dist/index.js CHANGED
@@ -2309,7 +2309,7 @@ var Contour = class _Contour extends AContour {
2309
2309
  if (orient2 !== rOrientation) {
2310
2310
  throw `err390: orientation unstable ${rOrientation} ${orient2} with ${pts.length} points`;
2311
2311
  }
2312
- return [rXmin, rXmax, rYmin, rYmax, rOrientation];
2312
+ return { xMin: rXmin, xMax: rXmax, yMin: rYmin, yMax: rYmax, orientation: rOrientation };
2313
2313
  }
2314
2314
  generateLines() {
2315
2315
  const rLines = [];
@@ -2507,13 +2507,13 @@ var ContourCircle = class _ContourCircle extends AContour {
2507
2507
  return rPoints;
2508
2508
  }
2509
2509
  getEnvelop() {
2510
- return [
2511
- this.px - this.radius,
2512
- this.px + this.radius,
2513
- this.py - this.radius,
2514
- this.py + this.radius,
2515
- true
2516
- ];
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
2517
  }
2518
2518
  generateLines() {
2519
2519
  return [];
@@ -4483,6 +4483,166 @@ function parseParamFile(fContentStr) {
4483
4483
  return [rObj, rlog];
4484
4484
  }
4485
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
+
4486
4646
  // src/transform3d.ts
4487
4647
  function t3dInitNull() {
4488
4648
  const rM = [
@@ -4641,8 +4801,8 @@ var Transform3d = class {
4641
4801
  return rV;
4642
4802
  }
4643
4803
  };
4644
- var initMid = t3dInitIdentity();
4645
- function transform3d(initM = initMid) {
4804
+ var initMid2 = t3dInitIdentity();
4805
+ function transform3d(initM = initMid2) {
4646
4806
  return new Transform3d(initM);
4647
4807
  }
4648
4808
 
@@ -4738,6 +4898,7 @@ export {
4738
4898
  Segment1,
4739
4899
  Segment2,
4740
4900
  ShapePoint,
4901
+ Transform2d,
4741
4902
  Transform3d,
4742
4903
  Vector,
4743
4904
  aBFromLaLbAa,
@@ -4776,6 +4937,7 @@ export {
4776
4937
  dxfSegCircle,
4777
4938
  dxfSegLine,
4778
4939
  dxfWriter,
4940
+ envelop,
4779
4941
  ffix,
4780
4942
  figure,
4781
4943
  fileBin,
@@ -4820,6 +4982,7 @@ export {
4820
4982
  rightTriLbFromLaLc,
4821
4983
  roundZero,
4822
4984
  tolerance,
4985
+ transform2d,
4823
4986
  transform3d,
4824
4987
  vector,
4825
4988
  version_details,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geometrix",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "The 2D geometry engine of the parametrix",
5
5
  "private": false,
6
6
  "repository": {