@itwin/core-geometry 4.3.0-dev.21 → 4.3.0-dev.23

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.
Files changed (67) hide show
  1. package/lib/cjs/Geometry.d.ts.map +1 -1
  2. package/lib/cjs/Geometry.js +4 -3
  3. package/lib/cjs/Geometry.js.map +1 -1
  4. package/lib/cjs/core-geometry.d.ts +0 -2
  5. package/lib/cjs/core-geometry.d.ts.map +1 -1
  6. package/lib/cjs/core-geometry.js +0 -2
  7. package/lib/cjs/core-geometry.js.map +1 -1
  8. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  9. package/lib/cjs/curve/Arc3d.js +5 -5
  10. package/lib/cjs/curve/Arc3d.js.map +1 -1
  11. package/lib/cjs/curve/LineString3d.d.ts +1 -0
  12. package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
  13. package/lib/cjs/curve/LineString3d.js +1 -0
  14. package/lib/cjs/curve/LineString3d.js.map +1 -1
  15. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +15 -9
  16. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
  17. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +68 -56
  18. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  19. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +14 -16
  20. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  21. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +42 -63
  22. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  23. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
  24. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js +3 -2
  25. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
  26. package/lib/cjs/numerics/Newton.d.ts +44 -17
  27. package/lib/cjs/numerics/Newton.d.ts.map +1 -1
  28. package/lib/cjs/numerics/Newton.js +116 -7
  29. package/lib/cjs/numerics/Newton.js.map +1 -1
  30. package/lib/cjs/numerics/Polynomials.d.ts +4 -8
  31. package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
  32. package/lib/cjs/numerics/Polynomials.js +4 -8
  33. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  34. package/lib/esm/Geometry.d.ts.map +1 -1
  35. package/lib/esm/Geometry.js +4 -3
  36. package/lib/esm/Geometry.js.map +1 -1
  37. package/lib/esm/core-geometry.d.ts +0 -2
  38. package/lib/esm/core-geometry.d.ts.map +1 -1
  39. package/lib/esm/core-geometry.js +0 -2
  40. package/lib/esm/core-geometry.js.map +1 -1
  41. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  42. package/lib/esm/curve/Arc3d.js +5 -5
  43. package/lib/esm/curve/Arc3d.js.map +1 -1
  44. package/lib/esm/curve/LineString3d.d.ts +1 -0
  45. package/lib/esm/curve/LineString3d.d.ts.map +1 -1
  46. package/lib/esm/curve/LineString3d.js +1 -0
  47. package/lib/esm/curve/LineString3d.js.map +1 -1
  48. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +15 -9
  49. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
  50. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +69 -57
  51. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  52. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +14 -16
  53. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
  54. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +42 -62
  55. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
  56. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
  57. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js +3 -2
  58. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
  59. package/lib/esm/numerics/Newton.d.ts +44 -17
  60. package/lib/esm/numerics/Newton.d.ts.map +1 -1
  61. package/lib/esm/numerics/Newton.js +112 -6
  62. package/lib/esm/numerics/Newton.js.map +1 -1
  63. package/lib/esm/numerics/Polynomials.d.ts +4 -8
  64. package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
  65. package/lib/esm/numerics/Polynomials.js +4 -8
  66. package/lib/esm/numerics/Polynomials.js.map +1 -1
  67. package/package.json +3 -3
@@ -1,9 +1,7 @@
1
- import { BezierCurveBase } from "../../bspline/BezierCurveBase";
2
1
  import { BSplineCurve3d } from "../../bspline/BSplineCurve";
3
2
  import { BSplineCurve3dH } from "../../bspline/BSplineCurve3dH";
4
3
  import { RecurseToCurvesGeometryHandler } from "../../geometry3d/GeometryHandler";
5
4
  import { Matrix4d } from "../../geometry4d/Matrix4d";
6
- import { NewtonEvaluatorRRtoRRD } from "../../numerics/Newton";
7
5
  import { Arc3d } from "../Arc3d";
8
6
  import { CurveChainWithDistanceIndex } from "../CurveChainWithDistanceIndex";
9
7
  import { CurveLocationDetailPair } from "../CurveLocationDetail";
@@ -11,19 +9,6 @@ import { CurvePrimitive } from "../CurvePrimitive";
11
9
  import { AnyCurve } from "../CurveTypes";
12
10
  import { LineSegment3d } from "../LineSegment3d";
13
11
  import { LineString3d } from "../LineString3d";
14
- /**
15
- * Private class for refining bezier-bezier intersections.
16
- * * The inputs are assumed pre-transformed so that the target condition is to match x and y coordinates.
17
- * @internal
18
- */
19
- export declare class BezierBezierIntersectionXYRRToRRD extends NewtonEvaluatorRRtoRRD {
20
- private _curveA;
21
- private _curveB;
22
- private _rayA;
23
- private _rayB;
24
- constructor(curveA: BezierCurveBase, curveB: BezierCurveBase);
25
- evaluate(fractionA: number, fractionB: number): boolean;
26
- }
27
12
  /**
28
13
  * Handler class for XY intersections between _geometryB and another geometry.
29
14
  * * Instances are initialized and called from CurveCurve.
@@ -105,7 +90,20 @@ export declare class CurveCurveIntersectXY extends RecurseToCurvesGeometryHandle
105
90
  private computeSegmentSegment3DH;
106
91
  private dispatchSegmentSegment;
107
92
  private dispatchSegmentArc;
93
+ /**
94
+ * Compute the intersection of two xy-arcs.
95
+ * * Each matrix has [U V C] in (x,y,w) form from homogeneous projection (local to world).
96
+ * * Arcs are ordered so that matrixA is better conditioned.
97
+ */
108
98
  private dispatchArcArcThisOrder;
99
+ /**
100
+ * We have 2 xy-arcs.
101
+ * 1- We pick the arc that is closest to circular (larger condition number is closer to circular).
102
+ * 2- Transform it to local coords, where it becomes the unit xy-circle.
103
+ * 3- Use the same map to transform the other arc.
104
+ * 4- Find the intersection of arc and unit circle.
105
+ * 5- Convert intersection angles to fractions and record intersections.
106
+ */
109
107
  private dispatchArcArc;
110
108
  private dispatchArcBsplineCurve3d;
111
109
  /** Apply the transformation to bezier curves. Optionally construct ranges. */
@@ -132,7 +130,7 @@ export declare class CurveCurveIntersectXY extends RecurseToCurvesGeometryHandle
132
130
  private static setTransformedWorkPoints;
133
131
  /** Low level dispatch of curve collection. */
134
132
  private dispatchCurveCollection;
135
- /** Low level dispatch to geomA given a CurveChainWithDistanceIndex in geometryB. */
133
+ /** Low level dispatch of CurveChainWithDistanceIndex. */
136
134
  private dispatchCurveChainWithDistanceIndex;
137
135
  /** Double dispatch handler for strongly typed segment. */
138
136
  handleLineSegment3d(segmentA: LineSegment3d): any;
@@ -1 +1 @@
1
- {"version":3,"file":"CurveCurveIntersectXY.d.ts","sourceRoot":"","sources":["../../../../src/curve/internalContexts/CurveCurveIntersectXY.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAsB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,EAAE,8BAA8B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G,GAAG;IA2BjE,6DAA6D;IAC7C,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,GAAG;IAiB1D,sDAAsD;IACtC,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,GAAG;IAmB7C,gEAAgE;IAChD,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,GAAG;IAmBhE,8EAA8E;IAC9D,iCAAiC,CAAC,KAAK,EAAE,2BAA2B,GAAG,GAAG;IAK1F,8EAA8E;IAC9D,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,GAAG;CAgBpE"}
@@ -14,10 +14,9 @@ import { GrowableFloat64Array } from "../../geometry3d/GrowableFloat64Array";
14
14
  import { Matrix3d } from "../../geometry3d/Matrix3d";
15
15
  import { Vector2d } from "../../geometry3d/Point2dVector2d";
16
16
  import { Point3d } from "../../geometry3d/Point3dVector3d";
17
- import { Ray3d } from "../../geometry3d/Ray3d";
18
17
  import { Point4d } from "../../geometry4d/Point4d";
19
18
  import { UnivariateBezier } from "../../numerics/BezierPolynomials";
20
- import { Newton2dUnboundedWithDerivative, NewtonEvaluatorRRtoRRD } from "../../numerics/Newton";
19
+ import { CurveCurveIntersectionXYRRToRRD, Newton2dUnboundedWithDerivative } from "../../numerics/Newton";
21
20
  import { AnalyticRoots, SmallSystem, TrigPolynomial } from "../../numerics/Polynomials";
22
21
  import { Arc3d } from "../Arc3d";
23
22
  import { CurveChainWithDistanceIndex } from "../CurveChainWithDistanceIndex";
@@ -26,26 +25,6 @@ import { CurveIntervalRole, CurveLocationDetail, CurveLocationDetailPair } from
26
25
  import { LineSegment3d } from "../LineSegment3d";
27
26
  import { LineString3d } from "../LineString3d";
28
27
  // cspell:word XYRR
29
- /**
30
- * Private class for refining bezier-bezier intersections.
31
- * * The inputs are assumed pre-transformed so that the target condition is to match x and y coordinates.
32
- * @internal
33
- */
34
- export class BezierBezierIntersectionXYRRToRRD extends NewtonEvaluatorRRtoRRD {
35
- constructor(curveA, curveB) {
36
- super();
37
- this._curveA = curveA;
38
- this._curveB = curveB;
39
- this._rayA = Ray3d.createZero();
40
- this._rayB = Ray3d.createZero();
41
- }
42
- evaluate(fractionA, fractionB) {
43
- this._curveA.fractionToPointAndDerivative(fractionA, this._rayA);
44
- this._curveB.fractionToPointAndDerivative(fractionB, this._rayB);
45
- this.currentF.setOriginAndVectorsXYZ(this._rayB.origin.x - this._rayA.origin.x, this._rayB.origin.y - this._rayA.origin.y, 0.0, -this._rayA.direction.x, -this._rayA.direction.y, 0.0, this._rayB.direction.x, this._rayB.direction.y, 0.0);
46
- return true;
47
- }
48
- }
49
28
  /**
50
29
  * Handler class for XY intersections between _geometryB and another geometry.
51
30
  * * Instances are initialized and called from CurveCurve.
@@ -305,44 +284,44 @@ class CurveCurveIntersectXY extends RecurseToCurvesGeometryHandler {
305
284
  }
306
285
  }
307
286
  }
308
- // Caller accesses data from two arcs.
309
- // Each matrix has [U V C] in (x,y,w) form from projection.
310
- // Invert the projection matrix matrixA.
311
- // Apply the inverse to matrixB. Then arc b is an ellipse in the circular space of A.
312
- dispatchArcArcThisOrder(cpA, matrixA, // homogeneous xyw projection !!!
313
- extendA, cpB, matrixB, // homogeneous xyw projection !!!
314
- extendB, reversed) {
287
+ /**
288
+ * Compute the intersection of two xy-arcs.
289
+ * * Each matrix has [U V C] in (x,y,w) form from homogeneous projection (local to world).
290
+ * * Arcs are ordered so that matrixA is better conditioned.
291
+ */
292
+ dispatchArcArcThisOrder(cpA, // arc closer to being circular
293
+ matrixA, extendA, cpB, matrixB, extendB, reversed) {
294
+ // inverseA transforms arcA to its local coordinates, where it is the unit xy-circle.
315
295
  const inverseA = matrixA.inverse();
316
296
  if (inverseA) {
317
- const localB = inverseA.multiplyMatrixMatrix(matrixB); // localB->localA transform
297
+ // localB defines the arc formed by transforming arcB into the local coordinates of arcA
298
+ const localB = inverseA.multiplyMatrixMatrix(matrixB);
318
299
  const ellipseRadians = [];
319
300
  const circleRadians = [];
301
+ // find the intersection of the transformed arcs
320
302
  TrigPolynomial.solveUnitCircleHomogeneousEllipseIntersection(localB.coffs[2], localB.coffs[5], localB.coffs[8], // center xyw
321
303
  localB.coffs[0], localB.coffs[3], localB.coffs[6], // vector0 xyw
322
304
  localB.coffs[1], localB.coffs[4], localB.coffs[7], // vector90 xyw
323
305
  ellipseRadians, circleRadians);
306
+ // the intersections are transform-invariant, so the solution angles apply directly to the input arcs
324
307
  for (let i = 0; i < ellipseRadians.length; i++) {
325
308
  const fractionA = cpA.sweep.radiansToSignedPeriodicFraction(circleRadians[i]);
326
309
  const fractionB = cpB.sweep.radiansToSignedPeriodicFraction(ellipseRadians[i]);
327
- // hm .. do we really need to check the fractions? We know they are internal to the beziers
328
310
  if (this.acceptFraction(extendA, fractionA, extendA) && this.acceptFraction(extendB, fractionB, extendB)) {
329
311
  this.recordPointWithLocalFractions(fractionA, cpA, 0, 1, fractionB, cpB, 0, 1, reversed);
330
312
  }
331
313
  }
332
314
  }
333
315
  }
334
- // Caller accesses data from two arcs.
335
- // Selects the best conditioned arc (in xy parts) as "circle after inversion".
336
- // Solves the arc-arc equations.
316
+ /**
317
+ * We have 2 xy-arcs.
318
+ * 1- We pick the arc that is closest to circular (larger condition number is closer to circular).
319
+ * 2- Transform it to local coords, where it becomes the unit xy-circle.
320
+ * 3- Use the same map to transform the other arc.
321
+ * 4- Find the intersection of arc and unit circle.
322
+ * 5- Convert intersection angles to fractions and record intersections.
323
+ */
337
324
  dispatchArcArc(cpA, extendA, cpB, extendB, reversed) {
338
- // Arc: X = C + cU + sV
339
- // Line: contains points A0,A1
340
- // Arc point colinear with line if det (A0, A1, X) = 0
341
- // with homogeneous xyw points and vectors.
342
- // With equational X: det (A0, A1, C) + c det (A0, A1, U) + s det (A0, A1, V) = 0.
343
- // solve for theta.
344
- // evaluate points.
345
- // project back to line.
346
325
  let matrixA;
347
326
  let matrixB;
348
327
  if (this._worldToLocalPerspective) {
@@ -359,11 +338,12 @@ class CurveCurveIntersectXY extends RecurseToCurvesGeometryHandler {
359
338
  }
360
339
  const conditionA = matrixA.conditionNumber();
361
340
  const conditionB = matrixB.conditionNumber();
341
+ // pick the arc that is closest to circular.
362
342
  if (conditionA > conditionB)
363
343
  this.dispatchArcArcThisOrder(cpA, matrixA, extendA, cpB, matrixB, extendB, reversed);
364
344
  else
365
345
  this.dispatchArcArcThisOrder(cpB, matrixB, extendB, cpA, matrixA, extendA, !reversed);
366
- // overlap handling .. perspective is not handled . . .
346
+ // overlap handling. perspective is not handled.
367
347
  if (!this._coincidentGeometryContext) {
368
348
  // do nothing
369
349
  }
@@ -514,32 +494,32 @@ class CurveCurveIntersectXY extends RecurseToCurvesGeometryHandler {
514
494
  const segmentAFraction = SmallSystem.lineSegment3dHXYClosestPointUnbounded(this._xyzwA0, this._xyzwA1, this._xyzwB);
515
495
  if (segmentAFraction && Geometry.isIn01WithTolerance(segmentAFraction, intervalTolerance)) {
516
496
  let bezierAFraction = Geometry.interpolate(f0, segmentAFraction, f1);
517
- const xyMatchingFunction = new BezierBezierIntersectionXYRRToRRD(bezierA, bezierB);
497
+ // We have a near intersection at fractions on the two beziers
498
+ // Iterate on the curves for a true intersection
499
+ const xyMatchingFunction = new CurveCurveIntersectionXYRRToRRD(bezierA, bezierB);
518
500
  const newtonSearcher = new Newton2dUnboundedWithDerivative(xyMatchingFunction);
519
501
  newtonSearcher.setUV(bezierAFraction, bezierBFraction);
520
502
  if (newtonSearcher.runIterations()) {
521
503
  bezierAFraction = newtonSearcher.getU();
522
504
  bezierBFraction = newtonSearcher.getV();
523
505
  }
524
- // We have a near intersection at fractions on the two beziers !!!
525
- // Iterate on the curves for a true intersection ....
526
- // NEEDS WORK -- just accept . . .
527
506
  const bcurveAFraction = bezierA.fractionToParentFraction(bezierAFraction);
528
507
  const bcurveBFraction = bezierB.fractionToParentFraction(bezierBFraction);
529
- const xyzA0 = bezierA.fractionToPoint(bezierAFraction);
530
- const xyzA1 = bcurveA.fractionToPoint(bcurveAFraction);
531
- const xyzB0 = bezierB.fractionToPoint(bezierBFraction);
532
- const xyzB1 = bcurveB.fractionToPoint(bcurveBFraction);
533
- if (!xyzA0.isAlmostEqualXY(xyzA1))
534
- errors++;
535
- if (!xyzB0.isAlmostEqualXY(xyzB1))
536
- errors++;
537
- if (errors > 0 && !xyzA0.isAlmostEqual(xyzB0))
538
- errors++;
539
- if (errors > 0 && !xyzA1.isAlmostEqual(xyzB1))
540
- errors++;
541
- if (this.acceptFraction(false, bcurveAFraction, false) &&
542
- this.acceptFraction(false, bcurveBFraction, false)) {
508
+ if (!"verify results") {
509
+ const xyzA0 = bezierA.fractionToPoint(bezierAFraction);
510
+ const xyzA1 = bcurveA.fractionToPoint(bcurveAFraction);
511
+ const xyzB0 = bezierB.fractionToPoint(bezierBFraction);
512
+ const xyzB1 = bcurveB.fractionToPoint(bcurveBFraction);
513
+ if (!xyzA0.isAlmostEqualXY(xyzA1))
514
+ errors++;
515
+ if (!xyzB0.isAlmostEqualXY(xyzB1))
516
+ errors++;
517
+ if (errors > 0 && !xyzA0.isAlmostEqual(xyzB0))
518
+ errors++;
519
+ if (errors > 0 && !xyzA1.isAlmostEqual(xyzB1))
520
+ errors++;
521
+ }
522
+ if (this.acceptFraction(false, bcurveAFraction, false) && this.acceptFraction(false, bcurveBFraction, false)) {
543
523
  this.recordPointWithLocalFractions(bcurveAFraction, bcurveA, 0, 1, bcurveBFraction, bcurveB, 0, 1, reversed);
544
524
  }
545
525
  }
@@ -735,7 +715,7 @@ class CurveCurveIntersectXY extends RecurseToCurvesGeometryHandler {
735
715
  }
736
716
  this._geometryB = geomB; // restore
737
717
  }
738
- /** Low level dispatch to geomA given a CurveChainWithDistanceIndex in geometryB. */
718
+ /** Low level dispatch of CurveChainWithDistanceIndex. */
739
719
  dispatchCurveChainWithDistanceIndex(geomA, geomAHandler) {
740
720
  if (!this._geometryB || !(this._geometryB instanceof CurveChainWithDistanceIndex))
741
721
  return;