@glandais/vcyclist-engine 4.0.0 → 4.2.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.
@@ -30,88 +30,115 @@
30
30
  var imul = Math.imul;
31
31
  var hypot = Math.hypot;
32
32
  var sign = Math.sign;
33
- var protoOf = kotlin_kotlin.$_$.c7;
34
- var initMetadataForCompanion = kotlin_kotlin.$_$.o6;
33
+ var protoOf = kotlin_kotlin.$_$.j7;
34
+ var initMetadataForCompanion = kotlin_kotlin.$_$.v6;
35
35
  var VOID = kotlin_kotlin.$_$.a;
36
- var getNumberHashCode = kotlin_kotlin.$_$.j6;
37
- var equals = kotlin_kotlin.$_$.g6;
38
- var initMetadataForClass = kotlin_kotlin.$_$.n6;
39
- var toString = kotlin_kotlin.$_$.f7;
40
- var hashCode = kotlin_kotlin.$_$.m6;
41
- var getBooleanHashCode = kotlin_kotlin.$_$.i6;
36
+ var getNumberHashCode = kotlin_kotlin.$_$.q6;
37
+ var equals = kotlin_kotlin.$_$.n6;
38
+ var initMetadataForClass = kotlin_kotlin.$_$.u6;
39
+ var toString = kotlin_kotlin.$_$.m7;
40
+ var hashCode = kotlin_kotlin.$_$.t6;
41
+ var initMetadataForObject = kotlin_kotlin.$_$.a7;
42
+ var getBooleanHashCode = kotlin_kotlin.$_$.p6;
42
43
  var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.a2;
43
44
  var Unit_instance = kotlin_kotlin.$_$.g1;
44
- var CoroutineImpl = kotlin_kotlin.$_$.x4;
45
+ var CoroutineImpl = kotlin_kotlin.$_$.d5;
45
46
  var PointPerDistance_instance = kotlin_io_github_glandais_gpx.$_$.k;
46
47
  var ElevationStep_instance = kotlin_io_github_glandais_gpx.$_$.h;
47
- var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.i4;
48
+ var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.o4;
48
49
  var PointPerSecond_instance = kotlin_io_github_glandais_gpx.$_$.l;
49
50
  var PathSimplifier_instance = kotlin_io_github_glandais_gpx.$_$.i;
50
- var initMetadataForCoroutine = kotlin_kotlin.$_$.p6;
51
- var initMetadataForObject = kotlin_kotlin.$_$.t6;
51
+ var initMetadataForCoroutine = kotlin_kotlin.$_$.w6;
52
+ var enumEntries = kotlin_kotlin.$_$.f5;
53
+ var Enum = kotlin_kotlin.$_$.t9;
52
54
  var ArrayList_init_$Create$ = kotlin_kotlin.$_$.j1;
53
55
  var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.i1;
54
- var last = kotlin_kotlin.$_$.o3;
55
- var toIntArray = kotlin_kotlin.$_$.a4;
56
- var sortedWith = kotlin_kotlin.$_$.y3;
57
- var toMutableList = kotlin_kotlin.$_$.e4;
58
- var first = kotlin_kotlin.$_$.i3;
59
- var removeAll = kotlin_kotlin.$_$.t3;
60
- var numberRangeToNumber = kotlin_kotlin.$_$.y6;
56
+ var last = kotlin_kotlin.$_$.q3;
57
+ var toIntArray = kotlin_kotlin.$_$.f4;
58
+ var sortedWith = kotlin_kotlin.$_$.b4;
59
+ var toMutableList = kotlin_kotlin.$_$.j4;
60
+ var first = kotlin_kotlin.$_$.j3;
61
+ var removeAll = kotlin_kotlin.$_$.w3;
62
+ var numberRangeToNumber = kotlin_kotlin.$_$.f7;
61
63
  var collectionSizeOrDefault = kotlin_kotlin.$_$.x2;
62
64
  var Vector3D = kotlin_io_github_glandais_elevation.$_$.g;
63
- var emptyList = kotlin_kotlin.$_$.f3;
64
- var coerceIn = kotlin_kotlin.$_$.m7;
65
+ var emptyList = kotlin_kotlin.$_$.g3;
66
+ var coerceIn = kotlin_kotlin.$_$.u7;
65
67
  var DouglasPeucker_instance = kotlin_io_github_glandais_elevation.$_$.b;
66
- var FunctionAdapter = kotlin_kotlin.$_$.u5;
67
- var isInterface = kotlin_kotlin.$_$.v6;
68
- var Comparator = kotlin_kotlin.$_$.i9;
69
- var compareValues = kotlin_kotlin.$_$.g4;
70
- var until = kotlin_kotlin.$_$.q7;
71
- var Pair = kotlin_kotlin.$_$.p9;
72
- var listOf = kotlin_kotlin.$_$.p3;
68
+ var FunctionAdapter = kotlin_kotlin.$_$.b6;
69
+ var isInterface = kotlin_kotlin.$_$.c7;
70
+ var Comparator = kotlin_kotlin.$_$.s9;
71
+ var compareValues = kotlin_kotlin.$_$.m4;
72
+ var until = kotlin_kotlin.$_$.z7;
73
+ var Pair = kotlin_kotlin.$_$.z9;
74
+ var listOf = kotlin_kotlin.$_$.r3;
73
75
  var Default_getInstance = kotlin_kotlin.$_$.b1;
74
- var isFinite = kotlin_kotlin.$_$.ca;
76
+ var Companion_instance = kotlin_kotlin.$_$.e1;
77
+ var equals_0 = kotlin_kotlin.$_$.p8;
78
+ var noWhenBranchMatchedException = kotlin_kotlin.$_$.qa;
79
+ var isNaN_0 = kotlin_kotlin.$_$.oa;
80
+ var isFinite = kotlin_kotlin.$_$.ma;
75
81
  var PointField_TEMPERATURE_getInstance = kotlin_io_github_glandais_gpx.$_$.c;
76
- var isNaN_0 = kotlin_kotlin.$_$.ea;
77
82
  var get_entries = kotlin_io_github_glandais_gpx.$_$.u;
78
83
  var Path = kotlin_io_github_glandais_gpx.$_$.t;
84
+ var arrayCopy = kotlin_kotlin.$_$.t2;
85
+ var sort = kotlin_kotlin.$_$.d4;
86
+ var numberToInt = kotlin_kotlin.$_$.h7;
87
+ var coerceIn_0 = kotlin_kotlin.$_$.v7;
88
+ var lastOrNull = kotlin_kotlin.$_$.p3;
89
+ var HashMap_init_$Create$ = kotlin_kotlin.$_$.l1;
90
+ var fromInt = kotlin_kotlin.$_$.s5;
91
+ var add = kotlin_kotlin.$_$.i5;
92
+ var numberToLong = kotlin_kotlin.$_$.v5;
93
+ var shiftLeft = kotlin_kotlin.$_$.w5;
94
+ var Long = kotlin_kotlin.$_$.x9;
95
+ var bitwiseAnd = kotlin_kotlin.$_$.j5;
96
+ var bitwiseXor = kotlin_kotlin.$_$.l5;
97
+ var copyOf = kotlin_kotlin.$_$.c3;
98
+ var coerceAtLeast = kotlin_kotlin.$_$.r7;
99
+ var round = kotlin_kotlin.$_$.p7;
100
+ var listOf_0 = kotlin_kotlin.$_$.s3;
101
+ var Collection = kotlin_kotlin.$_$.n2;
102
+ var zipWithNext = kotlin_kotlin.$_$.l4;
103
+ var toDoubleArray = kotlin_kotlin.$_$.e4;
104
+ var joinToString = kotlin_kotlin.$_$.m3;
79
105
  var GpxParser_instance = kotlin_io_github_glandais_gpx.$_$.d;
80
- var copyToArray = kotlin_kotlin.$_$.e3;
106
+ var copyToArray = kotlin_kotlin.$_$.f3;
81
107
  var firstTrackAsPath = kotlin_io_github_glandais_gpx.$_$.n;
82
108
  var tracksAsPaths = kotlin_io_github_glandais_gpx.$_$.q;
83
109
  var segmentsAsPaths = kotlin_io_github_glandais_gpx.$_$.o;
84
110
  var GpxPathKind_TRACK_getInstance = kotlin_io_github_glandais_gpx.$_$.b;
85
- var setOf = kotlin_kotlin.$_$.w3;
111
+ var setOf = kotlin_kotlin.$_$.z3;
86
112
  var GpxPathKind_ROUTE_getInstance = kotlin_io_github_glandais_gpx.$_$.a;
87
113
  var GpxWriter_instance = kotlin_io_github_glandais_gpx.$_$.e;
88
- var toList = kotlin_kotlin.$_$.d4;
114
+ var toList = kotlin_kotlin.$_$.i4;
89
115
  var toGpxDocument = kotlin_io_github_glandais_gpx.$_$.p;
90
116
  var Companion_getInstance = kotlin_kotlin.$_$.d1;
91
- var numberToLong = kotlin_kotlin.$_$.o5;
92
117
  var GlobalScope_instance = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.a;
93
118
  var promise = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.j;
94
119
  var Companion_getInstance_0 = kotlin_io_github_glandais_gpx.$_$.j;
95
120
  var IllegalStateException_init_$Create$ = kotlin_kotlin.$_$.c2;
96
121
  var CsvWriter_instance = kotlin_io_github_glandais_gpx.$_$.f;
97
- var firstOrNull = kotlin_kotlin.$_$.g8;
122
+ var firstOrNull = kotlin_kotlin.$_$.q8;
98
123
  var _Char___init__impl__6a9atx = kotlin_kotlin.$_$.b;
99
- var Char = kotlin_kotlin.$_$.h9;
124
+ var Char = kotlin_kotlin.$_$.r9;
100
125
  var CsvOptions = kotlin_io_github_glandais_gpx.$_$.r;
101
126
  var JsonWriter_instance = kotlin_io_github_glandais_gpx.$_$.g;
102
127
  var JsonOptions = kotlin_io_github_glandais_gpx.$_$.s;
103
128
  var toFitBytes = kotlin_io_github_glandais_fit.$_$.a;
104
129
  var Companion_getInstance_1 = kotlin_kotlin.$_$.c1;
105
130
  var DurationUnit_MILLISECONDS_getInstance = kotlin_kotlin.$_$.w;
106
- var toDuration = kotlin_kotlin.$_$.g9;
131
+ var toDuration = kotlin_kotlin.$_$.q9;
107
132
  var toFitBytes_0 = kotlin_io_github_glandais_fit.$_$.b;
108
- var toNumber = kotlin_kotlin.$_$.t5;
133
+ var toNumber = kotlin_kotlin.$_$.a6;
109
134
  var GpxWaypoint = kotlin_io_github_glandais_gpx.$_$.m;
110
- var THROW_CCE = kotlin_kotlin.$_$.s9;
135
+ var sorted = kotlin_kotlin.$_$.c4;
136
+ var THROW_CCE = kotlin_kotlin.$_$.ca;
111
137
  var CoroutineScope = kotlin_org_jetbrains_kotlinx_kotlinx_coroutines_core.$_$.h;
112
138
  var ElevationProvider = kotlin_io_github_glandais_elevation.$_$.d;
113
- var initMetadataForLambda = kotlin_kotlin.$_$.s6;
114
- var constructCallableReference = kotlin_kotlin.$_$.d6;
139
+ var initMetadataForLambda = kotlin_kotlin.$_$.z6;
140
+ var constructCallableReference = kotlin_kotlin.$_$.k6;
141
+ var setOf_0 = kotlin_kotlin.$_$.a4;
115
142
  //endregion
116
143
  //region block: pre-declaration
117
144
  initMetadataForCompanion(Companion);
@@ -121,12 +148,14 @@
121
148
  initMetadataForClass(CoursePhysics, 'CoursePhysics');
122
149
  initMetadataForCompanion(Companion_1);
123
150
  initMetadataForClass(Cyclist, 'Cyclist', Cyclist);
151
+ initMetadataForObject(EngineConstants, 'EngineConstants');
124
152
  initMetadataForClass(SimplifyPathOptions, 'SimplifyPathOptions', SimplifyPathOptions);
125
153
  initMetadataForClass(WPrimeBalanceOptions, 'WPrimeBalanceOptions', WPrimeBalanceOptions);
126
154
  initMetadataForCompanion(Companion_2);
127
155
  initMetadataForClass(EnhanceOptions, 'EnhanceOptions', EnhanceOptions);
128
156
  initMetadataForCoroutine($enhanceCourseCOROUTINE$, CoroutineImpl);
129
157
  initMetadataForObject(Enhancer, 'Enhancer', VOID, VOID, VOID, [3]);
158
+ initMetadataForClass(RoadCondition, 'RoadCondition', VOID, Enum);
130
159
  initMetadataForClass(Climb, 'Climb');
131
160
  initMetadataForClass(ClimbPart, 'ClimbPart');
132
161
  initMetadataForCompanion(Companion_3);
@@ -141,37 +170,68 @@
141
170
  initMetadataForObject(AeroProviderConstant, 'AeroProviderConstant');
142
171
  initMetadataForCompanion(Companion_5);
143
172
  initMetadataForClass(CyclistPowerProviderBase, 'CyclistPowerProviderBase');
173
+ initMetadataForCompanion(Companion_6);
174
+ initMetadataForClass(PowerModel, 'PowerModel', VOID, Enum);
175
+ initMetadataForClass(CyclistPowerSpec, 'CyclistPowerSpec', CyclistPowerSpec);
144
176
  initMetadataForObject(GravPowerProvider, 'GravPowerProvider');
145
177
  initMetadataForClass(Harmonic, 'Harmonic');
146
178
  initMetadataForObject(MaxSpeedComputer, 'MaxSpeedComputer');
147
179
  initMetadataForObject(MuscularPowerProvider, 'MuscularPowerProvider');
148
180
  initMetadataForObject(PowerComputer, 'PowerComputer');
149
181
  initMetadataForClass(PowerProviderConstant, 'PowerProviderConstant', VOID, CyclistPowerProviderBase);
150
- initMetadataForCompanion(Companion_6);
182
+ initMetadataForCompanion(Companion_7);
183
+ initMetadataForClass(PowerProviderCriticalPower, 'PowerProviderCriticalPower', VOID, CyclistPowerProviderBase);
184
+ initMetadataForCompanion(Companion_8);
151
185
  initMetadataForClass(PowerProviderDurability, 'PowerProviderDurability', VOID, CyclistPowerProviderBase);
152
186
  initMetadataForObject(PowerProviderFromData, 'PowerProviderFromData');
187
+ initMetadataForClass(PowerProviderSlewLimited, 'PowerProviderSlewLimited');
188
+ initMetadataForCompanion(Companion_9);
189
+ initMetadataForClass(PowerProviderTerrainPacing, 'PowerProviderTerrainPacing');
153
190
  initMetadataForObject(RhoProviderDefault, 'RhoProviderDefault');
154
191
  initMetadataForObject(RhoProviderEstimate, 'RhoProviderEstimate');
155
192
  initMetadataForObject(RollingResistancePowerProvider, 'RollingResistancePowerProvider');
156
193
  initMetadataForObject(VirtualizeService, 'VirtualizeService');
157
194
  initMetadataForObject(WheelBearingsPowerProvider, 'WheelBearingsPowerProvider');
158
- initMetadataForCompanion(Companion_7);
195
+ initMetadataForCompanion(Companion_10);
159
196
  initMetadataForClass(Wind, 'Wind');
160
197
  initMetadataForObject(WindProviderNone, 'WindProviderNone');
161
198
  initMetadataForClass(WindProviderConstant, 'WindProviderConstant');
162
199
  initMetadataForObject(WPrimeBalanceComputer, 'WPrimeBalanceComputer');
200
+ initMetadataForObject(BandedLdl, 'BandedLdl');
201
+ initMetadataForClass(CornerSpan, 'CornerSpan');
202
+ initMetadataForObject(CornerDetector, 'CornerDetector');
203
+ initMetadataForClass(CorridorBounds, 'CorridorBounds');
204
+ initMetadataForObject(Corridor, 'Corridor');
205
+ initMetadataForClass(Fit, 'Fit');
206
+ initMetadataForObject(CurvatureEstimator, 'CurvatureEstimator');
207
+ initMetadataForObject(LocalFrame, 'LocalFrame');
208
+ initMetadataForCompanion(Companion_11);
209
+ initMetadataForClass(OffsetEnergy, 'OffsetEnergy');
210
+ initMetadataForClass(QpResult, 'QpResult');
211
+ initMetadataForObject(OffsetQp, 'OffsetQp');
212
+ initMetadataForCompanion(Companion_12);
213
+ initMetadataForClass(CurvatureOptions, 'CurvatureOptions', CurvatureOptions);
214
+ initMetadataForObject(PathCurvature, 'PathCurvature');
215
+ initMetadataForClass(PlanarFrame, 'PlanarFrame');
216
+ initMetadataForClass(RacingLineReport, 'RacingLineReport');
217
+ initMetadataForObject(RacingLine, 'RacingLine');
218
+ initMetadataForCompanion(Companion_13);
219
+ initMetadataForClass(CorridorMode, 'CorridorMode', VOID, Enum);
220
+ initMetadataForClass(CornerKind, 'CornerKind', VOID, Enum);
221
+ initMetadataForCompanion(Companion_14);
222
+ initMetadataForClass(RacingLineOptions, 'RacingLineOptions', RacingLineOptions);
163
223
  initMetadataForLambda(enhance$slambda, CoroutineImpl, VOID, [1]);
164
224
  initMetadataForLambda(enhanceWithCourse$slambda, CoroutineImpl, VOID, [1]);
165
225
  //endregion
166
226
  function Companion() {
167
- Companion_instance = this;
227
+ Companion_instance_0 = this;
168
228
  this.DEFAULT_1 = new Bike();
169
229
  }
170
- var Companion_instance;
230
+ var Companion_instance_0;
171
231
  function Companion_getInstance_2() {
172
- if (Companion_instance == null)
232
+ if (Companion_instance_0 == null)
173
233
  new Companion();
174
- return Companion_instance;
234
+ return Companion_instance_0;
175
235
  }
176
236
  function Bike(crr, inertiaFront, inertiaRear, wheelRadiusM, efficiency, maxPedalingLeanAngleDeg) {
177
237
  Companion_getInstance_2();
@@ -269,14 +329,14 @@
269
329
  return true;
270
330
  };
271
331
  function Companion_0() {
272
- Companion_instance_0 = this;
332
+ Companion_instance_1 = this;
273
333
  this.DEFAULT_CYCLIST_POWER_PROVIDER_1 = new PowerProviderConstant(280.0);
274
334
  }
275
- var Companion_instance_0;
335
+ var Companion_instance_1;
276
336
  function Companion_getInstance_3() {
277
- if (Companion_instance_0 == null)
337
+ if (Companion_instance_1 == null)
278
338
  new Companion_0();
279
- return Companion_instance_0;
339
+ return Companion_instance_1;
280
340
  }
281
341
  function CoursePhysics(course, rhoProvider, aeroProvider, windProvider, cyclistPowerProvider) {
282
342
  Companion_getInstance_3();
@@ -339,14 +399,14 @@
339
399
  return true;
340
400
  };
341
401
  function Companion_1() {
342
- Companion_instance_1 = this;
402
+ Companion_instance_2 = this;
343
403
  this.DEFAULT_1 = new Cyclist();
344
404
  }
345
- var Companion_instance_1;
405
+ var Companion_instance_2;
346
406
  function Companion_getInstance_4() {
347
- if (Companion_instance_1 == null)
407
+ if (Companion_instance_2 == null)
348
408
  new Companion_1();
349
- return Companion_instance_1;
409
+ return Companion_instance_2;
350
410
  }
351
411
  function Cyclist(massKg, maxBrakeG, cd, frontalAreaM2, maxLeanAngleDeg, maxSpeedKmH) {
352
412
  Companion_getInstance_4();
@@ -405,6 +465,43 @@
405
465
  return false;
406
466
  return true;
407
467
  };
468
+ function EngineConstants() {
469
+ EngineConstants_instance = this;
470
+ this.G_1 = 9.80665;
471
+ this.MINIMAL_SPEED_1 = 0.5555555555555556;
472
+ this.DEFAULT_CRR_1 = 0.004;
473
+ this.DEFAULT_INERTIA_FRONT_1 = 0.05;
474
+ this.DEFAULT_INERTIA_REAR_1 = 0.07;
475
+ this.DEFAULT_WHEEL_RADIUS_M_1 = 0.35;
476
+ this.DEFAULT_DRIVETRAIN_EFFICIENCY_1 = 0.976;
477
+ this.DEFAULT_MAX_PEDALING_LEAN_ANGLE_DEG_1 = 20.0;
478
+ this.DEFAULT_CYCLIST_MASS_KG_1 = 80.0;
479
+ this.DEFAULT_CYCLIST_POWER_W_1 = 280.0;
480
+ this.DEFAULT_MAX_POWER_SLEW_W_PER_S_1 = 50.0;
481
+ this.DEFAULT_MAX_BRAKE_G_1 = 0.4;
482
+ this.DEFAULT_MAX_LEAN_ANGLE_DEG_1 = 35.0;
483
+ this.DRY_ROAD_MU_1 = 0.9;
484
+ this.WET_ROAD_MU_1 = 0.36;
485
+ this.PITCH_OVER_BRAKE_G_1 = 0.63;
486
+ var tmp = this;
487
+ // Inline function 'kotlin.math.tan' call
488
+ var x = 0.6108652381980153;
489
+ tmp.RIDER_GRIP_FRACTION_1 = Math.tan(x) / 0.9;
490
+ this.RIDER_BRAKE_FRACTION_1 = 0.634920634920635;
491
+ this.DEFAULT_MAX_LEAN_ANGLE_RAD_1 = 0.6108652381980153;
492
+ this.DEFAULT_MAX_SPEED_KMH_1 = 100.0;
493
+ this.DEFAULT_CRITICAL_POWER_W_1 = 250.0;
494
+ this.DEFAULT_W_PRIME_J_1 = 20000.0;
495
+ this.DEFAULT_DRAG_COEFFICIENT_1 = 0.7;
496
+ this.DEFAULT_FRONTAL_AREA_M2__1 = 0.5;
497
+ this.DEFAULT_AIR_DENSITY_1 = 1.225;
498
+ }
499
+ var EngineConstants_instance;
500
+ function EngineConstants_getInstance() {
501
+ if (EngineConstants_instance == null)
502
+ new EngineConstants();
503
+ return EngineConstants_instance;
504
+ }
408
505
  function SimplifyPathOptions(enabled, toleranceM, zExaggeration) {
409
506
  enabled = enabled === VOID ? true : enabled;
410
507
  toleranceM = toleranceM === VOID ? 10.0 : toleranceM;
@@ -476,16 +573,16 @@
476
573
  return true;
477
574
  };
478
575
  function Companion_2() {
479
- Companion_instance_2 = this;
576
+ Companion_instance_3 = this;
480
577
  this.DEFAULT_1 = new EnhanceOptions();
481
578
  }
482
- var Companion_instance_2;
579
+ var Companion_instance_3;
483
580
  function Companion_getInstance_5() {
484
- if (Companion_instance_2 == null)
581
+ if (Companion_instance_3 == null)
485
582
  new Companion_2();
486
- return Companion_instance_2;
583
+ return Companion_instance_3;
487
584
  }
488
- function EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance) {
585
+ function EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance, curvature, racingLine) {
489
586
  Companion_getInstance_5();
490
587
  fixElevation = fixElevation === VOID ? true : fixElevation;
491
588
  computeMaxSpeeds = computeMaxSpeeds === VOID ? true : computeMaxSpeeds;
@@ -493,27 +590,33 @@
493
590
  computeOnePointPerSecond = computeOnePointPerSecond === VOID ? true : computeOnePointPerSecond;
494
591
  simplifyPath = simplifyPath === VOID ? new SimplifyPathOptions() : simplifyPath;
495
592
  wPrimeBalance = wPrimeBalance === VOID ? new WPrimeBalanceOptions() : wPrimeBalance;
593
+ curvature = curvature === VOID ? new CurvatureOptions() : curvature;
594
+ racingLine = racingLine === VOID ? new RacingLineOptions() : racingLine;
496
595
  this.fixElevation_1 = fixElevation;
497
596
  this.computeMaxSpeeds_1 = computeMaxSpeeds;
498
597
  this.virtualizeTrack_1 = virtualizeTrack;
499
598
  this.computeOnePointPerSecond_1 = computeOnePointPerSecond;
500
599
  this.simplifyPath_1 = simplifyPath;
501
600
  this.wPrimeBalance_1 = wPrimeBalance;
601
+ this.curvature_1 = curvature;
602
+ this.racingLine_1 = racingLine;
502
603
  }
503
- protoOf(EnhanceOptions).copy_bazpxz_k$ = function (fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance) {
504
- return new EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance);
604
+ protoOf(EnhanceOptions).copy_i8t81g_k$ = function (fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance, curvature, racingLine) {
605
+ return new EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance, curvature, racingLine);
505
606
  };
506
- protoOf(EnhanceOptions).copy$default_2rfmrp_k$ = function (fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance, $super) {
607
+ protoOf(EnhanceOptions).copy$default_q3w1nk_k$ = function (fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance, curvature, racingLine, $super) {
507
608
  fixElevation = fixElevation === VOID ? this.fixElevation_1 : fixElevation;
508
609
  computeMaxSpeeds = computeMaxSpeeds === VOID ? this.computeMaxSpeeds_1 : computeMaxSpeeds;
509
610
  virtualizeTrack = virtualizeTrack === VOID ? this.virtualizeTrack_1 : virtualizeTrack;
510
611
  computeOnePointPerSecond = computeOnePointPerSecond === VOID ? this.computeOnePointPerSecond_1 : computeOnePointPerSecond;
511
612
  simplifyPath = simplifyPath === VOID ? this.simplifyPath_1 : simplifyPath;
512
613
  wPrimeBalance = wPrimeBalance === VOID ? this.wPrimeBalance_1 : wPrimeBalance;
513
- return $super === VOID ? this.copy_bazpxz_k$(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance) : $super.copy_bazpxz_k$.call(this, fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance);
614
+ curvature = curvature === VOID ? this.curvature_1 : curvature;
615
+ racingLine = racingLine === VOID ? this.racingLine_1 : racingLine;
616
+ return $super === VOID ? this.copy_i8t81g_k$(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance, curvature, racingLine) : $super.copy_i8t81g_k$.call(this, fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance, curvature, racingLine);
514
617
  };
515
618
  protoOf(EnhanceOptions).toString = function () {
516
- return 'EnhanceOptions(fixElevation=' + this.fixElevation_1 + ', computeMaxSpeeds=' + this.computeMaxSpeeds_1 + ', virtualizeTrack=' + this.virtualizeTrack_1 + ', computeOnePointPerSecond=' + this.computeOnePointPerSecond_1 + ', simplifyPath=' + this.simplifyPath_1.toString() + ', wPrimeBalance=' + this.wPrimeBalance_1.toString() + ')';
619
+ return 'EnhanceOptions(fixElevation=' + this.fixElevation_1 + ', computeMaxSpeeds=' + this.computeMaxSpeeds_1 + ', virtualizeTrack=' + this.virtualizeTrack_1 + ', computeOnePointPerSecond=' + this.computeOnePointPerSecond_1 + ', simplifyPath=' + this.simplifyPath_1.toString() + ', wPrimeBalance=' + this.wPrimeBalance_1.toString() + ', curvature=' + this.curvature_1.toString() + ', racingLine=' + this.racingLine_1.toString() + ')';
517
620
  };
518
621
  protoOf(EnhanceOptions).hashCode = function () {
519
622
  var result = getBooleanHashCode(this.fixElevation_1);
@@ -522,6 +625,8 @@
522
625
  result = imul(result, 31) + getBooleanHashCode(this.computeOnePointPerSecond_1) | 0;
523
626
  result = imul(result, 31) + this.simplifyPath_1.hashCode() | 0;
524
627
  result = imul(result, 31) + this.wPrimeBalance_1.hashCode() | 0;
628
+ result = imul(result, 31) + this.curvature_1.hashCode() | 0;
629
+ result = imul(result, 31) + this.racingLine_1.hashCode() | 0;
525
630
  return result;
526
631
  };
527
632
  protoOf(EnhanceOptions).equals = function (other) {
@@ -541,6 +646,10 @@
541
646
  return false;
542
647
  if (!this.wPrimeBalance_1.equals(other.wPrimeBalance_1))
543
648
  return false;
649
+ if (!this.curvature_1.equals(other.curvature_1))
650
+ return false;
651
+ if (!this.racingLine_1.equals(other.racingLine_1))
652
+ return false;
544
653
  return true;
545
654
  };
546
655
  function $enhanceCourseCOROUTINE$(_this__u8e3s4, course, options, elevationProvider, resultContinuation) {
@@ -584,6 +693,13 @@
584
693
  case 2:
585
694
  this.path0__1 = PointPerDistance_instance.compute_7vlifv_k$(this.path0__1, 1.0, 2.0);
586
695
  this.path0__1 = ElevationStep_instance.smoothElevation$default_3c035p_k$(this.path0__1);
696
+ var racingLineApplied = this.options_1.racingLine_1.enabled_1;
697
+ if (racingLineApplied) {
698
+ this.path0__1 = RacingLine_instance.compute_uyx32p_k$(this.path0__1, this.options_1.racingLine_1);
699
+ } else if (this.options_1.curvature_1.enabled_1) {
700
+ PathCurvature_instance.compute_s9yd16_k$(this.path0__1, this.options_1.curvature_1);
701
+ }
702
+
587
703
  var working = this.course_1.copy$default_a3dskc_k$(this.course_1.course_1.copy$default_mmxsnj_k$(this.path0__1));
588
704
  if (this.options_1.computeMaxSpeeds_1 || this.options_1.virtualizeTrack_1) {
589
705
  MaxSpeedComputer_instance.computeMaxSpeeds_jc4v4o_k$(working.course_1);
@@ -603,7 +719,16 @@
603
719
  }
604
720
 
605
721
  if (this.options_1.simplifyPath_1.enabled_1) {
606
- this.path0__1 = PathSimplifier_instance.simplify_gxhj7b_k$(this.path0__1, this.options_1.simplifyPath_1.toleranceM_1, this.options_1.simplifyPath_1.zExaggeration_1);
722
+ var tmp_0;
723
+ if (racingLineApplied) {
724
+ var tmp0 = this.options_1.simplifyPath_1.toleranceM_1;
725
+ var b = this.options_1.racingLine_1.simplifyToleranceCapM_1;
726
+ tmp_0 = Math.min(tmp0, b);
727
+ } else {
728
+ tmp_0 = this.options_1.simplifyPath_1.toleranceM_1;
729
+ }
730
+ var tolerance = tmp_0;
731
+ this.path0__1 = PathSimplifier_instance.simplify_gxhj7b_k$(this.path0__1, tolerance, this.options_1.simplifyPath_1.zExaggeration_1);
607
732
  }
608
733
 
609
734
  return this.path0__1;
@@ -627,7 +752,7 @@
627
752
  return new CoursePhysics(new Course(path), RhoProviderEstimate_instance, AeroProviderConstant_instance, WindProviderNone_instance, new PowerProviderConstant(280.0));
628
753
  };
629
754
  protoOf(Enhancer).enhanceCourseDefault_jm937y_k$ = function (path, elevationProvider, options, $completion) {
630
- return this.enhanceCourse_mout3j_k$(this.getDefaultCourse_gqi1xw_k$(path), options.copy$default_2rfmrp_k$(options.fixElevation_1 && !(elevationProvider == null)), elevationProvider, $completion);
755
+ return this.enhanceCourse_mout3j_k$(this.getDefaultCourse_gqi1xw_k$(path), options.copy$default_q3w1nk_k$(options.fixElevation_1 && !(elevationProvider == null)), elevationProvider, $completion);
631
756
  };
632
757
  protoOf(Enhancer).enhanceCourse_mout3j_k$ = function (course, options, elevationProvider, $completion) {
633
758
  var tmp = new $enhanceCourseCOROUTINE$(this, course, options, elevationProvider, $completion);
@@ -639,6 +764,48 @@
639
764
  function Enhancer_getInstance() {
640
765
  return Enhancer_instance;
641
766
  }
767
+ var static_init_called;
768
+ function static_init() {
769
+ if (static_init_called)
770
+ return Unit_instance;
771
+ static_init_called = true;
772
+ // Inline function 'kotlin.math.tan' call
773
+ var x = 0.6108652381980153;
774
+ var tmp$ret$0 = Math.tan(x);
775
+ RoadCondition_DRY_instance = new RoadCondition('DRY', 0, tmp$ret$0, 0.4);
776
+ RoadCondition_WET_instance = new RoadCondition('WET', 1, EngineConstants_getInstance().RIDER_GRIP_FRACTION_1 * 0.36, 0.634920634920635 * 0.36);
777
+ }
778
+ var RoadCondition_DRY_instance;
779
+ var RoadCondition_WET_instance;
780
+ function values() {
781
+ static_init();
782
+ return [RoadCondition_DRY_getInstance(), RoadCondition_WET_getInstance()];
783
+ }
784
+ function get_entries_0() {
785
+ static_init();
786
+ if ($ENTRIES == null)
787
+ $ENTRIES = enumEntries(values());
788
+ return $ENTRIES;
789
+ }
790
+ var $ENTRIES;
791
+ function RoadCondition(name, ordinal, mu, maxBrakeG) {
792
+ Enum.call(this, name, ordinal);
793
+ this.mu_1 = mu;
794
+ this.maxBrakeG_1 = maxBrakeG;
795
+ }
796
+ protoOf(RoadCondition).get_leanAngleDeg_9xbhfm_k$ = function () {
797
+ // Inline function 'kotlin.math.atan' call
798
+ var x = this.mu_1;
799
+ return Math.atan(x) * 180.0 / 3.141592653589793;
800
+ };
801
+ function RoadCondition_DRY_getInstance() {
802
+ static_init();
803
+ return RoadCondition_DRY_instance;
804
+ }
805
+ function RoadCondition_WET_getInstance() {
806
+ static_init();
807
+ return RoadCondition_WET_instance;
808
+ }
642
809
  function Climb(startIndex, endIndex, startDistanceM, endDistanceM, startElevationM, endElevationM, positiveElevationM, negativeElevationM, parts) {
643
810
  this.startIndex_1 = startIndex;
644
811
  this.endIndex_1 = endIndex;
@@ -763,14 +930,14 @@
763
930
  return true;
764
931
  };
765
932
  function Companion_3() {
766
- Companion_instance_3 = this;
933
+ Companion_instance_4 = this;
767
934
  this.DEFAULT_1 = new ClimbOptions();
768
935
  }
769
- var Companion_instance_3;
936
+ var Companion_instance_4;
770
937
  function Companion_getInstance_6() {
771
- if (Companion_instance_3 == null)
938
+ if (Companion_instance_4 == null)
772
939
  new Companion_3();
773
- return Companion_instance_3;
940
+ return Companion_instance_4;
774
941
  }
775
942
  function ClimbOptions(minMinClimbElevationM, maxMinClimbElevationM, minClimbElevationRatio, minGradePercent, maxDiffRealGradeRatio, booster, maxAnalysisPoints) {
776
943
  Companion_getInstance_6();
@@ -874,9 +1041,9 @@
874
1041
  }
875
1042
  return new Profile(tmp_6, tmp_10, indices);
876
1043
  };
877
- var Companion_instance_4;
1044
+ var Companion_instance_5;
878
1045
  function Companion_getInstance_7() {
879
- return Companion_instance_4;
1046
+ return Companion_instance_5;
880
1047
  }
881
1048
  function Profile(distance, elevation, sourceIndex) {
882
1049
  this.distance_1 = distance;
@@ -1129,7 +1296,7 @@
1129
1296
  // Inline function 'kotlin.comparisons.maxOf' call
1130
1297
  var b_0 = Math.min(tmp0_0, b);
1131
1298
  var minClimbElevation = Math.max(tmp0, b_0);
1132
- var profile = Companion_instance_4.of_tmvbpf_k$(path, options.maxAnalysisPoints_1);
1299
+ var profile = Companion_instance_5.of_tmvbpf_k$(path, options.maxAnalysisPoints_1);
1133
1300
  // Inline function 'kotlin.collections.mapNotNull' call
1134
1301
  var tmp0_1 = until(0, profile.get_size_woubt6_k$());
1135
1302
  // Inline function 'kotlin.collections.mapNotNullTo' call
@@ -1327,9 +1494,9 @@
1327
1494
  this.TOLERANCE_1 = 0.05;
1328
1495
  this.MAX_MULTIPLIER_1 = 3.0;
1329
1496
  }
1330
- var Companion_instance_5;
1497
+ var Companion_instance_6;
1331
1498
  function Companion_getInstance_8() {
1332
- return Companion_instance_5;
1499
+ return Companion_instance_6;
1333
1500
  }
1334
1501
  function CyclistPowerProviderBase(useHarmonics, random) {
1335
1502
  random = random === VOID ? Default_getInstance() : random;
@@ -1376,6 +1543,173 @@
1376
1543
  path.setPCyclistPowerNeeded_54po1x_k$(pointIndex, powerNeeded);
1377
1544
  return power;
1378
1545
  };
1546
+ var static_init_called_0;
1547
+ function static_init_0() {
1548
+ if (static_init_called_0)
1549
+ return Unit_instance;
1550
+ static_init_called_0 = true;
1551
+ PowerModel_CONSTANT_instance = new PowerModel('CONSTANT', 0, 'constant');
1552
+ PowerModel_DURABILITY_instance = new PowerModel('DURABILITY', 1, 'durability');
1553
+ PowerModel_CRITICAL_POWER_instance = new PowerModel('CRITICAL_POWER', 2, 'critical-power');
1554
+ PowerModel_FROM_DATA_instance = new PowerModel('FROM_DATA', 3, 'from_data');
1555
+ if (Companion_instance_7 == null) {
1556
+ Companion_instance;
1557
+ new Companion_6();
1558
+ }
1559
+ }
1560
+ var PowerModel_CONSTANT_instance;
1561
+ var PowerModel_DURABILITY_instance;
1562
+ var PowerModel_CRITICAL_POWER_instance;
1563
+ var PowerModel_FROM_DATA_instance;
1564
+ function Companion_6() {
1565
+ }
1566
+ protoOf(Companion_6).get_ids_18j3qp_k$ = function () {
1567
+ // Inline function 'kotlin.collections.map' call
1568
+ var this_0 = get_entries_1();
1569
+ // Inline function 'kotlin.collections.mapTo' call
1570
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
1571
+ var _iterator__ex2g4s = this_0.iterator_jk1svi_k$();
1572
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
1573
+ var item = _iterator__ex2g4s.next_20eer_k$();
1574
+ var tmp$ret$2 = item.id_1;
1575
+ destination.add_utx5q5_k$(tmp$ret$2);
1576
+ }
1577
+ return destination;
1578
+ };
1579
+ protoOf(Companion_6).fromIdOrNull_83jhaj_k$ = function (id) {
1580
+ var tmp0 = get_entries_1();
1581
+ var tmp$ret$0;
1582
+ $l$block: {
1583
+ // Inline function 'kotlin.collections.firstOrNull' call
1584
+ var _iterator__ex2g4s = tmp0.iterator_jk1svi_k$();
1585
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
1586
+ var element = _iterator__ex2g4s.next_20eer_k$();
1587
+ if (equals_0(element.id_1, id, true)) {
1588
+ tmp$ret$0 = element;
1589
+ break $l$block;
1590
+ }
1591
+ }
1592
+ tmp$ret$0 = null;
1593
+ }
1594
+ return tmp$ret$0;
1595
+ };
1596
+ var Companion_instance_7;
1597
+ function Companion_getInstance_9() {
1598
+ return Companion_instance_7;
1599
+ }
1600
+ function values_0() {
1601
+ static_init_0();
1602
+ return [PowerModel_CONSTANT_getInstance(), PowerModel_DURABILITY_getInstance(), PowerModel_CRITICAL_POWER_getInstance(), PowerModel_FROM_DATA_getInstance()];
1603
+ }
1604
+ function get_entries_1() {
1605
+ static_init_0();
1606
+ if ($ENTRIES_0 == null)
1607
+ $ENTRIES_0 = enumEntries(values_0());
1608
+ return $ENTRIES_0;
1609
+ }
1610
+ var $ENTRIES_0;
1611
+ function PowerModel(name, ordinal, id) {
1612
+ Enum.call(this, name, ordinal);
1613
+ this.id_1 = id;
1614
+ }
1615
+ protoOf(PowerModel).toString = function () {
1616
+ return this.id_1;
1617
+ };
1618
+ function baseProvider($this) {
1619
+ var tmp;
1620
+ switch ($this.model_1.ordinal_1) {
1621
+ case 0:
1622
+ tmp = new PowerProviderConstant($this.powerW_1, $this.useHarmonics_1);
1623
+ break;
1624
+ case 1:
1625
+ tmp = new PowerProviderDurability($this.powerW_1, $this.criticalPowerW_1, VOID, VOID, $this.useHarmonics_1);
1626
+ break;
1627
+ case 2:
1628
+ tmp = new PowerProviderCriticalPower($this.powerW_1, $this.criticalPowerW_1, $this.wPrimeJ_1, VOID, $this.useHarmonics_1);
1629
+ break;
1630
+ case 3:
1631
+ tmp = PowerProviderFromData_instance;
1632
+ break;
1633
+ default:
1634
+ noWhenBranchMatchedException();
1635
+ break;
1636
+ }
1637
+ return tmp;
1638
+ }
1639
+ function CyclistPowerSpec(model, powerW, criticalPowerW, wPrimeJ, useHarmonics, pacing, maxSlewWPerS) {
1640
+ model = model === VOID ? PowerModel_CONSTANT_getInstance() : model;
1641
+ powerW = powerW === VOID ? 280.0 : powerW;
1642
+ criticalPowerW = criticalPowerW === VOID ? 250.0 : criticalPowerW;
1643
+ wPrimeJ = wPrimeJ === VOID ? 20000.0 : wPrimeJ;
1644
+ useHarmonics = useHarmonics === VOID ? false : useHarmonics;
1645
+ pacing = pacing === VOID ? false : pacing;
1646
+ maxSlewWPerS = maxSlewWPerS === VOID ? 0.0 : maxSlewWPerS;
1647
+ this.model_1 = model;
1648
+ this.powerW_1 = powerW;
1649
+ this.criticalPowerW_1 = criticalPowerW;
1650
+ this.wPrimeJ_1 = wPrimeJ;
1651
+ this.useHarmonics_1 = useHarmonics;
1652
+ this.pacing_1 = pacing;
1653
+ this.maxSlewWPerS_1 = maxSlewWPerS;
1654
+ }
1655
+ protoOf(CyclistPowerSpec).toProvider_gnvkvo_k$ = function () {
1656
+ var provider = baseProvider(this);
1657
+ if (this.pacing_1)
1658
+ provider = new PowerProviderTerrainPacing(provider);
1659
+ if (this.maxSlewWPerS_1 > 0.0)
1660
+ provider = new PowerProviderSlewLimited(provider, this.maxSlewWPerS_1);
1661
+ return provider;
1662
+ };
1663
+ protoOf(CyclistPowerSpec).toString = function () {
1664
+ return 'CyclistPowerSpec(model=' + this.model_1.toString() + ', powerW=' + this.powerW_1 + ', criticalPowerW=' + this.criticalPowerW_1 + ', wPrimeJ=' + this.wPrimeJ_1 + ', useHarmonics=' + this.useHarmonics_1 + ', pacing=' + this.pacing_1 + ', maxSlewWPerS=' + this.maxSlewWPerS_1 + ')';
1665
+ };
1666
+ protoOf(CyclistPowerSpec).hashCode = function () {
1667
+ var result = this.model_1.hashCode();
1668
+ result = imul(result, 31) + getNumberHashCode(this.powerW_1) | 0;
1669
+ result = imul(result, 31) + getNumberHashCode(this.criticalPowerW_1) | 0;
1670
+ result = imul(result, 31) + getNumberHashCode(this.wPrimeJ_1) | 0;
1671
+ result = imul(result, 31) + getBooleanHashCode(this.useHarmonics_1) | 0;
1672
+ result = imul(result, 31) + getBooleanHashCode(this.pacing_1) | 0;
1673
+ result = imul(result, 31) + getNumberHashCode(this.maxSlewWPerS_1) | 0;
1674
+ return result;
1675
+ };
1676
+ protoOf(CyclistPowerSpec).equals = function (other) {
1677
+ if (this === other)
1678
+ return true;
1679
+ if (!(other instanceof CyclistPowerSpec))
1680
+ return false;
1681
+ if (!this.model_1.equals(other.model_1))
1682
+ return false;
1683
+ if (!equals(this.powerW_1, other.powerW_1))
1684
+ return false;
1685
+ if (!equals(this.criticalPowerW_1, other.criticalPowerW_1))
1686
+ return false;
1687
+ if (!equals(this.wPrimeJ_1, other.wPrimeJ_1))
1688
+ return false;
1689
+ if (!(this.useHarmonics_1 === other.useHarmonics_1))
1690
+ return false;
1691
+ if (!(this.pacing_1 === other.pacing_1))
1692
+ return false;
1693
+ if (!equals(this.maxSlewWPerS_1, other.maxSlewWPerS_1))
1694
+ return false;
1695
+ return true;
1696
+ };
1697
+ function PowerModel_CONSTANT_getInstance() {
1698
+ static_init_0();
1699
+ return PowerModel_CONSTANT_instance;
1700
+ }
1701
+ function PowerModel_DURABILITY_getInstance() {
1702
+ static_init_0();
1703
+ return PowerModel_DURABILITY_instance;
1704
+ }
1705
+ function PowerModel_CRITICAL_POWER_getInstance() {
1706
+ static_init_0();
1707
+ return PowerModel_CRITICAL_POWER_instance;
1708
+ }
1709
+ function PowerModel_FROM_DATA_getInstance() {
1710
+ static_init_0();
1711
+ return PowerModel_FROM_DATA_instance;
1712
+ }
1379
1713
  function GravPowerProvider() {
1380
1714
  }
1381
1715
  protoOf(GravPowerProvider).powerAt_ejucaq_k$ = function (course, path, pointIndex) {
@@ -1440,13 +1774,27 @@
1440
1774
  return result;
1441
1775
  }
1442
1776
  function computeRadiusWindowed($this, path, i, k) {
1777
+ var kappa = path.trajectoryCurvature_t4abpc_k$(i);
1778
+ if (!isNaN_0(kappa)) {
1779
+ // Inline function 'kotlin.math.abs' call
1780
+ var tmp0 = Math.abs(kappa);
1781
+ // Inline function 'kotlin.math.max' call
1782
+ var b = 1.0 / 200.0;
1783
+ // Inline function 'kotlin.math.min' call
1784
+ var b_0 = 1.0 / Math.max(tmp0, b);
1785
+ // Inline function 'kotlin.math.max' call
1786
+ var b_1 = Math.min(200.0, b_0);
1787
+ var clamped = Math.max(5.0, b_1);
1788
+ path.setRadius_p1cueq_k$(i, clamped);
1789
+ return clamped;
1790
+ }
1443
1791
  // Inline function 'kotlin.math.max' call
1444
- var b = i - k | 0;
1445
- var mini = Math.max(0, b);
1446
- var tmp0 = path.size_1 - 1 | 0;
1792
+ var b_2 = i - k | 0;
1793
+ var mini = Math.max(0, b_2);
1794
+ var tmp0_0 = path.size_1 - 1 | 0;
1447
1795
  // Inline function 'kotlin.math.min' call
1448
- var b_0 = i + k | 0;
1449
- var maxi = Math.min(tmp0, b_0);
1796
+ var b_3 = i + k | 0;
1797
+ var maxi = Math.min(tmp0_0, b_3);
1450
1798
  var totalBearingChange = $this.normalizeAngleDiff_6gshzi_k$(path.bearing_fz5vxm_k$(maxi) - path.bearing_fz5vxm_k$(mini));
1451
1799
  var totalDistance = path.distance_5s4s77_k$(maxi) - path.distance_5s4s77_k$(mini);
1452
1800
  // Inline function 'kotlin.math.abs' call
@@ -1458,10 +1806,10 @@
1458
1806
  var raw = totalDistance / Math.abs(totalBearingChange);
1459
1807
  // Inline function 'kotlin.math.min' call
1460
1808
  // Inline function 'kotlin.math.max' call
1461
- var b_1 = Math.min(200.0, raw);
1462
- var clamped = Math.max(5.0, b_1);
1463
- path.setRadius_p1cueq_k$(i, clamped);
1464
- return clamped;
1809
+ var b_4 = Math.min(200.0, raw);
1810
+ var clamped_0 = Math.max(5.0, b_4);
1811
+ path.setRadius_p1cueq_k$(i, clamped_0);
1812
+ return clamped_0;
1465
1813
  }
1466
1814
  function computeBrakingLimit($this, course, currentIndex, nextIndex, corneringLimit) {
1467
1815
  var path = course.path_1;
@@ -1666,13 +2014,96 @@
1666
2014
  protoOf(PowerProviderConstant).optimalPower_36kg19_k$ = function (course, path, pointIndex) {
1667
2015
  return this.power_1;
1668
2016
  };
1669
- function Companion_6() {
2017
+ function Companion_7() {
2018
+ this.DEFAULT_TAPER_START_FRACTION_1 = 0.5;
2019
+ }
2020
+ var Companion_instance_8;
2021
+ function Companion_getInstance_10() {
2022
+ return Companion_instance_8;
2023
+ }
2024
+ function PowerProviderCriticalPower(powerW, criticalPowerW, wPrimeJ, taperStartFraction, useHarmonics, random) {
2025
+ criticalPowerW = criticalPowerW === VOID ? 250.0 : criticalPowerW;
2026
+ wPrimeJ = wPrimeJ === VOID ? 20000.0 : wPrimeJ;
2027
+ taperStartFraction = taperStartFraction === VOID ? 0.5 : taperStartFraction;
2028
+ useHarmonics = useHarmonics === VOID ? false : useHarmonics;
2029
+ random = random === VOID ? Default_getInstance() : random;
2030
+ CyclistPowerProviderBase.call(this, useHarmonics, random);
2031
+ this.powerW_1 = powerW;
2032
+ this.criticalPowerW_1 = criticalPowerW;
2033
+ this.wPrimeJ_1 = wPrimeJ;
2034
+ this.taperStartFraction_1 = taperStartFraction;
2035
+ // Inline function 'kotlin.require' call
2036
+ if (!(this.powerW_1 > 0.0)) {
2037
+ var message = 'powerW must be > 0, got ' + this.powerW_1;
2038
+ throw IllegalArgumentException_init_$Create$(toString(message));
2039
+ }
2040
+ // Inline function 'kotlin.require' call
2041
+ if (!(this.criticalPowerW_1 > 0.0)) {
2042
+ var message_0 = 'criticalPowerW must be > 0, got ' + this.criticalPowerW_1;
2043
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
2044
+ }
2045
+ // Inline function 'kotlin.require' call
2046
+ if (!(this.wPrimeJ_1 > 0.0)) {
2047
+ var message_1 = 'wPrimeJ must be > 0, got ' + this.wPrimeJ_1;
2048
+ throw IllegalArgumentException_init_$Create$(toString(message_1));
2049
+ }
2050
+ var containsArg = this.taperStartFraction_1;
2051
+ // Inline function 'kotlin.require' call
2052
+ if (!(0.0 <= containsArg ? containsArg <= 1.0 : false)) {
2053
+ var message_2 = 'taperStartFraction must be in [0, 1], got ' + this.taperStartFraction_1;
2054
+ throw IllegalArgumentException_init_$Create$(toString(message_2));
2055
+ }
2056
+ this.lastIndex_1 = -1;
2057
+ this.lastElapsedS_1 = 0.0;
2058
+ this.lastPowerW_1 = 0.0;
2059
+ this.wPrimeBalanceJ_1 = this.wPrimeJ_1;
2060
+ }
2061
+ protoOf(PowerProviderCriticalPower).get_reserveFraction_7eakgb_k$ = function () {
2062
+ return this.wPrimeBalanceJ_1 / this.wPrimeJ_1;
2063
+ };
2064
+ protoOf(PowerProviderCriticalPower).optimalPower_36kg19_k$ = function (course, path, pointIndex) {
2065
+ if (pointIndex < this.lastIndex_1) {
2066
+ this.reset_5u6xz3_k$();
2067
+ }
2068
+ if (pointIndex > this.lastIndex_1) {
2069
+ var elapsedS = path.elapsed_7307rw_k$(pointIndex) / 1000.0;
2070
+ var dtS = elapsedS - this.lastElapsedS_1;
2071
+ if (dtS > 0.0 && isFinite(dtS)) {
2072
+ this.wPrimeBalanceJ_1 = WPrimeBalanceComputer_instance.step_447nu7_k$(this.wPrimeBalanceJ_1, this.lastPowerW_1, this.criticalPowerW_1, this.wPrimeJ_1, dtS);
2073
+ }
2074
+ if (isFinite(elapsedS))
2075
+ this.lastElapsedS_1 = elapsedS;
2076
+ this.lastIndex_1 = pointIndex;
2077
+ }
2078
+ var rationed = this.ration_enbpy2_k$(this.powerW_1);
2079
+ this.lastPowerW_1 = rationed;
2080
+ return rationed;
2081
+ };
2082
+ protoOf(PowerProviderCriticalPower).ration_enbpy2_k$ = function (target) {
2083
+ if (target <= this.criticalPowerW_1)
2084
+ return target;
2085
+ var tmp;
2086
+ if (this.taperStartFraction_1 <= 0.0) {
2087
+ tmp = 1.0;
2088
+ } else {
2089
+ tmp = coerceIn(this.get_reserveFraction_7eakgb_k$() / this.taperStartFraction_1, 0.0, 1.0);
2090
+ }
2091
+ var shape = tmp;
2092
+ return this.criticalPowerW_1 + (target - this.criticalPowerW_1) * shape;
2093
+ };
2094
+ protoOf(PowerProviderCriticalPower).reset_5u6xz3_k$ = function () {
2095
+ this.lastIndex_1 = -1;
2096
+ this.lastElapsedS_1 = 0.0;
2097
+ this.lastPowerW_1 = 0.0;
2098
+ this.wPrimeBalanceJ_1 = this.wPrimeJ_1;
2099
+ };
2100
+ function Companion_8() {
1670
2101
  this.DEFAULT_DECLINE_PER_KJ_PER_KG_1 = 0.006666666666666667;
1671
2102
  this.DEFAULT_MAX_DECLINE_1 = 0.2;
1672
2103
  }
1673
- var Companion_instance_6;
1674
- function Companion_getInstance_9() {
1675
- return Companion_instance_6;
2104
+ var Companion_instance_9;
2105
+ function Companion_getInstance_11() {
2106
+ return Companion_instance_9;
1676
2107
  }
1677
2108
  function PowerProviderDurability(powerW, criticalPowerW, declinePerKjPerKg, maxDecline, useHarmonics, random) {
1678
2109
  criticalPowerW = criticalPowerW === VOID ? 250.0 : criticalPowerW;
@@ -1756,6 +2187,184 @@
1756
2187
  function PowerProviderFromData_getInstance() {
1757
2188
  return PowerProviderFromData_instance;
1758
2189
  }
2190
+ function PowerProviderSlewLimited(delegate, maxSlewWPerS) {
2191
+ maxSlewWPerS = maxSlewWPerS === VOID ? 50.0 : maxSlewWPerS;
2192
+ this.delegate_1 = delegate;
2193
+ this.maxSlewWPerS_1 = maxSlewWPerS;
2194
+ // Inline function 'kotlin.require' call
2195
+ if (!(this.maxSlewWPerS_1 > 0.0)) {
2196
+ var message = 'maxSlewWPerS must be > 0, got ' + this.maxSlewWPerS_1;
2197
+ throw IllegalArgumentException_init_$Create$(toString(message));
2198
+ }
2199
+ this.lastIndex_1 = -1;
2200
+ this.lastElapsedS_1 = 0.0;
2201
+ this.lastPowerW_1 = 0.0;
2202
+ }
2203
+ protoOf(PowerProviderSlewLimited).powerAt_ejucaq_k$ = function (course, path, pointIndex) {
2204
+ var target = this.delegate_1.powerAt_ejucaq_k$(course, path, pointIndex);
2205
+ if (pointIndex < this.lastIndex_1) {
2206
+ this.reset_5u6xz3_k$();
2207
+ }
2208
+ if (pointIndex === this.lastIndex_1)
2209
+ return this.lastPowerW_1;
2210
+ var elapsedS = path.elapsed_7307rw_k$(pointIndex) / 1000.0;
2211
+ var dtS = elapsedS - this.lastElapsedS_1;
2212
+ var tmp;
2213
+ if (dtS > 0.0 && isFinite(dtS)) {
2214
+ var budget = this.maxSlewWPerS_1 * dtS;
2215
+ var delta = target - this.lastPowerW_1;
2216
+ var tmp_0;
2217
+ // Inline function 'kotlin.math.abs' call
2218
+ if (Math.abs(delta) <= budget) {
2219
+ tmp_0 = target;
2220
+ } else {
2221
+ tmp_0 = this.lastPowerW_1 + (delta > 0 ? budget : -budget);
2222
+ }
2223
+ tmp = tmp_0;
2224
+ } else {
2225
+ tmp = this.lastPowerW_1;
2226
+ }
2227
+ var limited = tmp;
2228
+ if (isFinite(elapsedS))
2229
+ this.lastElapsedS_1 = elapsedS;
2230
+ this.lastIndex_1 = pointIndex;
2231
+ this.lastPowerW_1 = limited;
2232
+ return limited;
2233
+ };
2234
+ protoOf(PowerProviderSlewLimited).reset_5u6xz3_k$ = function () {
2235
+ this.lastIndex_1 = -1;
2236
+ this.lastElapsedS_1 = 0.0;
2237
+ this.lastPowerW_1 = 0.0;
2238
+ };
2239
+ function Companion_9() {
2240
+ this.DEFAULT_GRADIENT_GAIN_1 = 3.0;
2241
+ this.DEFAULT_HEADWIND_GAIN_PER_MS_1 = 0.02;
2242
+ this.DEFAULT_MIN_MULTIPLIER_1 = 0.5;
2243
+ this.DEFAULT_MAX_MULTIPLIER_1 = 1.3;
2244
+ this.DEFAULT_RAMP_DISTANCE_M_1 = 300.0;
2245
+ this.DEFAULT_ENERGY_BUDGET_SECONDS_1 = 600.0;
2246
+ }
2247
+ var Companion_instance_10;
2248
+ function Companion_getInstance_12() {
2249
+ return Companion_instance_10;
2250
+ }
2251
+ function PowerProviderTerrainPacing(delegate, gradientGain, headwindGainPerMS, minMultiplier, maxMultiplier, rampDistanceM, energyBudgetSeconds) {
2252
+ gradientGain = gradientGain === VOID ? 3.0 : gradientGain;
2253
+ headwindGainPerMS = headwindGainPerMS === VOID ? 0.02 : headwindGainPerMS;
2254
+ minMultiplier = minMultiplier === VOID ? 0.5 : minMultiplier;
2255
+ maxMultiplier = maxMultiplier === VOID ? 1.3 : maxMultiplier;
2256
+ rampDistanceM = rampDistanceM === VOID ? 300.0 : rampDistanceM;
2257
+ energyBudgetSeconds = energyBudgetSeconds === VOID ? 600.0 : energyBudgetSeconds;
2258
+ this.delegate_1 = delegate;
2259
+ this.gradientGain_1 = gradientGain;
2260
+ this.headwindGainPerMS_1 = headwindGainPerMS;
2261
+ this.minMultiplier_1 = minMultiplier;
2262
+ this.maxMultiplier_1 = maxMultiplier;
2263
+ this.rampDistanceM_1 = rampDistanceM;
2264
+ this.energyBudgetSeconds_1 = energyBudgetSeconds;
2265
+ // Inline function 'kotlin.require' call
2266
+ if (!(this.gradientGain_1 >= 0.0)) {
2267
+ var message = 'gradientGain must be >= 0, got ' + this.gradientGain_1;
2268
+ throw IllegalArgumentException_init_$Create$(toString(message));
2269
+ }
2270
+ // Inline function 'kotlin.require' call
2271
+ if (!(this.headwindGainPerMS_1 >= 0.0)) {
2272
+ var message_0 = 'headwindGainPerMS must be >= 0, got ' + this.headwindGainPerMS_1;
2273
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
2274
+ }
2275
+ // Inline function 'kotlin.require' call
2276
+ if (!(this.minMultiplier_1 > 0.0)) {
2277
+ var message_1 = 'minMultiplier must be > 0, got ' + this.minMultiplier_1;
2278
+ throw IllegalArgumentException_init_$Create$(toString(message_1));
2279
+ }
2280
+ // Inline function 'kotlin.require' call
2281
+ if (!(this.maxMultiplier_1 >= this.minMultiplier_1)) {
2282
+ var message_2 = 'maxMultiplier (' + this.maxMultiplier_1 + ') must be >= minMultiplier (' + this.minMultiplier_1 + ')';
2283
+ throw IllegalArgumentException_init_$Create$(toString(message_2));
2284
+ }
2285
+ // Inline function 'kotlin.require' call
2286
+ if (!(this.rampDistanceM_1 > 0.0)) {
2287
+ var message_3 = 'rampDistanceM must be > 0, got ' + this.rampDistanceM_1;
2288
+ throw IllegalArgumentException_init_$Create$(toString(message_3));
2289
+ }
2290
+ // Inline function 'kotlin.require' call
2291
+ if (!(this.energyBudgetSeconds_1 > 0.0)) {
2292
+ var message_4 = 'energyBudgetSeconds must be > 0, got ' + this.energyBudgetSeconds_1;
2293
+ throw IllegalArgumentException_init_$Create$(toString(message_4));
2294
+ }
2295
+ this.lastIndex_1 = -1;
2296
+ this.lastDistanceM_1 = 0.0;
2297
+ this.lastElapsedS_1 = 0.0;
2298
+ this.lastDeliveredW_1 = 0.0;
2299
+ this.lastTargetW_1 = 0.0;
2300
+ this.multiplier_1 = 1.0;
2301
+ this.energyDebtJ_1 = 0.0;
2302
+ }
2303
+ protoOf(PowerProviderTerrainPacing).powerAt_ejucaq_k$ = function (course, path, pointIndex) {
2304
+ var target = this.delegate_1.powerAt_ejucaq_k$(course, path, pointIndex);
2305
+ if (pointIndex < this.lastIndex_1) {
2306
+ this.reset_5u6xz3_k$();
2307
+ }
2308
+ if (pointIndex > this.lastIndex_1) {
2309
+ var distanceM = path.distance_5s4s77_k$(pointIndex);
2310
+ var dx = distanceM - this.lastDistanceM_1;
2311
+ this.multiplier_1 = this.smooth_uy9sy9_k$(this.multiplier_1, this.rawMultiplier_2rfnpc_k$(path, pointIndex), dx);
2312
+ if (isFinite(distanceM))
2313
+ this.lastDistanceM_1 = distanceM;
2314
+ var elapsedS = path.elapsed_7307rw_k$(pointIndex) / 1000.0;
2315
+ var dtS = elapsedS - this.lastElapsedS_1;
2316
+ if (dtS > 0.0 && isFinite(dtS)) {
2317
+ this.energyDebtJ_1 = this.energyDebtJ_1 + (this.lastDeliveredW_1 - this.lastTargetW_1) * dtS;
2318
+ }
2319
+ if (isFinite(elapsedS))
2320
+ this.lastElapsedS_1 = elapsedS;
2321
+ this.lastIndex_1 = pointIndex;
2322
+ }
2323
+ var delivered = target * this.multiplier_1 * this.energyCorrection_sm6t7b_k$(target);
2324
+ this.lastTargetW_1 = target;
2325
+ this.lastDeliveredW_1 = delivered;
2326
+ return delivered;
2327
+ };
2328
+ protoOf(PowerProviderTerrainPacing).energyCorrection_sm6t7b_k$ = function (target) {
2329
+ if (target <= 0.0)
2330
+ return 1.0;
2331
+ var budgetJ = target * this.energyBudgetSeconds_1;
2332
+ return coerceIn(1.0 - this.energyDebtJ_1 / budgetJ, this.minMultiplier_1, this.maxMultiplier_1);
2333
+ };
2334
+ protoOf(PowerProviderTerrainPacing).rawMultiplier_2rfnpc_k$ = function (path, pointIndex) {
2335
+ // Inline function 'kotlin.let' call
2336
+ var it = path.grade_c4yjz5_k$(pointIndex);
2337
+ var grade = isFinite(it) ? it : 0.0;
2338
+ // Inline function 'kotlin.let' call
2339
+ var it_0 = path.windSpeed_6m3dy1_k$(pointIndex);
2340
+ var windSpeed = isFinite(it_0) ? it_0 : 0.0;
2341
+ // Inline function 'kotlin.let' call
2342
+ var it_1 = path.windAlpha_7rjela_k$(pointIndex);
2343
+ var alpha = isFinite(it_1) ? it_1 : 0.0;
2344
+ // Inline function 'kotlin.math.cos' call
2345
+ var headwind = windSpeed * Math.cos(alpha);
2346
+ var raw = 1.0 + this.gradientGain_1 * grade + this.headwindGainPerMS_1 * headwind;
2347
+ return coerceIn(raw, this.minMultiplier_1, this.maxMultiplier_1);
2348
+ };
2349
+ protoOf(PowerProviderTerrainPacing).smooth_uy9sy9_k$ = function (current, raw, dx) {
2350
+ if (raw <= current)
2351
+ return raw;
2352
+ if (!isFinite(dx) || dx <= 0.0)
2353
+ return current;
2354
+ // Inline function 'kotlin.math.exp' call
2355
+ var x = -dx / this.rampDistanceM_1;
2356
+ var blend = 1.0 - Math.exp(x);
2357
+ return current + (raw - current) * blend;
2358
+ };
2359
+ protoOf(PowerProviderTerrainPacing).reset_5u6xz3_k$ = function () {
2360
+ this.lastIndex_1 = -1;
2361
+ this.lastDistanceM_1 = 0.0;
2362
+ this.lastElapsedS_1 = 0.0;
2363
+ this.lastDeliveredW_1 = 0.0;
2364
+ this.lastTargetW_1 = 0.0;
2365
+ this.multiplier_1 = 1.0;
2366
+ this.energyDebtJ_1 = 0.0;
2367
+ };
1759
2368
  function RhoProviderDefault() {
1760
2369
  }
1761
2370
  protoOf(RhoProviderDefault).rho_pwqvzi_k$ = function (course, path, pointIndex) {
@@ -1904,18 +2513,18 @@
1904
2513
  function WheelBearingsPowerProvider_getInstance() {
1905
2514
  return WheelBearingsPowerProvider_instance;
1906
2515
  }
1907
- function Companion_7() {
1908
- Companion_instance_7 = this;
2516
+ function Companion_10() {
2517
+ Companion_instance_11 = this;
1909
2518
  this.NONE_1 = new Wind(0.0, 0.0);
1910
2519
  }
1911
- var Companion_instance_7;
1912
- function Companion_getInstance_10() {
1913
- if (Companion_instance_7 == null)
1914
- new Companion_7();
1915
- return Companion_instance_7;
2520
+ var Companion_instance_11;
2521
+ function Companion_getInstance_13() {
2522
+ if (Companion_instance_11 == null)
2523
+ new Companion_10();
2524
+ return Companion_instance_11;
1916
2525
  }
1917
2526
  function Wind(speedMS, directionRad) {
1918
- Companion_getInstance_10();
2527
+ Companion_getInstance_13();
1919
2528
  this.speedMS_1 = speedMS;
1920
2529
  this.directionRad_1 = directionRad;
1921
2530
  }
@@ -1934,70 +2543,2047 @@
1934
2543
  return false;
1935
2544
  if (!equals(this.speedMS_1, other.speedMS_1))
1936
2545
  return false;
1937
- if (!equals(this.directionRad_1, other.directionRad_1))
2546
+ if (!equals(this.directionRad_1, other.directionRad_1))
2547
+ return false;
2548
+ return true;
2549
+ };
2550
+ function WindProviderNone() {
2551
+ }
2552
+ protoOf(WindProviderNone).wind_umf2tf_k$ = function (course, path, pointIndex) {
2553
+ return Companion_getInstance_13().NONE_1;
2554
+ };
2555
+ var WindProviderNone_instance;
2556
+ function WindProviderNone_getInstance() {
2557
+ return WindProviderNone_instance;
2558
+ }
2559
+ function WindProviderConstant(wind) {
2560
+ this.wind_1 = wind;
2561
+ }
2562
+ protoOf(WindProviderConstant).wind_umf2tf_k$ = function (course, path, pointIndex) {
2563
+ return this.wind_1;
2564
+ };
2565
+ function WPrimeBalanceComputer() {
2566
+ }
2567
+ protoOf(WPrimeBalanceComputer).compute_ewvoaz_k$ = function (path, options) {
2568
+ if (path.size_1 === 0)
2569
+ return Unit_instance;
2570
+ var cp = options.criticalPowerW_1;
2571
+ var wPrime = options.wPrimeJ_1;
2572
+ var balance = wPrime;
2573
+ path.setWPrimeBalance_stwqkw_k$(0, balance);
2574
+ var inductionVariable = 1;
2575
+ var last = path.size_1;
2576
+ if (inductionVariable < last)
2577
+ do {
2578
+ var i = inductionVariable;
2579
+ inductionVariable = inductionVariable + 1 | 0;
2580
+ var dtSeconds = (path.time_ryc845_k$(i) - path.time_ryc845_k$(i - 1 | 0)) / 1000.0;
2581
+ var power = path.pComputedPower_g6dnn4_k$(i);
2582
+ if (isFinite(dtSeconds) && dtSeconds > 0.0 && isFinite(power)) {
2583
+ balance = this.step_447nu7_k$(balance, power, cp, wPrime, dtSeconds);
2584
+ }
2585
+ path.setWPrimeBalance_stwqkw_k$(i, balance);
2586
+ }
2587
+ while (inductionVariable < last);
2588
+ };
2589
+ protoOf(WPrimeBalanceComputer).step_447nu7_k$ = function (balance, power, cp, wPrime, dtSeconds) {
2590
+ var tmp;
2591
+ if (power >= cp) {
2592
+ tmp = balance - (power - cp) * dtSeconds;
2593
+ } else {
2594
+ var tmp_0 = wPrime - balance;
2595
+ // Inline function 'kotlin.math.exp' call
2596
+ var x = -(cp - power) * dtSeconds / wPrime;
2597
+ tmp = wPrime - tmp_0 * Math.exp(x);
2598
+ }
2599
+ var next = tmp;
2600
+ // Inline function 'kotlin.math.max' call
2601
+ // Inline function 'kotlin.math.min' call
2602
+ var b = Math.max(0.0, next);
2603
+ return Math.min(wPrime, b);
2604
+ };
2605
+ var WPrimeBalanceComputer_instance;
2606
+ function WPrimeBalanceComputer_getInstance() {
2607
+ return WPrimeBalanceComputer_instance;
2608
+ }
2609
+ function BandedLdl() {
2610
+ }
2611
+ protoOf(BandedLdl).factor_n459o6_k$ = function (a0, a1, a2) {
2612
+ var n = a0.length;
2613
+ if (n === 0)
2614
+ return true;
2615
+ var l1 = new Float64Array(n);
2616
+ var l2 = new Float64Array(n);
2617
+ var d = new Float64Array(n);
2618
+ var inductionVariable = 0;
2619
+ if (inductionVariable < n)
2620
+ do {
2621
+ var i = inductionVariable;
2622
+ inductionVariable = inductionVariable + 1 | 0;
2623
+ var dm1 = i >= 1 ? d[i - 1 | 0] : 0.0;
2624
+ var dm2 = i >= 2 ? d[i - 2 | 0] : 0.0;
2625
+ l2[i] = i >= 2 ? a2[i - 2 | 0] / dm2 : 0.0;
2626
+ var tmp;
2627
+ if (i >= 1) {
2628
+ var correction = i >= 2 ? l2[i] * l1[i - 1 | 0] * dm2 : 0.0;
2629
+ tmp = (a1[i - 1 | 0] - correction) / dm1;
2630
+ } else {
2631
+ tmp = 0.0;
2632
+ }
2633
+ l1[i] = tmp;
2634
+ var pivot = a0[i];
2635
+ if (i >= 1)
2636
+ pivot = pivot - l1[i] * l1[i] * dm1;
2637
+ if (i >= 2)
2638
+ pivot = pivot - l2[i] * l2[i] * dm2;
2639
+ if (!(pivot > 0.0) || !isFinite(pivot))
2640
+ return false;
2641
+ d[i] = pivot;
2642
+ }
2643
+ while (inductionVariable < n);
2644
+ // Inline function 'kotlin.collections.copyInto' call
2645
+ var endIndex = d.length;
2646
+ // Inline function 'kotlin.js.unsafeCast' call
2647
+ // Inline function 'kotlin.js.asDynamic' call
2648
+ var tmp_0 = d;
2649
+ // Inline function 'kotlin.js.unsafeCast' call
2650
+ // Inline function 'kotlin.js.asDynamic' call
2651
+ arrayCopy(tmp_0, a0, 0, 0, endIndex);
2652
+ var inductionVariable_0 = 0;
2653
+ if (inductionVariable_0 < n)
2654
+ do {
2655
+ var i_0 = inductionVariable_0;
2656
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
2657
+ if (i_0 >= 1) {
2658
+ a1[i_0 - 1 | 0] = l1[i_0];
2659
+ }
2660
+ if (i_0 >= 2) {
2661
+ a2[i_0 - 2 | 0] = l2[i_0];
2662
+ }
2663
+ }
2664
+ while (inductionVariable_0 < n);
2665
+ return true;
2666
+ };
2667
+ protoOf(BandedLdl).solveInPlace_jrw92v_k$ = function (d, l1, l2, b) {
2668
+ var n = d.length;
2669
+ if (n === 0)
2670
+ return Unit_instance;
2671
+ var inductionVariable = 0;
2672
+ if (inductionVariable < n)
2673
+ do {
2674
+ var i = inductionVariable;
2675
+ inductionVariable = inductionVariable + 1 | 0;
2676
+ var v = b[i];
2677
+ if (i >= 1)
2678
+ v = v - l1[i - 1 | 0] * b[i - 1 | 0];
2679
+ if (i >= 2)
2680
+ v = v - l2[i - 2 | 0] * b[i - 2 | 0];
2681
+ b[i] = v;
2682
+ }
2683
+ while (inductionVariable < n);
2684
+ var inductionVariable_0 = 0;
2685
+ if (inductionVariable_0 < n)
2686
+ do {
2687
+ var i_0 = inductionVariable_0;
2688
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
2689
+ b[i_0] = b[i_0] / d[i_0];
2690
+ }
2691
+ while (inductionVariable_0 < n);
2692
+ var inductionVariable_1 = n - 1 | 0;
2693
+ if (0 <= inductionVariable_1)
2694
+ do {
2695
+ var i_1 = inductionVariable_1;
2696
+ inductionVariable_1 = inductionVariable_1 + -1 | 0;
2697
+ var v_0 = b[i_1];
2698
+ if ((i_1 + 1 | 0) < n)
2699
+ v_0 = v_0 - l1[i_1] * b[i_1 + 1 | 0];
2700
+ if ((i_1 + 2 | 0) < n)
2701
+ v_0 = v_0 - l2[i_1] * b[i_1 + 2 | 0];
2702
+ b[i_1] = v_0;
2703
+ }
2704
+ while (0 <= inductionVariable_1);
2705
+ };
2706
+ protoOf(BandedLdl).multiply_dwj15t_k$ = function (a0, a1, a2, x, y) {
2707
+ var n = a0.length;
2708
+ var inductionVariable = 0;
2709
+ if (inductionVariable < n)
2710
+ do {
2711
+ var i = inductionVariable;
2712
+ inductionVariable = inductionVariable + 1 | 0;
2713
+ var v = a0[i] * x[i];
2714
+ if (i >= 1)
2715
+ v = v + a1[i - 1 | 0] * x[i - 1 | 0];
2716
+ if ((i + 1 | 0) < n)
2717
+ v = v + a1[i] * x[i + 1 | 0];
2718
+ if (i >= 2)
2719
+ v = v + a2[i - 2 | 0] * x[i - 2 | 0];
2720
+ if ((i + 2 | 0) < n)
2721
+ v = v + a2[i] * x[i + 2 | 0];
2722
+ y[i] = v;
2723
+ }
2724
+ while (inductionVariable < n);
2725
+ };
2726
+ var BandedLdl_instance;
2727
+ function BandedLdl_getInstance() {
2728
+ return BandedLdl_instance;
2729
+ }
2730
+ function CornerSpan(fromIndex, untilIndex, apexIndex, kind, turnRad, direction, radiusQ20M, radiusMinM, lengthM) {
2731
+ this.fromIndex_1 = fromIndex;
2732
+ this.untilIndex_1 = untilIndex;
2733
+ this.apexIndex_1 = apexIndex;
2734
+ this.kind_1 = kind;
2735
+ this.turnRad_1 = turnRad;
2736
+ this.direction_1 = direction;
2737
+ this.radiusQ20M_1 = radiusQ20M;
2738
+ this.radiusMinM_1 = radiusMinM;
2739
+ this.lengthM_1 = lengthM;
2740
+ }
2741
+ protoOf(CornerSpan).toString = function () {
2742
+ return 'CornerSpan(fromIndex=' + this.fromIndex_1 + ', untilIndex=' + this.untilIndex_1 + ', apexIndex=' + this.apexIndex_1 + ', kind=' + this.kind_1.toString() + ', turnRad=' + this.turnRad_1 + ', direction=' + this.direction_1 + ', radiusQ20M=' + this.radiusQ20M_1 + ', radiusMinM=' + this.radiusMinM_1 + ', lengthM=' + this.lengthM_1 + ')';
2743
+ };
2744
+ protoOf(CornerSpan).hashCode = function () {
2745
+ var result = this.fromIndex_1;
2746
+ result = imul(result, 31) + this.untilIndex_1 | 0;
2747
+ result = imul(result, 31) + this.apexIndex_1 | 0;
2748
+ result = imul(result, 31) + this.kind_1.hashCode() | 0;
2749
+ result = imul(result, 31) + getNumberHashCode(this.turnRad_1) | 0;
2750
+ result = imul(result, 31) + this.direction_1 | 0;
2751
+ result = imul(result, 31) + getNumberHashCode(this.radiusQ20M_1) | 0;
2752
+ result = imul(result, 31) + getNumberHashCode(this.radiusMinM_1) | 0;
2753
+ result = imul(result, 31) + getNumberHashCode(this.lengthM_1) | 0;
2754
+ return result;
2755
+ };
2756
+ protoOf(CornerSpan).equals = function (other) {
2757
+ if (this === other)
2758
+ return true;
2759
+ if (!(other instanceof CornerSpan))
2760
+ return false;
2761
+ if (!(this.fromIndex_1 === other.fromIndex_1))
2762
+ return false;
2763
+ if (!(this.untilIndex_1 === other.untilIndex_1))
2764
+ return false;
2765
+ if (!(this.apexIndex_1 === other.apexIndex_1))
2766
+ return false;
2767
+ if (!this.kind_1.equals(other.kind_1))
2768
+ return false;
2769
+ if (!equals(this.turnRad_1, other.turnRad_1))
2770
+ return false;
2771
+ if (!(this.direction_1 === other.direction_1))
2772
+ return false;
2773
+ if (!equals(this.radiusQ20M_1, other.radiusQ20M_1))
2774
+ return false;
2775
+ if (!equals(this.radiusMinM_1, other.radiusMinM_1))
2776
+ return false;
2777
+ if (!equals(this.lengthM_1, other.lengthM_1))
2778
+ return false;
2779
+ return true;
2780
+ };
2781
+ function radiusPercentile($this, kappa, from, until, fraction) {
2782
+ var count = until - from | 0;
2783
+ if (count <= 0)
2784
+ return Infinity;
2785
+ var tmp = 0;
2786
+ var tmp_0 = new Float64Array(count);
2787
+ while (tmp < count) {
2788
+ var tmp_1 = tmp;
2789
+ tmp_0[tmp_1] = CurvatureEstimator_instance.radiusAt_umgvjz_k$(kappa[from + tmp_1 | 0]);
2790
+ tmp = tmp + 1 | 0;
2791
+ }
2792
+ var radii = tmp_0;
2793
+ sort(radii);
2794
+ var idx = coerceIn_0(numberToInt((count - 1 | 0) * fraction), 0, count - 1 | 0);
2795
+ return radii[idx];
2796
+ }
2797
+ function CornerDetector() {
2798
+ }
2799
+ protoOf(CornerDetector).detect_cq5dkx_k$ = function (frame, options, widthM) {
2800
+ var n = frame.get_size_woubt6_k$();
2801
+ if (n < 3)
2802
+ return emptyList();
2803
+ var enter = 1.0 / options.cornerEnterRadiusM_1;
2804
+ var exit = 1.0 / options.cornerExitRadiusM_1;
2805
+ var kappa = frame.kappa_1;
2806
+ // Inline function 'kotlin.collections.mutableListOf' call
2807
+ var raw = ArrayList_init_$Create$();
2808
+ var start = -1;
2809
+ var sign = 0;
2810
+ var inductionVariable = 0;
2811
+ if (inductionVariable < n)
2812
+ do {
2813
+ var i = inductionVariable;
2814
+ inductionVariable = inductionVariable + 1 | 0;
2815
+ var k = kappa[i];
2816
+ // Inline function 'kotlin.math.abs' call
2817
+ var a = Math.abs(k);
2818
+ var tmp;
2819
+ if (k > 0) {
2820
+ tmp = 1;
2821
+ } else if (k < 0) {
2822
+ tmp = -1;
2823
+ } else {
2824
+ tmp = 0;
2825
+ }
2826
+ var s = tmp;
2827
+ if (start < 0) {
2828
+ if (a > enter && !(s === 0)) {
2829
+ start = i;
2830
+ sign = s;
2831
+ }
2832
+ } else {
2833
+ var sameSign = s === sign || s === 0;
2834
+ if (a < exit || !sameSign) {
2835
+ // Inline function 'kotlin.intArrayOf' call
2836
+ var tmp$ret$2 = new Int32Array([start, i, sign]);
2837
+ raw.add_utx5q5_k$(tmp$ret$2);
2838
+ start = a > enter && !(s === 0) && !sameSign ? i : -1;
2839
+ if (start >= 0)
2840
+ sign = s;
2841
+ }
2842
+ }
2843
+ }
2844
+ while (inductionVariable < n);
2845
+ if (start >= 0) {
2846
+ // Inline function 'kotlin.intArrayOf' call
2847
+ var tmp$ret$3 = new Int32Array([start, n, sign]);
2848
+ raw.add_utx5q5_k$(tmp$ret$3);
2849
+ }
2850
+ // Inline function 'kotlin.collections.mutableListOf' call
2851
+ var merged = ArrayList_init_$Create$();
2852
+ var _iterator__ex2g4s = raw.iterator_jk1svi_k$();
2853
+ $l$loop: while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
2854
+ var span = _iterator__ex2g4s.next_20eer_k$();
2855
+ var last = lastOrNull(merged);
2856
+ if (!(last == null) && last[2] === span[2]) {
2857
+ var tmp0 = span[0];
2858
+ // Inline function 'kotlin.comparisons.minOf' call
2859
+ var b = n - 1 | 0;
2860
+ var tmp$ret$5 = Math.min(tmp0, b);
2861
+ var tmp_0 = frame.s_1[tmp$ret$5];
2862
+ var tmp0_0 = last[1];
2863
+ // Inline function 'kotlin.comparisons.minOf' call
2864
+ var b_0 = n - 1 | 0;
2865
+ var tmp$ret$6 = Math.min(tmp0_0, b_0);
2866
+ var gap = tmp_0 - frame.s_1[tmp$ret$6];
2867
+ var tmp0_1 = span[0];
2868
+ // Inline function 'kotlin.comparisons.minOf' call
2869
+ var b_1 = widthM.length - 1 | 0;
2870
+ var w = widthM[Math.min(tmp0_1, b_1)];
2871
+ // Inline function 'kotlin.math.max' call
2872
+ var b_2 = 3.0 * w;
2873
+ if (gap < Math.max(15.0, b_2)) {
2874
+ last[1] = span[1];
2875
+ continue $l$loop;
2876
+ }
2877
+ }
2878
+ merged.add_utx5q5_k$(span);
2879
+ }
2880
+ var minTurn = options.minCornerTurnDeg_1 * 3.141592653589793 / 180.0;
2881
+ var hairpinTurn = options.hairpinTurnDeg_1 * 3.141592653589793 / 180.0;
2882
+ // Inline function 'kotlin.collections.mutableListOf' call
2883
+ var out = ArrayList_init_$Create$();
2884
+ var _iterator__ex2g4s_0 = merged.iterator_jk1svi_k$();
2885
+ $l$loop_2: while (_iterator__ex2g4s_0.hasNext_bitz1p_k$()) {
2886
+ var span_0 = _iterator__ex2g4s_0.next_20eer_k$();
2887
+ var from = span_0[0];
2888
+ // Inline function 'kotlin.comparisons.minOf' call
2889
+ var a_0 = span_0[1];
2890
+ var until = Math.min(a_0, n);
2891
+ if ((until - from | 0) < 2)
2892
+ continue $l$loop_2;
2893
+ var lengthM = frame.s_1[until - 1 | 0] - frame.s_1[from];
2894
+ if (lengthM < options.minCornerLengthM_1)
2895
+ continue $l$loop_2;
2896
+ var turn = frame.theta_1[until - 1 | 0] - frame.theta_1[from];
2897
+ // Inline function 'kotlin.math.abs' call
2898
+ if (Math.abs(turn) < minTurn)
2899
+ continue $l$loop_2;
2900
+ var apex = from;
2901
+ var peak = 0.0;
2902
+ var minRadius = 1.7976931348623157E308;
2903
+ var inductionVariable_0 = from;
2904
+ if (inductionVariable_0 < until)
2905
+ do {
2906
+ var i_0 = inductionVariable_0;
2907
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
2908
+ // Inline function 'kotlin.math.abs' call
2909
+ var x = kappa[i_0];
2910
+ var a_1 = Math.abs(x);
2911
+ if (a_1 > peak) {
2912
+ peak = a_1;
2913
+ apex = i_0;
2914
+ }
2915
+ var r = CurvatureEstimator_instance.radiusAt_umgvjz_k$(kappa[i_0]);
2916
+ if (r < minRadius)
2917
+ minRadius = r;
2918
+ }
2919
+ while (inductionVariable_0 < until);
2920
+ var q20 = radiusPercentile(this, kappa, from, until, 0.2);
2921
+ var tmp_1;
2922
+ // Inline function 'kotlin.math.abs' call
2923
+ if (Math.abs(turn) >= hairpinTurn) {
2924
+ tmp_1 = CornerKind_HAIRPIN_getInstance();
2925
+ } else {
2926
+ if (q20 >= options.gentleRadiusM_1) {
2927
+ tmp_1 = CornerKind_GENTLE_getInstance();
2928
+ } else {
2929
+ tmp_1 = CornerKind_CORNER_getInstance();
2930
+ }
2931
+ }
2932
+ var kind = tmp_1;
2933
+ out.add_utx5q5_k$(new CornerSpan(from, until, apex, kind, turn, span_0[2], q20, minRadius === 1.7976931348623157E308 ? Infinity : minRadius, lengthM));
2934
+ }
2935
+ return out;
2936
+ };
2937
+ var CornerDetector_instance;
2938
+ function CornerDetector_getInstance() {
2939
+ return CornerDetector_instance;
2940
+ }
2941
+ function CorridorBounds(lo, hi, halfWidthM) {
2942
+ this.lo_1 = lo;
2943
+ this.hi_1 = hi;
2944
+ this.halfWidthM_1 = halfWidthM;
2945
+ }
2946
+ function applyRegularityClamp($this, frame, options, lo, hi) {
2947
+ var inductionVariable = 0;
2948
+ var last = frame.get_size_woubt6_k$();
2949
+ if (inductionVariable < last)
2950
+ do {
2951
+ var i = inductionVariable;
2952
+ inductionVariable = inductionVariable + 1 | 0;
2953
+ // Inline function 'kotlin.math.abs' call
2954
+ var x = frame.kappa_1[i];
2955
+ // Inline function 'kotlin.math.max' call
2956
+ var a = Math.abs(x);
2957
+ var tmp$ret$1 = Math.max(a, 1.0E-9);
2958
+ var limit = options.regularityFactor_1 / tmp$ret$1;
2959
+ var tmp0 = lo[i];
2960
+ // Inline function 'kotlin.math.max' call
2961
+ var b = -limit;
2962
+ lo[i] = Math.max(tmp0, b);
2963
+ // Inline function 'kotlin.math.min' call
2964
+ var a_0 = hi[i];
2965
+ hi[i] = Math.min(a_0, limit);
2966
+ }
2967
+ while (inductionVariable < last);
2968
+ }
2969
+ function applySelfProximityClamp($this, frame, options, lo, hi) {
2970
+ var n = frame.get_size_woubt6_k$();
2971
+ var buckets = HashMap_init_$Create$();
2972
+ var inductionVariable = 0;
2973
+ if (inductionVariable < n)
2974
+ do {
2975
+ var i = inductionVariable;
2976
+ inductionVariable = inductionVariable + 1 | 0;
2977
+ // Inline function 'kotlin.collections.getOrPut' call
2978
+ var key = cellKey($this, bucketOf($this, frame.x_1[i]), bucketOf($this, frame.y_1[i]));
2979
+ var value = buckets.get_wei43m_k$(key);
2980
+ var tmp;
2981
+ if (value == null) {
2982
+ // Inline function 'kotlin.collections.mutableListOf' call
2983
+ var answer = ArrayList_init_$Create$();
2984
+ buckets.put_4fpzoq_k$(key, answer);
2985
+ tmp = answer;
2986
+ } else {
2987
+ tmp = value;
2988
+ }
2989
+ tmp.add_utx5q5_k$(i);
2990
+ }
2991
+ while (inductionVariable < n);
2992
+ var inductionVariable_0 = 0;
2993
+ if (inductionVariable_0 < n)
2994
+ $l$loop_1: do {
2995
+ var i_0 = inductionVariable_0;
2996
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
2997
+ var bx = bucketOf($this, frame.x_1[i_0]);
2998
+ var by = bucketOf($this, frame.y_1[i_0]);
2999
+ var nearest = 1.7976931348623157E308;
3000
+ var inductionVariable_1 = -1;
3001
+ if (inductionVariable_1 <= 1)
3002
+ do {
3003
+ var dx = inductionVariable_1;
3004
+ inductionVariable_1 = inductionVariable_1 + 1 | 0;
3005
+ var inductionVariable_2 = -1;
3006
+ if (inductionVariable_2 <= 1)
3007
+ $l$loop: do {
3008
+ var dy = inductionVariable_2;
3009
+ inductionVariable_2 = inductionVariable_2 + 1 | 0;
3010
+ // Inline function 'kotlin.Long.plus' call
3011
+ var tmp_0 = add(bx, fromInt(dx));
3012
+ // Inline function 'kotlin.Long.plus' call
3013
+ var tmp$ret$4 = add(by, fromInt(dy));
3014
+ var tmp0_elvis_lhs = buckets.get_wei43m_k$(cellKey($this, tmp_0, tmp$ret$4));
3015
+ var tmp_1;
3016
+ if (tmp0_elvis_lhs == null) {
3017
+ continue $l$loop;
3018
+ } else {
3019
+ tmp_1 = tmp0_elvis_lhs;
3020
+ }
3021
+ var cell = tmp_1;
3022
+ var _iterator__ex2g4s = cell.iterator_jk1svi_k$();
3023
+ $l$loop_0: while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
3024
+ var j = _iterator__ex2g4s.next_20eer_k$();
3025
+ // Inline function 'kotlin.math.abs' call
3026
+ var x = frame.s_1[j] - frame.s_1[i_0];
3027
+ var alongPath = Math.abs(x);
3028
+ var ddx = frame.x_1[j] - frame.x_1[i_0];
3029
+ var ddy = frame.y_1[j] - frame.y_1[i_0];
3030
+ // Inline function 'kotlin.math.sqrt' call
3031
+ var x_0 = ddx * ddx + ddy * ddy;
3032
+ var d = Math.sqrt(x_0);
3033
+ // Inline function 'kotlin.math.abs' call
3034
+ var x_1 = LocalFrame_instance.unwrap_i6c8al_k$(frame.theta_1[j] - frame.theta_1[i_0]);
3035
+ var headingGap = Math.abs(x_1);
3036
+ var sameRoad = alongPath <= options.selfProximityGapM_1 && headingGap < 1.5707963267948966;
3037
+ if (sameRoad)
3038
+ continue $l$loop_0;
3039
+ if (d < nearest)
3040
+ nearest = d;
3041
+ }
3042
+ }
3043
+ while (inductionVariable_2 <= 1);
3044
+ }
3045
+ while (inductionVariable_1 <= 1);
3046
+ if (nearest === 1.7976931348623157E308)
3047
+ continue $l$loop_1;
3048
+ // Inline function 'kotlin.math.max' call
3049
+ var b = nearest / 2.0 - 0.5;
3050
+ var allowed = Math.max(0.0, b);
3051
+ var tmp0 = lo[i_0];
3052
+ // Inline function 'kotlin.math.max' call
3053
+ var b_0 = -allowed;
3054
+ lo[i_0] = Math.max(tmp0, b_0);
3055
+ // Inline function 'kotlin.math.min' call
3056
+ var a = hi[i_0];
3057
+ hi[i_0] = Math.min(a, allowed);
3058
+ }
3059
+ while (inductionVariable_0 < n);
3060
+ }
3061
+ function bucketOf($this, v) {
3062
+ // Inline function 'kotlin.math.floor' call
3063
+ var x = v / 12.0;
3064
+ var tmp$ret$0 = Math.floor(x);
3065
+ return numberToLong(tmp$ret$0);
3066
+ }
3067
+ function cellKey($this, bx, by) {
3068
+ return bitwiseXor(shiftLeft(bx, 32), bitwiseAnd(by, new Long(-1, 0)));
3069
+ }
3070
+ function applyPins($this, frame, options, lo, hi) {
3071
+ var n = frame.get_size_woubt6_k$();
3072
+ // Inline function 'kotlin.intArrayOf' call
3073
+ var indexedObject = new Int32Array([0, 1, n - 2 | 0, n - 1 | 0]);
3074
+ var inductionVariable = 0;
3075
+ var last = indexedObject.length;
3076
+ while (inductionVariable < last) {
3077
+ var i = indexedObject[inductionVariable];
3078
+ inductionVariable = inductionVariable + 1 | 0;
3079
+ if (0 <= i ? i < n : false) {
3080
+ lo[i] = 0.0;
3081
+ hi[i] = 0.0;
3082
+ }
3083
+ }
3084
+ var straightKappa = 1.0 / options.straightRadiusM_1;
3085
+ var runStart = -1;
3086
+ var inductionVariable_0 = 0;
3087
+ if (inductionVariable_0 < n)
3088
+ do {
3089
+ var i_0 = inductionVariable_0;
3090
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
3091
+ // Inline function 'kotlin.math.abs' call
3092
+ var x = frame.kappa_1[i_0];
3093
+ var straight = Math.abs(x) < straightKappa;
3094
+ if (straight) {
3095
+ if (runStart < 0)
3096
+ runStart = i_0;
3097
+ } else {
3098
+ pinRunMidpoint($this, frame, options, runStart, i_0, lo, hi);
3099
+ runStart = -1;
3100
+ }
3101
+ }
3102
+ while (inductionVariable_0 < n);
3103
+ pinRunMidpoint($this, frame, options, runStart, n, lo, hi);
3104
+ }
3105
+ function pinRunMidpoint($this, frame, options, from, until, lo, hi) {
3106
+ if (from < 0 || (until - from | 0) < 2)
3107
+ return Unit_instance;
3108
+ if (frame.s_1[until - 1 | 0] - frame.s_1[from] < options.straightRunM_1)
3109
+ return Unit_instance;
3110
+ var mid = (from + until | 0) / 2 | 0;
3111
+ // Inline function 'kotlin.intArrayOf' call
3112
+ var indexedObject = new Int32Array([mid, mid + 1 | 0]);
3113
+ var inductionVariable = 0;
3114
+ var last = indexedObject.length;
3115
+ while (inductionVariable < last) {
3116
+ var i = indexedObject[inductionVariable];
3117
+ inductionVariable = inductionVariable + 1 | 0;
3118
+ if (0 <= i ? i < frame.get_size_woubt6_k$() : false) {
3119
+ lo[i] = 0.0;
3120
+ hi[i] = 0.0;
3121
+ }
3122
+ }
3123
+ }
3124
+ function Corridor() {
3125
+ this.MAX_HALF_WIDTH_M_1 = 6.0;
3126
+ this.GRID_M_1 = 12.0;
3127
+ this.PROXIMITY_CLEARANCE_M_1 = 0.5;
3128
+ this.SAME_ROAD_HEADING_RAD_1 = 1.5707963267948966;
3129
+ }
3130
+ protoOf(Corridor).resolveWidth_feg61f_k$ = function (path, frame, options) {
3131
+ var raw = new Float64Array(frame.get_size_woubt6_k$());
3132
+ var inductionVariable = 0;
3133
+ var last = raw.length - 1 | 0;
3134
+ if (inductionVariable <= last)
3135
+ do {
3136
+ var i = inductionVariable;
3137
+ inductionVariable = inductionVariable + 1 | 0;
3138
+ var w = path.roadWidth_7zv9qq_k$(i);
3139
+ raw[i] = isNaN_0(w) || w <= 0.0 ? options.defaultRoadWidthM_1 : w;
3140
+ }
3141
+ while (inductionVariable <= last);
3142
+ return LocalFrame_instance.smooth_kce7pb_k$(raw, frame.s_1, options.widthSmoothWindowM_1);
3143
+ };
3144
+ protoOf(Corridor).build_fyfb0s_k$ = function (frame, widthM, options) {
3145
+ var n = frame.get_size_woubt6_k$();
3146
+ var lo = new Float64Array(n);
3147
+ var hi = new Float64Array(n);
3148
+ var half = new Float64Array(n);
3149
+ var inductionVariable = 0;
3150
+ if (inductionVariable < n)
3151
+ do {
3152
+ var i = inductionVariable;
3153
+ inductionVariable = inductionVariable + 1 | 0;
3154
+ var h = coerceIn(widthM[i] / 2.0 - options.edgeMarginM_1, 0.0, 6.0);
3155
+ half[i] = h;
3156
+ switch (options.corridor_1.ordinal_1) {
3157
+ case 0:
3158
+ lo[i] = -h;
3159
+ hi[i] = 0.0;
3160
+ break;
3161
+ case 1:
3162
+ lo[i] = 0.0;
3163
+ hi[i] = h;
3164
+ break;
3165
+ case 2:
3166
+ lo[i] = -h;
3167
+ hi[i] = h;
3168
+ break;
3169
+ default:
3170
+ noWhenBranchMatchedException();
3171
+ break;
3172
+ }
3173
+ }
3174
+ while (inductionVariable < n);
3175
+ applyRegularityClamp(this, frame, options, lo, hi);
3176
+ applySelfProximityClamp(this, frame, options, lo, hi);
3177
+ applyPins(this, frame, options, lo, hi);
3178
+ var inductionVariable_0 = 0;
3179
+ if (inductionVariable_0 < n)
3180
+ do {
3181
+ var i_0 = inductionVariable_0;
3182
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
3183
+ if (lo[i_0] > hi[i_0]) {
3184
+ var mid = (lo[i_0] + hi[i_0]) / 2.0;
3185
+ lo[i_0] = mid;
3186
+ hi[i_0] = mid;
3187
+ }
3188
+ }
3189
+ while (inductionVariable_0 < n);
3190
+ return new CorridorBounds(lo, hi, half);
3191
+ };
3192
+ var Corridor_instance;
3193
+ function Corridor_getInstance() {
3194
+ return Corridor_instance;
3195
+ }
3196
+ function medianSigma($this, frame, halfWidthM) {
3197
+ var n = frame.get_size_woubt6_k$();
3198
+ if (n === 0)
3199
+ return 0.0;
3200
+ var values = new Float64Array(n);
3201
+ var count = 0;
3202
+ var inductionVariable = 0;
3203
+ if (inductionVariable < n)
3204
+ $l$loop: do {
3205
+ var i = inductionVariable;
3206
+ inductionVariable = inductionVariable + 1 | 0;
3207
+ var tmp0_elvis_lhs = fitSlope($this, frame, i, halfWidthM);
3208
+ var tmp;
3209
+ if (tmp0_elvis_lhs == null) {
3210
+ continue $l$loop;
3211
+ } else {
3212
+ tmp = tmp0_elvis_lhs;
3213
+ }
3214
+ var fit = tmp;
3215
+ var _unary__edvuaz = count;
3216
+ count = _unary__edvuaz + 1 | 0;
3217
+ values[_unary__edvuaz] = fit.residualSigma_1;
3218
+ }
3219
+ while (inductionVariable < n);
3220
+ if (count === 0)
3221
+ return 0.0;
3222
+ var trimmed = copyOf(values, count);
3223
+ sort(trimmed);
3224
+ return trimmed[count / 2 | 0];
3225
+ }
3226
+ function Fit(slope, residualSigma) {
3227
+ this.slope_1 = slope;
3228
+ this.residualSigma_1 = residualSigma;
3229
+ }
3230
+ function fitSlope($this, frame, i, halfWidthM) {
3231
+ var n = frame.get_size_woubt6_k$();
3232
+ var s = frame.s_1;
3233
+ var theta = frame.theta_1;
3234
+ var si = s[i];
3235
+ var ti = theta[i];
3236
+ var lo = i;
3237
+ while (lo > 0 && si - s[lo - 1 | 0] <= halfWidthM && (i - lo | 0) < 400) {
3238
+ lo = lo - 1 | 0;
3239
+ }
3240
+ var hi = i;
3241
+ while (hi < (n - 1 | 0) && s[hi + 1 | 0] - si <= halfWidthM && (hi - i | 0) < 400) {
3242
+ hi = hi + 1 | 0;
3243
+ }
3244
+ var m = (hi - lo | 0) + 1 | 0;
3245
+ if (m < 3)
3246
+ return null;
3247
+ var sumS = 0.0;
3248
+ var sumSS = 0.0;
3249
+ var sumT = 0.0;
3250
+ var sumST = 0.0;
3251
+ var inductionVariable = lo;
3252
+ var last = hi;
3253
+ if (inductionVariable <= last)
3254
+ do {
3255
+ var j = inductionVariable;
3256
+ inductionVariable = inductionVariable + 1 | 0;
3257
+ var ds = s[j] - si;
3258
+ var dt = theta[j] - ti;
3259
+ sumS = sumS + ds;
3260
+ sumSS = sumSS + ds * ds;
3261
+ sumT = sumT + dt;
3262
+ sumST = sumST + ds * dt;
3263
+ }
3264
+ while (!(j === last));
3265
+ var mD = m;
3266
+ var denominator = mD * sumSS - sumS * sumS;
3267
+ if (denominator < 1.0E-6 * mD * halfWidthM * halfWidthM)
3268
+ return null;
3269
+ var slope = (mD * sumST - sumS * sumT) / denominator;
3270
+ var intercept = (sumT - slope * sumS) / mD;
3271
+ var rss = 0.0;
3272
+ var inductionVariable_0 = lo;
3273
+ var last_0 = hi;
3274
+ if (inductionVariable_0 <= last_0)
3275
+ do {
3276
+ var j_0 = inductionVariable_0;
3277
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
3278
+ var ds_0 = s[j_0] - si;
3279
+ var residual = theta[j_0] - ti - intercept - slope * ds_0;
3280
+ rss = rss + residual * residual;
3281
+ }
3282
+ while (!(j_0 === last_0));
3283
+ // Inline function 'kotlin.math.sqrt' call
3284
+ var x = rss / coerceAtLeast(mD - 2.0, 1.0);
3285
+ var sigma = Math.sqrt(x);
3286
+ return !isFinite(slope) || !isFinite(sigma) ? null : new Fit(slope, sigma);
3287
+ }
3288
+ function CurvatureEstimator() {
3289
+ this.SCALE_RESIDUAL_FACTOR_1 = 2.0;
3290
+ this.MAX_HALF_WINDOW_POINTS_1 = 400;
3291
+ this.DEGENERACY_FACTOR_1 = 1.0E-6;
3292
+ }
3293
+ protoOf(CurvatureEstimator).computeHeadings_ev7p13_k$ = function (frame) {
3294
+ var n = frame.get_size_woubt6_k$();
3295
+ var theta = frame.theta_1;
3296
+ if (n === 0)
3297
+ return Unit_instance;
3298
+ var previous = NaN;
3299
+ var inductionVariable = 0;
3300
+ if (inductionVariable < n)
3301
+ do {
3302
+ var i = inductionVariable;
3303
+ inductionVariable = inductionVariable + 1 | 0;
3304
+ var a = i > 0 ? i - 1 | 0 : 0;
3305
+ var b = i < (n - 1 | 0) ? i + 1 | 0 : n - 1 | 0;
3306
+ var dx = frame.x_1[b] - frame.x_1[a];
3307
+ var dy = frame.y_1[b] - frame.y_1[a];
3308
+ var tmp;
3309
+ if (dx === 0.0 && dy === 0.0) {
3310
+ tmp = isNaN_0(previous) ? 0.0 : previous;
3311
+ } else {
3312
+ // Inline function 'kotlin.math.atan2' call
3313
+ tmp = Math.atan2(dy, dx);
3314
+ }
3315
+ var raw = tmp;
3316
+ var tmp_0;
3317
+ if (i === 0 || isNaN_0(previous)) {
3318
+ tmp_0 = raw;
3319
+ } else {
3320
+ tmp_0 = previous + LocalFrame_instance.unwrap_i6c8al_k$(raw - previous);
3321
+ }
3322
+ theta[i] = tmp_0;
3323
+ previous = theta[i];
3324
+ }
3325
+ while (inductionVariable < n);
3326
+ };
3327
+ protoOf(CurvatureEstimator).computeCurvature_emiphc_k$ = function (frame, windowsM, sigmaThetaRad, curvatureSmoothM) {
3328
+ var n = frame.get_size_woubt6_k$();
3329
+ var kappa = frame.kappa_1;
3330
+ if (n === 0)
3331
+ return Unit_instance;
3332
+ // Inline function 'kotlin.collections.isNotEmpty' call
3333
+ // Inline function 'kotlin.collections.isEmpty' call
3334
+ // Inline function 'kotlin.require' call
3335
+ if (!!(windowsM.length === 0)) {
3336
+ var message = 'At least one curvature window is required';
3337
+ throw IllegalArgumentException_init_$Create$(toString(message));
3338
+ }
3339
+ var scales = windowsM.length;
3340
+ var slopes = new Float64Array(scales);
3341
+ var sigmas = new Float64Array(scales);
3342
+ var raw = new Float64Array(n);
3343
+ var measuredNoise = medianSigma(this, frame, windowsM[scales - 1 | 0]);
3344
+ // Inline function 'kotlin.comparisons.maxOf' call
3345
+ var threshold = 2.0 * Math.max(sigmaThetaRad, measuredNoise);
3346
+ var inductionVariable = 0;
3347
+ if (inductionVariable < n)
3348
+ do {
3349
+ var i = inductionVariable;
3350
+ inductionVariable = inductionVariable + 1 | 0;
3351
+ var inductionVariable_0 = 0;
3352
+ if (inductionVariable_0 < scales)
3353
+ do {
3354
+ var w = inductionVariable_0;
3355
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
3356
+ var fit = fitSlope(this, frame, i, windowsM[w]);
3357
+ var tmp1_elvis_lhs = fit == null ? null : fit.slope_1;
3358
+ slopes[w] = tmp1_elvis_lhs == null ? NaN : tmp1_elvis_lhs;
3359
+ var tmp3_elvis_lhs = fit == null ? null : fit.residualSigma_1;
3360
+ sigmas[w] = tmp3_elvis_lhs == null ? NaN : tmp3_elvis_lhs;
3361
+ }
3362
+ while (inductionVariable_0 < scales);
3363
+ var chosen = NaN;
3364
+ var widest = NaN;
3365
+ var inductionVariable_1 = scales - 1 | 0;
3366
+ if (0 <= inductionVariable_1)
3367
+ $l$loop_0: do {
3368
+ var w_0 = inductionVariable_1;
3369
+ inductionVariable_1 = inductionVariable_1 + -1 | 0;
3370
+ if (isNaN_0(sigmas[w_0]))
3371
+ continue $l$loop_0;
3372
+ if (isNaN_0(widest))
3373
+ widest = slopes[w_0];
3374
+ if (sigmas[w_0] <= threshold) {
3375
+ chosen = slopes[w_0];
3376
+ break $l$loop_0;
3377
+ }
3378
+ }
3379
+ while (0 <= inductionVariable_1);
3380
+ var tmp;
3381
+ if (!isNaN_0(chosen)) {
3382
+ tmp = chosen;
3383
+ } else if (!isNaN_0(widest)) {
3384
+ tmp = widest;
3385
+ } else {
3386
+ tmp = 0.0;
3387
+ }
3388
+ raw[i] = tmp;
3389
+ }
3390
+ while (inductionVariable < n);
3391
+ var smoothed = LocalFrame_instance.smooth_kce7pb_k$(raw, frame.s_1, curvatureSmoothM);
3392
+ // Inline function 'kotlin.collections.copyInto' call
3393
+ var endIndex = smoothed.length;
3394
+ // Inline function 'kotlin.js.unsafeCast' call
3395
+ // Inline function 'kotlin.js.asDynamic' call
3396
+ var tmp_0 = smoothed;
3397
+ // Inline function 'kotlin.js.unsafeCast' call
3398
+ // Inline function 'kotlin.js.asDynamic' call
3399
+ arrayCopy(tmp_0, kappa, 0, 0, endIndex);
3400
+ };
3401
+ protoOf(CurvatureEstimator).radiusAt_umgvjz_k$ = function (kappa) {
3402
+ var tmp;
3403
+ // Inline function 'kotlin.math.abs' call
3404
+ if (Math.abs(kappa) < 1.0E-12) {
3405
+ tmp = Infinity;
3406
+ } else {
3407
+ // Inline function 'kotlin.math.abs' call
3408
+ tmp = 1.0 / Math.abs(kappa);
3409
+ }
3410
+ return tmp;
3411
+ };
3412
+ var CurvatureEstimator_instance;
3413
+ function CurvatureEstimator_getInstance() {
3414
+ return CurvatureEstimator_instance;
3415
+ }
3416
+ function LocalFrame() {
3417
+ this.MAX_ABS_LATITUDE_RAD_1 = 1.4835298641951802;
3418
+ this.MIN_POINTS_1 = 8;
3419
+ }
3420
+ protoOf(LocalFrame).project_n982lp_k$ = function (path, smoothWindowM) {
3421
+ var n = path.size_1;
3422
+ if (n < 8)
3423
+ return null;
3424
+ var bounds = path.boundsRad_1;
3425
+ var lat0 = (bounds.minLat_1 + bounds.maxLat_1) / 2.0;
3426
+ var lon0 = (bounds.minLon_1 + bounds.maxLon_1) / 2.0;
3427
+ if (!isFinite(lat0) || !isFinite(lon0))
3428
+ return null;
3429
+ // Inline function 'kotlin.math.abs' call
3430
+ if (Math.abs(lat0) > 1.4835298641951802)
3431
+ return null;
3432
+ if (bounds.maxLon_1 - bounds.minLon_1 > 3.141592653589793)
3433
+ lon0 = path.longitude_a9xl_k$(0);
3434
+ // Inline function 'kotlin.math.cos' call
3435
+ var k = Math.cos(lat0);
3436
+ var rawX = new Float64Array(n);
3437
+ var rawY = new Float64Array(n);
3438
+ var s = new Float64Array(n);
3439
+ var inductionVariable = 0;
3440
+ if (inductionVariable < n)
3441
+ do {
3442
+ var i = inductionVariable;
3443
+ inductionVariable = inductionVariable + 1 | 0;
3444
+ var lat = path.latitude_gb4iok_k$(i);
3445
+ var lon = path.longitude_a9xl_k$(i);
3446
+ var dist = path.distance_5s4s77_k$(i);
3447
+ if (!isFinite(lat) || !isFinite(lon) || !isFinite(dist))
3448
+ return null;
3449
+ var dLon = this.unwrap_i6c8al_k$(lon - lon0);
3450
+ rawX[i] = 6371000.0 * k * dLon;
3451
+ rawY[i] = 6371000.0 * (lat - lat0);
3452
+ s[i] = dist;
3453
+ }
3454
+ while (inductionVariable < n);
3455
+ var x = this.smooth_kce7pb_k$(rawX, s, smoothWindowM);
3456
+ var y = this.smooth_kce7pb_k$(rawY, s, smoothWindowM);
3457
+ this.arclengthOf_yiuhr5_k$(x, y, s);
3458
+ return new PlanarFrame(x, y, s, new Float64Array(n), new Float64Array(n), lat0, lon0, k);
3459
+ };
3460
+ protoOf(LocalFrame).unproject_ym27oh_k$ = function (frame, x, y) {
3461
+ var lat = frame.lat0__1 + y / 6371000.0;
3462
+ var lon = frame.lon0__1 + x / (6371000.0 * frame.k_1);
3463
+ // Inline function 'kotlin.doubleArrayOf' call
3464
+ return new Float64Array([lat, lon]);
3465
+ };
3466
+ protoOf(LocalFrame).arclengthOf_yiuhr5_k$ = function (x, y, s) {
3467
+ s[0] = 0.0;
3468
+ var inductionVariable = 1;
3469
+ var last = x.length;
3470
+ if (inductionVariable < last)
3471
+ do {
3472
+ var i = inductionVariable;
3473
+ inductionVariable = inductionVariable + 1 | 0;
3474
+ var dx = x[i] - x[i - 1 | 0];
3475
+ var dy = y[i] - y[i - 1 | 0];
3476
+ var tmp = s[i - 1 | 0];
3477
+ // Inline function 'kotlin.math.sqrt' call
3478
+ var x_0 = dx * dx + dy * dy;
3479
+ s[i] = tmp + Math.sqrt(x_0);
3480
+ }
3481
+ while (inductionVariable < last);
3482
+ };
3483
+ protoOf(LocalFrame).unwrap_i6c8al_k$ = function (a) {
3484
+ return a - 2.0 * 3.141592653589793 * round(a / (2.0 * 3.141592653589793));
3485
+ };
3486
+ protoOf(LocalFrame).smooth_kce7pb_k$ = function (v, s, windowM) {
3487
+ var n = v.length;
3488
+ if (windowM <= 0.0 || n < 3) {
3489
+ // Inline function 'kotlin.collections.copyOf' call
3490
+ // Inline function 'kotlin.js.asDynamic' call
3491
+ return v.slice();
3492
+ }
3493
+ var out = new Float64Array(n);
3494
+ var lo = 0;
3495
+ var hi = 0;
3496
+ var inductionVariable = 0;
3497
+ if (inductionVariable < n)
3498
+ do {
3499
+ var i = inductionVariable;
3500
+ inductionVariable = inductionVariable + 1 | 0;
3501
+ var c = s[i];
3502
+ while (lo < i && c - s[lo] > windowM) {
3503
+ lo = lo + 1 | 0;
3504
+ }
3505
+ if (hi < i)
3506
+ hi = i;
3507
+ while (hi < (n - 1 | 0) && s[hi + 1 | 0] - c <= windowM) {
3508
+ hi = hi + 1 | 0;
3509
+ }
3510
+ var weightSum = 0.0;
3511
+ var valueSum = 0.0;
3512
+ var inductionVariable_0 = lo;
3513
+ var last = hi;
3514
+ if (inductionVariable_0 <= last)
3515
+ $l$loop: do {
3516
+ var j = inductionVariable_0;
3517
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
3518
+ // Inline function 'kotlin.math.abs' call
3519
+ var x = s[j] - c;
3520
+ var w = 1.0 - Math.abs(x) / windowM;
3521
+ if (w <= 0.0)
3522
+ continue $l$loop;
3523
+ weightSum = weightSum + w;
3524
+ valueSum = valueSum + v[j] * w;
3525
+ }
3526
+ while (!(j === last));
3527
+ out[i] = weightSum > 0.0 ? valueSum / weightSum : v[i];
3528
+ }
3529
+ while (inductionVariable < n);
3530
+ return out;
3531
+ };
3532
+ var LocalFrame_instance;
3533
+ function LocalFrame_getInstance() {
3534
+ return LocalFrame_instance;
3535
+ }
3536
+ function Companion_11() {
3537
+ }
3538
+ protoOf(Companion_11).assemble_miimn7_k$ = function (frame, center, rho, steeringLengthM, centeringLengthM) {
3539
+ var n = frame.get_size_woubt6_k$();
3540
+ var h0 = new Float64Array(n);
3541
+ var h1 = new Float64Array(n);
3542
+ var h2 = new Float64Array(n);
3543
+ var linear = new Float64Array(n);
3544
+ var constant = 0.0;
3545
+ var lambdaR = 1.0 / (steeringLengthM * steeringLengthM);
3546
+ var lambdaC = 1.0 / (centeringLengthM * centeringLengthM * centeringLengthM * centeringLengthM);
3547
+ var a = new Float64Array(3);
3548
+ var b = new Float64Array(3);
3549
+ var inductionVariable = 0;
3550
+ if (inductionVariable < n)
3551
+ $l$loop_0: do {
3552
+ var i = inductionVariable;
3553
+ inductionVariable = inductionVariable + 1 | 0;
3554
+ var hMinus = i >= 1 ? frame.s_1[i] - frame.s_1[i - 1 | 0] : 0.0;
3555
+ var hPlus = (i + 1 | 0) < n ? frame.s_1[i + 1 | 0] - frame.s_1[i] : 0.0;
3556
+ var weight = 0.5 * (hMinus + hPlus);
3557
+ h0[i] = h0[i] + 2.0 * weight * lambdaC;
3558
+ linear[i] = linear[i] - 2.0 * weight * lambdaC * center[i];
3559
+ constant = constant + weight * lambdaC * center[i] * center[i];
3560
+ if (i < 1 || (i + 1 | 0) >= n)
3561
+ continue $l$loop_0;
3562
+ var denom = hPlus * hMinus * (hPlus + hMinus);
3563
+ if (denom <= 0.0)
3564
+ continue $l$loop_0;
3565
+ a[0] = 2.0 * hPlus / denom;
3566
+ a[1] = -2.0 * (hPlus + hMinus) / denom + frame.kappa_1[i] * frame.kappa_1[i];
3567
+ a[2] = 2.0 * hMinus / denom;
3568
+ b[0] = -hPlus * hPlus / denom;
3569
+ b[1] = (hPlus * hPlus - hMinus * hMinus) / denom;
3570
+ b[2] = hMinus * hMinus / denom;
3571
+ var wRho = weight * rho[i];
3572
+ var wR = weight * lambdaR;
3573
+ var kappaI = frame.kappa_1[i];
3574
+ var inductionVariable_0 = 0;
3575
+ if (inductionVariable_0 <= 2)
3576
+ do {
3577
+ var p = inductionVariable_0;
3578
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
3579
+ var row = (i - 1 | 0) + p | 0;
3580
+ linear[row] = linear[row] + 2.0 * wRho * kappaI * a[p];
3581
+ var inductionVariable_1 = p;
3582
+ if (inductionVariable_1 <= 2)
3583
+ do {
3584
+ var q = inductionVariable_1;
3585
+ inductionVariable_1 = inductionVariable_1 + 1 | 0;
3586
+ var col = (i - 1 | 0) + q | 0;
3587
+ var contribution = 2.0 * (wRho * a[p] * a[q] + wR * b[p] * b[q]);
3588
+ switch (col - row | 0) {
3589
+ case 0:
3590
+ h0[row] = h0[row] + contribution;
3591
+ break;
3592
+ case 1:
3593
+ h1[row] = h1[row] + contribution;
3594
+ break;
3595
+ case 2:
3596
+ h2[row] = h2[row] + contribution;
3597
+ break;
3598
+ }
3599
+ }
3600
+ while (inductionVariable_1 <= 2);
3601
+ }
3602
+ while (inductionVariable_0 <= 2);
3603
+ constant = constant + wRho * kappaI * kappaI;
3604
+ }
3605
+ while (inductionVariable < n);
3606
+ return new OffsetEnergy(h0, h1, h2, linear, constant);
3607
+ };
3608
+ var Companion_instance_12;
3609
+ function Companion_getInstance_14() {
3610
+ return Companion_instance_12;
3611
+ }
3612
+ function OffsetEnergy(h0, h1, h2, linear, constant) {
3613
+ this.h0__1 = h0;
3614
+ this.h1__1 = h1;
3615
+ this.h2__1 = h2;
3616
+ this.linear_1 = linear;
3617
+ this.constant_1 = constant;
3618
+ }
3619
+ protoOf(OffsetEnergy).get_size_woubt6_k$ = function () {
3620
+ return this.h0__1.length;
3621
+ };
3622
+ protoOf(OffsetEnergy).value_6wg803_k$ = function (n, scratch) {
3623
+ BandedLdl_instance.multiply_dwj15t_k$(this.h0__1, this.h1__1, this.h2__1, n, scratch);
3624
+ var acc = this.constant_1;
3625
+ var inductionVariable = 0;
3626
+ var last = n.length - 1 | 0;
3627
+ if (inductionVariable <= last)
3628
+ do {
3629
+ var i = inductionVariable;
3630
+ inductionVariable = inductionVariable + 1 | 0;
3631
+ acc = acc + (0.5 * scratch[i] * n[i] + this.linear_1[i] * n[i]);
3632
+ }
3633
+ while (inductionVariable <= last);
3634
+ return acc;
3635
+ };
3636
+ protoOf(OffsetEnergy).gradient_zecmby_k$ = function (n, out) {
3637
+ BandedLdl_instance.multiply_dwj15t_k$(this.h0__1, this.h1__1, this.h2__1, n, out);
3638
+ var inductionVariable = 0;
3639
+ var last = out.length - 1 | 0;
3640
+ if (inductionVariable <= last)
3641
+ do {
3642
+ var i = inductionVariable;
3643
+ inductionVariable = inductionVariable + 1 | 0;
3644
+ out[i] = out[i] + this.linear_1[i];
3645
+ }
3646
+ while (inductionVariable <= last);
3647
+ };
3648
+ function QpResult(offset, iterations, gradientInfNorm, converged, activeConstraints) {
3649
+ this.offset_1 = offset;
3650
+ this.iterations_1 = iterations;
3651
+ this.gradientInfNorm_1 = gradientInfNorm;
3652
+ this.converged_1 = converged;
3653
+ this.activeConstraints_1 = activeConstraints;
3654
+ }
3655
+ function isFree($this, x, lo, hi, g, epsilon) {
3656
+ if (hi - lo <= 2.0 * epsilon)
3657
+ return false;
3658
+ if (x <= lo + epsilon && g > 0.0)
3659
+ return false;
3660
+ if (x >= hi - epsilon && g < 0.0)
3661
+ return false;
3662
+ return true;
3663
+ }
3664
+ function buildFreeSystem($this, energy, freeIndex, freeCount, f0, f1, f2) {
3665
+ var inductionVariable = 0;
3666
+ if (inductionVariable < freeCount)
3667
+ do {
3668
+ var p = inductionVariable;
3669
+ inductionVariable = inductionVariable + 1 | 0;
3670
+ var i = freeIndex[p];
3671
+ f0[p] = energy.h0__1[i];
3672
+ f1[p] = 0.0;
3673
+ f2[p] = 0.0;
3674
+ if ((p + 1 | 0) < freeCount) {
3675
+ var tmp0_subject = freeIndex[p + 1 | 0] - i | 0;
3676
+ if (tmp0_subject === 1) {
3677
+ f1[p] = energy.h1__1[i];
3678
+ } else if (tmp0_subject === 2) {
3679
+ f1[p] = energy.h2__1[i];
3680
+ }
3681
+ }
3682
+ if ((p + 2 | 0) < freeCount && (freeIndex[p + 2 | 0] - i | 0) === 2) {
3683
+ f2[p] = energy.h2__1[i];
3684
+ }
3685
+ }
3686
+ while (inductionVariable < freeCount);
3687
+ }
3688
+ function OffsetQp() {
3689
+ this.ARMIJO_C1__1 = 1.0E-4;
3690
+ this.MAX_BACKTRACKS_1 = 20;
3691
+ }
3692
+ protoOf(OffsetQp).solve_j37bz7_k$ = function (energy, lo, hi, seed, maxIterations, gradientTolerance, boundEpsilonM) {
3693
+ var n = energy.get_size_woubt6_k$();
3694
+ var tmp = 0;
3695
+ var tmp_0 = new Float64Array(n);
3696
+ while (tmp < n) {
3697
+ var tmp_1 = tmp;
3698
+ tmp_0[tmp_1] = coerceIn(seed[tmp_1], lo[tmp_1], hi[tmp_1]);
3699
+ tmp = tmp + 1 | 0;
3700
+ }
3701
+ var x = tmp_0;
3702
+ var g = new Float64Array(n);
3703
+ var scratch = new Float64Array(n);
3704
+ var direction = new Float64Array(n);
3705
+ var candidate = new Float64Array(n);
3706
+ energy.gradient_zecmby_k$(x, g);
3707
+ var referenceGradient = 0.0;
3708
+ var inductionVariable = 0;
3709
+ if (inductionVariable < n)
3710
+ do {
3711
+ var i = inductionVariable;
3712
+ inductionVariable = inductionVariable + 1 | 0;
3713
+ var tmp_2;
3714
+ if (isFree(this, x[i], lo[i], hi[i], g[i], boundEpsilonM)) {
3715
+ // Inline function 'kotlin.math.abs' call
3716
+ var x_0 = g[i];
3717
+ tmp_2 = Math.abs(x_0) > referenceGradient;
3718
+ } else {
3719
+ tmp_2 = false;
3720
+ }
3721
+ if (tmp_2) {
3722
+ // Inline function 'kotlin.math.abs' call
3723
+ var x_1 = g[i];
3724
+ referenceGradient = Math.abs(x_1);
3725
+ }
3726
+ }
3727
+ while (inductionVariable < n);
3728
+ if (referenceGradient <= 0.0)
3729
+ referenceGradient = 1.0;
3730
+ var iterations = 0;
3731
+ var converged = false;
3732
+ var relativeResidual = 0.0;
3733
+ var freeIndex = new Int32Array(n);
3734
+ var f0 = new Float64Array(n);
3735
+ var f1 = new Float64Array(n);
3736
+ var f2 = new Float64Array(n);
3737
+ var rhs = new Float64Array(n);
3738
+ $l$loop_3: while (iterations < maxIterations) {
3739
+ energy.gradient_zecmby_k$(x, g);
3740
+ var freeCount = 0;
3741
+ var residual = 0.0;
3742
+ var inductionVariable_0 = 0;
3743
+ if (inductionVariable_0 < n)
3744
+ do {
3745
+ var i_0 = inductionVariable_0;
3746
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
3747
+ if (isFree(this, x[i_0], lo[i_0], hi[i_0], g[i_0], boundEpsilonM)) {
3748
+ var _unary__edvuaz = freeCount;
3749
+ freeCount = _unary__edvuaz + 1 | 0;
3750
+ freeIndex[_unary__edvuaz] = i_0;
3751
+ // Inline function 'kotlin.math.abs' call
3752
+ var x_2 = g[i_0];
3753
+ if (Math.abs(x_2) > residual) {
3754
+ // Inline function 'kotlin.math.abs' call
3755
+ var x_3 = g[i_0];
3756
+ residual = Math.abs(x_3);
3757
+ }
3758
+ }
3759
+ }
3760
+ while (inductionVariable_0 < n);
3761
+ relativeResidual = residual / referenceGradient;
3762
+ if (freeCount === 0 || relativeResidual <= gradientTolerance) {
3763
+ converged = true;
3764
+ break $l$loop_3;
3765
+ }
3766
+ buildFreeSystem(this, energy, freeIndex, freeCount, f0, f1, f2);
3767
+ var fa0 = copyOf(f0, freeCount);
3768
+ var fa1 = copyOf(f1, freeCount);
3769
+ var fa2 = copyOf(f2, freeCount);
3770
+ if (!BandedLdl_instance.factor_n459o6_k$(fa0, fa1, fa2)) {
3771
+ break $l$loop_3;
3772
+ }
3773
+ var inductionVariable_1 = 0;
3774
+ var last = freeCount;
3775
+ if (inductionVariable_1 < last)
3776
+ do {
3777
+ var p = inductionVariable_1;
3778
+ inductionVariable_1 = inductionVariable_1 + 1 | 0;
3779
+ rhs[p] = -g[freeIndex[p]];
3780
+ }
3781
+ while (inductionVariable_1 < last);
3782
+ BandedLdl_instance.solveInPlace_jrw92v_k$(fa0, fa1, fa2, rhs);
3783
+ var inductionVariable_2 = 0;
3784
+ if (inductionVariable_2 < n)
3785
+ do {
3786
+ var i_1 = inductionVariable_2;
3787
+ inductionVariable_2 = inductionVariable_2 + 1 | 0;
3788
+ direction[i_1] = 0.0;
3789
+ }
3790
+ while (inductionVariable_2 < n);
3791
+ var inductionVariable_3 = 0;
3792
+ var last_0 = freeCount;
3793
+ if (inductionVariable_3 < last_0)
3794
+ do {
3795
+ var p_0 = inductionVariable_3;
3796
+ inductionVariable_3 = inductionVariable_3 + 1 | 0;
3797
+ direction[freeIndex[p_0]] = rhs[p_0];
3798
+ }
3799
+ while (inductionVariable_3 < last_0);
3800
+ var directionalDerivative = 0.0;
3801
+ var inductionVariable_4 = 0;
3802
+ var last_1 = freeCount;
3803
+ if (inductionVariable_4 < last_1)
3804
+ do {
3805
+ var p_1 = inductionVariable_4;
3806
+ inductionVariable_4 = inductionVariable_4 + 1 | 0;
3807
+ var i_2 = freeIndex[p_1];
3808
+ directionalDerivative = directionalDerivative + g[i_2] * direction[i_2];
3809
+ }
3810
+ while (inductionVariable_4 < last_1);
3811
+ if (directionalDerivative >= 0.0)
3812
+ break $l$loop_3;
3813
+ var current = energy.value_6wg803_k$(x, scratch);
3814
+ var step = 1.0;
3815
+ var accepted = false;
3816
+ var inductionVariable_5 = 0;
3817
+ if (inductionVariable_5 < 20)
3818
+ $l$loop_2: do {
3819
+ var attempt = inductionVariable_5;
3820
+ inductionVariable_5 = inductionVariable_5 + 1 | 0;
3821
+ var inductionVariable_6 = 0;
3822
+ if (inductionVariable_6 < n)
3823
+ do {
3824
+ var i_3 = inductionVariable_6;
3825
+ inductionVariable_6 = inductionVariable_6 + 1 | 0;
3826
+ candidate[i_3] = coerceIn(x[i_3] + step * direction[i_3], lo[i_3], hi[i_3]);
3827
+ }
3828
+ while (inductionVariable_6 < n);
3829
+ var trial = energy.value_6wg803_k$(candidate, scratch);
3830
+ if (trial <= current + 1.0E-4 * step * directionalDerivative) {
3831
+ accepted = true;
3832
+ break $l$loop_2;
3833
+ }
3834
+ step = step / 2.0;
3835
+ }
3836
+ while (inductionVariable_5 < 20);
3837
+ if (!accepted)
3838
+ break $l$loop_3;
3839
+ // Inline function 'kotlin.collections.copyInto' call
3840
+ var endIndex = candidate.length;
3841
+ // Inline function 'kotlin.js.unsafeCast' call
3842
+ // Inline function 'kotlin.js.asDynamic' call
3843
+ var tmp_3 = candidate;
3844
+ // Inline function 'kotlin.js.unsafeCast' call
3845
+ // Inline function 'kotlin.js.asDynamic' call
3846
+ arrayCopy(tmp_3, x, 0, 0, endIndex);
3847
+ iterations = iterations + 1 | 0;
3848
+ }
3849
+ var active = 0;
3850
+ var inductionVariable_7 = 0;
3851
+ if (inductionVariable_7 < n)
3852
+ do {
3853
+ var i_4 = inductionVariable_7;
3854
+ inductionVariable_7 = inductionVariable_7 + 1 | 0;
3855
+ if (x[i_4] <= lo[i_4] + boundEpsilonM || x[i_4] >= hi[i_4] - boundEpsilonM) {
3856
+ active = active + 1 | 0;
3857
+ }
3858
+ }
3859
+ while (inductionVariable_7 < n);
3860
+ return new QpResult(x, iterations, relativeResidual, converged, active);
3861
+ };
3862
+ var OffsetQp_instance;
3863
+ function OffsetQp_getInstance() {
3864
+ return OffsetQp_instance;
3865
+ }
3866
+ function Companion_12() {
3867
+ Companion_instance_13 = this;
3868
+ this.DEFAULT_1 = new CurvatureOptions();
3869
+ }
3870
+ var Companion_instance_13;
3871
+ function Companion_getInstance_15() {
3872
+ if (Companion_instance_13 == null)
3873
+ new Companion_12();
3874
+ return Companion_instance_13;
3875
+ }
3876
+ function CurvatureOptions(enabled, geometrySmoothWindowM, curvatureWindowsM, headingNoiseRad, curvatureSmoothWindowM) {
3877
+ Companion_getInstance_15();
3878
+ enabled = enabled === VOID ? true : enabled;
3879
+ geometrySmoothWindowM = geometrySmoothWindowM === VOID ? 3.0 : geometrySmoothWindowM;
3880
+ curvatureWindowsM = curvatureWindowsM === VOID ? listOf_0([3.0, 6.0, 12.0, 25.0]) : curvatureWindowsM;
3881
+ headingNoiseRad = headingNoiseRad === VOID ? 0.05 : headingNoiseRad;
3882
+ curvatureSmoothWindowM = curvatureSmoothWindowM === VOID ? 3.0 : curvatureSmoothWindowM;
3883
+ this.enabled_1 = enabled;
3884
+ this.geometrySmoothWindowM_1 = geometrySmoothWindowM;
3885
+ this.curvatureWindowsM_1 = curvatureWindowsM;
3886
+ this.headingNoiseRad_1 = headingNoiseRad;
3887
+ this.curvatureSmoothWindowM_1 = curvatureSmoothWindowM;
3888
+ // Inline function 'kotlin.require' call
3889
+ if (!(this.geometrySmoothWindowM_1 >= 0.0)) {
3890
+ var message = 'geometrySmoothWindowM must be >= 0';
3891
+ throw IllegalArgumentException_init_$Create$(toString(message));
3892
+ }
3893
+ // Inline function 'kotlin.collections.isNotEmpty' call
3894
+ // Inline function 'kotlin.require' call
3895
+ if (!!this.curvatureWindowsM_1.isEmpty_y1axqb_k$()) {
3896
+ var message_0 = 'at least one curvature window is required';
3897
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
3898
+ }
3899
+ var tmp0 = this.curvatureWindowsM_1;
3900
+ var tmp$ret$5;
3901
+ $l$block_0: {
3902
+ // Inline function 'kotlin.collections.all' call
3903
+ var tmp;
3904
+ if (isInterface(tmp0, Collection)) {
3905
+ tmp = tmp0.isEmpty_y1axqb_k$();
3906
+ } else {
3907
+ tmp = false;
3908
+ }
3909
+ if (tmp) {
3910
+ tmp$ret$5 = true;
3911
+ break $l$block_0;
3912
+ }
3913
+ var _iterator__ex2g4s = tmp0.iterator_jk1svi_k$();
3914
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
3915
+ var element = _iterator__ex2g4s.next_20eer_k$();
3916
+ if (!(element > 0.0)) {
3917
+ tmp$ret$5 = false;
3918
+ break $l$block_0;
3919
+ }
3920
+ }
3921
+ tmp$ret$5 = true;
3922
+ }
3923
+ // Inline function 'kotlin.require' call
3924
+ if (!tmp$ret$5) {
3925
+ var message_1 = 'curvature windows must be positive';
3926
+ throw IllegalArgumentException_init_$Create$(toString(message_1));
3927
+ }
3928
+ var tmp0_0 = zipWithNext(this.curvatureWindowsM_1);
3929
+ var tmp$ret$9;
3930
+ $l$block_2: {
3931
+ // Inline function 'kotlin.collections.all' call
3932
+ var tmp_0;
3933
+ if (isInterface(tmp0_0, Collection)) {
3934
+ tmp_0 = tmp0_0.isEmpty_y1axqb_k$();
3935
+ } else {
3936
+ tmp_0 = false;
3937
+ }
3938
+ if (tmp_0) {
3939
+ tmp$ret$9 = true;
3940
+ break $l$block_2;
3941
+ }
3942
+ var _iterator__ex2g4s_0 = tmp0_0.iterator_jk1svi_k$();
3943
+ while (_iterator__ex2g4s_0.hasNext_bitz1p_k$()) {
3944
+ var element_0 = _iterator__ex2g4s_0.next_20eer_k$();
3945
+ var a = element_0.component1_7eebsc_k$();
3946
+ var b = element_0.component2_7eebsb_k$();
3947
+ if (!(a < b)) {
3948
+ tmp$ret$9 = false;
3949
+ break $l$block_2;
3950
+ }
3951
+ }
3952
+ tmp$ret$9 = true;
3953
+ }
3954
+ // Inline function 'kotlin.require' call
3955
+ if (!tmp$ret$9) {
3956
+ var message_2 = 'curvature windows must be strictly ascending: ' + toString(this.curvatureWindowsM_1);
3957
+ throw IllegalArgumentException_init_$Create$(toString(message_2));
3958
+ }
3959
+ // Inline function 'kotlin.require' call
3960
+ if (!(this.headingNoiseRad_1 > 0.0)) {
3961
+ var message_3 = 'headingNoiseRad must be positive';
3962
+ throw IllegalArgumentException_init_$Create$(toString(message_3));
3963
+ }
3964
+ // Inline function 'kotlin.require' call
3965
+ if (!(this.curvatureSmoothWindowM_1 >= 0.0)) {
3966
+ var message_4 = 'curvatureSmoothWindowM must be >= 0';
3967
+ throw IllegalArgumentException_init_$Create$(toString(message_4));
3968
+ }
3969
+ }
3970
+ protoOf(CurvatureOptions).copy_8k70ek_k$ = function (enabled, geometrySmoothWindowM, curvatureWindowsM, headingNoiseRad, curvatureSmoothWindowM) {
3971
+ return new CurvatureOptions(enabled, geometrySmoothWindowM, curvatureWindowsM, headingNoiseRad, curvatureSmoothWindowM);
3972
+ };
3973
+ protoOf(CurvatureOptions).copy$default_7y8gcg_k$ = function (enabled, geometrySmoothWindowM, curvatureWindowsM, headingNoiseRad, curvatureSmoothWindowM, $super) {
3974
+ enabled = enabled === VOID ? this.enabled_1 : enabled;
3975
+ geometrySmoothWindowM = geometrySmoothWindowM === VOID ? this.geometrySmoothWindowM_1 : geometrySmoothWindowM;
3976
+ curvatureWindowsM = curvatureWindowsM === VOID ? this.curvatureWindowsM_1 : curvatureWindowsM;
3977
+ headingNoiseRad = headingNoiseRad === VOID ? this.headingNoiseRad_1 : headingNoiseRad;
3978
+ curvatureSmoothWindowM = curvatureSmoothWindowM === VOID ? this.curvatureSmoothWindowM_1 : curvatureSmoothWindowM;
3979
+ return $super === VOID ? this.copy_8k70ek_k$(enabled, geometrySmoothWindowM, curvatureWindowsM, headingNoiseRad, curvatureSmoothWindowM) : $super.copy_8k70ek_k$.call(this, enabled, geometrySmoothWindowM, curvatureWindowsM, headingNoiseRad, curvatureSmoothWindowM);
3980
+ };
3981
+ protoOf(CurvatureOptions).toString = function () {
3982
+ return 'CurvatureOptions(enabled=' + this.enabled_1 + ', geometrySmoothWindowM=' + this.geometrySmoothWindowM_1 + ', curvatureWindowsM=' + toString(this.curvatureWindowsM_1) + ', headingNoiseRad=' + this.headingNoiseRad_1 + ', curvatureSmoothWindowM=' + this.curvatureSmoothWindowM_1 + ')';
3983
+ };
3984
+ protoOf(CurvatureOptions).hashCode = function () {
3985
+ var result = getBooleanHashCode(this.enabled_1);
3986
+ result = imul(result, 31) + getNumberHashCode(this.geometrySmoothWindowM_1) | 0;
3987
+ result = imul(result, 31) + hashCode(this.curvatureWindowsM_1) | 0;
3988
+ result = imul(result, 31) + getNumberHashCode(this.headingNoiseRad_1) | 0;
3989
+ result = imul(result, 31) + getNumberHashCode(this.curvatureSmoothWindowM_1) | 0;
3990
+ return result;
3991
+ };
3992
+ protoOf(CurvatureOptions).equals = function (other) {
3993
+ if (this === other)
3994
+ return true;
3995
+ if (!(other instanceof CurvatureOptions))
3996
+ return false;
3997
+ if (!(this.enabled_1 === other.enabled_1))
3998
+ return false;
3999
+ if (!equals(this.geometrySmoothWindowM_1, other.geometrySmoothWindowM_1))
4000
+ return false;
4001
+ if (!equals(this.curvatureWindowsM_1, other.curvatureWindowsM_1))
4002
+ return false;
4003
+ if (!equals(this.headingNoiseRad_1, other.headingNoiseRad_1))
4004
+ return false;
4005
+ if (!equals(this.curvatureSmoothWindowM_1, other.curvatureSmoothWindowM_1))
1938
4006
  return false;
1939
4007
  return true;
1940
4008
  };
1941
- function WindProviderNone() {
4009
+ function PathCurvature() {
1942
4010
  }
1943
- protoOf(WindProviderNone).wind_umf2tf_k$ = function (course, path, pointIndex) {
1944
- return Companion_getInstance_10().NONE_1;
4011
+ protoOf(PathCurvature).compute_s9yd16_k$ = function (path, options) {
4012
+ if (!options.enabled_1)
4013
+ return false;
4014
+ var tmp0_elvis_lhs = LocalFrame_instance.project_n982lp_k$(path, options.geometrySmoothWindowM_1);
4015
+ var tmp;
4016
+ if (tmp0_elvis_lhs == null) {
4017
+ return false;
4018
+ } else {
4019
+ tmp = tmp0_elvis_lhs;
4020
+ }
4021
+ var frame = tmp;
4022
+ CurvatureEstimator_instance.computeHeadings_ev7p13_k$(frame);
4023
+ CurvatureEstimator_instance.computeCurvature_emiphc_k$(frame, toDoubleArray(options.curvatureWindowsM_1), options.headingNoiseRad_1, options.curvatureSmoothWindowM_1);
4024
+ var inductionVariable = 0;
4025
+ var last = path.size_1;
4026
+ if (inductionVariable < last)
4027
+ do {
4028
+ var i = inductionVariable;
4029
+ inductionVariable = inductionVariable + 1 | 0;
4030
+ path.setTrajectoryCurvature_yjmp8s_k$(i, frame.kappa_1[i]);
4031
+ }
4032
+ while (inductionVariable < last);
4033
+ return true;
1945
4034
  };
1946
- var WindProviderNone_instance;
1947
- function WindProviderNone_getInstance() {
1948
- return WindProviderNone_instance;
1949
- }
1950
- function WindProviderConstant(wind) {
1951
- this.wind_1 = wind;
1952
- }
1953
- protoOf(WindProviderConstant).wind_umf2tf_k$ = function (course, path, pointIndex) {
1954
- return this.wind_1;
4035
+ var PathCurvature_instance;
4036
+ function PathCurvature_getInstance() {
4037
+ return PathCurvature_instance;
4038
+ }
4039
+ function PlanarFrame(x, y, s, theta, kappa, lat0, lon0, k) {
4040
+ this.x_1 = x;
4041
+ this.y_1 = y;
4042
+ this.s_1 = s;
4043
+ this.theta_1 = theta;
4044
+ this.kappa_1 = kappa;
4045
+ this.lat0__1 = lat0;
4046
+ this.lon0__1 = lon0;
4047
+ this.k_1 = k;
4048
+ }
4049
+ protoOf(PlanarFrame).get_size_woubt6_k$ = function () {
4050
+ return this.x_1.length;
1955
4051
  };
1956
- function WPrimeBalanceComputer() {
1957
- }
1958
- protoOf(WPrimeBalanceComputer).compute_ewvoaz_k$ = function (path, options) {
1959
- if (path.size_1 === 0)
1960
- return Unit_instance;
1961
- var cp = options.criticalPowerW_1;
1962
- var wPrime = options.wPrimeJ_1;
1963
- var balance = wPrime;
1964
- path.setWPrimeBalance_stwqkw_k$(0, balance);
1965
- var inductionVariable = 1;
1966
- var last = path.size_1;
4052
+ function RacingLineReport(size, corners, centerlineCurvature, corridorLo, corridorHi, roadHalfWidthM, lateralOffsetM, trajectoryCurvature, newtonIterations, relativeGradient, converged, activeConstraints) {
4053
+ this.size_1 = size;
4054
+ this.corners_1 = corners;
4055
+ this.centerlineCurvature_1 = centerlineCurvature;
4056
+ this.corridorLo_1 = corridorLo;
4057
+ this.corridorHi_1 = corridorHi;
4058
+ this.roadHalfWidthM_1 = roadHalfWidthM;
4059
+ this.lateralOffsetM_1 = lateralOffsetM;
4060
+ this.trajectoryCurvature_1 = trajectoryCurvature;
4061
+ this.newtonIterations_1 = newtonIterations;
4062
+ this.relativeGradient_1 = relativeGradient;
4063
+ this.converged_1 = converged;
4064
+ this.activeConstraints_1 = activeConstraints;
4065
+ }
4066
+ protoOf(RacingLineReport).get_maxCorridorWidthM_7bycoc_k$ = function () {
4067
+ var m = 0.0;
4068
+ var inductionVariable = 0;
4069
+ var last = this.size_1;
1967
4070
  if (inductionVariable < last)
1968
4071
  do {
1969
4072
  var i = inductionVariable;
1970
4073
  inductionVariable = inductionVariable + 1 | 0;
1971
- var dtSeconds = (path.time_ryc845_k$(i) - path.time_ryc845_k$(i - 1 | 0)) / 1000.0;
1972
- var power = path.pComputedPower_g6dnn4_k$(i);
1973
- if (isFinite(dtSeconds) && dtSeconds > 0.0 && isFinite(power)) {
1974
- balance = this.step_447nu7_k$(balance, power, cp, wPrime, dtSeconds);
4074
+ var w = this.corridorHi_1[i] - this.corridorLo_1[i];
4075
+ if (w > m)
4076
+ m = w;
4077
+ }
4078
+ while (inductionVariable < last);
4079
+ return m;
4080
+ };
4081
+ function project($this, path, options) {
4082
+ var tmp0_elvis_lhs = LocalFrame_instance.project_n982lp_k$(path, options.curvature_1.geometrySmoothWindowM_1);
4083
+ var tmp;
4084
+ if (tmp0_elvis_lhs == null) {
4085
+ return null;
4086
+ } else {
4087
+ tmp = tmp0_elvis_lhs;
4088
+ }
4089
+ var frame = tmp;
4090
+ CurvatureEstimator_instance.computeHeadings_ev7p13_k$(frame);
4091
+ CurvatureEstimator_instance.computeCurvature_emiphc_k$(frame, toDoubleArray(options.curvature_1.curvatureWindowsM_1), options.curvature_1.headingNoiseRad_1, options.curvature_1.curvatureSmoothWindowM_1);
4092
+ return frame;
4093
+ }
4094
+ function analyzeFrame($this, path, frame, options) {
4095
+ var width = Corridor_instance.resolveWidth_feg61f_k$(path, frame, options);
4096
+ var corners = CornerDetector_instance.detect_cq5dkx_k$(frame, options, width);
4097
+ var bounds = Corridor_instance.build_fyfb0s_k$(frame, width, options);
4098
+ var tmp = 0;
4099
+ var tmp_0 = frame.get_size_woubt6_k$();
4100
+ var tmp_1 = new Float64Array(tmp_0);
4101
+ while (tmp < tmp_0) {
4102
+ var tmp_2 = tmp;
4103
+ tmp_1[tmp_2] = coerceIn(0.0, bounds.lo_1[tmp_2], bounds.hi_1[tmp_2]);
4104
+ tmp = tmp + 1 | 0;
4105
+ }
4106
+ var center = tmp_1;
4107
+ var objectiveKappa = 1.0 / options.objectiveRadiusM_1;
4108
+ var tmp_3 = 0;
4109
+ var tmp_4 = frame.get_size_woubt6_k$();
4110
+ var tmp_5 = new Float64Array(tmp_4);
4111
+ while (tmp_3 < tmp_4) {
4112
+ var tmp_6 = tmp_3;
4113
+ var tmp_7;
4114
+ // Inline function 'kotlin.math.abs' call
4115
+ var x = frame.kappa_1[tmp_6];
4116
+ if (Math.abs(x) > objectiveKappa) {
4117
+ tmp_7 = 1.0;
4118
+ } else {
4119
+ tmp_7 = 0.0;
4120
+ }
4121
+ tmp_5[tmp_6] = tmp_7;
4122
+ tmp_3 = tmp_3 + 1 | 0;
4123
+ }
4124
+ var rho = tmp_5;
4125
+ var energy = Companion_instance_12.assemble_miimn7_k$(frame, center, rho, options.steeringLengthM_1, options.centeringLengthM_1);
4126
+ var seed = center;
4127
+ var solved = OffsetQp_instance.solve_j37bz7_k$(energy, bounds.lo_1, bounds.hi_1, seed, options.maxNewtonIterations_1, options.gradientTolerance_1, options.boundEpsilonM_1);
4128
+ var trajectoryCurvature = measureOffsetCurvature($this, frame, solved.offset_1, options);
4129
+ var tmp_8 = frame.get_size_woubt6_k$();
4130
+ // Inline function 'kotlin.collections.copyOf' call
4131
+ // Inline function 'kotlin.js.asDynamic' call
4132
+ var tmp$ret$3 = frame.kappa_1.slice();
4133
+ return new RacingLineReport(tmp_8, corners, tmp$ret$3, bounds.lo_1, bounds.hi_1, bounds.halfWidthM_1, solved.offset_1, trajectoryCurvature, solved.iterations_1, solved.gradientInfNorm_1, solved.converged_1, solved.activeConstraints_1);
4134
+ }
4135
+ function measureOffsetCurvature($this, frame, offset, options) {
4136
+ var size = frame.get_size_woubt6_k$();
4137
+ var x = new Float64Array(size);
4138
+ var y = new Float64Array(size);
4139
+ var inductionVariable = 0;
4140
+ if (inductionVariable < size)
4141
+ do {
4142
+ var i = inductionVariable;
4143
+ inductionVariable = inductionVariable + 1 | 0;
4144
+ var tmp = frame.x_1[i];
4145
+ var tmp_0 = offset[i];
4146
+ // Inline function 'kotlin.math.sin' call
4147
+ var x_0 = frame.theta_1[i];
4148
+ x[i] = tmp - tmp_0 * Math.sin(x_0);
4149
+ var tmp_1 = frame.y_1[i];
4150
+ var tmp_2 = offset[i];
4151
+ // Inline function 'kotlin.math.cos' call
4152
+ var x_1 = frame.theta_1[i];
4153
+ y[i] = tmp_1 + tmp_2 * Math.cos(x_1);
4154
+ }
4155
+ while (inductionVariable < size);
4156
+ var s = new Float64Array(size);
4157
+ LocalFrame_instance.arclengthOf_yiuhr5_k$(x, y, s);
4158
+ var line = new PlanarFrame(x, y, s, new Float64Array(size), new Float64Array(size), frame.lat0__1, frame.lon0__1, frame.k_1);
4159
+ CurvatureEstimator_instance.computeHeadings_ev7p13_k$(line);
4160
+ CurvatureEstimator_instance.computeCurvature_emiphc_k$(line, toDoubleArray(options.curvature_1.curvatureWindowsM_1), options.curvature_1.headingNoiseRad_1, options.curvature_1.curvatureSmoothWindowM_1);
4161
+ return line.kappa_1;
4162
+ }
4163
+ function RacingLine() {
4164
+ }
4165
+ protoOf(RacingLine).analyze_ikwae4_k$ = function (path, options) {
4166
+ var tmp0_elvis_lhs = project(this, path, options);
4167
+ var tmp;
4168
+ if (tmp0_elvis_lhs == null) {
4169
+ return null;
4170
+ } else {
4171
+ tmp = tmp0_elvis_lhs;
4172
+ }
4173
+ var frame = tmp;
4174
+ return analyzeFrame(this, path, frame, options);
4175
+ };
4176
+ protoOf(RacingLine).compute_uyx32p_k$ = function (source, options) {
4177
+ var tmp0_elvis_lhs = project(this, source, options);
4178
+ var tmp;
4179
+ if (tmp0_elvis_lhs == null) {
4180
+ return source.copy_1tks5_k$();
4181
+ } else {
4182
+ tmp = tmp0_elvis_lhs;
4183
+ }
4184
+ var frame = tmp;
4185
+ var report = analyzeFrame(this, source, frame, options);
4186
+ var out = new Path(source.size_1);
4187
+ var inductionVariable = 0;
4188
+ var last = source.size_1;
4189
+ if (inductionVariable < last)
4190
+ do {
4191
+ var i = inductionVariable;
4192
+ inductionVariable = inductionVariable + 1 | 0;
4193
+ var _iterator__ex2g4s = get_entries().iterator_jk1svi_k$();
4194
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
4195
+ var field = _iterator__ex2g4s.next_20eer_k$();
4196
+ out.set_b3ze83_k$(i, field, source.get_z3le6l_k$(i, field));
1975
4197
  }
1976
- path.setWPrimeBalance_stwqkw_k$(i, balance);
1977
4198
  }
1978
4199
  while (inductionVariable < last);
4200
+ var inductionVariable_0 = 0;
4201
+ var last_0 = source.size_1;
4202
+ if (inductionVariable_0 < last_0)
4203
+ do {
4204
+ var i_0 = inductionVariable_0;
4205
+ inductionVariable_0 = inductionVariable_0 + 1 | 0;
4206
+ var n = report.lateralOffsetM_1[i_0];
4207
+ // Inline function 'kotlin.math.sin' call
4208
+ var x = frame.theta_1[i_0];
4209
+ var nx = -Math.sin(x);
4210
+ // Inline function 'kotlin.math.cos' call
4211
+ var x_0 = frame.theta_1[i_0];
4212
+ var ny = Math.cos(x_0);
4213
+ var x_1 = frame.x_1[i_0] + n * nx;
4214
+ var y = frame.y_1[i_0] + n * ny;
4215
+ out.setSourceLatitude_jzh9ix_k$(i_0, source.latitude_gb4iok_k$(i_0));
4216
+ out.setSourceLongitude_xmvvyo_k$(i_0, source.longitude_a9xl_k$(i_0));
4217
+ var latLon = LocalFrame_instance.unproject_ym27oh_k$(frame, x_1, y);
4218
+ out.setLatitude_skkzf0_k$(i_0, latLon[0]);
4219
+ out.setLongitude_k0bc8l_k$(i_0, latLon[1]);
4220
+ out.setLateralOffset_k5uegq_k$(i_0, n);
4221
+ out.setTrajectoryCurvature_yjmp8s_k$(i_0, report.trajectoryCurvature_1[i_0]);
4222
+ out.setRoadWidth_g0vcte_k$(i_0, source.roadWidth_7zv9qq_k$(i_0));
4223
+ }
4224
+ while (inductionVariable_0 < last_0);
4225
+ out.computeDerivedData_uoxpeo_k$();
4226
+ PathCurvature_instance.compute_s9yd16_k$(out, options.curvature_1.copy$default_7y8gcg_k$(true));
4227
+ return out;
1979
4228
  };
1980
- protoOf(WPrimeBalanceComputer).step_447nu7_k$ = function (balance, power, cp, wPrime, dtSeconds) {
4229
+ var RacingLine_instance;
4230
+ function RacingLine_getInstance() {
4231
+ return RacingLine_instance;
4232
+ }
4233
+ function CorridorMode$Companion$byId$lambda(it) {
4234
+ return it.get_id_kntnx8_k$();
4235
+ }
4236
+ var static_init_called_1;
4237
+ function static_init_1() {
4238
+ if (static_init_called_1)
4239
+ return Unit_instance;
4240
+ static_init_called_1 = true;
4241
+ CorridorMode_LANE_instance = new CorridorMode('LANE', 0);
4242
+ CorridorMode_LANE_LEFT_instance = new CorridorMode('LANE_LEFT', 1);
4243
+ CorridorMode_FULL_ROAD_instance = new CorridorMode('FULL_ROAD', 2);
4244
+ if (Companion_instance_14 == null) {
4245
+ Companion_instance;
4246
+ new Companion_13();
4247
+ }
4248
+ }
4249
+ var CorridorMode_LANE_instance;
4250
+ var CorridorMode_LANE_LEFT_instance;
4251
+ var CorridorMode_FULL_ROAD_instance;
4252
+ function Companion_13() {
4253
+ }
4254
+ protoOf(Companion_13).byId_8gmd94_k$ = function (name) {
4255
+ var tmp0 = get_entries_2();
4256
+ var tmp$ret$0;
4257
+ $l$block: {
4258
+ // Inline function 'kotlin.collections.firstOrNull' call
4259
+ var _iterator__ex2g4s = tmp0.iterator_jk1svi_k$();
4260
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
4261
+ var element = _iterator__ex2g4s.next_20eer_k$();
4262
+ if (equals_0(element.get_id_kntnx8_k$(), name, true) || equals_0(element.name_1, name, true)) {
4263
+ tmp$ret$0 = element;
4264
+ break $l$block;
4265
+ }
4266
+ }
4267
+ tmp$ret$0 = null;
4268
+ }
4269
+ var tmp0_elvis_lhs = tmp$ret$0;
1981
4270
  var tmp;
1982
- if (power >= cp) {
1983
- tmp = balance - (power - cp) * dtSeconds;
4271
+ if (tmp0_elvis_lhs == null) {
4272
+ var tmp_0 = get_entries_2();
4273
+ throw IllegalArgumentException_init_$Create$("Unknown corridor '" + name + "': expected one of " + joinToString(tmp_0, ', ', VOID, VOID, VOID, VOID, CorridorMode$Companion$byId$lambda));
1984
4274
  } else {
1985
- var tmp_0 = wPrime - balance;
1986
- // Inline function 'kotlin.math.exp' call
1987
- var x = -(cp - power) * dtSeconds / wPrime;
1988
- tmp = wPrime - tmp_0 * Math.exp(x);
4275
+ tmp = tmp0_elvis_lhs;
1989
4276
  }
1990
- var next = tmp;
1991
- // Inline function 'kotlin.math.max' call
1992
- // Inline function 'kotlin.math.min' call
1993
- var b = Math.max(0.0, next);
1994
- return Math.min(wPrime, b);
4277
+ return tmp;
1995
4278
  };
1996
- var WPrimeBalanceComputer_instance;
1997
- function WPrimeBalanceComputer_getInstance() {
1998
- return WPrimeBalanceComputer_instance;
4279
+ var Companion_instance_14;
4280
+ function Companion_getInstance_16() {
4281
+ return Companion_instance_14;
4282
+ }
4283
+ function values_1() {
4284
+ static_init_1();
4285
+ return [CorridorMode_LANE_getInstance(), CorridorMode_LANE_LEFT_getInstance(), CorridorMode_FULL_ROAD_getInstance()];
4286
+ }
4287
+ function get_entries_2() {
4288
+ static_init_1();
4289
+ if ($ENTRIES_1 == null)
4290
+ $ENTRIES_1 = enumEntries(values_1());
4291
+ return $ENTRIES_1;
4292
+ }
4293
+ var $ENTRIES_1;
4294
+ function CorridorMode(name, ordinal) {
4295
+ Enum.call(this, name, ordinal);
4296
+ }
4297
+ protoOf(CorridorMode).get_id_kntnx8_k$ = function () {
4298
+ var tmp;
4299
+ switch (this.ordinal_1) {
4300
+ case 0:
4301
+ tmp = 'lane';
4302
+ break;
4303
+ case 1:
4304
+ tmp = 'lane-left';
4305
+ break;
4306
+ case 2:
4307
+ tmp = 'full-road';
4308
+ break;
4309
+ default:
4310
+ noWhenBranchMatchedException();
4311
+ break;
4312
+ }
4313
+ return tmp;
4314
+ };
4315
+ var static_init_called_2;
4316
+ function static_init_2() {
4317
+ if (static_init_called_2)
4318
+ return Unit_instance;
4319
+ static_init_called_2 = true;
4320
+ CornerKind_GENTLE_instance = new CornerKind('GENTLE', 0);
4321
+ CornerKind_CORNER_instance = new CornerKind('CORNER', 1);
4322
+ CornerKind_HAIRPIN_instance = new CornerKind('HAIRPIN', 2);
4323
+ }
4324
+ var CornerKind_GENTLE_instance;
4325
+ var CornerKind_CORNER_instance;
4326
+ var CornerKind_HAIRPIN_instance;
4327
+ function CornerKind(name, ordinal) {
4328
+ Enum.call(this, name, ordinal);
4329
+ }
4330
+ function Companion_14() {
4331
+ Companion_instance_15 = this;
4332
+ this.DEFAULT_1 = new RacingLineOptions();
4333
+ }
4334
+ var Companion_instance_15;
4335
+ function Companion_getInstance_17() {
4336
+ if (Companion_instance_15 == null)
4337
+ new Companion_14();
4338
+ return Companion_instance_15;
4339
+ }
4340
+ function RacingLineOptions(enabled, defaultRoadWidthM, edgeMarginM, corridor, cornerEnterRadiusM, cornerExitRadiusM, minCornerLengthM, minCornerTurnDeg, hairpinTurnDeg, gentleRadiusM, regularityFactor, selfProximityGapM, straightRunM, straightRadiusM, widthSmoothWindowM, objectiveRadiusM, steeringLengthM, centeringLengthM, maxNewtonIterations, gradientTolerance, boundEpsilonM, curvature, simplifyToleranceCapM) {
4341
+ Companion_getInstance_17();
4342
+ enabled = enabled === VOID ? false : enabled;
4343
+ defaultRoadWidthM = defaultRoadWidthM === VOID ? 6.0 : defaultRoadWidthM;
4344
+ edgeMarginM = edgeMarginM === VOID ? 0.5 : edgeMarginM;
4345
+ corridor = corridor === VOID ? CorridorMode_LANE_getInstance() : corridor;
4346
+ cornerEnterRadiusM = cornerEnterRadiusM === VOID ? 120.0 : cornerEnterRadiusM;
4347
+ cornerExitRadiusM = cornerExitRadiusM === VOID ? 250.0 : cornerExitRadiusM;
4348
+ minCornerLengthM = minCornerLengthM === VOID ? 8.0 : minCornerLengthM;
4349
+ minCornerTurnDeg = minCornerTurnDeg === VOID ? 8.0 : minCornerTurnDeg;
4350
+ hairpinTurnDeg = hairpinTurnDeg === VOID ? 150.0 : hairpinTurnDeg;
4351
+ gentleRadiusM = gentleRadiusM === VOID ? 100.0 : gentleRadiusM;
4352
+ regularityFactor = regularityFactor === VOID ? 0.85 : regularityFactor;
4353
+ selfProximityGapM = selfProximityGapM === VOID ? 60.0 : selfProximityGapM;
4354
+ straightRunM = straightRunM === VOID ? 150.0 : straightRunM;
4355
+ straightRadiusM = straightRadiusM === VOID ? 500.0 : straightRadiusM;
4356
+ widthSmoothWindowM = widthSmoothWindowM === VOID ? 20.0 : widthSmoothWindowM;
4357
+ objectiveRadiusM = objectiveRadiusM === VOID ? 200.0 : objectiveRadiusM;
4358
+ steeringLengthM = steeringLengthM === VOID ? 20.0 : steeringLengthM;
4359
+ centeringLengthM = centeringLengthM === VOID ? 60.0 : centeringLengthM;
4360
+ maxNewtonIterations = maxNewtonIterations === VOID ? 200 : maxNewtonIterations;
4361
+ gradientTolerance = gradientTolerance === VOID ? 1.0E-8 : gradientTolerance;
4362
+ boundEpsilonM = boundEpsilonM === VOID ? 1.0E-6 : boundEpsilonM;
4363
+ curvature = curvature === VOID ? Companion_getInstance_15().DEFAULT_1 : curvature;
4364
+ simplifyToleranceCapM = simplifyToleranceCapM === VOID ? 2.0 : simplifyToleranceCapM;
4365
+ this.enabled_1 = enabled;
4366
+ this.defaultRoadWidthM_1 = defaultRoadWidthM;
4367
+ this.edgeMarginM_1 = edgeMarginM;
4368
+ this.corridor_1 = corridor;
4369
+ this.cornerEnterRadiusM_1 = cornerEnterRadiusM;
4370
+ this.cornerExitRadiusM_1 = cornerExitRadiusM;
4371
+ this.minCornerLengthM_1 = minCornerLengthM;
4372
+ this.minCornerTurnDeg_1 = minCornerTurnDeg;
4373
+ this.hairpinTurnDeg_1 = hairpinTurnDeg;
4374
+ this.gentleRadiusM_1 = gentleRadiusM;
4375
+ this.regularityFactor_1 = regularityFactor;
4376
+ this.selfProximityGapM_1 = selfProximityGapM;
4377
+ this.straightRunM_1 = straightRunM;
4378
+ this.straightRadiusM_1 = straightRadiusM;
4379
+ this.widthSmoothWindowM_1 = widthSmoothWindowM;
4380
+ this.objectiveRadiusM_1 = objectiveRadiusM;
4381
+ this.steeringLengthM_1 = steeringLengthM;
4382
+ this.centeringLengthM_1 = centeringLengthM;
4383
+ this.maxNewtonIterations_1 = maxNewtonIterations;
4384
+ this.gradientTolerance_1 = gradientTolerance;
4385
+ this.boundEpsilonM_1 = boundEpsilonM;
4386
+ this.curvature_1 = curvature;
4387
+ this.simplifyToleranceCapM_1 = simplifyToleranceCapM;
4388
+ // Inline function 'kotlin.require' call
4389
+ if (!(this.defaultRoadWidthM_1 > 0.0)) {
4390
+ var message = 'defaultRoadWidthM must be > 0';
4391
+ throw IllegalArgumentException_init_$Create$(toString(message));
4392
+ }
4393
+ // Inline function 'kotlin.require' call
4394
+ if (!(this.edgeMarginM_1 >= 0.0)) {
4395
+ var message_0 = 'edgeMarginM must be >= 0';
4396
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
4397
+ }
4398
+ // Inline function 'kotlin.require' call
4399
+ if (!(this.cornerEnterRadiusM_1 > 0.0 && this.cornerExitRadiusM_1 > 0.0)) {
4400
+ var message_1 = 'corner radii must be > 0';
4401
+ throw IllegalArgumentException_init_$Create$(toString(message_1));
4402
+ }
4403
+ // Inline function 'kotlin.require' call
4404
+ if (!(this.cornerExitRadiusM_1 >= this.cornerEnterRadiusM_1)) {
4405
+ var message_2 = 'cornerExitRadiusM (' + this.cornerExitRadiusM_1 + ') must be >= cornerEnterRadiusM ' + ('(' + this.cornerEnterRadiusM_1 + '): a corner has to be harder to open than to keep open, or ') + 'the hysteresis runs backwards and corners flicker';
4406
+ throw IllegalArgumentException_init_$Create$(toString(message_2));
4407
+ }
4408
+ // Inline function 'kotlin.require' call
4409
+ if (!(this.regularityFactor_1 > 0.0 && this.regularityFactor_1 < 1.0)) {
4410
+ var message_3 = 'regularityFactor must be in (0, 1) \u2014 at 1.0 the offset map folds';
4411
+ throw IllegalArgumentException_init_$Create$(toString(message_3));
4412
+ }
4413
+ // Inline function 'kotlin.require' call
4414
+ if (!(this.selfProximityGapM_1 > 0.0)) {
4415
+ var message_4 = 'selfProximityGapM must be > 0';
4416
+ throw IllegalArgumentException_init_$Create$(toString(message_4));
4417
+ }
4418
+ // Inline function 'kotlin.require' call
4419
+ if (!(this.widthSmoothWindowM_1 >= 0.0)) {
4420
+ var message_5 = 'widthSmoothWindowM must be >= 0';
4421
+ throw IllegalArgumentException_init_$Create$(toString(message_5));
4422
+ }
4423
+ // Inline function 'kotlin.require' call
4424
+ if (!(this.objectiveRadiusM_1 > 0.0)) {
4425
+ var message_6 = 'objectiveRadiusM must be > 0';
4426
+ throw IllegalArgumentException_init_$Create$(toString(message_6));
4427
+ }
4428
+ // Inline function 'kotlin.require' call
4429
+ if (!(this.steeringLengthM_1 > 0.0)) {
4430
+ var message_7 = 'steeringLengthM must be > 0';
4431
+ throw IllegalArgumentException_init_$Create$(toString(message_7));
4432
+ }
4433
+ // Inline function 'kotlin.require' call
4434
+ if (!(this.centeringLengthM_1 > 0.0)) {
4435
+ var message_8 = 'centeringLengthM must be > 0';
4436
+ throw IllegalArgumentException_init_$Create$(toString(message_8));
4437
+ }
4438
+ // Inline function 'kotlin.require' call
4439
+ if (!(this.maxNewtonIterations_1 > 0)) {
4440
+ var message_9 = 'maxNewtonIterations must be > 0';
4441
+ throw IllegalArgumentException_init_$Create$(toString(message_9));
4442
+ }
4443
+ // Inline function 'kotlin.require' call
4444
+ if (!(this.gradientTolerance_1 > 0.0)) {
4445
+ var message_10 = 'gradientTolerance must be > 0';
4446
+ throw IllegalArgumentException_init_$Create$(toString(message_10));
4447
+ }
4448
+ // Inline function 'kotlin.require' call
4449
+ if (!(this.boundEpsilonM_1 > 0.0)) {
4450
+ var message_11 = 'boundEpsilonM must be > 0';
4451
+ throw IllegalArgumentException_init_$Create$(toString(message_11));
4452
+ }
1999
4453
  }
4454
+ protoOf(RacingLineOptions).toString = function () {
4455
+ return 'RacingLineOptions(enabled=' + this.enabled_1 + ', defaultRoadWidthM=' + this.defaultRoadWidthM_1 + ', edgeMarginM=' + this.edgeMarginM_1 + ', corridor=' + this.corridor_1.toString() + ', cornerEnterRadiusM=' + this.cornerEnterRadiusM_1 + ', cornerExitRadiusM=' + this.cornerExitRadiusM_1 + ', minCornerLengthM=' + this.minCornerLengthM_1 + ', minCornerTurnDeg=' + this.minCornerTurnDeg_1 + ', hairpinTurnDeg=' + this.hairpinTurnDeg_1 + ', gentleRadiusM=' + this.gentleRadiusM_1 + ', regularityFactor=' + this.regularityFactor_1 + ', selfProximityGapM=' + this.selfProximityGapM_1 + ', straightRunM=' + this.straightRunM_1 + ', straightRadiusM=' + this.straightRadiusM_1 + ', widthSmoothWindowM=' + this.widthSmoothWindowM_1 + ', objectiveRadiusM=' + this.objectiveRadiusM_1 + ', steeringLengthM=' + this.steeringLengthM_1 + ', centeringLengthM=' + this.centeringLengthM_1 + ', maxNewtonIterations=' + this.maxNewtonIterations_1 + ', gradientTolerance=' + this.gradientTolerance_1 + ', boundEpsilonM=' + this.boundEpsilonM_1 + ', curvature=' + this.curvature_1.toString() + ', simplifyToleranceCapM=' + this.simplifyToleranceCapM_1 + ')';
4456
+ };
4457
+ protoOf(RacingLineOptions).hashCode = function () {
4458
+ var result = getBooleanHashCode(this.enabled_1);
4459
+ result = imul(result, 31) + getNumberHashCode(this.defaultRoadWidthM_1) | 0;
4460
+ result = imul(result, 31) + getNumberHashCode(this.edgeMarginM_1) | 0;
4461
+ result = imul(result, 31) + this.corridor_1.hashCode() | 0;
4462
+ result = imul(result, 31) + getNumberHashCode(this.cornerEnterRadiusM_1) | 0;
4463
+ result = imul(result, 31) + getNumberHashCode(this.cornerExitRadiusM_1) | 0;
4464
+ result = imul(result, 31) + getNumberHashCode(this.minCornerLengthM_1) | 0;
4465
+ result = imul(result, 31) + getNumberHashCode(this.minCornerTurnDeg_1) | 0;
4466
+ result = imul(result, 31) + getNumberHashCode(this.hairpinTurnDeg_1) | 0;
4467
+ result = imul(result, 31) + getNumberHashCode(this.gentleRadiusM_1) | 0;
4468
+ result = imul(result, 31) + getNumberHashCode(this.regularityFactor_1) | 0;
4469
+ result = imul(result, 31) + getNumberHashCode(this.selfProximityGapM_1) | 0;
4470
+ result = imul(result, 31) + getNumberHashCode(this.straightRunM_1) | 0;
4471
+ result = imul(result, 31) + getNumberHashCode(this.straightRadiusM_1) | 0;
4472
+ result = imul(result, 31) + getNumberHashCode(this.widthSmoothWindowM_1) | 0;
4473
+ result = imul(result, 31) + getNumberHashCode(this.objectiveRadiusM_1) | 0;
4474
+ result = imul(result, 31) + getNumberHashCode(this.steeringLengthM_1) | 0;
4475
+ result = imul(result, 31) + getNumberHashCode(this.centeringLengthM_1) | 0;
4476
+ result = imul(result, 31) + this.maxNewtonIterations_1 | 0;
4477
+ result = imul(result, 31) + getNumberHashCode(this.gradientTolerance_1) | 0;
4478
+ result = imul(result, 31) + getNumberHashCode(this.boundEpsilonM_1) | 0;
4479
+ result = imul(result, 31) + this.curvature_1.hashCode() | 0;
4480
+ result = imul(result, 31) + getNumberHashCode(this.simplifyToleranceCapM_1) | 0;
4481
+ return result;
4482
+ };
4483
+ protoOf(RacingLineOptions).equals = function (other) {
4484
+ if (this === other)
4485
+ return true;
4486
+ if (!(other instanceof RacingLineOptions))
4487
+ return false;
4488
+ if (!(this.enabled_1 === other.enabled_1))
4489
+ return false;
4490
+ if (!equals(this.defaultRoadWidthM_1, other.defaultRoadWidthM_1))
4491
+ return false;
4492
+ if (!equals(this.edgeMarginM_1, other.edgeMarginM_1))
4493
+ return false;
4494
+ if (!this.corridor_1.equals(other.corridor_1))
4495
+ return false;
4496
+ if (!equals(this.cornerEnterRadiusM_1, other.cornerEnterRadiusM_1))
4497
+ return false;
4498
+ if (!equals(this.cornerExitRadiusM_1, other.cornerExitRadiusM_1))
4499
+ return false;
4500
+ if (!equals(this.minCornerLengthM_1, other.minCornerLengthM_1))
4501
+ return false;
4502
+ if (!equals(this.minCornerTurnDeg_1, other.minCornerTurnDeg_1))
4503
+ return false;
4504
+ if (!equals(this.hairpinTurnDeg_1, other.hairpinTurnDeg_1))
4505
+ return false;
4506
+ if (!equals(this.gentleRadiusM_1, other.gentleRadiusM_1))
4507
+ return false;
4508
+ if (!equals(this.regularityFactor_1, other.regularityFactor_1))
4509
+ return false;
4510
+ if (!equals(this.selfProximityGapM_1, other.selfProximityGapM_1))
4511
+ return false;
4512
+ if (!equals(this.straightRunM_1, other.straightRunM_1))
4513
+ return false;
4514
+ if (!equals(this.straightRadiusM_1, other.straightRadiusM_1))
4515
+ return false;
4516
+ if (!equals(this.widthSmoothWindowM_1, other.widthSmoothWindowM_1))
4517
+ return false;
4518
+ if (!equals(this.objectiveRadiusM_1, other.objectiveRadiusM_1))
4519
+ return false;
4520
+ if (!equals(this.steeringLengthM_1, other.steeringLengthM_1))
4521
+ return false;
4522
+ if (!equals(this.centeringLengthM_1, other.centeringLengthM_1))
4523
+ return false;
4524
+ if (!(this.maxNewtonIterations_1 === other.maxNewtonIterations_1))
4525
+ return false;
4526
+ if (!equals(this.gradientTolerance_1, other.gradientTolerance_1))
4527
+ return false;
4528
+ if (!equals(this.boundEpsilonM_1, other.boundEpsilonM_1))
4529
+ return false;
4530
+ if (!this.curvature_1.equals(other.curvature_1))
4531
+ return false;
4532
+ if (!equals(this.simplifyToleranceCapM_1, other.simplifyToleranceCapM_1))
4533
+ return false;
4534
+ return true;
4535
+ };
4536
+ function CorridorMode_LANE_getInstance() {
4537
+ static_init_1();
4538
+ return CorridorMode_LANE_instance;
4539
+ }
4540
+ function CorridorMode_LANE_LEFT_getInstance() {
4541
+ static_init_1();
4542
+ return CorridorMode_LANE_LEFT_instance;
4543
+ }
4544
+ function CorridorMode_FULL_ROAD_getInstance() {
4545
+ static_init_1();
4546
+ return CorridorMode_FULL_ROAD_instance;
4547
+ }
4548
+ function CornerKind_GENTLE_getInstance() {
4549
+ static_init_2();
4550
+ return CornerKind_GENTLE_instance;
4551
+ }
4552
+ function CornerKind_CORNER_getInstance() {
4553
+ static_init_2();
4554
+ return CornerKind_CORNER_instance;
4555
+ }
4556
+ function CornerKind_HAIRPIN_getInstance() {
4557
+ static_init_2();
4558
+ return CornerKind_HAIRPIN_instance;
4559
+ }
4560
+ function get_POWER_PROVIDER_KEYS() {
4561
+ _init_properties_EngineJsApi_kt__9bputf();
4562
+ return POWER_PROVIDER_KEYS;
4563
+ }
4564
+ var POWER_PROVIDER_KEYS;
4565
+ function get_CYCLIST_KEYS() {
4566
+ _init_properties_EngineJsApi_kt__9bputf();
4567
+ return CYCLIST_KEYS;
4568
+ }
4569
+ var CYCLIST_KEYS;
4570
+ function get_BIKE_KEYS() {
4571
+ _init_properties_EngineJsApi_kt__9bputf();
4572
+ return BIKE_KEYS;
4573
+ }
4574
+ var BIKE_KEYS;
4575
+ function get_WIND_KEYS() {
4576
+ _init_properties_EngineJsApi_kt__9bputf();
4577
+ return WIND_KEYS;
4578
+ }
4579
+ var WIND_KEYS;
4580
+ function get_ENHANCE_OPTIONS_KEYS() {
4581
+ _init_properties_EngineJsApi_kt__9bputf();
4582
+ return ENHANCE_OPTIONS_KEYS;
4583
+ }
4584
+ var ENHANCE_OPTIONS_KEYS;
2000
4585
  function parseGpxWaypoints(xml) {
4586
+ _init_properties_EngineJsApi_kt__9bputf();
2001
4587
  // Inline function 'kotlin.collections.map' call
2002
4588
  var this_0 = GpxParser_instance.parse$default_ez0f31_k$(xml).waypoints_1;
2003
4589
  // Inline function 'kotlin.collections.mapTo' call
@@ -2012,24 +4598,29 @@
2012
4598
  return copyToArray(destination);
2013
4599
  }
2014
4600
  function parseGpx(xml) {
4601
+ _init_properties_EngineJsApi_kt__9bputf();
2015
4602
  return firstTrackAsPath(GpxParser_instance.parse$default_ez0f31_k$(xml));
2016
4603
  }
2017
4604
  function parseGpxTracks(xml) {
4605
+ _init_properties_EngineJsApi_kt__9bputf();
2018
4606
  // Inline function 'kotlin.collections.toTypedArray' call
2019
4607
  var this_0 = tracksAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml));
2020
4608
  return copyToArray(this_0);
2021
4609
  }
2022
4610
  function parseGpxSegments(xml) {
4611
+ _init_properties_EngineJsApi_kt__9bputf();
2023
4612
  // Inline function 'kotlin.collections.toTypedArray' call
2024
4613
  var this_0 = segmentsAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml));
2025
4614
  return copyToArray(this_0);
2026
4615
  }
2027
4616
  function parseGpxTracksOnly(xml) {
4617
+ _init_properties_EngineJsApi_kt__9bputf();
2028
4618
  // Inline function 'kotlin.collections.toTypedArray' call
2029
4619
  var this_0 = tracksAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml), setOf(GpxPathKind_TRACK_getInstance()));
2030
4620
  return copyToArray(this_0);
2031
4621
  }
2032
4622
  function parseGpxRoutesOnly(xml) {
4623
+ _init_properties_EngineJsApi_kt__9bputf();
2033
4624
  // Inline function 'kotlin.collections.toTypedArray' call
2034
4625
  var this_0 = tracksAsPaths(GpxParser_instance.parse$default_ez0f31_k$(xml), setOf(GpxPathKind_ROUTE_getInstance()));
2035
4626
  return copyToArray(this_0);
@@ -2044,6 +4635,7 @@
2044
4635
  }
2045
4636
  waypoints = tmp;
2046
4637
  writeExtensions = writeExtensions === VOID ? true : writeExtensions;
4638
+ _init_properties_EngineJsApi_kt__9bputf();
2047
4639
  var tmp_0 = GpxWriter_instance;
2048
4640
  var tmp_1 = toList(paths);
2049
4641
  // Inline function 'kotlin.collections.map' call
@@ -2060,40 +4652,51 @@
2060
4652
  return tmp_0.write$default_koqy5u_k$(tmp_1, VOID, VOID, destination, VOID, writeExtensions);
2061
4653
  }
2062
4654
  function pathSize(path) {
4655
+ _init_properties_EngineJsApi_kt__9bputf();
2063
4656
  return path.size_1;
2064
4657
  }
2065
4658
  function pathTotalDistance(path) {
4659
+ _init_properties_EngineJsApi_kt__9bputf();
2066
4660
  return path.totalDistance_1;
2067
4661
  }
2068
4662
  function pathDurationMs(path) {
4663
+ _init_properties_EngineJsApi_kt__9bputf();
2069
4664
  return path.durationMs_1;
2070
4665
  }
2071
4666
  function pathElevationGain(path) {
4667
+ _init_properties_EngineJsApi_kt__9bputf();
2072
4668
  return path.elevationGain_1;
2073
4669
  }
2074
4670
  function pathElevationLoss(path) {
4671
+ _init_properties_EngineJsApi_kt__9bputf();
2075
4672
  return path.elevationLoss_1;
2076
4673
  }
2077
4674
  function pointAt(path, i) {
4675
+ _init_properties_EngineJsApi_kt__9bputf();
2078
4676
  return pointObj(path.latitudeDeg_i25sm6_k$(i), path.longitudeDeg_ikk1un_k$(i), path.elevation_iziwkb_k$(i), path.time_ryc845_k$(i), path.speed_npav2n_k$(i), path.pComputedPower_g6dnn4_k$(i), path.distance_5s4s77_k$(i), path.grade_c4yjz5_k$(i));
2079
4677
  }
2080
4678
  function writeGpx(path, writeExtensions) {
2081
4679
  writeExtensions = writeExtensions === VOID ? true : writeExtensions;
4680
+ _init_properties_EngineJsApi_kt__9bputf();
2082
4681
  return GpxWriter_instance.write_7y52k2_k$(toGpxDocument(path, VOID, 'virtualized'), writeExtensions);
2083
4682
  }
2084
4683
  function writeGpxAt(path, startTimeEpochMs, writeExtensions) {
2085
4684
  writeExtensions = writeExtensions === VOID ? true : writeExtensions;
4685
+ _init_properties_EngineJsApi_kt__9bputf();
2086
4686
  return GpxWriter_instance.write_7y52k2_k$(toGpxDocument(path, VOID, 'virtualized', Companion_getInstance().fromEpochMilliseconds_uaz65_k$(numberToLong(startTimeEpochMs))), writeExtensions);
2087
4687
  }
2088
4688
  function enhance(path, options) {
4689
+ _init_properties_EngineJsApi_kt__9bputf();
2089
4690
  var tmp = GlobalScope_instance;
2090
4691
  return promise(tmp, VOID, VOID, enhance$slambda_0(options, path, null));
2091
4692
  }
2092
4693
  function enhanceWithCourse(path, cyclist, bike, wind, power, options) {
4694
+ _init_properties_EngineJsApi_kt__9bputf();
2093
4695
  var tmp = GlobalScope_instance;
2094
4696
  return promise(tmp, VOID, VOID, enhanceWithCourse$slambda_0(options, path, cyclist, bike, wind, power, null));
2095
4697
  }
2096
4698
  function getField(path, i, fieldProp) {
4699
+ _init_properties_EngineJsApi_kt__9bputf();
2097
4700
  var tmp0_elvis_lhs = Companion_getInstance_0().byProp_kdf1eo_k$(fieldProp);
2098
4701
  var tmp;
2099
4702
  if (tmp0_elvis_lhs == null) {
@@ -2107,6 +4710,7 @@
2107
4710
  return path.get_z3le6l_k$(i, field);
2108
4711
  }
2109
4712
  function fieldDefinitions() {
4713
+ _init_properties_EngineJsApi_kt__9bputf();
2110
4714
  // Inline function 'kotlin.collections.map' call
2111
4715
  var this_0 = get_entries();
2112
4716
  // Inline function 'kotlin.collections.mapTo' call
@@ -2129,12 +4733,15 @@
2129
4733
  return copyToArray(destination);
2130
4734
  }
2131
4735
  function pathLatitudeDeg(path, i) {
4736
+ _init_properties_EngineJsApi_kt__9bputf();
2132
4737
  return path.latitudeDeg_i25sm6_k$(i);
2133
4738
  }
2134
4739
  function pathLongitudeDeg(path, i) {
4740
+ _init_properties_EngineJsApi_kt__9bputf();
2135
4741
  return path.longitudeDeg_ikk1un_k$(i);
2136
4742
  }
2137
4743
  function pathToCsv(path, separator, unitsInHeader) {
4744
+ _init_properties_EngineJsApi_kt__9bputf();
2138
4745
  var tmp = CsvWriter_instance;
2139
4746
  var tmp0_elvis_lhs = firstOrNull(separator);
2140
4747
  var tmp_0;
@@ -2147,13 +4754,16 @@
2147
4754
  return tmp.write_p5vnh4_k$(path, new CsvOptions(VOID, tmp_0, unitsInHeader));
2148
4755
  }
2149
4756
  function pathToJson(path, pretty) {
4757
+ _init_properties_EngineJsApi_kt__9bputf();
2150
4758
  return JsonWriter_instance.write_lwqeog_k$(path, new JsonOptions(VOID, pretty));
2151
4759
  }
2152
4760
  function pathToFit(path, name, startTimeEpochMs) {
4761
+ _init_properties_EngineJsApi_kt__9bputf();
2153
4762
  return toFitBytes(path, name, Companion_getInstance().fromEpochMilliseconds_uaz65_k$(numberToLong(startTimeEpochMs)));
2154
4763
  }
2155
4764
  function pathsToFit(paths, name, startTimeEpochMs, interPathGapMs) {
2156
4765
  interPathGapMs = interPathGapMs === VOID ? 0.0 : interPathGapMs;
4766
+ _init_properties_EngineJsApi_kt__9bputf();
2157
4767
  var tmp = toList(paths);
2158
4768
  var tmp_0 = Companion_getInstance().fromEpochMilliseconds_uaz65_k$(numberToLong(startTimeEpochMs));
2159
4769
  Companion_getInstance_1();
@@ -2163,12 +4773,15 @@
2163
4773
  return toFitBytes_0(tmp, name, tmp_0, VOID, tmp$ret$0);
2164
4774
  }
2165
4775
  function dominantHeadwindAzimuth(path) {
4776
+ _init_properties_EngineJsApi_kt__9bputf();
2166
4777
  return dominantHeadwindAzimuthDeg(path);
2167
4778
  }
2168
4779
  function dominantHeadwindAzimuthOfTracks(paths) {
4780
+ _init_properties_EngineJsApi_kt__9bputf();
2169
4781
  return dominantHeadwindAzimuthDeg_0(toList(paths));
2170
4782
  }
2171
4783
  function detectClimbs(path) {
4784
+ _init_properties_EngineJsApi_kt__9bputf();
2172
4785
  // Inline function 'kotlin.collections.map' call
2173
4786
  var this_0 = ClimbDetector_instance.detect$default_6ml3ny_k$(path);
2174
4787
  // Inline function 'kotlin.collections.mapTo' call
@@ -2183,6 +4796,7 @@
2183
4796
  return copyToArray(destination);
2184
4797
  }
2185
4798
  function detectClimbsWithOptions(path, minMinClimbElevationM, maxMinClimbElevationM, minClimbElevationRatio, minGradePercent, maxDiffRealGrade, booster) {
4799
+ _init_properties_EngineJsApi_kt__9bputf();
2186
4800
  // Inline function 'kotlin.collections.map' call
2187
4801
  var this_0 = ClimbDetector_instance.detect_llooq2_k$(path, new ClimbOptions(minMinClimbElevationM, maxMinClimbElevationM, minClimbElevationRatio, minGradePercent, maxDiffRealGrade, booster));
2188
4802
  // Inline function 'kotlin.collections.mapTo' call
@@ -2196,7 +4810,48 @@
2196
4810
  // Inline function 'kotlin.collections.toTypedArray' call
2197
4811
  return copyToArray(destination);
2198
4812
  }
4813
+ function analyzeRacingLine(path, options) {
4814
+ options = options === VOID ? null : options;
4815
+ _init_properties_EngineJsApi_kt__9bputf();
4816
+ var racingLine = toEnhanceOptions(options).racingLine_1;
4817
+ var tmp0_elvis_lhs = RacingLine_instance.analyze_ikwae4_k$(path, racingLine);
4818
+ var tmp;
4819
+ if (tmp0_elvis_lhs == null) {
4820
+ return null;
4821
+ } else {
4822
+ tmp = tmp0_elvis_lhs;
4823
+ }
4824
+ var report = tmp;
4825
+ var o = {};
4826
+ o.size = report.size_1;
4827
+ // Inline function 'kotlin.collections.map' call
4828
+ var this_0 = report.corners_1;
4829
+ // Inline function 'kotlin.collections.mapTo' call
4830
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
4831
+ var _iterator__ex2g4s = this_0.iterator_jk1svi_k$();
4832
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
4833
+ var item = _iterator__ex2g4s.next_20eer_k$();
4834
+ var tmp$ret$2 = cornerObj(item);
4835
+ destination.add_utx5q5_k$(tmp$ret$2);
4836
+ }
4837
+ // Inline function 'kotlin.collections.toTypedArray' call
4838
+ o.corners = copyToArray(destination);
4839
+ o.centerlineCurvature = report.centerlineCurvature_1;
4840
+ o.trajectoryCurvature = report.trajectoryCurvature_1;
4841
+ o.corridorLo = report.corridorLo_1;
4842
+ o.corridorHi = report.corridorHi_1;
4843
+ o.roadHalfWidthM = report.roadHalfWidthM_1;
4844
+ o.lateralOffsetM = report.lateralOffsetM_1;
4845
+ o.maxCorridorWidthM = report.get_maxCorridorWidthM_7bycoc_k$();
4846
+ o.newtonIterations = report.newtonIterations_1;
4847
+ o.relativeGradient = report.relativeGradient_1;
4848
+ o.converged = report.converged_1;
4849
+ o.activeConstraints = report.activeConstraints_1;
4850
+ // Inline function 'kotlin.js.unsafeCast' call
4851
+ return o;
4852
+ }
2199
4853
  function waypointObj(w) {
4854
+ _init_properties_EngineJsApi_kt__9bputf();
2200
4855
  var o = {};
2201
4856
  o.latitudeDeg = w.latitudeDeg_1;
2202
4857
  o.longitudeDeg = w.longitudeDeg_1;
@@ -2211,6 +4866,7 @@
2211
4866
  return o;
2212
4867
  }
2213
4868
  function pointObj(latitudeDeg, longitudeDeg, elevation, timeMs, speed, pComputedPower, distance, grade) {
4869
+ _init_properties_EngineJsApi_kt__9bputf();
2214
4870
  var o = {};
2215
4871
  o.latitudeDeg = latitudeDeg;
2216
4872
  o.longitudeDeg = longitudeDeg;
@@ -2224,6 +4880,7 @@
2224
4880
  return o;
2225
4881
  }
2226
4882
  function toGpxWaypoint(_this__u8e3s4) {
4883
+ _init_properties_EngineJsApi_kt__9bputf();
2227
4884
  var tmp = _this__u8e3s4.latitudeDeg;
2228
4885
  var tmp_0 = _this__u8e3s4.longitudeDeg;
2229
4886
  var tmp_1 = _this__u8e3s4.elevationM;
@@ -2235,8 +4892,10 @@
2235
4892
  return new GpxWaypoint(tmp, tmp_0, tmp_1, tmp_2, tmp_3, tmp_4, tmp_5, tmp0_safe_receiver == null ? null : numberToLong(tmp0_safe_receiver));
2236
4893
  }
2237
4894
  function toEnhanceOptions(_this__u8e3s4) {
4895
+ _init_properties_EngineJsApi_kt__9bputf();
2238
4896
  if (_this__u8e3s4 == null)
2239
4897
  return defaultJsOptions();
4898
+ requireOnlyKeys(_this__u8e3s4, 'EnhanceOptionsDto', get_ENHANCE_OPTIONS_KEYS());
2240
4899
  var tmp0_elvis_lhs = _this__u8e3s4.fixElevation;
2241
4900
  var tmp = tmp0_elvis_lhs == null ? false : tmp0_elvis_lhs;
2242
4901
  var tmp1_elvis_lhs = _this__u8e3s4.computeMaxSpeeds;
@@ -2250,19 +4909,90 @@
2250
4909
  var tmp5_elvis_lhs = _this__u8e3s4.simplifyToleranceM;
2251
4910
  var tmp_4 = tmp5_elvis_lhs == null ? 10.0 : tmp5_elvis_lhs;
2252
4911
  var tmp6_elvis_lhs = _this__u8e3s4.simplifyZExaggeration;
2253
- return new EnhanceOptions(tmp, tmp_0, tmp_1, tmp_2, new SimplifyPathOptions(tmp_3, tmp_4, tmp6_elvis_lhs == null ? 3.0 : tmp6_elvis_lhs));
4912
+ var tmp_5 = new SimplifyPathOptions(tmp_3, tmp_4, tmp6_elvis_lhs == null ? 3.0 : tmp6_elvis_lhs);
4913
+ var tmp7_elvis_lhs = _this__u8e3s4.wPrimeBalanceEnabled;
4914
+ var tmp_6 = tmp7_elvis_lhs == null ? (new WPrimeBalanceOptions()).enabled_1 : tmp7_elvis_lhs;
4915
+ var tmp8_elvis_lhs = _this__u8e3s4.wPrimeBalanceCriticalPower;
4916
+ var tmp_7 = tmp8_elvis_lhs == null ? 250.0 : tmp8_elvis_lhs;
4917
+ var tmp9_elvis_lhs = _this__u8e3s4.wPrimeBalanceWPrime;
4918
+ var tmp_8 = new WPrimeBalanceOptions(tmp_6, tmp_7, tmp9_elvis_lhs == null ? 20000.0 : tmp9_elvis_lhs);
4919
+ var tmp10_elvis_lhs = _this__u8e3s4.curvatureEnabled;
4920
+ var tmp_9 = new CurvatureOptions(tmp10_elvis_lhs == null ? true : tmp10_elvis_lhs);
4921
+ var tmp11_elvis_lhs = _this__u8e3s4.racingLineEnabled;
4922
+ var tmp13_enabled = tmp11_elvis_lhs == null ? false : tmp11_elvis_lhs;
4923
+ var tmp14_corridor = parseCorridor(_this__u8e3s4.racingLineCorridor);
4924
+ var tmp12_elvis_lhs = _this__u8e3s4.racingLineRoadWidthM;
4925
+ var tmp15_defaultRoadWidthM = tmp12_elvis_lhs == null ? Companion_getInstance_17().DEFAULT_1.defaultRoadWidthM_1 : tmp12_elvis_lhs;
4926
+ return new EnhanceOptions(tmp, tmp_0, tmp_1, tmp_2, tmp_5, tmp_8, tmp_9, new RacingLineOptions(tmp13_enabled, tmp15_defaultRoadWidthM, VOID, tmp14_corridor));
4927
+ }
4928
+ function parseCorridor(name) {
4929
+ _init_properties_EngineJsApi_kt__9bputf();
4930
+ return name == null ? Companion_getInstance_17().DEFAULT_1.corridor_1 : Companion_instance_14.byId_8gmd94_k$(name);
2254
4931
  }
2255
4932
  function defaultJsOptions() {
2256
- return new EnhanceOptions(false, true, true, false, new SimplifyPathOptions(false));
4933
+ _init_properties_EngineJsApi_kt__9bputf();
4934
+ return new EnhanceOptions(false, true, true, false, new SimplifyPathOptions(false), VOID, new CurvatureOptions(true), new RacingLineOptions(false));
2257
4935
  }
2258
4936
  function toCyclist(_this__u8e3s4) {
4937
+ _init_properties_EngineJsApi_kt__9bputf();
2259
4938
  if (_this__u8e3s4 == null)
2260
4939
  return new Cyclist();
2261
- return new Cyclist(_this__u8e3s4.massKg, _this__u8e3s4.maxBrakeG, _this__u8e3s4.cd, _this__u8e3s4.frontalAreaM2, _this__u8e3s4.maxLeanAngleDeg, _this__u8e3s4.maxSpeedKmH);
4940
+ requireOnlyKeys(_this__u8e3s4, 'CyclistDto', get_CYCLIST_KEYS());
4941
+ var tmp0_safe_receiver = _this__u8e3s4.roadCondition;
4942
+ var condition = tmp0_safe_receiver == null ? null : toRoadCondition(tmp0_safe_receiver);
4943
+ var tmp = _this__u8e3s4.massKg;
4944
+ var tmp2_elvis_lhs = condition == null ? null : condition.maxBrakeG_1;
4945
+ var tmp_0 = tmp2_elvis_lhs == null ? _this__u8e3s4.maxBrakeG : tmp2_elvis_lhs;
4946
+ var tmp_1 = _this__u8e3s4.cd;
4947
+ var tmp_2 = _this__u8e3s4.frontalAreaM2;
4948
+ var tmp4_elvis_lhs = condition == null ? null : condition.get_leanAngleDeg_9xbhfm_k$();
4949
+ return new Cyclist(tmp, tmp_0, tmp_1, tmp_2, tmp4_elvis_lhs == null ? _this__u8e3s4.maxLeanAngleDeg : tmp4_elvis_lhs, _this__u8e3s4.maxSpeedKmH);
4950
+ }
4951
+ function toRoadCondition(_this__u8e3s4) {
4952
+ _init_properties_EngineJsApi_kt__9bputf();
4953
+ var tmp0 = get_entries_0();
4954
+ var tmp$ret$0;
4955
+ $l$block: {
4956
+ // Inline function 'kotlin.collections.firstOrNull' call
4957
+ var _iterator__ex2g4s = tmp0.iterator_jk1svi_k$();
4958
+ while (_iterator__ex2g4s.hasNext_bitz1p_k$()) {
4959
+ var element = _iterator__ex2g4s.next_20eer_k$();
4960
+ if (equals_0(element.name_1, _this__u8e3s4, true)) {
4961
+ tmp$ret$0 = element;
4962
+ break $l$block;
4963
+ }
4964
+ }
4965
+ tmp$ret$0 = null;
4966
+ }
4967
+ var tmp0_elvis_lhs = tmp$ret$0;
4968
+ var tmp;
4969
+ if (tmp0_elvis_lhs == null) {
4970
+ var tmp_0 = 'Unknown CyclistDto.roadCondition: ' + _this__u8e3s4 + ' (expected one of ';
4971
+ // Inline function 'kotlin.collections.map' call
4972
+ var this_0 = get_entries_0();
4973
+ // Inline function 'kotlin.collections.mapTo' call
4974
+ var destination = ArrayList_init_$Create$_0(collectionSizeOrDefault(this_0, 10));
4975
+ var _iterator__ex2g4s_0 = this_0.iterator_jk1svi_k$();
4976
+ while (_iterator__ex2g4s_0.hasNext_bitz1p_k$()) {
4977
+ var item = _iterator__ex2g4s_0.next_20eer_k$();
4978
+ // Inline function 'kotlin.text.lowercase' call
4979
+ // Inline function 'kotlin.js.asDynamic' call
4980
+ var tmp$ret$4 = item.name_1.toLowerCase();
4981
+ destination.add_utx5q5_k$(tmp$ret$4);
4982
+ }
4983
+ // Inline function 'kotlin.error' call
4984
+ var message = tmp_0 + (toString(destination) + ')');
4985
+ throw IllegalStateException_init_$Create$(toString(message));
4986
+ } else {
4987
+ tmp = tmp0_elvis_lhs;
4988
+ }
4989
+ return tmp;
2262
4990
  }
2263
4991
  function toBike(_this__u8e3s4) {
4992
+ _init_properties_EngineJsApi_kt__9bputf();
2264
4993
  if (_this__u8e3s4 == null)
2265
4994
  return new Bike();
4995
+ requireOnlyKeys(_this__u8e3s4, 'BikeDto', get_BIKE_KEYS());
2266
4996
  var tmp = _this__u8e3s4.crr;
2267
4997
  var tmp_0 = _this__u8e3s4.inertiaFront;
2268
4998
  var tmp_1 = _this__u8e3s4.inertiaRear;
@@ -2272,41 +5002,71 @@
2272
5002
  return new Bike(tmp, tmp_0, tmp_1, tmp_2, tmp_3, tmp0_elvis_lhs == null ? 20.0 : tmp0_elvis_lhs);
2273
5003
  }
2274
5004
  function toWindProvider(_this__u8e3s4) {
5005
+ _init_properties_EngineJsApi_kt__9bputf();
2275
5006
  if (_this__u8e3s4 == null)
2276
5007
  return WindProviderNone_instance;
5008
+ requireOnlyKeys(_this__u8e3s4, 'WindDto', get_WIND_KEYS());
2277
5009
  return new WindProviderConstant(new Wind(_this__u8e3s4.windSpeed, _this__u8e3s4.windDirection * 3.141592653589793 / 180.0));
2278
5010
  }
2279
5011
  function toCyclistPowerProvider(_this__u8e3s4) {
5012
+ _init_properties_EngineJsApi_kt__9bputf();
5013
+ return toPowerSpec(_this__u8e3s4).toProvider_gnvkvo_k$();
5014
+ }
5015
+ function toPowerSpec(_this__u8e3s4) {
5016
+ _init_properties_EngineJsApi_kt__9bputf();
2280
5017
  if (_this__u8e3s4 == null)
2281
- return new PowerProviderConstant(250.0, false);
5018
+ return new CyclistPowerSpec();
5019
+ requireOnlyKeys(_this__u8e3s4, 'PowerProviderDto', get_POWER_PROVIDER_KEYS());
5020
+ var defaults = new CyclistPowerSpec();
5021
+ var tmp0_elvis_lhs = Companion_instance_7.fromIdOrNull_83jhaj_k$(_this__u8e3s4.type);
2282
5022
  var tmp;
2283
- switch (_this__u8e3s4.type) {
2284
- case 'constant':
2285
- var tmp1_elvis_lhs = _this__u8e3s4.power;
2286
- var tmp_0 = tmp1_elvis_lhs == null ? 250.0 : tmp1_elvis_lhs;
2287
- var tmp2_elvis_lhs = _this__u8e3s4.useHarmonics;
2288
- tmp = new PowerProviderConstant(tmp_0, tmp2_elvis_lhs == null ? false : tmp2_elvis_lhs);
2289
- break;
2290
- case 'durability':
2291
- var tmp3_elvis_lhs = _this__u8e3s4.power;
2292
- var tmp_1 = tmp3_elvis_lhs == null ? 250.0 : tmp3_elvis_lhs;
2293
- var tmp4_elvis_lhs = _this__u8e3s4.criticalPower;
2294
- var tmp_2 = tmp4_elvis_lhs == null ? 250.0 : tmp4_elvis_lhs;
2295
- var tmp5_elvis_lhs = _this__u8e3s4.useHarmonics;
2296
- tmp = new PowerProviderDurability(tmp_1, tmp_2, VOID, VOID, tmp5_elvis_lhs == null ? false : tmp5_elvis_lhs);
2297
- break;
2298
- case 'from_data':
2299
- tmp = PowerProviderFromData_instance;
2300
- break;
2301
- default:
2302
- // Inline function 'kotlin.error' call
2303
-
2304
- var message = 'Unknown PowerProviderDto.type: ' + _this__u8e3s4.type;
2305
- throw IllegalStateException_init_$Create$(toString(message));
5023
+ if (tmp0_elvis_lhs == null) {
5024
+ // Inline function 'kotlin.error' call
5025
+ var message = 'Unknown PowerProviderDto.type: ' + _this__u8e3s4.type + ' (expected one of ' + toString(Companion_instance_7.get_ids_18j3qp_k$()) + ')';
5026
+ throw IllegalStateException_init_$Create$(toString(message));
5027
+ } else {
5028
+ tmp = tmp0_elvis_lhs;
5029
+ }
5030
+ var tmp_0 = tmp;
5031
+ var tmp1_elvis_lhs = _this__u8e3s4.power;
5032
+ var tmp_1 = tmp1_elvis_lhs == null ? defaults.powerW_1 : tmp1_elvis_lhs;
5033
+ var tmp2_elvis_lhs = _this__u8e3s4.criticalPower;
5034
+ var tmp_2 = tmp2_elvis_lhs == null ? defaults.criticalPowerW_1 : tmp2_elvis_lhs;
5035
+ var tmp3_elvis_lhs = _this__u8e3s4.wPrime;
5036
+ var tmp_3 = tmp3_elvis_lhs == null ? defaults.wPrimeJ_1 : tmp3_elvis_lhs;
5037
+ var tmp4_elvis_lhs = _this__u8e3s4.useHarmonics;
5038
+ var tmp_4 = tmp4_elvis_lhs == null ? defaults.useHarmonics_1 : tmp4_elvis_lhs;
5039
+ var tmp5_elvis_lhs = _this__u8e3s4.pacing;
5040
+ var tmp_5 = tmp5_elvis_lhs == null ? defaults.pacing_1 : tmp5_elvis_lhs;
5041
+ var tmp6_elvis_lhs = _this__u8e3s4.maxSlewWPerS;
5042
+ return new CyclistPowerSpec(tmp_0, tmp_1, tmp_2, tmp_3, tmp_4, tmp_5, tmp6_elvis_lhs == null ? defaults.maxSlewWPerS_1 : tmp6_elvis_lhs);
5043
+ }
5044
+ function requireOnlyKeys(_this__u8e3s4, dtoName, allowed) {
5045
+ _init_properties_EngineJsApi_kt__9bputf();
5046
+ // Inline function 'kotlin.js.unsafeCast' call
5047
+ var keys = Object.keys(_this__u8e3s4);
5048
+ // Inline function 'kotlin.collections.filterNot' call
5049
+ // Inline function 'kotlin.collections.filterNotTo' call
5050
+ var destination = ArrayList_init_$Create$();
5051
+ var inductionVariable = 0;
5052
+ var last = keys.length;
5053
+ while (inductionVariable < last) {
5054
+ var element = keys[inductionVariable];
5055
+ inductionVariable = inductionVariable + 1 | 0;
5056
+ if (!allowed.contains_aljjnj_k$(element)) {
5057
+ destination.add_utx5q5_k$(element);
5058
+ }
5059
+ }
5060
+ var unknown = destination;
5061
+ // Inline function 'kotlin.collections.isNotEmpty' call
5062
+ if (!unknown.isEmpty_y1axqb_k$()) {
5063
+ // Inline function 'kotlin.error' call
5064
+ var message = 'Unknown ' + dtoName + ' key(s): ' + joinToString(unknown) + ' \u2014 expected one of ' + joinToString(sorted(allowed));
5065
+ throw IllegalStateException_init_$Create$(toString(message));
2306
5066
  }
2307
- return tmp;
2308
5067
  }
2309
5068
  function toDto(_this__u8e3s4) {
5069
+ _init_properties_EngineJsApi_kt__9bputf();
2310
5070
  var o = {};
2311
5071
  o.startDistanceM = _this__u8e3s4.startDistanceM_1;
2312
5072
  o.endDistanceM = _this__u8e3s4.endDistanceM_1;
@@ -2319,6 +5079,7 @@
2319
5079
  return o;
2320
5080
  }
2321
5081
  function toDto_0(_this__u8e3s4) {
5082
+ _init_properties_EngineJsApi_kt__9bputf();
2322
5083
  var o = {};
2323
5084
  o.startIndex = _this__u8e3s4.startIndex_1;
2324
5085
  o.endIndex = _this__u8e3s4.endIndex_1;
@@ -2347,6 +5108,21 @@
2347
5108
  // Inline function 'kotlin.js.unsafeCast' call
2348
5109
  return o;
2349
5110
  }
5111
+ function cornerObj(c) {
5112
+ _init_properties_EngineJsApi_kt__9bputf();
5113
+ var o = {};
5114
+ o.fromIndex = c.fromIndex_1;
5115
+ o.untilIndex = c.untilIndex_1;
5116
+ o.apexIndex = c.apexIndex_1;
5117
+ o.kind = c.kind_1.name_1;
5118
+ o.turnRad = c.turnRad_1;
5119
+ o.direction = c.direction_1;
5120
+ o.radiusQ20M = c.radiusQ20M_1;
5121
+ o.radiusMinM = c.radiusMinM_1;
5122
+ o.lengthM = c.lengthM_1;
5123
+ // Inline function 'kotlin.js.unsafeCast' call
5124
+ return o;
5125
+ }
2350
5126
  function enhance$slambda($options, $path, resultContinuation) {
2351
5127
  this.$options_1 = $options;
2352
5128
  this.$path_1 = $path;
@@ -2468,19 +5244,33 @@
2468
5244
  return i.invoke_jiwoso_k$($this$promise, $completion);
2469
5245
  }, 1);
2470
5246
  }
5247
+ var properties_initialized_EngineJsApi_kt_2x4hj5;
5248
+ function _init_properties_EngineJsApi_kt__9bputf() {
5249
+ if (!properties_initialized_EngineJsApi_kt_2x4hj5) {
5250
+ properties_initialized_EngineJsApi_kt_2x4hj5 = true;
5251
+ POWER_PROVIDER_KEYS = setOf_0(['type', 'power', 'useHarmonics', 'criticalPower', 'wPrime', 'pacing', 'maxSlewWPerS']);
5252
+ CYCLIST_KEYS = setOf_0(['massKg', 'cd', 'frontalAreaM2', 'maxLeanAngleDeg', 'maxBrakeG', 'maxSpeedKmH', 'roadCondition']);
5253
+ BIKE_KEYS = setOf_0(['crr', 'inertiaFront', 'inertiaRear', 'wheelRadiusM', 'efficiency', 'maxPedalingLeanAngleDeg']);
5254
+ WIND_KEYS = setOf_0(['windSpeed', 'windDirection']);
5255
+ ENHANCE_OPTIONS_KEYS = setOf_0(['fixElevation', 'computeMaxSpeeds', 'virtualizeTrack', 'computeOnePointPerSecond', 'simplifyEnabled', 'simplifyToleranceM', 'simplifyZExaggeration', 'wPrimeBalanceEnabled', 'wPrimeBalanceCriticalPower', 'wPrimeBalanceWPrime', 'curvatureEnabled', 'racingLineEnabled', 'racingLineCorridor', 'racingLineRoadWidthM']);
5256
+ }
5257
+ }
2471
5258
  //region block: init
2472
5259
  Enhancer_instance = new Enhancer();
2473
- Companion_instance_4 = new Companion_4();
5260
+ Companion_instance_5 = new Companion_4();
2474
5261
  ClimbDetector_instance = new ClimbDetector();
2475
5262
  AeroPowerProvider_instance = new AeroPowerProvider();
2476
5263
  AeroProviderConstant_instance = new AeroProviderConstant();
2477
- Companion_instance_5 = new Companion_5();
5264
+ Companion_instance_6 = new Companion_5();
5265
+ Companion_instance_7 = new Companion_6();
2478
5266
  GravPowerProvider_instance = new GravPowerProvider();
2479
5267
  MaxSpeedComputer_instance = new MaxSpeedComputer();
2480
5268
  MuscularPowerProvider_instance = new MuscularPowerProvider();
2481
5269
  PowerComputer_instance = new PowerComputer();
2482
- Companion_instance_6 = new Companion_6();
5270
+ Companion_instance_8 = new Companion_7();
5271
+ Companion_instance_9 = new Companion_8();
2483
5272
  PowerProviderFromData_instance = new PowerProviderFromData();
5273
+ Companion_instance_10 = new Companion_9();
2484
5274
  RhoProviderDefault_instance = new RhoProviderDefault();
2485
5275
  RhoProviderEstimate_instance = new RhoProviderEstimate();
2486
5276
  RollingResistancePowerProvider_instance = new RollingResistancePowerProvider();
@@ -2488,6 +5278,16 @@
2488
5278
  WheelBearingsPowerProvider_instance = new WheelBearingsPowerProvider();
2489
5279
  WindProviderNone_instance = new WindProviderNone();
2490
5280
  WPrimeBalanceComputer_instance = new WPrimeBalanceComputer();
5281
+ BandedLdl_instance = new BandedLdl();
5282
+ CornerDetector_instance = new CornerDetector();
5283
+ Corridor_instance = new Corridor();
5284
+ CurvatureEstimator_instance = new CurvatureEstimator();
5285
+ LocalFrame_instance = new LocalFrame();
5286
+ Companion_instance_12 = new Companion_11();
5287
+ OffsetQp_instance = new OffsetQp();
5288
+ PathCurvature_instance = new PathCurvature();
5289
+ RacingLine_instance = new RacingLine();
5290
+ Companion_instance_14 = new Companion_13();
2491
5291
  //endregion
2492
5292
  //region block: exports
2493
5293
  function $jsExportAll$(_) {
@@ -2524,6 +5324,7 @@
2524
5324
  engine.dominantHeadwindAzimuthOfTracks = dominantHeadwindAzimuthOfTracks;
2525
5325
  engine.detectClimbs = detectClimbs;
2526
5326
  engine.detectClimbsWithOptions = detectClimbsWithOptions;
5327
+ engine.analyzeRacingLine = analyzeRacingLine;
2527
5328
  }
2528
5329
  $jsExportAll$(_);
2529
5330
  kotlin_io_github_glandais_elevation.$jsExportAll$(_);