@itwin/core-geometry 5.0.0-dev.99 → 5.0.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 +48 -1
- package/lib/cjs/Geometry.d.ts +15 -4
- package/lib/cjs/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js +17 -3
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/bspline/BSpline1dNd.d.ts +1 -1
- package/lib/cjs/bspline/BSpline1dNd.js +1 -1
- package/lib/cjs/bspline/BSpline1dNd.js.map +1 -1
- package/lib/cjs/bspline/BSplineSurface.d.ts +4 -3
- package/lib/cjs/bspline/BSplineSurface.d.ts.map +1 -1
- package/lib/cjs/bspline/BSplineSurface.js +6 -5
- package/lib/cjs/bspline/BSplineSurface.js.map +1 -1
- package/lib/cjs/clipping/ClipPlane.d.ts +7 -5
- package/lib/cjs/clipping/ClipPlane.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipPlane.js +9 -5
- package/lib/cjs/clipping/ClipPlane.js.map +1 -1
- package/lib/cjs/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipUtils.js +5 -3
- package/lib/cjs/clipping/ClipUtils.js.map +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
- package/lib/cjs/clipping/ConvexClipPlaneSet.js +12 -23
- package/lib/cjs/clipping/ConvexClipPlaneSet.js.map +1 -1
- package/lib/cjs/core-geometry.d.ts +1 -0
- package/lib/cjs/core-geometry.d.ts.map +1 -1
- package/lib/cjs/core-geometry.js +1 -0
- package/lib/cjs/core-geometry.js.map +1 -1
- package/lib/cjs/curve/Arc3d.d.ts +56 -32
- package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
- package/lib/cjs/curve/Arc3d.js +91 -36
- package/lib/cjs/curve/Arc3d.js.map +1 -1
- package/lib/cjs/curve/CurveCollection.d.ts +2 -0
- package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCollection.js +14 -0
- package/lib/cjs/curve/CurveCollection.js.map +1 -1
- package/lib/cjs/curve/CurveExtendMode.d.ts +13 -5
- package/lib/cjs/curve/CurveExtendMode.d.ts.map +1 -1
- package/lib/cjs/curve/CurveExtendMode.js +19 -15
- package/lib/cjs/curve/CurveExtendMode.js.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.d.ts +1 -1
- package/lib/cjs/curve/CurveLocationDetail.js +1 -1
- package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.d.ts +67 -8
- package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.js +59 -6
- package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
- package/lib/cjs/curve/CurveTypes.d.ts +1 -1
- package/lib/cjs/curve/CurveTypes.js.map +1 -1
- package/lib/cjs/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineSegment3d.js +1 -0
- package/lib/cjs/curve/LineSegment3d.js.map +1 -1
- package/lib/cjs/curve/LineString3d.d.ts +8 -7
- package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineString3d.js +25 -22
- package/lib/cjs/curve/LineString3d.js.map +1 -1
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js +10 -5
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.js +7 -2
- package/lib/cjs/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/cjs/curve/RegionMomentsXY.d.ts +15 -21
- package/lib/cjs/curve/RegionMomentsXY.d.ts.map +1 -1
- package/lib/cjs/curve/RegionMomentsXY.js +38 -58
- package/lib/cjs/curve/RegionMomentsXY.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +70 -38
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +115 -45
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +12 -13
- package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js +23 -23
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/cjs/curve/StrokeOptions.d.ts +1 -1
- package/lib/cjs/curve/StrokeOptions.js +1 -1
- package/lib/cjs/curve/StrokeOptions.js.map +1 -1
- package/lib/cjs/curve/internalContexts/AnnounceTangentStrokeHandler.d.ts +71 -0
- package/lib/cjs/curve/internalContexts/AnnounceTangentStrokeHandler.d.ts.map +1 -0
- package/lib/cjs/curve/internalContexts/AnnounceTangentStrokeHandler.js +181 -0
- package/lib/cjs/curve/internalContexts/AnnounceTangentStrokeHandler.js.map +1 -0
- package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts +21 -5
- package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js +42 -17
- package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +36 -12
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.d.ts +5 -3
- package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.js +5 -3
- package/lib/cjs/curve/internalContexts/NewtonRtoRStrokeHandler.js.map +1 -1
- package/lib/cjs/curve/internalContexts/TransferWithSplitArcs.d.ts +14 -0
- package/lib/cjs/curve/internalContexts/TransferWithSplitArcs.d.ts.map +1 -0
- package/lib/cjs/curve/internalContexts/TransferWithSplitArcs.js +34 -0
- package/lib/cjs/curve/internalContexts/TransferWithSplitArcs.js.map +1 -0
- package/lib/cjs/geometry3d/AngleSweep.d.ts +25 -18
- package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js +39 -25
- package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
- package/lib/cjs/geometry3d/GeometryHandler.d.ts +15 -16
- package/lib/cjs/geometry3d/GeometryHandler.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GeometryHandler.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.d.ts +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +7 -2
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.js +20 -2
- package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +2 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.js +7 -3
- package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.d.ts +10 -11
- package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.js +11 -12
- package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
- package/lib/cjs/geometry3d/Plane3d.d.ts +2 -0
- package/lib/cjs/geometry3d/Plane3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Plane3d.js +6 -1
- package/lib/cjs/geometry3d/Plane3d.js.map +1 -1
- package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.d.ts +2 -0
- package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.js +6 -1
- package/lib/cjs/geometry3d/Plane3dByOriginAndUnitNormal.js.map +1 -1
- package/lib/cjs/geometry3d/Plane3dByOriginAndVectors.d.ts +8 -2
- package/lib/cjs/geometry3d/Plane3dByOriginAndVectors.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Plane3dByOriginAndVectors.js +18 -10
- package/lib/cjs/geometry3d/Plane3dByOriginAndVectors.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +4 -4
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +6 -6
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts +7 -7
- package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.js +66 -26
- package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.d.ts +57 -9
- package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.js +57 -17
- package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
- package/lib/cjs/geometry3d/PolylineCompressionByEdgeOffset.d.ts +13 -6
- package/lib/cjs/geometry3d/PolylineCompressionByEdgeOffset.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolylineCompressionByEdgeOffset.js +16 -9
- package/lib/cjs/geometry3d/PolylineCompressionByEdgeOffset.js.map +1 -1
- package/lib/cjs/geometry3d/PolylineOps.d.ts +5 -4
- package/lib/cjs/geometry3d/PolylineOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolylineOps.js +5 -4
- package/lib/cjs/geometry3d/PolylineOps.js.map +1 -1
- package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Ray3d.js +11 -23
- package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
- package/lib/cjs/geometry3d/Transform.d.ts +21 -2
- package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Transform.js +32 -13
- package/lib/cjs/geometry3d/Transform.js.map +1 -1
- package/lib/cjs/geometry4d/Matrix4d.d.ts +7 -7
- package/lib/cjs/geometry4d/Matrix4d.d.ts.map +1 -1
- package/lib/cjs/geometry4d/Matrix4d.js +9 -9
- package/lib/cjs/geometry4d/Matrix4d.js.map +1 -1
- package/lib/cjs/geometry4d/MomentData.d.ts +32 -34
- package/lib/cjs/geometry4d/MomentData.d.ts.map +1 -1
- package/lib/cjs/geometry4d/MomentData.js +56 -57
- package/lib/cjs/geometry4d/MomentData.js.map +1 -1
- package/lib/cjs/geometry4d/Point4d.d.ts +8 -5
- package/lib/cjs/geometry4d/Point4d.d.ts.map +1 -1
- package/lib/cjs/geometry4d/Point4d.js +27 -16
- package/lib/cjs/geometry4d/Point4d.js.map +1 -1
- package/lib/cjs/polyface/FacetOrientation.d.ts +1 -1
- package/lib/cjs/polyface/FacetOrientation.js +2 -2
- package/lib/cjs/polyface/FacetOrientation.js.map +1 -1
- package/lib/cjs/polyface/IndexedEdgeMatcher.d.ts +55 -40
- package/lib/cjs/polyface/IndexedEdgeMatcher.d.ts.map +1 -1
- package/lib/cjs/polyface/IndexedEdgeMatcher.js +83 -75
- package/lib/cjs/polyface/IndexedEdgeMatcher.js.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts +15 -14
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +47 -38
- package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceWalker.d.ts +26 -19
- package/lib/cjs/polyface/IndexedPolyfaceWalker.d.ts.map +1 -1
- package/lib/cjs/polyface/IndexedPolyfaceWalker.js +47 -32
- package/lib/cjs/polyface/IndexedPolyfaceWalker.js.map +1 -1
- package/lib/cjs/polyface/Polyface.d.ts +19 -5
- package/lib/cjs/polyface/Polyface.d.ts.map +1 -1
- package/lib/cjs/polyface/Polyface.js +18 -2
- package/lib/cjs/polyface/Polyface.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.js +3 -3
- package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceClip.d.ts +19 -18
- package/lib/cjs/polyface/PolyfaceClip.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceClip.js +39 -42
- package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceData.d.ts +1 -1
- package/lib/cjs/polyface/PolyfaceData.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceData.js +3 -1
- package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.d.ts +119 -78
- package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceQuery.js +315 -231
- package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/cjs/polyface/RangeTree/RangeTreeNode.d.ts +3 -3
- package/lib/cjs/polyface/RangeTree/RangeTreeNode.d.ts.map +1 -1
- package/lib/cjs/polyface/RangeTree/RangeTreeNode.js +3 -3
- package/lib/cjs/polyface/RangeTree/RangeTreeNode.js.map +1 -1
- package/lib/cjs/polyface/multiclip/SweepLineStringToFacetContext.d.ts +7 -6
- package/lib/cjs/polyface/multiclip/SweepLineStringToFacetContext.d.ts.map +1 -1
- package/lib/cjs/polyface/multiclip/SweepLineStringToFacetContext.js +8 -9
- package/lib/cjs/polyface/multiclip/SweepLineStringToFacetContext.js.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.d.ts +1 -1
- package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/cjs/serialization/GeometrySamples.js +1 -1
- package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.d.ts +3 -3
- package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/cjs/topology/ChainMerge.d.ts +1 -1
- package/lib/cjs/topology/ChainMerge.js +1 -1
- package/lib/cjs/topology/ChainMerge.js.map +1 -1
- package/lib/cjs/topology/Triangulation.d.ts +3 -3
- package/lib/cjs/topology/Triangulation.d.ts.map +1 -1
- package/lib/cjs/topology/Triangulation.js +7 -7
- package/lib/cjs/topology/Triangulation.js.map +1 -1
- package/lib/esm/Geometry.d.ts +15 -4
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js +17 -3
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/bspline/BSpline1dNd.d.ts +1 -1
- package/lib/esm/bspline/BSpline1dNd.js +1 -1
- package/lib/esm/bspline/BSpline1dNd.js.map +1 -1
- package/lib/esm/bspline/BSplineSurface.d.ts +4 -3
- package/lib/esm/bspline/BSplineSurface.d.ts.map +1 -1
- package/lib/esm/bspline/BSplineSurface.js +6 -5
- package/lib/esm/bspline/BSplineSurface.js.map +1 -1
- package/lib/esm/clipping/ClipPlane.d.ts +7 -5
- package/lib/esm/clipping/ClipPlane.d.ts.map +1 -1
- package/lib/esm/clipping/ClipPlane.js +9 -5
- package/lib/esm/clipping/ClipPlane.js.map +1 -1
- package/lib/esm/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/esm/clipping/ClipUtils.js +5 -3
- package/lib/esm/clipping/ClipUtils.js.map +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
- package/lib/esm/clipping/ConvexClipPlaneSet.js +12 -23
- package/lib/esm/clipping/ConvexClipPlaneSet.js.map +1 -1
- package/lib/esm/core-geometry.d.ts +1 -0
- package/lib/esm/core-geometry.d.ts.map +1 -1
- package/lib/esm/core-geometry.js +1 -0
- package/lib/esm/core-geometry.js.map +1 -1
- package/lib/esm/curve/Arc3d.d.ts +56 -32
- package/lib/esm/curve/Arc3d.d.ts.map +1 -1
- package/lib/esm/curve/Arc3d.js +91 -36
- package/lib/esm/curve/Arc3d.js.map +1 -1
- package/lib/esm/curve/CurveCollection.d.ts +2 -0
- package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
- package/lib/esm/curve/CurveCollection.js +14 -0
- package/lib/esm/curve/CurveCollection.js.map +1 -1
- package/lib/esm/curve/CurveExtendMode.d.ts +13 -5
- package/lib/esm/curve/CurveExtendMode.d.ts.map +1 -1
- package/lib/esm/curve/CurveExtendMode.js +19 -15
- package/lib/esm/curve/CurveExtendMode.js.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.d.ts +1 -1
- package/lib/esm/curve/CurveLocationDetail.js +1 -1
- package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
- package/lib/esm/curve/CurvePrimitive.d.ts +67 -8
- package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/esm/curve/CurvePrimitive.js +59 -6
- package/lib/esm/curve/CurvePrimitive.js.map +1 -1
- package/lib/esm/curve/CurveTypes.d.ts +1 -1
- package/lib/esm/curve/CurveTypes.js.map +1 -1
- package/lib/esm/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/esm/curve/LineSegment3d.js +1 -0
- package/lib/esm/curve/LineSegment3d.js.map +1 -1
- package/lib/esm/curve/LineString3d.d.ts +8 -7
- package/lib/esm/curve/LineString3d.d.ts.map +1 -1
- package/lib/esm/curve/LineString3d.js +25 -22
- package/lib/esm/curve/LineString3d.js.map +1 -1
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js +10 -5
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.js +7 -2
- package/lib/esm/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/esm/curve/RegionMomentsXY.d.ts +15 -21
- package/lib/esm/curve/RegionMomentsXY.d.ts.map +1 -1
- package/lib/esm/curve/RegionMomentsXY.js +38 -58
- package/lib/esm/curve/RegionMomentsXY.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +70 -38
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +116 -46
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +12 -13
- package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.js +23 -23
- package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/esm/curve/StrokeOptions.d.ts +1 -1
- package/lib/esm/curve/StrokeOptions.js +1 -1
- package/lib/esm/curve/StrokeOptions.js.map +1 -1
- package/lib/esm/curve/internalContexts/AnnounceTangentStrokeHandler.d.ts +71 -0
- package/lib/esm/curve/internalContexts/AnnounceTangentStrokeHandler.d.ts.map +1 -0
- package/lib/esm/curve/internalContexts/AnnounceTangentStrokeHandler.js +177 -0
- package/lib/esm/curve/internalContexts/AnnounceTangentStrokeHandler.js.map +1 -0
- package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts +21 -5
- package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js +42 -17
- package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +36 -12
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.d.ts +5 -3
- package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.js +5 -3
- package/lib/esm/curve/internalContexts/NewtonRtoRStrokeHandler.js.map +1 -1
- package/lib/esm/curve/internalContexts/TransferWithSplitArcs.d.ts +14 -0
- package/lib/esm/curve/internalContexts/TransferWithSplitArcs.d.ts.map +1 -0
- package/lib/esm/curve/internalContexts/TransferWithSplitArcs.js +30 -0
- package/lib/esm/curve/internalContexts/TransferWithSplitArcs.js.map +1 -0
- package/lib/esm/geometry3d/AngleSweep.d.ts +25 -18
- package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.js +39 -25
- package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
- package/lib/esm/geometry3d/GeometryHandler.d.ts +15 -16
- package/lib/esm/geometry3d/GeometryHandler.d.ts.map +1 -1
- package/lib/esm/geometry3d/GeometryHandler.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.d.ts +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.js +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts +7 -2
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.js +20 -2
- package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +2 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.js +7 -3
- package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.d.ts +10 -11
- package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.js +11 -12
- package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
- package/lib/esm/geometry3d/Plane3d.d.ts +2 -0
- package/lib/esm/geometry3d/Plane3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Plane3d.js +6 -1
- package/lib/esm/geometry3d/Plane3d.js.map +1 -1
- package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.d.ts +2 -0
- package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.d.ts.map +1 -1
- package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.js +6 -1
- package/lib/esm/geometry3d/Plane3dByOriginAndUnitNormal.js.map +1 -1
- package/lib/esm/geometry3d/Plane3dByOriginAndVectors.d.ts +8 -2
- package/lib/esm/geometry3d/Plane3dByOriginAndVectors.d.ts.map +1 -1
- package/lib/esm/geometry3d/Plane3dByOriginAndVectors.js +18 -10
- package/lib/esm/geometry3d/Plane3dByOriginAndVectors.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +4 -4
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +6 -6
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts +7 -7
- package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.js +66 -26
- package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.d.ts +57 -9
- package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.js +57 -17
- package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
- package/lib/esm/geometry3d/PolylineCompressionByEdgeOffset.d.ts +13 -6
- package/lib/esm/geometry3d/PolylineCompressionByEdgeOffset.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolylineCompressionByEdgeOffset.js +16 -9
- package/lib/esm/geometry3d/PolylineCompressionByEdgeOffset.js.map +1 -1
- package/lib/esm/geometry3d/PolylineOps.d.ts +5 -4
- package/lib/esm/geometry3d/PolylineOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolylineOps.js +5 -4
- package/lib/esm/geometry3d/PolylineOps.js.map +1 -1
- package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Ray3d.js +11 -23
- package/lib/esm/geometry3d/Ray3d.js.map +1 -1
- package/lib/esm/geometry3d/Transform.d.ts +21 -2
- package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
- package/lib/esm/geometry3d/Transform.js +32 -13
- package/lib/esm/geometry3d/Transform.js.map +1 -1
- package/lib/esm/geometry4d/Matrix4d.d.ts +7 -7
- package/lib/esm/geometry4d/Matrix4d.d.ts.map +1 -1
- package/lib/esm/geometry4d/Matrix4d.js +9 -9
- package/lib/esm/geometry4d/Matrix4d.js.map +1 -1
- package/lib/esm/geometry4d/MomentData.d.ts +32 -34
- package/lib/esm/geometry4d/MomentData.d.ts.map +1 -1
- package/lib/esm/geometry4d/MomentData.js +56 -57
- package/lib/esm/geometry4d/MomentData.js.map +1 -1
- package/lib/esm/geometry4d/Point4d.d.ts +8 -5
- package/lib/esm/geometry4d/Point4d.d.ts.map +1 -1
- package/lib/esm/geometry4d/Point4d.js +27 -16
- package/lib/esm/geometry4d/Point4d.js.map +1 -1
- package/lib/esm/polyface/FacetOrientation.d.ts +1 -1
- package/lib/esm/polyface/FacetOrientation.js +2 -2
- package/lib/esm/polyface/FacetOrientation.js.map +1 -1
- package/lib/esm/polyface/IndexedEdgeMatcher.d.ts +55 -40
- package/lib/esm/polyface/IndexedEdgeMatcher.d.ts.map +1 -1
- package/lib/esm/polyface/IndexedEdgeMatcher.js +83 -75
- package/lib/esm/polyface/IndexedEdgeMatcher.js.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts +15 -14
- package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js +47 -38
- package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceWalker.d.ts +26 -19
- package/lib/esm/polyface/IndexedPolyfaceWalker.d.ts.map +1 -1
- package/lib/esm/polyface/IndexedPolyfaceWalker.js +47 -32
- package/lib/esm/polyface/IndexedPolyfaceWalker.js.map +1 -1
- package/lib/esm/polyface/Polyface.d.ts +19 -5
- package/lib/esm/polyface/Polyface.d.ts.map +1 -1
- package/lib/esm/polyface/Polyface.js +18 -2
- package/lib/esm/polyface/Polyface.js.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.d.ts +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.js +3 -3
- package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/esm/polyface/PolyfaceClip.d.ts +19 -18
- package/lib/esm/polyface/PolyfaceClip.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceClip.js +39 -42
- package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
- package/lib/esm/polyface/PolyfaceData.d.ts +1 -1
- package/lib/esm/polyface/PolyfaceData.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceData.js +3 -1
- package/lib/esm/polyface/PolyfaceData.js.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.d.ts +119 -78
- package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceQuery.js +316 -232
- package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
- package/lib/esm/polyface/RangeTree/RangeTreeNode.d.ts +3 -3
- package/lib/esm/polyface/RangeTree/RangeTreeNode.d.ts.map +1 -1
- package/lib/esm/polyface/RangeTree/RangeTreeNode.js +3 -3
- package/lib/esm/polyface/RangeTree/RangeTreeNode.js.map +1 -1
- package/lib/esm/polyface/multiclip/SweepLineStringToFacetContext.d.ts +7 -6
- package/lib/esm/polyface/multiclip/SweepLineStringToFacetContext.d.ts.map +1 -1
- package/lib/esm/polyface/multiclip/SweepLineStringToFacetContext.js +8 -9
- package/lib/esm/polyface/multiclip/SweepLineStringToFacetContext.js.map +1 -1
- package/lib/esm/serialization/GeometrySamples.d.ts +1 -1
- package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
- package/lib/esm/serialization/GeometrySamples.js +1 -1
- package/lib/esm/serialization/GeometrySamples.js.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.d.ts +3 -3
- package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/esm/topology/ChainMerge.d.ts +1 -1
- package/lib/esm/topology/ChainMerge.js +1 -1
- package/lib/esm/topology/ChainMerge.js.map +1 -1
- package/lib/esm/topology/Triangulation.d.ts +3 -3
- package/lib/esm/topology/Triangulation.d.ts.map +1 -1
- package/lib/esm/topology/Triangulation.js +7 -7
- package/lib/esm/topology/Triangulation.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module Curve
|
|
7
|
+
*/
|
|
8
|
+
import { assert } from "@itwin/core-bentley";
|
|
9
|
+
import { Geometry } from "../../Geometry";
|
|
10
|
+
import { Vector3d } from "../../geometry3d/Point3dVector3d";
|
|
11
|
+
import { Ray3d } from "../../geometry3d/Ray3d";
|
|
12
|
+
import { Newton1dUnboundedApproximateDerivative } from "../../numerics/Newton";
|
|
13
|
+
import { CurveLocationDetail } from "../CurveLocationDetail";
|
|
14
|
+
import { NewtonRtoRStrokeHandler } from "./NewtonRtoRStrokeHandler";
|
|
15
|
+
/**
|
|
16
|
+
* Context for searching for the tangent(s) to a CurvePrimitive.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export class AnnounceTangentStrokeHandler extends NewtonRtoRStrokeHandler {
|
|
20
|
+
_curve;
|
|
21
|
+
_announceTangent;
|
|
22
|
+
_spacePoint;
|
|
23
|
+
_vectorToEye;
|
|
24
|
+
_distanceTol;
|
|
25
|
+
_distanceTolSquared;
|
|
26
|
+
// fraction and function value on one side of an interval that may bracket a root
|
|
27
|
+
_fractionA = 0;
|
|
28
|
+
_functionA = 0;
|
|
29
|
+
// fraction and function value on the other side of an interval that may bracket a root
|
|
30
|
+
_fractionB = 0;
|
|
31
|
+
_functionB = 0;
|
|
32
|
+
_numThisCurve = 0;
|
|
33
|
+
// scratch vars to use within methods
|
|
34
|
+
_fractionMRU;
|
|
35
|
+
_curveMRU;
|
|
36
|
+
_workRay;
|
|
37
|
+
_workDetail;
|
|
38
|
+
_newtonSolver;
|
|
39
|
+
/** Constructor */
|
|
40
|
+
constructor(spacePoint, announceTangent, options) {
|
|
41
|
+
super();
|
|
42
|
+
this._announceTangent = announceTangent;
|
|
43
|
+
this._spacePoint = spacePoint;
|
|
44
|
+
this._vectorToEye = options?.vectorToEye ?? Vector3d.unitZ();
|
|
45
|
+
this._distanceTol = options?.distanceTol ?? Geometry.smallMetricDistance;
|
|
46
|
+
this._distanceTolSquared = this._distanceTol * this._distanceTol;
|
|
47
|
+
this._workRay = Ray3d.createZero();
|
|
48
|
+
this.startCurvePrimitive(undefined);
|
|
49
|
+
this._newtonSolver = new Newton1dUnboundedApproximateDerivative(this);
|
|
50
|
+
}
|
|
51
|
+
/** Specified by IStrokeHandler. */
|
|
52
|
+
needPrimaryGeometryForStrokes() {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
/** Specified by IStrokeHandler. */
|
|
56
|
+
startCurvePrimitive(curve) {
|
|
57
|
+
this._curve = curve;
|
|
58
|
+
this._fractionA = 0.0;
|
|
59
|
+
this._numThisCurve = 0;
|
|
60
|
+
this._functionA = 0.0;
|
|
61
|
+
}
|
|
62
|
+
/** Specified by IStrokeHandler. */
|
|
63
|
+
endCurvePrimitive() {
|
|
64
|
+
}
|
|
65
|
+
/** Specified by IStrokeHandler. */
|
|
66
|
+
announceIntervalForUniformStepStrokes(cp, numStrokes, fraction0, fraction1) {
|
|
67
|
+
this.startCurvePrimitive(cp);
|
|
68
|
+
if (numStrokes < 1)
|
|
69
|
+
numStrokes = 1;
|
|
70
|
+
const df = 1.0 / numStrokes;
|
|
71
|
+
for (let i = 0; i <= numStrokes; i++) {
|
|
72
|
+
const fraction = Geometry.interpolate(fraction0, i * df, fraction1);
|
|
73
|
+
cp.fractionToPointAndDerivative(fraction, this._workRay);
|
|
74
|
+
this.announceRay(fraction, this._workRay);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
announceCandidate(cp, fraction, point) {
|
|
78
|
+
if (this._parentCurvePrimitive)
|
|
79
|
+
cp = this._parentCurvePrimitive;
|
|
80
|
+
if (this._curveMRU === cp && Geometry.isAlmostEqualOptional(this._fractionMRU, fraction, Geometry.smallFloatingPoint))
|
|
81
|
+
return; // avoid announcing duplicate tangents in succession (e.g., at interior stroke point)
|
|
82
|
+
this._workDetail = CurveLocationDetail.createCurveFractionPoint(cp, fraction, point, this._workDetail);
|
|
83
|
+
this._announceTangent(this._workDetail);
|
|
84
|
+
this._fractionMRU = fraction;
|
|
85
|
+
this._curveMRU = cp;
|
|
86
|
+
}
|
|
87
|
+
/** Specified by IStrokeHandler. */
|
|
88
|
+
announceSegmentInterval(cp, point0, point1, _numStrokes, fraction0, fraction1) {
|
|
89
|
+
let fraction;
|
|
90
|
+
let point;
|
|
91
|
+
const distance0 = this._spacePoint.distanceSquared(point0);
|
|
92
|
+
const distance1 = this._spacePoint.distanceSquared(point1);
|
|
93
|
+
if (distance0 < distance1) {
|
|
94
|
+
fraction = fraction0;
|
|
95
|
+
point = point0;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
fraction = fraction1;
|
|
99
|
+
point = point1;
|
|
100
|
+
}
|
|
101
|
+
// evaluate at midpoint; the endpoints may be at corners, which have ambiguous tangent
|
|
102
|
+
const value = this.evaluateFunction(undefined, (fraction0 + fraction1) / 2, cp);
|
|
103
|
+
if (value !== undefined && Geometry.isDistanceWithinTol(value, this._distanceTol))
|
|
104
|
+
this.announceCandidate(cp, fraction, point);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Given a function `f` and (unordered) fractions `a` and `b`, search for and announce a root of `f` in this
|
|
108
|
+
* fractional interval.
|
|
109
|
+
* * This method searches for a root of `f` if and only if the stroke segment defined by `(a, f(a))` and
|
|
110
|
+
* `(b, f(b))` has a root. This is a HEURISTIC: given continuous `f` between `a` and `b`, a root of the stroke
|
|
111
|
+
* segment implies a root of `f`, but not vice-versa. Therefore, if the strokes are not sufficiently dense,
|
|
112
|
+
* this method can miss a root of `f`.
|
|
113
|
+
*/
|
|
114
|
+
searchInterval() {
|
|
115
|
+
// directly announce at endpoint if we are extra certain it's a root; Newton can miss it if it has multiplicity > 1
|
|
116
|
+
if (Geometry.isDistanceWithinTol(this._functionA, this._distanceTolSquared))
|
|
117
|
+
this.announceSolutionFraction(this._fractionA);
|
|
118
|
+
if (Geometry.isDistanceWithinTol(this._functionB, this._distanceTolSquared))
|
|
119
|
+
this.announceSolutionFraction(this._fractionB);
|
|
120
|
+
if (this._functionA * this._functionB < 0) {
|
|
121
|
+
// by the Intermediate Value Theorem, a root lies between fractionA and fractionB; use Newton to find it.
|
|
122
|
+
const fraction = Geometry.inverseInterpolate(this._fractionA, this._functionA, this._fractionB, this._functionB);
|
|
123
|
+
if (fraction) {
|
|
124
|
+
this._newtonSolver.setX(fraction);
|
|
125
|
+
if (this._newtonSolver.runIterations())
|
|
126
|
+
this.announceSolutionFraction(this._newtonSolver.getX());
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
announceSolutionFraction(fraction) {
|
|
131
|
+
if (this._curve)
|
|
132
|
+
this.announceCandidate(this._curve, fraction, this._curve.fractionToPoint(fraction));
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Evaluate the univariate real-valued function for which we are finding roots.
|
|
136
|
+
* * For finding the tangents to curve `X` from point `Q` as seen in a view plane with normal `N`, this
|
|
137
|
+
* function is `f(t) := (Q - X(t)) dot (X'(t) cross N)`. The second vector in the dot product defines a
|
|
138
|
+
* _tangent plane_ at `X(t)`.
|
|
139
|
+
* * Either `pointAndDerivative` must be defined, or both `fraction` and `curve`.
|
|
140
|
+
* @param pointAndDerivative pre-evaluated curve
|
|
141
|
+
* @param fraction fraction at which to evaluate `curve`
|
|
142
|
+
* @param curve curve to evaluate at `fraction`
|
|
143
|
+
* @returns distance of `Q` from the tangent plane at `X(t)`.
|
|
144
|
+
*/
|
|
145
|
+
evaluateFunction(pointAndDerivative, fraction, curve) {
|
|
146
|
+
if (pointAndDerivative)
|
|
147
|
+
this._workRay.setFrom(pointAndDerivative);
|
|
148
|
+
else if (fraction !== undefined && curve)
|
|
149
|
+
this._workRay = curve.fractionToPointAndDerivative(fraction, this._workRay);
|
|
150
|
+
else
|
|
151
|
+
return undefined;
|
|
152
|
+
const cross = this._vectorToEye.unitCrossProduct(this._workRay.direction); // normalized so we return true distance
|
|
153
|
+
return cross ? cross.dotProductStartEnd(this._workRay.origin, this._spacePoint) : undefined;
|
|
154
|
+
}
|
|
155
|
+
/** Specified by NewtonRtoRStrokeHandler. */
|
|
156
|
+
evaluate(fraction) {
|
|
157
|
+
const curve = this._parentCurvePrimitive ?? this._curve;
|
|
158
|
+
const value = this.evaluateFunction(undefined, fraction, curve);
|
|
159
|
+
if (value === undefined)
|
|
160
|
+
return false;
|
|
161
|
+
this.currentF = value;
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
announceRay(fraction, data) {
|
|
165
|
+
this._functionB = this.evaluateFunction(data);
|
|
166
|
+
this._fractionB = fraction;
|
|
167
|
+
if (this._numThisCurve++ > 0) // after the first stroke point, a stroke segment is defined, so we have an interval
|
|
168
|
+
this.searchInterval();
|
|
169
|
+
this._functionA = this._functionB;
|
|
170
|
+
this._fractionA = this._fractionB;
|
|
171
|
+
}
|
|
172
|
+
/** Specified by IStrokeHandler. */
|
|
173
|
+
announcePointTangent(_point, _fraction, _tangent) {
|
|
174
|
+
assert(false, "No callers expected. IStrokeHandler probably didn't need to specify this method.");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=AnnounceTangentStrokeHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnounceTangentStrokeHandler.js","sourceRoot":"","sources":["../../../../src/curve/internalContexts/AnnounceTangentStrokeHandler.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAW,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,sCAAsC,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;GAGG;AACH,MAAM,OAAO,4BAA6B,SAAQ,uBAAuB;IAC/D,MAAM,CAA6B;IACnC,gBAAgB,CAAwC;IACxD,WAAW,CAAU;IACrB,YAAY,CAAW;IACvB,YAAY,CAAS;IACrB,mBAAmB,CAAS;IACpC,iFAAiF;IACzE,UAAU,GAAW,CAAC,CAAC;IACvB,UAAU,GAAW,CAAC,CAAC;IAC/B,uFAAuF;IAC/E,UAAU,GAAW,CAAC,CAAC;IACvB,UAAU,GAAW,CAAC,CAAC;IACvB,aAAa,GAA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AAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAChE,IAAI,KAAK,KAAK,SAAS;YACrB,OAAO,KAAK,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IACO,WAAW,CAAC,QAAgB,EAAE,IAAW;QAC/C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAE,CAAC;QAC/C,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC;QAC3B,IAAI,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,EAAE,oFAAoF;YAChH,IAAI,CAAC,cAAc,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACpC,CAAC;IACD,mCAAmC;IAC5B,oBAAoB,CAAC,MAAe,EAAE,SAAiB,EAAE,QAAkB;QAChF,MAAM,CAAC,KAAK,EAAE,kFAAkF,CAAC,CAAC;IACpG,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { assert } from \"@itwin/core-bentley\";\nimport { Geometry } from \"../../Geometry\";\nimport { IStrokeHandler } from \"../../geometry3d/GeometryHandler\";\nimport { Point3d, Vector3d } from \"../../geometry3d/Point3dVector3d\";\nimport { Ray3d } from \"../../geometry3d/Ray3d\";\nimport { Newton1dUnboundedApproximateDerivative } from \"../../numerics/Newton\";\nimport { CurveLocationDetail } from \"../CurveLocationDetail\";\nimport { CurvePrimitive, TangentOptions } from \"../CurvePrimitive\";\nimport { NewtonRtoRStrokeHandler } from \"./NewtonRtoRStrokeHandler\";\n\n/**\n * Context for searching for the tangent(s) to a CurvePrimitive.\n * @internal\n */\nexport class AnnounceTangentStrokeHandler extends NewtonRtoRStrokeHandler implements IStrokeHandler {\n private _curve: CurvePrimitive | undefined;\n private _announceTangent: (tangent: CurveLocationDetail) => any;\n private _spacePoint: Point3d;\n private _vectorToEye: Vector3d;\n private _distanceTol: number;\n private _distanceTolSquared: number;\n // fraction and function value on one side of an interval that may bracket a root\n private _fractionA: number = 0;\n private _functionA: number = 0;\n // fraction and function value on the other side of an interval that may bracket a root\n private _fractionB: number = 0;\n private _functionB: number = 0;\n private _numThisCurve: number = 0;\n // scratch vars to use within methods\n private _fractionMRU?: number;\n private _curveMRU?: CurvePrimitive;\n private _workRay: Ray3d;\n private _workDetail?: CurveLocationDetail;\n private _newtonSolver: Newton1dUnboundedApproximateDerivative;\n /** Constructor */\n public constructor(spacePoint: Point3d, announceTangent: (tangent: CurveLocationDetail) => any, options?: TangentOptions) {\n super();\n this._announceTangent = announceTangent;\n this._spacePoint = spacePoint;\n this._vectorToEye = options?.vectorToEye ?? Vector3d.unitZ();\n this._distanceTol = options?.distanceTol ?? Geometry.smallMetricDistance;\n this._distanceTolSquared = this._distanceTol * this._distanceTol;\n this._workRay = Ray3d.createZero();\n this.startCurvePrimitive(undefined);\n this._newtonSolver = new Newton1dUnboundedApproximateDerivative(this);\n }\n /** Specified by IStrokeHandler. */\n public needPrimaryGeometryForStrokes() {\n return true;\n }\n /** Specified by IStrokeHandler. */\n public startCurvePrimitive(curve: CurvePrimitive | undefined) {\n this._curve = curve;\n this._fractionA = 0.0;\n this._numThisCurve = 0;\n this._functionA = 0.0;\n }\n /** Specified by IStrokeHandler. */\n public endCurvePrimitive() {\n }\n /** Specified by IStrokeHandler. */\n public announceIntervalForUniformStepStrokes(\n cp: CurvePrimitive, numStrokes: number, fraction0: number, fraction1: number,\n ): void {\n this.startCurvePrimitive(cp);\n if (numStrokes < 1)\n numStrokes = 1;\n const df = 1.0 / numStrokes;\n for (let i = 0; i <= numStrokes; i++) {\n const fraction = Geometry.interpolate(fraction0, i * df, fraction1);\n cp.fractionToPointAndDerivative(fraction, this._workRay);\n this.announceRay(fraction, this._workRay);\n }\n }\n private announceCandidate(cp: CurvePrimitive, fraction: number, point: Point3d) {\n if (this._parentCurvePrimitive)\n cp = this._parentCurvePrimitive;\n if (this._curveMRU === cp && Geometry.isAlmostEqualOptional(this._fractionMRU, fraction, Geometry.smallFloatingPoint))\n return; // avoid announcing duplicate tangents in succession (e.g., at interior stroke point)\n this._workDetail = CurveLocationDetail.createCurveFractionPoint(cp, fraction, point, this._workDetail);\n this._announceTangent(this._workDetail);\n this._fractionMRU = fraction;\n this._curveMRU = cp;\n }\n /** Specified by IStrokeHandler. */\n public announceSegmentInterval(\n cp: CurvePrimitive, point0: Point3d, point1: Point3d, _numStrokes: number, fraction0: number, fraction1: number,\n ): void {\n let fraction: number;\n let point: Point3d;\n const distance0 = this._spacePoint.distanceSquared(point0);\n const distance1 = this._spacePoint.distanceSquared(point1);\n if (distance0 < distance1) {\n fraction = fraction0;\n point = point0;\n } else {\n fraction = fraction1;\n point = point1;\n }\n // evaluate at midpoint; the endpoints may be at corners, which have ambiguous tangent\n const value = this.evaluateFunction(undefined, (fraction0 + fraction1) / 2, cp);\n if (value !== undefined && Geometry.isDistanceWithinTol(value, this._distanceTol))\n this.announceCandidate(cp, fraction, point);\n }\n /**\n * Given a function `f` and (unordered) fractions `a` and `b`, search for and announce a root of `f` in this\n * fractional interval.\n * * This method searches for a root of `f` if and only if the stroke segment defined by `(a, f(a))` and\n * `(b, f(b))` has a root. This is a HEURISTIC: given continuous `f` between `a` and `b`, a root of the stroke\n * segment implies a root of `f`, but not vice-versa. Therefore, if the strokes are not sufficiently dense,\n * this method can miss a root of `f`.\n */\n private searchInterval() {\n // directly announce at endpoint if we are extra certain it's a root; Newton can miss it if it has multiplicity > 1\n if (Geometry.isDistanceWithinTol(this._functionA, this._distanceTolSquared))\n this.announceSolutionFraction(this._fractionA);\n if (Geometry.isDistanceWithinTol(this._functionB, this._distanceTolSquared))\n this.announceSolutionFraction(this._fractionB);\n if (this._functionA * this._functionB < 0) {\n // by the Intermediate Value Theorem, a root lies between fractionA and fractionB; use Newton to find it.\n const fraction = Geometry.inverseInterpolate(this._fractionA, this._functionA, this._fractionB, this._functionB);\n if (fraction) {\n this._newtonSolver.setX(fraction);\n if (this._newtonSolver.runIterations())\n this.announceSolutionFraction(this._newtonSolver.getX());\n }\n }\n }\n private announceSolutionFraction(fraction: number) {\n if (this._curve)\n this.announceCandidate(this._curve, fraction, this._curve.fractionToPoint(fraction));\n }\n /**\n * Evaluate the univariate real-valued function for which we are finding roots.\n * * For finding the tangents to curve `X` from point `Q` as seen in a view plane with normal `N`, this\n * function is `f(t) := (Q - X(t)) dot (X'(t) cross N)`. The second vector in the dot product defines a\n * _tangent plane_ at `X(t)`.\n * * Either `pointAndDerivative` must be defined, or both `fraction` and `curve`.\n * @param pointAndDerivative pre-evaluated curve\n * @param fraction fraction at which to evaluate `curve`\n * @param curve curve to evaluate at `fraction`\n * @returns distance of `Q` from the tangent plane at `X(t)`.\n */\n private evaluateFunction(pointAndDerivative?: Ray3d, fraction?: number, curve?: CurvePrimitive): number | undefined {\n if (pointAndDerivative)\n this._workRay.setFrom(pointAndDerivative);\n else if (fraction !== undefined && curve)\n this._workRay = curve.fractionToPointAndDerivative(fraction, this._workRay);\n else\n return undefined;\n const cross = this._vectorToEye.unitCrossProduct(this._workRay.direction); // normalized so we return true distance\n return cross ? cross.dotProductStartEnd(this._workRay.origin, this._spacePoint) : undefined;\n }\n /** Specified by NewtonRtoRStrokeHandler. */\n public evaluate(fraction: number): boolean {\n const curve = this._parentCurvePrimitive ?? this._curve;\n const value = this.evaluateFunction(undefined, fraction, curve);\n if (value === undefined)\n return false;\n this.currentF = value;\n return true;\n }\n private announceRay(fraction: number, data: Ray3d): void {\n this._functionB = this.evaluateFunction(data)!;\n this._fractionB = fraction;\n if (this._numThisCurve++ > 0) // after the first stroke point, a stroke segment is defined, so we have an interval\n this.searchInterval();\n this._functionA = this._functionB;\n this._fractionA = this._fractionB;\n }\n /** Specified by IStrokeHandler. */\n public announcePointTangent(_point: Point3d, _fraction: number, _tangent: Vector3d) {\n assert(false, \"No callers expected. IStrokeHandler probably didn't need to specify this method.\");\n }\n}\n"]}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { IStrokeHandler } from "../../geometry3d/GeometryHandler";
|
|
5
5
|
import { Point3d, Vector3d } from "../../geometry3d/Point3dVector3d";
|
|
6
|
-
import { Ray3d } from "../../geometry3d/Ray3d";
|
|
7
6
|
import { VariantCurveExtendParameter } from "../CurveExtendMode";
|
|
8
7
|
import { CurveLocationDetail } from "../CurveLocationDetail";
|
|
9
8
|
import { CurvePrimitive } from "../CurvePrimitive";
|
|
@@ -19,13 +18,14 @@ export declare class ClosestPointStrokeHandler extends NewtonRtoRStrokeHandler i
|
|
|
19
18
|
private _extend;
|
|
20
19
|
private _fractionA;
|
|
21
20
|
private _functionA;
|
|
22
|
-
private _functionB;
|
|
23
21
|
private _fractionB;
|
|
22
|
+
private _functionB;
|
|
24
23
|
private _numThisCurve;
|
|
25
24
|
private _workPoint;
|
|
26
25
|
private _workRay;
|
|
27
26
|
private _newtonSolver;
|
|
28
|
-
|
|
27
|
+
/** Constructor */
|
|
28
|
+
constructor(spacePoint: Point3d, extend?: VariantCurveExtendParameter, result?: CurveLocationDetail);
|
|
29
29
|
claimResult(): CurveLocationDetail | undefined;
|
|
30
30
|
needPrimaryGeometryForStrokes(): boolean;
|
|
31
31
|
startCurvePrimitive(curve: CurvePrimitive | undefined): void;
|
|
@@ -33,11 +33,27 @@ export declare class ClosestPointStrokeHandler extends NewtonRtoRStrokeHandler i
|
|
|
33
33
|
announceIntervalForUniformStepStrokes(cp: CurvePrimitive, numStrokes: number, fraction0: number, fraction1: number): void;
|
|
34
34
|
private announceCandidate;
|
|
35
35
|
announceSegmentInterval(cp: CurvePrimitive, point0: Point3d, point1: Point3d, _numStrokes: number, fraction0: number, fraction1: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* Given a function `f` and (unordered) fractions `a` and `b`, search for and announce a root of `f` in this
|
|
38
|
+
* fractional interval.
|
|
39
|
+
* * This method searches for a root of `f` if and only if the stroke segment defined by `(a, f(a))` and
|
|
40
|
+
* `(b, f(b))` has a root. This is a HEURISTIC: given continuous `f` between `a` and `b`, a root of the stroke
|
|
41
|
+
* segment implies a root of `f`, but not vice-versa. Therefore, if the strokes are not sufficiently dense,
|
|
42
|
+
* this method can miss a root of `f`.
|
|
43
|
+
*/
|
|
36
44
|
private searchInterval;
|
|
37
|
-
private evaluateB;
|
|
38
45
|
private announceSolutionFraction;
|
|
46
|
+
/**
|
|
47
|
+
* Evaluate the univariate real-valued function for which we are finding roots.
|
|
48
|
+
* * For finding the closest point to curve X from point Q, this function is `f(t) := Q-X(t) dot X'(t)`.
|
|
49
|
+
* * Either `pointAndDerivative` must be defined, or both `fraction` and `curve`.
|
|
50
|
+
* @param pointAndDerivative pre-evaluated curve
|
|
51
|
+
* @param fraction fraction at which to evaluate `curve`
|
|
52
|
+
* @param curve curve to evaluate at `fraction`
|
|
53
|
+
*/
|
|
54
|
+
private evaluateFunction;
|
|
39
55
|
evaluate(fraction: number): boolean;
|
|
40
|
-
announceRay
|
|
56
|
+
private announceRay;
|
|
41
57
|
announcePointTangent(point: Point3d, fraction: number, tangent: Vector3d): void;
|
|
42
58
|
}
|
|
43
59
|
//# sourceMappingURL=ClosestPointStrokeHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClosestPointStrokeHandler.d.ts","sourceRoot":"","sources":["../../../../src/curve/internalContexts/ClosestPointStrokeHandler.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":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AI;IAaP,OAAO,CAAC,iBAAiB;IASlB,uBAAuB,CAC5B,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAC9G,IAAI;IAeP;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;IAiBtB,OAAO,CAAC,wBAAwB;IAIhC;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IASjB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAU1C,OAAO,CAAC,WAAW;IAQZ,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ;CAIhF"}
|
|
@@ -21,22 +21,25 @@ export class ClosestPointStrokeHandler extends NewtonRtoRStrokeHandler {
|
|
|
21
21
|
_closestPoint;
|
|
22
22
|
_spacePoint;
|
|
23
23
|
_extend;
|
|
24
|
+
// fraction and function value on one side of an interval that may bracket a root
|
|
24
25
|
_fractionA = 0;
|
|
25
26
|
_functionA = 0;
|
|
26
|
-
|
|
27
|
+
// fraction and function value on the other side of an interval that may bracket a root
|
|
27
28
|
_fractionB = 0;
|
|
29
|
+
_functionB = 0;
|
|
28
30
|
_numThisCurve = 0;
|
|
29
|
-
// scratch vars
|
|
31
|
+
// scratch vars to use within methods
|
|
30
32
|
_workPoint;
|
|
31
33
|
_workRay;
|
|
32
34
|
_newtonSolver;
|
|
35
|
+
/** Constructor */
|
|
33
36
|
constructor(spacePoint, extend, result) {
|
|
34
37
|
super();
|
|
35
38
|
this._spacePoint = spacePoint;
|
|
36
39
|
this._workPoint = Point3d.create();
|
|
37
40
|
this._workRay = Ray3d.createZero();
|
|
38
41
|
this._closestPoint = result;
|
|
39
|
-
this._extend = extend;
|
|
42
|
+
this._extend = extend ?? false;
|
|
40
43
|
this.startCurvePrimitive(undefined);
|
|
41
44
|
this._newtonSolver = new Newton1dUnboundedApproximateDerivative(this);
|
|
42
45
|
}
|
|
@@ -87,7 +90,7 @@ export class ClosestPointStrokeHandler extends NewtonRtoRStrokeHandler {
|
|
|
87
90
|
}
|
|
88
91
|
announceSegmentInterval(cp, point0, point1, _numStrokes, fraction0, fraction1) {
|
|
89
92
|
let localFraction = this._spacePoint.fractionOfProjectionToLine(point0, point1, 0.0);
|
|
90
|
-
// only consider extending the segment if the immediate caller says we are at endpoints
|
|
93
|
+
// only consider extending the segment if the immediate caller says we are at endpoints
|
|
91
94
|
if (!this._extend)
|
|
92
95
|
localFraction = Geometry.clampToStartEnd(localFraction, 0.0, 1.0);
|
|
93
96
|
else {
|
|
@@ -100,13 +103,22 @@ export class ClosestPointStrokeHandler extends NewtonRtoRStrokeHandler {
|
|
|
100
103
|
const globalFraction = Geometry.interpolate(fraction0, localFraction, fraction1);
|
|
101
104
|
this.announceCandidate(cp, globalFraction, this._workPoint);
|
|
102
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Given a function `f` and (unordered) fractions `a` and `b`, search for and announce a root of `f` in this
|
|
108
|
+
* fractional interval.
|
|
109
|
+
* * This method searches for a root of `f` if and only if the stroke segment defined by `(a, f(a))` and
|
|
110
|
+
* `(b, f(b))` has a root. This is a HEURISTIC: given continuous `f` between `a` and `b`, a root of the stroke
|
|
111
|
+
* segment implies a root of `f`, but not vice-versa. Therefore, if the strokes are not sufficiently dense,
|
|
112
|
+
* this method can miss a root of `f`.
|
|
113
|
+
*/
|
|
103
114
|
searchInterval() {
|
|
104
115
|
if (this._functionA * this._functionB > 0)
|
|
105
|
-
return;
|
|
116
|
+
return; // stroke segment has no root; ASSUME the function has no root either
|
|
106
117
|
if (this._functionA === 0)
|
|
107
118
|
this.announceSolutionFraction(this._fractionA);
|
|
108
119
|
if (this._functionB === 0)
|
|
109
120
|
this.announceSolutionFraction(this._fractionB);
|
|
121
|
+
// by the Intermediate Value Theorem, a root lies between fractionA and fractionB; use Newton to find it.
|
|
110
122
|
if (this._functionA * this._functionB < 0) {
|
|
111
123
|
const fraction = Geometry.inverseInterpolate(this._fractionA, this._functionA, this._fractionB, this._functionB);
|
|
112
124
|
if (fraction) {
|
|
@@ -116,28 +128,41 @@ export class ClosestPointStrokeHandler extends NewtonRtoRStrokeHandler {
|
|
|
116
128
|
}
|
|
117
129
|
}
|
|
118
130
|
}
|
|
119
|
-
evaluateB(fractionB, dataB) {
|
|
120
|
-
this._functionB = dataB.dotProductToPoint(this._spacePoint);
|
|
121
|
-
this._fractionB = fractionB;
|
|
122
|
-
}
|
|
123
131
|
announceSolutionFraction(fraction) {
|
|
124
132
|
if (this._curve)
|
|
125
133
|
this.announceCandidate(this._curve, fraction, this._curve.fractionToPoint(fraction));
|
|
126
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Evaluate the univariate real-valued function for which we are finding roots.
|
|
137
|
+
* * For finding the closest point to curve X from point Q, this function is `f(t) := Q-X(t) dot X'(t)`.
|
|
138
|
+
* * Either `pointAndDerivative` must be defined, or both `fraction` and `curve`.
|
|
139
|
+
* @param pointAndDerivative pre-evaluated curve
|
|
140
|
+
* @param fraction fraction at which to evaluate `curve`
|
|
141
|
+
* @param curve curve to evaluate at `fraction`
|
|
142
|
+
*/
|
|
143
|
+
evaluateFunction(pointAndDerivative, fraction, curve) {
|
|
144
|
+
if (pointAndDerivative)
|
|
145
|
+
this._workRay.setFrom(pointAndDerivative);
|
|
146
|
+
else if (fraction !== undefined && curve)
|
|
147
|
+
this._workRay = curve.fractionToPointAndDerivative(fraction, this._workRay);
|
|
148
|
+
else
|
|
149
|
+
return undefined;
|
|
150
|
+
return this._workRay.dotProductToPoint(this._spacePoint);
|
|
151
|
+
}
|
|
127
152
|
evaluate(fraction) {
|
|
128
153
|
let curve = this._curve;
|
|
129
154
|
if (this._parentCurvePrimitive)
|
|
130
155
|
curve = this._parentCurvePrimitive;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return false;
|
|
156
|
+
const value = this.evaluateFunction(undefined, fraction, curve);
|
|
157
|
+
if (value === undefined)
|
|
158
|
+
return false;
|
|
159
|
+
this.currentF = value;
|
|
160
|
+
return true;
|
|
137
161
|
}
|
|
138
162
|
announceRay(fraction, data) {
|
|
139
|
-
this.
|
|
140
|
-
|
|
163
|
+
this._functionB = this.evaluateFunction(data);
|
|
164
|
+
this._fractionB = fraction;
|
|
165
|
+
if (this._numThisCurve++ > 0) // after the first stroke point, a stroke segment is defined, so we have an interval
|
|
141
166
|
this.searchInterval();
|
|
142
167
|
this._functionA = this._functionB;
|
|
143
168
|
this._fractionA = this._fractionB;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClosestPointStrokeHandler.js","sourceRoot":"","sources":["../../../../src/curve/internalContexts/ClosestPointStrokeHandler.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAY,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,sCAAsC,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAA+B,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;GAGG;AACH,MAAM,OAAO,yBAA0B,SAAQ,uBAAuB;IAC5D,MAAM,CAA6B;IACnC,aAAa,CAAkC;IAC/C,WAAW,CAAU;IACrB,OAAO,CAA8B;IACrC,UAAU,GAAW,CAAC,CAAC;IACvB,UAAU,GAAW,CAAC,CAAC;IACvB,UAAU,GAAW,CAAC,CAAC;IACvB,UAAU,GAAW,CAAC,CAAC;IACvB,aAAa,GAAW,CAAC,CAAC;IAClC,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5E,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAClE,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,WAAW,CAAC,QAAgB,EAAE,IAAW;QAC9C,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC/B,IAAI,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC;YAAE,IAAI,CAAC,cAAc,EAAE,CAAC;QACpD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACpC,CAAC;IAEM,oBAAoB,CAAC,KAAc,EAAE,QAAgB,EAAE,OAAiB;QAC7E,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { Geometry } from \"../../Geometry\";\nimport { IStrokeHandler } from \"../../geometry3d/GeometryHandler\";\nimport { Point3d, Vector3d } from \"../../geometry3d/Point3dVector3d\";\nimport { Ray3d } from \"../../geometry3d/Ray3d\";\nimport { Newton1dUnboundedApproximateDerivative } from \"../../numerics/Newton\";\nimport { CurveExtendOptions, VariantCurveExtendParameter } from \"../CurveExtendMode\";\nimport { CurveLocationDetail } from \"../CurveLocationDetail\";\nimport { CurvePrimitive } from \"../CurvePrimitive\";\nimport { NewtonRtoRStrokeHandler } from \"./NewtonRtoRStrokeHandler\";\n\n/**\n * Context for searching for the closest point to a CurvePrimitive.\n * @internal\n */\nexport class ClosestPointStrokeHandler extends NewtonRtoRStrokeHandler implements IStrokeHandler {\n private _curve: CurvePrimitive | undefined;\n private _closestPoint: CurveLocationDetail | undefined;\n private _spacePoint: Point3d;\n private _extend: VariantCurveExtendParameter;\n private _fractionA: number = 0;\n private _functionA: number = 0;\n private _functionB: number = 0;\n private _fractionB: number = 0;\n private _numThisCurve: number = 0;\n // scratch vars for use within methods.\n private _workPoint: Point3d;\n private _workRay: Ray3d;\n private _newtonSolver: Newton1dUnboundedApproximateDerivative;\n\n public constructor(spacePoint: Point3d, extend: VariantCurveExtendParameter, result?: CurveLocationDetail) {\n super();\n this._spacePoint = spacePoint;\n this._workPoint = Point3d.create();\n this._workRay = Ray3d.createZero();\n this._closestPoint = result;\n this._extend = extend;\n this.startCurvePrimitive(undefined);\n this._newtonSolver = new Newton1dUnboundedApproximateDerivative(this);\n }\n\n public claimResult(): CurveLocationDetail | undefined {\n if (this._closestPoint) {\n this._newtonSolver.setX(this._closestPoint.fraction);\n this._curve = this._closestPoint.curve;\n if (this._newtonSolver.runIterations()) {\n let fraction = this._newtonSolver.getX();\n fraction = CurveExtendOptions.correctFraction(this._extend, fraction);\n this.announceSolutionFraction(fraction);\n }\n }\n return this._closestPoint;\n }\n\n public needPrimaryGeometryForStrokes() {\n return true;\n }\n\n public startCurvePrimitive(curve: CurvePrimitive | undefined) {\n this._curve = curve;\n this._fractionA = 0.0;\n this._numThisCurve = 0;\n this._functionA = 0.0;\n }\n\n public endCurvePrimitive() {\n }\n\n public announceIntervalForUniformStepStrokes(cp: CurvePrimitive, numStrokes: number, fraction0: number, fraction1: number): void {\n this.startCurvePrimitive(cp);\n this.announceSolutionFraction(0.0); // test start point as closest\n this.announceSolutionFraction(1.0); // test end point as closest\n if (numStrokes < 1) numStrokes = 1;\n const df = 1.0 / numStrokes;\n for (let i = 0; i <= numStrokes; i++) {\n const fraction = Geometry.interpolate(fraction0, i * df, fraction1);\n cp.fractionToPointAndDerivative(fraction, this._workRay);\n this.announceRay(fraction, this._workRay);\n }\n }\n\n private announceCandidate(cp: CurvePrimitive, fraction: number, point: Point3d) {\n const distance = this._spacePoint.distance(point);\n if (this._closestPoint && distance > this._closestPoint.a)\n return;\n this._closestPoint = CurveLocationDetail.createCurveFractionPoint(cp, fraction, point, this._closestPoint);\n this._closestPoint.a = distance;\n if (this._parentCurvePrimitive !== undefined)\n this._closestPoint.curve = this._parentCurvePrimitive;\n }\n\n public announceSegmentInterval(cp: CurvePrimitive, point0: Point3d, point1: Point3d, _numStrokes: number, fraction0: number, fraction1: number): void {\n let localFraction = this._spacePoint.fractionOfProjectionToLine(point0, point1, 0.0);\n // only consider extending the segment if the immediate caller says we are at endpoints ...\n if (!this._extend)\n localFraction = Geometry.clampToStartEnd(localFraction, 0.0, 1.0);\n else {\n if (fraction0 !== 0.0)\n localFraction = Math.max(localFraction, 0.0);\n if (fraction1 !== 1.0)\n localFraction = Math.min(localFraction, 1.0);\n }\n this._workPoint = point0.interpolate(localFraction, point1);\n const globalFraction = Geometry.interpolate(fraction0, localFraction, fraction1);\n this.announceCandidate(cp, globalFraction, this._workPoint);\n }\n\n private searchInterval() {\n if (this._functionA * this._functionB > 0) return;\n if (this._functionA === 0) this.announceSolutionFraction(this._fractionA);\n if (this._functionB === 0) this.announceSolutionFraction(this._fractionB);\n if (this._functionA * this._functionB < 0) {\n const fraction = Geometry.inverseInterpolate(this._fractionA, this._functionA, this._fractionB, this._functionB);\n if (fraction) {\n this._newtonSolver.setX(fraction);\n if (this._newtonSolver.runIterations())\n this.announceSolutionFraction(this._newtonSolver.getX());\n }\n }\n }\n\n private evaluateB(fractionB: number, dataB: Ray3d) {\n this._functionB = dataB.dotProductToPoint(this._spacePoint);\n this._fractionB = fractionB;\n }\n\n private announceSolutionFraction(fraction: number) {\n if (this._curve)\n this.announceCandidate(this._curve, fraction, this._curve.fractionToPoint(fraction));\n }\n\n public evaluate(fraction: number): boolean {\n let curve = this._curve;\n if (this._parentCurvePrimitive)\n curve = this._parentCurvePrimitive;\n if (curve) {\n this._workRay = curve.fractionToPointAndDerivative(fraction, this._workRay);\n this.currentF = this._workRay.dotProductToPoint(this._spacePoint);\n return true;\n }\n return false;\n }\n\n public announceRay(fraction: number, data: Ray3d): void {\n this.evaluateB(fraction, data);\n if (this._numThisCurve++ > 0) this.searchInterval();\n this._functionA = this._functionB;\n this._fractionA = this._fractionB;\n }\n\n public announcePointTangent(point: Point3d, fraction: number, tangent: Vector3d) {\n this._workRay.set(point, tangent);\n this.announceRay(fraction, this._workRay);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ClosestPointStrokeHandler.js","sourceRoot":"","sources":["../../../../src/curve/internalContexts/ClosestPointStrokeHandler.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAY,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,sCAAsC,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAA+B,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;GAGG;AACH,MAAM,OAAO,yBAA0B,SAAQ,uBAAuB;IAC5D,MAAM,CAA6B;IACnC,aAAa,CAAkC;IAC/C,WAAW,CAAU;IACrB,OAAO,CAA8B;IAC7C,iFAAiF;IACzE,UAAU,GAAW,CAAC,CAAC;IACvB,UAAU,GAAW,CAAC,CAAC;IAC/B,uFAAuF;IAC/E,UAAU,GAAW,CAAC,CAAC;IACvB,UAAU,GAAW,CAAC,CAAC;IACvB,aAAa,GAAW,CAAC,CAAC;IAClC,qCAAqC;IAC7B,UAAU,CAAU;IACpB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AAC,QAAgB;QAC9B,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QACxB,IAAI,IAAI,CAAC,qBAAqB;YAC5B,KAAK,GAAG,IAAI,CAAC,qBAAqB,CAAC;QACrC,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAChE,IAAI,KAAK,KAAK,SAAS;YACrB,OAAO,KAAK,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IACO,WAAW,CAAC,QAAgB,EAAE,IAAW;QAC/C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAE,CAAC;QAC/C,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC;QAC3B,IAAI,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,EAAE,oFAAoF;YAChH,IAAI,CAAC,cAAc,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IACpC,CAAC;IACM,oBAAoB,CAAC,KAAc,EAAE,QAAgB,EAAE,OAAiB;QAC7E,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAClC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { Geometry } from \"../../Geometry\";\nimport { IStrokeHandler } from \"../../geometry3d/GeometryHandler\";\nimport { Point3d, Vector3d } from \"../../geometry3d/Point3dVector3d\";\nimport { Ray3d } from \"../../geometry3d/Ray3d\";\nimport { Newton1dUnboundedApproximateDerivative } from \"../../numerics/Newton\";\nimport { CurveExtendOptions, VariantCurveExtendParameter } from \"../CurveExtendMode\";\nimport { CurveLocationDetail } from \"../CurveLocationDetail\";\nimport { CurvePrimitive } from \"../CurvePrimitive\";\nimport { NewtonRtoRStrokeHandler } from \"./NewtonRtoRStrokeHandler\";\n\n/**\n * Context for searching for the closest point to a CurvePrimitive.\n * @internal\n */\nexport class ClosestPointStrokeHandler extends NewtonRtoRStrokeHandler implements IStrokeHandler {\n private _curve: CurvePrimitive | undefined;\n private _closestPoint: CurveLocationDetail | undefined;\n private _spacePoint: Point3d;\n private _extend: VariantCurveExtendParameter;\n // fraction and function value on one side of an interval that may bracket a root\n private _fractionA: number = 0;\n private _functionA: number = 0;\n // fraction and function value on the other side of an interval that may bracket a root\n private _fractionB: number = 0;\n private _functionB: number = 0;\n private _numThisCurve: number = 0;\n // scratch vars to use within methods\n private _workPoint: Point3d;\n private _workRay: Ray3d;\n private _newtonSolver: Newton1dUnboundedApproximateDerivative;\n /** Constructor */\n public constructor(spacePoint: Point3d, extend?: VariantCurveExtendParameter, result?: CurveLocationDetail) {\n super();\n this._spacePoint = spacePoint;\n this._workPoint = Point3d.create();\n this._workRay = Ray3d.createZero();\n this._closestPoint = result;\n this._extend = extend ?? false;\n this.startCurvePrimitive(undefined);\n this._newtonSolver = new Newton1dUnboundedApproximateDerivative(this);\n }\n public claimResult(): CurveLocationDetail | undefined {\n if (this._closestPoint) {\n this._newtonSolver.setX(this._closestPoint.fraction);\n this._curve = this._closestPoint.curve;\n if (this._newtonSolver.runIterations()) {\n let fraction = this._newtonSolver.getX();\n fraction = CurveExtendOptions.correctFraction(this._extend, fraction);\n this.announceSolutionFraction(fraction);\n }\n }\n return this._closestPoint;\n }\n public needPrimaryGeometryForStrokes() {\n return true;\n }\n public startCurvePrimitive(curve: CurvePrimitive | undefined) {\n this._curve = curve;\n this._fractionA = 0.0;\n this._numThisCurve = 0;\n this._functionA = 0.0;\n }\n public endCurvePrimitive() {\n }\n public announceIntervalForUniformStepStrokes(\n cp: CurvePrimitive, numStrokes: number, fraction0: number, fraction1: number,\n ): void {\n this.startCurvePrimitive(cp);\n this.announceSolutionFraction(0.0); // test start point as closest\n this.announceSolutionFraction(1.0); // test end point as closest\n if (numStrokes < 1)\n numStrokes = 1;\n const df = 1.0 / numStrokes;\n for (let i = 0; i <= numStrokes; i++) {\n const fraction = Geometry.interpolate(fraction0, i * df, fraction1);\n cp.fractionToPointAndDerivative(fraction, this._workRay);\n this.announceRay(fraction, this._workRay);\n }\n }\n private announceCandidate(cp: CurvePrimitive, fraction: number, point: Point3d) {\n const distance = this._spacePoint.distance(point);\n if (this._closestPoint && distance > this._closestPoint.a)\n return;\n this._closestPoint = CurveLocationDetail.createCurveFractionPoint(cp, fraction, point, this._closestPoint);\n this._closestPoint.a = distance;\n if (this._parentCurvePrimitive !== undefined)\n this._closestPoint.curve = this._parentCurvePrimitive;\n }\n public announceSegmentInterval(\n cp: CurvePrimitive, point0: Point3d, point1: Point3d, _numStrokes: number, fraction0: number, fraction1: number,\n ): void {\n let localFraction = this._spacePoint.fractionOfProjectionToLine(point0, point1, 0.0);\n // only consider extending the segment if the immediate caller says we are at endpoints\n if (!this._extend)\n localFraction = Geometry.clampToStartEnd(localFraction, 0.0, 1.0);\n else {\n if (fraction0 !== 0.0)\n localFraction = Math.max(localFraction, 0.0);\n if (fraction1 !== 1.0)\n localFraction = Math.min(localFraction, 1.0);\n }\n this._workPoint = point0.interpolate(localFraction, point1);\n const globalFraction = Geometry.interpolate(fraction0, localFraction, fraction1);\n this.announceCandidate(cp, globalFraction, this._workPoint);\n }\n /**\n * Given a function `f` and (unordered) fractions `a` and `b`, search for and announce a root of `f` in this\n * fractional interval.\n * * This method searches for a root of `f` if and only if the stroke segment defined by `(a, f(a))` and\n * `(b, f(b))` has a root. This is a HEURISTIC: given continuous `f` between `a` and `b`, a root of the stroke\n * segment implies a root of `f`, but not vice-versa. Therefore, if the strokes are not sufficiently dense,\n * this method can miss a root of `f`.\n */\n private searchInterval() {\n if (this._functionA * this._functionB > 0)\n return; // stroke segment has no root; ASSUME the function has no root either\n if (this._functionA === 0)\n this.announceSolutionFraction(this._fractionA);\n if (this._functionB === 0)\n this.announceSolutionFraction(this._fractionB);\n // by the Intermediate Value Theorem, a root lies between fractionA and fractionB; use Newton to find it.\n if (this._functionA * this._functionB < 0) {\n const fraction = Geometry.inverseInterpolate(this._fractionA, this._functionA, this._fractionB, this._functionB);\n if (fraction) {\n this._newtonSolver.setX(fraction);\n if (this._newtonSolver.runIterations())\n this.announceSolutionFraction(this._newtonSolver.getX());\n }\n }\n }\n private announceSolutionFraction(fraction: number) {\n if (this._curve)\n this.announceCandidate(this._curve, fraction, this._curve.fractionToPoint(fraction));\n }\n /**\n * Evaluate the univariate real-valued function for which we are finding roots.\n * * For finding the closest point to curve X from point Q, this function is `f(t) := Q-X(t) dot X'(t)`.\n * * Either `pointAndDerivative` must be defined, or both `fraction` and `curve`.\n * @param pointAndDerivative pre-evaluated curve\n * @param fraction fraction at which to evaluate `curve`\n * @param curve curve to evaluate at `fraction`\n */\n private evaluateFunction(pointAndDerivative?: Ray3d, fraction?: number, curve?: CurvePrimitive): number | undefined {\n if (pointAndDerivative)\n this._workRay.setFrom(pointAndDerivative);\n else if (fraction !== undefined && curve)\n this._workRay = curve.fractionToPointAndDerivative(fraction, this._workRay);\n else\n return undefined;\n return this._workRay.dotProductToPoint(this._spacePoint);\n }\n public evaluate(fraction: number): boolean {\n let curve = this._curve;\n if (this._parentCurvePrimitive)\n curve = this._parentCurvePrimitive;\n const value = this.evaluateFunction(undefined, fraction, curve);\n if (value === undefined)\n return false;\n this.currentF = value;\n return true;\n }\n private announceRay(fraction: number, data: Ray3d): void {\n this._functionB = this.evaluateFunction(data)!;\n this._fractionB = fraction;\n if (this._numThisCurve++ > 0) // after the first stroke point, a stroke segment is defined, so we have an interval\n this.searchInterval();\n this._functionA = this._functionB;\n this._fractionA = this._fractionB;\n }\n public announcePointTangent(point: Point3d, fraction: number, tangent: Vector3d) {\n this._workRay.set(point, tangent);\n this.announceRay(fraction, this._workRay);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurveCurveIntersectXY.d.ts","sourceRoot":"","sources":["../../../../src/curve/internalContexts/CurveCurveIntersectXY.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,cAAc,EAAsB,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAQlF,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAMrD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAC;AAE7E,OAAO,EAA0C,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACzG,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAK/C;;;;;GAKG;AACH,qBAAa,qBAAsB,SAAQ,8BAA8B;IACvE,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,wBAAwB,CAAuB;IACvD,OAAO,CAAC,mBAAmB,CAAwB;IACnD,OAAO,CAAC,0BAA0B,CAA0B;IAC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E,QAAQ,EAAE,OAAO,EACvD,QAAQ,EAAE,OAAO,GAChB,GAAG;IAqBN,iEAAiE;IACjE,OAAO,CAAC,2BAA2B;IAiCnC,OAAO,CAAC,MAAM,CAAC,wBAAwB;IAQvC;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAyB/B;;;OAGG;IACH,OAAO,CAAC,mCAAmC;IAe3C;;;OAGG;IACa,cAAc,CAAC,CAAC,EAAE,aAAa,GAAG,GAAG;IAqBrD,0DAA0D;IAC1C,mBAAmB,CAAC,QAAQ,EAAE,aAAa,GAAG,GAAG;IA6BjE,6DAA6D;IAC7C,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,GAAG;IAuB1D,sDAAsD;IACtC,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,GAAG;IAuB7C,gEAAgE;IAChD,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,GAAG;IAsBhE,8EAA8E;IAC9D,iCAAiC,CAAC,KAAK,EAAE,2BAA2B,GAAG,GAAG;IAK1F,4EAA4E;IAC5D,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,GAAG;CAgBpE"}
|
|
@@ -258,6 +258,8 @@ export class CurveCurveIntersectXY extends RecurseToCurvesGeometryHandler {
|
|
|
258
258
|
// The line segment in question might be (a) a full line segment or (b) a fragment within a linestring.
|
|
259
259
|
// The fraction and extend parameters allow all combinations to be passed in.
|
|
260
260
|
dispatchSegmentArc(cpA, extendA0, pointA0, fractionA0, pointA1, fractionA1, extendA1, arc, extendB0, extendB1, reversed) {
|
|
261
|
+
const tol2 = this._coincidentGeometryContext.tolerance * this._coincidentGeometryContext.tolerance;
|
|
262
|
+
let dist2;
|
|
261
263
|
// Arc: X = C + cU + sV
|
|
262
264
|
// Line: contains points A0,A1
|
|
263
265
|
// Arc point colinear with line if det (A0, A1, X) = 0
|
|
@@ -268,6 +270,10 @@ export class CurveCurveIntersectXY extends RecurseToCurvesGeometryHandler {
|
|
|
268
270
|
// project back to line.
|
|
269
271
|
if (this._worldToLocalPerspective) {
|
|
270
272
|
const data = arc.toTransformedPoint4d(this._worldToLocalPerspective);
|
|
273
|
+
const radians0 = data.sweep.fractionToRadians(0);
|
|
274
|
+
const pointB0H = data.center.plus2Scaled(data.vector0, Math.cos(radians0), data.vector90, Math.sin(radians0));
|
|
275
|
+
const radians1 = data.sweep.fractionToRadians(1);
|
|
276
|
+
const pointB1H = data.center.plus2Scaled(data.vector0, Math.cos(radians1), data.vector90, Math.sin(radians1));
|
|
271
277
|
const pointA0H = this._worldToLocalPerspective.multiplyPoint3d(pointA0, 1);
|
|
272
278
|
const pointA1H = this._worldToLocalPerspective.multiplyPoint3d(pointA1, 1);
|
|
273
279
|
const alpha = Geometry.tripleProductPoint4dXYW(pointA0H, pointA1H, data.center);
|
|
@@ -277,19 +283,31 @@ export class CurveCurveIntersectXY extends RecurseToCurvesGeometryHandler {
|
|
|
277
283
|
const sines = new GrowableFloat64Array(2);
|
|
278
284
|
const radians = new GrowableFloat64Array(2);
|
|
279
285
|
const numRoots = AnalyticRoots.appendImplicitLineUnitCircleIntersections(alpha, beta, gamma, cosines, sines, radians);
|
|
286
|
+
if (numRoots <= 0)
|
|
287
|
+
return;
|
|
280
288
|
for (let i = 0; i < numRoots; i++) {
|
|
281
289
|
const arcPoint = data.center.plus2Scaled(data.vector0, cosines.atUncheckedIndex(i), data.vector90, sines.atUncheckedIndex(i));
|
|
282
|
-
|
|
290
|
+
let arcFraction = data.sweep.radiansToSignedFraction(radians.atUncheckedIndex(i), extendB0);
|
|
283
291
|
const lineFraction = SmallSystem.lineSegment3dHXYClosestPointUnbounded(pointA0H, pointA1H, arcPoint);
|
|
284
|
-
if (lineFraction !== undefined
|
|
285
|
-
this.acceptFraction(extendA0, lineFraction, extendA1) &&
|
|
286
|
-
|
|
287
|
-
|
|
292
|
+
if (lineFraction !== undefined) {
|
|
293
|
+
if (this.acceptFraction(extendA0, lineFraction, extendA1) && this.acceptFraction(extendB0, arcFraction, extendB1)) {
|
|
294
|
+
this.recordPointWithLocalFractions(lineFraction, cpA, fractionA0, fractionA1, arcFraction, arc, 0, 1, reversed);
|
|
295
|
+
}
|
|
296
|
+
else { // check for endpoint intersections beyond parametric tolerance but within point tolerance
|
|
297
|
+
const pointAH = lineFraction < 0.5 ? pointA0H : pointA1H;
|
|
298
|
+
const pointBH = (arcFraction = data.sweep.fractionToSignedPeriodicFraction(arcFraction)) < 0.5 ? pointB0H : pointB1H;
|
|
299
|
+
if ((dist2 = pointAH.realDistanceSquaredXY(pointBH)) !== undefined && Geometry.isDistanceWithinTol(dist2, tol2))
|
|
300
|
+
this.recordPointWithLocalFractions(lineFraction < 0.5 ? 0 : 1, cpA, fractionA0, fractionA1, arcFraction < 0.5 ? 0 : 1, arc, 0, 1, reversed);
|
|
301
|
+
}
|
|
288
302
|
}
|
|
289
303
|
}
|
|
290
304
|
}
|
|
291
305
|
else {
|
|
292
306
|
const data = arc.toTransformedVectors(this._worldToLocalAffine);
|
|
307
|
+
const radians0 = data.sweep.fractionToRadians(0);
|
|
308
|
+
const pointB0Local = data.center.plus2Scaled(data.vector0, Math.cos(radians0), data.vector90, Math.sin(radians0));
|
|
309
|
+
const radians1 = data.sweep.fractionToRadians(1);
|
|
310
|
+
const pointB1Local = data.center.plus2Scaled(data.vector0, Math.cos(radians1), data.vector90, Math.sin(radians1));
|
|
293
311
|
let pointA0Local = pointA0;
|
|
294
312
|
let pointA1Local = pointA1;
|
|
295
313
|
if (this._worldToLocalAffine) {
|
|
@@ -303,16 +321,22 @@ export class CurveCurveIntersectXY extends RecurseToCurvesGeometryHandler {
|
|
|
303
321
|
const sines = new GrowableFloat64Array(2);
|
|
304
322
|
const radians = new GrowableFloat64Array(2);
|
|
305
323
|
const numRoots = AnalyticRoots.appendImplicitLineUnitCircleIntersections(alpha, beta, gamma, cosines, sines, radians);
|
|
306
|
-
|
|
307
|
-
|
|
324
|
+
if (numRoots <= 0)
|
|
325
|
+
return;
|
|
308
326
|
for (let i = 0; i < numRoots; i++) {
|
|
309
327
|
const arcPoint = data.center.plus2Scaled(data.vector0, cosines.atUncheckedIndex(i), data.vector90, sines.atUncheckedIndex(i));
|
|
310
|
-
|
|
328
|
+
let arcFraction = data.sweep.radiansToSignedFraction(radians.atUncheckedIndex(i), extendB0);
|
|
311
329
|
const lineFraction = SmallSystem.lineSegment3dXYClosestPointUnbounded(pointA0Local, pointA1Local, arcPoint);
|
|
312
|
-
if (lineFraction !== undefined
|
|
313
|
-
this.acceptFraction(extendA0, lineFraction, extendA1,
|
|
314
|
-
|
|
315
|
-
|
|
330
|
+
if (lineFraction !== undefined) {
|
|
331
|
+
if (this.acceptFraction(extendA0, lineFraction, extendA1) && this.acceptFraction(extendB0, arcFraction, extendB1)) {
|
|
332
|
+
this.recordPointWithLocalFractions(lineFraction, cpA, fractionA0, fractionA1, arcFraction, arc, 0, 1, reversed);
|
|
333
|
+
}
|
|
334
|
+
else { // check for endpoint intersections beyond parametric tolerance but within point tolerance
|
|
335
|
+
const pointALocal = lineFraction < 0.5 ? pointA0Local : pointA1Local;
|
|
336
|
+
const pointBLocal = (arcFraction = data.sweep.fractionToSignedPeriodicFraction(arcFraction)) < 0.5 ? pointB0Local : pointB1Local;
|
|
337
|
+
if ((dist2 = pointALocal.distanceSquaredXY(pointBLocal)) !== undefined && Geometry.isDistanceWithinTol(dist2, tol2))
|
|
338
|
+
this.recordPointWithLocalFractions(lineFraction < 0.5 ? 0 : 1, cpA, fractionA0, fractionA1, arcFraction < 0.5 ? 0 : 1, arc, 0, 1, reversed);
|
|
339
|
+
}
|
|
316
340
|
}
|
|
317
341
|
}
|
|
318
342
|
}
|