import { BSplineCurve3d } from "../../bspline/BSplineCurve"; import { BSplineCurve3dH } from "../../bspline/BSplineCurve3dH"; import { RecurseToCurvesGeometryHandler } from "../../geometry3d/GeometryHandler"; import { Arc3d } from "../Arc3d"; import { CurveChainWithDistanceIndex } from "../CurveChainWithDistanceIndex"; import { CurveLocationDetailPair } from "../CurveLocationDetail"; import { AnyCurve } from "../CurveTypes"; import { LineSegment3d } from "../LineSegment3d"; import { LineString3d } from "../LineString3d"; import { TransitionSpiral3d } from "../spiral/TransitionSpiral3d"; /** * Handler class for XY close approach between _geometryB and another geometry. * * Approach means the XY distance (z is ignored) between _geometryB and another geometry. * * Closest approach is a measure of the proximity of one curve to another. It's the length of the shortest line * segment perpendicular to both curves; if the curves intersect, the closest approach is zero. In the context of * this class, z-coordinates are ignored, so the closest approach is as seen in the top view. If you have coplanar * input curves and want to find closest approach in their plane, rotate them first into a plane parallel to the * xy-plane, then afterward, rotate the results back as required. * * Close approach can also be from a curve endpoint perpendicular to another curve or from a curve endpoint to * another curve endpoint. * * Instances are initialized and called from CurveCurve. * * geometryB is saved for later reference. * @internal */ export declare class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler { private _geometryB; /** * Maximum XY distance (z is ignored). Approach larger than this is not interesting. * This is caller defined and can be undefined. */ private _maxDistanceToAccept; /** Squared max distance. Default is [[Geometry.smallMetricDistanceSquared]]. */ private _maxDistanceSquared; private _xyTolerance; private _newtonTolerance; private _maxIterations; /** * Start and end points of line segments that meet closest approach criteria, i.e., they are perpendicular to * both curves and their length is smaller than _maxDistanceToAccept. */ private _results; private static _workPointAA0; private static _workPointAA1; private static _workPointBB0; private static _workPointBB1; private static _workPointB; /** * Constructor. * @param geometryB second curve for intersection. Saved for reference by specific handler methods. * @param xyTolerance optional tolerance for comparing xy points (default [[Geometry.smallMetricDistance]]). * @param newtonTolerance optional relative fraction tolerance for Newton iteration (default [[Geometry.smallNewtonStep]]). * @param maxIterations optional max iterations for Newton iteration (default 50). */ constructor(geometryB?: AnyCurve, xyTolerance?: number, newtonTolerance?: number, maxIterations?: number); /** Set the (possibly undefined) max XY distance (z is ignored) to accept. */ set maxDistanceToAccept(value: number | undefined); /** Access the (possibly undefined) max XY distance (z is ignored) to accept. */ get maxDistanceToAccept(): number | undefined; /** Ask if the maxDistanceToAccept value is defined and positive */ get isMaxDistanceSet(): boolean; /** * Reset the geometry. * * Undefined inputs are ignored. * * All other instance data is unchanged, including accumulated intersections. */ resetGeometry(geometryB?: AnyCurve): void; /** returns true if `fraction` is in [0,1] within tolerance */ private acceptFraction; /** Extract (and clear) the results, structured as an array of CurveLocationDetailPair. */ grabPairedResults(): CurveLocationDetailPair[]; /** * Create and record a close-approach pair from raw curve/fraction/point data. * * If points are undefined, they are computed from the fractions via `fractionToPoint`. * * Fractions are global (i.e., relative to the full curve, not a sub-segment). * * The pair is recorded only if the XY distance is within `_maxDistanceSquared`. * @param cpA first curve * @param fA global fraction on cpA * @param pointA point on cpA at fA, or undefined to compute from fA * @param cpB second curve * @param fB global fraction on cpB * @param pointB point on cpB at fB, or undefined to compute from fB * @param reversed if true, swap detailA and detailB before recording */ private testAndRecordPointPair; /** * Record a pre-built close-approach pair with global fractions already set. * * Computes and stores the XY distance on both details. * * The pair is recorded only if the XY distance is within `_maxDistanceSquared`. * @param pair details with global fractions and points already set; modified in place * @param reversed if true, swap detailA and detailB before recording */ private testAndRecordPair; /** * Convert a close-approach pair from local (sub-segment) fractions to global fractions, then record it. * * Local fractions in the pair are interpolated into the global fraction ranges. * * Points are recomputed from the parent curves at the global fractions. * * The pair is recorded only if the XY distance is within `_maxDistanceSquared`. * @param pair local details (curve unspecified); modified in place with global fractions, curves, and points * @param cpA parent curve A * @param fractionA0 global fraction corresponding to local fraction 0 on curve A * @param fractionA1 global fraction corresponding to local fraction 1 on curve A * @param cpB parent curve B * @param fractionB0 global fraction corresponding to local fraction 0 on curve B * @param fractionB1 global fraction corresponding to local fraction 1 on curve B * @param reversed if true, swap detailA and detailB before recording */ private testAndRecordLocalPair; /** Modify the current closest approach if the inputs are closer. */ private static updatePointToSegmentDistance; /** * Return fractions of close approach within maxDistance between two line segments (a0,a1) and (b0,b1). * * Math details can be found at core/geometry/internaldocs/Curve.md * @param a0 start point of line a * @param a1 end point of line a * @param b0 start point of line b * @param b1 end point of line b * @param maxDistanceSquared maximum distance squared (assumed to be positive) * @returns a pair of details for the closest approach, or `undefined` if no approach is within `maxDistanceSquared`. * `detailA.fraction` is the fraction on segment a; `detailB.fraction` is the fraction on segment b. Returned * details store the *squared* distance in the `a` property. */ private static segmentSegmentBoundedApproach; /** * Compute closest approaches from the endpoints of each curve (if open) to the other curve. * Record a [[CurveLocationDetailPair]] if such a distance is less than [[maxDistance]]. * @param cpA curveA * @param cpB curveB * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to curveA). */ private testAndRecordEndPointApproaches; /** Find the closest xy approach between `pointA` and `cpB`. */ private testAndRecordProjection; /** * Compute closest xy approach of two line segments. * Filter by extension rules. * Record with fraction mapping. * * The fraction mappings allow portions of a linestring to be passed here. */ private computeSegmentSegment; /** * Compute the perpendiculars between a line segment and an arc, without extending either curve. * * One or two perpendiculars will be found. * * Each perpendicular segment starts or ends on the arc where the arc tangent is parallel to the line tangent. * @param startA line segment start point * @param endA line segment end point * @param arcB the arc * @param announce callback to receive line and arc fractions and optional points of each perpendicular segment computed. */ private announceAllPerpendicularsSegmentArcBounded; /** * Find close approaches within maxDistance between a line segment and an arc. * To consider: * 1) intersection between arc and segment. * 2) endpoints to endpoints, or endpoints projection to the other curve. * 3) arc tangent parallel to line segment * @param lineA the line segment * @param arcB the arc * @param reversed whether to reverse the details in the pair (e.g., so that detailB refers to arcA). */ private computeSegmentArc; /** * Compute segments perpendicular to two elliptical arcs, without extending either curve. * * Perpendiculars from an endpoint are not explicitly computed. * * Intersections are also found by this search: they are reported as zero-length segments. * @param arcA first arc * @param arcB second arc * @param reversed swap the details in the recorded pair (default: false) */ allPerpendicularsArcArcBounded(arcA: Arc3d, arcB: Arc3d, reversed?: boolean): void; /** Low level dispatch of arc with Arc3d. */ private dispatchArcArc; /** Detail computation for segment approaching linestring. */ private computeSegmentLineString; /** Detail computation for arc approaching linestring. */ private computeArcLineString; /** * Set bits for comparison to range xy * * bit 0x01 => x smaller than range.low.x * * bit 0x02 => x larger than range.high.x * * bit 0x04 => y smaller than range.low.y * * bit 0x08 => y larger than range.high.y * * If we divide XY plane into 9 areas using the range, the function returns 0 for points * inside the range. Below is other binary numbers returned by the function for all 9 areas: * 1001 | 1000 | 1010 * ------------------ * 1 | 0 | 10 * ------------------ * 101 | 100 | 110 * @param xy point to test * @param range range for comparison */ private classifyBitsPointRangeXY; /** Low level dispatch of line string with line string. */ private computeLineStringLineString; /** Low level dispatch of curve collection. */ private dispatchCurveCollection; /** Low level dispatch to geomA given a CurveChainWithDistanceIndex in geometryB. */ private dispatchCurveChainWithDistanceIndex; /** Specifies whether the curve needs to be stroked for close approach computation. */ private needsStroking; /** * Process seeds for xy close approach between one curve and another curve. * * Seeds typically result from solving a discrete close approach problem, where one or both curves have been stroked. * * Refine each result via Newton iteration. If it doesn't converge, remove it. * @param seeds the initial seed results to refine. * @param curveA curve to find its XY close approach with curveB. * @param curveAIsStroked whether `seeds` contains results from a linestring approximation to `curveA` * @param curveB the other curve. * @param curveBIsStroked whether `seeds` contains results from a linestring approximation to `curveB` * @param reversed whether `curveB` data is in `detailA` of each recorded pair, and `curveA` data in `detailB`. */ private refineStrokedResultsByNewton; /** * Append stroke points and return the line string. * * This is a convenient wrapper for [[CurvePrimitive.emitStrokes]] but the analogous instance method cannot be added * to that class due to the ensuing recursion with subclass [[LineString3d]]. * @param options options for stroking the instance curve. * @param result object to receive appended stroke points; if omitted, a new object is created, populated, and returned. */ private strokeCurve; /** Find and return the close approaches between curveA and the discretization of curveB. */ private computeDiscreteCloseApproachResults; /** * Compute the XY close approach of a curve and another curve to be stroked. * @param curveA curve to find its XY close approach with curveB. * @param curveB the other curve, to be stroked. * @param reversed whether `curveB` data will be recorded in `detailA` of each result, and `curveA` data in `detailB`. */ private dispatchCurveStrokedCurve; /** Double dispatch handler for strongly typed segment. */ handleLineSegment3d(segmentA: LineSegment3d): any; /** Double dispatch handler for strongly typed linestring. */ handleLineString3d(lsA: LineString3d): any; /** Double dispatch handler for strongly typed arc. */ handleArc3d(arcA: Arc3d): any; /** Double dispatch handler for strongly typed bspline curve. */ handleBSplineCurve3d(curveA: BSplineCurve3d): any; /** Double dispatch handler for strongly typed spiral curve. */ handleTransitionSpiral(spiral: TransitionSpiral3d): any; /** Double dispatch handler for strongly typed CurveChainWithDistanceIndex. */ handleCurveChainWithDistanceIndex(chain: CurveChainWithDistanceIndex): any; /** Double dispatch handler for strongly typed homogeneous bspline curve .. */ handleBSplineCurve3dH(_curve: BSplineCurve3dH): any; } //# sourceMappingURL=CurveCurveCloseApproachXY.d.ts.map