@itwin/core-geometry 5.3.0-dev.9 → 5.4.0-dev.3
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 +21 -1
- package/lib/cjs/curve/Arc3d.d.ts +15 -1
- package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
- package/lib/cjs/curve/Arc3d.js +31 -2
- package/lib/cjs/curve/Arc3d.js.map +1 -1
- package/lib/cjs/curve/CurveFactory.d.ts +25 -8
- package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
- package/lib/cjs/curve/CurveFactory.js +51 -55
- package/lib/cjs/curve/CurveFactory.js.map +1 -1
- package/lib/cjs/curve/spiral/AustralianRailCorpXYEvaluator.d.ts +10 -13
- package/lib/cjs/curve/spiral/AustralianRailCorpXYEvaluator.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/AustralianRailCorpXYEvaluator.js +23 -22
- package/lib/cjs/curve/spiral/AustralianRailCorpXYEvaluator.js.map +1 -1
- package/lib/cjs/curve/spiral/ClothoidSeries.d.ts +10 -6
- package/lib/cjs/curve/spiral/ClothoidSeries.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/ClothoidSeries.js +36 -19
- package/lib/cjs/curve/spiral/ClothoidSeries.js.map +1 -1
- package/lib/cjs/curve/spiral/CubicEvaluator.d.ts +7 -6
- package/lib/cjs/curve/spiral/CubicEvaluator.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/CubicEvaluator.js +29 -14
- package/lib/cjs/curve/spiral/CubicEvaluator.js.map +1 -1
- package/lib/cjs/curve/spiral/CzechSpiralEvaluator.d.ts +34 -44
- package/lib/cjs/curve/spiral/CzechSpiralEvaluator.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/CzechSpiralEvaluator.js +47 -53
- package/lib/cjs/curve/spiral/CzechSpiralEvaluator.js.map +1 -1
- package/lib/cjs/curve/spiral/DirectHalfCosineSpiralEvaluator.d.ts +2 -2
- package/lib/cjs/curve/spiral/DirectHalfCosineSpiralEvaluator.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/DirectHalfCosineSpiralEvaluator.js +17 -7
- package/lib/cjs/curve/spiral/DirectHalfCosineSpiralEvaluator.js.map +1 -1
- package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts +112 -104
- package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/DirectSpiral3d.js +143 -117
- package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
- package/lib/cjs/curve/spiral/IntegratedSpiral3d.d.ts +71 -53
- package/lib/cjs/curve/spiral/IntegratedSpiral3d.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/IntegratedSpiral3d.js +99 -66
- package/lib/cjs/curve/spiral/IntegratedSpiral3d.js.map +1 -1
- package/lib/cjs/curve/spiral/MXCubicAlongArcSpiralEvaluator.d.ts +8 -12
- package/lib/cjs/curve/spiral/MXCubicAlongArcSpiralEvaluator.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/MXCubicAlongArcSpiralEvaluator.js +11 -13
- package/lib/cjs/curve/spiral/MXCubicAlongArcSpiralEvaluator.js.map +1 -1
- package/lib/cjs/curve/spiral/NormalizedTransition.d.ts +36 -29
- package/lib/cjs/curve/spiral/NormalizedTransition.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/NormalizedTransition.js +62 -40
- package/lib/cjs/curve/spiral/NormalizedTransition.js.map +1 -1
- package/lib/cjs/curve/spiral/PolishCubicSpiralEvaluator.d.ts +13 -18
- package/lib/cjs/curve/spiral/PolishCubicSpiralEvaluator.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/PolishCubicSpiralEvaluator.js +21 -24
- package/lib/cjs/curve/spiral/PolishCubicSpiralEvaluator.js.map +1 -1
- package/lib/cjs/curve/spiral/TransitionConditionalProperties.d.ts +41 -27
- package/lib/cjs/curve/spiral/TransitionConditionalProperties.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/TransitionConditionalProperties.js +50 -33
- package/lib/cjs/curve/spiral/TransitionConditionalProperties.js.map +1 -1
- package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts +45 -34
- package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/TransitionSpiral3d.js +56 -38
- package/lib/cjs/curve/spiral/TransitionSpiral3d.js.map +1 -1
- package/lib/cjs/curve/spiral/XYCurveEvaluator.d.ts +27 -21
- package/lib/cjs/curve/spiral/XYCurveEvaluator.d.ts.map +1 -1
- package/lib/cjs/curve/spiral/XYCurveEvaluator.js +23 -18
- package/lib/cjs/curve/spiral/XYCurveEvaluator.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.d.ts +96 -98
- package/lib/cjs/geometry3d/GrowableXYArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYArray.js +121 -110
- package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +135 -142
- package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/cjs/geometry3d/GrowableXYZArray.js +165 -160
- package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYCollection.d.ts +51 -34
- package/lib/cjs/geometry3d/IndexedXYCollection.d.ts.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYCollection.js +16 -6
- package/lib/cjs/geometry3d/IndexedXYCollection.js.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +78 -77
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.js +38 -35
- package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.d.ts +27 -7
- package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PolygonOps.js +30 -9
- package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
- package/lib/esm/curve/Arc3d.d.ts +15 -1
- package/lib/esm/curve/Arc3d.d.ts.map +1 -1
- package/lib/esm/curve/Arc3d.js +31 -2
- package/lib/esm/curve/Arc3d.js.map +1 -1
- package/lib/esm/curve/CurveFactory.d.ts +25 -8
- package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
- package/lib/esm/curve/CurveFactory.js +51 -55
- package/lib/esm/curve/CurveFactory.js.map +1 -1
- package/lib/esm/curve/spiral/AustralianRailCorpXYEvaluator.d.ts +10 -13
- package/lib/esm/curve/spiral/AustralianRailCorpXYEvaluator.d.ts.map +1 -1
- package/lib/esm/curve/spiral/AustralianRailCorpXYEvaluator.js +23 -22
- package/lib/esm/curve/spiral/AustralianRailCorpXYEvaluator.js.map +1 -1
- package/lib/esm/curve/spiral/ClothoidSeries.d.ts +10 -6
- package/lib/esm/curve/spiral/ClothoidSeries.d.ts.map +1 -1
- package/lib/esm/curve/spiral/ClothoidSeries.js +36 -19
- package/lib/esm/curve/spiral/ClothoidSeries.js.map +1 -1
- package/lib/esm/curve/spiral/CubicEvaluator.d.ts +7 -6
- package/lib/esm/curve/spiral/CubicEvaluator.d.ts.map +1 -1
- package/lib/esm/curve/spiral/CubicEvaluator.js +29 -14
- package/lib/esm/curve/spiral/CubicEvaluator.js.map +1 -1
- package/lib/esm/curve/spiral/CzechSpiralEvaluator.d.ts +34 -44
- package/lib/esm/curve/spiral/CzechSpiralEvaluator.d.ts.map +1 -1
- package/lib/esm/curve/spiral/CzechSpiralEvaluator.js +47 -53
- package/lib/esm/curve/spiral/CzechSpiralEvaluator.js.map +1 -1
- package/lib/esm/curve/spiral/DirectHalfCosineSpiralEvaluator.d.ts +2 -2
- package/lib/esm/curve/spiral/DirectHalfCosineSpiralEvaluator.d.ts.map +1 -1
- package/lib/esm/curve/spiral/DirectHalfCosineSpiralEvaluator.js +17 -7
- package/lib/esm/curve/spiral/DirectHalfCosineSpiralEvaluator.js.map +1 -1
- package/lib/esm/curve/spiral/DirectSpiral3d.d.ts +112 -104
- package/lib/esm/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
- package/lib/esm/curve/spiral/DirectSpiral3d.js +143 -117
- package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
- package/lib/esm/curve/spiral/IntegratedSpiral3d.d.ts +71 -53
- package/lib/esm/curve/spiral/IntegratedSpiral3d.d.ts.map +1 -1
- package/lib/esm/curve/spiral/IntegratedSpiral3d.js +99 -66
- package/lib/esm/curve/spiral/IntegratedSpiral3d.js.map +1 -1
- package/lib/esm/curve/spiral/MXCubicAlongArcSpiralEvaluator.d.ts +8 -12
- package/lib/esm/curve/spiral/MXCubicAlongArcSpiralEvaluator.d.ts.map +1 -1
- package/lib/esm/curve/spiral/MXCubicAlongArcSpiralEvaluator.js +11 -13
- package/lib/esm/curve/spiral/MXCubicAlongArcSpiralEvaluator.js.map +1 -1
- package/lib/esm/curve/spiral/NormalizedTransition.d.ts +36 -29
- package/lib/esm/curve/spiral/NormalizedTransition.d.ts.map +1 -1
- package/lib/esm/curve/spiral/NormalizedTransition.js +62 -40
- package/lib/esm/curve/spiral/NormalizedTransition.js.map +1 -1
- package/lib/esm/curve/spiral/PolishCubicSpiralEvaluator.d.ts +13 -18
- package/lib/esm/curve/spiral/PolishCubicSpiralEvaluator.d.ts.map +1 -1
- package/lib/esm/curve/spiral/PolishCubicSpiralEvaluator.js +21 -24
- package/lib/esm/curve/spiral/PolishCubicSpiralEvaluator.js.map +1 -1
- package/lib/esm/curve/spiral/TransitionConditionalProperties.d.ts +41 -27
- package/lib/esm/curve/spiral/TransitionConditionalProperties.d.ts.map +1 -1
- package/lib/esm/curve/spiral/TransitionConditionalProperties.js +50 -33
- package/lib/esm/curve/spiral/TransitionConditionalProperties.js.map +1 -1
- package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts +45 -34
- package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
- package/lib/esm/curve/spiral/TransitionSpiral3d.js +56 -38
- package/lib/esm/curve/spiral/TransitionSpiral3d.js.map +1 -1
- package/lib/esm/curve/spiral/XYCurveEvaluator.d.ts +27 -21
- package/lib/esm/curve/spiral/XYCurveEvaluator.d.ts.map +1 -1
- package/lib/esm/curve/spiral/XYCurveEvaluator.js +23 -18
- package/lib/esm/curve/spiral/XYCurveEvaluator.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.d.ts +96 -98
- package/lib/esm/geometry3d/GrowableXYArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableXYArray.js +122 -111
- package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts +135 -142
- package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
- package/lib/esm/geometry3d/GrowableXYZArray.js +165 -160
- package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
- package/lib/esm/geometry3d/IndexedXYCollection.d.ts +51 -34
- package/lib/esm/geometry3d/IndexedXYCollection.d.ts.map +1 -1
- package/lib/esm/geometry3d/IndexedXYCollection.js +14 -5
- package/lib/esm/geometry3d/IndexedXYCollection.js.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +78 -77
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.js +38 -35
- package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.d.ts +27 -7
- package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/PolygonOps.js +30 -9
- package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
- package/package.json +3 -3
|
@@ -16,31 +16,38 @@ const OffsetOptions_1 = require("../OffsetOptions");
|
|
|
16
16
|
/**
|
|
17
17
|
* TransitionSpiral3d is a base class for multiple variants of spirals.
|
|
18
18
|
* * The menagerie of spiral types have 2 broad categories:
|
|
19
|
-
* * IntegratedSpiral3d -- a spiral whose direct function for curvature versus distance must be integrated to
|
|
20
|
-
*
|
|
19
|
+
* * IntegratedSpiral3d -- a spiral whose direct function for curvature versus distance must be integrated to
|
|
20
|
+
* determine x,y.
|
|
21
|
+
* * The IntegratedSpiral3d types are enumerated in `IntegratedSpiralTypes`.
|
|
21
22
|
* * DirectSpiral3d -- a spiral implemented with direct calculation of x,y from fractional position along the spiral.
|
|
22
|
-
* * The direct spiral types are enumerated in the `DirectSpiralType
|
|
23
|
-
* * The method set for CurvePrimitive support includes a `handleTransitionSpiral(g: TransitionSpiral3d)` which receives
|
|
23
|
+
* * The direct spiral types are enumerated in the `DirectSpiralType`.
|
|
24
|
+
* * The method set for CurvePrimitive support includes a `handleTransitionSpiral(g: TransitionSpiral3d)` which receives
|
|
25
|
+
* all the spiral types.
|
|
24
26
|
* * The spiral class may impose expectations that its inflection is at the origin, with tangent along the x axis.
|
|
25
27
|
* * This is generally necessary for direct spirals.
|
|
26
28
|
* * This is not necessary for integrated spirals.
|
|
27
29
|
* @public
|
|
28
30
|
*/
|
|
29
31
|
class TransitionSpiral3d extends CurvePrimitive_1.CurvePrimitive {
|
|
30
|
-
/**
|
|
32
|
+
/** String name of spiral type. */
|
|
31
33
|
_spiralType;
|
|
32
34
|
/** Original defining properties. */
|
|
33
35
|
_designProperties;
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
+
/** Placement transform. */
|
|
37
|
+
_localToWorld;
|
|
38
|
+
/**
|
|
39
|
+
* Fractional interval for the "active" part of a containing spiral.
|
|
40
|
+
* (the radius, angle, and length conditions define a complete spiral, and some portion of it is "active")
|
|
36
41
|
*/
|
|
37
42
|
_activeFractionInterval;
|
|
38
43
|
/** Return (reference to) the active portion of the reference spiral. */
|
|
39
|
-
get activeFractionInterval() {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/** (
|
|
43
|
-
get localToWorld() {
|
|
44
|
+
get activeFractionInterval() {
|
|
45
|
+
return this._activeFractionInterval;
|
|
46
|
+
}
|
|
47
|
+
/** (Reference to) placement transform. */
|
|
48
|
+
get localToWorld() {
|
|
49
|
+
return this._localToWorld;
|
|
50
|
+
}
|
|
44
51
|
constructor(spiralType, localToWorld, activeFractionInterval, designProperties) {
|
|
45
52
|
super();
|
|
46
53
|
this._spiralType = spiralType ? spiralType : "unknownSpiralType";
|
|
@@ -48,10 +55,14 @@ class TransitionSpiral3d extends CurvePrimitive_1.CurvePrimitive {
|
|
|
48
55
|
this._localToWorld = localToWorld;
|
|
49
56
|
this._activeFractionInterval = activeFractionInterval ? activeFractionInterval : Segment1d_1.Segment1d.create(0, 1);
|
|
50
57
|
}
|
|
51
|
-
get spiralType() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/** Return 1/
|
|
58
|
+
get spiralType() {
|
|
59
|
+
return this._spiralType;
|
|
60
|
+
}
|
|
61
|
+
/** Return 1/r with convention that exact zero input returns 0 (straight line, zero curvature, infinite radius). */
|
|
62
|
+
static radiusToCurvature(radius) {
|
|
63
|
+
return (radius === 0.0) ? 0.0 : 1.0 / radius;
|
|
64
|
+
}
|
|
65
|
+
/** Return 1/k with convention that near-zero input returns 0 (straight line, zero curvature, infinite radius). */
|
|
55
66
|
static curvatureToRadius(curvature) {
|
|
56
67
|
if (Math.abs(curvature) < Geometry_1.Geometry.smallAngleRadians)
|
|
57
68
|
return 0.0;
|
|
@@ -66,10 +77,10 @@ class TransitionSpiral3d extends CurvePrimitive_1.CurvePrimitive {
|
|
|
66
77
|
spiralB.refreshComputedProperties();
|
|
67
78
|
return spiralB;
|
|
68
79
|
}
|
|
69
|
-
/** Clone with a transform applied */
|
|
80
|
+
/** Clone with a transform applied. */
|
|
70
81
|
cloneTransformed(transform) {
|
|
71
82
|
const result = this.clone();
|
|
72
|
-
result.tryTransformInPlace(transform); //
|
|
83
|
+
result.tryTransformInPlace(transform); // we're confident it will always work
|
|
73
84
|
return result;
|
|
74
85
|
}
|
|
75
86
|
/** Return the average of the start and end curvatures. */
|
|
@@ -77,17 +88,18 @@ class TransitionSpiral3d extends CurvePrimitive_1.CurvePrimitive {
|
|
|
77
88
|
return 0.5 * (TransitionSpiral3d.radiusToCurvature(radiusLimits.x0) + TransitionSpiral3d.radiusToCurvature(radiusLimits.x1));
|
|
78
89
|
}
|
|
79
90
|
/**
|
|
80
|
-
* Given two radii (or zeros for 0 curvature) return the average curvature
|
|
81
|
-
* @param r0 start radius, or 0 for line
|
|
82
|
-
* @param r1 end radius, or 0 for line
|
|
91
|
+
* Given two radii (or zeros for 0 curvature) return the average curvature.
|
|
92
|
+
* @param r0 start radius, or 0 for line.
|
|
93
|
+
* @param r1 end radius, or 0 for line.
|
|
83
94
|
*/
|
|
84
95
|
static averageCurvatureR0R1(r0, r1) {
|
|
85
96
|
return 0.5 * (TransitionSpiral3d.radiusToCurvature(r0) + TransitionSpiral3d.radiusToCurvature(r1));
|
|
86
97
|
}
|
|
87
98
|
/**
|
|
88
|
-
* Given two radii (or zeros for 0 curvature) return the
|
|
89
|
-
* @param r0 start radius, or 0 for line
|
|
90
|
-
* @param
|
|
99
|
+
* Given two radii (or zeros for 0 curvature) return the curvature at the given fraction.
|
|
100
|
+
* @param r0 start radius, or 0 for line.
|
|
101
|
+
* @param fraction fractional position between the curvatures defined by r0 and r1.
|
|
102
|
+
* @param r1 end radius, or 0 for line.
|
|
91
103
|
*/
|
|
92
104
|
static interpolateCurvatureR0R1(r0, fraction, r1) {
|
|
93
105
|
return Geometry_1.Geometry.interpolate(TransitionSpiral3d.radiusToCurvature(r0), fraction, TransitionSpiral3d.radiusToCurvature(r1));
|
|
@@ -109,9 +121,12 @@ class TransitionSpiral3d extends CurvePrimitive_1.CurvePrimitive {
|
|
|
109
121
|
return TransitionSpiral3d.curvatureToRadius((2.0 * sweepRadians / arcLength) - TransitionSpiral3d.radiusToCurvature(radius1));
|
|
110
122
|
}
|
|
111
123
|
/** Return the original defining properties (if any) saved by the constructor. */
|
|
112
|
-
get designProperties() {
|
|
124
|
+
get designProperties() {
|
|
125
|
+
return this._designProperties;
|
|
126
|
+
}
|
|
113
127
|
/**
|
|
114
|
-
* * If transformA is rigid with uniform scale, apply the rigid part of transformA to the localToWorld transform and
|
|
128
|
+
* * If transformA is rigid with uniform scale, apply the rigid part of transformA to the localToWorld transform and
|
|
129
|
+
* return the scale and rigid separation.
|
|
115
130
|
* * If not rigid, do nothing and return undefined.
|
|
116
131
|
* * Also apply the scale factor to the designProperties.
|
|
117
132
|
* @param transformA
|
|
@@ -120,9 +135,9 @@ class TransitionSpiral3d extends CurvePrimitive_1.CurvePrimitive {
|
|
|
120
135
|
const rigidData = transformA.matrix.factorRigidWithSignedScale();
|
|
121
136
|
if (rigidData !== undefined) {
|
|
122
137
|
// [sQ a][R b] = [sQ*R sQb+a]
|
|
123
|
-
// but we save it as [Q*R sQb+a] with spiral data scaled by s
|
|
138
|
+
// but we save it as [Q*R sQb+a] with spiral data scaled by s
|
|
124
139
|
const transformC0 = transformA.multiplyTransformTransform(this.localToWorld);
|
|
125
|
-
//
|
|
140
|
+
// but pull the scale part out of the matrix
|
|
126
141
|
const matrixC = rigidData.rigidAxes.multiplyMatrixMatrix(this.localToWorld.matrix);
|
|
127
142
|
this._localToWorld = Transform_1.Transform.createOriginAndMatrix(transformC0.origin, matrixC);
|
|
128
143
|
if (this.designProperties)
|
|
@@ -133,9 +148,9 @@ class TransitionSpiral3d extends CurvePrimitive_1.CurvePrimitive {
|
|
|
133
148
|
}
|
|
134
149
|
/**
|
|
135
150
|
* Construct an offset of the instance curve as viewed in the xy-plane (ignoring z).
|
|
136
|
-
* * No attempt is made to join the offsets of smaller constituent primitives. To construct a fully joined offset
|
|
137
|
-
*
|
|
138
|
-
* @param offsetDistanceOrOptions offset distance (positive to left of the instance curve), or options object
|
|
151
|
+
* * No attempt is made to join the offsets of smaller constituent primitives. To construct a fully joined offset for an
|
|
152
|
+
* aggregate instance (e.g., LineString3d, CurveChainWithDistanceIndex), use RegionOps.constructCurveXYOffset() instead.
|
|
153
|
+
* @param offsetDistanceOrOptions offset distance (positive to left of the instance curve), or options object.
|
|
139
154
|
*/
|
|
140
155
|
constructOffsetXY(offsetDistanceOrOptions) {
|
|
141
156
|
const options = OffsetOptions_1.OffsetOptions.create(offsetDistanceOrOptions);
|
|
@@ -143,13 +158,13 @@ class TransitionSpiral3d extends CurvePrimitive_1.CurvePrimitive {
|
|
|
143
158
|
this.emitStrokableParts(handler, options.strokeOptions);
|
|
144
159
|
return handler.claimResult();
|
|
145
160
|
}
|
|
146
|
-
/**
|
|
161
|
+
/** Extend the range by the strokes of the spiral. */
|
|
147
162
|
extendRange(rangeToExtend, transform) {
|
|
148
|
-
|
|
149
|
-
rangeToExtend.extendRange(myRange);
|
|
163
|
+
rangeToExtend.extendRange(this.rangeBetweenFractions(0.0, 1.0, transform));
|
|
150
164
|
}
|
|
151
|
-
/**
|
|
152
|
-
*
|
|
165
|
+
/**
|
|
166
|
+
* Return the range of spiral between fractions of the activeStrokes.
|
|
167
|
+
* * Use activeStrokes point count times interval factor for initial evaluation count, but do at least 5.
|
|
153
168
|
*/
|
|
154
169
|
rangeBetweenFractions(fractionA, fractionB, transform) {
|
|
155
170
|
const strokes = this.activeStrokes;
|
|
@@ -159,10 +174,13 @@ class TransitionSpiral3d extends CurvePrimitive_1.CurvePrimitive {
|
|
|
159
174
|
count = Geometry_1.Geometry.clamp(5, count, 30);
|
|
160
175
|
return this.rangeBetweenFractionsByCount(fractionA, fractionB, count, transform, 0.5);
|
|
161
176
|
}
|
|
162
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* Project instance geometry (via dispatch) onto the given ray, and return the extreme fractional parameters of
|
|
179
|
+
* projection.
|
|
163
180
|
* @param ray ray onto which the instance is projected. A `Vector3d` is treated as a `Ray3d` with zero origin.
|
|
164
181
|
* @param lowHigh optional receiver for output
|
|
165
|
-
* @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the
|
|
182
|
+
* @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the
|
|
183
|
+
* end of the ray.
|
|
166
184
|
*/
|
|
167
185
|
projectedParameterRange(ray, lowHigh) {
|
|
168
186
|
return PlaneAltitudeRangeContext_1.PlaneAltitudeRangeContext.findExtremeFractionsAlongDirection(this, ray, lowHigh);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransitionSpiral3d.js","sourceRoot":"","sources":["../../../../src/curve/spiral/TransitionSpiral3d.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAO/F,6CAA0C;AAE1C,kDAA0D;AAC1D,0DAAuD;AACvD,0DAAuD;AACvD,sDAAmD;AACnD,mFAAgF;AAChF,6FAA0F;AAE1F,oDAAiD;AAsCjD;;;;;;;;;;;;GAYG;AACH,MAAsB,kBAAmB,SAAQ,+BAAc;IAC7D,iCAAiC;IACvB,WAAW,CAAS;IAC9B,oCAAoC;IAC1B,iBAAiB,CAA8C;IAEzE;;OAEG;IACO,uBAAuB,CAAY;IAC7C,wEAAwE;IACxE,IAAW,sBAAsB,KAAgB,OAAO,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC;IAGvF,0BAA0B;IAChB,aAAa,CAAY;IACnC,0CAA0C;IAC1C,IAAW,YAAY,KAAgB,OAAO,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;IAEnE,YAAsB,UAA8B,EAAE,YAAuB,EAAE,sBAA6C,EAAE,gBAA6D;QACzL,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,mBAAmB,CAAC;QACjE,IAAI,CAAC,iBAAiB,GAAG,gBAAgB,CAAC;QAC1C,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,uBAAuB,GAAG,sBAAsB,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,qBAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1G,CAA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,CAAC,aAAsB,EAAE,SAAqB;QACvE,MAAM,OAAO,GAAG,IAAI,CAAC,qBAAqB,CAAE,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QACjE,aAAa,CAAC,WAAW,CAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACc,qBAAqB,CAAC,SAAiB,EAAE,SAAiB,EAAE,SAAqB;QAChG,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC;QACnC,IAAI,SAAS,KAAK,OAAO;YACvB,OAAO,eAAO,CAAC,UAAU,EAAG,CAAC;QAC/B,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,CAAE,OAAO,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,GAAG,CAAE,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC;QAC/E,KAAK,GAAG,mBAAQ,CAAC,KAAK,CAAE,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,4BAA4B,CAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;IACzF,CAAC;IACD;;;;OAIG;IACa,uBAAuB,CAAC,GAAqB,EAAE,OAAiB;QAC9E,OAAO,qDAAyB,CAAC,kCAAkC,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1F,CAAC;CACF;AAlKD,gDAkKC","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\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { BSplineCurve3d } from \"../../bspline/BSplineCurve\";\nimport { Geometry } from \"../../Geometry\";\nimport { Matrix3d } from \"../../geometry3d/Matrix3d\";\nimport { Range1d, Range3d } from \"../../geometry3d/Range\";\nimport { Segment1d } from \"../../geometry3d/Segment1d\";\nimport { Transform } from \"../../geometry3d/Transform\";\nimport { CurvePrimitive } from \"../CurvePrimitive\";\nimport { CurveOffsetXYHandler } from \"../internalContexts/CurveOffsetXYHandler\";\nimport { PlaneAltitudeRangeContext } from \"../internalContexts/PlaneAltitudeRangeContext\";\nimport { LineString3d } from \"../LineString3d\";\nimport { OffsetOptions } from \"../OffsetOptions\";\nimport { TransitionConditionalProperties } from \"./TransitionConditionalProperties\";\n\nimport type { Vector3d } from \"../../geometry3d/Point3dVector3d\";\nimport type { Ray3d } from \"../../geometry3d/Ray3d\";\n/**\n * This is the set of valid type names for \"integrated\" spirals\n * * Behavior is expressed by a `NormalizedTransition` snap function.\n * * The snap function varies smoothly from f(0)=0 to f(1)=1\n * * The various snap functions are:\n * * clothoid: linear\n * * biquadratic: 2 quadratics pieced together, joining with 1st derivative continuity at f(0.) = 0.5, with zero slope f'(0)=0 and f'(1)= 0\n * * bloss: A single cubic with zero slope at 0 and 1\n * * cosine: half of a cosine wave, centered around 0.5\n * * sine: full period of a sine wave added to the line f(u)=u\n * *\n * @public\n */\nexport type IntegratedSpiralTypeName = \"clothoid\" | \"bloss\" | \"biquadratic\" | \"cosine\" | \"sine\";\n\n/**\n * This is the set of valid type names for \"direct\" spirals.\n * \"Direct\" spirals can evaluate fractionToPoint by direct equations, i.e. not requiring the numeric integrations in \"Integrated\" spiral types.\n * @public\n */\nexport type DirectSpiralTypeName =\n \"JapaneseCubic\" // 1 term from each of the X,Y clothoid series expansions: y = x^3 / (6RL)\n | \"Arema\" // 2 terms from each of the X,Y clothoid series expansions. Identical to ChineseCubic!\n | \"ChineseCubic\" // Identical to Arema!\n | \"HalfCosine\" // high continuity cosine variation from quadratic.\n | \"AustralianRailCorp\" // cubic with high accuracy distance series\n | \"WesternAustralian\" // simple cubic -- 2 terms of x series, 1 term of y series.\n | \"Czech\" // simple cubic with two term distance approximation\n | \"MXCubicAlongArc\" // x obtained from fractional distance via 2-terms from series, y = x^3/ (6RL)\n | \"Polish\"\n | \"Italian\"\n ;\n\n/**\n * TransitionSpiral3d is a base class for multiple variants of spirals.\n * * The menagerie of spiral types have 2 broad categories:\n * * IntegratedSpiral3d -- a spiral whose direct function for curvature versus distance must be integrated to determine x,y\n * * The IntegratedSpiral3d types are enumerated in `IntegratedSpiralTypes`\n * * DirectSpiral3d -- a spiral implemented with direct calculation of x,y from fractional position along the spiral.\n * * The direct spiral types are enumerated in the `DirectSpiralType`\n * * The method set for CurvePrimitive support includes a `handleTransitionSpiral(g: TransitionSpiral3d)` which receives all the spiral types.\n * * The spiral class may impose expectations that its inflection is at the origin, with tangent along the x axis.\n * * This is generally necessary for direct spirals.\n * * This is not necessary for integrated spirals.\n * @public\n */\nexport abstract class TransitionSpiral3d extends CurvePrimitive {\n /** string name of spiral type */\n protected _spiralType: string;\n /** Original defining properties. */\n protected _designProperties: TransitionConditionalProperties | undefined;\n\n /** Fractional interval for the \"active\" part of a containing spiral.\n * (The radius, angle, and length conditions define a complete spiral, and some portion of it is \"active\")\n */\n protected _activeFractionInterval: Segment1d;\n /** Return (reference to) the active portion of the reference spiral. */\n public get activeFractionInterval(): Segment1d { return this._activeFractionInterval; }\n /** strokes in the active portion */\n public abstract get activeStrokes(): LineString3d;\n /** Placement transform */\n protected _localToWorld: Transform;\n /** (reference to) placement transform. */\n public get localToWorld(): Transform { return this._localToWorld; }\n\n protected constructor(spiralType: string | undefined, localToWorld: Transform, activeFractionInterval: Segment1d | undefined, designProperties: TransitionConditionalProperties | undefined) {\n super();\n this._spiralType = spiralType ? spiralType : \"unknownSpiralType\";\n this._designProperties = designProperties;\n this._localToWorld = localToWorld;\n this._activeFractionInterval = activeFractionInterval ? activeFractionInterval : Segment1d.create(0, 1);\n }\n\n public get spiralType(): string { return this._spiralType; }\n /** Return 1/r with convention that if true zero is given as radius it represents infinite radius (0 curvature, straight line) */\n public static radiusToCurvature(radius: number): number { return (radius === 0.0) ? 0.0 : 1.0 / radius; }\n\n /** Return 1/k with convention that if near-zero is given as curvature, its infinite radius is returned as 0 */\n public static curvatureToRadius(curvature: number): number {\n if (Math.abs(curvature) < Geometry.smallAngleRadians)\n return 0.0;\n return 1.0 / curvature;\n }\n\n /** Return a deep clone. */\n public abstract override clone(): TransitionSpiral3d;\n\n /** Recompute strokes */\n public abstract refreshComputedProperties(): void;\n\n /** Return (if possible) a spiral which is a portion of this curve. */\n public override clonePartialCurve(fractionA: number, fractionB: number): TransitionSpiral3d {\n const spiralB = this.clone();\n const globalFractionA = this._activeFractionInterval.fractionToPoint(fractionA);\n const globalFractionB = this._activeFractionInterval.fractionToPoint(fractionB);\n spiralB._activeFractionInterval.set(globalFractionA, globalFractionB);\n spiralB.refreshComputedProperties();\n return spiralB;\n }\n\n /** Clone with a transform applied */\n public override cloneTransformed(transform: Transform): TransitionSpiral3d {\n const result = this.clone();\n result.tryTransformInPlace(transform); // ok, we're confident it will always work.\n return result;\n }\n\n /** Return the average of the start and end curvatures. */\n public static averageCurvature(radiusLimits: Segment1d): number {\n return 0.5 * (TransitionSpiral3d.radiusToCurvature(radiusLimits.x0) + TransitionSpiral3d.radiusToCurvature(radiusLimits.x1));\n }\n /**\n * Given two radii (or zeros for 0 curvature) return the average curvature\n * @param r0 start radius, or 0 for line\n * @param r1 end radius, or 0 for line\n */\n public static averageCurvatureR0R1(r0: number, r1: number): number {\n return 0.5 * (TransitionSpiral3d.radiusToCurvature(r0) + TransitionSpiral3d.radiusToCurvature(r1));\n }\n /**\n * Given two radii (or zeros for 0 curvature) return the average curvature\n * @param r0 start radius, or 0 for line\n * @param r1 end radius, or 0 for line\n */\n public static interpolateCurvatureR0R1(r0: number, fraction: number, r1: number): number {\n return Geometry.interpolate(TransitionSpiral3d.radiusToCurvature(r0), fraction, TransitionSpiral3d.radiusToCurvature(r1));\n }\n\n /** Return the arc length of a transition spiral with given sweep and radius pair. */\n public static radiusRadiusSweepRadiansToArcLength(radius0: number, radius1: number, sweepRadians: number): number {\n return Math.abs(sweepRadians / TransitionSpiral3d.averageCurvatureR0R1(radius0, radius1));\n }\n\n /** Return the turn angle for spiral of given length between two radii */\n public static radiusRadiusLengthToSweepRadians(radius0: number, radius1: number, arcLength: number): number {\n return TransitionSpiral3d.averageCurvatureR0R1(radius0, radius1) * arcLength;\n }\n\n /** Return the end radius for spiral of given start radius, length, and turn angle. */\n public static radius0LengthSweepRadiansToRadius1(radius0: number, arcLength: number, sweepRadians: number) {\n return TransitionSpiral3d.curvatureToRadius((2.0 * sweepRadians / arcLength) - TransitionSpiral3d.radiusToCurvature(radius0));\n }\n /** Return the start radius for spiral of given end radius, length, and turn angle. */\n public static radius1LengthSweepRadiansToRadius0(radius1: number, arcLength: number, sweepRadians: number) {\n return TransitionSpiral3d.curvatureToRadius((2.0 * sweepRadians / arcLength) - TransitionSpiral3d.radiusToCurvature(radius1));\n }\n /** Return the original defining properties (if any) saved by the constructor. */\n public get designProperties(): TransitionConditionalProperties | undefined { return this._designProperties; }\n /**\n * * If transformA is rigid with uniform scale, apply the rigid part of transformA to the localToWorld transform and return the scale and rigid separation.\n * * If not rigid, do nothing and return undefined.\n * * Also apply the scale factor to the designProperties.\n * @param transformA\n */\n protected applyRigidPartOfTransform(transformA: Transform): { rigidAxes: Matrix3d, scale: number } | undefined {\n const rigidData = transformA.matrix.factorRigidWithSignedScale();\n if (rigidData !== undefined) {\n // [sQ a][R b] = [sQ*R sQb+a]\n // but we save it as [Q*R sQb+a] with spiral data scaled by s.\n const transformC0 = transformA.multiplyTransformTransform(this.localToWorld);\n // BUT pull the scale part out of the matrix ...\n const matrixC = rigidData.rigidAxes.multiplyMatrixMatrix(this.localToWorld.matrix);\n this._localToWorld = Transform.createOriginAndMatrix(transformC0.origin, matrixC);\n if (this.designProperties)\n this.designProperties.applyScaleFactor(rigidData.scale);\n\n return rigidData;\n }\n return undefined;\n }\n\n /**\n * Construct an offset of the instance curve as viewed in the xy-plane (ignoring z).\n * * No attempt is made to join the offsets of smaller constituent primitives. To construct a fully joined offset\n * for an aggregate instance (e.g., LineString3d, CurveChainWithDistanceIndex), use RegionOps.constructCurveXYOffset() instead.\n * @param offsetDistanceOrOptions offset distance (positive to left of the instance curve), or options object\n */\n public override constructOffsetXY(offsetDistanceOrOptions: number | OffsetOptions): BSplineCurve3d | undefined {\n const options = OffsetOptions.create(offsetDistanceOrOptions);\n const handler = new CurveOffsetXYHandler(this, options.leftOffsetDistance);\n this.emitStrokableParts(handler, options.strokeOptions);\n return handler.claimResult();\n }\n /** extend the range by the strokes of the spiral */\n public override extendRange(rangeToExtend: Range3d, transform?: Transform): void {\n const myRange = this.rangeBetweenFractions (0.0, 1.0, transform);\n rangeToExtend.extendRange (myRange);\n }\n\n /** return the range of spiral between fractions of the activeStrokes.\n * * Use activeStrokes point count times interval factor for initial evaluation count, but do at least 5\n */\n public override rangeBetweenFractions(fractionA: number, fractionB: number, transform?: Transform): Range3d {\n const strokes = this.activeStrokes;\n if (undefined === strokes)\n return Range3d.createNull ();\n let count = Math.ceil (strokes.numPoints() * Math.abs (fractionB - fractionA));\n count = Geometry.clamp (5, count, 30);\n return this.rangeBetweenFractionsByCount (fractionA, fractionB, count, transform, 0.5);\n }\n /** Project instance geometry (via dispatch) onto the given ray, and return the extreme fractional parameters of projection.\n * @param ray ray onto which the instance is projected. A `Vector3d` is treated as a `Ray3d` with zero origin.\n * @param lowHigh optional receiver for output\n * @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the end of the ray.\n */\n public override projectedParameterRange(ray: Vector3d | Ray3d, lowHigh?: Range1d): Range1d | undefined {\n return PlaneAltitudeRangeContext.findExtremeFractionsAlongDirection(this, ray, lowHigh);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TransitionSpiral3d.js","sourceRoot":"","sources":["../../../../src/curve/spiral/TransitionSpiral3d.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAO/F,6CAA0C;AAE1C,kDAA0D;AAC1D,0DAAuD;AACvD,0DAAuD;AACvD,sDAAmD;AACnD,mFAAgF;AAChF,6FAA0F;AAE1F,oDAAiD;AAyCjD;;;;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SAAS,CAAC,CAAC,CAAC;QAC7E,KAAK,GAAG,mBAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,4BAA4B,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;IACxF,CAAC;IACD;;;;;;;OAOG;IACa,uBAAuB,CAAC,GAAqB,EAAE,OAAiB;QAC9E,OAAO,qDAAyB,CAAC,kCAAkC,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1F,CAAC;CACF;AA5KD,gDA4KC","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\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { BSplineCurve3d } from \"../../bspline/BSplineCurve\";\nimport { Geometry } from \"../../Geometry\";\nimport { Matrix3d } from \"../../geometry3d/Matrix3d\";\nimport { Range1d, Range3d } from \"../../geometry3d/Range\";\nimport { Segment1d } from \"../../geometry3d/Segment1d\";\nimport { Transform } from \"../../geometry3d/Transform\";\nimport { CurvePrimitive } from \"../CurvePrimitive\";\nimport { CurveOffsetXYHandler } from \"../internalContexts/CurveOffsetXYHandler\";\nimport { PlaneAltitudeRangeContext } from \"../internalContexts/PlaneAltitudeRangeContext\";\nimport { LineString3d } from \"../LineString3d\";\nimport { OffsetOptions } from \"../OffsetOptions\";\nimport { TransitionConditionalProperties } from \"./TransitionConditionalProperties\";\n\nimport type { Vector3d } from \"../../geometry3d/Point3dVector3d\";\nimport type { Ray3d } from \"../../geometry3d/Ray3d\";\n\n/**\n * This is the set of valid type names for \"integrated\" spirals.\n * * Behavior is expressed by a `NormalizedTransition` snap function.\n * * The snap function varies smoothly from f(0) = 0 to f(1) = 1.\n * * The various snap functions are:\n * * clothoid: linear\n * * biquadratic: 2 quadratics pieced together, joining with 1st derivative continuity at f(0.5) = 0.5, with zero\n * slope f'(0) = 0 and f'(1) = 0\n * * bloss: A single cubic with zero slope at 0 and 1\n * * cosine: half of a cosine wave, centered around 0.5\n * * sine: full period of a sine wave added to the line f(u)=u\n * *\n * @public\n */\nexport type IntegratedSpiralTypeName = \"clothoid\" | \"bloss\" | \"biquadratic\" | \"cosine\" | \"sine\";\n\n/**\n * This is the set of valid type names for \"direct\" spirals.\n * \"Direct\" spirals can evaluate fractionToPoint by direct equations, i.e. not requiring the numeric integrations in\n * \"Integrated\" spiral types.\n * @public\n */\nexport type DirectSpiralTypeName =\n \"JapaneseCubic\" // 1 term from each of the X,Y clothoid series expansions: y = x^3 / (6RL)\n | \"Arema\" // 2 terms from each of the X,Y clothoid series expansions; identical to ChineseCubic\n | \"ChineseCubic\" // Identical to Arema\n | \"HalfCosine\" // high continuity cosine variation from quadratic\n | \"AustralianRailCorp\" // cubic with high accuracy distance series\n | \"WesternAustralian\" // simple cubic -- 2 terms of x series, 1 term of y series\n | \"Czech\" // simple cubic with two term distance approximation\n | \"MXCubicAlongArc\" // x obtained from fractional distance via 2-terms from series, y = x^3 / (6RL)\n | \"Polish\"\n | \"Italian\"\n ;\n\n/**\n * TransitionSpiral3d is a base class for multiple variants of spirals.\n * * The menagerie of spiral types have 2 broad categories:\n * * IntegratedSpiral3d -- a spiral whose direct function for curvature versus distance must be integrated to\n * determine x,y.\n * * The IntegratedSpiral3d types are enumerated in `IntegratedSpiralTypes`.\n * * DirectSpiral3d -- a spiral implemented with direct calculation of x,y from fractional position along the spiral.\n * * The direct spiral types are enumerated in the `DirectSpiralType`.\n * * The method set for CurvePrimitive support includes a `handleTransitionSpiral(g: TransitionSpiral3d)` which receives\n * all the spiral types.\n * * The spiral class may impose expectations that its inflection is at the origin, with tangent along the x axis.\n * * This is generally necessary for direct spirals.\n * * This is not necessary for integrated spirals.\n * @public\n */\nexport abstract class TransitionSpiral3d extends CurvePrimitive {\n /** String name of spiral type. */\n protected _spiralType: string;\n /** Original defining properties. */\n protected _designProperties: TransitionConditionalProperties | undefined;\n /** Placement transform. */\n protected _localToWorld: Transform;\n /**\n * Fractional interval for the \"active\" part of a containing spiral.\n * (the radius, angle, and length conditions define a complete spiral, and some portion of it is \"active\")\n */\n protected _activeFractionInterval: Segment1d;\n /** Return (reference to) the active portion of the reference spiral. */\n public get activeFractionInterval(): Segment1d {\n return this._activeFractionInterval;\n }\n /** Strokes in the active portion. */\n public abstract get activeStrokes(): LineString3d;\n /** (Reference to) placement transform. */\n public get localToWorld(): Transform {\n return this._localToWorld;\n }\n protected constructor(\n spiralType: string | undefined,\n localToWorld: Transform,\n activeFractionInterval: Segment1d | undefined,\n designProperties: TransitionConditionalProperties | undefined,\n ) {\n super();\n this._spiralType = spiralType ? spiralType : \"unknownSpiralType\";\n this._designProperties = designProperties;\n this._localToWorld = localToWorld;\n this._activeFractionInterval = activeFractionInterval ? activeFractionInterval : Segment1d.create(0, 1);\n }\n public get spiralType(): string {\n return this._spiralType;\n }\n /** Return 1/r with convention that exact zero input returns 0 (straight line, zero curvature, infinite radius). */\n public static radiusToCurvature(radius: number): number {\n return (radius === 0.0) ? 0.0 : 1.0 / radius;\n }\n /** Return 1/k with convention that near-zero input returns 0 (straight line, zero curvature, infinite radius). */\n public static curvatureToRadius(curvature: number): number {\n if (Math.abs(curvature) < Geometry.smallAngleRadians)\n return 0.0;\n return 1.0 / curvature;\n }\n /** Return a deep clone. */\n public abstract override clone(): TransitionSpiral3d;\n /** Recompute strokes. */\n public abstract refreshComputedProperties(): void;\n /** Return (if possible) a spiral which is a portion of this curve. */\n public override clonePartialCurve(fractionA: number, fractionB: number): TransitionSpiral3d {\n const spiralB = this.clone();\n const globalFractionA = this._activeFractionInterval.fractionToPoint(fractionA);\n const globalFractionB = this._activeFractionInterval.fractionToPoint(fractionB);\n spiralB._activeFractionInterval.set(globalFractionA, globalFractionB);\n spiralB.refreshComputedProperties();\n return spiralB;\n }\n /** Clone with a transform applied. */\n public override cloneTransformed(transform: Transform): TransitionSpiral3d {\n const result = this.clone();\n result.tryTransformInPlace(transform); // we're confident it will always work\n return result;\n }\n /** Return the average of the start and end curvatures. */\n public static averageCurvature(radiusLimits: Segment1d): number {\n return 0.5 * (TransitionSpiral3d.radiusToCurvature(radiusLimits.x0) + TransitionSpiral3d.radiusToCurvature(radiusLimits.x1));\n }\n /**\n * Given two radii (or zeros for 0 curvature) return the average curvature.\n * @param r0 start radius, or 0 for line.\n * @param r1 end radius, or 0 for line.\n */\n public static averageCurvatureR0R1(r0: number, r1: number): number {\n return 0.5 * (TransitionSpiral3d.radiusToCurvature(r0) + TransitionSpiral3d.radiusToCurvature(r1));\n }\n /**\n * Given two radii (or zeros for 0 curvature) return the curvature at the given fraction.\n * @param r0 start radius, or 0 for line.\n * @param fraction fractional position between the curvatures defined by r0 and r1.\n * @param r1 end radius, or 0 for line.\n */\n public static interpolateCurvatureR0R1(r0: number, fraction: number, r1: number): number {\n return Geometry.interpolate(TransitionSpiral3d.radiusToCurvature(r0), fraction, TransitionSpiral3d.radiusToCurvature(r1));\n }\n /** Return the arc length of a transition spiral with given sweep and radius pair. */\n public static radiusRadiusSweepRadiansToArcLength(radius0: number, radius1: number, sweepRadians: number): number {\n return Math.abs(sweepRadians / TransitionSpiral3d.averageCurvatureR0R1(radius0, radius1));\n }\n /** Return the turn angle for spiral of given length between two radii */\n public static radiusRadiusLengthToSweepRadians(radius0: number, radius1: number, arcLength: number): number {\n return TransitionSpiral3d.averageCurvatureR0R1(radius0, radius1) * arcLength;\n }\n /** Return the end radius for spiral of given start radius, length, and turn angle. */\n public static radius0LengthSweepRadiansToRadius1(radius0: number, arcLength: number, sweepRadians: number) {\n return TransitionSpiral3d.curvatureToRadius(\n (2.0 * sweepRadians / arcLength) - TransitionSpiral3d.radiusToCurvature(radius0),\n );\n }\n /** Return the start radius for spiral of given end radius, length, and turn angle. */\n public static radius1LengthSweepRadiansToRadius0(radius1: number, arcLength: number, sweepRadians: number) {\n return TransitionSpiral3d.curvatureToRadius(\n (2.0 * sweepRadians / arcLength) - TransitionSpiral3d.radiusToCurvature(radius1),\n );\n }\n /** Return the original defining properties (if any) saved by the constructor. */\n public get designProperties(): TransitionConditionalProperties | undefined {\n return this._designProperties;\n }\n /**\n * * If transformA is rigid with uniform scale, apply the rigid part of transformA to the localToWorld transform and\n * return the scale and rigid separation.\n * * If not rigid, do nothing and return undefined.\n * * Also apply the scale factor to the designProperties.\n * @param transformA\n */\n protected applyRigidPartOfTransform(transformA: Transform): { rigidAxes: Matrix3d, scale: number } | undefined {\n const rigidData = transformA.matrix.factorRigidWithSignedScale();\n if (rigidData !== undefined) {\n // [sQ a][R b] = [sQ*R sQb+a]\n // but we save it as [Q*R sQb+a] with spiral data scaled by s\n const transformC0 = transformA.multiplyTransformTransform(this.localToWorld);\n // but pull the scale part out of the matrix\n const matrixC = rigidData.rigidAxes.multiplyMatrixMatrix(this.localToWorld.matrix);\n this._localToWorld = Transform.createOriginAndMatrix(transformC0.origin, matrixC);\n if (this.designProperties)\n this.designProperties.applyScaleFactor(rigidData.scale);\n return rigidData;\n }\n return undefined;\n }\n /**\n * Construct an offset of the instance curve as viewed in the xy-plane (ignoring z).\n * * No attempt is made to join the offsets of smaller constituent primitives. To construct a fully joined offset for an\n * aggregate instance (e.g., LineString3d, CurveChainWithDistanceIndex), use RegionOps.constructCurveXYOffset() instead.\n * @param offsetDistanceOrOptions offset distance (positive to left of the instance curve), or options object.\n */\n public override constructOffsetXY(offsetDistanceOrOptions: number | OffsetOptions): BSplineCurve3d | undefined {\n const options = OffsetOptions.create(offsetDistanceOrOptions);\n const handler = new CurveOffsetXYHandler(this, options.leftOffsetDistance);\n this.emitStrokableParts(handler, options.strokeOptions);\n return handler.claimResult();\n }\n /** Extend the range by the strokes of the spiral. */\n public override extendRange(rangeToExtend: Range3d, transform?: Transform): void {\n rangeToExtend.extendRange(this.rangeBetweenFractions(0.0, 1.0, transform));\n }\n /**\n * Return the range of spiral between fractions of the activeStrokes.\n * * Use activeStrokes point count times interval factor for initial evaluation count, but do at least 5.\n */\n public override rangeBetweenFractions(fractionA: number, fractionB: number, transform?: Transform): Range3d {\n const strokes = this.activeStrokes;\n if (undefined === strokes)\n return Range3d.createNull();\n let count = Math.ceil(strokes.numPoints() * Math.abs(fractionB - fractionA));\n count = Geometry.clamp(5, count, 30);\n return this.rangeBetweenFractionsByCount(fractionA, fractionB, count, transform, 0.5);\n }\n /**\n * Project instance geometry (via dispatch) onto the given ray, and return the extreme fractional parameters of\n * projection.\n * @param ray ray onto which the instance is projected. A `Vector3d` is treated as a `Ray3d` with zero origin.\n * @param lowHigh optional receiver for output\n * @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the\n * end of the ray.\n */\n public override projectedParameterRange(ray: Vector3d | Ray3d, lowHigh?: Range1d): Range1d | undefined {\n return PlaneAltitudeRangeContext.findExtremeFractionsAlongDirection(this, ray, lowHigh);\n }\n}\n"]}
|
|
@@ -5,14 +5,14 @@ import { Ray3d } from "../../geometry3d/Ray3d";
|
|
|
5
5
|
* XYCurveEvaluator is an abstract with methods for evaluating X and Y parts of a curve parameterized by a fraction.
|
|
6
6
|
* * The required methods call for independent X and Y evaluation.
|
|
7
7
|
* * Base class methods package those (multiple) calls into point, ray, and plane structures.
|
|
8
|
-
* *
|
|
9
|
-
*
|
|
8
|
+
* * An implementation that has evaluation substantial cost that can be shared among x,y parts or between
|
|
9
|
+
* primary functions and derivatives might choose to implement the point and derivative methods directly.
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
12
|
export declare abstract class XYCurveEvaluator {
|
|
13
|
-
/**
|
|
13
|
+
/** Return a deep copy of the evaluator. */
|
|
14
14
|
abstract clone(): XYCurveEvaluator;
|
|
15
|
-
/**
|
|
15
|
+
/** Test for near identical evaluator. */
|
|
16
16
|
abstract isAlmostEqual(other: any): boolean;
|
|
17
17
|
/** Evaluate X at fractional position. */
|
|
18
18
|
abstract fractionToX(fraction: number): number;
|
|
@@ -26,16 +26,21 @@ export declare abstract class XYCurveEvaluator {
|
|
|
26
26
|
abstract fractionToDDX(fraction: number): number;
|
|
27
27
|
/** Evaluate second derivative of Y with respect to fraction at fractional position. */
|
|
28
28
|
abstract fractionToDDY(fraction: number): number;
|
|
29
|
-
/** Evaluate
|
|
30
|
-
/** Evaluate second derivative of X with respect to fraction at fractional position. */
|
|
29
|
+
/** Evaluate third derivative of X with respect to fraction at fractional position. */
|
|
31
30
|
abstract fractionToD3X(fraction: number): number;
|
|
32
|
-
/** Evaluate
|
|
31
|
+
/** Evaluate third derivative of Y with respect to fraction at fractional position. */
|
|
33
32
|
abstract fractionToD3Y(fraction: number): number;
|
|
34
33
|
/** Evaluate both X and Y at fractional coordinate, return bundled as a point. */
|
|
35
34
|
fractionToPoint(fraction: number, result?: Point3d): Point3d;
|
|
36
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Evaluate both X and Y and their first derivatives at fractional coordinate, return bundled as origin and
|
|
37
|
+
* (non-unit) direction vector.
|
|
38
|
+
*/
|
|
37
39
|
fractionToPointAndDerivative(fraction: number, result?: Ray3d): Ray3d;
|
|
38
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Evaluate both X and Y and their second derivatives at fractional coordinate, return bundled as origin and
|
|
42
|
+
* (non-unit) vectorU an vectorV.
|
|
43
|
+
*/
|
|
39
44
|
fractionToPointAnd2Derivatives(fraction: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors;
|
|
40
45
|
/**
|
|
41
46
|
* Return the magnitude of the tangent vector at fraction.
|
|
@@ -44,34 +49,35 @@ export declare abstract class XYCurveEvaluator {
|
|
|
44
49
|
fractionToTangentMagnitude(fraction: number): number;
|
|
45
50
|
/** Invert the fractionToX function for given X. */
|
|
46
51
|
abstract xToFraction(x: number): number | undefined;
|
|
47
|
-
/** Initialize class level work arrays for 5 point Gaussian Quadrature. */
|
|
48
52
|
protected static _gaussX: Float64Array;
|
|
49
53
|
protected static _gaussWeight: Float64Array;
|
|
50
54
|
protected static _gaussMapper: (xA: number, xB: number, arrayX: Float64Array, arrayW: Float64Array) => number;
|
|
55
|
+
/**
|
|
56
|
+
* Initialize class level work arrays for 5 point Gaussian quadrature.
|
|
57
|
+
* * These static variables are reused on calls to [[integrateDistanceBetweenFractions]].
|
|
58
|
+
*/
|
|
51
59
|
static initWorkSpace(): void;
|
|
52
60
|
/**
|
|
53
61
|
* Integrate between nominal fractions with default gauss rule.
|
|
54
62
|
* * The caller is expected to choose nearby fractions so that the single gauss interval accuracy is good.
|
|
55
|
-
* @param fraction0
|
|
56
|
-
* @param fraction1
|
|
57
63
|
*/
|
|
58
64
|
integrateDistanceBetweenFractions(fraction0: number, fraction1: number): number;
|
|
59
65
|
/**
|
|
60
|
-
* Inverse integrated distance
|
|
61
|
-
* @param fraction0 start of fraction interval
|
|
62
|
-
* @param fraction1 end of fraction interval
|
|
63
|
-
* @param distance0 distance at start
|
|
64
|
-
* @param distance1 distance at end
|
|
66
|
+
* Inverse integrated distance.
|
|
67
|
+
* @param fraction0 start of fraction interval.
|
|
68
|
+
* @param fraction1 end of fraction interval.
|
|
69
|
+
* @param distance0 distance at start.
|
|
70
|
+
* @param distance1 distance at end.
|
|
65
71
|
* @param targetDistance intermediate distance.
|
|
66
72
|
*/
|
|
67
73
|
inverseDistanceFraction(fraction0: number, fraction1: number, distance0: number, distance1: number, targetDistance: number): number | undefined;
|
|
68
74
|
/**
|
|
69
|
-
*
|
|
75
|
+
* Get the point and its derivatives at a given fraction.
|
|
70
76
|
* @param fraction fractional position along x axis
|
|
71
77
|
* @param xy xy coordinates of point on the curve
|
|
72
|
-
* @param d1xy
|
|
73
|
-
* @param d2xy
|
|
74
|
-
* @param d3xy
|
|
78
|
+
* @param d1xy first derivative vector
|
|
79
|
+
* @param d2xy second derivative vector
|
|
80
|
+
* @param d3xy third derivative vector
|
|
75
81
|
*/
|
|
76
82
|
fractionToPointAnd3Derivatives(fraction: number, xy: Point3d, d1xy?: Vector3d, d2xy?: Vector3d, d3xy?: Vector3d): void;
|
|
77
83
|
/** Apply a uniform scale around the origin. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XYCurveEvaluator.d.ts","sourceRoot":"","sources":["../../../../src/curve/spiral/XYCurveEvaluator.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"XYCurveEvaluator.d.ts","sourceRoot":"","sources":["../../../../src/curve/spiral/XYCurveEvaluator.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAI/C;;;;;;;GAOG;AACH,8BAAsB,gBAAgB;IACpC,2CAA2C;aAC3B,KAAK,IAAI,gBAAgB;IACzC,yCAAyC;aACzB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO;IAClD,yCAAyC;aACzB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IACrD,yCAAyC;aACzB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IACrD,gFAAgF;aAChE,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IACtD,gFAAgF;aAChE,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IACtD,uFAAuF;aACvE,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IACvD,uFAAuF;aACvE,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IACvD,sFAAsF;aACtE,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IACvD,sF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,QAAQ,GAC/E,IAAI;IASP,+CAA+C;aAC/B,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CACxD"}
|
|
@@ -18,8 +18,8 @@ const Newton_1 = require("../../numerics/Newton");
|
|
|
18
18
|
* XYCurveEvaluator is an abstract with methods for evaluating X and Y parts of a curve parameterized by a fraction.
|
|
19
19
|
* * The required methods call for independent X and Y evaluation.
|
|
20
20
|
* * Base class methods package those (multiple) calls into point, ray, and plane structures.
|
|
21
|
-
* *
|
|
22
|
-
*
|
|
21
|
+
* * An implementation that has evaluation substantial cost that can be shared among x,y parts or between
|
|
22
|
+
* primary functions and derivatives might choose to implement the point and derivative methods directly.
|
|
23
23
|
* @internal
|
|
24
24
|
*/
|
|
25
25
|
class XYCurveEvaluator {
|
|
@@ -27,11 +27,17 @@ class XYCurveEvaluator {
|
|
|
27
27
|
fractionToPoint(fraction, result) {
|
|
28
28
|
return Point3dVector3d_1.Point3d.create(this.fractionToX(fraction), this.fractionToY(fraction), 0.0, result);
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Evaluate both X and Y and their first derivatives at fractional coordinate, return bundled as origin and
|
|
32
|
+
* (non-unit) direction vector.
|
|
33
|
+
*/
|
|
31
34
|
fractionToPointAndDerivative(fraction, result) {
|
|
32
35
|
return Ray3d_1.Ray3d.createXYZUVW(this.fractionToX(fraction), this.fractionToY(fraction), 0.0, this.fractionToDX(fraction), this.fractionToDY(fraction), 0, result);
|
|
33
36
|
}
|
|
34
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Evaluate both X and Y and their second derivatives at fractional coordinate, return bundled as origin and
|
|
39
|
+
* (non-unit) vectorU an vectorV.
|
|
40
|
+
*/
|
|
35
41
|
fractionToPointAnd2Derivatives(fraction, result) {
|
|
36
42
|
return Plane3dByOriginAndVectors_1.Plane3dByOriginAndVectors.createOriginAndVectorsXYZ(this.fractionToX(fraction), this.fractionToY(fraction), 0.0, this.fractionToDX(fraction), this.fractionToDY(fraction), 0, this.fractionToDDX(fraction), this.fractionToDDY(fraction), 0, result);
|
|
37
43
|
}
|
|
@@ -44,12 +50,13 @@ class XYCurveEvaluator {
|
|
|
44
50
|
const v = this.fractionToDY(fraction);
|
|
45
51
|
return Geometry_1.Geometry.hypotenuseXY(u, v);
|
|
46
52
|
}
|
|
47
|
-
/** Initialize class level work arrays for 5 point Gaussian Quadrature. */
|
|
48
|
-
// Class resources for integration . . .
|
|
49
|
-
// These static variables are reused on calls to integrateFromStartFraction
|
|
50
53
|
static _gaussX;
|
|
51
54
|
static _gaussWeight;
|
|
52
55
|
static _gaussMapper;
|
|
56
|
+
/**
|
|
57
|
+
* Initialize class level work arrays for 5 point Gaussian quadrature.
|
|
58
|
+
* * These static variables are reused on calls to [[integrateDistanceBetweenFractions]].
|
|
59
|
+
*/
|
|
53
60
|
static initWorkSpace() {
|
|
54
61
|
XYCurveEvaluator._gaussX = new Float64Array(5);
|
|
55
62
|
XYCurveEvaluator._gaussWeight = new Float64Array(5);
|
|
@@ -58,8 +65,6 @@ class XYCurveEvaluator {
|
|
|
58
65
|
/**
|
|
59
66
|
* Integrate between nominal fractions with default gauss rule.
|
|
60
67
|
* * The caller is expected to choose nearby fractions so that the single gauss interval accuracy is good.
|
|
61
|
-
* @param fraction0
|
|
62
|
-
* @param fraction1
|
|
63
68
|
*/
|
|
64
69
|
integrateDistanceBetweenFractions(fraction0, fraction1) {
|
|
65
70
|
const gaussX = XYCurveEvaluator._gaussX;
|
|
@@ -72,11 +77,11 @@ class XYCurveEvaluator {
|
|
|
72
77
|
return sum;
|
|
73
78
|
}
|
|
74
79
|
/**
|
|
75
|
-
* Inverse integrated distance
|
|
76
|
-
* @param fraction0 start of fraction interval
|
|
77
|
-
* @param fraction1 end of fraction interval
|
|
78
|
-
* @param distance0 distance at start
|
|
79
|
-
* @param distance1 distance at end
|
|
80
|
+
* Inverse integrated distance.
|
|
81
|
+
* @param fraction0 start of fraction interval.
|
|
82
|
+
* @param fraction1 end of fraction interval.
|
|
83
|
+
* @param distance0 distance at start.
|
|
84
|
+
* @param distance1 distance at end.
|
|
80
85
|
* @param targetDistance intermediate distance.
|
|
81
86
|
*/
|
|
82
87
|
inverseDistanceFraction(fraction0, fraction1, distance0, distance1, targetDistance) {
|
|
@@ -90,12 +95,12 @@ class XYCurveEvaluator {
|
|
|
90
95
|
return undefined;
|
|
91
96
|
}
|
|
92
97
|
/**
|
|
93
|
-
*
|
|
98
|
+
* Get the point and its derivatives at a given fraction.
|
|
94
99
|
* @param fraction fractional position along x axis
|
|
95
100
|
* @param xy xy coordinates of point on the curve
|
|
96
|
-
* @param d1xy
|
|
97
|
-
* @param d2xy
|
|
98
|
-
* @param d3xy
|
|
101
|
+
* @param d1xy first derivative vector
|
|
102
|
+
* @param d2xy second derivative vector
|
|
103
|
+
* @param d3xy third derivative vector
|
|
99
104
|
*/
|
|
100
105
|
fractionToPointAnd3Derivatives(fraction, xy, d1xy, d2xy, d3xy) {
|
|
101
106
|
xy.set(this.fractionToX(fraction), this.fractionToY(fraction), 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XYCurveEvaluator.js","sourceRoot":"","sources":["../../../../src/curve/spiral/XYCurveEvaluator.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,6CAA0C;AAC1C,0FAAuF;AACvF,sEAAqE;AACrE,kDAA+C;AAC/C,0DAAuD;AACvD,kDAAqD;AACrD;;;;;;;GAOG;AACH,MAAsB,gBAAgB;IAsBpC,iFAAiF;IAC1E,eAAe,CAAC,QAAgB,EAAE,MAAgB;QACvD,OAAO,yBAAO,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAC7F,CAAC;IACD,4IAA4I;IACrI,4BAA4B,CAAC,QAAgB,EAAE,MAAc;QAClE,OAAO,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B,EAAE,EAAE,CAAC,IAAI,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;;OAOG;IACI,8BAA8B,CAAC,QAAgB,EAAE,EAAW,EAAE,IAAe,EAAE,IAAe,EAAE,IAAe;QACpH,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QAClE,IAAI,IAAI;YACN,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QACxE,IAAI,IAAI;YACN,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1E,IAAI,IAAI;YACN,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5E,CAAC;CAGF;AAxHD,4CAwHC;AACD,sDAAsD;AACtD,gBAAgB,CAAC,aAAa,EAAE,CAAC","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\n/** @packageDocumentation\n * @module Curve\n */\nimport { Geometry } from \"../../Geometry\";\nimport { Plane3dByOriginAndVectors } from \"../../geometry3d/Plane3dByOriginAndVectors\";\nimport { Point3d, Vector3d } from \"../../geometry3d/Point3dVector3d\";\nimport { Ray3d } from \"../../geometry3d/Ray3d\";\nimport { Quadrature } from \"../../numerics/Quadrature\";\nimport { SimpleNewton } from \"../../numerics/Newton\";\n/**\n * XYCurveEvaluator is an abstract with methods for evaluating X and Y parts of a curve parameterized by a fraction.\n * * The required methods call for independent X and Y evaluation.\n * * Base class methods package those (multiple) calls into point, ray, and plane structures.\n * * A implementation that has evaluation substantial cost that can be shared among x,y parts or between\n * primary functions and derivatives might choose to implement the point and derivative methods directly.\n * @internal\n */\nexport abstract class XYCurveEvaluator {\n /** return a deep copy of the evaluator */\n public abstract clone(): XYCurveEvaluator;\n /** test for near identical evaluator */\n public abstract isAlmostEqual(other: any): boolean;\n /** Evaluate X at fractional position. */\n public abstract fractionToX(fraction: number): number;\n /** Evaluate Y at fractional position. */\n public abstract fractionToY(fraction: number): number;\n /** Evaluate derivative of X with respect to fraction at fractional position. */\n public abstract fractionToDX(fraction: number): number;\n /** Evaluate derivative of Y with respect to fraction at fractional position. */\n public abstract fractionToDY(fraction: number): number;\n /** Evaluate second derivative of X with respect to fraction at fractional position. */\n public abstract fractionToDDX(fraction: number): number;\n /** Evaluate second derivative of Y with respect to fraction at fractional position. */\n public abstract fractionToDDY(fraction: number): number;\n /** Evaluate both X and Y at fractional coordinate, return bundled as a point. */\n /** Evaluate second derivative of X with respect to fraction at fractional position. */\n public abstract fractionToD3X(fraction: number): number;\n /** Evaluate second derivative of Y with respect to fraction at fractional position. */\n public abstract fractionToD3Y(fraction: number): number;\n /** Evaluate both X and Y at fractional coordinate, return bundled as a point. */\n public fractionToPoint(fraction: number, result?: Point3d): Point3d {\n return Point3d.create(this.fractionToX(fraction), this.fractionToY(fraction), 0.0, result);\n }\n /** Evaluate both X and Y and their first derivatives at fractional coordinate, return bundled as origin and (non-unit) direction vector. */\n public fractionToPointAndDerivative(fraction: number, result?: Ray3d): Ray3d {\n return Ray3d.createXYZUVW(this.fractionToX(fraction), this.fractionToY(fraction), 0.0,\n this.fractionToDX(fraction), this.fractionToDY(fraction), 0,\n result);\n }\n /** Evaluate both X and Y and their second derivatives at fractional coordinate, return bundled as origin and (non-unit) vectorU an vectorV. */\n public fractionToPointAnd2Derivatives(fraction: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors {\n return Plane3dByOriginAndVectors.createOriginAndVectorsXYZ(\n this.fractionToX(fraction), this.fractionToY(fraction), 0.0,\n this.fractionToDX(fraction), this.fractionToDY(fraction), 0,\n this.fractionToDDX(fraction), this.fractionToDDY(fraction), 0,\n result);\n }\n /**\n * Return the magnitude of the tangent vector at fraction.\n * @param fraction fractional position along the curve\n */\n public fractionToTangentMagnitude(fraction: number): number {\n const u = this.fractionToDX(fraction);\n const v = this.fractionToDY(fraction);\n return Geometry.hypotenuseXY(u, v);\n }\n\n /** Invert the fractionToX function for given X. */\n\n public abstract xToFraction(x: number): number | undefined;\n /** Initialize class level work arrays for 5 point Gaussian Quadrature. */\n // Class resources for integration . . .\n // These static variables are reused on calls to integrateFromStartFraction\n protected static _gaussX: Float64Array;\n protected static _gaussWeight: Float64Array;\n protected static _gaussMapper: (xA: number, xB: number, arrayX: Float64Array, arrayW: Float64Array) => number;\n public static initWorkSpace() {\n XYCurveEvaluator._gaussX = new Float64Array(5);\n XYCurveEvaluator._gaussWeight = new Float64Array(5);\n XYCurveEvaluator._gaussMapper = (xA, xB, xMapped, wMapped) => Quadrature.setupGauss5(xA, xB, xMapped, wMapped);\n }\n /**\n * Integrate between nominal fractions with default gauss rule.\n * * The caller is expected to choose nearby fractions so that the single gauss interval accuracy is good.\n * @param fraction0\n * @param fraction1\n */\n public integrateDistanceBetweenFractions(fraction0: number, fraction1: number): number {\n const gaussX = XYCurveEvaluator._gaussX;\n const gaussWeight = XYCurveEvaluator._gaussWeight;\n const numEval = XYCurveEvaluator._gaussMapper(fraction0, fraction1, gaussX, gaussWeight);\n let sum = 0;\n for (let k = 0; k < numEval; k++) {\n sum += gaussWeight[k] * this.fractionToTangentMagnitude(gaussX[k]);\n }\n return sum;\n }\n /**\n * Inverse integrated distance\n * @param fraction0 start of fraction interval\n * @param fraction1 end of fraction interval\n * @param distance0 distance at start\n * @param distance1 distance at end\n * @param targetDistance intermediate distance.\n */\n public inverseDistanceFraction(fraction0: number, fraction1: number, distance0: number, distance1: number, targetDistance: number): number | undefined {\n const startFraction = Geometry.inverseInterpolate(fraction0, distance0, fraction1, distance1, targetDistance);\n if (startFraction !== undefined) {\n return SimpleNewton.runNewton1D(startFraction,\n (fraction: number) => {\n const d = this.integrateDistanceBetweenFractions(fraction0, fraction);\n return distance0 + d - targetDistance;\n },\n (fraction: number) => this.fractionToTangentMagnitude(fraction));\n }\n return undefined;\n }\n\n /**\n *\n * @param fraction fractional position along x axis\n * @param xy xy coordinates of point on the curve\n * @param d1xy\n * @param d2xy\n * @param d3xy\n */\n public fractionToPointAnd3Derivatives(fraction: number, xy: Point3d, d1xy?: Vector3d, d2xy?: Vector3d, d3xy?: Vector3d) {\n xy.set(this.fractionToX(fraction), this.fractionToY(fraction), 0);\n if (d1xy)\n d1xy.set(this.fractionToDX(fraction), this.fractionToDY(fraction), 0);\n if (d2xy)\n d2xy.set(this.fractionToDDX(fraction), this.fractionToDDY(fraction), 0);\n if (d3xy)\n d3xy.set(this.fractionToD3X(fraction), this.fractionToD3Y(fraction), 0);\n }\n /** Apply a uniform scale around the origin. */\n public abstract scaleInPlace(scaleFactor: number): void;\n}\n// at load time, initialize gauss quadrature workspace\nXYCurveEvaluator.initWorkSpace();\n"]}
|
|
1
|
+
{"version":3,"file":"XYCurveEvaluator.js","sourceRoot":"","sources":["../../../../src/curve/spiral/XYCurveEvaluator.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,6CAA0C;AAC1C,0FAAuF;AACvF,sEAAqE;AACrE,kDAA+C;AAC/C,0DAAuD;AACvD,kDAAqD;AAErD;;;;;;;GAOG;AACH,MAAsB,gBAAgB;IAqBpC,iFAAiF;IAC1E,eAAe,CAAC,QAAgB,EAAE,MAAgB;QACvD,OAAO,yBAAO,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,Q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AAI,CAAC,iCAAiC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;gBACtE,OAAO,SAAS,GAAG,CAAC,GAAG,cAAc,CAAC;YACxC,CAAC,EACD,CAAC,QAAgB,EAAE,EAAE,CAAC,IAAI,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD;;;;;;;OAOG;IACI,8BAA8B,CACnC,QAAgB,EAAE,EAAW,EAAE,IAAe,EAAE,IAAe,EAAE,IAAe;QAEhF,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QAClE,IAAI,IAAI;YACN,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QACxE,IAAI,IAAI;YACN,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1E,IAAI,IAAI;YACN,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5E,CAAC;CAGF;AA9HD,4CA8HC;AACD,sDAAsD;AACtD,gBAAgB,CAAC,aAAa,EAAE,CAAC","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\n/** @packageDocumentation\n * @module Curve\n */\nimport { Geometry } from \"../../Geometry\";\nimport { Plane3dByOriginAndVectors } from \"../../geometry3d/Plane3dByOriginAndVectors\";\nimport { Point3d, Vector3d } from \"../../geometry3d/Point3dVector3d\";\nimport { Ray3d } from \"../../geometry3d/Ray3d\";\nimport { Quadrature } from \"../../numerics/Quadrature\";\nimport { SimpleNewton } from \"../../numerics/Newton\";\n\n/**\n * XYCurveEvaluator is an abstract with methods for evaluating X and Y parts of a curve parameterized by a fraction.\n * * The required methods call for independent X and Y evaluation.\n * * Base class methods package those (multiple) calls into point, ray, and plane structures.\n * * An implementation that has evaluation substantial cost that can be shared among x,y parts or between\n * primary functions and derivatives might choose to implement the point and derivative methods directly.\n * @internal\n */\nexport abstract class XYCurveEvaluator {\n /** Return a deep copy of the evaluator. */\n public abstract clone(): XYCurveEvaluator;\n /** Test for near identical evaluator. */\n public abstract isAlmostEqual(other: any): boolean;\n /** Evaluate X at fractional position. */\n public abstract fractionToX(fraction: number): number;\n /** Evaluate Y at fractional position. */\n public abstract fractionToY(fraction: number): number;\n /** Evaluate derivative of X with respect to fraction at fractional position. */\n public abstract fractionToDX(fraction: number): number;\n /** Evaluate derivative of Y with respect to fraction at fractional position. */\n public abstract fractionToDY(fraction: number): number;\n /** Evaluate second derivative of X with respect to fraction at fractional position. */\n public abstract fractionToDDX(fraction: number): number;\n /** Evaluate second derivative of Y with respect to fraction at fractional position. */\n public abstract fractionToDDY(fraction: number): number;\n /** Evaluate third derivative of X with respect to fraction at fractional position. */\n public abstract fractionToD3X(fraction: number): number;\n /** Evaluate third derivative of Y with respect to fraction at fractional position. */\n public abstract fractionToD3Y(fraction: number): number;\n /** Evaluate both X and Y at fractional coordinate, return bundled as a point. */\n public fractionToPoint(fraction: number, result?: Point3d): Point3d {\n return Point3d.create(this.fractionToX(fraction), this.fractionToY(fraction), 0.0, result);\n }\n /**\n * Evaluate both X and Y and their first derivatives at fractional coordinate, return bundled as origin and\n * (non-unit) direction vector.\n */\n public fractionToPointAndDerivative(fraction: number, result?: Ray3d): Ray3d {\n return Ray3d.createXYZUVW(this.fractionToX(fraction), this.fractionToY(fraction), 0.0,\n this.fractionToDX(fraction), this.fractionToDY(fraction), 0,\n result);\n }\n /**\n * Evaluate both X and Y and their second derivatives at fractional coordinate, return bundled as origin and\n * (non-unit) vectorU an vectorV.\n */\n public fractionToPointAnd2Derivatives(fraction: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors {\n return Plane3dByOriginAndVectors.createOriginAndVectorsXYZ(\n this.fractionToX(fraction), this.fractionToY(fraction), 0.0,\n this.fractionToDX(fraction), this.fractionToDY(fraction), 0,\n this.fractionToDDX(fraction), this.fractionToDDY(fraction), 0,\n result,\n );\n }\n /**\n * Return the magnitude of the tangent vector at fraction.\n * @param fraction fractional position along the curve\n */\n public fractionToTangentMagnitude(fraction: number): number {\n const u = this.fractionToDX(fraction);\n const v = this.fractionToDY(fraction);\n return Geometry.hypotenuseXY(u, v);\n }\n /** Invert the fractionToX function for given X. */\n public abstract xToFraction(x: number): number | undefined;\n protected static _gaussX: Float64Array;\n protected static _gaussWeight: Float64Array;\n protected static _gaussMapper: (xA: number, xB: number, arrayX: Float64Array, arrayW: Float64Array) => number;\n /**\n * Initialize class level work arrays for 5 point Gaussian quadrature.\n * * These static variables are reused on calls to [[integrateDistanceBetweenFractions]].\n */\n public static initWorkSpace(): void {\n XYCurveEvaluator._gaussX = new Float64Array(5);\n XYCurveEvaluator._gaussWeight = new Float64Array(5);\n XYCurveEvaluator._gaussMapper = (xA, xB, xMapped, wMapped) => Quadrature.setupGauss5(xA, xB, xMapped, wMapped);\n }\n /**\n * Integrate between nominal fractions with default gauss rule.\n * * The caller is expected to choose nearby fractions so that the single gauss interval accuracy is good.\n */\n public integrateDistanceBetweenFractions(fraction0: number, fraction1: number): number {\n const gaussX = XYCurveEvaluator._gaussX;\n const gaussWeight = XYCurveEvaluator._gaussWeight;\n const numEval = XYCurveEvaluator._gaussMapper(fraction0, fraction1, gaussX, gaussWeight);\n let sum = 0;\n for (let k = 0; k < numEval; k++) {\n sum += gaussWeight[k] * this.fractionToTangentMagnitude(gaussX[k]);\n }\n return sum;\n }\n /**\n * Inverse integrated distance.\n * @param fraction0 start of fraction interval.\n * @param fraction1 end of fraction interval.\n * @param distance0 distance at start.\n * @param distance1 distance at end.\n * @param targetDistance intermediate distance.\n */\n public inverseDistanceFraction(\n fraction0: number, fraction1: number, distance0: number, distance1: number, targetDistance: number,\n ): number | undefined {\n const startFraction = Geometry.inverseInterpolate(fraction0, distance0, fraction1, distance1, targetDistance);\n if (startFraction !== undefined) {\n return SimpleNewton.runNewton1D(startFraction,\n (fraction: number) => {\n const d = this.integrateDistanceBetweenFractions(fraction0, fraction);\n return distance0 + d - targetDistance;\n },\n (fraction: number) => this.fractionToTangentMagnitude(fraction));\n }\n return undefined;\n }\n /**\n * Get the point and its derivatives at a given fraction.\n * @param fraction fractional position along x axis\n * @param xy xy coordinates of point on the curve\n * @param d1xy first derivative vector\n * @param d2xy second derivative vector\n * @param d3xy third derivative vector\n */\n public fractionToPointAnd3Derivatives(\n fraction: number, xy: Point3d, d1xy?: Vector3d, d2xy?: Vector3d, d3xy?: Vector3d,\n ): void {\n xy.set(this.fractionToX(fraction), this.fractionToY(fraction), 0);\n if (d1xy)\n d1xy.set(this.fractionToDX(fraction), this.fractionToDY(fraction), 0);\n if (d2xy)\n d2xy.set(this.fractionToDDX(fraction), this.fractionToDDY(fraction), 0);\n if (d3xy)\n d3xy.set(this.fractionToD3X(fraction), this.fractionToD3Y(fraction), 0);\n }\n /** Apply a uniform scale around the origin. */\n public abstract scaleInPlace(scaleFactor: number): void;\n}\n// at load time, initialize gauss quadrature workspace\nXYCurveEvaluator.initWorkSpace();\n"]}
|