@itwin/core-geometry 4.3.0-dev.8 → 4.3.0
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/CHANGELOG.md +57 -1
- package/lib/cjs/Geometry.d.ts +14 -2
- package/lib/cjs/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js +20 -9
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/bspline/BSpline1dNd.d.ts +12 -2
- package/lib/cjs/bspline/BSpline1dNd.d.ts.map +1 -1
- package/lib/cjs/bspline/BSpline1dNd.js +27 -17
- package/lib/cjs/bspline/BSpline1dNd.js.map +1 -1
- package/lib/cjs/bspline/BSplineCurve.d.ts +30 -16
- package/lib/cjs/bspline/BSplineCurve.d.ts.map +1 -1
- package/lib/cjs/bspline/BSplineCurve.js +68 -44
- package/lib/cjs/bspline/BSplineCurve.js.map +1 -1
- package/lib/cjs/bspline/BSplineCurve3dH.d.ts +27 -20
- package/lib/cjs/bspline/BSplineCurve3dH.d.ts.map +1 -1
- package/lib/cjs/bspline/BSplineCurve3dH.js +136 -87
- package/lib/cjs/bspline/BSplineCurve3dH.js.map +1 -1
- package/lib/cjs/bspline/BSplineSurface.d.ts +138 -74
- package/lib/cjs/bspline/BSplineSurface.d.ts.map +1 -1
- package/lib/cjs/bspline/BSplineSurface.js +242 -119
- package/lib/cjs/bspline/BSplineSurface.js.map +1 -1
- package/lib/cjs/bspline/Bezier1dNd.d.ts +18 -4
- package/lib/cjs/bspline/Bezier1dNd.d.ts.map +1 -1
- package/lib/cjs/bspline/Bezier1dNd.js +19 -5
- package/lib/cjs/bspline/Bezier1dNd.js.map +1 -1
- package/lib/cjs/bspline/BezierCurve3dH.d.ts.map +1 -1
- package/lib/cjs/bspline/BezierCurve3dH.js +2 -1
- package/lib/cjs/bspline/BezierCurve3dH.js.map +1 -1
- package/lib/cjs/bspline/KnotVector.d.ts +30 -33
- package/lib/cjs/bspline/KnotVector.d.ts.map +1 -1
- package/lib/cjs/bspline/KnotVector.js +76 -69
- package/lib/cjs/bspline/KnotVector.js.map +1 -1
- package/lib/cjs/clipping/ClipUtils.d.ts +32 -5
- package/lib/cjs/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipUtils.js +92 -11
- package/lib/cjs/clipping/ClipUtils.js.map +1 -1
- package/lib/cjs/core-geometry.d.ts +0 -2
- package/lib/cjs/core-geometry.d.ts.map +1 -1
- package/lib/cjs/core-geometry.js +0 -2
- package/lib/cjs/core-geometry.js.map +1 -1
- package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
- package/lib/cjs/curve/Arc3d.js +5 -5
- package/lib/cjs/curve/Arc3d.js.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.d.ts +1 -4
- package/lib/cjs/curve/CurveLocationDetail.d.ts.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.js +4 -10
- package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
- package/lib/cjs/curve/CurveOps.d.ts +4 -5
- package/lib/cjs/curve/CurveOps.d.ts.map +1 -1
- package/lib/cjs/curve/CurveOps.js +1 -1
- package/lib/cjs/curve/CurveOps.js.map +1 -1
- package/lib/cjs/curve/CurveTypes.d.ts +14 -2
- package/lib/cjs/curve/CurveTypes.d.ts.map +1 -1
- package/lib/cjs/curve/CurveTypes.js.map +1 -1
- package/lib/cjs/curve/LineString3d.d.ts +3 -2
- package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineString3d.js +1 -0
- package/lib/cjs/curve/LineString3d.js.map +1 -1
- package/lib/cjs/curve/PointString3d.d.ts +2 -1
- package/lib/cjs/curve/PointString3d.d.ts.map +1 -1
- package/lib/cjs/curve/PointString3d.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +5 -11
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +15 -9
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +68 -56
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +14 -16
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +51 -69
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js +3 -2
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
- package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts +2 -3
- package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/MultiChainCollector.js.map +1 -1
- package/lib/cjs/curve/internalContexts/PolygonOffsetContext.d.ts +4 -4
- package/lib/cjs/curve/internalContexts/PolygonOffsetContext.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/PolygonOffsetContext.js +38 -36
- package/lib/cjs/curve/internalContexts/PolygonOffsetContext.js.map +1 -1
- package/lib/cjs/geometry3d/Angle.d.ts +0 -1
- package/lib/cjs/geometry3d/Angle.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Angle.js +0 -1
- package/lib/cjs/geometry3d/Angle.js.map +1 -1
- package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts +21 -5
- package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/CoincidentGeometryOps.js +71 -45
- package/lib/cjs/geometry3d/CoincidentGeometryOps.js.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.d.ts +20 -13
- package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.js +28 -21
- package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +11 -2
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +16 -5
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts +58 -20
- package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.js +213 -62
- package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
- package/lib/cjs/geometry3d/Segment1d.d.ts +5 -1
- package/lib/cjs/geometry3d/Segment1d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Segment1d.js +11 -7
- package/lib/cjs/geometry3d/Segment1d.js.map +1 -1
- package/lib/cjs/geometry3d/Transform.d.ts +4 -5
- package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Transform.js +4 -5
- package/lib/cjs/geometry3d/Transform.js.map +1 -1
- package/lib/cjs/geometry4d/Point4d.d.ts +13 -0
- package/lib/cjs/geometry4d/Point4d.d.ts.map +1 -1
- package/lib/cjs/geometry4d/Point4d.js +21 -0
- package/lib/cjs/geometry4d/Point4d.js.map +1 -1
- package/lib/cjs/numerics/BezierPolynomials.d.ts +88 -64
- package/lib/cjs/numerics/BezierPolynomials.d.ts.map +1 -1
- package/lib/cjs/numerics/BezierPolynomials.js +92 -73
- package/lib/cjs/numerics/BezierPolynomials.js.map +1 -1
- package/lib/cjs/numerics/Newton.d.ts +143 -61
- package/lib/cjs/numerics/Newton.d.ts.map +1 -1
- package/lib/cjs/numerics/Newton.js +233 -66
- package/lib/cjs/numerics/Newton.js.map +1 -1
- package/lib/cjs/numerics/PascalCoefficients.d.ts +8 -12
- package/lib/cjs/numerics/PascalCoefficients.d.ts.map +1 -1
- package/lib/cjs/numerics/PascalCoefficients.js +10 -12
- package/lib/cjs/numerics/PascalCoefficients.js.map +1 -1
- package/lib/cjs/numerics/Polynomials.d.ts +6 -10
- package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
- package/lib/cjs/numerics/Polynomials.js +6 -10
- package/lib/cjs/numerics/Polynomials.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts +3 -0
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.js +13 -2
- package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceData.d.ts +1 -1
- package/lib/cjs/polyface/PolyfaceData.js +1 -1
- package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts +38 -11
- package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +93 -16
- package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/cjs/serialization/BGFBReader.d.ts +10 -10
- package/lib/cjs/serialization/BGFBReader.d.ts.map +1 -1
- package/lib/cjs/serialization/BGFBReader.js +69 -42
- package/lib/cjs/serialization/BGFBReader.js.map +1 -1
- package/lib/cjs/serialization/BGFBWriter.d.ts +8 -8
- package/lib/cjs/serialization/BGFBWriter.d.ts.map +1 -1
- package/lib/cjs/serialization/BGFBWriter.js +80 -55
- package/lib/cjs/serialization/BGFBWriter.js.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.js +6 -8
- package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.d.ts +8 -14
- package/lib/cjs/serialization/IModelJsonSchema.d.ts.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.js +85 -259
- package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/cjs/serialization/SerializationHelpers.d.ts +109 -0
- package/lib/cjs/serialization/SerializationHelpers.d.ts.map +1 -0
- package/lib/cjs/serialization/SerializationHelpers.js +591 -0
- package/lib/cjs/serialization/SerializationHelpers.js.map +1 -0
- package/lib/cjs/topology/Graph.d.ts +399 -366
- package/lib/cjs/topology/Graph.d.ts.map +1 -1
- package/lib/cjs/topology/Graph.js +531 -464
- package/lib/cjs/topology/Graph.js.map +1 -1
- package/lib/cjs/topology/MaskManager.d.ts +8 -9
- package/lib/cjs/topology/MaskManager.d.ts.map +1 -1
- package/lib/cjs/topology/MaskManager.js +11 -12
- package/lib/cjs/topology/MaskManager.js.map +1 -1
- package/lib/esm/Geometry.d.ts +14 -2
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js +20 -9
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/bspline/BSpline1dNd.d.ts +12 -2
- package/lib/esm/bspline/BSpline1dNd.d.ts.map +1 -1
- package/lib/esm/bspline/BSpline1dNd.js +27 -17
- package/lib/esm/bspline/BSpline1dNd.js.map +1 -1
- package/lib/esm/bspline/BSplineCurve.d.ts +30 -16
- package/lib/esm/bspline/BSplineCurve.d.ts.map +1 -1
- package/lib/esm/bspline/BSplineCurve.js +68 -44
- package/lib/esm/bspline/BSplineCurve.js.map +1 -1
- package/lib/esm/bspline/BSplineCurve3dH.d.ts +27 -20
- package/lib/esm/bspline/BSplineCurve3dH.d.ts.map +1 -1
- package/lib/esm/bspline/BSplineCurve3dH.js +137 -88
- package/lib/esm/bspline/BSplineCurve3dH.js.map +1 -1
- package/lib/esm/bspline/BSplineSurface.d.ts +138 -74
- package/lib/esm/bspline/BSplineSurface.d.ts.map +1 -1
- package/lib/esm/bspline/BSplineSurface.js +242 -119
- package/lib/esm/bspline/BSplineSurface.js.map +1 -1
- package/lib/esm/bspline/Bezier1dNd.d.ts +18 -4
- package/lib/esm/bspline/Bezier1dNd.d.ts.map +1 -1
- package/lib/esm/bspline/Bezier1dNd.js +19 -5
- package/lib/esm/bspline/Bezier1dNd.js.map +1 -1
- package/lib/esm/bspline/BezierCurve3dH.d.ts.map +1 -1
- package/lib/esm/bspline/BezierCurve3dH.js +2 -1
- package/lib/esm/bspline/BezierCurve3dH.js.map +1 -1
- package/lib/esm/bspline/KnotVector.d.ts +30 -33
- package/lib/esm/bspline/KnotVector.d.ts.map +1 -1
- package/lib/esm/bspline/KnotVector.js +76 -69
- package/lib/esm/bspline/KnotVector.js.map +1 -1
- package/lib/esm/clipping/ClipUtils.d.ts +32 -5
- package/lib/esm/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/esm/clipping/ClipUtils.js +92 -11
- package/lib/esm/clipping/ClipUtils.js.map +1 -1
- package/lib/esm/core-geometry.d.ts +0 -2
- package/lib/esm/core-geometry.d.ts.map +1 -1
- package/lib/esm/core-geometry.js +0 -2
- package/lib/esm/core-geometry.js.map +1 -1
- package/lib/esm/curve/Arc3d.d.ts.map +1 -1
- package/lib/esm/curve/Arc3d.js +5 -5
- package/lib/esm/curve/Arc3d.js.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.d.ts +1 -4
- package/lib/esm/curve/CurveLocationDetail.d.ts.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.js +4 -10
- package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
- package/lib/esm/curve/CurveOps.d.ts +4 -5
- package/lib/esm/curve/CurveOps.d.ts.map +1 -1
- package/lib/esm/curve/CurveOps.js +1 -1
- package/lib/esm/curve/CurveOps.js.map +1 -1
- package/lib/esm/curve/CurveTypes.d.ts +14 -2
- package/lib/esm/curve/CurveTypes.d.ts.map +1 -1
- package/lib/esm/curve/CurveTypes.js.map +1 -1
- package/lib/esm/curve/LineString3d.d.ts +3 -2
- package/lib/esm/curve/LineString3d.d.ts.map +1 -1
- package/lib/esm/curve/LineString3d.js +1 -0
- package/lib/esm/curve/LineString3d.js.map +1 -1
- package/lib/esm/curve/PointString3d.d.ts +2 -1
- package/lib/esm/curve/PointString3d.d.ts.map +1 -1
- package/lib/esm/curve/PointString3d.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +5 -11
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +15 -9
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +69 -57
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +14 -16
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +51 -68
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js +3 -2
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
- package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts +2 -3
- package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/MultiChainCollector.js.map +1 -1
- package/lib/esm/curve/internalContexts/PolygonOffsetContext.d.ts +4 -4
- package/lib/esm/curve/internalContexts/PolygonOffsetContext.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/PolygonOffsetContext.js +38 -36
- package/lib/esm/curve/internalContexts/PolygonOffsetContext.js.map +1 -1
- package/lib/esm/geometry3d/Angle.d.ts +0 -1
- package/lib/esm/geometry3d/Angle.d.ts.map +1 -1
- package/lib/esm/geometry3d/Angle.js +0 -1
- package/lib/esm/geometry3d/Angle.js.map +1 -1
- package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts +21 -5
- package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/CoincidentGeometryOps.js +71 -45
- package/lib/esm/geometry3d/CoincidentGeometryOps.js.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.d.ts +20 -13
- package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.js +28 -21
- package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +11 -2
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +16 -5
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts +58 -20
- package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.js +213 -62
- package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
- package/lib/esm/geometry3d/Segment1d.d.ts +5 -1
- package/lib/esm/geometry3d/Segment1d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Segment1d.js +11 -7
- package/lib/esm/geometry3d/Segment1d.js.map +1 -1
- package/lib/esm/geometry3d/Transform.d.ts +4 -5
- package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
- package/lib/esm/geometry3d/Transform.js +4 -5
- package/lib/esm/geometry3d/Transform.js.map +1 -1
- package/lib/esm/geometry4d/Point4d.d.ts +13 -0
- package/lib/esm/geometry4d/Point4d.d.ts.map +1 -1
- package/lib/esm/geometry4d/Point4d.js +21 -0
- package/lib/esm/geometry4d/Point4d.js.map +1 -1
- package/lib/esm/numerics/BezierPolynomials.d.ts +88 -64
- package/lib/esm/numerics/BezierPolynomials.d.ts.map +1 -1
- package/lib/esm/numerics/BezierPolynomials.js +92 -73
- package/lib/esm/numerics/BezierPolynomials.js.map +1 -1
- package/lib/esm/numerics/Newton.d.ts +143 -61
- package/lib/esm/numerics/Newton.d.ts.map +1 -1
- package/lib/esm/numerics/Newton.js +229 -65
- package/lib/esm/numerics/Newton.js.map +1 -1
- package/lib/esm/numerics/PascalCoefficients.d.ts +8 -12
- package/lib/esm/numerics/PascalCoefficients.d.ts.map +1 -1
- package/lib/esm/numerics/PascalCoefficients.js +10 -12
- package/lib/esm/numerics/PascalCoefficients.js.map +1 -1
- package/lib/esm/numerics/Polynomials.d.ts +6 -10
- package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
- package/lib/esm/numerics/Polynomials.js +6 -10
- package/lib/esm/numerics/Polynomials.js.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.d.ts +3 -0
- package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.js +13 -2
- package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/esm/polyface/PolyfaceData.d.ts +1 -1
- package/lib/esm/polyface/PolyfaceData.js +1 -1
- package/lib/esm/polyface/PolyfaceData.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts +38 -11
- package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +93 -16
- package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/esm/serialization/BGFBReader.d.ts +10 -10
- package/lib/esm/serialization/BGFBReader.d.ts.map +1 -1
- package/lib/esm/serialization/BGFBReader.js +69 -42
- package/lib/esm/serialization/BGFBReader.js.map +1 -1
- package/lib/esm/serialization/BGFBWriter.d.ts +8 -8
- package/lib/esm/serialization/BGFBWriter.d.ts.map +1 -1
- package/lib/esm/serialization/BGFBWriter.js +80 -55
- package/lib/esm/serialization/BGFBWriter.js.map +1 -1
- package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/esm/serialization/GeometrySamples.js +7 -9
- package/lib/esm/serialization/GeometrySamples.js.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.d.ts +8 -14
- package/lib/esm/serialization/IModelJsonSchema.d.ts.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.js +86 -260
- package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/esm/serialization/SerializationHelpers.d.ts +109 -0
- package/lib/esm/serialization/SerializationHelpers.d.ts.map +1 -0
- package/lib/esm/serialization/SerializationHelpers.js +588 -0
- package/lib/esm/serialization/SerializationHelpers.js.map +1 -0
- package/lib/esm/topology/Graph.d.ts +399 -366
- package/lib/esm/topology/Graph.d.ts.map +1 -1
- package/lib/esm/topology/Graph.js +531 -464
- package/lib/esm/topology/Graph.js.map +1 -1
- package/lib/esm/topology/MaskManager.d.ts +8 -9
- package/lib/esm/topology/MaskManager.d.ts.map +1 -1
- package/lib/esm/topology/MaskManager.js +11 -12
- package/lib/esm/topology/MaskManager.js.map +1 -1
- package/package.json +3 -4
|
@@ -15,6 +15,7 @@ const GeometryHandler_1 = require("../../geometry3d/GeometryHandler");
|
|
|
15
15
|
const GrowableFloat64Array_1 = require("../../geometry3d/GrowableFloat64Array");
|
|
16
16
|
const Point3dVector3d_1 = require("../../geometry3d/Point3dVector3d");
|
|
17
17
|
const Range_1 = require("../../geometry3d/Range");
|
|
18
|
+
const Newton_1 = require("../../numerics/Newton");
|
|
18
19
|
const Polynomials_1 = require("../../numerics/Polynomials");
|
|
19
20
|
const Arc3d_1 = require("../Arc3d");
|
|
20
21
|
const CurveChainWithDistanceIndex_1 = require("../CurveChainWithDistanceIndex");
|
|
@@ -22,7 +23,7 @@ const CurveCollection_1 = require("../CurveCollection");
|
|
|
22
23
|
const CurveLocationDetail_1 = require("../CurveLocationDetail");
|
|
23
24
|
const LineSegment3d_1 = require("../LineSegment3d");
|
|
24
25
|
const LineString3d_1 = require("../LineString3d");
|
|
25
|
-
// cspell:word XYRR
|
|
26
|
+
// cspell:word XYRR currentdFdX
|
|
26
27
|
/**
|
|
27
28
|
* Handler class for XY close approach between _geometryB and another geometry.
|
|
28
29
|
* * Approach means the XY distance (z is ignored) between _geometryB and another geometry.
|
|
@@ -357,10 +358,44 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
357
358
|
this.testAndRecordProjection(cpB, fB1, pointB1, cpA, fA0, fA1, !reversed);
|
|
358
359
|
}
|
|
359
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Return XY closest approach between a curve primitive and a point.
|
|
363
|
+
* Currently, this function only supports Arc3d and LineSegment.
|
|
364
|
+
* Note that this function doesn't handle endpoints.
|
|
365
|
+
*/
|
|
366
|
+
getPointCurveClosestApproachXYNewton(curveP, pointQ) {
|
|
367
|
+
if (!(curveP instanceof Arc3d_1.Arc3d) && !(curveP instanceof LineSegment3d_1.LineSegment3d)) {
|
|
368
|
+
(0, core_bentley_1.assert)(!!"getPointCurveClosestApproachXYNewton only supports Arc3d and LineSegment");
|
|
369
|
+
return undefined;
|
|
370
|
+
}
|
|
371
|
+
const seeds = [0.2, 0.4, 0.6, 0.8]; // HEURISTIC: arcs have up to 4 perpendiculars; lines have only 1
|
|
372
|
+
const newtonEvaluator = new Newton_1.CurvePointCloseApproachXYRtoRD(curveP, pointQ);
|
|
373
|
+
const newtonSearcher = new Newton_1.Newton1dUnbounded(newtonEvaluator);
|
|
374
|
+
let minCloseApproachLength = Geometry_1.Geometry.largeCoordinateResult;
|
|
375
|
+
let minCurvePFraction;
|
|
376
|
+
let minPointP;
|
|
377
|
+
for (const seed of seeds) {
|
|
378
|
+
newtonSearcher.setX(seed);
|
|
379
|
+
if (newtonSearcher.runIterations()) {
|
|
380
|
+
const curvePFraction = newtonSearcher.getX();
|
|
381
|
+
if (this.acceptFraction(curvePFraction)) {
|
|
382
|
+
const pointP = curveP.fractionToPoint(curvePFraction);
|
|
383
|
+
const closeApproachLength = pointP.distanceSquaredXY(pointQ);
|
|
384
|
+
if (closeApproachLength < minCloseApproachLength) {
|
|
385
|
+
minCloseApproachLength = closeApproachLength;
|
|
386
|
+
minCurvePFraction = curvePFraction;
|
|
387
|
+
minPointP = pointP;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (minCurvePFraction && minPointP)
|
|
393
|
+
return CurveLocationDetail_1.CurveLocationDetail.createCurveFractionPoint(curveP, minCurvePFraction, minPointP);
|
|
394
|
+
return undefined;
|
|
395
|
+
}
|
|
360
396
|
/** Find the closest approach between pointA and cpB. Add the approach if it's within fB0 and fB1. */
|
|
361
397
|
testAndRecordProjection(cpA, fA, pointA, cpB, fB0, fB1, reversed) {
|
|
362
|
-
|
|
363
|
-
const detail = cpB.closestPoint(pointA, false);
|
|
398
|
+
const detail = this.getPointCurveClosestApproachXYNewton(cpB, pointA);
|
|
364
399
|
if (detail) {
|
|
365
400
|
const fB = Geometry_1.Geometry.restrictToInterval(detail.fraction, fB0, fB1);
|
|
366
401
|
if (fB === detail.fraction) { // if fraction is within fB0 and fB1
|
|
@@ -389,13 +424,13 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
389
424
|
this.computeSegmentSegment3D(cpA, pointA0, fractionA0, pointA1, fractionA1, cpB, pointB0, fractionB0, pointB1, fractionB1, reversed);
|
|
390
425
|
}
|
|
391
426
|
/**
|
|
392
|
-
* Low level dispatch of segment with arc.
|
|
427
|
+
* Low level dispatch of line segment with arc.
|
|
393
428
|
* Find close approaches within maxDistance between a line segments (pointA0, pointA1) and an arc.
|
|
394
429
|
* To consider:
|
|
395
430
|
* 1) intersection between arc and segment.
|
|
396
|
-
* 2)
|
|
397
|
-
* 3)
|
|
398
|
-
* @param cpA curve A (line segment or line string)
|
|
431
|
+
* 2) endpoints to endpoints or endpoints projection to the other curve.
|
|
432
|
+
* 3) arc tangent parallel to line segment (or line string).
|
|
433
|
+
* @param cpA curve A (line segment or line string; if it is a line string, then the fractions must specify a segment)
|
|
399
434
|
* @param pointA0 start point of the segment
|
|
400
435
|
* @param fractionA0 fraction of the start of the segment
|
|
401
436
|
* @param pointA1 end point of the segment
|
|
@@ -404,7 +439,7 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
404
439
|
* @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).
|
|
405
440
|
*/
|
|
406
441
|
dispatchSegmentArc(cpA, pointA0, fractionA0, pointA1, fractionA1, arc, reversed) {
|
|
407
|
-
// 1) intersection between arc and segment
|
|
442
|
+
// 1) intersection between arc and line segment (or string).
|
|
408
443
|
// Suppose:
|
|
409
444
|
// Arc: X = C + cU + sV where c = cos(theta) and s = sin(theta)
|
|
410
445
|
// Line: contains points A0 and A1
|
|
@@ -437,9 +472,9 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
437
472
|
}
|
|
438
473
|
if (intersectionFound)
|
|
439
474
|
return;
|
|
440
|
-
// 2) endpoints to endpoints or endpoints projection to the other curve
|
|
441
|
-
this.testAndRecordFractionalPairApproach(cpA, fractionA0, fractionA1, true, arc, 0, 1,
|
|
442
|
-
// 3)
|
|
475
|
+
// 2) endpoints to endpoints or endpoints projection to the other curve.
|
|
476
|
+
this.testAndRecordFractionalPairApproach(cpA, fractionA0, fractionA1, true, arc, 0, 1, true, reversed);
|
|
477
|
+
// 3) arc tangent parallel to line segment (or string).
|
|
443
478
|
// If line does not intersect the arc, then the closest (and/or the furthest) point on arc to the line is a
|
|
444
479
|
// point where the tangent line on arc at that point is parallel to the line.
|
|
445
480
|
const dotUT = data.vector0.crossProductStartEndXY(pointA0, pointA1);
|
|
@@ -455,63 +490,40 @@ class CurveCurveCloseApproachXY extends GeometryHandler_1.RecurseToCurvesGeometr
|
|
|
455
490
|
}
|
|
456
491
|
}
|
|
457
492
|
}
|
|
458
|
-
/**
|
|
459
|
-
|
|
460
|
-
const
|
|
461
|
-
const
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
for (const rA of [-radiusA, radiusA]) {
|
|
472
|
-
for (const rB of [-radiusB, radiusB]) {
|
|
473
|
-
const tangentDistance = c - rA + rB;
|
|
474
|
-
if (tangentDistance < e) {
|
|
475
|
-
const detailA = this.resolveDirectionToArcXYFraction(cpA, vectorAB, rA);
|
|
476
|
-
if (detailA) {
|
|
477
|
-
const detailB = this.resolveDirectionToArcXYFraction(cpB, vectorAB, rB);
|
|
478
|
-
if (detailB)
|
|
479
|
-
this.captureDetailPair(detailA, detailB, reversed);
|
|
480
|
-
}
|
|
493
|
+
/** Solve Newton for 2 arcs and the given newtonEvaluator. */
|
|
494
|
+
solveArcArcNewton(curveP, curveQ, reversed, newtonEvaluator) {
|
|
495
|
+
const seedsU = [0.2, 0.4, 0.6, 0.8]; // HEURISTIC: 2 arcs have up to 4 perpendiculars/intersections
|
|
496
|
+
const seedsV = [0.2, 0.4, 0.6, 0.8];
|
|
497
|
+
const newtonSearcher = new Newton_1.Newton2dUnboundedWithDerivative(newtonEvaluator);
|
|
498
|
+
for (const seedU of seedsU) {
|
|
499
|
+
for (const seedV of seedsV) {
|
|
500
|
+
newtonSearcher.setUV(seedU, seedV);
|
|
501
|
+
if (newtonSearcher.runIterations()) {
|
|
502
|
+
const curvePFraction = newtonSearcher.getU();
|
|
503
|
+
const curveQFraction = newtonSearcher.getV();
|
|
504
|
+
if (this.acceptFraction(curvePFraction) && this.acceptFraction(curveQFraction)) {
|
|
505
|
+
this.recordPointWithLocalFractions(curvePFraction, curveP, 0, 1, curveQFraction, curveQ, 0, 1, reversed);
|
|
481
506
|
}
|
|
482
507
|
}
|
|
483
508
|
}
|
|
484
509
|
}
|
|
485
510
|
}
|
|
486
|
-
/** Find
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
const s = scale * arc.matrixRef.columnDotXYZ(1, radialVector.x, radialVector.y, 0);
|
|
491
|
-
const radians = Math.atan2(s, c);
|
|
492
|
-
const fraction = arc.sweep.radiansToPositivePeriodicFraction(radians, 0);
|
|
493
|
-
if (fraction < 1.0)
|
|
494
|
-
return CurveLocationDetail_1.CurveLocationDetail.createCurveEvaluatedFraction(arc, fraction);
|
|
495
|
-
return undefined;
|
|
511
|
+
/** Find and store perpendicular line between 2 arcs. */
|
|
512
|
+
findPerpLineXYArcArcNewton(curveP, curveQ, reversed) {
|
|
513
|
+
const newtonEvaluator = new Newton_1.CurveCurveCloseApproachXYRRtoRRD(curveP, curveQ);
|
|
514
|
+
this.solveArcArcNewton(curveP, curveQ, reversed, newtonEvaluator);
|
|
496
515
|
}
|
|
497
|
-
/** Low level dispatch of arc with
|
|
516
|
+
/** Low level dispatch of arc with Arc3d. */
|
|
498
517
|
dispatchArcArc(cpA, cpB, reversed) {
|
|
499
518
|
const rangeA = cpA.range();
|
|
500
519
|
const rangeB = cpB.range();
|
|
501
520
|
rangeA.expandInPlace(this._maxDistanceToAccept);
|
|
502
521
|
if (!rangeB.intersectsRangeXY(rangeA))
|
|
503
522
|
return;
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
if (radiusA >= radiusB)
|
|
509
|
-
this.dispatchCircularCircularOrdered(cpA, radiusA, cpB, radiusB, reversed);
|
|
510
|
-
else
|
|
511
|
-
this.dispatchCircularCircularOrdered(cpB, radiusB, cpA, radiusA, !reversed);
|
|
512
|
-
return;
|
|
513
|
-
}
|
|
514
|
-
}
|
|
523
|
+
// 1) endpoints to endpoints or endpoints projection to the other curve
|
|
524
|
+
this.testAndRecordFractionalPairApproach(cpA, 0, 1, true, cpB, 0, 1, true, reversed);
|
|
525
|
+
// 2) perpendicular line between 2 arcs (includes intersections)
|
|
526
|
+
this.findPerpLineXYArcArcNewton(cpA, cpB, reversed);
|
|
515
527
|
}
|
|
516
528
|
/** Low level dispatch of arc with (beziers of) a bspline curve */
|
|
517
529
|
dispatchArcBsplineCurve3d(cpA, cpB, reversed) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurveCurveCloseApproachXY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AAI,CAAC,UAAU,YAAY,iCAAkB,EAAE;YACxD,IAAI,CAAC,oCAAoC,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;SAC1E;aAAM,IAAI,IAAI,CAAC,UAAU,YAAY,iCAAe,EAAE;YACrD,IAAI,CAAC,uBAAuB,CAAC,KAAK,EAAE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3E;aAAM,IAAI,IAAI,CAAC,UAAU,YAAY,yDAA2B,EAAE;YACjE,IAAI,CAAC,mCAAmC,CAAC,KAAK,EAAE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SACvF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,8EAA8E;IAC9D,iCAAiC,CAAC,KAAkC;QAClF,KAAK,CAAC,iCAAiC,CAAC,KAAK,CAAC,CAAC;QAC/C,kIAAkI;QAClI,IAAI,CAAC,QAAQ,GAAG,yDAA2B,CAAC,+BAA+B,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACxH,CAAC;IACD,8EAA8E;IAC9D,qBAAqB,CAAC,MAAuB;QAC3D;;;;;;;;;;;;UAYE;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;;AA30Bc,uCAAa,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;AACjC,uCAAa,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;AACjC,uCAAa,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;AACjC,uCAAa,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;AACjC,qCAAW,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;AAjCnC,8DAAyB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { BSplineCurve3d, BSplineCurve3dBase } from \"../../bspline/BSplineCurve\";\r\nimport { BSplineCurve3dH } from \"../../bspline/BSplineCurve3dH\";\r\nimport { Geometry } from \"../../Geometry\";\r\nimport { RecurseToCurvesGeometryHandler } from \"../../geometry3d/GeometryHandler\";\r\nimport { GrowableFloat64Array } from \"../../geometry3d/GrowableFloat64Array\";\r\nimport { Point3d, Vector3d } from \"../../geometry3d/Point3dVector3d\";\r\nimport { Range3d } from \"../../geometry3d/Range\";\r\nimport { AnalyticRoots, SmallSystem } from \"../../numerics/Polynomials\";\r\nimport { Arc3d } from \"../Arc3d\";\r\nimport { CurveChainWithDistanceIndex } from \"../CurveChainWithDistanceIndex\";\r\nimport { CurveCollection } from \"../CurveCollection\";\r\nimport { CurveIntervalRole, CurveLocationDetail, CurveLocationDetailPair } from \"../CurveLocationDetail\";\r\nimport { CurvePrimitive } from \"../CurvePrimitive\";\r\nimport { AnyCurve } from \"../CurveTypes\";\r\nimport { LineSegment3d } from \"../LineSegment3d\";\r\nimport { LineString3d } from \"../LineString3d\";\r\n\r\n// cspell:word XYRR\r\n\r\n/**\r\n * Handler class for XY close approach between _geometryB and another geometry.\r\n * * Approach means the XY distance (z is ignored) between _geometryB and another geometry.\r\n * * Closest approach is a measure of the proximity of one curve to another. It's the length of the shortest line\r\n * segment perpendicular to both curves; if the curves intersect, the closest approach is zero. In the context of\r\n * this class, z-coordinates are ignored, so the closest approach is as seen in the top view. If you have coplanar\r\n * input curves and want to find closest approach in their plane, rotate them first into a plane parallel to the\r\n * xy-plane, then afterward, rotate the results back as required.\r\n * * Close approach can also be from a curve endpoint perpendicular to another curve or from a curve endpoint to\r\n * another curve endpoint.\r\n * * Instances are initialized and called from CurveCurve.\r\n * * geometryB is saved for later reference.\r\n * @internal\r\n */\r\nexport class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {\r\n private _geometryB: AnyCurve | undefined;\r\n private _circularArcB: Arc3d | undefined;\r\n private _circularRadiusB: number | undefined;\r\n private setGeometryB(geometryB: AnyCurve | undefined) {\r\n this._geometryB = geometryB;\r\n this._circularArcB = undefined;\r\n this._circularRadiusB = undefined;\r\n if (geometryB instanceof Arc3d) {\r\n const r = geometryB.circularRadiusXY();\r\n if (r !== undefined) {\r\n this._circularRadiusB = r;\r\n this._circularArcB = geometryB;\r\n }\r\n }\r\n }\r\n /**\r\n * Maximum XY distance (z is ignored). Approach larger than this is not interesting.\r\n * This is caller defined and can be undefined.\r\n */\r\n private _maxDistanceToAccept: number | undefined;\r\n /** Squared max distance. This is private, and is forced to at least small metric distance squared. */\r\n private _maxDistanceSquared: number;\r\n /**\r\n * Start and end points of line segments that meet closest approach criteria, i.e., they are perpendicular to\r\n * both curves and their length is smaller than _maxDistanceToAccept.\r\n */\r\n private _results: CurveLocationDetailPair[];\r\n\r\n private static _workPointAA0 = Point3d.create();\r\n private static _workPointAA1 = Point3d.create();\r\n private static _workPointBB0 = Point3d.create();\r\n private static _workPointBB1 = Point3d.create();\r\n private static _workPointB = Point3d.create();\r\n\r\n /**\r\n * Constructor.\r\n * @param geometryB second curve for intersection. Saved for reference by specific handler methods.\r\n */\r\n public constructor(geometryB: AnyCurve | undefined) {\r\n super();\r\n this.setGeometryB(geometryB);\r\n this._maxDistanceSquared = Geometry.smallMetricDistanceSquared;\r\n this._results = [];\r\n }\r\n /** Set the (possibly undefined) max XY distance (z is ignored) to accept. */\r\n public set maxDistanceToAccept(value: number | undefined) {\r\n this._maxDistanceToAccept = value;\r\n if (this._maxDistanceToAccept !== undefined && this._maxDistanceToAccept > 0)\r\n this._maxDistanceSquared = this._maxDistanceToAccept * this._maxDistanceToAccept;\r\n }\r\n /** Access the (possibly undefined) max XY distance (z is ignored) to accept. */\r\n public get maxDistanceToAccept(): number | undefined {\r\n return this._maxDistanceToAccept;\r\n }\r\n /** Ask if the maxDistanceToAccept value is defined and positive */\r\n public get isMaxDistanceSet(): boolean {\r\n return this._maxDistanceToAccept !== undefined && this._maxDistanceToAccept > 0;\r\n }\r\n /** Reset the geometry and flags, leaving all other parts unchanged (and preserving accumulated intersections) */\r\n public resetGeometry(geometryB: AnyCurve) {\r\n this.setGeometryB(geometryB);\r\n }\r\n /** returns true if `fraction` is in [0,1] within tolerance */\r\n private acceptFraction(fraction: number, fractionTol: number = 1.0e-12) {\r\n if (fraction < -fractionTol)\r\n return false;\r\n if (fraction > 1.0 + fractionTol)\r\n return false;\r\n return true;\r\n }\r\n /**\r\n * Return the results structure for the intersection calculation, structured as an array of CurveLocationDetailPair.\r\n * @param reinitialize if true, a new results structure is created for use by later calls.\r\n */\r\n public grabPairedResults(reinitialize: boolean = false): CurveLocationDetailPair[] {\r\n const result = this._results;\r\n if (reinitialize)\r\n this._results = [];\r\n return result;\r\n }\r\n /**\r\n * If distance between pointA and pointB is less than maxDistance, record CurveLocationDetailPair which is\r\n * the approach from pointA to pointB.\r\n */\r\n private testAndRecordPointPairApproach(\r\n cpA: CurvePrimitive, fA: number, pointA: Point3d, cpB: CurvePrimitive, fB: number, pointB: Point3d, reversed: boolean,\r\n ): void {\r\n const d2 = pointA.distanceSquaredXY(pointB);\r\n if (d2 < this._maxDistanceSquared) {\r\n const detailA = CurveLocationDetail.createCurveFractionPoint(cpA, fA, pointA);\r\n const detailB = CurveLocationDetail.createCurveFractionPoint(cpB, fB, pointB);\r\n const pair = CurveLocationDetailPair.createCapture(detailA, detailB);\r\n if (reversed)\r\n pair.swapDetails();\r\n this._results.push(pair);\r\n }\r\n }\r\n /**\r\n * Create a close approach pair if XY distance is within maxDistance.\r\n * @param localFractionA a fraction on first curve\r\n * @param cpA the first curve\r\n * @param fractionA0 start of the first curve\r\n * @param fractionA1 end of the first curve\r\n * @param localFractionB a fraction on second curve\r\n * @param cpB the second curve\r\n * @param fractionB0 start of the second curve\r\n * @param fractionB1 end of the second curve\r\n * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).\r\n * @param intervalDetails optional CurveLocationDetailPair\r\n */\r\n private recordPointWithLocalFractions(\r\n localFractionA: number,\r\n cpA: CurvePrimitive,\r\n fractionA0: number,\r\n fractionA1: number,\r\n localFractionB: number,\r\n cpB: CurvePrimitive,\r\n fractionB0: number,\r\n fractionB1: number,\r\n reversed: boolean,\r\n intervalDetails?: undefined | CurveLocationDetailPair,\r\n ): void {\r\n let globalFractionA, globalFractionB;\r\n let globalFractionA1, globalFractionB1;\r\n const isInterval = intervalDetails !== undefined &&\r\n intervalDetails.detailA.hasFraction1 &&\r\n intervalDetails.detailB.hasFraction1;\r\n if (isInterval) {\r\n globalFractionA = Geometry.interpolate(fractionA0, intervalDetails.detailA.fraction, fractionA1);\r\n globalFractionB = Geometry.interpolate(fractionB0, intervalDetails.detailB.fraction, fractionB1);\r\n globalFractionA1 = Geometry.interpolate(fractionA0, intervalDetails.detailA.fraction1!, fractionA1);\r\n globalFractionB1 = Geometry.interpolate(fractionB0, intervalDetails.detailB.fraction1!, fractionB1);\r\n } else {\r\n globalFractionA = globalFractionA1 = Geometry.interpolate(fractionA0, localFractionA, fractionA1);\r\n globalFractionB = globalFractionB1 = Geometry.interpolate(fractionB0, localFractionB, fractionB1);\r\n }\r\n // ignore duplicate of most recent approach\r\n const numPrevious = this._results.length;\r\n if (numPrevious > 0 && !isInterval) {\r\n const oldDetailA = this._results[numPrevious - 1].detailA;\r\n const oldDetailB = this._results[numPrevious - 1].detailB;\r\n if (reversed) {\r\n if (oldDetailB.isSameCurveAndFraction({curve: cpA, fraction: globalFractionA}) &&\r\n oldDetailA.isSameCurveAndFraction({curve: cpB, fraction: globalFractionB}))\r\n return;\r\n } else {\r\n if (oldDetailA.isSameCurveAndFraction({curve: cpA, fraction: globalFractionA}) &&\r\n oldDetailB.isSameCurveAndFraction({curve: cpB, fraction: globalFractionB}))\r\n return;\r\n }\r\n }\r\n const detailA = CurveLocationDetail.createCurveFractionPoint(\r\n cpA, globalFractionA, cpA.fractionToPoint(globalFractionA),\r\n );\r\n const detailB = CurveLocationDetail.createCurveFractionPoint(\r\n cpB, globalFractionB, cpB.fractionToPoint(globalFractionB),\r\n );\r\n if (isInterval) {\r\n detailA.captureFraction1Point1(globalFractionA1, cpA.fractionToPoint(globalFractionA1));\r\n detailB.captureFraction1Point1(globalFractionB1, cpB.fractionToPoint(globalFractionB1));\r\n } else {\r\n const d2 = detailA.point.distanceSquaredXY(detailB.point);\r\n if (d2 > this._maxDistanceSquared)\r\n return;\r\n detailA.setIntervalRole(CurveIntervalRole.isolated);\r\n detailB.setIntervalRole(CurveIntervalRole.isolated);\r\n }\r\n if (reversed) {\r\n this._results.push(new CurveLocationDetailPair(detailB, detailA));\r\n } else {\r\n this._results.push(new CurveLocationDetailPair(detailA, detailB));\r\n }\r\n }\r\n /**\r\n * Capture a close approach pair that has point and local fraction but not curve.\r\n * * Record the pair, each detail modified with global fraction and input curve.\r\n * * Pair is neither modified nor recorded if it would be a duplicate of the last recorded pair.\r\n * @param pair details computed with local fractions\r\n * @param cpA curveA\r\n * @param fractionA0 global start fraction on curveA\r\n * @param fractionA1 global end fraction on curveA\r\n * @param cpB curveB\r\n * @param fractionB0 global start fraction on curveB\r\n * @param fractionB1 global end fraction on curveB\r\n * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).\r\n */\r\n private capturePairWithLocalFractions(\r\n pair: CurveLocationDetailPair,\r\n cpA: CurvePrimitive,\r\n fractionA0: number,\r\n fractionA1: number,\r\n cpB: CurvePrimitive,\r\n fractionB0: number,\r\n fractionB1: number,\r\n reversed: boolean,\r\n ) {\r\n const globalFractionA = Geometry.interpolate(fractionA0, pair.detailA.fraction, fractionA1);\r\n const globalFractionB = Geometry.interpolate(fractionB0, pair.detailB.fraction, fractionB1);\r\n // ignore duplicate of most recent pair\r\n const numPrevious = this._results.length;\r\n if (numPrevious > 0) {\r\n const oldDetailA = this._results[numPrevious - 1].detailA;\r\n const oldDetailB = this._results[numPrevious - 1].detailB;\r\n if (reversed) {\r\n if (oldDetailB.isSameCurveAndFraction({curve: cpA, fraction: globalFractionA}) &&\r\n oldDetailA.isSameCurveAndFraction({curve: cpB, fraction: globalFractionB}))\r\n return;\r\n } else {\r\n if (oldDetailA.isSameCurveAndFraction({curve: cpA, fraction: globalFractionA}) &&\r\n oldDetailB.isSameCurveAndFraction({curve: cpB, fraction: globalFractionB}))\r\n return;\r\n }\r\n }\r\n // recompute the points just in case\r\n CurveLocationDetail.createCurveEvaluatedFraction(cpA, globalFractionA, pair.detailA);\r\n CurveLocationDetail.createCurveEvaluatedFraction(cpB, globalFractionB, pair.detailB);\r\n pair.detailA.setIntervalRole(CurveIntervalRole.isolated);\r\n pair.detailB.setIntervalRole(CurveIntervalRole.isolated);\r\n if (reversed)\r\n pair.swapDetails();\r\n this._results.push(pair);\r\n }\r\n /**\r\n * Emit recordPoint for multiple pairs (on full curve) if within maxDistance.\r\n * @param cpA first curve primitive (possibly different from curve in detailA, but fraction compatible)\r\n * @param cpB second curve primitive (possibly different from curve in detailA, but fraction compatible)\r\n * @param pairs array of pairs\r\n * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).\r\n */\r\n public recordPairs(\r\n cpA: CurvePrimitive, cpB: CurvePrimitive, pairs: CurveLocationDetailPair[] | undefined, reversed: boolean,\r\n ): void {\r\n if (pairs !== undefined) {\r\n for (const p of pairs) {\r\n this.recordPointWithLocalFractions(\r\n p.detailA.fraction, cpA, 0, 1, p.detailB.fraction, cpB, 0, 1, reversed, p,\r\n );\r\n }\r\n }\r\n }\r\n /**\r\n * Record fully assembled (but possibly reversed) detail pair.\r\n * @param detailA first detail\r\n * @param detailB second detail\r\n * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).\r\n */\r\n public captureDetailPair(\r\n detailA: CurveLocationDetail | undefined, detailB: CurveLocationDetail | undefined, reversed: boolean,\r\n ): void {\r\n if (detailA && detailB) {\r\n if (reversed) {\r\n this._results.push(CurveLocationDetailPair.createCapture(detailB, detailA));\r\n } else {\r\n this._results.push(CurveLocationDetailPair.createCapture(detailA, detailB));\r\n }\r\n }\r\n }\r\n private static updatePointToSegmentDistance(\r\n fractionA: number,\r\n pointA: Point3d,\r\n pointB0: Point3d,\r\n pointB1: Point3d,\r\n fractionB: number,\r\n maxDistanceSquared: number,\r\n closestApproach: CurveLocationDetailPair, // modified on return\r\n ): boolean {\r\n let updated = false;\r\n if (fractionB < 0)\r\n fractionB = 0;\r\n else if (fractionB > 1)\r\n fractionB = 1;\r\n this._workPointB = pointB0.interpolate(fractionB, pointB1, this._workPointB);\r\n const distanceSquared = this._workPointB.distanceSquaredXY(pointA);\r\n if (distanceSquared <= Math.min(maxDistanceSquared, closestApproach.detailA.a)) {\r\n closestApproach.detailA.setFP(fractionA, pointA, undefined, distanceSquared);\r\n closestApproach.detailB.setFP(fractionB, this._workPointB, undefined, distanceSquared);\r\n updated = true;\r\n }\r\n return updated;\r\n }\r\n /**\r\n * Return fractions of close approach within maxDistance between two line segments (a0,a1) and (b0,b1).\r\n * * Math details can be found at core/geometry/internaldocs/Curve.md\r\n * @param a0 start point of line a\r\n * @param a1 end point of line a\r\n * @param b0 start point of line b\r\n * @param b1 end point of line b\r\n * @param maxDistanceSquared maximum distance squared (assumed to be positive)\r\n * @returns the fractional (not xy) coordinates in result.x and result.y. result.x is fraction on line a.\r\n * result.y is fraction on line b.\r\n */\r\n private static segmentSegmentBoundedApproach(\r\n a0: Point3d,\r\n a1: Point3d,\r\n b0: Point3d,\r\n b1: Point3d,\r\n maxDistanceSquared: number,\r\n ): CurveLocationDetailPair | undefined {\r\n const ux = a1.x - a0.x;\r\n const uy = a1.y - a0.y;\r\n const vx = b1.x - b0.x;\r\n const vy = b1.y - b0.y;\r\n const e00x = b0.x - a0.x;\r\n const e00y = b0.y - a0.y;\r\n const e01x = b1.x - a0.x;\r\n const e01y = b1.y - a0.y;\r\n const e10x = b0.x - a1.x;\r\n const e10y = b0.y - a1.y;\r\n const hab0 = Geometry.crossProductXYXY(ux, uy, e00x, e00y);\r\n const hab1 = Geometry.crossProductXYXY(ux, uy, e01x, e01y);\r\n const hba0 = -Geometry.crossProductXYXY(vx, vy, e00x, e00y);\r\n const hba1 = -Geometry.crossProductXYXY(vx, vy, e10x, e10y);\r\n if (hab0 * hab1 < 0.0 && hba0 * hba1 < 0.0) { // true intersection, strictly within both segments\r\n const fractionA = -hba0 / (hba1 - hba0);\r\n const fractionB = -hab0 / (hab1 - hab0);\r\n return CurveLocationDetailPair.createCapture(\r\n CurveLocationDetail.createCurveFractionPoint(undefined, fractionA, a0.interpolate(fractionA, a1)),\r\n CurveLocationDetail.createCurveFractionPoint(undefined, fractionB, b0.interpolate(fractionB, b1)),\r\n );\r\n }\r\n // there's no intersection, so find the closest approach within maxDistance from an endpoint\r\n const closestApproach = new CurveLocationDetailPair();\r\n closestApproach.detailA.a = 2 * maxDistanceSquared; // init to an approach that's too far away\r\n let reversed = false;\r\n const uu = Geometry.hypotenuseSquaredXY(ux, uy);\r\n if (hab0 * hab0 <= maxDistanceSquared * uu) { // test distance of b0 to u\r\n const fractionA = Geometry.dotProductXYXY(ux, uy, e00x, e00y) / uu;\r\n if (this.updatePointToSegmentDistance(0, b0, a0, a1, fractionA, maxDistanceSquared, closestApproach))\r\n reversed = true;\r\n }\r\n if (hab1 * hab1 <= maxDistanceSquared * uu) { // test distance of b1 to u\r\n const fractionA = Geometry.dotProductXYXY(ux, uy, e01x, e01y) / uu;\r\n if (this.updatePointToSegmentDistance(1, b1, a0, a1, fractionA, maxDistanceSquared, closestApproach))\r\n reversed = true;\r\n }\r\n const vv = Geometry.hypotenuseSquaredXY(vx, vy);\r\n if (hba0 * hba0 <= maxDistanceSquared * vv) { // test distance of a0 to v\r\n const fractionB = -Geometry.dotProductXYXY(vx, vy, e00x, e00y) / vv;\r\n if (this.updatePointToSegmentDistance(0, a0, b0, b1, fractionB, maxDistanceSquared, closestApproach))\r\n reversed = false;\r\n }\r\n if (hba1 * hba1 <= maxDistanceSquared * vv) { // test distance of a1 to v\r\n const fractionB = -Geometry.dotProductXYXY(vx, vy, e10x, e10y) / vv;\r\n if (this.updatePointToSegmentDistance(1, a1, b0, b1, fractionB, maxDistanceSquared, closestApproach))\r\n reversed = false;\r\n }\r\n if (closestApproach.detailA.a > maxDistanceSquared)\r\n return undefined;\r\n if (reversed)\r\n closestApproach.swapDetails();\r\n return closestApproach;\r\n }\r\n /**\r\n * Check different combination of fractions on curveA and curveB. If distance between points at 2 fractions\r\n * is less than maxDistance, record CurveLocationDetailPair which is the approach between the 2 points.\r\n * Optionally, record close approaches of one curve's points if they fall between the other curve's points.\r\n * @param cpA curveA\r\n * @param fA0 fraction0 on curveA\r\n * @param fA1 fraction1 on curveA\r\n * @param testProjectionOnA whether to record projections of the given curveB points onto curveA\r\n * @param cpB curveB\r\n * @param fB0 fraction0 on curveB\r\n * @param fB1 fraction0 on curveB\r\n * @param testProjectionOnB whether to record projections of the given curveA points onto curveB\r\n * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).\r\n */\r\n private testAndRecordFractionalPairApproach(\r\n cpA: CurvePrimitive,\r\n fA0: number,\r\n fA1: number,\r\n testProjectionOnA: boolean,\r\n cpB: CurvePrimitive,\r\n fB0: number,\r\n fB1: number,\r\n testProjectionOnB: boolean,\r\n reversed: boolean,\r\n ): void {\r\n const pointA0 = cpA.fractionToPoint(fA0);\r\n const pointA1 = cpA.fractionToPoint(fA1);\r\n const pointB0 = cpB.fractionToPoint(fB0);\r\n const pointB1 = cpB.fractionToPoint(fB1);\r\n this.testAndRecordPointPairApproach(cpA, fA0, pointA0, cpB, fB0, pointB0, reversed);\r\n this.testAndRecordPointPairApproach(cpA, fA1, pointA1, cpB, fB0, pointB0, reversed);\r\n this.testAndRecordPointPairApproach(cpA, fA0, pointA0, cpB, fB1, pointB1, reversed);\r\n this.testAndRecordPointPairApproach(cpA, fA1, pointA1, cpB, fB1, pointB1, reversed);\r\n if (testProjectionOnB) {\r\n this.testAndRecordProjection(cpA, fA0, pointA0, cpB, fB0, fB1, reversed);\r\n this.testAndRecordProjection(cpA, fA1, pointA1, cpB, fB0, fB1, reversed);\r\n }\r\n if (testProjectionOnA) {\r\n this.testAndRecordProjection(cpB, fB0, pointB0, cpA, fA0, fA1, !reversed);\r\n this.testAndRecordProjection(cpB, fB1, pointB1, cpA, fA0, fA1, !reversed);\r\n }\r\n }\r\n /** Find the closest approach between pointA and cpB. Add the approach if it's within fB0 and fB1. */\r\n private testAndRecordProjection(\r\n cpA: CurvePrimitive, fA: number, pointA: Point3d, cpB: CurvePrimitive, fB0: number, fB1: number, reversed: boolean,\r\n ) {\r\n // NO NO NO -- this is 3D closest point --- need 2d !!\r\n const detail = cpB.closestPoint(pointA, false);\r\n if (detail) {\r\n const fB = Geometry.restrictToInterval(detail.fraction, fB0, fB1);\r\n if (fB === detail.fraction) { // if fraction is within fB0 and fB1\r\n this.testAndRecordPointPairApproach(cpA, fA, pointA, cpB, detail.fraction, detail.point, reversed);\r\n }\r\n }\r\n }\r\n /**\r\n * Compute intersection of two line segments.\r\n * Filter by extension rules.\r\n * Record with fraction mapping.\r\n * * The fraction mappings allow portions of a linestring to be passed here.\r\n */\r\n private computeSegmentSegment3D(\r\n cpA: CurvePrimitive,\r\n pointA0: Point3d,\r\n fractionA0: number,\r\n pointA1: Point3d,\r\n fractionA1: number,\r\n cpB: CurvePrimitive,\r\n pointB0: Point3d,\r\n fractionB0: number,\r\n pointB1: Point3d,\r\n fractionB1: number,\r\n reversed: boolean,\r\n ): void {\r\n // compute a pair with fractions local to segments\r\n const approach = CurveCurveCloseApproachXY.segmentSegmentBoundedApproach(\r\n pointA0, pointA1, pointB0, pointB1, this._maxDistanceSquared,\r\n );\r\n // adjust the pair to refer to input curves and global fractions, then record it if new\r\n if (approach) {\r\n approach.detailA.setCurve(cpA);\r\n approach.detailB.setCurve(cpB);\r\n this.capturePairWithLocalFractions(approach, cpA, fractionA0, fractionA1, cpB, fractionB0, fractionB1, reversed);\r\n }\r\n }\r\n /** Low level dispatch of segment with segment. */\r\n private dispatchSegmentSegment(\r\n cpA: CurvePrimitive,\r\n pointA0: Point3d,\r\n fractionA0: number,\r\n pointA1: Point3d,\r\n fractionA1: number,\r\n cpB: CurvePrimitive,\r\n pointB0: Point3d,\r\n fractionB0: number,\r\n pointB1: Point3d,\r\n fractionB1: number,\r\n reversed: boolean,\r\n ): void {\r\n this.computeSegmentSegment3D(\r\n cpA, pointA0, fractionA0, pointA1, fractionA1,\r\n cpB, pointB0, fractionB0, pointB1, fractionB1,\r\n reversed,\r\n );\r\n }\r\n /**\r\n * Low level dispatch of segment with arc.\r\n * Find close approaches within maxDistance between a line segments (pointA0, pointA1) and an arc.\r\n * To consider:\r\n * 1) intersection between arc and segment.\r\n * 2) arc endpoints to segment endpoints or arc endpoints projection to the segment.\r\n * 3) line parallel to arc tangent.\r\n * @param cpA curve A (line segment or line string)\r\n * @param pointA0 start point of the segment\r\n * @param fractionA0 fraction of the start of the segment\r\n * @param pointA1 end point of the segment\r\n * @param fractionA1 fraction of the end of the segment\r\n * @param arc the arc\r\n * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).\r\n */\r\n private dispatchSegmentArc(\r\n cpA: CurvePrimitive,\r\n pointA0: Point3d,\r\n fractionA0: number,\r\n pointA1: Point3d,\r\n fractionA1: number,\r\n arc: Arc3d,\r\n reversed: boolean,\r\n ): void {\r\n // 1) intersection between arc and segment\r\n // Suppose:\r\n // Arc: X = C + cU + sV where c = cos(theta) and s = sin(theta)\r\n // Line: contains points A0 and A1\r\n // The arc intersects the line at point X if det(A0, A1, X) = 0 with homogeneous xyw points and vectors.\r\n // With equational X: det(A0, A1, C) + c*det(A0, A1, U) + s*det(A0, A1, V) = 0.\r\n // solve for theta.\r\n // evaluate points.\r\n // project back to line.\r\n let intersectionFound = false;\r\n const data = arc.toTransformedVectors();\r\n const pointA0Local = pointA0;\r\n const pointA1Local = pointA1;\r\n const alpha = Geometry.tripleProductXYW(pointA0Local, 1, pointA1Local, 1, data.center, 1); // det(A0, A1, C)\r\n const beta = Geometry.tripleProductXYW(pointA0Local, 1, pointA1Local, 1, data.vector0, 0); // det(A0, A1, U)\r\n const gamma = Geometry.tripleProductXYW(pointA0Local, 1, pointA1Local, 1, data.vector90, 0); // det(A0, A1, V)\r\n const cosines = new GrowableFloat64Array(2);\r\n const sines = new GrowableFloat64Array(2);\r\n const radians = new GrowableFloat64Array(2);\r\n const numRoots = AnalyticRoots.appendImplicitLineUnitCircleIntersections( // solve the equation\r\n alpha, beta, gamma, cosines, sines, radians,\r\n );\r\n for (let i = 0; i < numRoots; i++) {\r\n const arcPoint = data.center.plus2Scaled(\r\n data.vector0, cosines.atUncheckedIndex(i), data.vector90, sines.atUncheckedIndex(i),\r\n );\r\n const arcFraction = data.sweep.radiansToSignedPeriodicFraction(radians.atUncheckedIndex(i));\r\n const lineFraction = SmallSystem.lineSegment3dXYClosestPointUnbounded(pointA0Local, pointA1Local, arcPoint);\r\n // only add if the point is within the start and end fractions of both line segment and arc\r\n if (lineFraction !== undefined && this.acceptFraction(lineFraction) && this.acceptFraction(arcFraction)) {\r\n this.recordPointWithLocalFractions(\r\n lineFraction, cpA, fractionA0, fractionA1, arcFraction, arc, 0, 1, reversed,\r\n );\r\n intersectionFound = true;\r\n }\r\n }\r\n if (intersectionFound)\r\n return;\r\n // 2) endpoints to endpoints or endpoints projection to the other curve\r\n this.testAndRecordFractionalPairApproach(cpA, fractionA0, fractionA1, true, arc, 0, 1, false, reversed);\r\n // 3) line parallel to arc tangent.\r\n // If line does not intersect the arc, then the closest (and/or the furthest) point on arc to the line is a\r\n // point where the tangent line on arc at that point is parallel to the line.\r\n const dotUT = data.vector0.crossProductStartEndXY(pointA0, pointA1);\r\n const dotVT = data.vector90.crossProductStartEndXY(pointA0, pointA1);\r\n const parallelRadians = Math.atan2(dotVT, dotUT);\r\n for (const radians1 of [parallelRadians, parallelRadians + Math.PI]) {\r\n const arcPoint = data.center.plus2Scaled(data.vector0, Math.cos(radians1), data.vector90, Math.sin(radians1));\r\n const arcFraction = data.sweep.radiansToSignedPeriodicFraction(radians1);\r\n const lineFraction = SmallSystem.lineSegment3dXYClosestPointUnbounded(pointA0Local, pointA1Local, arcPoint);\r\n // only add if the point is within the start and end fractions of both line segment and arc\r\n if (lineFraction !== undefined && this.acceptFraction(lineFraction) && this.acceptFraction(arcFraction)) {\r\n this.recordPointWithLocalFractions(\r\n lineFraction, cpA, fractionA0, fractionA1, arcFraction, arc, 0, 1, reversed,\r\n );\r\n }\r\n }\r\n }\r\n /** Low level dispatch of circular arc with circular arc. radiusA must be larger than or equal to radiusB. */\r\n private dispatchCircularCircularOrdered(\r\n cpA: Arc3d, radiusA: number, cpB: Arc3d, radiusB: number, reversed: boolean,\r\n ): void {\r\n const c = cpA.center.distance(cpB.center);\r\n const e = this._maxDistanceToAccept !== undefined ? this._maxDistanceToAccept : Geometry.smallMetricDistance;\r\n if (c > radiusA + radiusB + e) // distance between circles is more than max distance\r\n return;\r\n // TODO: 1) intersection between arcs\r\n // 2) endpoints to endpoints\r\n this.testAndRecordFractionalPairApproach(cpA, 0, 1, false, cpB, 0, 1, false, reversed);\r\n // 3) line from one arc to another (perpendicular to arc tangents along center-center line)\r\n if (!Geometry.isSmallMetricDistance(c)) {\r\n const vectorAB = Vector3d.createStartEnd(cpA.center, cpB.center);\r\n vectorAB.scaleInPlace(1.0 / c);\r\n for (const rA of [-radiusA, radiusA]) {\r\n for (const rB of [-radiusB, radiusB]) {\r\n const tangentDistance = c - rA + rB;\r\n if (tangentDistance < e) {\r\n const detailA = this.resolveDirectionToArcXYFraction(cpA, vectorAB, rA);\r\n if (detailA) {\r\n const detailB = this.resolveDirectionToArcXYFraction(cpB, vectorAB, rB);\r\n if (detailB)\r\n this.captureDetailPair(detailA, detailB, reversed);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n /** Find the fractional point (if any) on the circular `arc` in the direction of `radialVector`. */\r\n private resolveDirectionToArcXYFraction(\r\n arc: Arc3d, radialVector: Vector3d, scale: number,\r\n ): CurveLocationDetail | undefined {\r\n // The scale ultimately only affects the direction --- easiest way to use it is two multiplies.\r\n const c = scale * arc.matrixRef.columnDotXYZ(0, radialVector.x, radialVector.y, 0);\r\n const s = scale * arc.matrixRef.columnDotXYZ(1, radialVector.x, radialVector.y, 0);\r\n const radians = Math.atan2(s, c);\r\n const fraction = arc.sweep.radiansToPositivePeriodicFraction(radians, 0);\r\n if (fraction < 1.0)\r\n return CurveLocationDetail.createCurveEvaluatedFraction(arc, fraction);\r\n return undefined;\r\n }\r\n /** Low level dispatch of arc with arc. Only circular arcs are supported. */\r\n private dispatchArcArc(cpA: Arc3d, cpB: Arc3d, reversed: boolean): void {\r\n const rangeA = cpA.range();\r\n const rangeB = cpB.range();\r\n rangeA.expandInPlace(this._maxDistanceToAccept!);\r\n if (!rangeB.intersectsRangeXY(rangeA))\r\n return;\r\n if (this._circularArcB) {\r\n const radiusB = this._circularRadiusB!;\r\n const radiusA = cpA.circularRadiusXY();\r\n if (radiusA !== undefined) {\r\n if (radiusA >= radiusB)\r\n this.dispatchCircularCircularOrdered(cpA, radiusA, cpB, radiusB, reversed);\r\n else\r\n this.dispatchCircularCircularOrdered(cpB, radiusB, cpA, radiusA, !reversed);\r\n return;\r\n }\r\n }\r\n }\r\n /** Low level dispatch of arc with (beziers of) a bspline curve */\r\n private dispatchArcBsplineCurve3d(cpA: Arc3d, cpB: BSplineCurve3d, reversed: boolean): void {\r\n const ls = LineString3d.create();\r\n cpB.emitStrokes(ls);\r\n this.computeArcLineString(cpA, ls, reversed);\r\n }\r\n /** Low level dispatch of (beziers of) a bspline curve with (beziers of) a bspline curve */\r\n private dispatchBSplineCurve3dBSplineCurve3d(\r\n bcurveA: BSplineCurve3dBase, bcurveB: BSplineCurve3dBase, reversed: boolean,\r\n ): void {\r\n const lsA = LineString3d.create();\r\n bcurveA.emitStrokes(lsA);\r\n const lsB = LineString3d.create();\r\n bcurveB.emitStrokes(lsB);\r\n this.computeLineStringLineString(lsA, lsB, reversed);\r\n }\r\n /** Low level dispatch of linestring with (beziers of) a bspline curve */\r\n public dispatchLineStringBSplineCurve(lsA: LineString3d, curveB: BSplineCurve3d, reversed: boolean): any {\r\n const lsB = LineString3d.create();\r\n curveB.emitStrokes(lsB);\r\n this.computeLineStringLineString(lsA, lsB, reversed);\r\n }\r\n /** Low level dispatch of segment with (beziers of) a bspline curve */\r\n public dispatchSegmentBsplineCurve(segA: LineSegment3d, curveB: BSplineCurve3d, reversed: boolean): any {\r\n const lsB = LineString3d.create();\r\n curveB.emitStrokes(lsB);\r\n this.computeSegmentLineString(segA, lsB, reversed);\r\n }\r\n /** Detail computation for segment approaching linestring. */\r\n public computeSegmentLineString(segA: LineSegment3d, lsB: LineString3d, reversed: boolean): void {\r\n const numB = lsB.numPoints();\r\n const deltaFracB = Geometry.safeDivideFraction(1, numB - 1, 0);\r\n const pointA0 = segA.point0Ref;\r\n const pointA1 = segA.point1Ref;\r\n const pointB0 = CurveCurveCloseApproachXY._workPointBB0;\r\n const pointB1 = CurveCurveCloseApproachXY._workPointBB1;\r\n for (let i = 0; i < numB - 1; ++i) {\r\n const fB0 = i * deltaFracB; // global linestring fractions\r\n const fB1 = (i + 1 === numB - 1) ? 1.0 : (i + 1) * deltaFracB; // make sure we nail the end fraction\r\n lsB.packedPoints.getPoint3dAtUncheckedPointIndex(i, pointB0);\r\n lsB.packedPoints.getPoint3dAtUncheckedPointIndex(i + 1, pointB1);\r\n this.dispatchSegmentSegment(segA, pointA0, 0.0, pointA1, 1.0, lsB, pointB0, fB0, pointB1, fB1, reversed);\r\n }\r\n }\r\n /** Detail computation for arc approaching linestring. */\r\n public computeArcLineString(arcA: Arc3d, lsB: LineString3d, reversed: boolean): any {\r\n const rangeA = arcA.range();\r\n const rangeB = lsB.range();\r\n rangeA.expandInPlace(this._maxDistanceToAccept!);\r\n if (!rangeB.intersectsRangeXY(rangeA))\r\n return;\r\n const pointB0 = CurveCurveCloseApproachXY._workPointBB0;\r\n const pointB1 = CurveCurveCloseApproachXY._workPointBB1;\r\n const numB = lsB.numPoints();\r\n if (numB > 1) {\r\n const dfB = 1.0 / (numB - 1);\r\n let fB0;\r\n let fB1;\r\n fB0 = 0.0;\r\n lsB.pointAt(0, pointB0);\r\n for (let ib = 1; ib < numB; ib++, pointB0.setFrom(pointB1), fB0 = fB1) {\r\n lsB.pointAt(ib, pointB1);\r\n fB1 = ib * dfB;\r\n this.dispatchSegmentArc(lsB, pointB0, fB0, pointB1, fB1, arcA, !reversed);\r\n }\r\n }\r\n return undefined;\r\n }\r\n /** Low level dispatch of curve collection. */\r\n private dispatchCurveCollection(geomA: AnyCurve, geomAHandler: (geomA: any) => any): void {\r\n const geomB = this._geometryB; // save\r\n if (!geomB || !geomB.children || !(geomB instanceof CurveCollection))\r\n return;\r\n for (const child of geomB.children) {\r\n this.resetGeometry(child);\r\n geomAHandler(geomA);\r\n }\r\n this._geometryB = geomB; // restore\r\n }\r\n /** Low level dispatch to geomA given a CurveChainWithDistanceIndex in geometryB. */\r\n private dispatchCurveChainWithDistanceIndex(geomA: AnyCurve, geomAHandler: (geomA: any) => any): void {\r\n if (!this._geometryB || !(this._geometryB instanceof CurveChainWithDistanceIndex))\r\n return;\r\n if (geomA instanceof CurveChainWithDistanceIndex) {\r\n assert(!!\"call handleCurveChainWithDistanceIndex(geomA) instead\");\r\n return;\r\n }\r\n const index0 = this._results.length;\r\n const geomB = this._geometryB; // save\r\n for (const child of geomB.path.children) {\r\n this.resetGeometry(child);\r\n geomAHandler(geomA);\r\n }\r\n this.resetGeometry(geomB); // restore\r\n this._results = CurveChainWithDistanceIndex.convertChildDetailToChainDetail(this._results, index0, undefined, geomB, true);\r\n }\r\n /** Double dispatch handler for strongly typed segment. */\r\n public override handleLineSegment3d(segmentA: LineSegment3d): any {\r\n if (this._geometryB instanceof LineSegment3d) {\r\n const segmentB = this._geometryB;\r\n this.dispatchSegmentSegment(\r\n segmentA, segmentA.point0Ref, 0.0, segmentA.point1Ref, 1.0,\r\n segmentB, segmentB.point0Ref, 0.0, segmentB.point1Ref, 1.0,\r\n false,\r\n );\r\n } else if (this._geometryB instanceof LineString3d) {\r\n this.computeSegmentLineString(segmentA, this._geometryB, false);\r\n } else if (this._geometryB instanceof Arc3d) {\r\n this.dispatchSegmentArc(segmentA, segmentA.point0Ref, 0.0, segmentA.point1Ref, 1.0, this._geometryB, false);\r\n } else if (this._geometryB instanceof BSplineCurve3d) {\r\n this.dispatchSegmentBsplineCurve(segmentA, this._geometryB, false);\r\n } else if (this._geometryB instanceof CurveCollection) {\r\n this.dispatchCurveCollection(segmentA, this.handleLineSegment3d.bind(this));\r\n } else if (this._geometryB instanceof CurveChainWithDistanceIndex) {\r\n this.dispatchCurveChainWithDistanceIndex(segmentA, this.handleLineSegment3d.bind(this));\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Set bits for comparison to range xy\r\n * * bit 0x01 => x smaller than range.low.x\r\n * * bit 0x02 => x larger than range.high.x\r\n * * bit 0x04 => y smaller than range.low.y\r\n * * bit 0x08 => y larger than range.high.y\r\n * * If we divide XY plane into 9 areas using the range, the function returns 0 for points\r\n * inside the range. Below is other binary numbers returned by the function for all 9 areas:\r\n * 1001 | 1000 | 1010\r\n * ------------------\r\n * 1 | 0 | 10\r\n * ------------------\r\n * 101 | 100 | 110\r\n * @param xy point to test\r\n * @param range range for comparison\r\n */\r\n private classifyBitsPointRangeXY(x: number, y: number, range: Range3d): number {\r\n let result = 0;\r\n if (x < range.low.x)\r\n result = 0x01;\r\n else if (x > range.high.x)\r\n result = 0x02;\r\n // note the OR operation\r\n if (y < range.low.y)\r\n result |= 0x04;\r\n else if (y > range.high.y)\r\n result |= 0x08;\r\n return result;\r\n }\r\n /** Low level dispatch of line string with line string. */\r\n private computeLineStringLineString(lsA: LineString3d, lsB: LineString3d, reversed: boolean): void {\r\n const rangeA = lsA.range();\r\n const rangeB = lsB.range();\r\n rangeA.expandInPlace(this._maxDistanceToAccept!);\r\n if (!rangeB.intersectsRangeXY(rangeA))\r\n return;\r\n let bitB0: number;\r\n let bitB1: number;\r\n const rangeA1 = Range3d.createNull();\r\n const pointA0 = CurveCurveCloseApproachXY._workPointAA0;\r\n const pointA1 = CurveCurveCloseApproachXY._workPointAA1;\r\n const pointB0 = CurveCurveCloseApproachXY._workPointBB0;\r\n const pointB1 = CurveCurveCloseApproachXY._workPointBB1;\r\n const numA = lsA.numPoints();\r\n const numB = lsB.numPoints();\r\n if (numA > 1 && numB > 1) {\r\n const dfA = 1.0 / (numA - 1);\r\n const dfB = 1.0 / (numB - 1);\r\n let fA0 = 0.0;\r\n let fA1, fB0, fB1;\r\n lsA.pointAt(0, pointA0);\r\n for (let ia = 1; ia < numA; ia++, pointA0.setFrom(pointA1), fA0 = fA1) {\r\n fA1 = ia * dfA;\r\n fB0 = 0.0;\r\n lsA.pointAt(ia, pointA1);\r\n // rangeA1 is around line segment [A0,A1] expanded by max distance\r\n rangeA1.setNull();\r\n rangeA1.extendPoint(pointA0);\r\n rangeA1.extendPoint(pointA1);\r\n rangeA1.expandInPlace(this._maxDistanceToAccept!);\r\n if (rangeA1.intersectsRangeXY(rangeB)) {\r\n lsB.pointAt(0, pointB0);\r\n bitB0 = this.classifyBitsPointRangeXY(pointB0.x, pointB0.y, rangeA1);\r\n for (let ib = 1; ib < numB; ib++, pointB0.setFrom(pointB1), fB0 = fB1, bitB0 = bitB1) {\r\n lsB.pointAt(ib, pointB1);\r\n bitB1 = this.classifyBitsPointRangeXY(pointB1.x, pointB1.y, rangeA1);\r\n fB1 = ib * dfB;\r\n // DO NOT study the segment in detail if both bitB bits are on for any of the 4 planes\r\n // (i.e., no intersection between rangeA1 and the range around line segment [B0,B1])\r\n if ((bitB0 & bitB1) === 0)\r\n this.dispatchSegmentSegment(lsA, pointA0, fA0, pointA1, fA1, lsB, pointB0, fB0, pointB1, fB1, reversed);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n /** Double dispatch handler for strongly typed linestring. */\r\n public override handleLineString3d(lsA: LineString3d): any {\r\n if (this._geometryB instanceof LineString3d) {\r\n const lsB = this._geometryB;\r\n this.computeLineStringLineString(lsA, lsB, false);\r\n } else if (this._geometryB instanceof LineSegment3d) {\r\n this.computeSegmentLineString(this._geometryB, lsA, true);\r\n } else if (this._geometryB instanceof Arc3d) {\r\n this.computeArcLineString(this._geometryB, lsA, true);\r\n } else if (this._geometryB instanceof BSplineCurve3d) {\r\n this.dispatchLineStringBSplineCurve(lsA, this._geometryB, false);\r\n } else if (this._geometryB instanceof CurveCollection) {\r\n this.dispatchCurveCollection(lsA, this.handleLineString3d.bind(this));\r\n } else if (this._geometryB instanceof CurveChainWithDistanceIndex) {\r\n this.dispatchCurveChainWithDistanceIndex(lsA, this.handleLineString3d.bind(this));\r\n }\r\n return undefined;\r\n }\r\n /** Double dispatch handler for strongly typed arc. */\r\n public override handleArc3d(arc0: Arc3d): any {\r\n if (this._geometryB instanceof LineSegment3d) {\r\n this.dispatchSegmentArc(\r\n this._geometryB, this._geometryB.point0Ref, 0.0, this._geometryB.point1Ref, 1.0, arc0, true,\r\n );\r\n } else if (this._geometryB instanceof LineString3d) {\r\n this.computeArcLineString(arc0, this._geometryB, false);\r\n } else if (this._geometryB instanceof Arc3d) {\r\n this.dispatchArcArc(arc0, this._geometryB, false);\r\n } else if (this._geometryB instanceof BSplineCurve3d) {\r\n this.dispatchArcBsplineCurve3d(arc0, this._geometryB, false);\r\n } else if (this._geometryB instanceof CurveCollection) {\r\n this.dispatchCurveCollection(arc0, this.handleArc3d.bind(this));\r\n } else if (this._geometryB instanceof CurveChainWithDistanceIndex) {\r\n this.dispatchCurveChainWithDistanceIndex(arc0, this.handleArc3d.bind(this));\r\n }\r\n return undefined;\r\n }\r\n /** Double dispatch handler for strongly typed bspline curve. */\r\n public override handleBSplineCurve3d(curve: BSplineCurve3d): any {\r\n if (this._geometryB instanceof LineSegment3d) {\r\n this.dispatchSegmentBsplineCurve(this._geometryB, curve, true);\r\n } else if (this._geometryB instanceof LineString3d) {\r\n this.dispatchLineStringBSplineCurve(this._geometryB, curve, true);\r\n } else if (this._geometryB instanceof Arc3d) {\r\n this.dispatchArcBsplineCurve3d(this._geometryB, curve, true);\r\n } else if (this._geometryB instanceof BSplineCurve3dBase) {\r\n this.dispatchBSplineCurve3dBSplineCurve3d(curve, this._geometryB, false);\r\n } else if (this._geometryB instanceof CurveCollection) {\r\n this.dispatchCurveCollection(curve, this.handleBSplineCurve3d.bind(this));\r\n } else if (this._geometryB instanceof CurveChainWithDistanceIndex) {\r\n this.dispatchCurveChainWithDistanceIndex(curve, this.handleBSplineCurve3d.bind(this));\r\n }\r\n return undefined;\r\n }\r\n /** Double dispatch handler for strongly typed CurveChainWithDistanceIndex. */\r\n public override handleCurveChainWithDistanceIndex(chain: CurveChainWithDistanceIndex): any {\r\n super.handleCurveChainWithDistanceIndex(chain);\r\n // if _geometryB is also a CurveChainWithDistanceIndex, it will already have been converted by dispatchCurveChainWithDistanceIndex\r\n this._results = CurveChainWithDistanceIndex.convertChildDetailToChainDetail(this._results, 0, chain, undefined, true);\r\n }\r\n /** Double dispatch handler for strongly typed homogeneous bspline curve .. */\r\n public override handleBSplineCurve3dH(_curve: BSplineCurve3dH): any {\r\n /*\r\n //NEEDS WORK -- make \"dispatch\" methods tolerant of both 3d and 3dH.\r\n // \"easy\" if both present BezierCurve3dH span loaders\r\n if (this._geometryB instanceof LineSegment3d) {\r\n this.dispatchSegmentBsplineCurve(\r\n this._geometryB, this._extendB, this._geometryB.point0Ref, 0.0, this._geometryB.point1Ref, 1.0, this._extendB,\r\n curve, this._extendA, true);\r\n } else if (this._geometryB instanceof LineString3d) {\r\n this.dispatchLineStringBSplineCurve(this._geometryB, this._extendB, curve, this._extendA, true);\r\n } else if (this._geometryB instanceof Arc3d) {\r\n this.dispatchArcBsplineCurve3d(this._geometryB, this._extendB, curve, this._extendA, true);\r\n }\r\n */\r\n return undefined;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"CurveCurveCloseApproachXY.js","sourceRoot":"","sources":["../../../../src/curve/internalContexts/CurveCurveCloseApproachXY.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,sDAA6C;AAC7C,6DAAgF;AAEhF,6CAA0C;AAC1C,sEAAkF;AAClF,gFAA6E;AAC7E,sEAA2D;AAC3D,kDAAiD;AACjD,kDAG+B;AAC/B,4DAAwE;AACxE,oCAAiC;AACjC,gFAA6E;AAC7E,wDAAqD;AACrD,gEAAyG;AAGzG,oDAAiD;AACjD,kDAA+C;AAE/C,+BAA+B;AAE/B;;;;;;;;;;;;;GAaG;AACH,MAAa,yBAA0B,SAAQ,gDAA8B;IAInE,YAAY,CAAC,SAA+B;QAClD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;QAC/B,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;QAClC,IAAI,SAAS,YAAY,aAAK,EAAE;YAC9B,MAAM,CAAC,GAAG,SAAS,CAAC,gBAAgB,EAAE,CAAC;YACvC,IAAI,CAAC,KAAK,SAAS,EAAE;gBACnB,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;gBAC1B,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;aAChC;SACF;IACH,CAAC;IAoBD;;;OAGG;IACH,YAAmB,SAA+B;QAChD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC7B,IAAI,CAAC,mBAAmB,GAAG,mBAAQ,CAAC,0BAA0B,CAAC;QAC/D,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACrB,CAAC;IACD,6EAA6E;IAC7E,IAAW,mBAAmB,CAAC,KAAyB;QACtD,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;QAClC,IAAI,IAAI,CAAC,oBAAoB,KAAK,SAAS,IAAI,IAAI,CAAC,oBAAoB,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ACjC,qCAAW,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;AAjCnC,8DAAyB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { BSplineCurve3d, BSplineCurve3dBase } from \"../../bspline/BSplineCurve\";\r\nimport { BSplineCurve3dH } from \"../../bspline/BSplineCurve3dH\";\r\nimport { Geometry } from \"../../Geometry\";\r\nimport { RecurseToCurvesGeometryHandler } from \"../../geometry3d/GeometryHandler\";\r\nimport { GrowableFloat64Array } from \"../../geometry3d/GrowableFloat64Array\";\r\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\r\nimport { Range3d } from \"../../geometry3d/Range\";\r\nimport {\r\n CurveCurveCloseApproachXYRRtoRRD, CurvePointCloseApproachXYRtoRD,\r\n Newton1dUnbounded, Newton2dUnboundedWithDerivative, NewtonEvaluatorRRtoRRD,\r\n} from \"../../numerics/Newton\";\r\nimport { AnalyticRoots, SmallSystem } from \"../../numerics/Polynomials\";\r\nimport { Arc3d } from \"../Arc3d\";\r\nimport { CurveChainWithDistanceIndex } from \"../CurveChainWithDistanceIndex\";\r\nimport { CurveCollection } from \"../CurveCollection\";\r\nimport { CurveIntervalRole, CurveLocationDetail, CurveLocationDetailPair } from \"../CurveLocationDetail\";\r\nimport { CurvePrimitive } from \"../CurvePrimitive\";\r\nimport { AnyCurve } from \"../CurveTypes\";\r\nimport { LineSegment3d } from \"../LineSegment3d\";\r\nimport { LineString3d } from \"../LineString3d\";\r\n\r\n// cspell:word XYRR currentdFdX\r\n\r\n/**\r\n * Handler class for XY close approach between _geometryB and another geometry.\r\n * * Approach means the XY distance (z is ignored) between _geometryB and another geometry.\r\n * * Closest approach is a measure of the proximity of one curve to another. It's the length of the shortest line\r\n * segment perpendicular to both curves; if the curves intersect, the closest approach is zero. In the context of\r\n * this class, z-coordinates are ignored, so the closest approach is as seen in the top view. If you have coplanar\r\n * input curves and want to find closest approach in their plane, rotate them first into a plane parallel to the\r\n * xy-plane, then afterward, rotate the results back as required.\r\n * * Close approach can also be from a curve endpoint perpendicular to another curve or from a curve endpoint to\r\n * another curve endpoint.\r\n * * Instances are initialized and called from CurveCurve.\r\n * * geometryB is saved for later reference.\r\n * @internal\r\n */\r\nexport class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {\r\n private _geometryB: AnyCurve | undefined;\r\n private _circularArcB: Arc3d | undefined;\r\n private _circularRadiusB: number | undefined;\r\n private setGeometryB(geometryB: AnyCurve | undefined) {\r\n this._geometryB = geometryB;\r\n this._circularArcB = undefined;\r\n this._circularRadiusB = undefined;\r\n if (geometryB instanceof Arc3d) {\r\n const r = geometryB.circularRadiusXY();\r\n if (r !== undefined) {\r\n this._circularRadiusB = r;\r\n this._circularArcB = geometryB;\r\n }\r\n }\r\n }\r\n /**\r\n * Maximum XY distance (z is ignored). Approach larger than this is not interesting.\r\n * This is caller defined and can be undefined.\r\n */\r\n private _maxDistanceToAccept: number | undefined;\r\n /** Squared max distance. This is private, and is forced to at least small metric distance squared. */\r\n private _maxDistanceSquared: number;\r\n /**\r\n * Start and end points of line segments that meet closest approach criteria, i.e., they are perpendicular to\r\n * both curves and their length is smaller than _maxDistanceToAccept.\r\n */\r\n private _results: CurveLocationDetailPair[];\r\n\r\n private static _workPointAA0 = Point3d.create();\r\n private static _workPointAA1 = Point3d.create();\r\n private static _workPointBB0 = Point3d.create();\r\n private static _workPointBB1 = Point3d.create();\r\n private static _workPointB = Point3d.create();\r\n\r\n /**\r\n * Constructor.\r\n * @param geometryB second curve for intersection. Saved for reference by specific handler methods.\r\n */\r\n public constructor(geometryB: AnyCurve | undefined) {\r\n super();\r\n this.setGeometryB(geometryB);\r\n this._maxDistanceSquared = Geometry.smallMetricDistanceSquared;\r\n this._results = [];\r\n }\r\n /** Set the (possibly undefined) max XY distance (z is ignored) to accept. */\r\n public set maxDistanceToAccept(value: number | undefined) {\r\n this._maxDistanceToAccept = value;\r\n if (this._maxDistanceToAccept !== undefined && this._maxDistanceToAccept > 0)\r\n this._maxDistanceSquared = this._maxDistanceToAccept * this._maxDistanceToAccept;\r\n }\r\n /** Access the (possibly undefined) max XY distance (z is ignored) to accept. */\r\n public get maxDistanceToAccept(): number | undefined {\r\n return this._maxDistanceToAccept;\r\n }\r\n /** Ask if the maxDistanceToAccept value is defined and positive */\r\n public get isMaxDistanceSet(): boolean {\r\n return this._maxDistanceToAccept !== undefined && this._maxDistanceToAccept > 0;\r\n }\r\n /** Reset the geometry and flags, leaving all other parts unchanged (and preserving accumulated intersections) */\r\n public resetGeometry(geometryB: AnyCurve) {\r\n this.setGeometryB(geometryB);\r\n }\r\n /** returns true if `fraction` is in [0,1] within tolerance */\r\n private acceptFraction(fraction: number, fractionTol: number = 1.0e-12) {\r\n if (fraction < -fractionTol)\r\n return false;\r\n if (fraction > 1.0 + fractionTol)\r\n return false;\r\n return true;\r\n }\r\n /**\r\n * Return the results structure for the intersection calculation, structured as an array of CurveLocationDetailPair.\r\n * @param reinitialize if true, a new results structure is created for use by later calls.\r\n */\r\n public grabPairedResults(reinitialize: boolean = false): CurveLocationDetailPair[] {\r\n const result = this._results;\r\n if (reinitialize)\r\n this._results = [];\r\n return result;\r\n }\r\n /**\r\n * If distance between pointA and pointB is less than maxDistance, record CurveLocationDetailPair which is\r\n * the approach from pointA to pointB.\r\n */\r\n private testAndRecordPointPairApproach(\r\n cpA: CurvePrimitive, fA: number, pointA: Point3d, cpB: CurvePrimitive, fB: number, pointB: Point3d, reversed: boolean,\r\n ): void {\r\n const d2 = pointA.distanceSquaredXY(pointB);\r\n if (d2 < this._maxDistanceSquared) {\r\n const detailA = CurveLocationDetail.createCurveFractionPoint(cpA, fA, pointA);\r\n const detailB = CurveLocationDetail.createCurveFractionPoint(cpB, fB, pointB);\r\n const pair = CurveLocationDetailPair.createCapture(detailA, detailB);\r\n if (reversed)\r\n pair.swapDetails();\r\n this._results.push(pair);\r\n }\r\n }\r\n /**\r\n * Create a close approach pair if XY distance is within maxDistance.\r\n * @param localFractionA a fraction on first curve\r\n * @param cpA the first curve\r\n * @param fractionA0 start of the first curve\r\n * @param fractionA1 end of the first curve\r\n * @param localFractionB a fraction on second curve\r\n * @param cpB the second curve\r\n * @param fractionB0 start of the second curve\r\n * @param fractionB1 end of the second curve\r\n * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).\r\n * @param intervalDetails optional CurveLocationDetailPair\r\n */\r\n private recordPointWithLocalFractions(\r\n localFractionA: number,\r\n cpA: CurvePrimitive,\r\n fractionA0: number,\r\n fractionA1: number,\r\n localFractionB: number,\r\n cpB: CurvePrimitive,\r\n fractionB0: number,\r\n fractionB1: number,\r\n reversed: boolean,\r\n intervalDetails?: undefined | CurveLocationDetailPair,\r\n ): void {\r\n let globalFractionA, globalFractionB;\r\n let globalFractionA1, globalFractionB1;\r\n const isInterval = intervalDetails !== undefined &&\r\n intervalDetails.detailA.hasFraction1 &&\r\n intervalDetails.detailB.hasFraction1;\r\n if (isInterval) {\r\n globalFractionA = Geometry.interpolate(fractionA0, intervalDetails.detailA.fraction, fractionA1);\r\n globalFractionB = Geometry.interpolate(fractionB0, intervalDetails.detailB.fraction, fractionB1);\r\n globalFractionA1 = Geometry.interpolate(fractionA0, intervalDetails.detailA.fraction1!, fractionA1);\r\n globalFractionB1 = Geometry.interpolate(fractionB0, intervalDetails.detailB.fraction1!, fractionB1);\r\n } else {\r\n globalFractionA = globalFractionA1 = Geometry.interpolate(fractionA0, localFractionA, fractionA1);\r\n globalFractionB = globalFractionB1 = Geometry.interpolate(fractionB0, localFractionB, fractionB1);\r\n }\r\n // ignore duplicate of most recent approach\r\n const numPrevious = this._results.length;\r\n if (numPrevious > 0 && !isInterval) {\r\n const oldDetailA = this._results[numPrevious - 1].detailA;\r\n const oldDetailB = this._results[numPrevious - 1].detailB;\r\n if (reversed) {\r\n if (oldDetailB.isSameCurveAndFraction({ curve: cpA, fraction: globalFractionA }) &&\r\n oldDetailA.isSameCurveAndFraction({ curve: cpB, fraction: globalFractionB }))\r\n return;\r\n } else {\r\n if (oldDetailA.isSameCurveAndFraction({ curve: cpA, fraction: globalFractionA }) &&\r\n oldDetailB.isSameCurveAndFraction({ curve: cpB, fraction: globalFractionB }))\r\n return;\r\n }\r\n }\r\n const detailA = CurveLocationDetail.createCurveFractionPoint(\r\n cpA, globalFractionA, cpA.fractionToPoint(globalFractionA),\r\n );\r\n const detailB = CurveLocationDetail.createCurveFractionPoint(\r\n cpB, globalFractionB, cpB.fractionToPoint(globalFractionB),\r\n );\r\n if (isInterval) {\r\n detailA.captureFraction1Point1(globalFractionA1, cpA.fractionToPoint(globalFractionA1));\r\n detailB.captureFraction1Point1(globalFractionB1, cpB.fractionToPoint(globalFractionB1));\r\n } else {\r\n const d2 = detailA.point.distanceSquaredXY(detailB.point);\r\n if (d2 > this._maxDistanceSquared)\r\n return;\r\n detailA.setIntervalRole(CurveIntervalRole.isolated);\r\n detailB.setIntervalRole(CurveIntervalRole.isolated);\r\n }\r\n if (reversed) {\r\n this._results.push(new CurveLocationDetailPair(detailB, detailA));\r\n } else {\r\n this._results.push(new CurveLocationDetailPair(detailA, detailB));\r\n }\r\n }\r\n /**\r\n * Capture a close approach pair that has point and local fraction but not curve.\r\n * * Record the pair, each detail modified with global fraction and input curve.\r\n * * Pair is neither modified nor recorded if it would be a duplicate of the last recorded pair.\r\n * @param pair details computed with local fractions\r\n * @param cpA curveA\r\n * @param fractionA0 global start fraction on curveA\r\n * @param fractionA1 global end fraction on curveA\r\n * @param cpB curveB\r\n * @param fractionB0 global start fraction on curveB\r\n * @param fractionB1 global end fraction on curveB\r\n * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).\r\n */\r\n private capturePairWithLocalFractions(\r\n pair: CurveLocationDetailPair,\r\n cpA: CurvePrimitive,\r\n fractionA0: number,\r\n fractionA1: number,\r\n cpB: CurvePrimitive,\r\n fractionB0: number,\r\n fractionB1: number,\r\n reversed: boolean,\r\n ) {\r\n const globalFractionA = Geometry.interpolate(fractionA0, pair.detailA.fraction, fractionA1);\r\n const globalFractionB = Geometry.interpolate(fractionB0, pair.detailB.fraction, fractionB1);\r\n // ignore duplicate of most recent pair\r\n const numPrevious = this._results.length;\r\n if (numPrevious > 0) {\r\n const oldDetailA = this._results[numPrevious - 1].detailA;\r\n const oldDetailB = this._results[numPrevious - 1].detailB;\r\n if (reversed) {\r\n if (oldDetailB.isSameCurveAndFraction({ curve: cpA, fraction: globalFractionA }) &&\r\n oldDetailA.isSameCurveAndFraction({ curve: cpB, fraction: globalFractionB }))\r\n return;\r\n } else {\r\n if (oldDetailA.isSameCurveAndFraction({ curve: cpA, fraction: globalFractionA }) &&\r\n oldDetailB.isSameCurveAndFraction({ curve: cpB, fraction: globalFractionB }))\r\n return;\r\n }\r\n }\r\n // recompute the points just in case\r\n CurveLocationDetail.createCurveEvaluatedFraction(cpA, globalFractionA, pair.detailA);\r\n CurveLocationDetail.createCurveEvaluatedFraction(cpB, globalFractionB, pair.detailB);\r\n pair.detailA.setIntervalRole(CurveIntervalRole.isolated);\r\n pair.detailB.setIntervalRole(CurveIntervalRole.isolated);\r\n if (reversed)\r\n pair.swapDetails();\r\n this._results.push(pair);\r\n }\r\n /**\r\n * Emit recordPoint for multiple pairs (on full curve) if within maxDistance.\r\n * @param cpA first curve primitive (possibly different from curve in detailA, but fraction compatible)\r\n * @param cpB second curve primitive (possibly different from curve in detailA, but fraction compatible)\r\n * @param pairs array of pairs\r\n * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).\r\n */\r\n public recordPairs(\r\n cpA: CurvePrimitive, cpB: CurvePrimitive, pairs: CurveLocationDetailPair[] | undefined, reversed: boolean,\r\n ): void {\r\n if (pairs !== undefined) {\r\n for (const p of pairs) {\r\n this.recordPointWithLocalFractions(\r\n p.detailA.fraction, cpA, 0, 1, p.detailB.fraction, cpB, 0, 1, reversed, p,\r\n );\r\n }\r\n }\r\n }\r\n /**\r\n * Record fully assembled (but possibly reversed) detail pair.\r\n * @param detailA first detail\r\n * @param detailB second detail\r\n * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).\r\n */\r\n public captureDetailPair(\r\n detailA: CurveLocationDetail | undefined, detailB: CurveLocationDetail | undefined, reversed: boolean,\r\n ): void {\r\n if (detailA && detailB) {\r\n if (reversed) {\r\n this._results.push(CurveLocationDetailPair.createCapture(detailB, detailA));\r\n } else {\r\n this._results.push(CurveLocationDetailPair.createCapture(detailA, detailB));\r\n }\r\n }\r\n }\r\n private static updatePointToSegmentDistance(\r\n fractionA: number,\r\n pointA: Point3d,\r\n pointB0: Point3d,\r\n pointB1: Point3d,\r\n fractionB: number,\r\n maxDistanceSquared: number,\r\n closestApproach: CurveLocationDetailPair, // modified on return\r\n ): boolean {\r\n let updated = false;\r\n if (fractionB < 0)\r\n fractionB = 0;\r\n else if (fractionB > 1)\r\n fractionB = 1;\r\n this._workPointB = pointB0.interpolate(fractionB, pointB1, this._workPointB);\r\n const distanceSquared = this._workPointB.distanceSquaredXY(pointA);\r\n if (distanceSquared <= Math.min(maxDistanceSquared, closestApproach.detailA.a)) {\r\n closestApproach.detailA.setFP(fractionA, pointA, undefined, distanceSquared);\r\n closestApproach.detailB.setFP(fractionB, this._workPointB, undefined, distanceSquared);\r\n updated = true;\r\n }\r\n return updated;\r\n }\r\n /**\r\n * Return fractions of close approach within maxDistance between two line segments (a0,a1) and (b0,b1).\r\n * * Math details can be found at core/geometry/internaldocs/Curve.md\r\n * @param a0 start point of line a\r\n * @param a1 end point of line a\r\n * @param b0 start point of line b\r\n * @param b1 end point of line b\r\n * @param maxDistanceSquared maximum distance squared (assumed to be positive)\r\n * @returns the fractional (not xy) coordinates in result.x and result.y. result.x is fraction on line a.\r\n * result.y is fraction on line b.\r\n */\r\n private static segmentSegmentBoundedApproach(\r\n a0: Point3d,\r\n a1: Point3d,\r\n b0: Point3d,\r\n b1: Point3d,\r\n maxDistanceSquared: number,\r\n ): CurveLocationDetailPair | undefined {\r\n const ux = a1.x - a0.x;\r\n const uy = a1.y - a0.y;\r\n const vx = b1.x - b0.x;\r\n const vy = b1.y - b0.y;\r\n const e00x = b0.x - a0.x;\r\n const e00y = b0.y - a0.y;\r\n const e01x = b1.x - a0.x;\r\n const e01y = b1.y - a0.y;\r\n const e10x = b0.x - a1.x;\r\n const e10y = b0.y - a1.y;\r\n const hab0 = Geometry.crossProductXYXY(ux, uy, e00x, e00y);\r\n const hab1 = Geometry.crossProductXYXY(ux, uy, e01x, e01y);\r\n const hba0 = -Geometry.crossProductXYXY(vx, vy, e00x, e00y);\r\n const hba1 = -Geometry.crossProductXYXY(vx, vy, e10x, e10y);\r\n if (hab0 * hab1 < 0.0 && hba0 * hba1 < 0.0) { // true intersection, strictly within both segments\r\n const fractionA = -hba0 / (hba1 - hba0);\r\n const fractionB = -hab0 / (hab1 - hab0);\r\n return CurveLocationDetailPair.createCapture(\r\n CurveLocationDetail.createCurveFractionPoint(undefined, fractionA, a0.interpolate(fractionA, a1)),\r\n CurveLocationDetail.createCurveFractionPoint(undefined, fractionB, b0.interpolate(fractionB, b1)),\r\n );\r\n }\r\n // there's no intersection, so find the closest approach within maxDistance from an endpoint\r\n const closestApproach = new CurveLocationDetailPair();\r\n closestApproach.detailA.a = 2 * maxDistanceSquared; // init to an approach that's too far away\r\n let reversed = false;\r\n const uu = Geometry.hypotenuseSquaredXY(ux, uy);\r\n if (hab0 * hab0 <= maxDistanceSquared * uu) { // test distance of b0 to u\r\n const fractionA = Geometry.dotProductXYXY(ux, uy, e00x, e00y) / uu;\r\n if (this.updatePointToSegmentDistance(0, b0, a0, a1, fractionA, maxDistanceSquared, closestApproach))\r\n reversed = true;\r\n }\r\n if (hab1 * hab1 <= maxDistanceSquared * uu) { // test distance of b1 to u\r\n const fractionA = Geometry.dotProductXYXY(ux, uy, e01x, e01y) / uu;\r\n if (this.updatePointToSegmentDistance(1, b1, a0, a1, fractionA, maxDistanceSquared, closestApproach))\r\n reversed = true;\r\n }\r\n const vv = Geometry.hypotenuseSquaredXY(vx, vy);\r\n if (hba0 * hba0 <= maxDistanceSquared * vv) { // test distance of a0 to v\r\n const fractionB = -Geometry.dotProductXYXY(vx, vy, e00x, e00y) / vv;\r\n if (this.updatePointToSegmentDistance(0, a0, b0, b1, fractionB, maxDistanceSquared, closestApproach))\r\n reversed = false;\r\n }\r\n if (hba1 * hba1 <= maxDistanceSquared * vv) { // test distance of a1 to v\r\n const fractionB = -Geometry.dotProductXYXY(vx, vy, e10x, e10y) / vv;\r\n if (this.updatePointToSegmentDistance(1, a1, b0, b1, fractionB, maxDistanceSquared, closestApproach))\r\n reversed = false;\r\n }\r\n if (closestApproach.detailA.a > maxDistanceSquared)\r\n return undefined;\r\n if (reversed)\r\n closestApproach.swapDetails();\r\n return closestApproach;\r\n }\r\n /**\r\n * Check different combination of fractions on curveA and curveB. If distance between points at 2 fractions\r\n * is less than maxDistance, record CurveLocationDetailPair which is the approach between the 2 points.\r\n * Optionally, record close approaches of one curve's points if they fall between the other curve's points.\r\n * @param cpA curveA\r\n * @param fA0 fraction0 on curveA\r\n * @param fA1 fraction1 on curveA\r\n * @param testProjectionOnA whether to record projections of the given curveB points onto curveA\r\n * @param cpB curveB\r\n * @param fB0 fraction0 on curveB\r\n * @param fB1 fraction0 on curveB\r\n * @param testProjectionOnB whether to record projections of the given curveA points onto curveB\r\n * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).\r\n */\r\n private testAndRecordFractionalPairApproach(\r\n cpA: CurvePrimitive,\r\n fA0: number,\r\n fA1: number,\r\n testProjectionOnA: boolean,\r\n cpB: CurvePrimitive,\r\n fB0: number,\r\n fB1: number,\r\n testProjectionOnB: boolean,\r\n reversed: boolean,\r\n ): void {\r\n const pointA0 = cpA.fractionToPoint(fA0);\r\n const pointA1 = cpA.fractionToPoint(fA1);\r\n const pointB0 = cpB.fractionToPoint(fB0);\r\n const pointB1 = cpB.fractionToPoint(fB1);\r\n this.testAndRecordPointPairApproach(cpA, fA0, pointA0, cpB, fB0, pointB0, reversed);\r\n this.testAndRecordPointPairApproach(cpA, fA1, pointA1, cpB, fB0, pointB0, reversed);\r\n this.testAndRecordPointPairApproach(cpA, fA0, pointA0, cpB, fB1, pointB1, reversed);\r\n this.testAndRecordPointPairApproach(cpA, fA1, pointA1, cpB, fB1, pointB1, reversed);\r\n if (testProjectionOnB) {\r\n this.testAndRecordProjection(cpA, fA0, pointA0, cpB, fB0, fB1, reversed);\r\n this.testAndRecordProjection(cpA, fA1, pointA1, cpB, fB0, fB1, reversed);\r\n }\r\n if (testProjectionOnA) {\r\n this.testAndRecordProjection(cpB, fB0, pointB0, cpA, fA0, fA1, !reversed);\r\n this.testAndRecordProjection(cpB, fB1, pointB1, cpA, fA0, fA1, !reversed);\r\n }\r\n }\r\n /**\r\n * Return XY closest approach between a curve primitive and a point.\r\n * Currently, this function only supports Arc3d and LineSegment.\r\n * Note that this function doesn't handle endpoints.\r\n */\r\n private getPointCurveClosestApproachXYNewton(curveP: CurvePrimitive, pointQ: Point3d): CurveLocationDetail | undefined {\r\n if (!(curveP instanceof Arc3d) && !(curveP instanceof LineSegment3d)) {\r\n assert(!!\"getPointCurveClosestApproachXYNewton only supports Arc3d and LineSegment\");\r\n return undefined;\r\n }\r\n const seeds = [0.2, 0.4, 0.6, 0.8]; // HEURISTIC: arcs have up to 4 perpendiculars; lines have only 1\r\n const newtonEvaluator = new CurvePointCloseApproachXYRtoRD(curveP, pointQ);\r\n const newtonSearcher = new Newton1dUnbounded(newtonEvaluator);\r\n let minCloseApproachLength = Geometry.largeCoordinateResult;\r\n let minCurvePFraction: number | undefined;\r\n let minPointP: Point3d | undefined;\r\n for (const seed of seeds) {\r\n newtonSearcher.setX(seed);\r\n if (newtonSearcher.runIterations()) {\r\n const curvePFraction = newtonSearcher.getX();\r\n if (this.acceptFraction(curvePFraction)) {\r\n const pointP = curveP.fractionToPoint(curvePFraction);\r\n const closeApproachLength = pointP.distanceSquaredXY(pointQ);\r\n if (closeApproachLength < minCloseApproachLength) {\r\n minCloseApproachLength = closeApproachLength;\r\n minCurvePFraction = curvePFraction;\r\n minPointP = pointP;\r\n }\r\n }\r\n }\r\n }\r\n if (minCurvePFraction && minPointP)\r\n return CurveLocationDetail.createCurveFractionPoint(curveP, minCurvePFraction, minPointP);\r\n return undefined;\r\n }\r\n /** Find the closest approach between pointA and cpB. Add the approach if it's within fB0 and fB1. */\r\n private testAndRecordProjection(\r\n cpA: CurvePrimitive, fA: number, pointA: Point3d, cpB: CurvePrimitive, fB0: number, fB1: number, reversed: boolean,\r\n ) {\r\n const detail = this.getPointCurveClosestApproachXYNewton(cpB, pointA);\r\n if (detail) {\r\n const fB = Geometry.restrictToInterval(detail.fraction, fB0, fB1);\r\n if (fB === detail.fraction) { // if fraction is within fB0 and fB1\r\n this.testAndRecordPointPairApproach(cpA, fA, pointA, cpB, detail.fraction, detail.point, reversed);\r\n }\r\n }\r\n }\r\n /**\r\n * Compute intersection of two line segments.\r\n * Filter by extension rules.\r\n * Record with fraction mapping.\r\n * * The fraction mappings allow portions of a linestring to be passed here.\r\n */\r\n private computeSegmentSegment3D(\r\n cpA: CurvePrimitive,\r\n pointA0: Point3d,\r\n fractionA0: number,\r\n pointA1: Point3d,\r\n fractionA1: number,\r\n cpB: CurvePrimitive,\r\n pointB0: Point3d,\r\n fractionB0: number,\r\n pointB1: Point3d,\r\n fractionB1: number,\r\n reversed: boolean,\r\n ): void {\r\n // compute a pair with fractions local to segments\r\n const approach = CurveCurveCloseApproachXY.segmentSegmentBoundedApproach(\r\n pointA0, pointA1, pointB0, pointB1, this._maxDistanceSquared,\r\n );\r\n // adjust the pair to refer to input curves and global fractions, then record it if new\r\n if (approach) {\r\n approach.detailA.setCurve(cpA);\r\n approach.detailB.setCurve(cpB);\r\n this.capturePairWithLocalFractions(approach, cpA, fractionA0, fractionA1, cpB, fractionB0, fractionB1, reversed);\r\n }\r\n }\r\n /** Low level dispatch of segment with segment. */\r\n private dispatchSegmentSegment(\r\n cpA: CurvePrimitive,\r\n pointA0: Point3d,\r\n fractionA0: number,\r\n pointA1: Point3d,\r\n fractionA1: number,\r\n cpB: CurvePrimitive,\r\n pointB0: Point3d,\r\n fractionB0: number,\r\n pointB1: Point3d,\r\n fractionB1: number,\r\n reversed: boolean,\r\n ): void {\r\n this.computeSegmentSegment3D(\r\n cpA, pointA0, fractionA0, pointA1, fractionA1,\r\n cpB, pointB0, fractionB0, pointB1, fractionB1,\r\n reversed,\r\n );\r\n }\r\n /**\r\n * Low level dispatch of line segment with arc.\r\n * Find close approaches within maxDistance between a line segments (pointA0, pointA1) and an arc.\r\n * To consider:\r\n * 1) intersection between arc and segment.\r\n * 2) endpoints to endpoints or endpoints projection to the other curve.\r\n * 3) arc tangent parallel to line segment (or line string).\r\n * @param cpA curve A (line segment or line string; if it is a line string, then the fractions must specify a segment)\r\n * @param pointA0 start point of the segment\r\n * @param fractionA0 fraction of the start of the segment\r\n * @param pointA1 end point of the segment\r\n * @param fractionA1 fraction of the end of the segment\r\n * @param arc the arc\r\n * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to geometryB).\r\n */\r\n private dispatchSegmentArc(\r\n cpA: CurvePrimitive,\r\n pointA0: Point3d,\r\n fractionA0: number,\r\n pointA1: Point3d,\r\n fractionA1: number,\r\n arc: Arc3d,\r\n reversed: boolean,\r\n ): void {\r\n // 1) intersection between arc and line segment (or string).\r\n // Suppose:\r\n // Arc: X = C + cU + sV where c = cos(theta) and s = sin(theta)\r\n // Line: contains points A0 and A1\r\n // The arc intersects the line at point X if det(A0, A1, X) = 0 with homogeneous xyw points and vectors.\r\n // With equational X: det(A0, A1, C) + c*det(A0, A1, U) + s*det(A0, A1, V) = 0.\r\n // solve for theta.\r\n // evaluate points.\r\n // project back to line.\r\n let intersectionFound = false;\r\n const data = arc.toTransformedVectors();\r\n const pointA0Local = pointA0;\r\n const pointA1Local = pointA1;\r\n const alpha = Geometry.tripleProductXYW(pointA0Local, 1, pointA1Local, 1, data.center, 1); // det(A0, A1, C)\r\n const beta = Geometry.tripleProductXYW(pointA0Local, 1, pointA1Local, 1, data.vector0, 0); // det(A0, A1, U)\r\n const gamma = Geometry.tripleProductXYW(pointA0Local, 1, pointA1Local, 1, data.vector90, 0); // det(A0, A1, V)\r\n const cosines = new GrowableFloat64Array(2);\r\n const sines = new GrowableFloat64Array(2);\r\n const radians = new GrowableFloat64Array(2);\r\n const numRoots = AnalyticRoots.appendImplicitLineUnitCircleIntersections( // solve the equation\r\n alpha, beta, gamma, cosines, sines, radians,\r\n );\r\n for (let i = 0; i < numRoots; i++) {\r\n const arcPoint = data.center.plus2Scaled(\r\n data.vector0, cosines.atUncheckedIndex(i), data.vector90, sines.atUncheckedIndex(i),\r\n );\r\n const arcFraction = data.sweep.radiansToSignedPeriodicFraction(radians.atUncheckedIndex(i));\r\n const lineFraction = SmallSystem.lineSegment3dXYClosestPointUnbounded(pointA0Local, pointA1Local, arcPoint);\r\n // only add if the point is within the start and end fractions of both line segment and arc\r\n if (lineFraction !== undefined && this.acceptFraction(lineFraction) && this.acceptFraction(arcFraction)) {\r\n this.recordPointWithLocalFractions(\r\n lineFraction, cpA, fractionA0, fractionA1, arcFraction, arc, 0, 1, reversed,\r\n );\r\n intersectionFound = true;\r\n }\r\n }\r\n if (intersectionFound)\r\n return;\r\n // 2) endpoints to endpoints or endpoints projection to the other curve.\r\n this.testAndRecordFractionalPairApproach(cpA, fractionA0, fractionA1, true, arc, 0, 1, true, reversed);\r\n // 3) arc tangent parallel to line segment (or string).\r\n // If line does not intersect the arc, then the closest (and/or the furthest) point on arc to the line is a\r\n // point where the tangent line on arc at that point is parallel to the line.\r\n const dotUT = data.vector0.crossProductStartEndXY(pointA0, pointA1);\r\n const dotVT = data.vector90.crossProductStartEndXY(pointA0, pointA1);\r\n const parallelRadians = Math.atan2(dotVT, dotUT);\r\n for (const radians1 of [parallelRadians, parallelRadians + Math.PI]) {\r\n const arcPoint = data.center.plus2Scaled(data.vector0, Math.cos(radians1), data.vector90, Math.sin(radians1));\r\n const arcFraction = data.sweep.radiansToSignedPeriodicFraction(radians1);\r\n const lineFraction = SmallSystem.lineSegment3dXYClosestPointUnbounded(pointA0Local, pointA1Local, arcPoint);\r\n // only add if the point is within the start and end fractions of both line segment and arc\r\n if (lineFraction !== undefined && this.acceptFraction(lineFraction) && this.acceptFraction(arcFraction)) {\r\n this.recordPointWithLocalFractions(\r\n lineFraction, cpA, fractionA0, fractionA1, arcFraction, arc, 0, 1, reversed,\r\n );\r\n }\r\n }\r\n }\r\n /** Solve Newton for 2 arcs and the given newtonEvaluator. */\r\n private solveArcArcNewton(\r\n curveP: Arc3d, curveQ: Arc3d, reversed: boolean, newtonEvaluator: NewtonEvaluatorRRtoRRD,\r\n ): void {\r\n const seedsU = [0.2, 0.4, 0.6, 0.8]; // HEURISTIC: 2 arcs have up to 4 perpendiculars/intersections\r\n const seedsV = [0.2, 0.4, 0.6, 0.8];\r\n const newtonSearcher = new Newton2dUnboundedWithDerivative(newtonEvaluator);\r\n for (const seedU of seedsU) {\r\n for (const seedV of seedsV) {\r\n newtonSearcher.setUV(seedU, seedV);\r\n if (newtonSearcher.runIterations()) {\r\n const curvePFraction = newtonSearcher.getU();\r\n const curveQFraction = newtonSearcher.getV();\r\n if (this.acceptFraction(curvePFraction) && this.acceptFraction(curveQFraction)) {\r\n this.recordPointWithLocalFractions(\r\n curvePFraction, curveP, 0, 1, curveQFraction, curveQ, 0, 1, reversed,\r\n );\r\n }\r\n }\r\n }\r\n }\r\n }\r\n /** Find and store perpendicular line between 2 arcs. */\r\n private findPerpLineXYArcArcNewton(curveP: Arc3d, curveQ: Arc3d, reversed: boolean): void {\r\n const newtonEvaluator = new CurveCurveCloseApproachXYRRtoRRD(curveP, curveQ);\r\n this.solveArcArcNewton(curveP, curveQ, reversed, newtonEvaluator);\r\n }\r\n /** Low level dispatch of arc with Arc3d. */\r\n private dispatchArcArc(cpA: Arc3d, cpB: Arc3d, reversed: boolean): void {\r\n const rangeA = cpA.range();\r\n const rangeB = cpB.range();\r\n rangeA.expandInPlace(this._maxDistanceToAccept!);\r\n if (!rangeB.intersectsRangeXY(rangeA))\r\n return;\r\n // 1) endpoints to endpoints or endpoints projection to the other curve\r\n this.testAndRecordFractionalPairApproach(cpA, 0, 1, true, cpB, 0, 1, true, reversed);\r\n // 2) perpendicular line between 2 arcs (includes intersections)\r\n this.findPerpLineXYArcArcNewton(cpA, cpB, reversed);\r\n }\r\n /** Low level dispatch of arc with (beziers of) a bspline curve */\r\n private dispatchArcBsplineCurve3d(cpA: Arc3d, cpB: BSplineCurve3d, reversed: boolean): void {\r\n const ls = LineString3d.create();\r\n cpB.emitStrokes(ls);\r\n this.computeArcLineString(cpA, ls, reversed);\r\n }\r\n /** Low level dispatch of (beziers of) a bspline curve with (beziers of) a bspline curve */\r\n private dispatchBSplineCurve3dBSplineCurve3d(\r\n bcurveA: BSplineCurve3dBase, bcurveB: BSplineCurve3dBase, reversed: boolean,\r\n ): void {\r\n const lsA = LineString3d.create();\r\n bcurveA.emitStrokes(lsA);\r\n const lsB = LineString3d.create();\r\n bcurveB.emitStrokes(lsB);\r\n this.computeLineStringLineString(lsA, lsB, reversed);\r\n }\r\n /** Low level dispatch of linestring with (beziers of) a bspline curve */\r\n public dispatchLineStringBSplineCurve(lsA: LineString3d, curveB: BSplineCurve3d, reversed: boolean): any {\r\n const lsB = LineString3d.create();\r\n curveB.emitStrokes(lsB);\r\n this.computeLineStringLineString(lsA, lsB, reversed);\r\n }\r\n /** Low level dispatch of segment with (beziers of) a bspline curve */\r\n public dispatchSegmentBsplineCurve(segA: LineSegment3d, curveB: BSplineCurve3d, reversed: boolean): any {\r\n const lsB = LineString3d.create();\r\n curveB.emitStrokes(lsB);\r\n this.computeSegmentLineString(segA, lsB, reversed);\r\n }\r\n /** Detail computation for segment approaching linestring. */\r\n public computeSegmentLineString(segA: LineSegment3d, lsB: LineString3d, reversed: boolean): void {\r\n const numB = lsB.numPoints();\r\n const deltaFracB = Geometry.safeDivideFraction(1, numB - 1, 0);\r\n const pointA0 = segA.point0Ref;\r\n const pointA1 = segA.point1Ref;\r\n const pointB0 = CurveCurveCloseApproachXY._workPointBB0;\r\n const pointB1 = CurveCurveCloseApproachXY._workPointBB1;\r\n for (let i = 0; i < numB - 1; ++i) {\r\n const fB0 = i * deltaFracB; // global linestring fractions\r\n const fB1 = (i + 1 === numB - 1) ? 1.0 : (i + 1) * deltaFracB; // make sure we nail the end fraction\r\n lsB.packedPoints.getPoint3dAtUncheckedPointIndex(i, pointB0);\r\n lsB.packedPoints.getPoint3dAtUncheckedPointIndex(i + 1, pointB1);\r\n this.dispatchSegmentSegment(segA, pointA0, 0.0, pointA1, 1.0, lsB, pointB0, fB0, pointB1, fB1, reversed);\r\n }\r\n }\r\n /** Detail computation for arc approaching linestring. */\r\n public computeArcLineString(arcA: Arc3d, lsB: LineString3d, reversed: boolean): any {\r\n const rangeA = arcA.range();\r\n const rangeB = lsB.range();\r\n rangeA.expandInPlace(this._maxDistanceToAccept!);\r\n if (!rangeB.intersectsRangeXY(rangeA))\r\n return;\r\n const pointB0 = CurveCurveCloseApproachXY._workPointBB0;\r\n const pointB1 = CurveCurveCloseApproachXY._workPointBB1;\r\n const numB = lsB.numPoints();\r\n if (numB > 1) {\r\n const dfB = 1.0 / (numB - 1);\r\n let fB0;\r\n let fB1;\r\n fB0 = 0.0;\r\n lsB.pointAt(0, pointB0);\r\n for (let ib = 1; ib < numB; ib++, pointB0.setFrom(pointB1), fB0 = fB1) {\r\n lsB.pointAt(ib, pointB1);\r\n fB1 = ib * dfB;\r\n this.dispatchSegmentArc(lsB, pointB0, fB0, pointB1, fB1, arcA, !reversed);\r\n }\r\n }\r\n return undefined;\r\n }\r\n /** Low level dispatch of curve collection. */\r\n private dispatchCurveCollection(geomA: AnyCurve, geomAHandler: (geomA: any) => any): void {\r\n const geomB = this._geometryB; // save\r\n if (!geomB || !geomB.children || !(geomB instanceof CurveCollection))\r\n return;\r\n for (const child of geomB.children) {\r\n this.resetGeometry(child);\r\n geomAHandler(geomA);\r\n }\r\n this._geometryB = geomB; // restore\r\n }\r\n /** Low level dispatch to geomA given a CurveChainWithDistanceIndex in geometryB. */\r\n private dispatchCurveChainWithDistanceIndex(geomA: AnyCurve, geomAHandler: (geomA: any) => any): void {\r\n if (!this._geometryB || !(this._geometryB instanceof CurveChainWithDistanceIndex))\r\n return;\r\n if (geomA instanceof CurveChainWithDistanceIndex) {\r\n assert(!!\"call handleCurveChainWithDistanceIndex(geomA) instead\");\r\n return;\r\n }\r\n const index0 = this._results.length;\r\n const geomB = this._geometryB; // save\r\n for (const child of geomB.path.children) {\r\n this.resetGeometry(child);\r\n geomAHandler(geomA);\r\n }\r\n this.resetGeometry(geomB); // restore\r\n this._results = CurveChainWithDistanceIndex.convertChildDetailToChainDetail(this._results, index0, undefined, geomB, true);\r\n }\r\n /** Double dispatch handler for strongly typed segment. */\r\n public override handleLineSegment3d(segmentA: LineSegment3d): any {\r\n if (this._geometryB instanceof LineSegment3d) {\r\n const segmentB = this._geometryB;\r\n this.dispatchSegmentSegment(\r\n segmentA, segmentA.point0Ref, 0.0, segmentA.point1Ref, 1.0,\r\n segmentB, segmentB.point0Ref, 0.0, segmentB.point1Ref, 1.0,\r\n false,\r\n );\r\n } else if (this._geometryB instanceof LineString3d) {\r\n this.computeSegmentLineString(segmentA, this._geometryB, false);\r\n } else if (this._geometryB instanceof Arc3d) {\r\n this.dispatchSegmentArc(segmentA, segmentA.point0Ref, 0.0, segmentA.point1Ref, 1.0, this._geometryB, false);\r\n } else if (this._geometryB instanceof BSplineCurve3d) {\r\n this.dispatchSegmentBsplineCurve(segmentA, this._geometryB, false);\r\n } else if (this._geometryB instanceof CurveCollection) {\r\n this.dispatchCurveCollection(segmentA, this.handleLineSegment3d.bind(this));\r\n } else if (this._geometryB instanceof CurveChainWithDistanceIndex) {\r\n this.dispatchCurveChainWithDistanceIndex(segmentA, this.handleLineSegment3d.bind(this));\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Set bits for comparison to range xy\r\n * * bit 0x01 => x smaller than range.low.x\r\n * * bit 0x02 => x larger than range.high.x\r\n * * bit 0x04 => y smaller than range.low.y\r\n * * bit 0x08 => y larger than range.high.y\r\n * * If we divide XY plane into 9 areas using the range, the function returns 0 for points\r\n * inside the range. Below is other binary numbers returned by the function for all 9 areas:\r\n * 1001 | 1000 | 1010\r\n * ------------------\r\n * 1 | 0 | 10\r\n * ------------------\r\n * 101 | 100 | 110\r\n * @param xy point to test\r\n * @param range range for comparison\r\n */\r\n private classifyBitsPointRangeXY(x: number, y: number, range: Range3d): number {\r\n let result = 0;\r\n if (x < range.low.x)\r\n result = 0x01;\r\n else if (x > range.high.x)\r\n result = 0x02;\r\n // note the OR operation\r\n if (y < range.low.y)\r\n result |= 0x04;\r\n else if (y > range.high.y)\r\n result |= 0x08;\r\n return result;\r\n }\r\n /** Low level dispatch of line string with line string. */\r\n private computeLineStringLineString(lsA: LineString3d, lsB: LineString3d, reversed: boolean): void {\r\n const rangeA = lsA.range();\r\n const rangeB = lsB.range();\r\n rangeA.expandInPlace(this._maxDistanceToAccept!);\r\n if (!rangeB.intersectsRangeXY(rangeA))\r\n return;\r\n let bitB0: number;\r\n let bitB1: number;\r\n const rangeA1 = Range3d.createNull();\r\n const pointA0 = CurveCurveCloseApproachXY._workPointAA0;\r\n const pointA1 = CurveCurveCloseApproachXY._workPointAA1;\r\n const pointB0 = CurveCurveCloseApproachXY._workPointBB0;\r\n const pointB1 = CurveCurveCloseApproachXY._workPointBB1;\r\n const numA = lsA.numPoints();\r\n const numB = lsB.numPoints();\r\n if (numA > 1 && numB > 1) {\r\n const dfA = 1.0 / (numA - 1);\r\n const dfB = 1.0 / (numB - 1);\r\n let fA0 = 0.0;\r\n let fA1, fB0, fB1;\r\n lsA.pointAt(0, pointA0);\r\n for (let ia = 1; ia < numA; ia++, pointA0.setFrom(pointA1), fA0 = fA1) {\r\n fA1 = ia * dfA;\r\n fB0 = 0.0;\r\n lsA.pointAt(ia, pointA1);\r\n // rangeA1 is around line segment [A0,A1] expanded by max distance\r\n rangeA1.setNull();\r\n rangeA1.extendPoint(pointA0);\r\n rangeA1.extendPoint(pointA1);\r\n rangeA1.expandInPlace(this._maxDistanceToAccept!);\r\n if (rangeA1.intersectsRangeXY(rangeB)) {\r\n lsB.pointAt(0, pointB0);\r\n bitB0 = this.classifyBitsPointRangeXY(pointB0.x, pointB0.y, rangeA1);\r\n for (let ib = 1; ib < numB; ib++, pointB0.setFrom(pointB1), fB0 = fB1, bitB0 = bitB1) {\r\n lsB.pointAt(ib, pointB1);\r\n bitB1 = this.classifyBitsPointRangeXY(pointB1.x, pointB1.y, rangeA1);\r\n fB1 = ib * dfB;\r\n // DO NOT study the segment in detail if both bitB bits are on for any of the 4 planes\r\n // (i.e., no intersection between rangeA1 and the range around line segment [B0,B1])\r\n if ((bitB0 & bitB1) === 0)\r\n this.dispatchSegmentSegment(lsA, pointA0, fA0, pointA1, fA1, lsB, pointB0, fB0, pointB1, fB1, reversed);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n /** Double dispatch handler for strongly typed linestring. */\r\n public override handleLineString3d(lsA: LineString3d): any {\r\n if (this._geometryB instanceof LineString3d) {\r\n const lsB = this._geometryB;\r\n this.computeLineStringLineString(lsA, lsB, false);\r\n } else if (this._geometryB instanceof LineSegment3d) {\r\n this.computeSegmentLineString(this._geometryB, lsA, true);\r\n } else if (this._geometryB instanceof Arc3d) {\r\n this.computeArcLineString(this._geometryB, lsA, true);\r\n } else if (this._geometryB instanceof BSplineCurve3d) {\r\n this.dispatchLineStringBSplineCurve(lsA, this._geometryB, false);\r\n } else if (this._geometryB instanceof CurveCollection) {\r\n this.dispatchCurveCollection(lsA, this.handleLineString3d.bind(this));\r\n } else if (this._geometryB instanceof CurveChainWithDistanceIndex) {\r\n this.dispatchCurveChainWithDistanceIndex(lsA, this.handleLineString3d.bind(this));\r\n }\r\n return undefined;\r\n }\r\n /** Double dispatch handler for strongly typed arc. */\r\n public override handleArc3d(arc0: Arc3d): any {\r\n if (this._geometryB instanceof LineSegment3d) {\r\n this.dispatchSegmentArc(\r\n this._geometryB, this._geometryB.point0Ref, 0.0, this._geometryB.point1Ref, 1.0, arc0, true,\r\n );\r\n } else if (this._geometryB instanceof LineString3d) {\r\n this.computeArcLineString(arc0, this._geometryB, false);\r\n } else if (this._geometryB instanceof Arc3d) {\r\n this.dispatchArcArc(arc0, this._geometryB, false);\r\n } else if (this._geometryB instanceof BSplineCurve3d) {\r\n this.dispatchArcBsplineCurve3d(arc0, this._geometryB, false);\r\n } else if (this._geometryB instanceof CurveCollection) {\r\n this.dispatchCurveCollection(arc0, this.handleArc3d.bind(this));\r\n } else if (this._geometryB instanceof CurveChainWithDistanceIndex) {\r\n this.dispatchCurveChainWithDistanceIndex(arc0, this.handleArc3d.bind(this));\r\n }\r\n return undefined;\r\n }\r\n /** Double dispatch handler for strongly typed bspline curve. */\r\n public override handleBSplineCurve3d(curve: BSplineCurve3d): any {\r\n if (this._geometryB instanceof LineSegment3d) {\r\n this.dispatchSegmentBsplineCurve(this._geometryB, curve, true);\r\n } else if (this._geometryB instanceof LineString3d) {\r\n this.dispatchLineStringBSplineCurve(this._geometryB, curve, true);\r\n } else if (this._geometryB instanceof Arc3d) {\r\n this.dispatchArcBsplineCurve3d(this._geometryB, curve, true);\r\n } else if (this._geometryB instanceof BSplineCurve3dBase) {\r\n this.dispatchBSplineCurve3dBSplineCurve3d(curve, this._geometryB, false);\r\n } else if (this._geometryB instanceof CurveCollection) {\r\n this.dispatchCurveCollection(curve, this.handleBSplineCurve3d.bind(this));\r\n } else if (this._geometryB instanceof CurveChainWithDistanceIndex) {\r\n this.dispatchCurveChainWithDistanceIndex(curve, this.handleBSplineCurve3d.bind(this));\r\n }\r\n return undefined;\r\n }\r\n /** Double dispatch handler for strongly typed CurveChainWithDistanceIndex. */\r\n public override handleCurveChainWithDistanceIndex(chain: CurveChainWithDistanceIndex): any {\r\n super.handleCurveChainWithDistanceIndex(chain);\r\n // if _geometryB is also a CurveChainWithDistanceIndex, it will already have been converted by dispatchCurveChainWithDistanceIndex\r\n this._results = CurveChainWithDistanceIndex.convertChildDetailToChainDetail(this._results, 0, chain, undefined, true);\r\n }\r\n /** Double dispatch handler for strongly typed homogeneous bspline curve .. */\r\n public override handleBSplineCurve3dH(_curve: BSplineCurve3dH): any {\r\n /*\r\n //NEEDS WORK -- make \"dispatch\" methods tolerant of both 3d and 3dH.\r\n // \"easy\" if both present BezierCurve3dH span loaders\r\n if (this._geometryB instanceof LineSegment3d) {\r\n this.dispatchSegmentBsplineCurve(\r\n this._geometryB, this._extendB, this._geometryB.point0Ref, 0.0, this._geometryB.point1Ref, 1.0, this._extendB,\r\n curve, this._extendA, true);\r\n } else if (this._geometryB instanceof LineString3d) {\r\n this.dispatchLineStringBSplineCurve(this._geometryB, this._extendB, curve, this._extendA, true);\r\n } else if (this._geometryB instanceof Arc3d) {\r\n this.dispatchArcBsplineCurve3d(this._geometryB, this._extendB, curve, this._extendA, true);\r\n }\r\n */\r\n return undefined;\r\n }\r\n}\r\n"]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { BezierCurveBase } from "../../bspline/BezierCurveBase";
|
|
2
1
|
import { BSplineCurve3d } from "../../bspline/BSplineCurve";
|
|
3
2
|
import { BSplineCurve3dH } from "../../bspline/BSplineCurve3dH";
|
|
4
3
|
import { RecurseToCurvesGeometryHandler } from "../../geometry3d/GeometryHandler";
|
|
5
4
|
import { Matrix4d } from "../../geometry4d/Matrix4d";
|
|
6
|
-
import { NewtonEvaluatorRRtoRRD } from "../../numerics/Newton";
|
|
7
5
|
import { Arc3d } from "../Arc3d";
|
|
8
6
|
import { CurveChainWithDistanceIndex } from "../CurveChainWithDistanceIndex";
|
|
9
7
|
import { CurveLocationDetailPair } from "../CurveLocationDetail";
|
|
@@ -11,19 +9,6 @@ import { CurvePrimitive } from "../CurvePrimitive";
|
|
|
11
9
|
import { AnyCurve } from "../CurveTypes";
|
|
12
10
|
import { LineSegment3d } from "../LineSegment3d";
|
|
13
11
|
import { LineString3d } from "../LineString3d";
|
|
14
|
-
/**
|
|
15
|
-
* Private class for refining bezier-bezier intersections.
|
|
16
|
-
* * The inputs are assumed pre-transformed so that the target condition is to match x and y coordinates.
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
19
|
-
export declare class BezierBezierIntersectionXYRRToRRD extends NewtonEvaluatorRRtoRRD {
|
|
20
|
-
private _curveA;
|
|
21
|
-
private _curveB;
|
|
22
|
-
private _rayA;
|
|
23
|
-
private _rayB;
|
|
24
|
-
constructor(curveA: BezierCurveBase, curveB: BezierCurveBase);
|
|
25
|
-
evaluate(fractionA: number, fractionB: number): boolean;
|
|
26
|
-
}
|
|
27
12
|
/**
|
|
28
13
|
* Handler class for XY intersections between _geometryB and another geometry.
|
|
29
14
|
* * Instances are initialized and called from CurveCurve.
|
|
@@ -105,7 +90,20 @@ export declare class CurveCurveIntersectXY extends RecurseToCurvesGeometryHandle
|
|
|
105
90
|
private computeSegmentSegment3DH;
|
|
106
91
|
private dispatchSegmentSegment;
|
|
107
92
|
private dispatchSegmentArc;
|
|
93
|
+
/**
|
|
94
|
+
* Compute the intersection of two xy-arcs.
|
|
95
|
+
* * Each matrix has [U V C] in (x,y,w) form from homogeneous projection (local to world).
|
|
96
|
+
* * Arcs are ordered so that matrixA is better conditioned.
|
|
97
|
+
*/
|
|
108
98
|
private dispatchArcArcThisOrder;
|
|
99
|
+
/**
|
|
100
|
+
* We have 2 xy-arcs.
|
|
101
|
+
* 1- We pick the arc that is closest to circular (larger condition number is closer to circular).
|
|
102
|
+
* 2- Transform it to local coords, where it becomes the unit xy-circle.
|
|
103
|
+
* 3- Use the same map to transform the other arc.
|
|
104
|
+
* 4- Find the intersection of arc and unit circle.
|
|
105
|
+
* 5- Convert intersection angles to fractions and record intersections.
|
|
106
|
+
*/
|
|
109
107
|
private dispatchArcArc;
|
|
110
108
|
private dispatchArcBsplineCurve3d;
|
|
111
109
|
/** Apply the transformation to bezier curves. Optionally construct ranges. */
|
|
@@ -132,7 +130,7 @@ export declare class CurveCurveIntersectXY extends RecurseToCurvesGeometryHandle
|
|
|
132
130
|
private static setTransformedWorkPoints;
|
|
133
131
|
/** Low level dispatch of curve collection. */
|
|
134
132
|
private dispatchCurveCollection;
|
|
135
|
-
/** Low level dispatch
|
|
133
|
+
/** Low level dispatch of CurveChainWithDistanceIndex. */
|
|
136
134
|
private dispatchCurveChainWithDistanceIndex;
|
|
137
135
|
/** Double dispatch handler for strongly typed segment. */
|
|
138
136
|
handleLineSegment3d(segmentA: LineSegment3d): any;
|