@itwin/core-geometry 5.3.0-dev.9 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -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
|
@@ -26,9 +26,15 @@ class AustralianRailCorpXYEvaluator extends CubicEvaluator_1.CubicEvaluator {
|
|
|
26
26
|
this._nominalLength1 = nominalLength1;
|
|
27
27
|
this._nominalRadius1 = nominalRadius1;
|
|
28
28
|
}
|
|
29
|
-
get nominalLength1() {
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
get nominalLength1() {
|
|
30
|
+
return this._nominalLength1;
|
|
31
|
+
}
|
|
32
|
+
get nominalRadius1() {
|
|
33
|
+
return this._nominalRadius1;
|
|
34
|
+
}
|
|
35
|
+
clone() {
|
|
36
|
+
return new AustralianRailCorpXYEvaluator(this._nominalLength1, this._nominalRadius1, this._axisLength, this._cubicM);
|
|
37
|
+
}
|
|
32
38
|
static create(nominalLength1, nominalRadius1) {
|
|
33
39
|
const axisLength = AustralianRailCorpXYEvaluator.radiusAndNominalLengthToAxisLength(nominalRadius1, nominalLength1);
|
|
34
40
|
const phi = this.radiusAndAxisLengthToPhi(nominalRadius1, axisLength);
|
|
@@ -36,11 +42,7 @@ class AustralianRailCorpXYEvaluator extends CubicEvaluator_1.CubicEvaluator {
|
|
|
36
42
|
const cubicM = Math.tan(phi) / (3.0 * xc2);
|
|
37
43
|
return new AustralianRailCorpXYEvaluator(nominalLength1, nominalRadius1, axisLength, cubicM);
|
|
38
44
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Compute the phi constant for AustralianRail spiral with given end radius and length along axis.
|
|
41
|
-
* @param nominalRadius1
|
|
42
|
-
* @param axisLength
|
|
43
|
-
*/
|
|
45
|
+
/** Compute the phi constant for AustralianRail spiral with given end radius and length along axis. */
|
|
44
46
|
static radiusAndAxisLengthToPhi(nominalRadius1, axisLength) {
|
|
45
47
|
const xc = axisLength;
|
|
46
48
|
const expr1 = (2. / Math.sqrt(3.));
|
|
@@ -53,26 +55,23 @@ class AustralianRailCorpXYEvaluator extends CubicEvaluator_1.CubicEvaluator {
|
|
|
53
55
|
return Math.asin(expr1 * Math.cos(Math.acos(expr2) / 3. + expr3));
|
|
54
56
|
}
|
|
55
57
|
scaleInPlace(scaleFactor) {
|
|
56
|
-
// apply the scale factor to all contents
|
|
57
|
-
// all distances scale directly . . .
|
|
58
|
+
// apply the scale factor to all contents; all distances scale directly
|
|
58
59
|
this._nominalLength1 *= scaleFactor;
|
|
59
60
|
this._nominalRadius1 *= scaleFactor;
|
|
60
61
|
super.scaleInPlace(scaleFactor);
|
|
61
62
|
}
|
|
62
|
-
/** Compute length along axis for AustralianRail spiral nominal radius and length.
|
|
63
|
-
*
|
|
64
|
-
*/
|
|
63
|
+
/** Compute length along axis for AustralianRail spiral nominal radius and length. */
|
|
65
64
|
static radiusAndNominalLengthToAxisLength(nominalRadius1, nominalLength1, tolerance = 1.0e-5, requiredConvergenceCount = 2) {
|
|
66
65
|
const R = nominalRadius1;
|
|
67
66
|
let idx = 0;
|
|
68
67
|
let m, phi, xc2;
|
|
69
68
|
let xc = .7 * nominalLength1;
|
|
70
69
|
let convergenceCount = 0;
|
|
71
|
-
// remark: This converges quickly
|
|
70
|
+
// remark: This converges quickly
|
|
72
71
|
// for L=100, R=400
|
|
73
72
|
// ** full precision at 7th iteration.
|
|
74
73
|
// ** classic tolerance 1.0e-5 (7 digits from L) with requiredConvergenceCount = 1 gives 11 digits after 3 iterations
|
|
75
|
-
// ** each iteration adds about 2 digits.
|
|
74
|
+
// ** each iteration adds about 2 digits. This is quite good for a successive replacement without derivative
|
|
76
75
|
// ** Unanswerable question: If this is only done once and reused over all evaluations, do you want:
|
|
77
76
|
// * run the 7 iterations to get full precision
|
|
78
77
|
// * stop with the classic tolerance to get compatibility?
|
|
@@ -81,8 +80,7 @@ class AustralianRailCorpXYEvaluator extends CubicEvaluator_1.CubicEvaluator {
|
|
|
81
80
|
xc2 = xc * xc;
|
|
82
81
|
m = Math.tan(phi) / (3.0 * xc2);
|
|
83
82
|
const m2x4 = m * m * xc2 * xc2;
|
|
84
|
-
const correction = xc * m2x4 * ((9. / 10) + m2x4 * (-(9. / 8.) + m2x4 * (+(729. / 208.) + m2x4 *
|
|
85
|
-
-(32805. / 2176.))));
|
|
83
|
+
const correction = xc * m2x4 * ((9. / 10) + m2x4 * (-(9. / 8.) + m2x4 * (+(729. / 208.) + m2x4 * -(32805. / 2176.))));
|
|
86
84
|
const correctedLength = xc + correction;
|
|
87
85
|
xc = (nominalLength1 / correctedLength) * xc;
|
|
88
86
|
if (Math.abs(nominalLength1 - correctedLength) < tolerance) {
|
|
@@ -107,12 +105,15 @@ class AustralianRailCorpXYEvaluator extends CubicEvaluator_1.CubicEvaluator {
|
|
|
107
105
|
}
|
|
108
106
|
/**
|
|
109
107
|
* Return a (quite good approximation) of fraction along x axis for given distance along spiral.
|
|
110
|
-
* * The AustralianRailSpiral has a supporting power series to approximately map distance along the spiral to
|
|
111
|
-
*
|
|
108
|
+
* * The AustralianRailSpiral has a supporting power series to approximately map distance along the spiral to
|
|
109
|
+
* an x coordinate.
|
|
110
|
+
* * The `xToFraction(x)` method quickly (with a single divide) converts this x to fraction used for
|
|
111
|
+
* this.fractionToX (fraction), this.fractionToY(fraction) etc to get coordinates and derivatives.
|
|
112
112
|
* * The x-to-distance relation is not as precise as the CurvePrimitive method moveSignedDistanceFromFraction.
|
|
113
|
-
* * It is supported here for users interested in replicating the AustralianRail distance mapping rather than the
|
|
114
|
-
*
|
|
115
|
-
*
|
|
113
|
+
* * It is supported here for users interested in replicating the AustralianRail distance mapping rather than the
|
|
114
|
+
* more accurate CurvePrimitive measurements.
|
|
115
|
+
* * Round tripping distance through (a) distanceAlongSpiralToAustralianApproximateX, (b) xToFraction, and
|
|
116
|
+
* (c) curveLengthBetweenFractions has 10 digit accuracy for L/R = 4, 12 digit accuracy for L/R = 10.
|
|
116
117
|
* @param s distance along the axis.
|
|
117
118
|
*/
|
|
118
119
|
distanceAlongSpiralToAustralianApproximateX(s) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AustralianRailCorpXYEvaluator.js","sourceRoot":"","sources":["../../../../src/curve/spiral/AustralianRailCorpXYEvaluator.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,6CAA0C;AAC1C,kDAA+C;AAC/C,qDAAkD;AAClD;;;;;;GAMG;AACH,MAAa,6BAA8B,SAAQ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AAC,eAAe,CAAC;mBACzE,mBAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,eAAe,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;QACjF,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD;;;;;;;;;OASG;IACI,2CAA2C,CAAC,CAAS;QAC1D,MAAM,EAAE,GAAG,MAAM,CAAC;QAClB,MAAM,EAAE,GAAG,MAAM,CAAC;QAClB,MAAM,EAAE,GAAG,OAAO,CAAC;QACnB,MAAM,EAAE,GAAG,QAAQ,CAAC;QACpB,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;QACvB,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,GAAG,CAAC,EAAE,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1E,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AAjHD,sEAiHC","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 { Angle } from \"../../geometry3d/Angle\";\nimport { CubicEvaluator } from \"./CubicEvaluator\";\n/**\n * AustralianRailCorp spiral (also known as New South Wales spiral)\n * * The ultimate curve is a cubic `y = m * x^3`.\n * * `m` is a constant throughout the curve.\n * * Computation of m from the R and L is an complicated sequence, but is only done at construction time.\n * @internal\n */\nexport class AustralianRailCorpXYEvaluator extends CubicEvaluator {\n private _nominalLength1: number;\n private _nominalRadius1: number;\n private constructor(nominalLength1: number, nominalRadius1: number, axisLength: number, cubicM: number) {\n super(axisLength, cubicM);\n this._nominalLength1 = nominalLength1;\n this._nominalRadius1 = nominalRadius1;\n }\n public get nominalLength1() { return this._nominalLength1; }\n public get nominalRadius1() { return this._nominalRadius1; }\n public clone(): AustralianRailCorpXYEvaluator { return new AustralianRailCorpXYEvaluator(this._nominalLength1, this._nominalRadius1, this._axisLength, this._cubicM); }\n public static create(nominalLength1: number, nominalRadius1: number): AustralianRailCorpXYEvaluator | undefined {\n const axisLength = AustralianRailCorpXYEvaluator.radiusAndNominalLengthToAxisLength(nominalRadius1, nominalLength1);\n const phi = this.radiusAndAxisLengthToPhi(nominalRadius1, axisLength);\n const xc2 = axisLength * axisLength;\n const cubicM = Math.tan(phi) / (3.0 * xc2);\n return new AustralianRailCorpXYEvaluator(nominalLength1, nominalRadius1, axisLength, cubicM);\n }\n /**\n * Compute the phi constant for AustralianRail spiral with given end radius and length along axis.\n * @param nominalRadius1\n * @param axisLength\n */\n public static radiusAndAxisLengthToPhi(nominalRadius1: number, axisLength: number): number {\n const xc = axisLength;\n const expr1 = (2. / Math.sqrt(3.));\n let expr2 = (-(3. / 4.) * Math.sqrt(3.) * xc / nominalRadius1);\n if (expr2 < -1.0)\n expr2 = -1.0;\n if (expr2 > 1.0)\n expr2 = 1.0;\n const expr3 = Angle.degreesToRadians(240);\n\n return Math.asin(expr1 * Math.cos(Math.acos(expr2) / 3. + expr3));\n }\n public override scaleInPlace(scaleFactor: number) {\n // apply the scale factor to all contents.\n // all distances scale directly . . .\n this._nominalLength1 *= scaleFactor;\n this._nominalRadius1 *= scaleFactor;\n super.scaleInPlace(scaleFactor);\n }\n /** Compute length along axis for AustralianRail spiral nominal radius and length.\n *\n */\n public static radiusAndNominalLengthToAxisLength(nominalRadius1: number, nominalLength1: number, tolerance: number = 1.0e-5,\n requiredConvergenceCount: number = 2) {\n const R = nominalRadius1;\n let idx = 0;\n let m, phi, xc2;\n\n let xc = .7 * nominalLength1;\n let convergenceCount = 0;\n // remark: This converges quickly --\n // for L=100, R=400\n // ** full precision at 7th iteration.\n // ** classic tolerance 1.0e-5 (7 digits from L) with requiredConvergenceCount = 1 gives 11 digits after 3 iterations\n // ** each iteration adds about 2 digits. This is quite good for a successive replacement without derivative !!!\n // ** Unanswerable question: If this is only done once and reused over all evaluations, do you want:\n // * run the 7 iterations to get full precision\n // * stop with the classic tolerance to get compatibility?\n for (idx = 0; idx < 100; ++idx) {\n phi = this.radiusAndAxisLengthToPhi(R, xc);\n xc2 = xc * xc;\n m = Math.tan(phi) / (3.0 * xc2);\n const m2x4 = m * m * xc2 * xc2;\n const correction = xc * m2x4 * (\n (9. / 10) + m2x4 * (\n -(9. / 8.) + m2x4 * (\n +(729. / 208.) + m2x4 *\n -(32805. / 2176.))));\n const correctedLength = xc + correction;\n xc = (nominalLength1 / correctedLength) * xc;\n\n if (Math.abs(nominalLength1 - correctedLength) < tolerance) {\n convergenceCount++;\n if (convergenceCount >= requiredConvergenceCount)\n break;\n } else {\n convergenceCount = 0;\n }\n }\n return xc;\n }\n public isAlmostEqual(other: any): boolean {\n if (other instanceof AustralianRailCorpXYEvaluator) {\n return Geometry.isAlmostEqualNumber(this._cubicM, other._cubicM)\n && Geometry.isAlmostEqualNumber(this._axisLength, other._axisLength)\n && Geometry.isAlmostEqualNumber(this._nominalLength1, other._nominalLength1)\n && Geometry.isAlmostEqualNumber(this._nominalRadius1, other._nominalRadius1);\n }\n return false;\n }\n /**\n * Return a (quite good approximation) of fraction along x axis for given distance along spiral.\n * * The AustralianRailSpiral has a supporting power series to approximately map distance along the spiral to an x coordinate.\n * * The `xToFraction(x)` method quickly (with a single divide) converts this x to fraction used fro this.fractionToX (fraction), this.fractionToY(fraction) etc to get coordinates and derivatives.\n * * The x-to-distance relation is not as precise as the CurvePrimitive method moveSignedDistanceFromFraction.\n * * It is supported here for users interested in replicating the AustralianRail distance mapping rather than the more accurate CurvePrimitive measurements.\n * * Round tripping distance through (a) distanceAlongSpiralToAustralianApproximateX, (b) xToFraction, and (c) curveLengthBetweenFractions has\n * * 10 digit accuracy for L/R = 4, 12 digit accuracy for L/R = 10\n * @param s distance along the axis.\n */\n public distanceAlongSpiralToAustralianApproximateX(s: number): number {\n const a1 = 0.9000;\n const a2 = 5.1750;\n const a3 = 43.1948;\n const a4 = 426.0564;\n const m = this._cubicM;\n const m2s4 = m * m * s * s * s * s;\n const x = s * (1.0 - m2s4 * (a1 - m2s4 * (a2 - m2s4 * (a3 - m2s4 * a4))));\n return x;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AustralianRailCorpXYEvaluator.js","sourceRoot":"","sources":["../../../../src/curve/spiral/AustralianRailCorpXYEvaluator.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,6CAA0C;AAC1C,kDAA+C;AAC/C,qDAAkD;AAElD;;;;;;GAMG;AACH,MAAa,6BAA8B,SAAQ,+BAAc;IACvD,eAAe,CAAS;IACxB,eAAe,CAAS;IAChC,YAAoB,cAAsB,EAAE,cAAsB,EAAE,UAAkB,EAAE,MAAc;QACpG,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QACtC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IACxC,CAAC;IACD,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IACD,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IACM,KAAK;QACV,OAAO,IAAI,6BAA6B,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACvH,CAAC;IACM,MAAM,CAAC,MAAM,CAAC,cAAsB,EAAE,cAAsB;QACjE,MAAM,UAAU,GAAG,6BAA6B,CAAC,kCAAkC,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QACpH,MAAM,GAAG,GA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AC;IACX,CAAC;CACF;AA7GD,sEA6GC","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 { Angle } from \"../../geometry3d/Angle\";\nimport { CubicEvaluator } from \"./CubicEvaluator\";\n\n/**\n * AustralianRailCorp spiral (also known as New South Wales spiral)\n * * The ultimate curve is a cubic `y = m * x^3`.\n * * `m` is a constant throughout the curve.\n * * Computation of m from the R and L is an complicated sequence, but is only done at construction time.\n * @internal\n */\nexport class AustralianRailCorpXYEvaluator extends CubicEvaluator {\n private _nominalLength1: number;\n private _nominalRadius1: number;\n private constructor(nominalLength1: number, nominalRadius1: number, axisLength: number, cubicM: number) {\n super(axisLength, cubicM);\n this._nominalLength1 = nominalLength1;\n this._nominalRadius1 = nominalRadius1;\n }\n public get nominalLength1() {\n return this._nominalLength1;\n }\n public get nominalRadius1() {\n return this._nominalRadius1;\n }\n public clone(): AustralianRailCorpXYEvaluator {\n return new AustralianRailCorpXYEvaluator(this._nominalLength1, this._nominalRadius1, this._axisLength, this._cubicM);\n }\n public static create(nominalLength1: number, nominalRadius1: number): AustralianRailCorpXYEvaluator | undefined {\n const axisLength = AustralianRailCorpXYEvaluator.radiusAndNominalLengthToAxisLength(nominalRadius1, nominalLength1);\n const phi = this.radiusAndAxisLengthToPhi(nominalRadius1, axisLength);\n const xc2 = axisLength * axisLength;\n const cubicM = Math.tan(phi) / (3.0 * xc2);\n return new AustralianRailCorpXYEvaluator(nominalLength1, nominalRadius1, axisLength, cubicM);\n }\n /** Compute the phi constant for AustralianRail spiral with given end radius and length along axis. */\n public static radiusAndAxisLengthToPhi(nominalRadius1: number, axisLength: number): number {\n const xc = axisLength;\n const expr1 = (2. / Math.sqrt(3.));\n let expr2 = (-(3. / 4.) * Math.sqrt(3.) * xc / nominalRadius1);\n if (expr2 < -1.0)\n expr2 = -1.0;\n if (expr2 > 1.0)\n expr2 = 1.0;\n const expr3 = Angle.degreesToRadians(240);\n return Math.asin(expr1 * Math.cos(Math.acos(expr2) / 3. + expr3));\n }\n public override scaleInPlace(scaleFactor: number): void {\n // apply the scale factor to all contents; all distances scale directly\n this._nominalLength1 *= scaleFactor;\n this._nominalRadius1 *= scaleFactor;\n super.scaleInPlace(scaleFactor);\n }\n /** Compute length along axis for AustralianRail spiral nominal radius and length. */\n public static radiusAndNominalLengthToAxisLength(\n nominalRadius1: number, nominalLength1: number, tolerance: number = 1.0e-5, requiredConvergenceCount: number = 2,\n ): number {\n const R = nominalRadius1;\n let idx = 0;\n let m, phi, xc2;\n let xc = .7 * nominalLength1;\n let convergenceCount = 0;\n // remark: This converges quickly\n // for L=100, R=400\n // ** full precision at 7th iteration.\n // ** classic tolerance 1.0e-5 (7 digits from L) with requiredConvergenceCount = 1 gives 11 digits after 3 iterations\n // ** each iteration adds about 2 digits. This is quite good for a successive replacement without derivative\n // ** Unanswerable question: If this is only done once and reused over all evaluations, do you want:\n // * run the 7 iterations to get full precision\n // * stop with the classic tolerance to get compatibility?\n for (idx = 0; idx < 100; ++idx) {\n phi = this.radiusAndAxisLengthToPhi(R, xc);\n xc2 = xc * xc;\n m = Math.tan(phi) / (3.0 * xc2);\n const m2x4 = m * m * xc2 * xc2;\n const correction = xc * m2x4 * ((9. / 10) + m2x4 * (-(9. / 8.) + m2x4 * (+(729. / 208.) + m2x4 * -(32805. / 2176.))));\n const correctedLength = xc + correction;\n xc = (nominalLength1 / correctedLength) * xc;\n if (Math.abs(nominalLength1 - correctedLength) < tolerance) {\n convergenceCount++;\n if (convergenceCount >= requiredConvergenceCount)\n break;\n } else {\n convergenceCount = 0;\n }\n }\n return xc;\n }\n public isAlmostEqual(other: any): boolean {\n if (other instanceof AustralianRailCorpXYEvaluator) {\n return Geometry.isAlmostEqualNumber(this._cubicM, other._cubicM)\n && Geometry.isAlmostEqualNumber(this._axisLength, other._axisLength)\n && Geometry.isAlmostEqualNumber(this._nominalLength1, other._nominalLength1)\n && Geometry.isAlmostEqualNumber(this._nominalRadius1, other._nominalRadius1);\n }\n return false;\n }\n /**\n * Return a (quite good approximation) of fraction along x axis for given distance along spiral.\n * * The AustralianRailSpiral has a supporting power series to approximately map distance along the spiral to\n * an x coordinate.\n * * The `xToFraction(x)` method quickly (with a single divide) converts this x to fraction used for\n * this.fractionToX (fraction), this.fractionToY(fraction) etc to get coordinates and derivatives.\n * * The x-to-distance relation is not as precise as the CurvePrimitive method moveSignedDistanceFromFraction.\n * * It is supported here for users interested in replicating the AustralianRail distance mapping rather than the\n * more accurate CurvePrimitive measurements.\n * * Round tripping distance through (a) distanceAlongSpiralToAustralianApproximateX, (b) xToFraction, and\n * (c) curveLengthBetweenFractions has 10 digit accuracy for L/R = 4, 12 digit accuracy for L/R = 10.\n * @param s distance along the axis.\n */\n public distanceAlongSpiralToAustralianApproximateX(s: number): number {\n const a1 = 0.9000;\n const a2 = 5.1750;\n const a3 = 43.1948;\n const a4 = 426.0564;\n const m = this._cubicM;\n const m2s4 = m * m * s * s * s * s;\n const x = s * (1.0 - m2s4 * (a1 - m2s4 * (a2 - m2s4 * (a3 - m2s4 * a4))));\n return x;\n }\n}\n"]}
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import { XYCurveEvaluator } from "./XYCurveEvaluator";
|
|
2
2
|
/**
|
|
3
|
-
* Methods to evaluate caller-specified number of terms of the x and y series for a clothoid.
|
|
4
|
-
* Each instance has
|
|
5
|
-
* *
|
|
6
|
-
* * constant for theta=c
|
|
7
|
-
* * This value is c=1/(2
|
|
3
|
+
* Methods to evaluate caller-specified number of terms of the x and y Taylor series for a clothoid.
|
|
4
|
+
* Each instance has:
|
|
5
|
+
* * number of x and y terms to use.
|
|
6
|
+
* * constant for theta = c*x*x.
|
|
7
|
+
* * This value is c = 1/(2*R*L) for curve length L measured from inflection to point with radius R.
|
|
8
8
|
* @internal
|
|
9
9
|
*/
|
|
10
10
|
export declare class ClothoidSeriesRLEvaluator extends XYCurveEvaluator {
|
|
11
|
+
/** Number of terms to use in x Taylor series. */
|
|
11
12
|
numXTerms: number;
|
|
13
|
+
/** Number of terms to use in y Taylor series. */
|
|
12
14
|
numYTerms: number;
|
|
15
|
+
/** Constant c = 1/(2*R*L) in theta = c*s*s. */
|
|
13
16
|
constantDiv2LR: number;
|
|
17
|
+
/** The nominal curve length. */
|
|
14
18
|
nominalLength1: number;
|
|
15
19
|
constructor(nominalLength1: number, constantDiv2LR: number, numXTerms?: number, numYTerms?: number);
|
|
16
20
|
/** Return a deep clone. */
|
|
17
21
|
clone(): ClothoidSeriesRLEvaluator;
|
|
18
22
|
scaleInPlace(scaleFactor: number): void;
|
|
19
|
-
/** Member by member matchup
|
|
23
|
+
/** Member by member matchup. */
|
|
20
24
|
isAlmostEqual(other: any): boolean;
|
|
21
25
|
/**
|
|
22
26
|
* Evaluate the X series at a nominal distance along the curve.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClothoidSeries.d.ts","sourceRoot":"","sources":["../../../../src/curve/spiral/ClothoidSeries.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ClothoidSeries.d.ts","sourceRoot":"","sources":["../../../../src/curve/spiral/ClothoidSeries.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD;;;;;;;GAOG;AACH,qBAAa,yBAA0B,SAAQ,gBAAgB;IAC7D,iDAAiD;IAC1C,SAAS,EAAE,MAAM,CAAC;IACzB,iDAAiD;IAC1C,SAAS,EAAE,MAAM,CAAC;IACzB,+CAA+C;IACxC,cAAc,EAAE,MAAM,CAAC;IAC9B,gCAAgC;IACzB,cAAc,EAAE,MAAM,CAAC;gBACX,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,E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@@ -12,17 +12,21 @@ const Geometry_1 = require("../../Geometry");
|
|
|
12
12
|
const XYCurveEvaluator_1 = require("./XYCurveEvaluator");
|
|
13
13
|
const Newton_1 = require("../../numerics/Newton");
|
|
14
14
|
/**
|
|
15
|
-
* Methods to evaluate caller-specified number of terms of the x and y series for a clothoid.
|
|
16
|
-
* Each instance has
|
|
17
|
-
* *
|
|
18
|
-
* * constant for theta=c
|
|
19
|
-
* * This value is c=1/(2
|
|
15
|
+
* Methods to evaluate caller-specified number of terms of the x and y Taylor series for a clothoid.
|
|
16
|
+
* Each instance has:
|
|
17
|
+
* * number of x and y terms to use.
|
|
18
|
+
* * constant for theta = c*x*x.
|
|
19
|
+
* * This value is c = 1/(2*R*L) for curve length L measured from inflection to point with radius R.
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
22
|
class ClothoidSeriesRLEvaluator extends XYCurveEvaluator_1.XYCurveEvaluator {
|
|
23
|
+
/** Number of terms to use in x Taylor series. */
|
|
23
24
|
numXTerms;
|
|
25
|
+
/** Number of terms to use in y Taylor series. */
|
|
24
26
|
numYTerms;
|
|
27
|
+
/** Constant c = 1/(2*R*L) in theta = c*s*s. */
|
|
25
28
|
constantDiv2LR;
|
|
29
|
+
/** The nominal curve length. */
|
|
26
30
|
nominalLength1;
|
|
27
31
|
constructor(nominalLength1, constantDiv2LR, numXTerms = 4, numYTerms = 4) {
|
|
28
32
|
super();
|
|
@@ -39,7 +43,7 @@ class ClothoidSeriesRLEvaluator extends XYCurveEvaluator_1.XYCurveEvaluator {
|
|
|
39
43
|
this.nominalLength1 *= scaleFactor;
|
|
40
44
|
this.constantDiv2LR /= (scaleFactor * scaleFactor);
|
|
41
45
|
}
|
|
42
|
-
/** Member by member matchup
|
|
46
|
+
/** Member by member matchup. */
|
|
43
47
|
isAlmostEqual(other) {
|
|
44
48
|
if (other instanceof ClothoidSeriesRLEvaluator) {
|
|
45
49
|
return this.numXTerms === other.numXTerms
|
|
@@ -53,43 +57,55 @@ class ClothoidSeriesRLEvaluator extends XYCurveEvaluator_1.XYCurveEvaluator {
|
|
|
53
57
|
* Evaluate the X series at a nominal distance along the curve.
|
|
54
58
|
* @param fraction fractional position along the curve.
|
|
55
59
|
*/
|
|
56
|
-
fractionToX(fraction) {
|
|
60
|
+
fractionToX(fraction) {
|
|
61
|
+
return this.fractionToXGo(fraction, this.numXTerms);
|
|
62
|
+
}
|
|
57
63
|
/**
|
|
58
64
|
* Evaluate the Y series at a nominal distance along the curve.
|
|
59
65
|
* @param fraction fractional position along the curve.
|
|
60
66
|
*/
|
|
61
|
-
fractionToY(fraction) {
|
|
67
|
+
fractionToY(fraction) {
|
|
68
|
+
return this.fractionToYGo(fraction, this.numYTerms);
|
|
69
|
+
}
|
|
62
70
|
/**
|
|
63
71
|
* Evaluate the derivative of the X series at a nominal distance along the curve.
|
|
64
72
|
* @param fraction fractional position along the curve.
|
|
65
73
|
*/
|
|
66
|
-
fractionToDX(fraction) {
|
|
74
|
+
fractionToDX(fraction) {
|
|
75
|
+
return this.fractionToDXGo(fraction, this.numXTerms);
|
|
76
|
+
}
|
|
67
77
|
/**
|
|
68
78
|
* Evaluate the derivative of the Y series at a nominal distance along the curve.
|
|
69
79
|
* @param fraction fractional position along the curve.
|
|
70
80
|
*/
|
|
71
|
-
fractionToDY(fraction) {
|
|
81
|
+
fractionToDY(fraction) {
|
|
82
|
+
return this.fractionToDYGo(fraction, this.numYTerms);
|
|
83
|
+
}
|
|
72
84
|
/**
|
|
73
85
|
* Evaluate the derivative of the X series at a nominal distance along the curve.
|
|
74
86
|
* @param fraction fractional position along the curve.
|
|
75
87
|
*/
|
|
76
|
-
fractionToDDX(fraction) {
|
|
88
|
+
fractionToDDX(fraction) {
|
|
89
|
+
return this.fractionToDDXGo(fraction, this.numXTerms);
|
|
90
|
+
}
|
|
77
91
|
/**
|
|
78
92
|
* Evaluate the derivative of the Y series at a nominal distance along the curve.
|
|
79
93
|
* @param fraction fractional position along the curve.
|
|
80
94
|
*/
|
|
81
|
-
fractionToDDY(fraction) {
|
|
95
|
+
fractionToDDY(fraction) {
|
|
96
|
+
return this.fractionToDDYGo(fraction, this.numYTerms);
|
|
97
|
+
}
|
|
82
98
|
/**
|
|
83
99
|
* Evaluate the X series at a nominal distance along the curve.
|
|
84
100
|
* @param fraction fractional position along the curve.
|
|
85
101
|
* @param numTerms number of terms to use.
|
|
86
102
|
*/
|
|
87
103
|
fractionToXGo(fraction, numTerms) {
|
|
88
|
-
//
|
|
104
|
+
// write the Taylor series for cos(theta)
|
|
89
105
|
// replace theta by s*s*c
|
|
90
106
|
// integrate wrt s
|
|
91
|
-
// x = s - s^5 c^
|
|
92
|
-
// x = s(1 - (s^4 c^2/2) ( 1/5 -s^4 c^2 /
|
|
107
|
+
// x = s - s^5 c^2/ 5*2! + s^9 c^4 / 9*4! - s^13 c^6 / 13*6! + ...
|
|
108
|
+
// x = s(1 - (s^4 c^2/2) ( 1/5 - (s^4 c^2 / 3*4) (1/9 - ...) ) )
|
|
93
109
|
const s = fraction * this.nominalLength1;
|
|
94
110
|
let result = s;
|
|
95
111
|
if (numTerms < 2)
|
|
@@ -108,10 +124,11 @@ class ClothoidSeriesRLEvaluator extends XYCurveEvaluator_1.XYCurveEvaluator {
|
|
|
108
124
|
return result;
|
|
109
125
|
}
|
|
110
126
|
fractionToYGo(fraction, numTerms) {
|
|
111
|
-
//
|
|
127
|
+
// write the Taylor series for sin(theta)
|
|
112
128
|
// replace theta by s*s*c
|
|
113
129
|
// integrate wrt s
|
|
114
|
-
//
|
|
130
|
+
// y = s^3 c / 3 - s^7 c^3 / 7*3! + s^11 c^5 / 11*5! - s^15 c^7 / 15*7! + ...
|
|
131
|
+
// y = s^3 c ( 1/3 - s^4 c^2/ 3! ( (1/7) - (s^4 c^2 / 4*5) (1/11 - ...) ) )
|
|
115
132
|
const s = fraction * this.nominalLength1;
|
|
116
133
|
const q1 = s * s * this.constantDiv2LR;
|
|
117
134
|
let result = q1 * s / 3;
|
|
@@ -130,7 +147,7 @@ class ClothoidSeriesRLEvaluator extends XYCurveEvaluator_1.XYCurveEvaluator {
|
|
|
130
147
|
return result;
|
|
131
148
|
}
|
|
132
149
|
fractionToDXGo(fraction, numTerms) {
|
|
133
|
-
//
|
|
150
|
+
// yes -- this does happen during derivatives of cosines with more than 0 terms
|
|
134
151
|
if (numTerms <= 0)
|
|
135
152
|
return 0;
|
|
136
153
|
// dX = 1 - s^4c^2/2 + s^8 c^4 / 4! -
|
|
@@ -185,7 +202,7 @@ class ClothoidSeriesRLEvaluator extends XYCurveEvaluator_1.XYCurveEvaluator {
|
|
|
185
202
|
fractionToDDYGo(fraction, numTerms) {
|
|
186
203
|
// DY is "sine"
|
|
187
204
|
// DDY is "cosine" series times chain rule dTheta/ds = 2 * s * this.constantDivLR
|
|
188
|
-
// BUT .... derivative of the cosine series leading term is zero ... use one less term
|
|
205
|
+
// BUT .... derivative of the cosine series leading term is zero ... use one less term
|
|
189
206
|
const s = fraction * this.nominalLength1;
|
|
190
207
|
const dTheta = 2 * this.constantDiv2LR * s;
|
|
191
208
|
const cosine = this.fractionToDXGo(fraction, numTerms);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClothoidSeries.js","sourceRoot":"","sources":["../../../../src/curve/spiral/ClothoidSeries.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,6CAA0C;AAC1C,yDAAsD;AACtD,kDAAqD;AACrD;;;;;;;GAOG;AACH,MAAa,yBAA0B,SAAQ,mCAAgB;IACtD,SAAS,CAAS;IAClB,SAAS,CAAS;IAClB,cAAc,CAAS;IACvB,cAAc,CAAS;IAC9B,YAAmB,cAAsB,EAAE,cAAsB,EAAE,YAAoB,CAAC,EAAE,YAAoB,CAAC;QAC7G,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,SAAS,CA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AAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AArND,8DAqNC","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 { Geometry } from \"../../Geometry\";\nimport { XYCurveEvaluator } from \"./XYCurveEvaluator\";\nimport { SimpleNewton } from \"../../numerics/Newton\";\n/**\n * Methods to evaluate caller-specified number of terms of the x and y series for a clothoid.\n * Each instance has\n * * Number of x and y terms to use.\n * * constant for theta=c * x * x\n * * This value is c=1/(2 R L) for curve length L measured from inflection to point with radius R.\n * @internal\n */\nexport class ClothoidSeriesRLEvaluator extends XYCurveEvaluator {\n public numXTerms: number;\n public numYTerms: number;\n public constantDiv2LR: number;\n public nominalLength1: number;\n public constructor(nominalLength1: number, constantDiv2LR: number, numXTerms: number = 4, numYTerms: number = 4) {\n super();\n this.nominalLength1 = nominalLength1;\n this.constantDiv2LR = constantDiv2LR;\n this.numXTerms = numXTerms;\n this.numYTerms = numYTerms;\n }\n /** Return a deep clone. */\n public clone(): ClothoidSeriesRLEvaluator {\n return new ClothoidSeriesRLEvaluator(this.nominalLength1, this.constantDiv2LR, this.numXTerms, this.numYTerms);\n }\n public scaleInPlace(scaleFactor: number) {\n this.nominalLength1 *= scaleFactor;\n this.constantDiv2LR /= (scaleFactor * scaleFactor);\n }\n /** Member by member matchup ... */\n public isAlmostEqual(other: any): boolean {\n if (other instanceof ClothoidSeriesRLEvaluator) {\n return this.numXTerms === other.numXTerms\n && this.numYTerms === other.numYTerms\n && Geometry.isAlmostEqualNumber(this.constantDiv2LR, other.constantDiv2LR)\n && Geometry.isSameCoordinate(this.nominalLength1, other.nominalLength1);\n }\n return false;\n }\n /**\n * Evaluate the X series at a nominal distance along the curve.\n * @param fraction fractional position along the curve.\n */\n public fractionToX(fraction: number): number { return this.fractionToXGo(fraction, this.numXTerms); }\n /**\n * Evaluate the Y series at a nominal distance along the curve.\n * @param fraction fractional position along the curve.\n */\n public fractionToY(fraction: number): number { return this.fractionToYGo(fraction, this.numYTerms); }\n\n /**\n * Evaluate the derivative of the X series at a nominal distance along the curve.\n * @param fraction fractional position along the curve.\n */\n public fractionToDX(fraction: number): number { return this.fractionToDXGo(fraction, this.numXTerms); }\n /**\n * Evaluate the derivative of the Y series at a nominal distance along the curve.\n * @param fraction fractional position along the curve.\n */\n public fractionToDY(fraction: number): number { return this.fractionToDYGo(fraction, this.numYTerms); }\n\n /**\n * Evaluate the derivative of the X series at a nominal distance along the curve.\n * @param fraction fractional position along the curve.\n */\n public fractionToDDX(fraction: number): number { return this.fractionToDDXGo(fraction, this.numXTerms); }\n /**\n * Evaluate the derivative of the Y series at a nominal distance along the curve.\n * @param fraction fractional position along the curve.\n */\n public fractionToDDY(fraction: number): number { return this.fractionToDDYGo(fraction, this.numYTerms); }\n\n /**\n * Evaluate the X series at a nominal distance along the curve.\n * @param fraction fractional position along the curve.\n * @param numTerms number of terms to use.\n */\n public fractionToXGo(fraction: number, numTerms: number): number {\n // Write the series for cos (theta)\n // replace theta by s*s*c\n // integrate wrt s\n // x = s - s^5 c^4/ 2 + s^9 c^8/(4!) - s^13 c^12 / 6!\n // x = s(1 - (s^4 c^2/2) ( 1/5 -s^4 c^2 / (3*4) ( 1/9 - ....) ) )\n const s = fraction * this.nominalLength1;\n let result = s;\n if (numTerms < 2)\n return result;\n const q1 = s * s * this.constantDiv2LR;\n const beta = - q1 * q1;\n let alpha = s;\n let m = 1;\n let n = 5;\n for (let i = 1; i < numTerms; i++) {\n alpha *= beta / (m * (m + 1));\n result += alpha / n;\n m += 2;\n n += 4;\n }\n return result;\n }\n public fractionToYGo(fraction: number, numTerms: number): number {\n // Write the series for sin (theta)\n // replace theta by s*s*c\n // integrate wrt s\n // x = s^3 c^2/ 3( (1/3)) - s^7 c^6/(3!) ((1/7)) - s^11 c^10 / 5! ((1/9) - ...)\n const s = fraction * this.nominalLength1;\n const q1 = s * s * this.constantDiv2LR;\n let result = q1 * s / 3;\n if (numTerms < 2)\n return result;\n const beta = - q1 * q1;\n let alpha = q1 * s;\n let m = 2;\n let n = 7;\n for (let i = 1; i < numTerms; i++) {\n alpha *= beta / (m * (m + 1));\n result += alpha / n;\n m += 2;\n n += 4;\n }\n return result;\n }\n public fractionToDXGo(fraction: number, numTerms: number): number {\n // Yes -- this does happen during derivatives of cosines with more than 0 terms !!\n if (numTerms <= 0)\n return 0;\n // dX = 1 - s^4c^2/2 + s^8 c^4 / 4! -\n // new Term = old Term * beta / (m(m+1))\n const s = fraction * this.nominalLength1;\n let result = 1;\n if (numTerms < 2) {\n return result * this.nominalLength1;\n }\n const q1 = s * s * this.constantDiv2LR;\n const beta = - q1 * q1;\n let alpha = 1.0;\n let m = 1;\n for (let i = 1; i < numTerms; i++) {\n alpha *= beta / (m * (m + 1));\n result += alpha;\n m += 2;\n }\n return result * this.nominalLength1;\n }\n public fractionToDYGo(fraction: number, numTerms: number): number {\n if (numTerms <= 0)\n return 0;\n // dY = q - q^3/3!\n // q = s^2 c\n // dY = s^2 c - s^6 c^3/3! + s^10 c^5/ 5!\n // recurrence advancing m by 2 alpha *= -(s^4 c^2) / (m(m+1))\n const s = fraction * this.nominalLength1;\n const q1 = s * s * this.constantDiv2LR;\n let result = q1;\n if (numTerms < 2)\n return result * this.nominalLength1;\n const beta = - q1 * q1;\n let alpha = q1;\n let m = 2;\n for (let i = 1; i < numTerms; i++) {\n alpha *= beta / (m * (m + 1));\n result += alpha;\n m += 2;\n }\n return result * this.nominalLength1;\n }\n\n public fractionToDDXGo(fraction: number, numTerms: number): number {\n // DX is \"cosine\"\n // DDX is \"- sine\" series times chain rule dTheta/ds = 2 * s * this.constantDivLR\n const s = fraction * this.nominalLength1;\n\n const dTheta = 2 * this.constantDiv2LR * s;\n const sine = this.fractionToDYGo(fraction, numTerms - 1);\n const resultA = (- dTheta * sine * this.nominalLength1);\n return resultA;\n }\n public fractionToDDYGo(fraction: number, numTerms: number): number {\n // DY is \"sine\"\n // DDY is \"cosine\" series times chain rule dTheta/ds = 2 * s * this.constantDivLR\n // BUT .... derivative of the cosine series leading term is zero ... use one less term!\n const s = fraction * this.nominalLength1;\n const dTheta = 2 * this.constantDiv2LR * s;\n const cosine = this.fractionToDXGo(fraction, numTerms);\n return cosine * dTheta * this.nominalLength1;\n }\n\n public fractionToD3X(fraction: number): number {\n if (this.numXTerms <= 1)\n return 0.0;\n // DX is \"cosine\"\n // DDX is \"- sine\" series times chain rule dTheta/ds = 2 * s * this.constantDivLR\n const s = fraction * this.nominalLength1;\n const dTheta = 2.0 * this.constantDiv2LR * s;\n const d2Theta = 2.0 * this.constantDiv2LR;\n const sine = this.fractionToDYGo(fraction, this.numXTerms - 1);\n const cosine = this.fractionToDXGo(fraction, this.numXTerms - 1);\n return (- cosine * dTheta * dTheta - sine * d2Theta) * this.nominalLength1 * this.nominalLength1;\n }\n public fractionToD3Y(fraction: number): number {\n // DY is \"sine\"\n // DDY is \"cosine\" series times chain rule dTheta/ds = 2 * s * this.constantDivLR\n const s = fraction * this.nominalLength1;\n const dTheta = 2.0 * this.constantDiv2LR * s;\n const d2Theta = 2.0 * this.constantDiv2LR;\n // dY is sine series with numYTerms.\n // ddY is cosine series. Leading term of sine series is non-constant, so numYTerms here also\n // d3Y is sine series. Derivative of preceding cosine killed first term.\n const cosine = this.fractionToDXGo(fraction, this.numYTerms);\n const sine = this.fractionToDYGo(fraction, this.numYTerms - 1);\n return (-sine * dTheta * dTheta + cosine * d2Theta) * this.nominalLength1 * this.nominalLength1;\n }\n\n public xToFraction(x: number): number | undefined {\n const fraction0 = x / this.nominalLength1;\n const fraction1 = SimpleNewton.runNewton1D(fraction0,\n (f: number) => (this.fractionToX(f) - x),\n (f: number) => this.fractionToDX(f));\n if (fraction1 === undefined)\n return undefined;\n return fraction1;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ClothoidSeries.js","sourceRoot":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,CAAC,CAAC,CAAC;QAC/D,OAAO,CAAC,CAAC,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;IAClG,CAAC;IACM,WAAW,CAAC,CAAS;QAC1B,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC;QAC1C,MAAM,SAAS,GAAG,qBAAY,CAAC,WAAW,CAAC,SAAS,EAClD,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EACxC,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,IAAI,SAAS,KAAK,SAAS;YACzB,OAAO,SAAS,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA/ND,8DA+NC","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 { Geometry } from \"../../Geometry\";\nimport { XYCurveEvaluator } from \"./XYCurveEvaluator\";\nimport { SimpleNewton } from \"../../numerics/Newton\";\n\n/**\n * Methods to evaluate caller-specified number of terms of the x and y Taylor series for a clothoid.\n * Each instance has:\n * * number of x and y terms to use.\n * * constant for theta = c*x*x.\n * * This value is c = 1/(2*R*L) for curve length L measured from inflection to point with radius R.\n * @internal\n */\nexport class ClothoidSeriesRLEvaluator extends XYCurveEvaluator {\n /** Number of terms to use in x Taylor series. */\n public numXTerms: number;\n /** Number of terms to use in y Taylor series. */\n public numYTerms: number;\n /** Constant c = 1/(2*R*L) in theta = c*s*s. */\n public constantDiv2LR: number;\n /** The nominal curve length. */\n public nominalLength1: number;\n public constructor(nominalLength1: number, constantDiv2LR: number, numXTerms: number = 4, numYTerms: number = 4) {\n super();\n this.nominalLength1 = nominalLength1;\n this.constantDiv2LR = constantDiv2LR;\n this.numXTerms = numXTerms;\n this.numYTerms = numYTerms;\n }\n /** Return a deep clone. */\n public clone(): ClothoidSeriesRLEvaluator {\n return new ClothoidSeriesRLEvaluator(this.nominalLength1, this.constantDiv2LR, this.numXTerms, this.numYTerms);\n }\n public scaleInPlace(scaleFactor: number): void {\n this.nominalLength1 *= scaleFactor;\n this.constantDiv2LR /= (scaleFactor * scaleFactor);\n }\n /** Member by member matchup. */\n public isAlmostEqual(other: any): boolean {\n if (other instanceof ClothoidSeriesRLEvaluator) {\n return this.numXTerms === other.numXTerms\n && this.numYTerms === other.numYTerms\n && Geometry.isAlmostEqualNumber(this.constantDiv2LR, other.constantDiv2LR)\n && Geometry.isSameCoordinate(this.nominalLength1, other.nominalLength1);\n }\n return false;\n }\n /**\n * Evaluate the X series at a nominal distance along the curve.\n * @param fraction fractional position along the curve.\n */\n public fractionToX(fraction: number): number {\n return this.fractionToXGo(fraction, this.numXTerms);\n }\n /**\n * Evaluate the Y series at a nominal distance along the curve.\n * @param fraction fractional position along the curve.\n */\n public fractionToY(fraction: number): number {\n return this.fractionToYGo(fraction, this.numYTerms);\n }\n /**\n * Evaluate the derivative of the X series at a nominal distance along the curve.\n * @param fraction fractional position along the curve.\n */\n public fractionToDX(fraction: number): number {\n return this.fractionToDXGo(fraction, this.numXTerms);\n }\n /**\n * Evaluate the derivative of the Y series at a nominal distance along the curve.\n * @param fraction fractional position along the curve.\n */\n public fractionToDY(fraction: number): number {\n return this.fractionToDYGo(fraction, this.numYTerms);\n }\n /**\n * Evaluate the derivative of the X series at a nominal distance along the curve.\n * @param fraction fractional position along the curve.\n */\n public fractionToDDX(fraction: number): number {\n return this.fractionToDDXGo(fraction, this.numXTerms);\n }\n /**\n * Evaluate the derivative of the Y series at a nominal distance along the curve.\n * @param fraction fractional position along the curve.\n */\n public fractionToDDY(fraction: number): number {\n return this.fractionToDDYGo(fraction, this.numYTerms);\n }\n /**\n * Evaluate the X series at a nominal distance along the curve.\n * @param fraction fractional position along the curve.\n * @param numTerms number of terms to use.\n */\n public fractionToXGo(fraction: number, numTerms: number): number {\n // write the Taylor series for cos(theta)\n // replace theta by s*s*c\n // integrate wrt s\n // x = s - s^5 c^2/ 5*2! + s^9 c^4 / 9*4! - s^13 c^6 / 13*6! + ...\n // x = s(1 - (s^4 c^2/2) ( 1/5 - (s^4 c^2 / 3*4) (1/9 - ...) ) )\n const s = fraction * this.nominalLength1;\n let result = s;\n if (numTerms < 2)\n return result;\n const q1 = s * s * this.constantDiv2LR;\n const beta = - q1 * q1;\n let alpha = s;\n let m = 1;\n let n = 5;\n for (let i = 1; i < numTerms; i++) {\n alpha *= beta / (m * (m + 1));\n result += alpha / n;\n m += 2;\n n += 4;\n }\n return result;\n }\n public fractionToYGo(fraction: number, numTerms: number): number {\n // write the Taylor series for sin(theta)\n // replace theta by s*s*c\n // integrate wrt s\n // y = s^3 c / 3 - s^7 c^3 / 7*3! + s^11 c^5 / 11*5! - s^15 c^7 / 15*7! + ...\n // y = s^3 c ( 1/3 - s^4 c^2/ 3! ( (1/7) - (s^4 c^2 / 4*5) (1/11 - ...) ) )\n const s = fraction * this.nominalLength1;\n const q1 = s * s * this.constantDiv2LR;\n let result = q1 * s / 3;\n if (numTerms < 2)\n return result;\n const beta = - q1 * q1;\n let alpha = q1 * s;\n let m = 2;\n let n = 7;\n for (let i = 1; i < numTerms; i++) {\n alpha *= beta / (m * (m + 1));\n result += alpha / n;\n m += 2;\n n += 4;\n }\n return result;\n }\n public fractionToDXGo(fraction: number, numTerms: number): number {\n // yes -- this does happen during derivatives of cosines with more than 0 terms\n if (numTerms <= 0)\n return 0;\n // dX = 1 - s^4c^2/2 + s^8 c^4 / 4! -\n // new Term = old Term * beta / (m(m+1))\n const s = fraction * this.nominalLength1;\n let result = 1;\n if (numTerms < 2) {\n return result * this.nominalLength1;\n }\n const q1 = s * s * this.constantDiv2LR;\n const beta = - q1 * q1;\n let alpha = 1.0;\n let m = 1;\n for (let i = 1; i < numTerms; i++) {\n alpha *= beta / (m * (m + 1));\n result += alpha;\n m += 2;\n }\n return result * this.nominalLength1;\n }\n public fractionToDYGo(fraction: number, numTerms: number): number {\n if (numTerms <= 0)\n return 0;\n // dY = q - q^3/3!\n // q = s^2 c\n // dY = s^2 c - s^6 c^3/3! + s^10 c^5/ 5!\n // recurrence advancing m by 2 alpha *= -(s^4 c^2) / (m(m+1))\n const s = fraction * this.nominalLength1;\n const q1 = s * s * this.constantDiv2LR;\n let result = q1;\n if (numTerms < 2)\n return result * this.nominalLength1;\n const beta = - q1 * q1;\n let alpha = q1;\n let m = 2;\n for (let i = 1; i < numTerms; i++) {\n alpha *= beta / (m * (m + 1));\n result += alpha;\n m += 2;\n }\n return result * this.nominalLength1;\n }\n public fractionToDDXGo(fraction: number, numTerms: number): number {\n // DX is \"cosine\"\n // DDX is \"- sine\" series times chain rule dTheta/ds = 2 * s * this.constantDivLR\n const s = fraction * this.nominalLength1;\n const dTheta = 2 * this.constantDiv2LR * s;\n const sine = this.fractionToDYGo(fraction, numTerms - 1);\n const resultA = (- dTheta * sine * this.nominalLength1);\n return resultA;\n }\n public fractionToDDYGo(fraction: number, numTerms: number): number {\n // DY is \"sine\"\n // DDY is \"cosine\" series times chain rule dTheta/ds = 2 * s * this.constantDivLR\n // BUT .... derivative of the cosine series leading term is zero ... use one less term\n const s = fraction * this.nominalLength1;\n const dTheta = 2 * this.constantDiv2LR * s;\n const cosine = this.fractionToDXGo(fraction, numTerms);\n return cosine * dTheta * this.nominalLength1;\n }\n public fractionToD3X(fraction: number): number {\n if (this.numXTerms <= 1)\n return 0.0;\n // DX is \"cosine\"\n // DDX is \"- sine\" series times chain rule dTheta/ds = 2 * s * this.constantDivLR\n const s = fraction * this.nominalLength1;\n const dTheta = 2.0 * this.constantDiv2LR * s;\n const d2Theta = 2.0 * this.constantDiv2LR;\n const sine = this.fractionToDYGo(fraction, this.numXTerms - 1);\n const cosine = this.fractionToDXGo(fraction, this.numXTerms - 1);\n return (- cosine * dTheta * dTheta - sine * d2Theta) * this.nominalLength1 * this.nominalLength1;\n }\n public fractionToD3Y(fraction: number): number {\n // DY is \"sine\"\n // DDY is \"cosine\" series times chain rule dTheta/ds = 2 * s * this.constantDivLR\n const s = fraction * this.nominalLength1;\n const dTheta = 2.0 * this.constantDiv2LR * s;\n const d2Theta = 2.0 * this.constantDiv2LR;\n // dY is sine series with numYTerms.\n // ddY is cosine series. Leading term of sine series is non-constant, so numYTerms here also\n // d3Y is sine series. Derivative of preceding cosine killed first term.\n const cosine = this.fractionToDXGo(fraction, this.numYTerms);\n const sine = this.fractionToDYGo(fraction, this.numYTerms - 1);\n return (-sine * dTheta * dTheta + cosine * d2Theta) * this.nominalLength1 * this.nominalLength1;\n }\n public xToFraction(x: number): number | undefined {\n const fraction0 = x / this.nominalLength1;\n const fraction1 = SimpleNewton.runNewton1D(fraction0,\n (f: number) => (this.fractionToX(f) - x),\n (f: number) => this.fractionToDX(f));\n if (fraction1 === undefined)\n return undefined;\n return fraction1;\n }\n}\n"]}
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* @module Curve
|
|
3
3
|
*/
|
|
4
4
|
import { XYCurveEvaluator } from "./XYCurveEvaluator";
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Intermediate class for evaluation of bare cubic spirals `y = m*x^3` with x axis from [0..xLength]
|
|
6
7
|
* * This implements all the computations among fraction, x, and y.
|
|
7
|
-
* * Derived classes implement specialized logic such as (a) precomputing `m` and (b) domain-specific fraction-to-distance
|
|
8
|
+
* * Derived classes implement specialized logic such as (a) precomputing `m` and (b) domain-specific fraction-to-distance
|
|
9
|
+
* approximations.
|
|
8
10
|
* @internal
|
|
9
11
|
*/
|
|
10
12
|
export declare abstract class CubicEvaluator extends XYCurveEvaluator {
|
|
@@ -18,16 +20,15 @@ export declare abstract class CubicEvaluator extends XYCurveEvaluator {
|
|
|
18
20
|
/**
|
|
19
21
|
* Apply `scaleFactor` to the xLength and cubicM.
|
|
20
22
|
* * Derived classes commonly call this as `super.scaleInPlace()`, and additionally apply the scale to their members.
|
|
21
|
-
* @param scaleFactor
|
|
22
23
|
*/
|
|
23
24
|
scaleInPlace(scaleFactor: number): void;
|
|
24
25
|
/** Evaluate X at fraction. */
|
|
25
26
|
fractionToX(fraction: number): number;
|
|
26
|
-
/** Evaluate derivative of X with respect to fraction */
|
|
27
|
+
/** Evaluate derivative of X with respect to fraction. */
|
|
27
28
|
fractionToDX(_fraction: number): number;
|
|
28
|
-
/** Evaluate second derivative of X with respect to fraction */
|
|
29
|
+
/** Evaluate second derivative of X with respect to fraction. */
|
|
29
30
|
fractionToDDX(_fraction: number): number;
|
|
30
|
-
/** Evaluate third derivative of X with respect to fraction */
|
|
31
|
+
/** Evaluate third derivative of X with respect to fraction. */
|
|
31
32
|
fractionToD3X(_fraction: number): number;
|
|
32
33
|
/** Evaluate Y at fraction. */
|
|
33
34
|
fractionToY(fraction: number): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CubicEvaluator.d.ts","sourceRoot":"","sources":["../../../../src/curve/spiral/CubicEvaluator.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"CubicEvaluator.d.ts","sourceRoot":"","sources":["../../../../src/curve/spiral/CubicEvaluator.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;;;GAMG;AACH,8BAAsB,cAAe,SAAQ,gBAAgB;IAC3D,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC;IAC9B,SAAS,aAAa,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAKxD,6BAA6B;IACtB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAItD,IAAW,UAAU,WAEpB;IACD,IAAW,MAAM,WAEhB;IACD;;;OAGG;IACI,YAAY,CAAC,WAAW,EAAE,MAAM;IAKvC,8BAA8B;IACvB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAG5C,yDAAyD;IAClD,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAG9C,gEAAgE;IACzD,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAG/C,+DAA+D;IACxD,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAG/C,8BAA8B;IACvB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAI5C,yDAAyD;IAClD,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAI7C,gEAAgE;IACzD,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAI9C,+DAA+D;IACxD,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAG/C,8BAA8B;IACvB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;CAGtC"}
|
|
@@ -9,9 +9,11 @@ exports.CubicEvaluator = void 0;
|
|
|
9
9
|
* @module Curve
|
|
10
10
|
*/
|
|
11
11
|
const XYCurveEvaluator_1 = require("./XYCurveEvaluator");
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Intermediate class for evaluation of bare cubic spirals `y = m*x^3` with x axis from [0..xLength]
|
|
13
14
|
* * This implements all the computations among fraction, x, and y.
|
|
14
|
-
* * Derived classes implement specialized logic such as (a) precomputing `m` and (b) domain-specific fraction-to-distance
|
|
15
|
+
* * Derived classes implement specialized logic such as (a) precomputing `m` and (b) domain-specific fraction-to-distance
|
|
16
|
+
* approximations.
|
|
15
17
|
* @internal
|
|
16
18
|
*/
|
|
17
19
|
class CubicEvaluator extends XYCurveEvaluator_1.XYCurveEvaluator {
|
|
@@ -27,26 +29,37 @@ class CubicEvaluator extends XYCurveEvaluator_1.XYCurveEvaluator {
|
|
|
27
29
|
this._axisLength = axisLength;
|
|
28
30
|
this._cubicM = cubicM;
|
|
29
31
|
}
|
|
30
|
-
get axisLength() {
|
|
31
|
-
|
|
32
|
+
get axisLength() {
|
|
33
|
+
return this._axisLength;
|
|
34
|
+
}
|
|
35
|
+
get cubicM() {
|
|
36
|
+
return this._cubicM;
|
|
37
|
+
}
|
|
32
38
|
/**
|
|
33
39
|
* Apply `scaleFactor` to the xLength and cubicM.
|
|
34
40
|
* * Derived classes commonly call this as `super.scaleInPlace()`, and additionally apply the scale to their members.
|
|
35
|
-
* @param scaleFactor
|
|
36
41
|
*/
|
|
37
42
|
scaleInPlace(scaleFactor) {
|
|
38
43
|
this._axisLength *= scaleFactor;
|
|
39
|
-
// "x" arriving at "m * x^3" will be scaled. "m" has to be divided by the scale to cancel 2 of the 3
|
|
44
|
+
// "x" arriving at "m * x^3" will be scaled. "m" has to be divided by the scale to cancel 2 of the 3
|
|
40
45
|
this._cubicM /= (scaleFactor * scaleFactor);
|
|
41
46
|
}
|
|
42
47
|
/** Evaluate X at fraction. */
|
|
43
|
-
fractionToX(fraction) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/** Evaluate
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
fractionToX(fraction) {
|
|
49
|
+
return fraction * this._axisLength;
|
|
50
|
+
}
|
|
51
|
+
/** Evaluate derivative of X with respect to fraction. */
|
|
52
|
+
fractionToDX(_fraction) {
|
|
53
|
+
return this._axisLength;
|
|
54
|
+
}
|
|
55
|
+
/** Evaluate second derivative of X with respect to fraction. */
|
|
56
|
+
fractionToDDX(_fraction) {
|
|
57
|
+
return 0.0;
|
|
58
|
+
}
|
|
59
|
+
/** Evaluate third derivative of X with respect to fraction. */
|
|
60
|
+
fractionToD3X(_fraction) {
|
|
61
|
+
return 0.0;
|
|
62
|
+
}
|
|
50
63
|
/** Evaluate Y at fraction. */
|
|
51
64
|
fractionToY(fraction) {
|
|
52
65
|
const x = fraction * this._axisLength;
|
|
@@ -67,7 +80,9 @@ class CubicEvaluator extends XYCurveEvaluator_1.XYCurveEvaluator {
|
|
|
67
80
|
return 6.0 * this._cubicM * this._axisLength * this._axisLength * this._axisLength;
|
|
68
81
|
}
|
|
69
82
|
/** Evaluate fraction at x. */
|
|
70
|
-
xToFraction(x) {
|
|
83
|
+
xToFraction(x) {
|
|
84
|
+
return x / this._axisLength;
|
|
85
|
+
}
|
|
71
86
|
}
|
|
72
87
|
exports.CubicEvaluator = CubicEvaluator;
|
|
73
88
|
//# sourceMappingURL=CubicEvaluator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CubicEvaluator.js","sourceRoot":"","sources":["../../../../src/curve/spiral/CubicEvaluator.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,yDAAsD;
|
|
1
|
+
{"version":3,"file":"CubicEvaluator.js","sourceRoot":"","sources":["../../../../src/curve/spiral/CubicEvaluator.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,yDAAsD;AAEtD;;;;;;GAMG;AACH,MAAsB,cAAe,SAAQ,mCAAgB;IACjD,OAAO,CAAS;IAChB,WAAW,CAAS;IAC9B,YAAsB,UAAkB,EAAE,MAAc;QACtD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;IACD,6BAA6B;IACtB,YAAY,CAAC,UAAkB,EAAE,MAAc;QACpD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IACD,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IACD,IAAW,MAAM;QACf,OAAO,IAA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,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IACrF,CAAC;IACD,8BAA8B;IACvB,WAAW,CAAC,CAAS;QAC1B,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC;IAC9B,CAAC;CACF;AAnED,wCAmEC","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 { XYCurveEvaluator } from \"./XYCurveEvaluator\";\n\n/**\n * Intermediate class for evaluation of bare cubic spirals `y = m*x^3` with x axis from [0..xLength]\n * * This implements all the computations among fraction, x, and y.\n * * Derived classes implement specialized logic such as (a) precomputing `m` and (b) domain-specific fraction-to-distance\n * approximations.\n * @internal\n */\nexport abstract class CubicEvaluator extends XYCurveEvaluator {\n protected _cubicM: number;\n protected _axisLength: number;\n protected constructor(axisLength: number, cubicM: number) {\n super();\n this._cubicM = cubicM;\n this._axisLength = axisLength;\n }\n /** Update both constants. */\n public setConstants(axisLength: number, cubicM: number) {\n this._axisLength = axisLength;\n this._cubicM = cubicM;\n }\n public get axisLength() {\n return this._axisLength;\n }\n public get cubicM() {\n return this._cubicM;\n }\n /**\n * Apply `scaleFactor` to the xLength and cubicM.\n * * Derived classes commonly call this as `super.scaleInPlace()`, and additionally apply the scale to their members.\n */\n public scaleInPlace(scaleFactor: number) {\n this._axisLength *= scaleFactor;\n // \"x\" arriving at \"m * x^3\" will be scaled. \"m\" has to be divided by the scale to cancel 2 of the 3\n this._cubicM /= (scaleFactor * scaleFactor);\n }\n /** Evaluate X at fraction. */\n public fractionToX(fraction: number): number {\n return fraction * this._axisLength;\n }\n /** Evaluate derivative of X with respect to fraction. */\n public fractionToDX(_fraction: number): number {\n return this._axisLength;\n }\n /** Evaluate second derivative of X with respect to fraction. */\n public fractionToDDX(_fraction: number): number {\n return 0.0;\n }\n /** Evaluate third derivative of X with respect to fraction. */\n public fractionToD3X(_fraction: number): number {\n return 0.0;\n }\n /** Evaluate Y at fraction. */\n public fractionToY(fraction: number): number {\n const x = fraction * this._axisLength;\n return this._cubicM * x * x * x;\n }\n /** Evaluate derivative of Y with respect to fraction. */\n public fractionToDY(fraction: number): number {\n const x = fraction * this._axisLength;\n return 3.0 * this._cubicM * x * x * this._axisLength;\n }\n /** Evaluate second derivative of Y with respect to fraction. */\n public fractionToDDY(fraction: number): number {\n const x = fraction * this._axisLength;\n return 6.0 * this._cubicM * x * this._axisLength * this._axisLength;\n }\n /** Evaluate third derivative of Y with respect to fraction. */\n public fractionToD3Y(_fraction: number): number {\n return 6.0 * this._cubicM * this._axisLength * this._axisLength * this._axisLength;\n }\n /** Evaluate fraction at x. */\n public xToFraction(x: number): number {\n return x / this._axisLength;\n }\n}\n"]}
|