@itwin/core-geometry 4.2.0-dev.17 → 4.2.0-dev.18
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 +6 -1
- package/lib/cjs/clipping/ClipUtils.d.ts +1 -1
- package/lib/cjs/clipping/ClipUtils.js.map +1 -1
- package/lib/cjs/core-geometry.d.ts +1 -1
- package/lib/cjs/core-geometry.js +1 -1
- package/lib/cjs/core-geometry.js.map +1 -1
- package/lib/cjs/curve/Arc3d.js +4 -4
- package/lib/cjs/curve/Arc3d.js.map +1 -1
- package/lib/cjs/curve/CurveCollection.d.ts +2 -15
- package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCollection.js +1 -18
- package/lib/cjs/curve/CurveCollection.js.map +1 -1
- package/lib/cjs/curve/CurveCurve.d.ts +4 -1
- package/lib/cjs/curve/CurveCurve.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCurve.js +3 -0
- package/lib/cjs/curve/CurveCurve.js.map +1 -1
- package/lib/cjs/curve/CurveFactory.d.ts +1 -1
- package/lib/cjs/curve/CurveFactory.js.map +1 -1
- package/lib/cjs/curve/CurveOps.d.ts +1 -1
- package/lib/cjs/curve/CurveOps.js.map +1 -1
- package/lib/cjs/curve/CurveProcessor.d.ts +1 -1
- package/lib/cjs/curve/CurveProcessor.js.map +1 -1
- package/lib/cjs/curve/{CurveChain.d.ts → CurveTypes.d.ts} +6 -6
- package/lib/cjs/curve/CurveTypes.d.ts.map +1 -0
- package/lib/cjs/curve/{CurveChain.js → CurveTypes.js} +1 -1
- package/lib/cjs/curve/CurveTypes.js.map +1 -0
- package/lib/cjs/curve/CurveWireMomentsXYZ.d.ts +1 -1
- package/lib/cjs/curve/CurveWireMomentsXYZ.js.map +1 -1
- package/lib/cjs/curve/ParityRegion.d.ts +1 -1
- package/lib/cjs/curve/ParityRegion.js.map +1 -1
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts +3 -2
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js +2 -2
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
- package/lib/cjs/curve/Query/CurveSplitContext.d.ts +1 -1
- package/lib/cjs/curve/Query/CurveSplitContext.js.map +1 -1
- package/lib/cjs/curve/Query/CylindricalRange.d.ts +1 -1
- package/lib/cjs/curve/Query/CylindricalRange.js.map +1 -1
- package/lib/cjs/curve/Query/InOutTests.d.ts +1 -1
- package/lib/cjs/curve/Query/InOutTests.js.map +1 -1
- package/lib/cjs/curve/Query/StrokeCountChain.d.ts +1 -1
- package/lib/cjs/curve/Query/StrokeCountChain.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +16 -2
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +18 -1
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/cjs/curve/UnionRegion.d.ts +1 -1
- package/lib/cjs/curve/UnionRegion.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +19 -10
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +69 -62
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
- package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts +1 -1
- package/lib/cjs/curve/internalContexts/MultiChainCollector.js.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +0 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +0 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/SortablePolygon.d.ts +1 -1
- package/lib/cjs/geometry3d/SortablePolygon.js.map +1 -1
- package/lib/cjs/geometry3d/YawPitchRollAngles.js +1 -1
- package/lib/cjs/geometry3d/YawPitchRollAngles.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
- package/lib/cjs/solid/LinearSweep.d.ts +1 -1
- package/lib/cjs/solid/LinearSweep.js.map +1 -1
- package/lib/cjs/solid/RotationalSweep.d.ts +1 -1
- package/lib/cjs/solid/RotationalSweep.js.map +1 -1
- package/lib/cjs/solid/RuledSweep.d.ts +1 -1
- package/lib/cjs/solid/RuledSweep.js.map +1 -1
- package/lib/cjs/solid/SweepContour.d.ts +1 -1
- package/lib/cjs/solid/SweepContour.js.map +1 -1
- package/lib/esm/clipping/ClipUtils.d.ts +1 -1
- package/lib/esm/clipping/ClipUtils.js.map +1 -1
- package/lib/esm/core-geometry.d.ts +1 -1
- package/lib/esm/core-geometry.js +1 -1
- package/lib/esm/core-geometry.js.map +1 -1
- package/lib/esm/curve/Arc3d.js +4 -4
- package/lib/esm/curve/Arc3d.js.map +1 -1
- package/lib/esm/curve/CurveCollection.d.ts +2 -15
- package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
- package/lib/esm/curve/CurveCollection.js +0 -16
- package/lib/esm/curve/CurveCollection.js.map +1 -1
- package/lib/esm/curve/CurveCurve.d.ts +4 -1
- package/lib/esm/curve/CurveCurve.d.ts.map +1 -1
- package/lib/esm/curve/CurveCurve.js +3 -0
- package/lib/esm/curve/CurveCurve.js.map +1 -1
- package/lib/esm/curve/CurveFactory.d.ts +1 -1
- package/lib/esm/curve/CurveFactory.js.map +1 -1
- package/lib/esm/curve/CurveOps.d.ts +1 -1
- package/lib/esm/curve/CurveOps.js.map +1 -1
- package/lib/esm/curve/CurveProcessor.d.ts +1 -1
- package/lib/esm/curve/CurveProcessor.js.map +1 -1
- package/lib/esm/curve/{CurveChain.d.ts → CurveTypes.d.ts} +6 -6
- package/lib/esm/curve/CurveTypes.d.ts.map +1 -0
- package/lib/esm/curve/{CurveChain.js → CurveTypes.js} +1 -1
- package/lib/esm/curve/CurveTypes.js.map +1 -0
- package/lib/esm/curve/CurveWireMomentsXYZ.d.ts +1 -1
- package/lib/esm/curve/CurveWireMomentsXYZ.js.map +1 -1
- package/lib/esm/curve/ParityRegion.d.ts +1 -1
- package/lib/esm/curve/ParityRegion.js.map +1 -1
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts +3 -2
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js +1 -1
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
- package/lib/esm/curve/Query/CurveSplitContext.d.ts +1 -1
- package/lib/esm/curve/Query/CurveSplitContext.js.map +1 -1
- package/lib/esm/curve/Query/CylindricalRange.d.ts +1 -1
- package/lib/esm/curve/Query/CylindricalRange.js.map +1 -1
- package/lib/esm/curve/Query/InOutTests.d.ts +1 -1
- package/lib/esm/curve/Query/InOutTests.js.map +1 -1
- package/lib/esm/curve/Query/StrokeCountChain.d.ts +1 -1
- package/lib/esm/curve/Query/StrokeCountChain.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +16 -2
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +16 -0
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/esm/curve/UnionRegion.d.ts +1 -1
- package/lib/esm/curve/UnionRegion.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +19 -10
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +70 -63
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -1
- package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts +1 -1
- package/lib/esm/curve/internalContexts/MultiChainCollector.js.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +0 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +0 -1
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/SortablePolygon.d.ts +1 -1
- package/lib/esm/geometry3d/SortablePolygon.js.map +1 -1
- package/lib/esm/geometry3d/YawPitchRollAngles.js +1 -1
- package/lib/esm/geometry3d/YawPitchRollAngles.js.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.d.ts +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
- package/lib/esm/solid/LinearSweep.d.ts +1 -1
- package/lib/esm/solid/LinearSweep.js.map +1 -1
- package/lib/esm/solid/RotationalSweep.d.ts +1 -1
- package/lib/esm/solid/RotationalSweep.js.map +1 -1
- package/lib/esm/solid/RuledSweep.d.ts +1 -1
- package/lib/esm/solid/RuledSweep.js.map +1 -1
- package/lib/esm/solid/SweepContour.d.ts +1 -1
- package/lib/esm/solid/SweepContour.js.map +1 -1
- package/package.json +3 -3
- package/lib/cjs/curve/CurveChain.d.ts.map +0 -1
- package/lib/cjs/curve/CurveChain.js.map +0 -1
- package/lib/esm/curve/CurveChain.d.ts.map +0 -1
- package/lib/esm/curve/CurveChain.js.map +0 -1
|
@@ -13,7 +13,7 @@ import { Point3d, Vector3d } from "../../geometry3d/Point3dVector3d";
|
|
|
13
13
|
import { Range3d } from "../../geometry3d/Range";
|
|
14
14
|
import { AnalyticRoots, SmallSystem } from "../../numerics/Polynomials";
|
|
15
15
|
import { Arc3d } from "../Arc3d";
|
|
16
|
-
import {
|
|
16
|
+
import { CurveCollection } from "../CurveCollection";
|
|
17
17
|
import { CurveIntervalRole, CurveLocationDetail, CurveLocationDetailPair } from "../CurveLocationDetail";
|
|
18
18
|
import { LineSegment3d } from "../LineSegment3d";
|
|
19
19
|
import { LineString3d } from "../LineString3d";
|
|
@@ -257,7 +257,7 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
257
257
|
fractionB = 1;
|
|
258
258
|
this._workPointB = pointB0.interpolate(fractionB, pointB1, this._workPointB);
|
|
259
259
|
const distanceSquared = this._workPointB.distanceSquaredXY(pointA);
|
|
260
|
-
if (distanceSquared
|
|
260
|
+
if (distanceSquared <= Math.min(maxDistanceSquared, closestApproach.detailA.a)) {
|
|
261
261
|
closestApproach.detailA.setFP(fractionA, pointA, undefined, distanceSquared);
|
|
262
262
|
closestApproach.detailB.setFP(fractionB, this._workPointB, undefined, distanceSquared);
|
|
263
263
|
updated = true;
|
|
@@ -300,23 +300,23 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
300
300
|
closestApproach.detailA.a = 2 * maxDistanceSquared; // init to an approach that's too far away
|
|
301
301
|
let reversed = false;
|
|
302
302
|
const uu = Geometry.hypotenuseSquaredXY(ux, uy);
|
|
303
|
-
if (hab0 * hab0
|
|
303
|
+
if (hab0 * hab0 <= maxDistanceSquared * uu) { // test distance of b0 to u
|
|
304
304
|
const fractionA = Geometry.dotProductXYXY(ux, uy, e00x, e00y) / uu;
|
|
305
305
|
if (this.updatePointToSegmentDistance(0, b0, a0, a1, fractionA, maxDistanceSquared, closestApproach))
|
|
306
306
|
reversed = true;
|
|
307
307
|
}
|
|
308
|
-
if (hab1 * hab1
|
|
308
|
+
if (hab1 * hab1 <= maxDistanceSquared * uu) { // test distance of b1 to u
|
|
309
309
|
const fractionA = Geometry.dotProductXYXY(ux, uy, e01x, e01y) / uu;
|
|
310
310
|
if (this.updatePointToSegmentDistance(1, b1, a0, a1, fractionA, maxDistanceSquared, closestApproach))
|
|
311
311
|
reversed = true;
|
|
312
312
|
}
|
|
313
313
|
const vv = Geometry.hypotenuseSquaredXY(vx, vy);
|
|
314
|
-
if (hba0 * hba0
|
|
314
|
+
if (hba0 * hba0 <= maxDistanceSquared * vv) { // test distance of a0 to v
|
|
315
315
|
const fractionB = -Geometry.dotProductXYXY(vx, vy, e00x, e00y) / vv;
|
|
316
316
|
if (this.updatePointToSegmentDistance(0, a0, b0, b1, fractionB, maxDistanceSquared, closestApproach))
|
|
317
317
|
reversed = false;
|
|
318
318
|
}
|
|
319
|
-
if (hba1 * hba1
|
|
319
|
+
if (hba1 * hba1 <= maxDistanceSquared * vv) { // test distance of a1 to v
|
|
320
320
|
const fractionB = -Geometry.dotProductXYXY(vx, vy, e10x, e10y) / vv;
|
|
321
321
|
if (this.updatePointToSegmentDistance(1, a1, b0, b1, fractionB, maxDistanceSquared, closestApproach))
|
|
322
322
|
reversed = false;
|
|
@@ -394,10 +394,10 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
394
394
|
* Low level dispatch of segment with arc.
|
|
395
395
|
* Find close approaches within maxDistance between a line segments (pointA0, pointA1) and an arc.
|
|
396
396
|
* To consider:
|
|
397
|
-
* 1)
|
|
398
|
-
* 2)
|
|
397
|
+
* 1) intersection between arc and segment.
|
|
398
|
+
* 2) arc endpoints to segment endpoints or arc endpoints projection to the segment.
|
|
399
399
|
* 3) line parallel to arc tangent.
|
|
400
|
-
* @param cpA
|
|
400
|
+
* @param cpA curve A (line segment or line string)
|
|
401
401
|
* @param pointA0 start point of the segment
|
|
402
402
|
* @param fractionA0 fraction of the start of the segment
|
|
403
403
|
* @param pointA1 end point of the segment
|
|
@@ -406,9 +406,7 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
406
406
|
* @param reversed true to have order reversed in final structures
|
|
407
407
|
*/
|
|
408
408
|
dispatchSegmentArc(cpA, pointA0, fractionA0, pointA1, fractionA1, arc, reversed) {
|
|
409
|
-
// 1)
|
|
410
|
-
this.testAndRecordFractionalPairApproach(cpA, 0, 1, true, arc, 0, 1, false, reversed);
|
|
411
|
-
// 2) intersection between arc and segment
|
|
409
|
+
// 1) intersection between arc and segment
|
|
412
410
|
// Suppose:
|
|
413
411
|
// Arc: X = C + cU + sV where c = cos(theta) and s = sin(theta)
|
|
414
412
|
// Line: contains points A0 and A1
|
|
@@ -417,6 +415,7 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
417
415
|
// solve for theta.
|
|
418
416
|
// evaluate points.
|
|
419
417
|
// project back to line.
|
|
418
|
+
let intersectionFound = false;
|
|
420
419
|
const data = arc.toTransformedVectors();
|
|
421
420
|
const pointA0Local = pointA0;
|
|
422
421
|
const pointA1Local = pointA1;
|
|
@@ -435,8 +434,13 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
435
434
|
// only add if the point is within the start and end fractions of both line segment and arc
|
|
436
435
|
if (lineFraction !== undefined && this.acceptFraction(lineFraction) && this.acceptFraction(arcFraction)) {
|
|
437
436
|
this.recordPointWithLocalFractions(lineFraction, cpA, fractionA0, fractionA1, arcFraction, arc, 0, 1, reversed);
|
|
437
|
+
intersectionFound = true;
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
|
+
if (intersectionFound)
|
|
441
|
+
return;
|
|
442
|
+
// 2) endpoints to endpoints or endpoints projection to the other curve
|
|
443
|
+
this.testAndRecordFractionalPairApproach(cpA, fractionA0, fractionA1, true, arc, 0, 1, false, reversed);
|
|
440
444
|
// 3) line parallel to arc tangent.
|
|
441
445
|
// If line does not intersect the arc, then the closest (and/or the furthest) point on arc to the line is a
|
|
442
446
|
// point where the tangent line on arc at that point is parallel to the line.
|
|
@@ -453,48 +457,37 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
453
457
|
}
|
|
454
458
|
}
|
|
455
459
|
}
|
|
456
|
-
|
|
460
|
+
/** Low level dispatch of circular arc with circular arc. radiusA must be larger than or equal to radiusB. */
|
|
457
461
|
dispatchCircularCircularOrdered(cpA, radiusA, cpB, radiusB, reversed) {
|
|
458
462
|
const c = cpA.center.distance(cpB.center);
|
|
459
463
|
const e = this._maxDistanceToAccept !== undefined ? this._maxDistanceToAccept : Geometry.smallMetricDistance;
|
|
460
|
-
if (c > radiusA + radiusB + e) //
|
|
464
|
+
if (c > radiusA + radiusB + e) // distance between circles is more than max distance
|
|
461
465
|
return;
|
|
462
|
-
//
|
|
463
|
-
//
|
|
464
|
-
// 2) true intersection
|
|
465
|
-
// 3) line parallel to arc tangent.
|
|
466
|
+
// TODO: 1) intersection between arcs
|
|
467
|
+
// 2) endpoints to endpoints
|
|
466
468
|
this.testAndRecordFractionalPairApproach(cpA, 0, 1, false, cpB, 0, 1, false, reversed);
|
|
469
|
+
// 3) line from one arc to another (perpendicular to arc tangents along center-center line)
|
|
467
470
|
if (!Geometry.isSmallMetricDistance(c)) {
|
|
468
|
-
// ?? endpoint hits are recorded. Maybe also need overlap?
|
|
469
471
|
const vectorAB = Vector3d.createStartEnd(cpA.center, cpB.center);
|
|
470
472
|
vectorAB.scaleInPlace(1.0 / c);
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
if (detailA) {
|
|
481
|
-
const detailB = this.resolveDirectionToArcXYFraction(cpB, vectorAB, rB);
|
|
482
|
-
if (detailB) {
|
|
483
|
-
this.captureDetailPair(detailA, detailB, reversed);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
473
|
+
for (const rA of [-radiusA, radiusA]) {
|
|
474
|
+
for (const rB of [-radiusB, radiusB]) {
|
|
475
|
+
const tangentDistance = c - rA + rB;
|
|
476
|
+
if (tangentDistance < e) {
|
|
477
|
+
const detailA = this.resolveDirectionToArcXYFraction(cpA, vectorAB, rA);
|
|
478
|
+
if (detailA) {
|
|
479
|
+
const detailB = this.resolveDirectionToArcXYFraction(cpB, vectorAB, rB);
|
|
480
|
+
if (detailB)
|
|
481
|
+
this.captureDetailPair(detailA, detailB, reversed);
|
|
486
482
|
}
|
|
487
483
|
}
|
|
488
484
|
}
|
|
489
485
|
}
|
|
490
486
|
}
|
|
491
487
|
}
|
|
492
|
-
/**
|
|
493
|
-
* Find the fractional point (if any) on an arc, known to be circular and displayed from the center in the
|
|
494
|
-
* direction of a scaled vector.
|
|
495
|
-
*/
|
|
488
|
+
/** Find the fractional point (if any) on the circular `arc` in the direction of `radialVector`. */
|
|
496
489
|
resolveDirectionToArcXYFraction(arc, radialVector, scale) {
|
|
497
|
-
// The scale ultimately only affects the direction --- easiest way to use it is two multiplies
|
|
490
|
+
// The scale ultimately only affects the direction --- easiest way to use it is two multiplies.
|
|
498
491
|
const c = scale * arc.matrixRef.columnDotXYZ(0, radialVector.x, radialVector.y, 0);
|
|
499
492
|
const s = scale * arc.matrixRef.columnDotXYZ(1, radialVector.x, radialVector.y, 0);
|
|
500
493
|
const radians = Math.atan2(s, c);
|
|
@@ -503,10 +496,13 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
503
496
|
return CurveLocationDetail.createCurveEvaluatedFraction(arc, fraction);
|
|
504
497
|
return undefined;
|
|
505
498
|
}
|
|
506
|
-
|
|
507
|
-
// Selects the best conditioned arc (in xy parts) as "circle after inversion"
|
|
508
|
-
// Solves the arc-arc equations
|
|
499
|
+
/** Low level dispatch of arc with arc. Only circular arcs are supported. */
|
|
509
500
|
dispatchArcArc(cpA, cpB, reversed) {
|
|
501
|
+
const rangeA = cpA.range();
|
|
502
|
+
const rangeB = cpB.range();
|
|
503
|
+
rangeA.expandInPlace(this._maxDistanceToAccept);
|
|
504
|
+
if (!rangeB.intersectsRangeXY(rangeA))
|
|
505
|
+
return;
|
|
510
506
|
if (this._circularArcB) {
|
|
511
507
|
const radiusB = this._circularRadiusB;
|
|
512
508
|
const radiusA = cpA.circularRadiusXY();
|
|
@@ -519,17 +515,13 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
519
515
|
}
|
|
520
516
|
}
|
|
521
517
|
}
|
|
522
|
-
|
|
523
|
-
// Selects the best conditioned arc (in xy parts) as "circle after inversion"
|
|
524
|
-
// Solves the arc-arc equations
|
|
518
|
+
/** Low level dispatch of arc with (beziers of) a bspline curve */
|
|
525
519
|
dispatchArcBsplineCurve3d(cpA, cpB, reversed) {
|
|
526
520
|
const ls = LineString3d.create();
|
|
527
521
|
cpB.emitStrokes(ls);
|
|
528
522
|
this.computeArcLineString(cpA, ls, reversed);
|
|
529
523
|
}
|
|
530
|
-
|
|
531
|
-
// Selects the best conditioned arc (in xy parts) as "circle after inversion"
|
|
532
|
-
// Solves the arc-arc equations
|
|
524
|
+
/** Low level dispatch of (beziers of) a bspline curve with (beziers of) a bspline curve */
|
|
533
525
|
dispatchBSplineCurve3dBSplineCurve3d(bcurveA, bcurveB, reversed) {
|
|
534
526
|
const lsA = LineString3d.create();
|
|
535
527
|
bcurveA.emitStrokes(lsA);
|
|
@@ -567,6 +559,11 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
567
559
|
}
|
|
568
560
|
/** Detail computation for arc approaching linestring. */
|
|
569
561
|
computeArcLineString(arcA, lsB, reversed) {
|
|
562
|
+
const rangeA = arcA.range();
|
|
563
|
+
const rangeB = lsB.range();
|
|
564
|
+
rangeA.expandInPlace(this._maxDistanceToAccept);
|
|
565
|
+
if (!rangeB.intersectsRangeXY(rangeA))
|
|
566
|
+
return;
|
|
570
567
|
const pointB0 = CurveCurveCloseApproachXY._workPointBB0;
|
|
571
568
|
const pointB1 = CurveCurveCloseApproachXY._workPointBB1;
|
|
572
569
|
const numB = lsB.numPoints();
|
|
@@ -584,10 +581,10 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
584
581
|
}
|
|
585
582
|
return undefined;
|
|
586
583
|
}
|
|
587
|
-
/** Low level dispatch of curve
|
|
588
|
-
|
|
584
|
+
/** Low level dispatch of curve collection. */
|
|
585
|
+
dispatchCurveCollection(geomA, geomAHandler) {
|
|
589
586
|
const geomB = this._geometryB; // save
|
|
590
|
-
if (!geomB || !(geomB instanceof
|
|
587
|
+
if (!geomB || !geomB.children || !(geomB instanceof CurveCollection))
|
|
591
588
|
return;
|
|
592
589
|
for (const child of geomB.children) {
|
|
593
590
|
this.resetGeometry(child);
|
|
@@ -610,9 +607,10 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
610
607
|
else if (this._geometryB instanceof BSplineCurve3d) {
|
|
611
608
|
this.dispatchSegmentBsplineCurve(segmentA, this._geometryB, false);
|
|
612
609
|
}
|
|
613
|
-
else if (this._geometryB instanceof
|
|
614
|
-
this.
|
|
610
|
+
else if (this._geometryB instanceof CurveCollection) {
|
|
611
|
+
this.dispatchCurveCollection(segmentA, this.handleLineSegment3d.bind(this));
|
|
615
612
|
}
|
|
613
|
+
return undefined;
|
|
616
614
|
}
|
|
617
615
|
/**
|
|
618
616
|
* Set bits for comparison to range xy
|
|
@@ -620,6 +618,13 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
620
618
|
* * bit 0x02 => x larger than range.high.x
|
|
621
619
|
* * bit 0x04 => y smaller than range.low.y
|
|
622
620
|
* * bit 0x08 => y larger than range.high.y
|
|
621
|
+
* * If we divide XY plane into 9 areas using the range, the function returns 0 for points
|
|
622
|
+
* inside the range. Below is other binary numbers returned by the function for all 9 areas:
|
|
623
|
+
* 1001 | 1000 | 1010
|
|
624
|
+
* ------------------
|
|
625
|
+
* 1 | 0 | 10
|
|
626
|
+
* ------------------
|
|
627
|
+
* 101 | 100 | 110
|
|
623
628
|
* @param xy point to test
|
|
624
629
|
* @param range range for comparison
|
|
625
630
|
*/
|
|
@@ -629,12 +634,14 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
629
634
|
result = 0x01;
|
|
630
635
|
else if (x > range.high.x)
|
|
631
636
|
result = 0x02;
|
|
637
|
+
// note the OR operation
|
|
632
638
|
if (y < range.low.y)
|
|
633
639
|
result |= 0x04;
|
|
634
640
|
else if (y > range.high.y)
|
|
635
641
|
result |= 0x08;
|
|
636
642
|
return result;
|
|
637
643
|
}
|
|
644
|
+
/** Low level dispatch of line string with line string. */
|
|
638
645
|
computeLineStringLineString(lsA, lsB, reversed) {
|
|
639
646
|
const rangeA = lsA.range();
|
|
640
647
|
const rangeB = lsB.range();
|
|
@@ -651,7 +658,6 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
651
658
|
const numA = lsA.numPoints();
|
|
652
659
|
const numB = lsB.numPoints();
|
|
653
660
|
if (numA > 1 && numB > 1) {
|
|
654
|
-
lsA.pointAt(0, pointA0);
|
|
655
661
|
const dfA = 1.0 / (numA - 1);
|
|
656
662
|
const dfB = 1.0 / (numB - 1);
|
|
657
663
|
let fA0 = 0.0;
|
|
@@ -661,6 +667,7 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
661
667
|
fA1 = ia * dfA;
|
|
662
668
|
fB0 = 0.0;
|
|
663
669
|
lsA.pointAt(ia, pointA1);
|
|
670
|
+
// rangeA1 is around line segment [A0,A1] expanded by max distance
|
|
664
671
|
rangeA1.setNull();
|
|
665
672
|
rangeA1.extendPoint(pointA0);
|
|
666
673
|
rangeA1.extendPoint(pointA1);
|
|
@@ -672,10 +679,10 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
672
679
|
lsB.pointAt(ib, pointB1);
|
|
673
680
|
bitB1 = this.classifyBitsPointRangeXY(pointB1.x, pointB1.y, rangeA1);
|
|
674
681
|
fB1 = ib * dfB;
|
|
675
|
-
//
|
|
676
|
-
|
|
682
|
+
// DO NOT study the segment in detail if both bitB bits are on for any of the 4 planes
|
|
683
|
+
// (i.e., no intersection between rangeA1 and the range around line segment [B0,B1])
|
|
684
|
+
if ((bitB0 & bitB1) === 0)
|
|
677
685
|
this.dispatchSegmentSegment(lsA, pointA0, fA0, pointA1, fA1, lsB, pointB0, fB0, pointB1, fB1, reversed);
|
|
678
|
-
}
|
|
679
686
|
}
|
|
680
687
|
}
|
|
681
688
|
}
|
|
@@ -696,8 +703,8 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
696
703
|
else if (this._geometryB instanceof BSplineCurve3d) {
|
|
697
704
|
this.dispatchLineStringBSplineCurve(lsA, this._geometryB, false);
|
|
698
705
|
}
|
|
699
|
-
else if (this._geometryB instanceof
|
|
700
|
-
this.
|
|
706
|
+
else if (this._geometryB instanceof CurveCollection) {
|
|
707
|
+
this.dispatchCurveCollection(lsA, this.handleLineString3d.bind(this));
|
|
701
708
|
}
|
|
702
709
|
return undefined;
|
|
703
710
|
}
|
|
@@ -715,8 +722,8 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
715
722
|
else if (this._geometryB instanceof BSplineCurve3d) {
|
|
716
723
|
this.dispatchArcBsplineCurve3d(arc0, this._geometryB, false);
|
|
717
724
|
}
|
|
718
|
-
else if (this._geometryB instanceof
|
|
719
|
-
this.
|
|
725
|
+
else if (this._geometryB instanceof CurveCollection) {
|
|
726
|
+
this.dispatchCurveCollection(arc0, this.handleArc3d.bind(this));
|
|
720
727
|
}
|
|
721
728
|
return undefined;
|
|
722
729
|
}
|
|
@@ -734,8 +741,8 @@ class CurveCurveCloseApproachXY extends RecurseToCurvesGeometryHandler {
|
|
|
734
741
|
else if (this._geometryB instanceof BSplineCurve3dBase) {
|
|
735
742
|
this.dispatchBSplineCurve3dBSplineCurve3d(curve, this._geometryB, false);
|
|
736
743
|
}
|
|
737
|
-
else if (this._geometryB instanceof
|
|
738
|
-
this.
|
|
744
|
+
else if (this._geometryB instanceof CurveCollection) {
|
|
745
|
+
this.dispatchCurveCollection(curve, this.handleBSplineCurve3d.bind(this));
|
|
739
746
|
}
|
|
740
747
|
return undefined;
|
|
741
748
|
}
|