@itwin/core-geometry 5.10.0-dev.18 → 5.10.0-dev.20
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/lib/cjs/Geometry.d.ts +5 -0
- package/lib/cjs/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js +7 -0
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/curve/CurveCurve.d.ts +34 -4
- package/lib/cjs/curve/CurveCurve.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCurve.js +19 -12
- package/lib/cjs/curve/CurveCurve.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +9 -4
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +20 -11
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/cjs/numerics/BezierPolynomials.d.ts.map +1 -1
- package/lib/cjs/numerics/BezierPolynomials.js +2 -1
- package/lib/cjs/numerics/BezierPolynomials.js.map +1 -1
- package/lib/esm/Geometry.d.ts +5 -0
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js +7 -0
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/curve/CurveCurve.d.ts +34 -4
- package/lib/esm/curve/CurveCurve.d.ts.map +1 -1
- package/lib/esm/curve/CurveCurve.js +19 -12
- package/lib/esm/curve/CurveCurve.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +9 -4
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +20 -11
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/esm/numerics/BezierPolynomials.d.ts.map +1 -1
- package/lib/esm/numerics/BezierPolynomials.js +2 -1
- package/lib/esm/numerics/BezierPolynomials.js.map +1 -1
- package/package.json +3 -3
|
@@ -85,11 +85,18 @@ class CurveCurve {
|
|
|
85
85
|
* an `AnyRegion`, then close approaches are computed only to the defining curves, not to the area they enclose.
|
|
86
86
|
* @param curveA first curve
|
|
87
87
|
* @param curveB second curve
|
|
88
|
-
* @param
|
|
88
|
+
* @param maxDistanceOrOptions maximum xy-distance to consider between the curves, or a list of extended options.
|
|
89
89
|
* Close approaches further than this xy-distance are not returned.
|
|
90
|
+
* @return array of detail pairs of close xy-approaches. XY-length of the returned close approach is set in `detailA.a`
|
|
91
|
+
* and `detailB.a`.
|
|
90
92
|
*/
|
|
91
|
-
static closeApproachProjectedXYPairs(curveA, curveB,
|
|
92
|
-
const
|
|
93
|
+
static closeApproachProjectedXYPairs(curveA, curveB, maxDistanceOrOptions = Geometry_1.Geometry.largeCoordinateResult) {
|
|
94
|
+
const optionIsNumber = Geometry_1.Geometry.isNumber(maxDistanceOrOptions);
|
|
95
|
+
const maxDistance = optionIsNumber ? maxDistanceOrOptions : maxDistanceOrOptions.maxDistance ?? Geometry_1.Geometry.largeCoordinateResult;
|
|
96
|
+
const xyTolerance = optionIsNumber ? undefined : maxDistanceOrOptions.xyTolerance;
|
|
97
|
+
const newtonTolerance = optionIsNumber ? undefined : maxDistanceOrOptions.newtonTolerance;
|
|
98
|
+
const maxIterations = optionIsNumber ? undefined : maxDistanceOrOptions.maxIterations;
|
|
99
|
+
const handler = new CurveCurveCloseApproachXY_1.CurveCurveCloseApproachXY(curveB, xyTolerance, newtonTolerance, maxIterations);
|
|
93
100
|
handler.maxDistanceToAccept = maxDistance;
|
|
94
101
|
curveA.dispatchToGeometryHandler(handler);
|
|
95
102
|
return handler.grabPairedResults();
|
|
@@ -103,20 +110,20 @@ class CurveCurve {
|
|
|
103
110
|
* found among the pairs.
|
|
104
111
|
* @param curveA first curve
|
|
105
112
|
* @param curveB second curve
|
|
106
|
-
* @
|
|
113
|
+
* @param options optional parameters for close approach calculation
|
|
114
|
+
* @return detail pair of closest xy-approach, undefined if not found. XY-length of the returned close approach is
|
|
115
|
+
* set in `detailA.a` and `detailB.a`.
|
|
107
116
|
*/
|
|
108
|
-
static closestApproachProjectedXYPair(curveA, curveB) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
const closeApproaches = this.closeApproachProjectedXYPairs(curveA, curveB, maxDistance);
|
|
117
|
+
static closestApproachProjectedXYPair(curveA, curveB, options) {
|
|
118
|
+
if (options === undefined)
|
|
119
|
+
options = { maxDistance: Geometry_1.Geometry.largeCoordinateResult };
|
|
120
|
+
const closeApproaches = this.closeApproachProjectedXYPairs(curveA, curveB, options);
|
|
113
121
|
if (!closeApproaches.length)
|
|
114
122
|
return undefined;
|
|
115
123
|
let iMin = 0;
|
|
116
|
-
let minDistXY =
|
|
124
|
+
let minDistXY = Geometry_1.Geometry.largeCoordinateResult;
|
|
117
125
|
for (let i = 0; i < closeApproaches.length; ++i) {
|
|
118
|
-
|
|
119
|
-
const distXY = closeApproaches[i].detailA.point.distanceXY(closeApproaches[i].detailB.point);
|
|
126
|
+
const distXY = closeApproaches[i].detailA.a;
|
|
120
127
|
if (distXY < minDistXY) {
|
|
121
128
|
iMin = i;
|
|
122
129
|
minDistXY = distXY;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurveCurve.js","sourceRoot":"","sources":["../../../src/curve/CurveCurve.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0CAAuC;AAKvC,4FAAyF;AACzF,oFAAiF;AACjF,sFAAmF;AAEnF;;;GAGG;AACH,MAAa,UAAU;IACrB;;;;;;;;OAQG;IACI,MAAM,CAAC,mBAAmB,CAC/B,MAAgB,EAChB,OAAgB,EAChB,MAAgB,EAChB,OAAgB,EAChB,YAAoB,mBAAQ,CAAC,mBAAmB;QAEhD,OAAO,UAAU,CAAC,4BAA4B,CAAC,SAAS,EAAE,MAAM,EAAE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CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC7F,IAAI,MAAM,GAAG,SAAS,EAAE,CAAC;gBACvB,IAAI,GAAG,CAAC,CAAC;gBACT,SAAS,GAAG,MAAM,CAAC;YACrB,CAAC;QACH,CAAC;QACD,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF;AA/HD,gCA+HC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { Geometry } from \"../Geometry\";\nimport { Matrix4d } from \"../geometry4d/Matrix4d\";\nimport { CurveLocationDetailPair } from \"./CurveLocationDetail\";\nimport { CurvePrimitive } from \"./CurvePrimitive\";\nimport { AnyCurve } from \"./CurveTypes\";\nimport { CurveCurveCloseApproachXY } from \"./internalContexts/CurveCurveCloseApproachXY\";\nimport { CurveCurveIntersectXY } from \"./internalContexts/CurveCurveIntersectXY\";\nimport { CurveCurveIntersectXYZ } from \"./internalContexts/CurveCurveIntersectXYZ\";\n\n/**\n * `CurveCurve` has static method for various computations that work on a pair of curves or curve collections.\n * @public\n */\nexport class CurveCurve {\n /**\n * Return xy intersections of 2 curves.\n * * Curves can be extended if extend flags are set. B-splines are not extended even if the flag is set.\n * @param curveA first curve\n * @param extendA true to allow curveA to extend\n * @param curveB second curve\n * @param extendB true to allow curveB to extend\n * @param tolerance optional distance tolerance for coincidence\n */\n public static intersectionXYPairs(\n curveA: AnyCurve,\n extendA: boolean,\n curveB: AnyCurve,\n extendB: boolean,\n tolerance: number = Geometry.smallMetricDistance,\n ): CurveLocationDetailPair[] {\n return CurveCurve.intersectionProjectedXYPairs(undefined, curveA, extendA, curveB, extendB, tolerance);\n }\n /**\n * Return xy intersections of 2 projected curves.\n * * Curves can be extended if extend flags are set. B-splines are not extended even if the flag is set.\n * @param worldToLocal transform (possibly perspective) defining the local coordinates in which to compute xy intersections\n * @param curveA first curve\n * @param extendA true to allow curveA to extend\n * @param curveB second curve\n * @param extendB true to allow curveB to extend\n * @param tolerance optional distance tolerance for coincidence\n */\n public static intersectionProjectedXYPairs(\n worldToLocal: Matrix4d | undefined,\n curveA: AnyCurve,\n extendA: boolean,\n curveB: AnyCurve,\n extendB: boolean,\n tolerance: number = Geometry.smallMetricDistance,\n ): CurveLocationDetailPair[] {\n const handler = new CurveCurveIntersectXY(worldToLocal, extendA, curveB, extendB, tolerance);\n curveA.dispatchToGeometryHandler(handler);\n return handler.grabPairedResults();\n }\n /**\n * Return full 3d xyz intersections of 2 curves.\n * * Implemented for combinations of LineSegment3d, LineString3d, Arc3d.\n * * Not Implemented for bspline and bezier curves.\n * @param curveA first curve\n * @param extendA true to allow curveA to extend\n * @param curveB second curve\n * @param extendB true to allow curveB to extend\n * @returns array of intersections structured as CurveLocationDetailPair[]\n */\n public static intersectionXYZPairs(\n curveA: AnyCurve, extendA: boolean, curveB: AnyCurve, extendB: boolean,\n ): CurveLocationDetailPair[] {\n const handler = new CurveCurveIntersectXYZ(extendA, curveB, extendB);\n curveA.dispatchToGeometryHandler(handler);\n return handler.grabPairedResults();\n }\n /**\n * Return xy intersections of input curves.\n * @param primitives input curves to intersect\n * @param tolerance optional distance tolerance for coincidence\n */\n public static allIntersectionsAmongPrimitivesXY(\n primitives: CurvePrimitive[], tolerance: number = Geometry.smallMetricDistance,\n ): CurveLocationDetailPair[] {\n const handler = new CurveCurveIntersectXY(undefined, false, undefined, false, tolerance);\n for (let i = 0; i < primitives.length; i++) {\n const curveA = primitives[i];\n for (let j = i + 1; j < primitives.length; j++) {\n handler.resetGeometryB(primitives[j]);\n curveA.dispatchToGeometryHandler(handler);\n }\n }\n return handler.grabPairedResults();\n }\n /**\n * Return at least one XY close approach between 2 curves.\n * * Close approach xy-distances are measured without regard to z. This is equivalent to their separation distance\n * as seen in the top view, or as measured between their projections onto the xy-plane.\n * * If more than one approach is returned, one of them is the closest approach.\n * * If an input curve is a `CurveCollection`, then close approaches are computed to each `CurvePrimitive` child.\n * This can lead to many returned pairs, especially when both inputs are `CurveCollection`s. If an input curve is\n * an `AnyRegion`, then close approaches are computed only to the defining curves, not to the area they enclose.\n * @param curveA first curve\n * @param curveB second curve\n * @param maxDistance maximum xy-distance to consider between the curves.\n * Close approaches further than this xy-distance are not returned.\n */\n public static closeApproachProjectedXYPairs(\n curveA: AnyCurve, curveB: AnyCurve, maxDistance: number,\n ): CurveLocationDetailPair[] {\n const handler = new CurveCurveCloseApproachXY(curveB);\n handler.maxDistanceToAccept = maxDistance;\n curveA.dispatchToGeometryHandler(handler);\n return handler.grabPairedResults();\n }\n /**\n * Convenience method that calls [[closeApproachProjectedXYPairs]] with a large `maxDistance`\n * and returns a detail pair representing the closest xy-approach between the curves.\n * * There may be many detail pairs that represent \"closest\" xy-approach, including coincident interval pairs,\n * isolated intersections, or close approaches within tolerance of each other. This method makes no attempt to\n * distinguish among them, and returns a pair whose `detail.point` values are separated by the smallest xy distance\n * found among the pairs.\n * @param curveA first curve\n * @param curveB second curve\n * @return detail pair of closest xy-approach, undefined if not found\n */\n public static closestApproachProjectedXYPair(curveA: AnyCurve, curveB: AnyCurve): CurveLocationDetailPair | undefined {\n const range = curveA.range();\n range.extendRange(curveB.range());\n const maxDistance = range.low.distanceXY(range.high);\n const closeApproaches = this.closeApproachProjectedXYPairs(curveA, curveB, maxDistance);\n if (!closeApproaches.length)\n return undefined;\n let iMin = 0;\n let minDistXY = 2 * maxDistance;\n for (let i = 0; i < closeApproaches.length; ++i) {\n // TODO: this distance should already be in detail.a. Verify this, then just use it instead of recomputing below.\n const distXY = closeApproaches[i].detailA.point.distanceXY(closeApproaches[i].detailB.point);\n if (distXY < minDistXY) {\n iMin = i;\n minDistXY = distXY;\n }\n }\n return closeApproaches[iMin];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CurveCurve.js","sourceRoot":"","sources":["../../../src/curve/CurveCurve.ts"],"names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AO,CAAC,mBAAmB,GAAG,WAAW,CAAC;QAC1C,MAAM,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;QAC1C,OAAO,OAAO,CAAC,iBAAiB,EAAE,CAAC;IACrC,CAAC;IACD;;;;;;;;;;;;OAYG;IACI,MAAM,CAAC,8BAA8B,CAC1C,MAAgB,EAAE,MAAgB,EAAE,OAA2B;QAE/D,IAAI,OAAO,KAAK,SAAS;YACvB,OAAO,GAAG,EAAE,WAAW,EAAE,mBAAQ,CAAC,qBAAqB,EAAE,CAAC;QAC5D,MAAM,eAAe,GAAG,IAAI,CAAC,6BAA6B,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QACpF,IAAI,CAAC,eAAe,CAAC,MAAM;YACzB,OAAO,SAAS,CAAC;QACnB,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,IAAI,SAAS,GAAG,mBAAQ,CAAC,qBAAqB,CAAC;QAC/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;YAChD,MAAM,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;YAC5C,IAAI,MAAM,GAAG,SAAS,EAAE,CAAC;gBACvB,IAAI,GAAG,CAAC,CAAC;gBACT,SAAS,GAAG,MAAM,CAAC;YACrB,CAAC;QACH,CAAC;QACD,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF;AAxID,gCAwIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { Geometry } from \"../Geometry\";\nimport { Matrix4d } from \"../geometry4d/Matrix4d\";\nimport { CurveLocationDetailPair } from \"./CurveLocationDetail\";\nimport { CurvePrimitive } from \"./CurvePrimitive\";\nimport { AnyCurve } from \"./CurveTypes\";\nimport { CurveCurveCloseApproachXY } from \"./internalContexts/CurveCurveCloseApproachXY\";\nimport { CurveCurveIntersectXY } from \"./internalContexts/CurveCurveIntersectXY\";\nimport { CurveCurveIntersectXYZ } from \"./internalContexts/CurveCurveIntersectXYZ\";\n\n/**\n * Options used for method [[CurveCurve.closeApproachProjectedXYPairs]] and [[CurveCurve.closestApproachProjectedXYPair]].\n * @public\n */\nexport interface CurveCurveOptions {\n /**\n * Maximum xy approach distance to be returned.\n * Default: {@link Geometry.largeCoordinateResult}.\n */\n maxDistance?: number;\n /**\n * Tolerance for comparing xy points.\n * Default: {@link Geometry.smallMetricDistance}.\n */\n xyTolerance?: number;\n /**\n * Newton convergence tolerance, in parametric space.\n * Default: {@link Geometry.smallNewtonStep}.\n */\n newtonTolerance?: number;\n /**\n * Maximum number of iterations for the Newton method.\n * Default: 50.\n */\n maxIterations?: number;\n}\n\n/**\n * `CurveCurve` has static method for various computations that work on a pair of curves or curve collections.\n * @public\n */\nexport class CurveCurve {\n /**\n * Return xy intersections of 2 curves.\n * * Curves can be extended if extend flags are set. B-splines are not extended even if the flag is set.\n * @param curveA first curve\n * @param extendA true to allow curveA to extend\n * @param curveB second curve\n * @param extendB true to allow curveB to extend\n * @param tolerance optional distance tolerance for coincidence\n */\n public static intersectionXYPairs(\n curveA: AnyCurve,\n extendA: boolean,\n curveB: AnyCurve,\n extendB: boolean,\n tolerance: number = Geometry.smallMetricDistance,\n ): CurveLocationDetailPair[] {\n return CurveCurve.intersectionProjectedXYPairs(undefined, curveA, extendA, curveB, extendB, tolerance);\n }\n /**\n * Return xy intersections of 2 projected curves.\n * * Curves can be extended if extend flags are set. B-splines are not extended even if the flag is set.\n * @param worldToLocal transform (possibly perspective) defining the local coordinates in which to compute xy intersections\n * @param curveA first curve\n * @param extendA true to allow curveA to extend\n * @param curveB second curve\n * @param extendB true to allow curveB to extend\n * @param tolerance optional distance tolerance for coincidence\n */\n public static intersectionProjectedXYPairs(\n worldToLocal: Matrix4d | undefined,\n curveA: AnyCurve,\n extendA: boolean,\n curveB: AnyCurve,\n extendB: boolean,\n tolerance: number = Geometry.smallMetricDistance,\n ): CurveLocationDetailPair[] {\n const handler = new CurveCurveIntersectXY(worldToLocal, extendA, curveB, extendB, tolerance);\n curveA.dispatchToGeometryHandler(handler);\n return handler.grabPairedResults();\n }\n /**\n * Return full 3d xyz intersections of 2 curves.\n * * Implemented for combinations of LineSegment3d, LineString3d, Arc3d.\n * * Not Implemented for bspline and bezier curves.\n * @param curveA first curve\n * @param extendA true to allow curveA to extend\n * @param curveB second curve\n * @param extendB true to allow curveB to extend\n * @returns array of intersections structured as CurveLocationDetailPair[]\n */\n public static intersectionXYZPairs(\n curveA: AnyCurve, extendA: boolean, curveB: AnyCurve, extendB: boolean,\n ): CurveLocationDetailPair[] {\n const handler = new CurveCurveIntersectXYZ(extendA, curveB, extendB);\n curveA.dispatchToGeometryHandler(handler);\n return handler.grabPairedResults();\n }\n /**\n * Return xy intersections of input curves.\n * @param primitives input curves to intersect\n * @param tolerance optional distance tolerance for coincidence\n */\n public static allIntersectionsAmongPrimitivesXY(\n primitives: CurvePrimitive[], tolerance: number = Geometry.smallMetricDistance,\n ): CurveLocationDetailPair[] {\n const handler = new CurveCurveIntersectXY(undefined, false, undefined, false, tolerance);\n for (let i = 0; i < primitives.length; i++) {\n const curveA = primitives[i];\n for (let j = i + 1; j < primitives.length; j++) {\n handler.resetGeometryB(primitives[j]);\n curveA.dispatchToGeometryHandler(handler);\n }\n }\n return handler.grabPairedResults();\n }\n /**\n * Return at least one XY close approach between 2 curves.\n * * Close approach xy-distances are measured without regard to z. This is equivalent to their separation distance\n * as seen in the top view, or as measured between their projections onto the xy-plane.\n * * If more than one approach is returned, one of them is the closest approach.\n * * If an input curve is a `CurveCollection`, then close approaches are computed to each `CurvePrimitive` child.\n * This can lead to many returned pairs, especially when both inputs are `CurveCollection`s. If an input curve is\n * an `AnyRegion`, then close approaches are computed only to the defining curves, not to the area they enclose.\n * @param curveA first curve\n * @param curveB second curve\n * @param maxDistanceOrOptions maximum xy-distance to consider between the curves, or a list of extended options.\n * Close approaches further than this xy-distance are not returned.\n * @return array of detail pairs of close xy-approaches. XY-length of the returned close approach is set in `detailA.a`\n * and `detailB.a`.\n */\n public static closeApproachProjectedXYPairs(\n curveA: AnyCurve, curveB: AnyCurve, maxDistanceOrOptions: number | CurveCurveOptions = Geometry.largeCoordinateResult,\n ): CurveLocationDetailPair[] {\n const optionIsNumber = Geometry.isNumber(maxDistanceOrOptions);\n const maxDistance = optionIsNumber ? maxDistanceOrOptions : maxDistanceOrOptions.maxDistance ?? Geometry.largeCoordinateResult;\n const xyTolerance = optionIsNumber ? undefined : maxDistanceOrOptions.xyTolerance;\n const newtonTolerance = optionIsNumber ? undefined : maxDistanceOrOptions.newtonTolerance;\n const maxIterations = optionIsNumber ? undefined : maxDistanceOrOptions.maxIterations;\n const handler = new CurveCurveCloseApproachXY(curveB, xyTolerance, newtonTolerance, maxIterations);\n handler.maxDistanceToAccept = maxDistance;\n curveA.dispatchToGeometryHandler(handler);\n return handler.grabPairedResults();\n }\n /**\n * Convenience method that calls [[closeApproachProjectedXYPairs]] with a large `maxDistance`\n * and returns a detail pair representing the closest xy-approach between the curves.\n * * There may be many detail pairs that represent \"closest\" xy-approach, including coincident interval pairs,\n * isolated intersections, or close approaches within tolerance of each other. This method makes no attempt to\n * distinguish among them, and returns a pair whose `detail.point` values are separated by the smallest xy distance\n * found among the pairs.\n * @param curveA first curve\n * @param curveB second curve\n * @param options optional parameters for close approach calculation\n * @return detail pair of closest xy-approach, undefined if not found. XY-length of the returned close approach is\n * set in `detailA.a` and `detailB.a`.\n */\n public static closestApproachProjectedXYPair(\n curveA: AnyCurve, curveB: AnyCurve, options?: CurveCurveOptions\n ): CurveLocationDetailPair | undefined {\n if (options === undefined)\n options = { maxDistance: Geometry.largeCoordinateResult };\n const closeApproaches = this.closeApproachProjectedXYPairs(curveA, curveB, options);\n if (!closeApproaches.length)\n return undefined;\n let iMin = 0;\n let minDistXY = Geometry.largeCoordinateResult;\n for (let i = 0; i < closeApproaches.length; ++i) {\n const distXY = closeApproaches[i].detailA.a;\n if (distXY < minDistXY) {\n iMin = i;\n minDistXY = distXY;\n }\n }\n return closeApproaches[iMin];\n }\n}\n"]}
|
|
@@ -33,6 +33,7 @@ export declare class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHa
|
|
|
33
33
|
private _maxDistanceSquared;
|
|
34
34
|
private _xyTolerance;
|
|
35
35
|
private _newtonTolerance;
|
|
36
|
+
private _maxIterations;
|
|
36
37
|
/**
|
|
37
38
|
* Start and end points of line segments that meet closest approach criteria, i.e., they are perpendicular to
|
|
38
39
|
* both curves and their length is smaller than _maxDistanceToAccept.
|
|
@@ -48,8 +49,9 @@ export declare class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHa
|
|
|
48
49
|
* @param geometryB second curve for intersection. Saved for reference by specific handler methods.
|
|
49
50
|
* @param xyTolerance optional tolerance for comparing xy points (default [[Geometry.smallMetricDistance]]).
|
|
50
51
|
* @param newtonTolerance optional relative fraction tolerance for Newton iteration (default [[Geometry.smallNewtonStep]]).
|
|
52
|
+
* @param maxIterations optional max iterations for Newton iteration (default 50).
|
|
51
53
|
*/
|
|
52
|
-
constructor(geometryB?: AnyCurve, xyTolerance?: number, newtonTolerance?: number);
|
|
54
|
+
constructor(geometryB?: AnyCurve, xyTolerance?: number, newtonTolerance?: number, maxIterations?: number);
|
|
53
55
|
/** Set the (possibly undefined) max XY distance (z is ignored) to accept. */
|
|
54
56
|
set maxDistanceToAccept(value: number | undefined);
|
|
55
57
|
/** Access the (possibly undefined) max XY distance (z is ignored) to accept. */
|
|
@@ -197,11 +199,14 @@ export declare class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHa
|
|
|
197
199
|
/** Specifies whether the curve needs to be stroked for close approach computation. */
|
|
198
200
|
private needsStroking;
|
|
199
201
|
/**
|
|
200
|
-
* Process seeds for xy close approach between one curve and another curve
|
|
202
|
+
* Process seeds for xy close approach between one curve and another curve.
|
|
203
|
+
* * Seeds typically result from solving a discrete close approach problem, where one or both curves have been stroked.
|
|
201
204
|
* * Refine each result via Newton iteration. If it doesn't converge, remove it.
|
|
202
205
|
* @param seeds the initial seed results to refine.
|
|
203
206
|
* @param curveA curve to find its XY close approach with curveB.
|
|
204
|
-
* @param
|
|
207
|
+
* @param curveAIsStroked whether `seeds` contains results from a linestring approximation to `curveA`
|
|
208
|
+
* @param curveB the other curve.
|
|
209
|
+
* @param curveBIsStroked whether `seeds` contains results from a linestring approximation to `curveB`
|
|
205
210
|
* @param reversed whether `curveB` data is in `detailA` of each recorded pair, and `curveA` data in `detailB`.
|
|
206
211
|
*/
|
|
207
212
|
private refineStrokedResultsByNewton;
|
|
@@ -218,7 +223,7 @@ export declare class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHa
|
|
|
218
223
|
/**
|
|
219
224
|
* Compute the XY close approach of a curve and another curve to be stroked.
|
|
220
225
|
* @param curveA curve to find its XY close approach with curveB.
|
|
221
|
-
* @param curveB the other curve to be stroked.
|
|
226
|
+
* @param curveB the other curve, to be stroked.
|
|
222
227
|
* @param reversed whether `curveB` data will be recorded in `detailA` of each result, and `curveA` data in `detailB`.
|
|
223
228
|
*/
|
|
224
229
|
private dispatchCurveStrokedCurve;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurveCurveCloseApproachXY.d.ts","sourceRoot":"","sources":["../../../../src/curve/internalContexts/CurveCurveCloseApproachXY.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAsB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAOlF,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,2BAA2B,EAAE,M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D;IAC7C,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,GAAG;IAgB1D,sDAAsD;IACtC,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,GAAG;IAgB7C,gEAAgE;IAChD,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,GAAG;IAUjE,+DAA+D;IAC/C,sBAAsB,CAAC,MAAM,EAAE,kBAAkB,GAAG,GAAG;IAUvE,8EAA8E;IAC9D,iCAAiC,CAAC,KAAK,EAAE,2BAA2B,GAAG,GAAG;IAS1F,8EAA8E;IAC9D,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,GAAG;CAIpE"}
|
|
@@ -54,6 +54,7 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
54
54
|
_maxDistanceSquared;
|
|
55
55
|
_xyTolerance;
|
|
56
56
|
_newtonTolerance;
|
|
57
|
+
_maxIterations;
|
|
57
58
|
/**
|
|
58
59
|
* Start and end points of line segments that meet closest approach criteria, i.e., they are perpendicular to
|
|
59
60
|
* both curves and their length is smaller than _maxDistanceToAccept.
|
|
@@ -69,13 +70,16 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
69
70
|
* @param geometryB second curve for intersection. Saved for reference by specific handler methods.
|
|
70
71
|
* @param xyTolerance optional tolerance for comparing xy points (default [[Geometry.smallMetricDistance]]).
|
|
71
72
|
* @param newtonTolerance optional relative fraction tolerance for Newton iteration (default [[Geometry.smallNewtonStep]]).
|
|
73
|
+
* @param maxIterations optional max iterations for Newton iteration (default 50).
|
|
72
74
|
*/
|
|
73
|
-
constructor(geometryB, xyTolerance = Geometry_1.Geometry.smallMetricDistance, newtonTolerance = Geometry_1.Geometry.smallNewtonStep
|
|
75
|
+
constructor(geometryB, xyTolerance = Geometry_1.Geometry.smallMetricDistance, newtonTolerance = Geometry_1.Geometry.smallNewtonStep, maxIterations = 50 // seen: 47
|
|
76
|
+
) {
|
|
74
77
|
super();
|
|
75
78
|
this._geometryB = geometryB instanceof ProxyCurve_1.ProxyCurve ? geometryB.proxyCurve : geometryB;
|
|
76
79
|
this._maxDistanceSquared = Geometry_1.Geometry.smallMetricDistanceSquared;
|
|
77
80
|
this._xyTolerance = xyTolerance;
|
|
78
81
|
this._newtonTolerance = newtonTolerance;
|
|
82
|
+
this._maxIterations = maxIterations;
|
|
79
83
|
const compare = CurveLocationDetail_1.CurveLocationDetailPair.comparePairsByPoints(xyTolerance, true);
|
|
80
84
|
this._results = new core_bentley_1.SortedArray(compare, core_bentley_1.DuplicatePolicy.Retain);
|
|
81
85
|
}
|
|
@@ -594,21 +598,27 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
594
598
|
return curve instanceof BSplineCurve_1.BSplineCurve3dBase || curve instanceof TransitionSpiral3d_1.TransitionSpiral3d;
|
|
595
599
|
}
|
|
596
600
|
/**
|
|
597
|
-
* Process seeds for xy close approach between one curve and another curve
|
|
601
|
+
* Process seeds for xy close approach between one curve and another curve.
|
|
602
|
+
* * Seeds typically result from solving a discrete close approach problem, where one or both curves have been stroked.
|
|
598
603
|
* * Refine each result via Newton iteration. If it doesn't converge, remove it.
|
|
599
604
|
* @param seeds the initial seed results to refine.
|
|
600
605
|
* @param curveA curve to find its XY close approach with curveB.
|
|
601
|
-
* @param
|
|
606
|
+
* @param curveAIsStroked whether `seeds` contains results from a linestring approximation to `curveA`
|
|
607
|
+
* @param curveB the other curve.
|
|
608
|
+
* @param curveBIsStroked whether `seeds` contains results from a linestring approximation to `curveB`
|
|
602
609
|
* @param reversed whether `curveB` data is in `detailA` of each recorded pair, and `curveA` data in `detailB`.
|
|
603
610
|
*/
|
|
604
|
-
refineStrokedResultsByNewton(seeds, curveA, curveB, reversed = false) {
|
|
611
|
+
refineStrokedResultsByNewton(seeds, curveA, curveAIsStroked, curveB, curveBIsStroked, reversed = false) {
|
|
605
612
|
const xyMatchingFunction = new Newton_1.CurveCurveCloseApproachXYRRtoRRD(curveA, curveB);
|
|
606
|
-
const newtonSearcher = new Newton_1.Newton2dUnboundedWithDerivative(xyMatchingFunction,
|
|
613
|
+
const newtonSearcher = new Newton_1.Newton2dUnboundedWithDerivative(xyMatchingFunction, this._maxIterations, this._newtonTolerance);
|
|
607
614
|
for (const seed of seeds) {
|
|
608
615
|
const detailA = reversed ? seed.detailB : seed.detailA;
|
|
609
616
|
const detailB = reversed ? seed.detailA : seed.detailB;
|
|
610
617
|
(0, core_bentley_1.assert)(detailB.curve instanceof LineString3d_1.LineString3d, "Caller has discretized the curve");
|
|
611
|
-
|
|
618
|
+
// when the curve is stroked, project the discrete seed to compute a fraction in the original curve's parameter space
|
|
619
|
+
const u = curveAIsStroked ? curveA.closestPointXY(detailA.point)?.fraction ?? detailA.fraction : detailA.fraction;
|
|
620
|
+
const v = curveBIsStroked ? curveB.closestPointXY(detailB.point)?.fraction ?? detailB.fraction : detailB.fraction;
|
|
621
|
+
newtonSearcher.setUV(u, v);
|
|
612
622
|
if (newtonSearcher.runIterations()) {
|
|
613
623
|
const fractionA = newtonSearcher.getU();
|
|
614
624
|
const fractionB = newtonSearcher.getV();
|
|
@@ -651,7 +661,7 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
651
661
|
/**
|
|
652
662
|
* Compute the XY close approach of a curve and another curve to be stroked.
|
|
653
663
|
* @param curveA curve to find its XY close approach with curveB.
|
|
654
|
-
* @param curveB the other curve to be stroked.
|
|
664
|
+
* @param curveB the other curve, to be stroked.
|
|
655
665
|
* @param reversed whether `curveB` data will be recorded in `detailA` of each result, and `curveA` data in `detailB`.
|
|
656
666
|
*/
|
|
657
667
|
dispatchCurveStrokedCurve(curveA, curveB, reversed) {
|
|
@@ -660,12 +670,11 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
660
670
|
for (const intersection of intersections)
|
|
661
671
|
this.testAndRecordPair(intersection, reversed);
|
|
662
672
|
// append seeds computed by solving the discretized spiral close approach problem, then refine the seeds via Newton
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
cpA = this.strokeCurve(curveA);
|
|
673
|
+
const curveAIsStroked = this.needsStroking(curveA);
|
|
674
|
+
const cpA = curveAIsStroked ? this.strokeCurve(curveA) : curveA;
|
|
666
675
|
const cpB = this.strokeCurve(curveB);
|
|
667
676
|
const seeds = this.computeDiscreteCloseApproachResults(cpA, cpB, reversed);
|
|
668
|
-
this.refineStrokedResultsByNewton(seeds, curveA, curveB, reversed);
|
|
677
|
+
this.refineStrokedResultsByNewton(seeds, curveA, curveAIsStroked, curveB, true, reversed);
|
|
669
678
|
if (curveA instanceof LineString3d_1.LineString3d) { // explicitly test corners (where Newton converges too slowly)
|
|
670
679
|
const fStep = Geometry_1.Geometry.safeDivideFraction(1.0, curveA.numEdges(), 0);
|
|
671
680
|
const v0 = CurveCurveCloseApproachXY._workPointBB0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurveCurveCloseApproachXY.js","sourceRoot":"","sources":["../../../../src/curve/internalContexts/CurveCurveCloseApproachXY.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,sDAA2E;AAC3E,6DAAgF;AAEhF,6CAA0C;AAC1C,sEAAkF;AAClF,gFAA6E;AAC7E,sEAA2D;AAC3D,kDAAiD;AACjD,kDAA0G;AAC1G,4DAA2D;AAC3D,4DAAyD;AACzD,oCAAiC;AACjC,gFAA6E;AAC7E,wDAAqD;AACrD,8CAA2C;AAC3C,gEAAyG;AACzG,sDAAmD;AAEnD,oDAAiD;AACjD,kDAA+C;AAC/C,8CAA2C;AAC3C,qEAAkE;AAGlE,+BAA+B;AAE/B;;;;;;;;;;;;;GAaG;AACH,MAAa,yBAA0B,SAAQ,gDAA8B;IACnE,UAAU,CAAuB;IACzC;;;OAGG;IACK,oBAAoB,CAAqB;IACjD,gFAAgF;IACxE,mBAAmB,CAAS;IAC5B,YAAY,C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I,CAAC,CAAC,CAAC;QAC7E,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,+DAA+D;IAC/C,sBAAsB,CAAC,MAA0B;QAC/D,IAAI,IAAI,CAAC,UAAU,YAAY,yDAA2B,EAAE,CAAC;YAC3D,IAAI,CAAC,mCAAmC,CAAC,MAAM,EAAE,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC3F,CAAC;aAAM,IAAI,IAAI,CAAC,UAAU,YAAY,+BAAc,EAAE,CAAC;YACrD,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAChE,CAAC;aAAM,IAAI,IAAI,CAAC,UAAU,YAAY,iCAAe,EAAE,CAAC;YACtD,IAAI,CAAC,uBAAuB,CAAC,MAAM,EAAE,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/E,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,8EAA8E;IAC9D,iCAAiC,CAAC,KAAkC;QAClF,KAAK,CAAC,iCAAiC,CAAC,KAAK,CAAC,CAAC;QAC/C,kIAAkI;QAClI,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;QAClD,YAAY,CAAC,OAAO,CAAC,CAAC,IAA6B,EAAE,EAAE;YACrD,yDAA2B,CAAC,qCAAqC,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;YAC1F,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;IACD,8EAA8E;IAC9D,qBAAqB,CAAC,MAAuB;QAC3D,oEAAoE;QACpE,OAAO,SAAS,CAAC;IACnB,CAAC;;AAzvBH,8DA0vBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { assert, DuplicatePolicy, SortedArray } from \"@itwin/core-bentley\";\nimport { BSplineCurve3d, BSplineCurve3dBase } from \"../../bspline/BSplineCurve\";\nimport { BSplineCurve3dH } from \"../../bspline/BSplineCurve3dH\";\nimport { Geometry } from \"../../Geometry\";\nimport { RecurseToCurvesGeometryHandler } from \"../../geometry3d/GeometryHandler\";\nimport { GrowableFloat64Array } from \"../../geometry3d/GrowableFloat64Array\";\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\nimport { Range3d } from \"../../geometry3d/Range\";\nimport { CurveCurveCloseApproachXYRRtoRRD, Newton2dUnboundedWithDerivative } from \"../../numerics/Newton\";\nimport { AnalyticRoots } from \"../../numerics/Polynomials\";\nimport { SmallSystem } from \"../../numerics/SmallSystem\";\nimport { Arc3d } from \"../Arc3d\";\nimport { CurveChainWithDistanceIndex } from \"../CurveChainWithDistanceIndex\";\nimport { CurveCollection } from \"../CurveCollection\";\nimport { CurveCurve } from \"../CurveCurve\";\nimport { CurveIntervalRole, CurveLocationDetail, CurveLocationDetailPair } from \"../CurveLocationDetail\";\nimport { CurvePrimitive } from \"../CurvePrimitive\";\nimport { AnyCurve } from \"../CurveTypes\";\nimport { LineSegment3d } from \"../LineSegment3d\";\nimport { LineString3d } from \"../LineString3d\";\nimport { ProxyCurve } from \"../ProxyCurve\";\nimport { TransitionSpiral3d } from \"../spiral/TransitionSpiral3d\";\nimport { StrokeOptions } from \"../StrokeOptions\";\n\n// cspell:word XYRR currentdFdX\n\n/**\n * Handler class for XY close approach between _geometryB and another geometry.\n * * Approach means the XY distance (z is ignored) between _geometryB and another geometry.\n * * Closest approach is a measure of the proximity of one curve to another. It's the length of the shortest line\n * segment perpendicular to both curves; if the curves intersect, the closest approach is zero. In the context of\n * this class, z-coordinates are ignored, so the closest approach is as seen in the top view. If you have coplanar\n * input curves and want to find closest approach in their plane, rotate them first into a plane parallel to the\n * xy-plane, then afterward, rotate the results back as required.\n * * Close approach can also be from a curve endpoint perpendicular to another curve or from a curve endpoint to\n * another curve endpoint.\n * * Instances are initialized and called from CurveCurve.\n * * geometryB is saved for later reference.\n * @internal\n */\nexport class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {\n private _geometryB: AnyCurve | undefined;\n /**\n * Maximum XY distance (z is ignored). Approach larger than this is not interesting.\n * This is caller defined and can be undefined.\n */\n private _maxDistanceToAccept: number | undefined;\n /** Squared max distance. Default is [[Geometry.smallMetricDistanceSquared]]. */\n private _maxDistanceSquared: number;\n private _xyTolerance: number;\n private _newtonTolerance: number;\n /**\n * Start and end points of line segments that meet closest approach criteria, i.e., they are perpendicular to\n * both curves and their length is smaller than _maxDistanceToAccept.\n */\n private _results: SortedArray<CurveLocationDetailPair>;\n\n private static _workPointAA0 = Point3d.create();\n private static _workPointAA1 = Point3d.create();\n private static _workPointBB0 = Point3d.create();\n private static _workPointBB1 = Point3d.create();\n private static _workPointB = Point3d.create();\n\n /**\n * Constructor.\n * @param geometryB second curve for intersection. Saved for reference by specific handler methods.\n * @param xyTolerance optional tolerance for comparing xy points (default [[Geometry.smallMetricDistance]]).\n * @param newtonTolerance optional relative fraction tolerance for Newton iteration (default [[Geometry.smallNewtonStep]]).\n */\n public constructor(geometryB?: AnyCurve, xyTolerance: number = Geometry.smallMetricDistance, newtonTolerance: number = Geometry.smallNewtonStep) {\n super();\n this._geometryB = geometryB instanceof ProxyCurve ? geometryB.proxyCurve : geometryB;\n this._maxDistanceSquared = Geometry.smallMetricDistanceSquared;\n this._xyTolerance = xyTolerance;\n this._newtonTolerance = newtonTolerance;\n const compare = CurveLocationDetailPair.comparePairsByPoints(xyTolerance, true);\n this._results = new SortedArray<CurveLocationDetailPair>(compare, DuplicatePolicy.Retain);\n }\n /** Set the (possibly undefined) max XY distance (z is ignored) to accept. */\n public set maxDistanceToAccept(value: number | undefined) {\n if (value === undefined) {\n this._maxDistanceToAccept = undefined;\n this._maxDistanceSquared = Geometry.smallMetricDistanceSquared;\n } else {\n this._maxDistanceToAccept = Math.abs(value);\n this._maxDistanceSquared = value * value;\n }\n }\n /** Access the (possibly undefined) max XY distance (z is ignored) to accept. */\n public get maxDistanceToAccept(): number | undefined {\n return this._maxDistanceToAccept;\n }\n /** Ask if the maxDistanceToAccept value is defined and positive */\n public get isMaxDistanceSet(): boolean {\n return this._maxDistanceToAccept !== undefined && this._maxDistanceToAccept > 0;\n }\n /**\n * Reset the geometry.\n * * Undefined inputs are ignored.\n * * All other instance data is unchanged, including accumulated intersections.\n */\n public resetGeometry(geometryB?: AnyCurve) {\n if (geometryB)\n this._geometryB = geometryB;\n }\n /** returns true if `fraction` is in [0,1] within tolerance */\n private acceptFraction(fraction: number, fractionTol: number = 1.0e-12) {\n if (fraction < -fractionTol)\n return false;\n if (fraction > 1.0 + fractionTol)\n return false;\n return true;\n }\n /** Extract (and clear) the results, structured as an array of CurveLocationDetailPair. */\n public grabPairedResults(): CurveLocationDetailPair[] {\n return this._results.extractArray();\n }\n /**\n * Create and record a close-approach pair from raw curve/fraction/point data.\n * * If points are undefined, they are computed from the fractions via `fractionToPoint`.\n * * Fractions are global (i.e., relative to the full curve, not a sub-segment).\n * * The pair is recorded only if the XY distance is within `_maxDistanceSquared`.\n * @param cpA first curve\n * @param fA global fraction on cpA\n * @param pointA point on cpA at fA, or undefined to compute from fA\n * @param cpB second curve\n * @param fB global fraction on cpB\n * @param pointB point on cpB at fB, or undefined to compute from fB\n * @param reversed if true, swap detailA and detailB before recording\n */\n private testAndRecordPointPair(\n cpA: CurvePrimitive, fA: number, pointA: Point3d | undefined,\n cpB: CurvePrimitive, fB: number, pointB: Point3d | undefined,\n reversed: boolean\n ): void {\n if (!pointA)\n pointA = cpA.fractionToPoint(fA);\n if (!pointB)\n pointB = cpB.fractionToPoint(fB);\n const d2 = pointA.distanceSquaredXY(pointB);\n if (d2 <= this._maxDistanceSquared) {\n const d = Math.sqrt(d2);\n const detailA = CurveLocationDetail.createCurveFractionPointDistance(cpA, fA, pointA, d);\n const detailB = CurveLocationDetail.createCurveFractionPointDistance(cpB, fB, pointB, d);\n detailA.setIntervalRole(CurveIntervalRole.isolated);\n detailB.setIntervalRole(CurveIntervalRole.isolated);\n const pair = CurveLocationDetailPair.createCapture(detailA, detailB);\n if (reversed)\n pair.swapDetails();\n this._results.insert(pair);\n }\n }\n /**\n * Record a pre-built close-approach pair with global fractions already set.\n * * Computes and stores the XY distance on both details.\n * * The pair is recorded only if the XY distance is within `_maxDistanceSquared`.\n * @param pair details with global fractions and points already set; modified in place\n * @param reversed if true, swap detailA and detailB before recording\n */\n private testAndRecordPair(pair: CurveLocationDetailPair, reversed: boolean) {\n const d2 = pair.detailA.point.distanceSquaredXY(pair.detailB.point);\n if (d2 > this._maxDistanceSquared)\n return;\n const d = Math.sqrt(d2);\n pair.detailA.a = pair.detailB.a = d;\n pair.detailA.setIntervalRole(CurveIntervalRole.isolated);\n pair.detailB.setIntervalRole(CurveIntervalRole.isolated);\n if (reversed)\n pair.swapDetails();\n this._results.insert(pair);\n }\n /**\n * Convert a close-approach pair from local (sub-segment) fractions to global fractions, then record it.\n * * Local fractions in the pair are interpolated into the global fraction ranges.\n * * Points are recomputed from the parent curves at the global fractions.\n * * The pair is recorded only if the XY distance is within `_maxDistanceSquared`.\n * @param pair local details (curve unspecified); modified in place with global fractions, curves, and points\n * @param cpA parent curve A\n * @param fractionA0 global fraction corresponding to local fraction 0 on curve A\n * @param fractionA1 global fraction corresponding to local fraction 1 on curve A\n * @param cpB parent curve B\n * @param fractionB0 global fraction corresponding to local fraction 0 on curve B\n * @param fractionB1 global fraction corresponding to local fraction 1 on curve B\n * @param reversed if true, swap detailA and detailB before recording\n */\n private testAndRecordLocalPair(\n pair: CurveLocationDetailPair,\n cpA: CurvePrimitive, fractionA0: number, fractionA1: number,\n cpB: CurvePrimitive, fractionB0: number, fractionB1: number,\n reversed: boolean,\n ) {\n const globalFractionA = Geometry.interpolate(fractionA0, pair.detailA.fraction, fractionA1);\n const globalFractionB = Geometry.interpolate(fractionB0, pair.detailB.fraction, fractionB1);\n const pointA = cpA.fractionToPoint(globalFractionA);\n const pointB = cpB.fractionToPoint(globalFractionB);\n const d2 = pointA.distanceSquaredXY(pointB);\n if (d2 > this._maxDistanceSquared)\n return;\n const d = Math.sqrt(d2);\n CurveLocationDetail.createCurveFractionPointDistance(cpA, globalFractionA, pointA, d, pair.detailA);\n CurveLocationDetail.createCurveFractionPointDistance(cpB, globalFractionB, pointB, d, pair.detailB);\n pair.detailA.setIntervalRole(CurveIntervalRole.isolated);\n pair.detailB.setIntervalRole(CurveIntervalRole.isolated);\n if (reversed)\n pair.swapDetails();\n this._results.insert(pair);\n }\n /** Modify the current closest approach if the inputs are closer. */\n private static updatePointToSegmentDistance(\n closestApproach: CurveLocationDetailPair,\n fractionA: number, pointA: Point3d,\n fractionB: number, pointB0: Point3d, pointB1: Point3d,\n maxDistanceSquared: number,\n ): boolean {\n let updated = false;\n if (fractionB < 0)\n fractionB = 0;\n else if (fractionB > 1)\n fractionB = 1;\n const pointB = pointB0.interpolate(fractionB, pointB1, this._workPointB);\n const distanceSquared = pointB.distanceSquaredXY(pointA);\n if (distanceSquared <= Math.min(maxDistanceSquared, closestApproach.detailA.a)) {\n closestApproach.detailA.setFP(fractionA, pointA, undefined, distanceSquared);\n closestApproach.detailB.setFP(fractionB, pointB, undefined, distanceSquared);\n updated = true;\n }\n return updated;\n }\n /**\n * Return fractions of close approach within maxDistance between two line segments (a0,a1) and (b0,b1).\n * * Math details can be found at core/geometry/internaldocs/Curve.md\n * @param a0 start point of line a\n * @param a1 end point of line a\n * @param b0 start point of line b\n * @param b1 end point of line b\n * @param maxDistanceSquared maximum distance squared (assumed to be positive)\n * @returns a pair of details for the closest approach, or `undefined` if no approach is within `maxDistanceSquared`.\n * `detailA.fraction` is the fraction on segment a; `detailB.fraction` is the fraction on segment b. Returned\n * details store the *squared* distance in the `a` property.\n */\n private static segmentSegmentBoundedApproach(\n a0: Point3d, a1: Point3d,\n b0: Point3d, b1: Point3d,\n maxDistanceSquared: number,\n ): CurveLocationDetailPair | undefined {\n const ux = a1.x - a0.x;\n const uy = a1.y - a0.y;\n const vx = b1.x - b0.x;\n const vy = b1.y - b0.y;\n const e00x = b0.x - a0.x;\n const e00y = b0.y - a0.y;\n const e01x = b1.x - a0.x;\n const e01y = b1.y - a0.y;\n const e10x = b0.x - a1.x;\n const e10y = b0.y - a1.y;\n const hab0 = Geometry.crossProductXYXY(ux, uy, e00x, e00y);\n const hab1 = Geometry.crossProductXYXY(ux, uy, e01x, e01y);\n const hba0 = -Geometry.crossProductXYXY(vx, vy, e00x, e00y);\n const hba1 = -Geometry.crossProductXYXY(vx, vy, e10x, e10y);\n if (hab0 * hab1 < 0.0 && hba0 * hba1 < 0.0) { // true intersection, strictly within both segments\n const fractionA = -hba0 / (hba1 - hba0);\n const fractionB = -hab0 / (hab1 - hab0);\n return CurveLocationDetailPair.createCapture(\n CurveLocationDetail.createCurveFractionPoint(undefined, fractionA, a0.interpolate(fractionA, a1)),\n CurveLocationDetail.createCurveFractionPoint(undefined, fractionB, b0.interpolate(fractionB, b1)),\n );\n }\n // there's no intersection, so find the closest approach within maxDistance from an endpoint\n const closestApproach = new CurveLocationDetailPair();\n closestApproach.detailA.a = 2 * maxDistanceSquared; // init to an approach that's too far away\n let reversed = false;\n const uu = Geometry.hypotenuseSquaredXY(ux, uy);\n if (hab0 * hab0 <= maxDistanceSquared * uu) { // test distance of b0 to u\n const fractionA = Geometry.safeDivideFraction(Geometry.dotProductXYXY(ux, uy, e00x, e00y), uu, 0.0);\n if (this.updatePointToSegmentDistance(closestApproach, 0, b0, fractionA, a0, a1, maxDistanceSquared))\n reversed = true;\n }\n if (hab1 * hab1 <= maxDistanceSquared * uu) { // test distance of b1 to u\n const fractionA = Geometry.safeDivideFraction(Geometry.dotProductXYXY(ux, uy, e01x, e01y), uu, 0.0);\n if (this.updatePointToSegmentDistance(closestApproach, 1, b1, fractionA, a0, a1, maxDistanceSquared))\n reversed = true;\n }\n const vv = Geometry.hypotenuseSquaredXY(vx, vy);\n if (hba0 * hba0 <= maxDistanceSquared * vv) { // test distance of a0 to v\n const fractionB = Geometry.safeDivideFraction(-Geometry.dotProductXYXY(vx, vy, e00x, e00y), vv, 0.0);\n if (this.updatePointToSegmentDistance(closestApproach, 0, a0, fractionB, b0, b1, maxDistanceSquared))\n reversed = false;\n }\n if (hba1 * hba1 <= maxDistanceSquared * vv) { // test distance of a1 to v\n const fractionB = Geometry.safeDivideFraction(-Geometry.dotProductXYXY(vx, vy, e10x, e10y), vv, 0.0);\n if (this.updatePointToSegmentDistance(closestApproach, 1, a1, fractionB, b0, b1, maxDistanceSquared))\n reversed = false;\n }\n if (closestApproach.detailA.a > maxDistanceSquared)\n return undefined;\n if (reversed)\n closestApproach.swapDetails();\n return closestApproach;\n }\n /**\n * Compute closest approaches from the endpoints of each curve (if open) to the other curve.\n * Record a [[CurveLocationDetailPair]] if such a distance is less than [[maxDistance]].\n * @param cpA curveA\n * @param cpB curveB\n * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to curveA).\n */\n private testAndRecordEndPointApproaches(cpA: CurvePrimitive, cpB: CurvePrimitive, reversed: boolean): void {\n const pt = CurveCurveCloseApproachXY._workPointB;\n // in closest approach context, endpoints of full sweep arcs are artificial locations, and thus ignored\n const isClosedArc = (curve: CurvePrimitive) => curve instanceof Arc3d && curve.sweep.isFullCircle;\n if (!isClosedArc(cpA)) {\n this.testAndRecordProjection(cpA, 0, cpA.startPoint(pt), cpB, reversed);\n this.testAndRecordProjection(cpA, 1, cpA.endPoint(pt), cpB, reversed);\n }\n if (!isClosedArc(cpB)) {\n this.testAndRecordProjection(cpB, 0, cpB.startPoint(pt), cpA, !reversed);\n this.testAndRecordProjection(cpB, 1, cpB.endPoint(pt), cpA, !reversed);\n }\n }\n /** Find the closest xy approach between `pointA` and `cpB`. */\n private testAndRecordProjection(cpA: CurvePrimitive, fA: number, pointA: Point3d, cpB: CurvePrimitive, reversed: boolean): void {\n const detail = cpB.closestPointXY(pointA);\n if (detail)\n this.testAndRecordPointPair(cpA, fA, pointA, cpB, detail.fraction, detail.point, reversed);\n }\n /**\n * Compute closest xy approach of two line segments.\n * Filter by extension rules.\n * Record with fraction mapping.\n * * The fraction mappings allow portions of a linestring to be passed here.\n */\n private computeSegmentSegment(\n cpA: CurvePrimitive, pointA0: Point3d, fractionA0: number, pointA1: Point3d, fractionA1: number,\n cpB: CurvePrimitive, pointB0: Point3d, fractionB0: number, pointB1: Point3d, fractionB1: number,\n reversed: boolean,\n ): void {\n // compute a pair with fractions local to segments\n const approach = CurveCurveCloseApproachXY.segmentSegmentBoundedApproach(\n pointA0, pointA1, pointB0, pointB1, this._maxDistanceSquared,\n );\n // adjust the pair to refer to input curves and global fractions, then record it if new\n if (approach) {\n approach.detailA.setCurve(cpA);\n approach.detailB.setCurve(cpB);\n this.testAndRecordLocalPair(approach, cpA, fractionA0, fractionA1, cpB, fractionB0, fractionB1, reversed);\n }\n }\n /**\n * Compute the perpendiculars between a line segment and an arc, without extending either curve.\n * * One or two perpendiculars will be found.\n * * Each perpendicular segment starts or ends on the arc where the arc tangent is parallel to the line tangent.\n * @param startA line segment start point\n * @param endA line segment end point\n * @param arcB the arc\n * @param announce callback to receive line and arc fractions and optional points of each perpendicular segment computed.\n */\n private announceAllPerpendicularsSegmentArcBounded(\n startA: Point3d, endA: Point3d, arcB: Arc3d,\n announce: (lineFraction: number, linePoint: Point3d | undefined, arcFraction: number, arcPoint: Point3d | undefined) => void,\n ): void {\n const dotUT = arcB.vector0.crossProductStartEndXY(startA, endA);\n const dotVT = arcB.vector90.crossProductStartEndXY(startA, endA);\n const parallelRadians = Math.atan2(dotVT, dotUT);\n for (const radians1 of [parallelRadians, parallelRadians + Math.PI]) {\n const arcPoint = arcB.radiansToPoint(radians1);\n const arcFraction = arcB.sweep.radiansToSignedPeriodicFraction(radians1);\n if (this.acceptFraction(arcFraction)) { // reject solution outside arc sweep\n const lineFraction = SmallSystem.lineSegment3dXYClosestPointUnbounded(startA, endA, arcPoint);\n if (lineFraction !== undefined && this.acceptFraction(lineFraction))\n announce(lineFraction, undefined, arcFraction, arcPoint);\n }\n }\n }\n /**\n * Find close approaches within maxDistance between a line segment and an arc.\n * To consider:\n * 1) intersection between arc and segment.\n * 2) endpoints to endpoints, or endpoints projection to the other curve.\n * 3) arc tangent parallel to line segment\n * @param lineA the line segment\n * @param arcB the arc\n * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to arcA).\n */\n private computeSegmentArc(lineA: LineSegment3d, arcB: Arc3d, reversed: boolean): void {\n // 1) intersection between arc and line segment (or string).\n // Suppose:\n // Arc: X = C + cU + sV where c = cos(theta) and s = sin(theta)\n // Line: contains points A0 and A1\n // The arc intersects the line at point X if det(A0, A1, X) = 0 with homogeneous xyw points and vectors.\n // With equational X: det(A0, A1, C) + c*det(A0, A1, U) + s*det(A0, A1, V) = 0.\n // solve for theta.\n // evaluate points.\n // project back to line.\n let intersectionFound = false;\n const data = arcB.toTransformedVectors();\n const alpha = Geometry.tripleProductXYW(lineA.point0Ref, 1, lineA.point1Ref, 1, data.center, 1); // det(A0, A1, C)\n const beta = Geometry.tripleProductXYW(lineA.point0Ref, 1, lineA.point1Ref, 1, data.vector0, 0); // det(A0, A1, U)\n const gamma = Geometry.tripleProductXYW(lineA.point0Ref, 1, lineA.point1Ref, 1, data.vector90, 0); // det(A0, A1, V)\n const cosines = new GrowableFloat64Array(2);\n const sines = new GrowableFloat64Array(2);\n const radians = new GrowableFloat64Array(2);\n const numRoots = AnalyticRoots.appendImplicitLineUnitCircleIntersections(alpha, beta, gamma, cosines, sines, radians);\n for (let i = 0; i < numRoots; i++) {\n const arcPoint = data.center.plus2Scaled(data.vector0, cosines.atUncheckedIndex(i), data.vector90, sines.atUncheckedIndex(i));\n const arcFraction = data.sweep.radiansToSignedPeriodicFraction(radians.atUncheckedIndex(i));\n if (this.acceptFraction(arcFraction)) { // reject solution outside arc sweep\n const lineFraction = SmallSystem.lineSegment3dXYClosestPointUnbounded(lineA.point0Ref, lineA.point1Ref, arcPoint);\n if (lineFraction !== undefined && this.acceptFraction(lineFraction)) {\n this.testAndRecordPointPair(lineA, lineFraction, undefined, arcB, arcFraction, arcPoint, reversed);\n intersectionFound = true;\n }\n }\n }\n if (intersectionFound)\n return;\n // 2) endpoints to endpoints, or endpoints projection to the other curve.\n this.testAndRecordEndPointApproaches(lineA, arcB, reversed);\n // 3) arc tangent parallel to line segment.\n // If line does not intersect the arc, then the closest (and/or the furthest) point on arc to the line is a\n // point where the tangent line on arc at that point is parallel to the line.\n this.announceAllPerpendicularsSegmentArcBounded(lineA.point0Ref, lineA.point1Ref, arcB,\n (lineFraction: number, linePoint: Point3d | undefined, arcFraction: number, arcPoint: Point3d | undefined) =>\n this.testAndRecordPointPair(lineA, lineFraction, linePoint, arcB, arcFraction, arcPoint, reversed),\n );\n }\n /**\n * Compute segments perpendicular to two elliptical arcs, without extending either curve.\n * * Perpendiculars from an endpoint are not explicitly computed.\n * * Intersections are also found by this search: they are reported as zero-length segments.\n * @param arcA first arc\n * @param arcB second arc\n * @param reversed swap the details in the recorded pair (default: false)\n */\n public allPerpendicularsArcArcBounded(arcA: Arc3d, arcB: Arc3d, reversed: boolean = false): void {\n const newtonEvaluator = new CurveCurveCloseApproachXYRRtoRRD(arcA, arcB);\n // HEURISTIC: 2 ellipses have up to 8 perpendiculars\n const seedDelta = 1 / 10; // denominator 9 fails the unit test\n const seedStart = seedDelta / 2;\n const newtonSearcher = new Newton2dUnboundedWithDerivative(newtonEvaluator, 100); // observed convergence to 1.0e-11 in 49 iters\n for (let seedU = seedStart; seedU < 1; seedU += seedDelta) {\n for (let seedV = seedStart; seedV < 1; seedV += seedDelta) {\n newtonSearcher.setUV(seedU, seedV);\n if (newtonSearcher.runIterations()) {\n const fractionA = newtonSearcher.getU();\n const fractionB = newtonSearcher.getV();\n if (this.acceptFraction(fractionA) && this.acceptFraction(fractionB)) {\n this.testAndRecordPointPair(arcA, fractionA, undefined, arcB, fractionB, undefined, reversed);\n }\n }\n }\n }\n }\n /** Low level dispatch of arc with Arc3d. */\n private dispatchArcArc(cpA: Arc3d, cpB: Arc3d, reversed: boolean): void {\n const rangeA = cpA.range();\n const rangeB = cpB.range();\n if (this._maxDistanceToAccept)\n rangeA.expandInPlace(this._maxDistanceToAccept);\n if (!rangeB.intersectsRangeXY(rangeA))\n return;\n // 1) endpoints to endpoints or endpoints projection to the other curve\n this.testAndRecordEndPointApproaches(cpA, cpB, reversed);\n // 2) perpendicular line between 2 arcs (includes intersections)\n this.allPerpendicularsArcArcBounded(cpA, cpB, reversed);\n }\n /** Detail computation for segment approaching linestring. */\n private computeSegmentLineString(segA: LineSegment3d, lsB: LineString3d, reversed: boolean): void {\n const numB = lsB.numPoints();\n const deltaFracB = Geometry.safeDivideFraction(1, numB - 1, 0);\n const pointA0 = segA.point0Ref;\n const pointA1 = segA.point1Ref;\n const pointB0 = CurveCurveCloseApproachXY._workPointBB0;\n const pointB1 = CurveCurveCloseApproachXY._workPointBB1;\n for (let i = 0; i < numB - 1; ++i) {\n const fB0 = i * deltaFracB; // global linestring fractions\n const fB1 = (i + 1 === numB - 1) ? 1.0 : (i + 1) * deltaFracB; // make sure we nail the end fraction\n lsB.packedPoints.getPoint3dAtUncheckedPointIndex(i, pointB0);\n lsB.packedPoints.getPoint3dAtUncheckedPointIndex(i + 1, pointB1);\n this.computeSegmentSegment(segA, pointA0, 0.0, pointA1, 1.0, lsB, pointB0, fB0, pointB1, fB1, reversed);\n }\n }\n /** Detail computation for arc approaching linestring. */\n private computeArcLineString(arcA: Arc3d, lsB: LineString3d, reversed: boolean): void {\n const rangeA = arcA.range();\n const rangeB = lsB.range();\n if (this._maxDistanceToAccept)\n rangeA.expandInPlace(this._maxDistanceToAccept);\n if (!rangeB.intersectsRangeXY(rangeA))\n return;\n const v0 = CurveCurveCloseApproachXY._workPointBB0;\n const v1 = CurveCurveCloseApproachXY._workPointBB1;\n // 1. record intersections\n const intersections = CurveCurve.intersectionXYPairs(arcA, false, lsB, false, this._xyTolerance);\n for (const intersection of intersections)\n this.testAndRecordPair(intersection, reversed);\n // 2. record linestring interior vertex projections onto arc\n const fStep = Geometry.safeDivideFraction(1.0, lsB.numEdges(), 0);\n for (let i = 1; i < lsB.numEdges(); ++i)\n this.testAndRecordProjection(lsB, i * fStep, lsB.pointAtUnchecked(i, v0), arcA, !reversed);\n // 3. record arc/linestring endpoint projections onto linestring/arc\n this.testAndRecordEndPointApproaches(arcA, lsB, reversed);\n // 4. record perpendiculars from within a segment to the arc\n lsB.startPoint(v0);\n for (let iSeg = 0; iSeg < lsB.numEdges(); ++iSeg, v0.setFrom(v1)) {\n lsB.pointAtUnchecked(iSeg + 1, v1);\n this.announceAllPerpendicularsSegmentArcBounded(v0, v1, arcA,\n (lineFraction: number, linePoint: Point3d | undefined, arcFraction: number, arcPoint: Point3d | undefined) => {\n const fLineString = lsB.segmentIndexAndLocalFractionToGlobalFraction(iSeg, lineFraction);\n this.testAndRecordPointPair(arcA, arcFraction, arcPoint, lsB, fLineString, linePoint, reversed);\n },\n );\n }\n }\n /**\n * Set bits for comparison to range xy\n * * bit 0x01 => x smaller than range.low.x\n * * bit 0x02 => x larger than range.high.x\n * * bit 0x04 => y smaller than range.low.y\n * * bit 0x08 => y larger than range.high.y\n * * If we divide XY plane into 9 areas using the range, the function returns 0 for points\n * inside the range. Below is other binary numbers returned by the function for all 9 areas:\n * 1001 | 1000 | 1010\n * ------------------\n * 1 | 0 | 10\n * ------------------\n * 101 | 100 | 110\n * @param xy point to test\n * @param range range for comparison\n */\n private classifyBitsPointRangeXY(x: number, y: number, range: Range3d): number {\n let result = 0;\n if (x < range.low.x)\n result = 0x01;\n else if (x > range.high.x)\n result = 0x02;\n // note the OR operation\n if (y < range.low.y)\n result |= 0x04;\n else if (y > range.high.y)\n result |= 0x08;\n return result;\n }\n /** Low level dispatch of line string with line string. */\n private computeLineStringLineString(lsA: LineString3d, lsB: LineString3d, reversed: boolean): void {\n const rangeA = lsA.range();\n const rangeB = lsB.range();\n if (this._maxDistanceToAccept)\n rangeA.expandInPlace(this._maxDistanceToAccept);\n if (!rangeB.intersectsRangeXY(rangeA))\n return;\n let bitB0: number;\n let bitB1: number;\n const rangeA1 = Range3d.createNull();\n const pointA0 = CurveCurveCloseApproachXY._workPointAA0;\n const pointA1 = CurveCurveCloseApproachXY._workPointAA1;\n const pointB0 = CurveCurveCloseApproachXY._workPointBB0;\n const pointB1 = CurveCurveCloseApproachXY._workPointBB1;\n const numA = lsA.numPoints();\n const numB = lsB.numPoints();\n if (numA > 1 && numB > 1) {\n const dfA = 1.0 / (numA - 1);\n const dfB = 1.0 / (numB - 1);\n let fA0 = 0.0;\n let fA1, fB0, fB1;\n lsA.pointAt(0, pointA0);\n for (let ia = 1; ia < numA; ia++, pointA0.setFrom(pointA1), fA0 = fA1) {\n fA1 = ia * dfA;\n fB0 = 0.0;\n lsA.pointAt(ia, pointA1);\n // rangeA1 is around line segment [A0,A1] expanded by max distance\n rangeA1.setNull();\n rangeA1.extendPoint(pointA0);\n rangeA1.extendPoint(pointA1);\n if (this._maxDistanceToAccept)\n rangeA1.expandInPlace(this._maxDistanceToAccept);\n if (rangeA1.intersectsRangeXY(rangeB)) {\n lsB.pointAt(0, pointB0);\n bitB0 = this.classifyBitsPointRangeXY(pointB0.x, pointB0.y, rangeA1);\n for (let ib = 1; ib < numB; ib++, pointB0.setFrom(pointB1), fB0 = fB1, bitB0 = bitB1) {\n lsB.pointAt(ib, pointB1);\n bitB1 = this.classifyBitsPointRangeXY(pointB1.x, pointB1.y, rangeA1);\n fB1 = ib * dfB;\n // DO NOT study the segment in detail if both bitB bits are on for any of the 4 planes\n // (i.e., no intersection between rangeA1 and the range around line segment [B0,B1])\n if ((bitB0 & bitB1) === 0)\n this.computeSegmentSegment(lsA, pointA0, fA0, pointA1, fA1, lsB, pointB0, fB0, pointB1, fB1, reversed);\n }\n }\n }\n }\n }\n /** Low level dispatch of curve collection. */\n private dispatchCurveCollection(geomA: AnyCurve, geomAHandler: (geomA: any) => any): void {\n const geomB = this._geometryB; // save\n if (!geomB || !geomB.children || !(geomB instanceof CurveCollection))\n return;\n for (const child of geomB.children) {\n this.resetGeometry(child);\n geomAHandler(geomA);\n }\n this._geometryB = geomB; // restore\n }\n /** Low level dispatch to geomA given a CurveChainWithDistanceIndex in geometryB. */\n private dispatchCurveChainWithDistanceIndex(geomA: AnyCurve, geomAHandler: (geomA: any) => any): void {\n if (!this._geometryB || !(this._geometryB instanceof CurveChainWithDistanceIndex))\n return;\n if (geomA instanceof CurveChainWithDistanceIndex)\n assert(false, \"call handleCurveChainWithDistanceIndex(geomA) instead\");\n const saveResults = this.grabPairedResults();\n const geomB = this._geometryB;\n for (const child of geomB.path.children) {\n this.resetGeometry(child);\n geomAHandler(geomA);\n }\n this.resetGeometry(geomB);\n const childResults = this._results.extractArray();\n childResults.forEach((pair: CurveLocationDetailPair) => {\n CurveChainWithDistanceIndex.convertChildDetailToChainDetailSingle(pair, undefined, geomB);\n this._results.insert(pair);\n });\n saveResults.forEach((pair: CurveLocationDetailPair) => this._results.insert(pair));\n }\n /** Specifies whether the curve needs to be stroked for close approach computation. */\n private needsStroking(curve?: AnyCurve): curve is BSplineCurve3dBase | TransitionSpiral3d {\n return curve instanceof BSplineCurve3dBase || curve instanceof TransitionSpiral3d;\n }\n /**\n * Process seeds for xy close approach between one curve and another curve to be stroked.\n * * Refine each result via Newton iteration. If it doesn't converge, remove it.\n * @param seeds the initial seed results to refine.\n * @param curveA curve to find its XY close approach with curveB.\n * @param curveB the other curve to be stroked.\n * @param reversed whether `curveB` data is in `detailA` of each recorded pair, and `curveA` data in `detailB`.\n */\n private refineStrokedResultsByNewton(\n seeds: CurveLocationDetailPair[], curveA: CurvePrimitive, curveB: CurvePrimitive, reversed = false\n ): void {\n const xyMatchingFunction = new CurveCurveCloseApproachXYRRtoRRD(curveA, curveB);\n const newtonSearcher = new Newton2dUnboundedWithDerivative(xyMatchingFunction, 50, this._newtonTolerance); // seen: 47\n for (const seed of seeds) {\n const detailA = reversed ? seed.detailB : seed.detailA;\n const detailB = reversed ? seed.detailA : seed.detailB;\n assert(detailB.curve instanceof LineString3d, \"Caller has discretized the curve\");\n newtonSearcher.setUV(detailA.fraction, detailB.fraction); // use the linestring fraction as initial curveB fraction (ASSUME it's close enough)\n if (newtonSearcher.runIterations()) {\n const fractionA = newtonSearcher.getU();\n const fractionB = newtonSearcher.getV();\n if (this.acceptFraction(fractionA) && this.acceptFraction(fractionB))\n this.testAndRecordPointPair(curveA, fractionA, undefined, curveB, fractionB, undefined, reversed);\n } // ignore failure to converge\n }\n }\n /**\n * Append stroke points and return the line string.\n * * This is a convenient wrapper for [[CurvePrimitive.emitStrokes]] but the analogous instance method cannot be added\n * to that class due to the ensuing recursion with subclass [[LineString3d]].\n * @param options options for stroking the instance curve.\n * @param result object to receive appended stroke points; if omitted, a new object is created, populated, and returned.\n */\n private strokeCurve(curve: CurvePrimitive, options?: StrokeOptions, result?: LineString3d): LineString3d {\n const ls = result ? result : LineString3d.create();\n curve.emitStrokes(ls, options);\n return ls;\n }\n /** Find and return the close approaches between curveA and the discretization of curveB. */\n private computeDiscreteCloseApproachResults(curveA: CurvePrimitive, lsB: LineString3d, reversed: boolean): CurveLocationDetailPair[] {\n const maxDist = this.maxDistanceToAccept;\n const saveResults = this.grabPairedResults(); // save current results\n const geomB = this._geometryB;\n this.maxDistanceToAccept = maxDist ? maxDist * 1.2 : undefined; // HEURISTIC: allow slack for Newton seeds\n this.resetGeometry(curveA);\n this.handleLineString3d(lsB); // populate empty results with discrete solutions\n if (!reversed) {\n // handleLineString3d put lsB data into detailA, so if we aren't reversing, we need to swap\n for (const result of this._results)\n result.swapDetails();\n }\n this.resetGeometry(geomB);\n this.maxDistanceToAccept = maxDist;\n const discreteResults = this._results.extractArray();\n saveResults.forEach((pair: CurveLocationDetailPair) => this._results.insert(pair)); // restore current results\n return discreteResults;\n }\n /**\n * Compute the XY close approach of a curve and another curve to be stroked.\n * @param curveA curve to find its XY close approach with curveB.\n * @param curveB the other curve to be stroked.\n * @param reversed whether `curveB` data will be recorded in `detailA` of each result, and `curveA` data in `detailB`.\n */\n private dispatchCurveStrokedCurve(curveA: CurvePrimitive, curveB: CurvePrimitive, reversed: boolean): void {\n // explicit search for intersections (Newton converges too slowly on DirectSpiral3d tangent intersections)\n const intersections = CurveCurve.intersectionXYPairs(curveA, false, curveB, false, this._xyTolerance);\n for (const intersection of intersections)\n this.testAndRecordPair(intersection, reversed);\n // append seeds computed by solving the discretized spiral close approach problem, then refine the seeds via Newton\n let cpA = curveA;\n if (this.needsStroking(curveA))\n cpA = this.strokeCurve(curveA);\n const cpB = this.strokeCurve(curveB);\n const seeds = this.computeDiscreteCloseApproachResults(cpA, cpB, reversed);\n this.refineStrokedResultsByNewton(seeds, curveA, curveB, reversed);\n if (curveA instanceof LineString3d) { // explicitly test corners (where Newton converges too slowly)\n const fStep = Geometry.safeDivideFraction(1.0, curveA.numEdges(), 0);\n const v0 = CurveCurveCloseApproachXY._workPointBB0;\n for (let i = 1; i < curveA.numEdges(); ++i)\n this.testAndRecordProjection(curveA, i * fStep, curveA.pointAtUnchecked(i, v0), curveB, reversed);\n }\n this.testAndRecordEndPointApproaches(curveA, curveB, reversed);\n }\n /** Double dispatch handler for strongly typed segment. */\n public override handleLineSegment3d(segmentA: LineSegment3d): any {\n if (this._geometryB instanceof LineSegment3d) {\n const segmentB = this._geometryB;\n this.computeSegmentSegment(\n segmentA, segmentA.point0Ref, 0.0, segmentA.point1Ref, 1.0,\n segmentB, segmentB.point0Ref, 0.0, segmentB.point1Ref, 1.0,\n false,\n );\n } else if (this._geometryB instanceof LineString3d) {\n this.computeSegmentLineString(segmentA, this._geometryB, false);\n } else if (this._geometryB instanceof Arc3d) {\n this.computeSegmentArc(segmentA, this._geometryB, false);\n } else if (this.needsStroking(this._geometryB)) {\n this.dispatchCurveStrokedCurve(segmentA, this._geometryB, false);\n } else if (this._geometryB instanceof CurveCollection) {\n this.dispatchCurveCollection(segmentA, this.handleLineSegment3d.bind(this));\n } else if (this._geometryB instanceof CurveChainWithDistanceIndex) {\n this.dispatchCurveChainWithDistanceIndex(segmentA, this.handleLineSegment3d.bind(this));\n }\n return undefined;\n }\n /** Double dispatch handler for strongly typed linestring. */\n public override handleLineString3d(lsA: LineString3d): any {\n if (this._geometryB instanceof LineSegment3d) {\n this.computeSegmentLineString(this._geometryB, lsA, true);\n } else if (this._geometryB instanceof LineString3d) {\n this.computeLineStringLineString(lsA, this._geometryB, false);\n } else if (this._geometryB instanceof Arc3d) {\n this.computeArcLineString(this._geometryB, lsA, true);\n } else if (this.needsStroking(this._geometryB)) {\n this.dispatchCurveStrokedCurve(lsA, this._geometryB, false);\n } else if (this._geometryB instanceof CurveCollection) {\n this.dispatchCurveCollection(lsA, this.handleLineString3d.bind(this));\n } else if (this._geometryB instanceof CurveChainWithDistanceIndex) {\n this.dispatchCurveChainWithDistanceIndex(lsA, this.handleLineString3d.bind(this));\n }\n return undefined;\n }\n /** Double dispatch handler for strongly typed arc. */\n public override handleArc3d(arcA: Arc3d): any {\n if (this._geometryB instanceof LineSegment3d) {\n this.computeSegmentArc(this._geometryB, arcA, true);\n } else if (this._geometryB instanceof LineString3d) {\n this.computeArcLineString(arcA, this._geometryB, false);\n } else if (this._geometryB instanceof Arc3d) {\n this.dispatchArcArc(arcA, this._geometryB, false);\n } else if (this.needsStroking(this._geometryB)) {\n this.dispatchCurveStrokedCurve(arcA, this._geometryB, false);\n } else if (this._geometryB instanceof CurveCollection) {\n this.dispatchCurveCollection(arcA, this.handleArc3d.bind(this));\n } else if (this._geometryB instanceof CurveChainWithDistanceIndex) {\n this.dispatchCurveChainWithDistanceIndex(arcA, this.handleArc3d.bind(this));\n }\n return undefined;\n }\n /** Double dispatch handler for strongly typed bspline curve. */\n public override handleBSplineCurve3d(curveA: BSplineCurve3d): any {\n if (this._geometryB instanceof CurveChainWithDistanceIndex) {\n this.dispatchCurveChainWithDistanceIndex(curveA, this.handleBSplineCurve3d.bind(this));\n } else if (this._geometryB instanceof CurvePrimitive) {\n this.dispatchCurveStrokedCurve(this._geometryB, curveA, true);\n } else if (this._geometryB instanceof CurveCollection) {\n this.dispatchCurveCollection(curveA, this.handleBSplineCurve3d.bind(this));\n }\n return undefined;\n }\n /** Double dispatch handler for strongly typed spiral curve. */\n public override handleTransitionSpiral(spiral: TransitionSpiral3d): any {\n if (this._geometryB instanceof CurveChainWithDistanceIndex) {\n this.dispatchCurveChainWithDistanceIndex(spiral, this.handleTransitionSpiral.bind(this));\n } else if (this._geometryB instanceof CurvePrimitive) {\n this.dispatchCurveStrokedCurve(this._geometryB, spiral, true);\n } else if (this._geometryB instanceof CurveCollection) {\n this.dispatchCurveCollection(spiral, this.handleTransitionSpiral.bind(this));\n }\n return undefined;\n }\n /** Double dispatch handler for strongly typed CurveChainWithDistanceIndex. */\n public override handleCurveChainWithDistanceIndex(chain: CurveChainWithDistanceIndex): any {\n super.handleCurveChainWithDistanceIndex(chain);\n // if _geometryB is also a CurveChainWithDistanceIndex, it will already have been converted by dispatchCurveChainWithDistanceIndex\n const childResults = this._results.extractArray();\n childResults.forEach((pair: CurveLocationDetailPair) => {\n CurveChainWithDistanceIndex.convertChildDetailToChainDetailSingle(pair, chain, undefined);\n this._results.insert(pair);\n });\n }\n /** Double dispatch handler for strongly typed homogeneous bspline curve .. */\n public override handleBSplineCurve3dH(_curve: BSplineCurve3dH): any {\n // NEEDS WORK -- make \"dispatch\" methods tolerant of both 3d and 3dH\n return undefined;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CurveCurveCloseApproachXY.js","sourceRoot":"","sources":["../../../../src/curve/internalContexts/CurveCurveCloseApproachXY.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,sDAA2E;AAC3E,6DAAgF;AAEhF,6CAA0C;AAC1C,sEAAkF;AAClF,g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,IAAI,CAAC,UAAU,YAAY,+BAAc,EAAE,CAAC;YACrD,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAChE,CAAC;aAAM,IAAI,IAAI,CAAC,UAAU,YAAY,iCAAe,EAAE,CAAC;YACtD,IAAI,CAAC,uBAAuB,CAAC,MAAM,EAAE,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/E,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,8EAA8E;IAC9D,iCAAiC,CAAC,KAAkC;QAClF,KAAK,CAAC,iCAAiC,CAAC,KAAK,CAAC,CAAC;QAC/C,kIAAkI;QAClI,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;QAClD,YAAY,CAAC,OAAO,CAAC,CAAC,IAA6B,EAAE,EAAE;YACrD,yDAA2B,CAAC,qCAAqC,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;YAC1F,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;IACD,8EAA8E;IAC9D,qBAAqB,CAAC,MAAuB;QAC3D,oEAAoE;QACpE,OAAO,SAAS,CAAC;IACnB,CAAC;;AA3wBH,8DA4wBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { assert, DuplicatePolicy, SortedArray } from \"@itwin/core-bentley\";\nimport { BSplineCurve3d, BSplineCurve3dBase } from \"../../bspline/BSplineCurve\";\nimport { BSplineCurve3dH } from \"../../bspline/BSplineCurve3dH\";\nimport { Geometry } from \"../../Geometry\";\nimport { RecurseToCurvesGeometryHandler } from \"../../geometry3d/GeometryHandler\";\nimport { GrowableFloat64Array } from \"../../geometry3d/GrowableFloat64Array\";\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\nimport { Range3d } from \"../../geometry3d/Range\";\nimport { CurveCurveCloseApproachXYRRtoRRD, Newton2dUnboundedWithDerivative } from \"../../numerics/Newton\";\nimport { AnalyticRoots } from \"../../numerics/Polynomials\";\nimport { SmallSystem } from \"../../numerics/SmallSystem\";\nimport { Arc3d } from \"../Arc3d\";\nimport { CurveChainWithDistanceIndex } from \"../CurveChainWithDistanceIndex\";\nimport { CurveCollection } from \"../CurveCollection\";\nimport { CurveCurve } from \"../CurveCurve\";\nimport { CurveIntervalRole, CurveLocationDetail, CurveLocationDetailPair } from \"../CurveLocationDetail\";\nimport { CurvePrimitive } from \"../CurvePrimitive\";\nimport { AnyCurve } from \"../CurveTypes\";\nimport { LineSegment3d } from \"../LineSegment3d\";\nimport { LineString3d } from \"../LineString3d\";\nimport { ProxyCurve } from \"../ProxyCurve\";\nimport { TransitionSpiral3d } from \"../spiral/TransitionSpiral3d\";\nimport { StrokeOptions } from \"../StrokeOptions\";\n\n// cspell:word XYRR currentdFdX\n\n/**\n * Handler class for XY close approach between _geometryB and another geometry.\n * * Approach means the XY distance (z is ignored) between _geometryB and another geometry.\n * * Closest approach is a measure of the proximity of one curve to another. It's the length of the shortest line\n * segment perpendicular to both curves; if the curves intersect, the closest approach is zero. In the context of\n * this class, z-coordinates are ignored, so the closest approach is as seen in the top view. If you have coplanar\n * input curves and want to find closest approach in their plane, rotate them first into a plane parallel to the\n * xy-plane, then afterward, rotate the results back as required.\n * * Close approach can also be from a curve endpoint perpendicular to another curve or from a curve endpoint to\n * another curve endpoint.\n * * Instances are initialized and called from CurveCurve.\n * * geometryB is saved for later reference.\n * @internal\n */\nexport class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {\n private _geometryB: AnyCurve | undefined;\n /**\n * Maximum XY distance (z is ignored). Approach larger than this is not interesting.\n * This is caller defined and can be undefined.\n */\n private _maxDistanceToAccept: number | undefined;\n /** Squared max distance. Default is [[Geometry.smallMetricDistanceSquared]]. */\n private _maxDistanceSquared: number;\n private _xyTolerance: number;\n private _newtonTolerance: number;\n private _maxIterations: number;\n /**\n * Start and end points of line segments that meet closest approach criteria, i.e., they are perpendicular to\n * both curves and their length is smaller than _maxDistanceToAccept.\n */\n private _results: SortedArray<CurveLocationDetailPair>;\n\n private static _workPointAA0 = Point3d.create();\n private static _workPointAA1 = Point3d.create();\n private static _workPointBB0 = Point3d.create();\n private static _workPointBB1 = Point3d.create();\n private static _workPointB = Point3d.create();\n\n /**\n * Constructor.\n * @param geometryB second curve for intersection. Saved for reference by specific handler methods.\n * @param xyTolerance optional tolerance for comparing xy points (default [[Geometry.smallMetricDistance]]).\n * @param newtonTolerance optional relative fraction tolerance for Newton iteration (default [[Geometry.smallNewtonStep]]).\n * @param maxIterations optional max iterations for Newton iteration (default 50).\n */\n public constructor(\n geometryB?: AnyCurve,\n xyTolerance: number = Geometry.smallMetricDistance,\n newtonTolerance: number = Geometry.smallNewtonStep,\n maxIterations: number = 50 // seen: 47\n ) {\n super();\n this._geometryB = geometryB instanceof ProxyCurve ? geometryB.proxyCurve : geometryB;\n this._maxDistanceSquared = Geometry.smallMetricDistanceSquared;\n this._xyTolerance = xyTolerance;\n this._newtonTolerance = newtonTolerance;\n this._maxIterations = maxIterations;\n const compare = CurveLocationDetailPair.comparePairsByPoints(xyTolerance, true);\n this._results = new SortedArray<CurveLocationDetailPair>(compare, DuplicatePolicy.Retain);\n }\n /** Set the (possibly undefined) max XY distance (z is ignored) to accept. */\n public set maxDistanceToAccept(value: number | undefined) {\n if (value === undefined) {\n this._maxDistanceToAccept = undefined;\n this._maxDistanceSquared = Geometry.smallMetricDistanceSquared;\n } else {\n this._maxDistanceToAccept = Math.abs(value);\n this._maxDistanceSquared = value * value;\n }\n }\n /** Access the (possibly undefined) max XY distance (z is ignored) to accept. */\n public get maxDistanceToAccept(): number | undefined {\n return this._maxDistanceToAccept;\n }\n /** Ask if the maxDistanceToAccept value is defined and positive */\n public get isMaxDistanceSet(): boolean {\n return this._maxDistanceToAccept !== undefined && this._maxDistanceToAccept > 0;\n }\n /**\n * Reset the geometry.\n * * Undefined inputs are ignored.\n * * All other instance data is unchanged, including accumulated intersections.\n */\n public resetGeometry(geometryB?: AnyCurve) {\n if (geometryB)\n this._geometryB = geometryB;\n }\n /** returns true if `fraction` is in [0,1] within tolerance */\n private acceptFraction(fraction: number, fractionTol: number = 1.0e-12) {\n if (fraction < -fractionTol)\n return false;\n if (fraction > 1.0 + fractionTol)\n return false;\n return true;\n }\n /** Extract (and clear) the results, structured as an array of CurveLocationDetailPair. */\n public grabPairedResults(): CurveLocationDetailPair[] {\n return this._results.extractArray();\n }\n /**\n * Create and record a close-approach pair from raw curve/fraction/point data.\n * * If points are undefined, they are computed from the fractions via `fractionToPoint`.\n * * Fractions are global (i.e., relative to the full curve, not a sub-segment).\n * * The pair is recorded only if the XY distance is within `_maxDistanceSquared`.\n * @param cpA first curve\n * @param fA global fraction on cpA\n * @param pointA point on cpA at fA, or undefined to compute from fA\n * @param cpB second curve\n * @param fB global fraction on cpB\n * @param pointB point on cpB at fB, or undefined to compute from fB\n * @param reversed if true, swap detailA and detailB before recording\n */\n private testAndRecordPointPair(\n cpA: CurvePrimitive, fA: number, pointA: Point3d | undefined,\n cpB: CurvePrimitive, fB: number, pointB: Point3d | undefined,\n reversed: boolean\n ): void {\n if (!pointA)\n pointA = cpA.fractionToPoint(fA);\n if (!pointB)\n pointB = cpB.fractionToPoint(fB);\n const d2 = pointA.distanceSquaredXY(pointB);\n if (d2 <= this._maxDistanceSquared) {\n const d = Math.sqrt(d2);\n const detailA = CurveLocationDetail.createCurveFractionPointDistance(cpA, fA, pointA, d);\n const detailB = CurveLocationDetail.createCurveFractionPointDistance(cpB, fB, pointB, d);\n detailA.setIntervalRole(CurveIntervalRole.isolated);\n detailB.setIntervalRole(CurveIntervalRole.isolated);\n const pair = CurveLocationDetailPair.createCapture(detailA, detailB);\n if (reversed)\n pair.swapDetails();\n this._results.insert(pair);\n }\n }\n /**\n * Record a pre-built close-approach pair with global fractions already set.\n * * Computes and stores the XY distance on both details.\n * * The pair is recorded only if the XY distance is within `_maxDistanceSquared`.\n * @param pair details with global fractions and points already set; modified in place\n * @param reversed if true, swap detailA and detailB before recording\n */\n private testAndRecordPair(pair: CurveLocationDetailPair, reversed: boolean) {\n const d2 = pair.detailA.point.distanceSquaredXY(pair.detailB.point);\n if (d2 > this._maxDistanceSquared)\n return;\n const d = Math.sqrt(d2);\n pair.detailA.a = pair.detailB.a = d;\n pair.detailA.setIntervalRole(CurveIntervalRole.isolated);\n pair.detailB.setIntervalRole(CurveIntervalRole.isolated);\n if (reversed)\n pair.swapDetails();\n this._results.insert(pair);\n }\n /**\n * Convert a close-approach pair from local (sub-segment) fractions to global fractions, then record it.\n * * Local fractions in the pair are interpolated into the global fraction ranges.\n * * Points are recomputed from the parent curves at the global fractions.\n * * The pair is recorded only if the XY distance is within `_maxDistanceSquared`.\n * @param pair local details (curve unspecified); modified in place with global fractions, curves, and points\n * @param cpA parent curve A\n * @param fractionA0 global fraction corresponding to local fraction 0 on curve A\n * @param fractionA1 global fraction corresponding to local fraction 1 on curve A\n * @param cpB parent curve B\n * @param fractionB0 global fraction corresponding to local fraction 0 on curve B\n * @param fractionB1 global fraction corresponding to local fraction 1 on curve B\n * @param reversed if true, swap detailA and detailB before recording\n */\n private testAndRecordLocalPair(\n pair: CurveLocationDetailPair,\n cpA: CurvePrimitive, fractionA0: number, fractionA1: number,\n cpB: CurvePrimitive, fractionB0: number, fractionB1: number,\n reversed: boolean,\n ) {\n const globalFractionA = Geometry.interpolate(fractionA0, pair.detailA.fraction, fractionA1);\n const globalFractionB = Geometry.interpolate(fractionB0, pair.detailB.fraction, fractionB1);\n const pointA = cpA.fractionToPoint(globalFractionA);\n const pointB = cpB.fractionToPoint(globalFractionB);\n const d2 = pointA.distanceSquaredXY(pointB);\n if (d2 > this._maxDistanceSquared)\n return;\n const d = Math.sqrt(d2);\n CurveLocationDetail.createCurveFractionPointDistance(cpA, globalFractionA, pointA, d, pair.detailA);\n CurveLocationDetail.createCurveFractionPointDistance(cpB, globalFractionB, pointB, d, pair.detailB);\n pair.detailA.setIntervalRole(CurveIntervalRole.isolated);\n pair.detailB.setIntervalRole(CurveIntervalRole.isolated);\n if (reversed)\n pair.swapDetails();\n this._results.insert(pair);\n }\n /** Modify the current closest approach if the inputs are closer. */\n private static updatePointToSegmentDistance(\n closestApproach: CurveLocationDetailPair,\n fractionA: number, pointA: Point3d,\n fractionB: number, pointB0: Point3d, pointB1: Point3d,\n maxDistanceSquared: number,\n ): boolean {\n let updated = false;\n if (fractionB < 0)\n fractionB = 0;\n else if (fractionB > 1)\n fractionB = 1;\n const pointB = pointB0.interpolate(fractionB, pointB1, this._workPointB);\n const distanceSquared = pointB.distanceSquaredXY(pointA);\n if (distanceSquared <= Math.min(maxDistanceSquared, closestApproach.detailA.a)) {\n closestApproach.detailA.setFP(fractionA, pointA, undefined, distanceSquared);\n closestApproach.detailB.setFP(fractionB, pointB, undefined, distanceSquared);\n updated = true;\n }\n return updated;\n }\n /**\n * Return fractions of close approach within maxDistance between two line segments (a0,a1) and (b0,b1).\n * * Math details can be found at core/geometry/internaldocs/Curve.md\n * @param a0 start point of line a\n * @param a1 end point of line a\n * @param b0 start point of line b\n * @param b1 end point of line b\n * @param maxDistanceSquared maximum distance squared (assumed to be positive)\n * @returns a pair of details for the closest approach, or `undefined` if no approach is within `maxDistanceSquared`.\n * `detailA.fraction` is the fraction on segment a; `detailB.fraction` is the fraction on segment b. Returned\n * details store the *squared* distance in the `a` property.\n */\n private static segmentSegmentBoundedApproach(\n a0: Point3d, a1: Point3d,\n b0: Point3d, b1: Point3d,\n maxDistanceSquared: number,\n ): CurveLocationDetailPair | undefined {\n const ux = a1.x - a0.x;\n const uy = a1.y - a0.y;\n const vx = b1.x - b0.x;\n const vy = b1.y - b0.y;\n const e00x = b0.x - a0.x;\n const e00y = b0.y - a0.y;\n const e01x = b1.x - a0.x;\n const e01y = b1.y - a0.y;\n const e10x = b0.x - a1.x;\n const e10y = b0.y - a1.y;\n const hab0 = Geometry.crossProductXYXY(ux, uy, e00x, e00y);\n const hab1 = Geometry.crossProductXYXY(ux, uy, e01x, e01y);\n const hba0 = -Geometry.crossProductXYXY(vx, vy, e00x, e00y);\n const hba1 = -Geometry.crossProductXYXY(vx, vy, e10x, e10y);\n if (hab0 * hab1 < 0.0 && hba0 * hba1 < 0.0) { // true intersection, strictly within both segments\n const fractionA = -hba0 / (hba1 - hba0);\n const fractionB = -hab0 / (hab1 - hab0);\n return CurveLocationDetailPair.createCapture(\n CurveLocationDetail.createCurveFractionPoint(undefined, fractionA, a0.interpolate(fractionA, a1)),\n CurveLocationDetail.createCurveFractionPoint(undefined, fractionB, b0.interpolate(fractionB, b1)),\n );\n }\n // there's no intersection, so find the closest approach within maxDistance from an endpoint\n const closestApproach = new CurveLocationDetailPair();\n closestApproach.detailA.a = 2 * maxDistanceSquared; // init to an approach that's too far away\n let reversed = false;\n const uu = Geometry.hypotenuseSquaredXY(ux, uy);\n if (hab0 * hab0 <= maxDistanceSquared * uu) { // test distance of b0 to u\n const fractionA = Geometry.safeDivideFraction(Geometry.dotProductXYXY(ux, uy, e00x, e00y), uu, 0.0);\n if (this.updatePointToSegmentDistance(closestApproach, 0, b0, fractionA, a0, a1, maxDistanceSquared))\n reversed = true;\n }\n if (hab1 * hab1 <= maxDistanceSquared * uu) { // test distance of b1 to u\n const fractionA = Geometry.safeDivideFraction(Geometry.dotProductXYXY(ux, uy, e01x, e01y), uu, 0.0);\n if (this.updatePointToSegmentDistance(closestApproach, 1, b1, fractionA, a0, a1, maxDistanceSquared))\n reversed = true;\n }\n const vv = Geometry.hypotenuseSquaredXY(vx, vy);\n if (hba0 * hba0 <= maxDistanceSquared * vv) { // test distance of a0 to v\n const fractionB = Geometry.safeDivideFraction(-Geometry.dotProductXYXY(vx, vy, e00x, e00y), vv, 0.0);\n if (this.updatePointToSegmentDistance(closestApproach, 0, a0, fractionB, b0, b1, maxDistanceSquared))\n reversed = false;\n }\n if (hba1 * hba1 <= maxDistanceSquared * vv) { // test distance of a1 to v\n const fractionB = Geometry.safeDivideFraction(-Geometry.dotProductXYXY(vx, vy, e10x, e10y), vv, 0.0);\n if (this.updatePointToSegmentDistance(closestApproach, 1, a1, fractionB, b0, b1, maxDistanceSquared))\n reversed = false;\n }\n if (closestApproach.detailA.a > maxDistanceSquared)\n return undefined;\n if (reversed)\n closestApproach.swapDetails();\n return closestApproach;\n }\n /**\n * Compute closest approaches from the endpoints of each curve (if open) to the other curve.\n * Record a [[CurveLocationDetailPair]] if such a distance is less than [[maxDistance]].\n * @param cpA curveA\n * @param cpB curveB\n * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to curveA).\n */\n private testAndRecordEndPointApproaches(cpA: CurvePrimitive, cpB: CurvePrimitive, reversed: boolean): void {\n const pt = CurveCurveCloseApproachXY._workPointB;\n // in closest approach context, endpoints of full sweep arcs are artificial locations, and thus ignored\n const isClosedArc = (curve: CurvePrimitive) => curve instanceof Arc3d && curve.sweep.isFullCircle;\n if (!isClosedArc(cpA)) {\n this.testAndRecordProjection(cpA, 0, cpA.startPoint(pt), cpB, reversed);\n this.testAndRecordProjection(cpA, 1, cpA.endPoint(pt), cpB, reversed);\n }\n if (!isClosedArc(cpB)) {\n this.testAndRecordProjection(cpB, 0, cpB.startPoint(pt), cpA, !reversed);\n this.testAndRecordProjection(cpB, 1, cpB.endPoint(pt), cpA, !reversed);\n }\n }\n /** Find the closest xy approach between `pointA` and `cpB`. */\n private testAndRecordProjection(cpA: CurvePrimitive, fA: number, pointA: Point3d, cpB: CurvePrimitive, reversed: boolean): void {\n const detail = cpB.closestPointXY(pointA);\n if (detail)\n this.testAndRecordPointPair(cpA, fA, pointA, cpB, detail.fraction, detail.point, reversed);\n }\n /**\n * Compute closest xy approach of two line segments.\n * Filter by extension rules.\n * Record with fraction mapping.\n * * The fraction mappings allow portions of a linestring to be passed here.\n */\n private computeSegmentSegment(\n cpA: CurvePrimitive, pointA0: Point3d, fractionA0: number, pointA1: Point3d, fractionA1: number,\n cpB: CurvePrimitive, pointB0: Point3d, fractionB0: number, pointB1: Point3d, fractionB1: number,\n reversed: boolean,\n ): void {\n // compute a pair with fractions local to segments\n const approach = CurveCurveCloseApproachXY.segmentSegmentBoundedApproach(\n pointA0, pointA1, pointB0, pointB1, this._maxDistanceSquared,\n );\n // adjust the pair to refer to input curves and global fractions, then record it if new\n if (approach) {\n approach.detailA.setCurve(cpA);\n approach.detailB.setCurve(cpB);\n this.testAndRecordLocalPair(approach, cpA, fractionA0, fractionA1, cpB, fractionB0, fractionB1, reversed);\n }\n }\n /**\n * Compute the perpendiculars between a line segment and an arc, without extending either curve.\n * * One or two perpendiculars will be found.\n * * Each perpendicular segment starts or ends on the arc where the arc tangent is parallel to the line tangent.\n * @param startA line segment start point\n * @param endA line segment end point\n * @param arcB the arc\n * @param announce callback to receive line and arc fractions and optional points of each perpendicular segment computed.\n */\n private announceAllPerpendicularsSegmentArcBounded(\n startA: Point3d, endA: Point3d, arcB: Arc3d,\n announce: (lineFraction: number, linePoint: Point3d | undefined, arcFraction: number, arcPoint: Point3d | undefined) => void,\n ): void {\n const dotUT = arcB.vector0.crossProductStartEndXY(startA, endA);\n const dotVT = arcB.vector90.crossProductStartEndXY(startA, endA);\n const parallelRadians = Math.atan2(dotVT, dotUT);\n for (const radians1 of [parallelRadians, parallelRadians + Math.PI]) {\n const arcPoint = arcB.radiansToPoint(radians1);\n const arcFraction = arcB.sweep.radiansToSignedPeriodicFraction(radians1);\n if (this.acceptFraction(arcFraction)) { // reject solution outside arc sweep\n const lineFraction = SmallSystem.lineSegment3dXYClosestPointUnbounded(startA, endA, arcPoint);\n if (lineFraction !== undefined && this.acceptFraction(lineFraction))\n announce(lineFraction, undefined, arcFraction, arcPoint);\n }\n }\n }\n /**\n * Find close approaches within maxDistance between a line segment and an arc.\n * To consider:\n * 1) intersection between arc and segment.\n * 2) endpoints to endpoints, or endpoints projection to the other curve.\n * 3) arc tangent parallel to line segment\n * @param lineA the line segment\n * @param arcB the arc\n * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to arcA).\n */\n private computeSegmentArc(lineA: LineSegment3d, arcB: Arc3d, reversed: boolean): void {\n // 1) intersection between arc and line segment (or string).\n // Suppose:\n // Arc: X = C + cU + sV where c = cos(theta) and s = sin(theta)\n // Line: contains points A0 and A1\n // The arc intersects the line at point X if det(A0, A1, X) = 0 with homogeneous xyw points and vectors.\n // With equational X: det(A0, A1, C) + c*det(A0, A1, U) + s*det(A0, A1, V) = 0.\n // solve for theta.\n // evaluate points.\n // project back to line.\n let intersectionFound = false;\n const data = arcB.toTransformedVectors();\n const alpha = Geometry.tripleProductXYW(lineA.point0Ref, 1, lineA.point1Ref, 1, data.center, 1); // det(A0, A1, C)\n const beta = Geometry.tripleProductXYW(lineA.point0Ref, 1, lineA.point1Ref, 1, data.vector0, 0); // det(A0, A1, U)\n const gamma = Geometry.tripleProductXYW(lineA.point0Ref, 1, lineA.point1Ref, 1, data.vector90, 0); // det(A0, A1, V)\n const cosines = new GrowableFloat64Array(2);\n const sines = new GrowableFloat64Array(2);\n const radians = new GrowableFloat64Array(2);\n const numRoots = AnalyticRoots.appendImplicitLineUnitCircleIntersections(alpha, beta, gamma, cosines, sines, radians);\n for (let i = 0; i < numRoots; i++) {\n const arcPoint = data.center.plus2Scaled(data.vector0, cosines.atUncheckedIndex(i), data.vector90, sines.atUncheckedIndex(i));\n const arcFraction = data.sweep.radiansToSignedPeriodicFraction(radians.atUncheckedIndex(i));\n if (this.acceptFraction(arcFraction)) { // reject solution outside arc sweep\n const lineFraction = SmallSystem.lineSegment3dXYClosestPointUnbounded(lineA.point0Ref, lineA.point1Ref, arcPoint);\n if (lineFraction !== undefined && this.acceptFraction(lineFraction)) {\n this.testAndRecordPointPair(lineA, lineFraction, undefined, arcB, arcFraction, arcPoint, reversed);\n intersectionFound = true;\n }\n }\n }\n if (intersectionFound)\n return;\n // 2) endpoints to endpoints, or endpoints projection to the other curve.\n this.testAndRecordEndPointApproaches(lineA, arcB, reversed);\n // 3) arc tangent parallel to line segment.\n // If line does not intersect the arc, then the closest (and/or the furthest) point on arc to the line is a\n // point where the tangent line on arc at that point is parallel to the line.\n this.announceAllPerpendicularsSegmentArcBounded(lineA.point0Ref, lineA.point1Ref, arcB,\n (lineFraction: number, linePoint: Point3d | undefined, arcFraction: number, arcPoint: Point3d | undefined) =>\n this.testAndRecordPointPair(lineA, lineFraction, linePoint, arcB, arcFraction, arcPoint, reversed),\n );\n }\n /**\n * Compute segments perpendicular to two elliptical arcs, without extending either curve.\n * * Perpendiculars from an endpoint are not explicitly computed.\n * * Intersections are also found by this search: they are reported as zero-length segments.\n * @param arcA first arc\n * @param arcB second arc\n * @param reversed swap the details in the recorded pair (default: false)\n */\n public allPerpendicularsArcArcBounded(arcA: Arc3d, arcB: Arc3d, reversed: boolean = false): void {\n const newtonEvaluator = new CurveCurveCloseApproachXYRRtoRRD(arcA, arcB);\n // HEURISTIC: 2 ellipses have up to 8 perpendiculars\n const seedDelta = 1 / 10; // denominator 9 fails the unit test\n const seedStart = seedDelta / 2;\n const newtonSearcher = new Newton2dUnboundedWithDerivative(newtonEvaluator, 100); // observed convergence to 1.0e-11 in 49 iters\n for (let seedU = seedStart; seedU < 1; seedU += seedDelta) {\n for (let seedV = seedStart; seedV < 1; seedV += seedDelta) {\n newtonSearcher.setUV(seedU, seedV);\n if (newtonSearcher.runIterations()) {\n const fractionA = newtonSearcher.getU();\n const fractionB = newtonSearcher.getV();\n if (this.acceptFraction(fractionA) && this.acceptFraction(fractionB)) {\n this.testAndRecordPointPair(arcA, fractionA, undefined, arcB, fractionB, undefined, reversed);\n }\n }\n }\n }\n }\n /** Low level dispatch of arc with Arc3d. */\n private dispatchArcArc(cpA: Arc3d, cpB: Arc3d, reversed: boolean): void {\n const rangeA = cpA.range();\n const rangeB = cpB.range();\n if (this._maxDistanceToAccept)\n rangeA.expandInPlace(this._maxDistanceToAccept);\n if (!rangeB.intersectsRangeXY(rangeA))\n return;\n // 1) endpoints to endpoints or endpoints projection to the other curve\n this.testAndRecordEndPointApproaches(cpA, cpB, reversed);\n // 2) perpendicular line between 2 arcs (includes intersections)\n this.allPerpendicularsArcArcBounded(cpA, cpB, reversed);\n }\n /** Detail computation for segment approaching linestring. */\n private computeSegmentLineString(segA: LineSegment3d, lsB: LineString3d, reversed: boolean): void {\n const numB = lsB.numPoints();\n const deltaFracB = Geometry.safeDivideFraction(1, numB - 1, 0);\n const pointA0 = segA.point0Ref;\n const pointA1 = segA.point1Ref;\n const pointB0 = CurveCurveCloseApproachXY._workPointBB0;\n const pointB1 = CurveCurveCloseApproachXY._workPointBB1;\n for (let i = 0; i < numB - 1; ++i) {\n const fB0 = i * deltaFracB; // global linestring fractions\n const fB1 = (i + 1 === numB - 1) ? 1.0 : (i + 1) * deltaFracB; // make sure we nail the end fraction\n lsB.packedPoints.getPoint3dAtUncheckedPointIndex(i, pointB0);\n lsB.packedPoints.getPoint3dAtUncheckedPointIndex(i + 1, pointB1);\n this.computeSegmentSegment(segA, pointA0, 0.0, pointA1, 1.0, lsB, pointB0, fB0, pointB1, fB1, reversed);\n }\n }\n /** Detail computation for arc approaching linestring. */\n private computeArcLineString(arcA: Arc3d, lsB: LineString3d, reversed: boolean): void {\n const rangeA = arcA.range();\n const rangeB = lsB.range();\n if (this._maxDistanceToAccept)\n rangeA.expandInPlace(this._maxDistanceToAccept);\n if (!rangeB.intersectsRangeXY(rangeA))\n return;\n const v0 = CurveCurveCloseApproachXY._workPointBB0;\n const v1 = CurveCurveCloseApproachXY._workPointBB1;\n // 1. record intersections\n const intersections = CurveCurve.intersectionXYPairs(arcA, false, lsB, false, this._xyTolerance);\n for (const intersection of intersections)\n this.testAndRecordPair(intersection, reversed);\n // 2. record linestring interior vertex projections onto arc\n const fStep = Geometry.safeDivideFraction(1.0, lsB.numEdges(), 0);\n for (let i = 1; i < lsB.numEdges(); ++i)\n this.testAndRecordProjection(lsB, i * fStep, lsB.pointAtUnchecked(i, v0), arcA, !reversed);\n // 3. record arc/linestring endpoint projections onto linestring/arc\n this.testAndRecordEndPointApproaches(arcA, lsB, reversed);\n // 4. record perpendiculars from within a segment to the arc\n lsB.startPoint(v0);\n for (let iSeg = 0; iSeg < lsB.numEdges(); ++iSeg, v0.setFrom(v1)) {\n lsB.pointAtUnchecked(iSeg + 1, v1);\n this.announceAllPerpendicularsSegmentArcBounded(v0, v1, arcA,\n (lineFraction: number, linePoint: Point3d | undefined, arcFraction: number, arcPoint: Point3d | undefined) => {\n const fLineString = lsB.segmentIndexAndLocalFractionToGlobalFraction(iSeg, lineFraction);\n this.testAndRecordPointPair(arcA, arcFraction, arcPoint, lsB, fLineString, linePoint, reversed);\n },\n );\n }\n }\n /**\n * Set bits for comparison to range xy\n * * bit 0x01 => x smaller than range.low.x\n * * bit 0x02 => x larger than range.high.x\n * * bit 0x04 => y smaller than range.low.y\n * * bit 0x08 => y larger than range.high.y\n * * If we divide XY plane into 9 areas using the range, the function returns 0 for points\n * inside the range. Below is other binary numbers returned by the function for all 9 areas:\n * 1001 | 1000 | 1010\n * ------------------\n * 1 | 0 | 10\n * ------------------\n * 101 | 100 | 110\n * @param xy point to test\n * @param range range for comparison\n */\n private classifyBitsPointRangeXY(x: number, y: number, range: Range3d): number {\n let result = 0;\n if (x < range.low.x)\n result = 0x01;\n else if (x > range.high.x)\n result = 0x02;\n // note the OR operation\n if (y < range.low.y)\n result |= 0x04;\n else if (y > range.high.y)\n result |= 0x08;\n return result;\n }\n /** Low level dispatch of line string with line string. */\n private computeLineStringLineString(lsA: LineString3d, lsB: LineString3d, reversed: boolean): void {\n const rangeA = lsA.range();\n const rangeB = lsB.range();\n if (this._maxDistanceToAccept)\n rangeA.expandInPlace(this._maxDistanceToAccept);\n if (!rangeB.intersectsRangeXY(rangeA))\n return;\n let bitB0: number;\n let bitB1: number;\n const rangeA1 = Range3d.createNull();\n const pointA0 = CurveCurveCloseApproachXY._workPointAA0;\n const pointA1 = CurveCurveCloseApproachXY._workPointAA1;\n const pointB0 = CurveCurveCloseApproachXY._workPointBB0;\n const pointB1 = CurveCurveCloseApproachXY._workPointBB1;\n const numA = lsA.numPoints();\n const numB = lsB.numPoints();\n if (numA > 1 && numB > 1) {\n const dfA = 1.0 / (numA - 1);\n const dfB = 1.0 / (numB - 1);\n let fA0 = 0.0;\n let fA1, fB0, fB1;\n lsA.pointAt(0, pointA0);\n for (let ia = 1; ia < numA; ia++, pointA0.setFrom(pointA1), fA0 = fA1) {\n fA1 = ia * dfA;\n fB0 = 0.0;\n lsA.pointAt(ia, pointA1);\n // rangeA1 is around line segment [A0,A1] expanded by max distance\n rangeA1.setNull();\n rangeA1.extendPoint(pointA0);\n rangeA1.extendPoint(pointA1);\n if (this._maxDistanceToAccept)\n rangeA1.expandInPlace(this._maxDistanceToAccept);\n if (rangeA1.intersectsRangeXY(rangeB)) {\n lsB.pointAt(0, pointB0);\n bitB0 = this.classifyBitsPointRangeXY(pointB0.x, pointB0.y, rangeA1);\n for (let ib = 1; ib < numB; ib++, pointB0.setFrom(pointB1), fB0 = fB1, bitB0 = bitB1) {\n lsB.pointAt(ib, pointB1);\n bitB1 = this.classifyBitsPointRangeXY(pointB1.x, pointB1.y, rangeA1);\n fB1 = ib * dfB;\n // DO NOT study the segment in detail if both bitB bits are on for any of the 4 planes\n // (i.e., no intersection between rangeA1 and the range around line segment [B0,B1])\n if ((bitB0 & bitB1) === 0)\n this.computeSegmentSegment(lsA, pointA0, fA0, pointA1, fA1, lsB, pointB0, fB0, pointB1, fB1, reversed);\n }\n }\n }\n }\n }\n /** Low level dispatch of curve collection. */\n private dispatchCurveCollection(geomA: AnyCurve, geomAHandler: (geomA: any) => any): void {\n const geomB = this._geometryB; // save\n if (!geomB || !geomB.children || !(geomB instanceof CurveCollection))\n return;\n for (const child of geomB.children) {\n this.resetGeometry(child);\n geomAHandler(geomA);\n }\n this._geometryB = geomB; // restore\n }\n /** Low level dispatch to geomA given a CurveChainWithDistanceIndex in geometryB. */\n private dispatchCurveChainWithDistanceIndex(geomA: AnyCurve, geomAHandler: (geomA: any) => any): void {\n if (!this._geometryB || !(this._geometryB instanceof CurveChainWithDistanceIndex))\n return;\n if (geomA instanceof CurveChainWithDistanceIndex)\n assert(false, \"call handleCurveChainWithDistanceIndex(geomA) instead\");\n const saveResults = this.grabPairedResults();\n const geomB = this._geometryB;\n for (const child of geomB.path.children) {\n this.resetGeometry(child);\n geomAHandler(geomA);\n }\n this.resetGeometry(geomB);\n const childResults = this._results.extractArray();\n childResults.forEach((pair: CurveLocationDetailPair) => {\n CurveChainWithDistanceIndex.convertChildDetailToChainDetailSingle(pair, undefined, geomB);\n this._results.insert(pair);\n });\n saveResults.forEach((pair: CurveLocationDetailPair) => this._results.insert(pair));\n }\n /** Specifies whether the curve needs to be stroked for close approach computation. */\n private needsStroking(curve?: AnyCurve): curve is BSplineCurve3dBase | TransitionSpiral3d {\n return curve instanceof BSplineCurve3dBase || curve instanceof TransitionSpiral3d;\n }\n /**\n * Process seeds for xy close approach between one curve and another curve.\n * * Seeds typically result from solving a discrete close approach problem, where one or both curves have been stroked.\n * * Refine each result via Newton iteration. If it doesn't converge, remove it.\n * @param seeds the initial seed results to refine.\n * @param curveA curve to find its XY close approach with curveB.\n * @param curveAIsStroked whether `seeds` contains results from a linestring approximation to `curveA`\n * @param curveB the other curve.\n * @param curveBIsStroked whether `seeds` contains results from a linestring approximation to `curveB`\n * @param reversed whether `curveB` data is in `detailA` of each recorded pair, and `curveA` data in `detailB`.\n */\n private refineStrokedResultsByNewton(\n seeds: CurveLocationDetailPair[],\n curveA: CurvePrimitive, curveAIsStroked: boolean,\n curveB: CurvePrimitive, curveBIsStroked: boolean,\n reversed = false\n ): void {\n const xyMatchingFunction = new CurveCurveCloseApproachXYRRtoRRD(curveA, curveB);\n const newtonSearcher = new Newton2dUnboundedWithDerivative(\n xyMatchingFunction, this._maxIterations, this._newtonTolerance\n );\n for (const seed of seeds) {\n const detailA = reversed ? seed.detailB : seed.detailA;\n const detailB = reversed ? seed.detailA : seed.detailB;\n assert(detailB.curve instanceof LineString3d, \"Caller has discretized the curve\");\n // when the curve is stroked, project the discrete seed to compute a fraction in the original curve's parameter space\n const u = curveAIsStroked ? curveA.closestPointXY(detailA.point)?.fraction ?? detailA.fraction : detailA.fraction;\n const v = curveBIsStroked ? curveB.closestPointXY(detailB.point)?.fraction ?? detailB.fraction : detailB.fraction;\n newtonSearcher.setUV(u, v);\n if (newtonSearcher.runIterations()) {\n const fractionA = newtonSearcher.getU();\n const fractionB = newtonSearcher.getV();\n if (this.acceptFraction(fractionA) && this.acceptFraction(fractionB))\n this.testAndRecordPointPair(curveA, fractionA, undefined, curveB, fractionB, undefined, reversed);\n } // ignore failure to converge\n }\n }\n /**\n * Append stroke points and return the line string.\n * * This is a convenient wrapper for [[CurvePrimitive.emitStrokes]] but the analogous instance method cannot be added\n * to that class due to the ensuing recursion with subclass [[LineString3d]].\n * @param options options for stroking the instance curve.\n * @param result object to receive appended stroke points; if omitted, a new object is created, populated, and returned.\n */\n private strokeCurve(curve: CurvePrimitive, options?: StrokeOptions, result?: LineString3d): LineString3d {\n const ls = result ? result : LineString3d.create();\n curve.emitStrokes(ls, options);\n return ls;\n }\n /** Find and return the close approaches between curveA and the discretization of curveB. */\n private computeDiscreteCloseApproachResults(curveA: CurvePrimitive, lsB: LineString3d, reversed: boolean): CurveLocationDetailPair[] {\n const maxDist = this.maxDistanceToAccept;\n const saveResults = this.grabPairedResults(); // save current results\n const geomB = this._geometryB;\n this.maxDistanceToAccept = maxDist ? maxDist * 1.2 : undefined; // HEURISTIC: allow slack for Newton seeds\n this.resetGeometry(curveA);\n this.handleLineString3d(lsB); // populate empty results with discrete solutions\n if (!reversed) {\n // handleLineString3d put lsB data into detailA, so if we aren't reversing, we need to swap\n for (const result of this._results)\n result.swapDetails();\n }\n this.resetGeometry(geomB);\n this.maxDistanceToAccept = maxDist;\n const discreteResults = this._results.extractArray();\n saveResults.forEach((pair: CurveLocationDetailPair) => this._results.insert(pair)); // restore current results\n return discreteResults;\n }\n /**\n * Compute the XY close approach of a curve and another curve to be stroked.\n * @param curveA curve to find its XY close approach with curveB.\n * @param curveB the other curve, to be stroked.\n * @param reversed whether `curveB` data will be recorded in `detailA` of each result, and `curveA` data in `detailB`.\n */\n private dispatchCurveStrokedCurve(curveA: CurvePrimitive, curveB: CurvePrimitive, reversed: boolean): void {\n // explicit search for intersections (Newton converges too slowly on DirectSpiral3d tangent intersections)\n const intersections = CurveCurve.intersectionXYPairs(curveA, false, curveB, false, this._xyTolerance);\n for (const intersection of intersections)\n this.testAndRecordPair(intersection, reversed);\n // append seeds computed by solving the discretized spiral close approach problem, then refine the seeds via Newton\n const curveAIsStroked = this.needsStroking(curveA);\n const cpA = curveAIsStroked ? this.strokeCurve(curveA) : curveA;\n const cpB = this.strokeCurve(curveB);\n const seeds = this.computeDiscreteCloseApproachResults(cpA, cpB, reversed);\n this.refineStrokedResultsByNewton(seeds, curveA, curveAIsStroked, curveB, true, reversed);\n if (curveA instanceof LineString3d) { // explicitly test corners (where Newton converges too slowly)\n const fStep = Geometry.safeDivideFraction(1.0, curveA.numEdges(), 0);\n const v0 = CurveCurveCloseApproachXY._workPointBB0;\n for (let i = 1; i < curveA.numEdges(); ++i)\n this.testAndRecordProjection(curveA, i * fStep, curveA.pointAtUnchecked(i, v0), curveB, reversed);\n }\n this.testAndRecordEndPointApproaches(curveA, curveB, reversed);\n }\n /** Double dispatch handler for strongly typed segment. */\n public override handleLineSegment3d(segmentA: LineSegment3d): any {\n if (this._geometryB instanceof LineSegment3d) {\n const segmentB = this._geometryB;\n this.computeSegmentSegment(\n segmentA, segmentA.point0Ref, 0.0, segmentA.point1Ref, 1.0,\n segmentB, segmentB.point0Ref, 0.0, segmentB.point1Ref, 1.0,\n false,\n );\n } else if (this._geometryB instanceof LineString3d) {\n this.computeSegmentLineString(segmentA, this._geometryB, false);\n } else if (this._geometryB instanceof Arc3d) {\n this.computeSegmentArc(segmentA, this._geometryB, false);\n } else if (this.needsStroking(this._geometryB)) {\n this.dispatchCurveStrokedCurve(segmentA, this._geometryB, false);\n } else if (this._geometryB instanceof CurveCollection) {\n this.dispatchCurveCollection(segmentA, this.handleLineSegment3d.bind(this));\n } else if (this._geometryB instanceof CurveChainWithDistanceIndex) {\n this.dispatchCurveChainWithDistanceIndex(segmentA, this.handleLineSegment3d.bind(this));\n }\n return undefined;\n }\n /** Double dispatch handler for strongly typed linestring. */\n public override handleLineString3d(lsA: LineString3d): any {\n if (this._geometryB instanceof LineSegment3d) {\n this.computeSegmentLineString(this._geometryB, lsA, true);\n } else if (this._geometryB instanceof LineString3d) {\n this.computeLineStringLineString(lsA, this._geometryB, false);\n } else if (this._geometryB instanceof Arc3d) {\n this.computeArcLineString(this._geometryB, lsA, true);\n } else if (this.needsStroking(this._geometryB)) {\n this.dispatchCurveStrokedCurve(lsA, this._geometryB, false);\n } else if (this._geometryB instanceof CurveCollection) {\n this.dispatchCurveCollection(lsA, this.handleLineString3d.bind(this));\n } else if (this._geometryB instanceof CurveChainWithDistanceIndex) {\n this.dispatchCurveChainWithDistanceIndex(lsA, this.handleLineString3d.bind(this));\n }\n return undefined;\n }\n /** Double dispatch handler for strongly typed arc. */\n public override handleArc3d(arcA: Arc3d): any {\n if (this._geometryB instanceof LineSegment3d) {\n this.computeSegmentArc(this._geometryB, arcA, true);\n } else if (this._geometryB instanceof LineString3d) {\n this.computeArcLineString(arcA, this._geometryB, false);\n } else if (this._geometryB instanceof Arc3d) {\n this.dispatchArcArc(arcA, this._geometryB, false);\n } else if (this.needsStroking(this._geometryB)) {\n this.dispatchCurveStrokedCurve(arcA, this._geometryB, false);\n } else if (this._geometryB instanceof CurveCollection) {\n this.dispatchCurveCollection(arcA, this.handleArc3d.bind(this));\n } else if (this._geometryB instanceof CurveChainWithDistanceIndex) {\n this.dispatchCurveChainWithDistanceIndex(arcA, this.handleArc3d.bind(this));\n }\n return undefined;\n }\n /** Double dispatch handler for strongly typed bspline curve. */\n public override handleBSplineCurve3d(curveA: BSplineCurve3d): any {\n if (this._geometryB instanceof CurveChainWithDistanceIndex) {\n this.dispatchCurveChainWithDistanceIndex(curveA, this.handleBSplineCurve3d.bind(this));\n } else if (this._geometryB instanceof CurvePrimitive) {\n this.dispatchCurveStrokedCurve(this._geometryB, curveA, true);\n } else if (this._geometryB instanceof CurveCollection) {\n this.dispatchCurveCollection(curveA, this.handleBSplineCurve3d.bind(this));\n }\n return undefined;\n }\n /** Double dispatch handler for strongly typed spiral curve. */\n public override handleTransitionSpiral(spiral: TransitionSpiral3d): any {\n if (this._geometryB instanceof CurveChainWithDistanceIndex) {\n this.dispatchCurveChainWithDistanceIndex(spiral, this.handleTransitionSpiral.bind(this));\n } else if (this._geometryB instanceof CurvePrimitive) {\n this.dispatchCurveStrokedCurve(this._geometryB, spiral, true);\n } else if (this._geometryB instanceof CurveCollection) {\n this.dispatchCurveCollection(spiral, this.handleTransitionSpiral.bind(this));\n }\n return undefined;\n }\n /** Double dispatch handler for strongly typed CurveChainWithDistanceIndex. */\n public override handleCurveChainWithDistanceIndex(chain: CurveChainWithDistanceIndex): any {\n super.handleCurveChainWithDistanceIndex(chain);\n // if _geometryB is also a CurveChainWithDistanceIndex, it will already have been converted by dispatchCurveChainWithDistanceIndex\n const childResults = this._results.extractArray();\n childResults.forEach((pair: CurveLocationDetailPair) => {\n CurveChainWithDistanceIndex.convertChildDetailToChainDetailSingle(pair, chain, undefined);\n this._results.insert(pair);\n });\n }\n /** Double dispatch handler for strongly typed homogeneous bspline curve .. */\n public override handleBSplineCurve3dH(_curve: BSplineCurve3dH): any {\n // NEEDS WORK -- make \"dispatch\" methods tolerant of both 3d and 3dH\n return undefined;\n }\n}\n"]}
|