@itwin/core-geometry 4.0.0-dev.99 → 4.1.0-dev.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/lib/cjs/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js +8 -5
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/curve/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCurveIntersectXY.js +3 -3
- package/lib/cjs/curve/CurveCurveIntersectXY.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/Query/PlanarSubdivision.d.ts +3 -2
- package/lib/cjs/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.js +57 -43
- package/lib/cjs/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +7 -5
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +17 -16
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts +9 -9
- package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/CoincidentGeometryOps.js +82 -56
- package/lib/cjs/geometry3d/CoincidentGeometryOps.js.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.js +1 -1
- package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
- package/lib/cjs/topology/Merging.d.ts +1 -0
- package/lib/cjs/topology/Merging.d.ts.map +1 -1
- package/lib/cjs/topology/Merging.js +1 -0
- package/lib/cjs/topology/Merging.js.map +1 -1
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js +8 -5
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/curve/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/esm/curve/CurveCurveIntersectXY.js +3 -3
- package/lib/esm/curve/CurveCurveIntersectXY.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/Query/PlanarSubdivision.d.ts +3 -2
- package/lib/esm/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.js +58 -44
- package/lib/esm/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +7 -5
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +17 -16
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.js +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts +9 -9
- package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/CoincidentGeometryOps.js +82 -56
- package/lib/esm/geometry3d/CoincidentGeometryOps.js.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.js +1 -1
- package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
- package/lib/esm/topology/Merging.d.ts +1 -0
- package/lib/esm/topology/Merging.d.ts.map +1 -1
- package/lib/esm/topology/Merging.js +1 -0
- package/lib/esm/topology/Merging.js.map +1 -1
- package/package.json +3 -3
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.CoincidentGeometryQuery = void 0;
|
|
8
|
+
/** @packageDocumentation
|
|
9
|
+
* @module CartesianGeometry
|
|
10
|
+
*/
|
|
11
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
8
12
|
const CurveLocationDetail_1 = require("../curve/CurveLocationDetail");
|
|
9
13
|
const Geometry_1 = require("../Geometry");
|
|
10
14
|
const AngleSweep_1 = require("./AngleSweep");
|
|
@@ -62,71 +66,71 @@ class CoincidentGeometryQuery {
|
|
|
62
66
|
* @param pointB1 end point of segment B
|
|
63
67
|
*/
|
|
64
68
|
coincidentSegmentRangeXY(pointA0, pointA1, pointB0, pointB1, restrictToBounds = true) {
|
|
65
|
-
const
|
|
66
|
-
if (pointA0.distanceXY(
|
|
69
|
+
const detailA0OnB = this.projectPointToSegmentXY(pointA0, pointB0, pointB1);
|
|
70
|
+
if (pointA0.distanceXY(detailA0OnB.point) > this._tolerance)
|
|
67
71
|
return undefined;
|
|
68
72
|
const detailA1OnB = this.projectPointToSegmentXY(pointA1, pointB0, pointB1);
|
|
69
73
|
if (pointA1.distanceXY(detailA1OnB.point) > this._tolerance)
|
|
70
74
|
return undefined;
|
|
71
|
-
const
|
|
72
|
-
if (pointB0.distanceXY(
|
|
75
|
+
const detailB0OnA = this.projectPointToSegmentXY(pointB0, pointA0, pointA1);
|
|
76
|
+
if (pointB0.distanceXY(detailB0OnA.point) > this._tolerance)
|
|
73
77
|
return undefined;
|
|
74
78
|
const detailB1OnA = this.projectPointToSegmentXY(pointB1, pointA0, pointA1);
|
|
75
79
|
if (pointB1.distanceXY(detailB1OnA.point) > this._tolerance)
|
|
76
80
|
return undefined;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
detailA0OnB.fraction1 = detailA1OnB.fraction;
|
|
82
|
+
detailA0OnB.point1 = detailA1OnB.point; // capture -- detailA1OnB is not reused.
|
|
83
|
+
detailB0OnA.fraction1 = detailB1OnA.fraction;
|
|
84
|
+
detailB0OnA.point1 = detailB1OnA.point;
|
|
81
85
|
if (!restrictToBounds)
|
|
82
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(
|
|
83
|
-
const segment = Segment1d_1.Segment1d.create(
|
|
86
|
+
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
87
|
+
const segment = Segment1d_1.Segment1d.create(detailB0OnA.fraction, detailB0OnA.fraction1);
|
|
84
88
|
if (segment.clampDirectedTo01()) {
|
|
85
|
-
segment.reverseIfNeededForDeltaSign(1.0);
|
|
86
89
|
const f0 = segment.x0;
|
|
87
90
|
const f1 = segment.x1;
|
|
88
|
-
const h0 =
|
|
89
|
-
const h1 =
|
|
91
|
+
const h0 = detailB0OnA.inverseInterpolateFraction(f0);
|
|
92
|
+
const h1 = detailB0OnA.inverseInterpolateFraction(f1);
|
|
90
93
|
// recompute fractions and points..
|
|
91
|
-
CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(
|
|
92
|
-
CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(
|
|
93
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(
|
|
94
|
+
CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(detailB0OnA, f0, f1, pointA0, pointA1, f0 > f1);
|
|
95
|
+
CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(detailA0OnB, h0, h1, pointB0, pointB1, h0 > h1);
|
|
96
|
+
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
94
97
|
}
|
|
95
98
|
else {
|
|
96
99
|
if (segment.signedDelta() < 0.0) {
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(
|
|
100
|
+
if (detailB0OnA.point.isAlmostEqual(pointA0, this.tolerance)) {
|
|
101
|
+
detailB0OnA.collapseToStart();
|
|
102
|
+
detailA0OnB.collapseToStart();
|
|
103
|
+
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
101
104
|
}
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(
|
|
105
|
+
if (detailB0OnA.point1.isAlmostEqual(pointA1, this.tolerance)) {
|
|
106
|
+
detailB0OnA.collapseToEnd();
|
|
107
|
+
detailA0OnB.collapseToEnd();
|
|
108
|
+
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
else {
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(
|
|
112
|
+
if (detailB0OnA.point.isAlmostEqual(pointA1, this.tolerance)) {
|
|
113
|
+
detailB0OnA.collapseToStart();
|
|
114
|
+
detailA0OnB.collapseToEnd();
|
|
115
|
+
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
113
116
|
}
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(
|
|
117
|
+
if (detailB0OnA.point1.isAlmostEqual(pointA0, this.tolerance)) {
|
|
118
|
+
detailB0OnA.collapseToEnd();
|
|
119
|
+
detailA0OnB.collapseToStart();
|
|
120
|
+
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
return undefined;
|
|
122
125
|
}
|
|
123
126
|
/**
|
|
124
|
-
* Create a CurveLocationDetailPair
|
|
127
|
+
* Create a CurveLocationDetailPair for a coincident interval of two overlapping curves
|
|
125
128
|
* @param cpA curveA
|
|
126
|
-
* @param cpB
|
|
127
|
-
* @param fractionsOnA
|
|
128
|
-
* @param fractionB0
|
|
129
|
-
* @param fractionB1 end fraction of
|
|
129
|
+
* @param cpB curveB
|
|
130
|
+
* @param fractionsOnA coincident interval of curveB in fraction space of curveA
|
|
131
|
+
* @param fractionB0 curveB start in fraction space of curveA
|
|
132
|
+
* @param fractionB1 curveB end in fraction space of curveA
|
|
133
|
+
* @param reverse whether curveB and curveA have opposite direction
|
|
130
134
|
*/
|
|
131
135
|
createDetailPair(cpA, cpB, fractionsOnA, fractionB0, fractionB1, reverse) {
|
|
132
136
|
const deltaB = fractionB1 - fractionB0;
|
|
@@ -135,10 +139,8 @@ class CoincidentGeometryQuery {
|
|
|
135
139
|
if (g0 !== undefined && g1 !== undefined) {
|
|
136
140
|
const detailA = CurveLocationDetail_1.CurveLocationDetail.createCurveEvaluatedFractionFraction(cpA, fractionsOnA.x0, fractionsOnA.x1);
|
|
137
141
|
const detailB = CurveLocationDetail_1.CurveLocationDetail.createCurveEvaluatedFractionFraction(cpB, g0, g1);
|
|
138
|
-
if (reverse)
|
|
142
|
+
if (reverse)
|
|
139
143
|
detailA.swapFractionsAndPoints();
|
|
140
|
-
detailB.swapFractionsAndPoints();
|
|
141
|
-
}
|
|
142
144
|
return CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailA, detailB);
|
|
143
145
|
}
|
|
144
146
|
return undefined;
|
|
@@ -156,11 +158,11 @@ class CoincidentGeometryQuery {
|
|
|
156
158
|
* @param arcA
|
|
157
159
|
* @param arcB
|
|
158
160
|
* @param _restrictToBounds
|
|
159
|
-
* @return 0, 1, or 2 overlap intervals
|
|
161
|
+
* @return 0, 1, or 2 overlap points/intervals
|
|
160
162
|
*/
|
|
161
163
|
coincidentArcIntersectionXY(arcA, arcB, _restrictToBounds = true) {
|
|
162
164
|
let result;
|
|
163
|
-
if (arcA.center.isAlmostEqual(arcB.center)) {
|
|
165
|
+
if (arcA.center.isAlmostEqual(arcB.center, this.tolerance)) {
|
|
164
166
|
const matrixBToA = arcA.matrixRef.multiplyMatrixInverseMatrix(arcB.matrixRef);
|
|
165
167
|
if (matrixBToA) {
|
|
166
168
|
const ux = matrixBToA.at(0, 0);
|
|
@@ -174,25 +176,49 @@ class CoincidentGeometryQuery {
|
|
|
174
176
|
if (Geometry_1.Geometry.isAlmostEqualNumber(ru, 1.0)
|
|
175
177
|
&& Geometry_1.Geometry.isAlmostEqualNumber(rv, 1.0)
|
|
176
178
|
&& Geometry_1.Geometry.isAlmostEqualNumber(0, dot)) {
|
|
177
|
-
const alphaB0Radians = Math.atan2(uy, ux); // angular position of arcB 0 point in
|
|
178
|
-
const sweepDirection = cross > 0 ? 1.0 : -1.0; // 1 if arcB
|
|
179
|
-
const betaStartRadians = alphaB0Radians + sweepDirection * arcB.sweep.startRadians;
|
|
180
|
-
const betaEndRadians = alphaB0Radians + sweepDirection * arcB.sweep.endRadians;
|
|
179
|
+
const alphaB0Radians = Math.atan2(uy, ux); // angular position of arcB 0 point in arcA sweep
|
|
180
|
+
const sweepDirection = cross > 0 ? 1.0 : -1.0; // 1 if arcB parameter space sweeps in same direction as arcA, -1 if opposite
|
|
181
|
+
const betaStartRadians = alphaB0Radians + sweepDirection * arcB.sweep.startRadians; // arcB start in arcA parameter space
|
|
182
|
+
const betaEndRadians = alphaB0Radians + sweepDirection * arcB.sweep.endRadians; // arcB end in arcA parameter space
|
|
181
183
|
const fractionSpacesReversed = (sweepDirection * arcA.sweep.sweepRadians * arcB.sweep.sweepRadians) < 0;
|
|
182
184
|
const sweepB = AngleSweep_1.AngleSweep.createStartEndRadians(betaStartRadians, betaEndRadians);
|
|
183
185
|
const sweepA = arcA.sweep;
|
|
184
186
|
const fractionPeriodA = sweepA.fractionPeriod();
|
|
185
|
-
const fractionB0 = sweepA.radiansToPositivePeriodicFraction(sweepB.startRadians);
|
|
186
|
-
|
|
187
|
-
const
|
|
187
|
+
const fractionB0 = sweepA.radiansToPositivePeriodicFraction(sweepB.startRadians); // arcB start in arcA fraction space
|
|
188
|
+
(0, core_bentley_1.assert)(fractionB0 >= 0.0);
|
|
189
|
+
const fractionSweep = sweepB.sweepRadians / sweepA.sweepRadians; // arcB sweep in arcA fraction space
|
|
190
|
+
const fractionB1 = fractionB0 + fractionSweep; // arcB end in arcA fraction space
|
|
188
191
|
const fractionSweepB = Segment1d_1.Segment1d.create(fractionB0, fractionB1);
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
/** lambda to add a coincident interval or isolated intersection, given inputs in arcA fraction space
|
|
193
|
+
* @param arcBInArcAFractionSpace span of arcB in arcA fraction space. On return, clamped to [0,1] if nontrivial.
|
|
194
|
+
* @param testStartOfArcA if no nontrivial coincident interval was found, look for an isolated intersection at the start (true) or end (false) of arcA
|
|
195
|
+
* @returns whether a detail pair was appended to result
|
|
196
|
+
*/
|
|
197
|
+
const appendCoincidentIntersection = (arcBInArcAFractionSpace, testStartOfArcA) => {
|
|
198
|
+
const size = result ? result.length : 0;
|
|
199
|
+
const arcBStart = arcBInArcAFractionSpace.x0;
|
|
200
|
+
const arcBEnd = arcBInArcAFractionSpace.x1;
|
|
201
|
+
if (arcBInArcAFractionSpace.clampDirectedTo01() && !Geometry_1.Geometry.isSmallRelative(arcBInArcAFractionSpace.absoluteDelta())) {
|
|
202
|
+
result = this.appendDetailPair(result, this.createDetailPair(arcA, arcB, arcBInArcAFractionSpace, arcBStart, arcBEnd, fractionSpacesReversed));
|
|
203
|
+
}
|
|
204
|
+
else { // test isolated intersection
|
|
205
|
+
const testStartOfArcB = fractionSpacesReversed ? testStartOfArcA : !testStartOfArcA;
|
|
206
|
+
const arcAPt = this._point0 = testStartOfArcA ? arcA.startPoint(this._point0) : arcA.endPoint(this._point0);
|
|
207
|
+
const arcBPt = this._point1 = testStartOfArcB ? arcB.startPoint(this._point1) : arcB.endPoint(this._point1);
|
|
208
|
+
if (arcAPt.isAlmostEqual(arcBPt, this.tolerance)) {
|
|
209
|
+
const detailA = CurveLocationDetail_1.CurveLocationDetail.createCurveFractionPoint(arcA, testStartOfArcA ? 0 : 1, arcAPt);
|
|
210
|
+
const detailB = CurveLocationDetail_1.CurveLocationDetail.createCurveFractionPoint(arcB, testStartOfArcB ? 0 : 1, arcBPt);
|
|
211
|
+
result = this.appendDetailPair(result, CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detailA, detailB));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return result !== undefined && result.length > size;
|
|
215
|
+
};
|
|
216
|
+
appendCoincidentIntersection(fractionSweepB, false); // compute overlap in strict interior, or at end of arcA
|
|
217
|
+
// check overlap at start of arcA with a periodic shift of fractionSweepB
|
|
218
|
+
if (fractionB1 >= fractionPeriodA)
|
|
219
|
+
appendCoincidentIntersection(Segment1d_1.Segment1d.create(fractionB0 - fractionPeriodA, fractionB1 - fractionPeriodA), true);
|
|
220
|
+
else if (fractionB0 === 0.0)
|
|
221
|
+
appendCoincidentIntersection(Segment1d_1.Segment1d.create(fractionB0 + fractionPeriodA, fractionB1 + fractionPeriodA), true);
|
|
196
222
|
}
|
|
197
223
|
}
|
|
198
224
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoincidentGeometryOps.js","sourceRoot":"","sources":["../../../src/geometry3d/CoincidentGeometryOps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAM/F,sEAA4F;AAE5F,0CAAuC;AACvC,6CAA0C;AAC1C,uDAAsD;AACtD,2CAAwC;AAExC;;;;;GAKG;AACH,MAAa,uBAAuB;IAIlC,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IACD,YAAoB,YAAoB,mBAAQ,CAAC,mBAAmB;QAClE,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IACM,MAAM,CAAC,MAAM,CAAC,YAAoB,mBAAQ,CAAC,mBAAmB;QACnE,OAAO,IAAI,uBAAuB,CAAC,SAAS,CAAC,CAAC;IAChD,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,0CA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CAAC,YAAY,CAAC;oBAChE,MAAM,UAAU,GAAG,UAAU,GAAG,aAAa,CAAC;oBAC9C,MAAM,cAAc,GAAG,qBAAS,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;oBAChE,IAAI,cAAc,CAAC,iBAAiB,EAAE;wBACpC,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC;oBAC5I,IAAI,UAAU,GAAG,eAAe,EAAE;wBAChC,MAAM,kBAAkB,GAAG,qBAAS,CAAC,MAAM,CAAC,UAAU,GAAG,eAAe,EAAE,UAAU,GAAG,eAAe,CAAC,CAAC;wBACxG,IAAI,kBAAkB,CAAC,iBAAiB,EAAE;4BACxC,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC;qBACjJ;iBACF;aACF;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA3LD,0DA2LC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\nimport { Arc3d } from \"../curve/Arc3d\";\r\nimport { CurveLocationDetail, CurveLocationDetailPair } from \"../curve/CurveLocationDetail\";\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { AngleSweep } from \"./AngleSweep\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Segment1d } from \"./Segment1d\";\r\n\r\n/**\r\n * `CoincidentGeometryQuery` has methods useful in testing for overlapping geometry.\r\n * * Each instance carries tolerance information that can be reused over extended call sequences.\r\n * * These methods are expected to be called internally by CurveCurve intersection methods.\r\n * @internal\r\n */\r\nexport class CoincidentGeometryQuery {\r\n private _vectorU?: Vector3d;\r\n private _vectorV?: Vector3d;\r\n private _tolerance: number;\r\n public get tolerance(): number {\r\n return this._tolerance;\r\n }\r\n private constructor(tolerance: number = Geometry.smallMetricDistance) {\r\n this._tolerance = tolerance;\r\n }\r\n public static create(tolerance: number = Geometry.smallMetricDistance): CoincidentGeometryQuery {\r\n return new CoincidentGeometryQuery(tolerance);\r\n }\r\n /**\r\n * * Assign both the fraction and fraction1 values in the detail, possibly swapped.\r\n * * reevaluate the points as simple interpolation between given points.\r\n */\r\n public static assignDetailInterpolatedFractionsAndPoints(detail: CurveLocationDetail, f0: number, f1: number,\r\n pointA: Point3d, pointB: Point3d, swap: boolean = false) {\r\n if (swap) {\r\n detail.fraction = f1;\r\n detail.fraction1 = f0;\r\n } else {\r\n detail.fraction = f0;\r\n detail.fraction1 = f1;\r\n }\r\n detail.point = pointA.interpolate(detail.fraction, pointB, detail.point);\r\n detail.point1 = pointA.interpolate(detail.fraction1, pointB, detail.point1);\r\n\r\n }\r\n\r\n /** Return a curve location detail with projection of a `spacePoint` to the line segment with `pointA` and `pointB`\r\n *\r\n */\r\n public projectPointToSegmentXY(spacePoint: Point3d, pointA: Point3d, pointB: Point3d): CurveLocationDetail {\r\n this._vectorU = Vector3d.createStartEnd(pointA, pointB, this._vectorU);\r\n this._vectorV = Vector3d.createStartEnd(pointA, spacePoint, this._vectorV);\r\n const uDotU = this._vectorU.dotProductXY(this._vectorU);\r\n const uDotV = this._vectorU.dotProductXY(this._vectorV);\r\n const fraction = Geometry.safeDivideFraction(uDotV, uDotU, 0.0);\r\n return CurveLocationDetail.createCurveFractionPoint(undefined, fraction,\r\n pointA.interpolate(fraction, pointB));\r\n }\r\n /**\r\n * * project `pointA0` and `pointA1` onto the segment with `pointB0` and `pointB1`\r\n * * In the returned detail pair, the `detailA` has fractions along segmentA, and `detailB` has fractions along segment B\r\n * @param pointA0 start point of segment A\r\n * @param pointA1 end point of segment A\r\n * @param pointB0 start point of segment B\r\n * @param pointB1 end point of segment B\r\n */\r\n public coincidentSegmentRangeXY(pointA0: Point3d, pointA1: Point3d, pointB0: Point3d, pointB1: Point3d, restrictToBounds: boolean = true): CurveLocationDetailPair | undefined {\r\n const detailAOnB = this.projectPointToSegmentXY(pointA0, pointB0, pointB1);\r\n if (pointA0.distanceXY(detailAOnB.point) > this._tolerance)\r\n return undefined;\r\n const detailA1OnB = this.projectPointToSegmentXY(pointA1, pointB0, pointB1);\r\n if (pointA1.distanceXY(detailA1OnB.point) > this._tolerance)\r\n return undefined;\r\n\r\n const detailBOnA = this.projectPointToSegmentXY(pointB0, pointA0, pointA1);\r\n if (pointB0.distanceXY(detailBOnA.point) > this._tolerance)\r\n return undefined;\r\n const detailB1OnA = this.projectPointToSegmentXY(pointB1, pointA0, pointA1);\r\n if (pointB1.distanceXY(detailB1OnA.point) > this._tolerance)\r\n return undefined;\r\n\r\n detailAOnB.fraction1 = detailA1OnB.fraction;\r\n detailAOnB.point1 = detailA1OnB.point; // capture -- detailB0OnA is not reused.\r\n detailBOnA.fraction1 = detailB1OnA.fraction;\r\n detailBOnA.point1 = detailB1OnA.point;\r\n if (!restrictToBounds)\r\n return CurveLocationDetailPair.createCapture(detailBOnA, detailAOnB);\r\n\r\n const segment = Segment1d.create(detailBOnA.fraction, detailBOnA.fraction1);\r\n if (segment.clampDirectedTo01()) {\r\n segment.reverseIfNeededForDeltaSign(1.0);\r\n const f0 = segment.x0;\r\n const f1 = segment.x1;\r\n const h0 = detailBOnA.inverseInterpolateFraction(f0);\r\n const h1 = detailBOnA.inverseInterpolateFraction(f1);\r\n // recompute fractions and points..\r\n CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(detailBOnA, f0, f1, pointA0, pointA1);\r\n CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(detailAOnB, h0, h1, pointB0, pointB1);\r\n return CurveLocationDetailPair.createCapture(detailBOnA, detailAOnB);\r\n } else {\r\n if (segment.signedDelta() < 0.0) {\r\n if (detailBOnA.point.isAlmostEqual(pointA0)) {\r\n detailBOnA.collapseToStart();\r\n detailAOnB.collapseToStart();\r\n return CurveLocationDetailPair.createCapture(detailBOnA, detailAOnB);\r\n }\r\n if (detailBOnA.point1.isAlmostEqual(pointA1)) {\r\n detailBOnA.collapseToEnd();\r\n detailAOnB.collapseToEnd();\r\n return CurveLocationDetailPair.createCapture(detailBOnA, detailAOnB);\r\n }\r\n } else {\r\n if (detailBOnA.point.isAlmostEqual(pointA1)) {\r\n detailBOnA.collapseToStart();\r\n detailAOnB.collapseToEnd();\r\n return CurveLocationDetailPair.createCapture(detailBOnA, detailAOnB);\r\n }\r\n if (detailBOnA.point1.isAlmostEqual(pointA0)) {\r\n detailBOnA.collapseToEnd();\r\n detailAOnB.collapseToStart();\r\n return CurveLocationDetailPair.createCapture(detailBOnA, detailAOnB);\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Create a CurveLocationDetailPair from . . .\r\n * @param cpA curveA\r\n * @param cpB curve B\r\n * @param fractionsOnA fractions of an active section of curveA\r\n * @param fractionB0 fraction of an original containing B interval\r\n * @param fractionB1 end fraction of an original containing B interval\r\n */\r\n private createDetailPair(cpA: CurvePrimitive, cpB: CurvePrimitive, fractionsOnA: Segment1d, fractionB0: number, fractionB1: number, reverse: boolean): CurveLocationDetailPair | undefined {\r\n const deltaB = fractionB1 - fractionB0;\r\n const g0 = Geometry.conditionalDivideFraction(fractionsOnA.x0 - fractionB0, deltaB);\r\n const g1 = Geometry.conditionalDivideFraction(fractionsOnA.x1 - fractionB0, deltaB);\r\n if (g0 !== undefined && g1 !== undefined) {\r\n const detailA = CurveLocationDetail.createCurveEvaluatedFractionFraction(cpA, fractionsOnA.x0, fractionsOnA.x1);\r\n const detailB = CurveLocationDetail.createCurveEvaluatedFractionFraction(cpB, g0, g1);\r\n if (reverse) {\r\n detailA.swapFractionsAndPoints();\r\n detailB.swapFractionsAndPoints();\r\n }\r\n return CurveLocationDetailPair.createCapture(detailA, detailB);\r\n }\r\n return undefined;\r\n }\r\n private appendDetailPair(result: CurveLocationDetailPair[] | undefined, pair: CurveLocationDetailPair | undefined): CurveLocationDetailPair[] | undefined {\r\n if (pair === undefined)\r\n return result;\r\n if (result === undefined)\r\n return [pair];\r\n result.push(pair);\r\n return result;\r\n }\r\n /**\r\n * Test if 2 arcs have coinciding portions.\r\n * @param arcA\r\n * @param arcB\r\n * @param _restrictToBounds\r\n * @return 0, 1, or 2 overlap intervals.\r\n */\r\n public coincidentArcIntersectionXY(arcA: Arc3d, arcB: Arc3d, _restrictToBounds: boolean = true): CurveLocationDetailPair[] | undefined {\r\n let result: CurveLocationDetailPair[] | undefined;\r\n if (arcA.center.isAlmostEqual(arcB.center)) {\r\n const matrixBToA = arcA.matrixRef.multiplyMatrixInverseMatrix(arcB.matrixRef);\r\n if (matrixBToA) {\r\n const ux = matrixBToA.at(0, 0); const uy = matrixBToA.at(1, 0);\r\n const vx = matrixBToA.at(0, 1); const vy = matrixBToA.at(1, 1);\r\n const ru = Geometry.hypotenuseXY(ux, uy);\r\n const rv = Geometry.hypotenuseXY(vx, vy);\r\n const dot = Geometry.dotProductXYXY(ux, uy, vx, vy);\r\n const cross = Geometry.crossProductXYXY(ux, uy, vx, vy);\r\n if (Geometry.isAlmostEqualNumber(ru, 1.0)\r\n && Geometry.isAlmostEqualNumber(rv, 1.0)\r\n && Geometry.isAlmostEqualNumber(0, dot)) {\r\n const alphaB0Radians = Math.atan2(uy, ux); // angular position of arcB 0 point in A sweep\r\n const sweepDirection = cross > 0 ? 1.0 : -1.0; // 1 if arcB's parameter space sweeps forward, -1 if reverse\r\n const betaStartRadians = alphaB0Radians + sweepDirection * arcB.sweep.startRadians;\r\n const betaEndRadians = alphaB0Radians + sweepDirection * arcB.sweep.endRadians;\r\n const fractionSpacesReversed = (sweepDirection * arcA.sweep.sweepRadians * arcB.sweep.sweepRadians) < 0;\r\n const sweepB = AngleSweep.createStartEndRadians(betaStartRadians, betaEndRadians);\r\n const sweepA = arcA.sweep;\r\n const fractionPeriodA = sweepA.fractionPeriod();\r\n const fractionB0 = sweepA.radiansToPositivePeriodicFraction(sweepB.startRadians);\r\n const fractionSweep = sweepB.sweepRadians / sweepA.sweepRadians;\r\n const fractionB1 = fractionB0 + fractionSweep;\r\n const fractionSweepB = Segment1d.create(fractionB0, fractionB1);\r\n if (fractionSweepB.clampDirectedTo01())\r\n result = this.appendDetailPair(result, this.createDetailPair(arcA, arcB, fractionSweepB, fractionB0, fractionB1, fractionSpacesReversed));\r\n if (fractionB1 > fractionPeriodA) {\r\n const fractionSweepBWrap = Segment1d.create(fractionB0 - fractionPeriodA, fractionB1 - fractionPeriodA);\r\n if (fractionSweepBWrap.clampDirectedTo01())\r\n result = this.appendDetailPair(result, this.createDetailPair(arcA, arcB, fractionSweepBWrap, fractionB0, fractionB1, fractionSpacesReversed));\r\n }\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"CoincidentGeometryOps.js","sourceRoot":"","sources":["../../../src/geometry3d/CoincidentGeometryOps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,sDAA6C;AAE7C,sEAA4F;AAE5F,0CAAuC;AACvC,6CAA0C;AAC1C,uDAAsD;AACtD,2CAAwC;AAExC;;;;;GAKG;AACH,MAAa,uBAAuB;IAMlC,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IACD,YAAoB,YAAoB,mBAAQ,CAAC,mBAAmB;QAClE,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IACM,MAAM,CAAC,MAAM,CAAC,YAAoB,mBAAQ,CAAC,mBAAmB;QACnE,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AAE,UAAU,GAAG,eAAe,CAAC,EAAE,IAAI,CAAC,CAAC;iBACpH;aACF;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AArND,0DAqNC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module CartesianGeometry\r\n */\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Arc3d } from \"../curve/Arc3d\";\r\nimport { CurveLocationDetail, CurveLocationDetailPair } from \"../curve/CurveLocationDetail\";\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { AngleSweep } from \"./AngleSweep\";\r\nimport { Point3d, Vector3d } from \"./Point3dVector3d\";\r\nimport { Segment1d } from \"./Segment1d\";\r\n\r\n/**\r\n * `CoincidentGeometryQuery` has methods useful in testing for overlapping geometry.\r\n * * Each instance carries tolerance information that can be reused over extended call sequences.\r\n * * These methods are expected to be called internally by CurveCurve intersection methods.\r\n * @internal\r\n */\r\nexport class CoincidentGeometryQuery {\r\n private _vectorU?: Vector3d;\r\n private _vectorV?: Vector3d;\r\n private _point0?: Point3d;\r\n private _point1?: Point3d;\r\n private _tolerance: number;\r\n public get tolerance(): number {\r\n return this._tolerance;\r\n }\r\n private constructor(tolerance: number = Geometry.smallMetricDistance) {\r\n this._tolerance = tolerance;\r\n }\r\n public static create(tolerance: number = Geometry.smallMetricDistance): CoincidentGeometryQuery {\r\n return new CoincidentGeometryQuery(tolerance);\r\n }\r\n /**\r\n * * Assign both the fraction and fraction1 values in the detail, possibly swapped.\r\n * * reevaluate the points as simple interpolation between given points.\r\n */\r\n public static assignDetailInterpolatedFractionsAndPoints(detail: CurveLocationDetail, f0: number, f1: number,\r\n pointA: Point3d, pointB: Point3d, swap: boolean = false) {\r\n if (swap) {\r\n detail.fraction = f1;\r\n detail.fraction1 = f0;\r\n } else {\r\n detail.fraction = f0;\r\n detail.fraction1 = f1;\r\n }\r\n detail.point = pointA.interpolate(detail.fraction, pointB, detail.point);\r\n detail.point1 = pointA.interpolate(detail.fraction1, pointB, detail.point1);\r\n\r\n }\r\n\r\n /** Return a curve location detail with projection of a `spacePoint` to the line segment with `pointA` and `pointB`\r\n *\r\n */\r\n public projectPointToSegmentXY(spacePoint: Point3d, pointA: Point3d, pointB: Point3d): CurveLocationDetail {\r\n this._vectorU = Vector3d.createStartEnd(pointA, pointB, this._vectorU);\r\n this._vectorV = Vector3d.createStartEnd(pointA, spacePoint, this._vectorV);\r\n const uDotU = this._vectorU.dotProductXY(this._vectorU);\r\n const uDotV = this._vectorU.dotProductXY(this._vectorV);\r\n const fraction = Geometry.safeDivideFraction(uDotV, uDotU, 0.0);\r\n return CurveLocationDetail.createCurveFractionPoint(undefined, fraction,\r\n pointA.interpolate(fraction, pointB));\r\n }\r\n /**\r\n * * project `pointA0` and `pointA1` onto the segment with `pointB0` and `pointB1`\r\n * * In the returned detail pair, the `detailA` has fractions along segmentA, and `detailB` has fractions along segment B\r\n * @param pointA0 start point of segment A\r\n * @param pointA1 end point of segment A\r\n * @param pointB0 start point of segment B\r\n * @param pointB1 end point of segment B\r\n */\r\n public coincidentSegmentRangeXY(pointA0: Point3d, pointA1: Point3d, pointB0: Point3d, pointB1: Point3d, restrictToBounds: boolean = true): CurveLocationDetailPair | undefined {\r\n const detailA0OnB = this.projectPointToSegmentXY(pointA0, pointB0, pointB1);\r\n if (pointA0.distanceXY(detailA0OnB.point) > this._tolerance)\r\n return undefined;\r\n const detailA1OnB = this.projectPointToSegmentXY(pointA1, pointB0, pointB1);\r\n if (pointA1.distanceXY(detailA1OnB.point) > this._tolerance)\r\n return undefined;\r\n\r\n const detailB0OnA = this.projectPointToSegmentXY(pointB0, pointA0, pointA1);\r\n if (pointB0.distanceXY(detailB0OnA.point) > this._tolerance)\r\n return undefined;\r\n const detailB1OnA = this.projectPointToSegmentXY(pointB1, pointA0, pointA1);\r\n if (pointB1.distanceXY(detailB1OnA.point) > this._tolerance)\r\n return undefined;\r\n\r\n detailA0OnB.fraction1 = detailA1OnB.fraction;\r\n detailA0OnB.point1 = detailA1OnB.point; // capture -- detailA1OnB is not reused.\r\n detailB0OnA.fraction1 = detailB1OnA.fraction;\r\n detailB0OnA.point1 = detailB1OnA.point;\r\n if (!restrictToBounds)\r\n return CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);\r\n\r\n const segment = Segment1d.create(detailB0OnA.fraction, detailB0OnA.fraction1);\r\n if (segment.clampDirectedTo01()) {\r\n const f0 = segment.x0;\r\n const f1 = segment.x1;\r\n const h0 = detailB0OnA.inverseInterpolateFraction(f0);\r\n const h1 = detailB0OnA.inverseInterpolateFraction(f1);\r\n // recompute fractions and points..\r\n CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(detailB0OnA, f0, f1, pointA0, pointA1, f0 > f1);\r\n CoincidentGeometryQuery.assignDetailInterpolatedFractionsAndPoints(detailA0OnB, h0, h1, pointB0, pointB1, h0 > h1);\r\n return CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);\r\n } else {\r\n if (segment.signedDelta() < 0.0) {\r\n if (detailB0OnA.point.isAlmostEqual(pointA0, this.tolerance)) {\r\n detailB0OnA.collapseToStart();\r\n detailA0OnB.collapseToStart();\r\n return CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);\r\n }\r\n if (detailB0OnA.point1.isAlmostEqual(pointA1, this.tolerance)) {\r\n detailB0OnA.collapseToEnd();\r\n detailA0OnB.collapseToEnd();\r\n return CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);\r\n }\r\n } else {\r\n if (detailB0OnA.point.isAlmostEqual(pointA1, this.tolerance)) {\r\n detailB0OnA.collapseToStart();\r\n detailA0OnB.collapseToEnd();\r\n return CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);\r\n }\r\n if (detailB0OnA.point1.isAlmostEqual(pointA0, this.tolerance)) {\r\n detailB0OnA.collapseToEnd();\r\n detailA0OnB.collapseToStart();\r\n return CurveLocationDetailPair.createCapture(detailB0OnA, detailA0OnB);\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Create a CurveLocationDetailPair for a coincident interval of two overlapping curves\r\n * @param cpA curveA\r\n * @param cpB curveB\r\n * @param fractionsOnA coincident interval of curveB in fraction space of curveA\r\n * @param fractionB0 curveB start in fraction space of curveA\r\n * @param fractionB1 curveB end in fraction space of curveA\r\n * @param reverse whether curveB and curveA have opposite direction\r\n */\r\n private createDetailPair(cpA: CurvePrimitive, cpB: CurvePrimitive, fractionsOnA: Segment1d, fractionB0: number, fractionB1: number, reverse: boolean): CurveLocationDetailPair | undefined {\r\n const deltaB = fractionB1 - fractionB0;\r\n const g0 = Geometry.conditionalDivideFraction(fractionsOnA.x0 - fractionB0, deltaB);\r\n const g1 = Geometry.conditionalDivideFraction(fractionsOnA.x1 - fractionB0, deltaB);\r\n if (g0 !== undefined && g1 !== undefined) {\r\n const detailA = CurveLocationDetail.createCurveEvaluatedFractionFraction(cpA, fractionsOnA.x0, fractionsOnA.x1);\r\n const detailB = CurveLocationDetail.createCurveEvaluatedFractionFraction(cpB, g0, g1);\r\n if (reverse)\r\n detailA.swapFractionsAndPoints();\r\n return CurveLocationDetailPair.createCapture(detailA, detailB);\r\n }\r\n return undefined;\r\n }\r\n private appendDetailPair(result: CurveLocationDetailPair[] | undefined, pair: CurveLocationDetailPair | undefined): CurveLocationDetailPair[] | undefined {\r\n if (pair === undefined)\r\n return result;\r\n if (result === undefined)\r\n return [pair];\r\n result.push(pair);\r\n return result;\r\n }\r\n /**\r\n * Test if 2 arcs have coinciding portions.\r\n * @param arcA\r\n * @param arcB\r\n * @param _restrictToBounds\r\n * @return 0, 1, or 2 overlap points/intervals\r\n */\r\n public coincidentArcIntersectionXY(arcA: Arc3d, arcB: Arc3d, _restrictToBounds: boolean = true): CurveLocationDetailPair[] | undefined {\r\n let result: CurveLocationDetailPair[] | undefined;\r\n if (arcA.center.isAlmostEqual(arcB.center, this.tolerance)) {\r\n const matrixBToA = arcA.matrixRef.multiplyMatrixInverseMatrix(arcB.matrixRef);\r\n if (matrixBToA) {\r\n const ux = matrixBToA.at(0, 0); const uy = matrixBToA.at(1, 0);\r\n const vx = matrixBToA.at(0, 1); const vy = matrixBToA.at(1, 1);\r\n const ru = Geometry.hypotenuseXY(ux, uy);\r\n const rv = Geometry.hypotenuseXY(vx, vy);\r\n const dot = Geometry.dotProductXYXY(ux, uy, vx, vy);\r\n const cross = Geometry.crossProductXYXY(ux, uy, vx, vy);\r\n if (Geometry.isAlmostEqualNumber(ru, 1.0)\r\n && Geometry.isAlmostEqualNumber(rv, 1.0)\r\n && Geometry.isAlmostEqualNumber(0, dot)) {\r\n const alphaB0Radians = Math.atan2(uy, ux); // angular position of arcB 0 point in arcA sweep\r\n const sweepDirection = cross > 0 ? 1.0 : -1.0; // 1 if arcB parameter space sweeps in same direction as arcA, -1 if opposite\r\n const betaStartRadians = alphaB0Radians + sweepDirection * arcB.sweep.startRadians; // arcB start in arcA parameter space\r\n const betaEndRadians = alphaB0Radians + sweepDirection * arcB.sweep.endRadians; // arcB end in arcA parameter space\r\n const fractionSpacesReversed = (sweepDirection * arcA.sweep.sweepRadians * arcB.sweep.sweepRadians) < 0;\r\n const sweepB = AngleSweep.createStartEndRadians(betaStartRadians, betaEndRadians);\r\n const sweepA = arcA.sweep;\r\n const fractionPeriodA = sweepA.fractionPeriod();\r\n const fractionB0 = sweepA.radiansToPositivePeriodicFraction(sweepB.startRadians); // arcB start in arcA fraction space\r\n assert(fractionB0 >= 0.0);\r\n const fractionSweep = sweepB.sweepRadians / sweepA.sweepRadians; // arcB sweep in arcA fraction space\r\n const fractionB1 = fractionB0 + fractionSweep; // arcB end in arcA fraction space\r\n const fractionSweepB = Segment1d.create(fractionB0, fractionB1);\r\n\r\n /** lambda to add a coincident interval or isolated intersection, given inputs in arcA fraction space\r\n * @param arcBInArcAFractionSpace span of arcB in arcA fraction space. On return, clamped to [0,1] if nontrivial.\r\n * @param testStartOfArcA if no nontrivial coincident interval was found, look for an isolated intersection at the start (true) or end (false) of arcA\r\n * @returns whether a detail pair was appended to result\r\n */\r\n const appendCoincidentIntersection = (arcBInArcAFractionSpace: Segment1d, testStartOfArcA: boolean): boolean => {\r\n const size = result ? result.length : 0;\r\n const arcBStart = arcBInArcAFractionSpace.x0;\r\n const arcBEnd = arcBInArcAFractionSpace.x1;\r\n if (arcBInArcAFractionSpace.clampDirectedTo01() && !Geometry.isSmallRelative(arcBInArcAFractionSpace.absoluteDelta())) {\r\n result = this.appendDetailPair(result, this.createDetailPair(arcA, arcB, arcBInArcAFractionSpace, arcBStart, arcBEnd, fractionSpacesReversed));\r\n } else { // test isolated intersection\r\n const testStartOfArcB = fractionSpacesReversed ? testStartOfArcA : !testStartOfArcA;\r\n const arcAPt = this._point0 = testStartOfArcA ? arcA.startPoint(this._point0): arcA.endPoint(this._point0);\r\n const arcBPt = this._point1 = testStartOfArcB ? arcB.startPoint(this._point1): arcB.endPoint(this._point1);\r\n if (arcAPt.isAlmostEqual(arcBPt, this.tolerance)) {\r\n const detailA = CurveLocationDetail.createCurveFractionPoint(arcA, testStartOfArcA ? 0 : 1, arcAPt);\r\n const detailB = CurveLocationDetail.createCurveFractionPoint(arcB, testStartOfArcB ? 0 : 1, arcBPt);\r\n result = this.appendDetailPair(result, CurveLocationDetailPair.createCapture(detailA, detailB));\r\n }\r\n }\r\n return result !== undefined && result.length > size;\r\n };\r\n\r\n appendCoincidentIntersection(fractionSweepB, false); // compute overlap in strict interior, or at end of arcA\r\n\r\n // check overlap at start of arcA with a periodic shift of fractionSweepB\r\n if (fractionB1 >= fractionPeriodA)\r\n appendCoincidentIntersection(Segment1d.create(fractionB0 - fractionPeriodA, fractionB1 - fractionPeriodA), true);\r\n else if (fractionB0 === 0.0)\r\n appendCoincidentIntersection(Segment1d.create(fractionB0 + fractionPeriodA, fractionB1 + fractionPeriodA), true);\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n}\r\n"]}
|
|
@@ -2387,7 +2387,7 @@ class Matrix3d {
|
|
|
2387
2387
|
* almost independent and matrix is invertible).
|
|
2388
2388
|
*/
|
|
2389
2389
|
conditionNumber() {
|
|
2390
|
-
const determinant = this.determinant();
|
|
2390
|
+
const determinant = Math.abs(this.determinant());
|
|
2391
2391
|
const columnMagnitudeSum = Geometry_1.Geometry.hypotenuseXYZ(this.coffs[0], this.coffs[3], this.coffs[6])
|
|
2392
2392
|
+ Geometry_1.Geometry.hypotenuseXYZ(this.coffs[1], this.coffs[4], this.coffs[7])
|
|
2393
2393
|
+ Geometry_1.Geometry.hypotenuseXYZ(this.coffs[2], this.coffs[5], this.coffs[8]);
|