@glandais/vcyclist-engine 3.1.1 → 4.0.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.
@@ -39,9 +39,9 @@
39
39
  var toString = kotlin_kotlin.$_$.f7;
40
40
  var hashCode = kotlin_kotlin.$_$.m6;
41
41
  var getBooleanHashCode = kotlin_kotlin.$_$.i6;
42
- var CoroutineImpl = kotlin_kotlin.$_$.x4;
43
42
  var IllegalArgumentException_init_$Create$ = kotlin_kotlin.$_$.a2;
44
43
  var Unit_instance = kotlin_kotlin.$_$.g1;
44
+ var CoroutineImpl = kotlin_kotlin.$_$.x4;
45
45
  var PointPerDistance_instance = kotlin_io_github_glandais_gpx.$_$.k;
46
46
  var ElevationStep_instance = kotlin_io_github_glandais_gpx.$_$.h;
47
47
  var get_COROUTINE_SUSPENDED = kotlin_kotlin.$_$.i4;
@@ -71,8 +71,9 @@
71
71
  var Pair = kotlin_kotlin.$_$.p9;
72
72
  var listOf = kotlin_kotlin.$_$.p3;
73
73
  var Default_getInstance = kotlin_kotlin.$_$.b1;
74
+ var isFinite = kotlin_kotlin.$_$.ca;
74
75
  var PointField_TEMPERATURE_getInstance = kotlin_io_github_glandais_gpx.$_$.c;
75
- var isNaN_0 = kotlin_kotlin.$_$.da;
76
+ var isNaN_0 = kotlin_kotlin.$_$.ea;
76
77
  var get_entries = kotlin_io_github_glandais_gpx.$_$.u;
77
78
  var Path = kotlin_io_github_glandais_gpx.$_$.t;
78
79
  var GpxParser_instance = kotlin_io_github_glandais_gpx.$_$.d;
@@ -121,6 +122,7 @@
121
122
  initMetadataForCompanion(Companion_1);
122
123
  initMetadataForClass(Cyclist, 'Cyclist', Cyclist);
123
124
  initMetadataForClass(SimplifyPathOptions, 'SimplifyPathOptions', SimplifyPathOptions);
125
+ initMetadataForClass(WPrimeBalanceOptions, 'WPrimeBalanceOptions', WPrimeBalanceOptions);
124
126
  initMetadataForCompanion(Companion_2);
125
127
  initMetadataForClass(EnhanceOptions, 'EnhanceOptions', EnhanceOptions);
126
128
  initMetadataForCoroutine($enhanceCourseCOROUTINE$, CoroutineImpl);
@@ -145,17 +147,19 @@
145
147
  initMetadataForObject(MuscularPowerProvider, 'MuscularPowerProvider');
146
148
  initMetadataForObject(PowerComputer, 'PowerComputer');
147
149
  initMetadataForClass(PowerProviderConstant, 'PowerProviderConstant', VOID, CyclistPowerProviderBase);
148
- initMetadataForClass(PowerProviderConstantWithTiring, 'PowerProviderConstantWithTiring', VOID, CyclistPowerProviderBase);
150
+ initMetadataForCompanion(Companion_6);
151
+ initMetadataForClass(PowerProviderDurability, 'PowerProviderDurability', VOID, CyclistPowerProviderBase);
149
152
  initMetadataForObject(PowerProviderFromData, 'PowerProviderFromData');
150
153
  initMetadataForObject(RhoProviderDefault, 'RhoProviderDefault');
151
154
  initMetadataForObject(RhoProviderEstimate, 'RhoProviderEstimate');
152
155
  initMetadataForObject(RollingResistancePowerProvider, 'RollingResistancePowerProvider');
153
156
  initMetadataForObject(VirtualizeService, 'VirtualizeService');
154
157
  initMetadataForObject(WheelBearingsPowerProvider, 'WheelBearingsPowerProvider');
155
- initMetadataForCompanion(Companion_6);
158
+ initMetadataForCompanion(Companion_7);
156
159
  initMetadataForClass(Wind, 'Wind');
157
160
  initMetadataForObject(WindProviderNone, 'WindProviderNone');
158
161
  initMetadataForClass(WindProviderConstant, 'WindProviderConstant');
162
+ initMetadataForObject(WPrimeBalanceComputer, 'WPrimeBalanceComputer');
159
163
  initMetadataForLambda(enhance$slambda, CoroutineImpl, VOID, [1]);
160
164
  initMetadataForLambda(enhanceWithCourse$slambda, CoroutineImpl, VOID, [1]);
161
165
  //endregion
@@ -169,21 +173,34 @@
169
173
  new Companion();
170
174
  return Companion_instance;
171
175
  }
172
- function Bike(crr, inertiaFront, inertiaRear, wheelRadiusM, efficiency) {
176
+ function Bike(crr, inertiaFront, inertiaRear, wheelRadiusM, efficiency, maxPedalingLeanAngleDeg) {
173
177
  Companion_getInstance_2();
174
178
  crr = crr === VOID ? 0.004 : crr;
175
179
  inertiaFront = inertiaFront === VOID ? 0.05 : inertiaFront;
176
180
  inertiaRear = inertiaRear === VOID ? 0.07 : inertiaRear;
177
181
  wheelRadiusM = wheelRadiusM === VOID ? 0.35 : wheelRadiusM;
178
182
  efficiency = efficiency === VOID ? 0.976 : efficiency;
183
+ maxPedalingLeanAngleDeg = maxPedalingLeanAngleDeg === VOID ? 20.0 : maxPedalingLeanAngleDeg;
179
184
  this.crr_1 = crr;
180
185
  this.inertiaFront_1 = inertiaFront;
181
186
  this.inertiaRear_1 = inertiaRear;
182
187
  this.wheelRadiusM_1 = wheelRadiusM;
183
188
  this.efficiency_1 = efficiency;
189
+ this.maxPedalingLeanAngleDeg_1 = maxPedalingLeanAngleDeg;
184
190
  }
191
+ protoOf(Bike).get_tanMaxPedalingLeanAngle_nft7tz_k$ = function () {
192
+ var tmp;
193
+ if (this.maxPedalingLeanAngleDeg_1 >= 90.0) {
194
+ tmp = Infinity;
195
+ } else {
196
+ // Inline function 'kotlin.math.tan' call
197
+ var x = this.maxPedalingLeanAngleDeg_1 * 3.141592653589793 / 180.0;
198
+ tmp = Math.tan(x);
199
+ }
200
+ return tmp;
201
+ };
185
202
  protoOf(Bike).toString = function () {
186
- return 'Bike(crr=' + this.crr_1 + ', inertiaFront=' + this.inertiaFront_1 + ', inertiaRear=' + this.inertiaRear_1 + ', wheelRadiusM=' + this.wheelRadiusM_1 + ', efficiency=' + this.efficiency_1 + ')';
203
+ return 'Bike(crr=' + this.crr_1 + ', inertiaFront=' + this.inertiaFront_1 + ', inertiaRear=' + this.inertiaRear_1 + ', wheelRadiusM=' + this.wheelRadiusM_1 + ', efficiency=' + this.efficiency_1 + ', maxPedalingLeanAngleDeg=' + this.maxPedalingLeanAngleDeg_1 + ')';
187
204
  };
188
205
  protoOf(Bike).hashCode = function () {
189
206
  var result = getNumberHashCode(this.crr_1);
@@ -191,6 +208,7 @@
191
208
  result = imul(result, 31) + getNumberHashCode(this.inertiaRear_1) | 0;
192
209
  result = imul(result, 31) + getNumberHashCode(this.wheelRadiusM_1) | 0;
193
210
  result = imul(result, 31) + getNumberHashCode(this.efficiency_1) | 0;
211
+ result = imul(result, 31) + getNumberHashCode(this.maxPedalingLeanAngleDeg_1) | 0;
194
212
  return result;
195
213
  };
196
214
  protoOf(Bike).equals = function (other) {
@@ -208,6 +226,8 @@
208
226
  return false;
209
227
  if (!equals(this.efficiency_1, other.efficiency_1))
210
228
  return false;
229
+ if (!equals(this.maxPedalingLeanAngleDeg_1, other.maxPedalingLeanAngleDeg_1))
230
+ return false;
211
231
  return true;
212
232
  };
213
233
  function Course(path, cyclist, bike) {
@@ -415,6 +435,46 @@
415
435
  return false;
416
436
  return true;
417
437
  };
438
+ function WPrimeBalanceOptions(enabled, criticalPowerW, wPrimeJ) {
439
+ enabled = enabled === VOID ? true : enabled;
440
+ criticalPowerW = criticalPowerW === VOID ? 250.0 : criticalPowerW;
441
+ wPrimeJ = wPrimeJ === VOID ? 20000.0 : wPrimeJ;
442
+ this.enabled_1 = enabled;
443
+ this.criticalPowerW_1 = criticalPowerW;
444
+ this.wPrimeJ_1 = wPrimeJ;
445
+ // Inline function 'kotlin.require' call
446
+ if (!(this.criticalPowerW_1 > 0.0)) {
447
+ var message = 'criticalPowerW must be > 0, got ' + this.criticalPowerW_1;
448
+ throw IllegalArgumentException_init_$Create$(toString(message));
449
+ }
450
+ // Inline function 'kotlin.require' call
451
+ if (!(this.wPrimeJ_1 > 0.0)) {
452
+ var message_0 = 'wPrimeJ must be > 0, got ' + this.wPrimeJ_1;
453
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
454
+ }
455
+ }
456
+ protoOf(WPrimeBalanceOptions).toString = function () {
457
+ return 'WPrimeBalanceOptions(enabled=' + this.enabled_1 + ', criticalPowerW=' + this.criticalPowerW_1 + ', wPrimeJ=' + this.wPrimeJ_1 + ')';
458
+ };
459
+ protoOf(WPrimeBalanceOptions).hashCode = function () {
460
+ var result = getBooleanHashCode(this.enabled_1);
461
+ result = imul(result, 31) + getNumberHashCode(this.criticalPowerW_1) | 0;
462
+ result = imul(result, 31) + getNumberHashCode(this.wPrimeJ_1) | 0;
463
+ return result;
464
+ };
465
+ protoOf(WPrimeBalanceOptions).equals = function (other) {
466
+ if (this === other)
467
+ return true;
468
+ if (!(other instanceof WPrimeBalanceOptions))
469
+ return false;
470
+ if (!(this.enabled_1 === other.enabled_1))
471
+ return false;
472
+ if (!equals(this.criticalPowerW_1, other.criticalPowerW_1))
473
+ return false;
474
+ if (!equals(this.wPrimeJ_1, other.wPrimeJ_1))
475
+ return false;
476
+ return true;
477
+ };
418
478
  function Companion_2() {
419
479
  Companion_instance_2 = this;
420
480
  this.DEFAULT_1 = new EnhanceOptions();
@@ -425,32 +485,35 @@
425
485
  new Companion_2();
426
486
  return Companion_instance_2;
427
487
  }
428
- function EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath) {
488
+ function EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance) {
429
489
  Companion_getInstance_5();
430
490
  fixElevation = fixElevation === VOID ? true : fixElevation;
431
491
  computeMaxSpeeds = computeMaxSpeeds === VOID ? true : computeMaxSpeeds;
432
492
  virtualizeTrack = virtualizeTrack === VOID ? true : virtualizeTrack;
433
493
  computeOnePointPerSecond = computeOnePointPerSecond === VOID ? true : computeOnePointPerSecond;
434
494
  simplifyPath = simplifyPath === VOID ? new SimplifyPathOptions() : simplifyPath;
495
+ wPrimeBalance = wPrimeBalance === VOID ? new WPrimeBalanceOptions() : wPrimeBalance;
435
496
  this.fixElevation_1 = fixElevation;
436
497
  this.computeMaxSpeeds_1 = computeMaxSpeeds;
437
498
  this.virtualizeTrack_1 = virtualizeTrack;
438
499
  this.computeOnePointPerSecond_1 = computeOnePointPerSecond;
439
500
  this.simplifyPath_1 = simplifyPath;
501
+ this.wPrimeBalance_1 = wPrimeBalance;
440
502
  }
441
- protoOf(EnhanceOptions).copy_8buhav_k$ = function (fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath) {
442
- return new EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath);
503
+ protoOf(EnhanceOptions).copy_bazpxz_k$ = function (fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance) {
504
+ return new EnhanceOptions(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance);
443
505
  };
444
- protoOf(EnhanceOptions).copy$default_9zz8ww_k$ = function (fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, $super) {
506
+ protoOf(EnhanceOptions).copy$default_2rfmrp_k$ = function (fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath, wPrimeBalance, $super) {
445
507
  fixElevation = fixElevation === VOID ? this.fixElevation_1 : fixElevation;
446
508
  computeMaxSpeeds = computeMaxSpeeds === VOID ? this.computeMaxSpeeds_1 : computeMaxSpeeds;
447
509
  virtualizeTrack = virtualizeTrack === VOID ? this.virtualizeTrack_1 : virtualizeTrack;
448
510
  computeOnePointPerSecond = computeOnePointPerSecond === VOID ? this.computeOnePointPerSecond_1 : computeOnePointPerSecond;
449
511
  simplifyPath = simplifyPath === VOID ? this.simplifyPath_1 : simplifyPath;
450
- return $super === VOID ? this.copy_8buhav_k$(fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath) : $super.copy_8buhav_k$.call(this, fixElevation, computeMaxSpeeds, virtualizeTrack, computeOnePointPerSecond, simplifyPath);
512
+ 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);
451
514
  };
452
515
  protoOf(EnhanceOptions).toString = function () {
453
- return 'EnhanceOptions(fixElevation=' + this.fixElevation_1 + ', computeMaxSpeeds=' + this.computeMaxSpeeds_1 + ', virtualizeTrack=' + this.virtualizeTrack_1 + ', computeOnePointPerSecond=' + this.computeOnePointPerSecond_1 + ', simplifyPath=' + this.simplifyPath_1.toString() + ')';
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() + ')';
454
517
  };
455
518
  protoOf(EnhanceOptions).hashCode = function () {
456
519
  var result = getBooleanHashCode(this.fixElevation_1);
@@ -458,6 +521,7 @@
458
521
  result = imul(result, 31) + getBooleanHashCode(this.virtualizeTrack_1) | 0;
459
522
  result = imul(result, 31) + getBooleanHashCode(this.computeOnePointPerSecond_1) | 0;
460
523
  result = imul(result, 31) + this.simplifyPath_1.hashCode() | 0;
524
+ result = imul(result, 31) + this.wPrimeBalance_1.hashCode() | 0;
461
525
  return result;
462
526
  };
463
527
  protoOf(EnhanceOptions).equals = function (other) {
@@ -475,6 +539,8 @@
475
539
  return false;
476
540
  if (!this.simplifyPath_1.equals(other.simplifyPath_1))
477
541
  return false;
542
+ if (!this.wPrimeBalance_1.equals(other.wPrimeBalance_1))
543
+ return false;
478
544
  return true;
479
545
  };
480
546
  function $enhanceCourseCOROUTINE$(_this__u8e3s4, course, options, elevationProvider, resultContinuation) {
@@ -532,6 +598,10 @@
532
598
  this.path0__1 = PointPerSecond_instance.computeOnePointPerSecond_7sah9a_k$(this.path0__1);
533
599
  }
534
600
 
601
+ if (this.options_1.wPrimeBalance_1.enabled_1) {
602
+ WPrimeBalanceComputer_instance.compute_ewvoaz_k$(this.path0__1, this.options_1.wPrimeBalance_1);
603
+ }
604
+
535
605
  if (this.options_1.simplifyPath_1.enabled_1) {
536
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);
537
607
  }
@@ -557,7 +627,7 @@
557
627
  return new CoursePhysics(new Course(path), RhoProviderEstimate_instance, AeroProviderConstant_instance, WindProviderNone_instance, new PowerProviderConstant(280.0));
558
628
  };
559
629
  protoOf(Enhancer).enhanceCourseDefault_jm937y_k$ = function (path, elevationProvider, options, $completion) {
560
- return this.enhanceCourse_mout3j_k$(this.getDefaultCourse_gqi1xw_k$(path), options.copy$default_9zz8ww_k$(options.fixElevation_1 && !(elevationProvider == null)), elevationProvider, $completion);
630
+ return this.enhanceCourse_mout3j_k$(this.getDefaultCourse_gqi1xw_k$(path), options.copy$default_2rfmrp_k$(options.fixElevation_1 && !(elevationProvider == null)), elevationProvider, $completion);
561
631
  };
562
632
  protoOf(Enhancer).enhanceCourse_mout3j_k$ = function (course, options, elevationProvider, $completion) {
563
633
  var tmp = new $enhanceCourseCOROUTINE$(this, course, options, elevationProvider, $completion);
@@ -1354,9 +1424,15 @@
1354
1424
  function computeCorneringLimit($this, course, currentIndex, window_0) {
1355
1425
  var path = course.path_1;
1356
1426
  var radius = computeRadiusWindowed($this, path, currentIndex, window_0);
1357
- // Inline function 'kotlin.math.sqrt' call
1358
- var x = 9.80665 * radius * course.cyclist_1.get_tanMaxLeanAngle_qqiag1_k$();
1359
- var vMax = Math.sqrt(x);
1427
+ var tmp;
1428
+ if (radius >= 200.0) {
1429
+ tmp = course.cyclist_1.get_maxSpeedMS_xz2r7y_k$();
1430
+ } else {
1431
+ // Inline function 'kotlin.math.sqrt' call
1432
+ var x = 9.80665 * radius * course.cyclist_1.get_tanMaxLeanAngle_qqiag1_k$();
1433
+ tmp = Math.sqrt(x);
1434
+ }
1435
+ var vMax = tmp;
1360
1436
  // Inline function 'kotlin.math.min' call
1361
1437
  var a = course.cyclist_1.get_maxSpeedMS_xz2r7y_k$();
1362
1438
  var result = Math.min(a, vMax);
@@ -1387,14 +1463,46 @@
1387
1463
  path.setRadius_p1cueq_k$(i, clamped);
1388
1464
  return clamped;
1389
1465
  }
1390
- function computeBrakingLimit($this, course, currentIndex, nextIndex) {
1466
+ function computeBrakingLimit($this, course, currentIndex, nextIndex, corneringLimit) {
1391
1467
  var path = course.path_1;
1392
1468
  var vf = path.speedMax_mjo2cl_k$(nextIndex);
1393
- var a = course.cyclist_1.get_maxBrakeMS2_nzouxw_k$();
1469
+ var aXMax = course.cyclist_1.get_maxBrakeMS2_nzouxw_k$();
1394
1470
  var d = path.distance_5s4s77_k$(nextIndex) - path.distance_5s4s77_k$(currentIndex);
1471
+ var radius = path.radius_84q0sm_k$(currentIndex);
1472
+ if (radius >= 200.0 || !isFinite(radius) || radius <= 0.0) {
1473
+ // Inline function 'kotlin.math.sqrt' call
1474
+ var x = vf * vf + 2.0 * aXMax * d;
1475
+ // Inline function 'kotlin.math.min' call
1476
+ var b = Math.sqrt(x);
1477
+ return Math.min(corneringLimit, b);
1478
+ }
1479
+ var aYMax = 9.80665 * course.cyclist_1.get_tanMaxLeanAngle_qqiag1_k$();
1480
+ if (computeBrakingLimit$slack(radius, aYMax, aXMax, vf, d, corneringLimit) >= 0.0)
1481
+ return corneringLimit;
1482
+ // Inline function 'kotlin.math.min' call
1483
+ var low = Math.min(vf, corneringLimit);
1484
+ var high = corneringLimit;
1485
+ // Inline function 'kotlin.repeat' call
1486
+ var inductionVariable = 0;
1487
+ if (inductionVariable < 24)
1488
+ do {
1489
+ var index = inductionVariable;
1490
+ inductionVariable = inductionVariable + 1 | 0;
1491
+ var mid = (low + high) / 2.0;
1492
+ if (computeBrakingLimit$slack(radius, aYMax, aXMax, vf, d, mid) >= 0.0)
1493
+ low = mid;
1494
+ else
1495
+ high = mid;
1496
+ }
1497
+ while (inductionVariable < 24);
1498
+ return low;
1499
+ }
1500
+ function computeBrakingLimit$slack(radius, aYMax, aXMax, vf, d, v) {
1501
+ var lateralFraction = coerceIn(v * v / radius / aYMax, 0.0, 1.0);
1395
1502
  // Inline function 'kotlin.math.sqrt' call
1396
- var x = vf * vf + 2.0 * a * d;
1397
- return Math.sqrt(x);
1503
+ var x = 1.0 - lateralFraction * lateralFraction;
1504
+ var aX = aXMax * Math.sqrt(x);
1505
+ return vf * vf + 2.0 * aX * d - v * v;
1398
1506
  }
1399
1507
  function MaxSpeedComputer() {
1400
1508
  this.MAX_RADIUS_M_1 = 200.0;
@@ -1402,6 +1510,7 @@
1402
1510
  this.END_SPEED_MS_1 = 2.0;
1403
1511
  this.BEARING_THRESHOLD_1 = 0.001;
1404
1512
  this.DEFAULT_WINDOW_1 = 10;
1513
+ this.ELLIPSE_ITERATIONS_1 = 24;
1405
1514
  }
1406
1515
  protoOf(MaxSpeedComputer).computeMaxSpeeds_jc4v4o_k$ = function (course) {
1407
1516
  var path = course.path_1;
@@ -1415,10 +1524,7 @@
1415
1524
  path.setSpeedMax_7xvqir_k$(i, 2.0);
1416
1525
  } else {
1417
1526
  var cornering = computeCorneringLimit(this, course, i, 10);
1418
- var braking = computeBrakingLimit(this, course, i, i + 1 | 0);
1419
- // Inline function 'kotlin.math.min' call
1420
- var tmp$ret$0 = Math.min(cornering, braking);
1421
- path.setSpeedMax_7xvqir_k$(i, tmp$ret$0);
1527
+ path.setSpeedMax_7xvqir_k$(i, computeBrakingLimit(this, course, i, i + 1 | 0, cornering));
1422
1528
  }
1423
1529
  }
1424
1530
  while (0 <= inductionVariable);
@@ -1439,12 +1545,23 @@
1439
1545
  function MuscularPowerProvider() {
1440
1546
  }
1441
1547
  protoOf(MuscularPowerProvider).powerAt_ejucaq_k$ = function (course, path, pointIndex) {
1442
- var muscular = course.cyclistPowerProvider_1.powerAt_ejucaq_k$(course, path, pointIndex);
1548
+ var intent = course.cyclistPowerProvider_1.powerAt_ejucaq_k$(course, path, pointIndex);
1549
+ var muscular = this.pedalsClear_b5t5mh_k$(course, path, pointIndex) ? intent : 0.0;
1443
1550
  path.setPCyclistProvidedMuscular_aori9q_k$(pointIndex, muscular);
1444
1551
  var wheel = muscular * course.get_bike_wojgoa_k$().efficiency_1;
1445
1552
  path.setPCyclistProvidedWheel_ofsihz_k$(pointIndex, wheel);
1446
1553
  return wheel;
1447
1554
  };
1555
+ protoOf(MuscularPowerProvider).pedalsClear_b5t5mh_k$ = function (course, path, pointIndex) {
1556
+ var radius = path.radius_84q0sm_k$(pointIndex);
1557
+ if (!isFinite(radius) || radius <= 0.0)
1558
+ return true;
1559
+ var speed = path.speed_npav2n_k$(pointIndex);
1560
+ if (!isFinite(speed))
1561
+ return true;
1562
+ var tanLean = speed * speed / (9.80665 * radius);
1563
+ return tanLean <= course.get_bike_wojgoa_k$().get_tanMaxPedalingLeanAngle_nft7tz_k$();
1564
+ };
1448
1565
  var MuscularPowerProvider_instance;
1449
1566
  function MuscularPowerProvider_getInstance() {
1450
1567
  return MuscularPowerProvider_instance;
@@ -1452,7 +1569,9 @@
1452
1569
  function getDtInner($this, pSum, equivalentMass, currentSpeed, dx, dt1Init, dt2Init) {
1453
1570
  var dt1 = dt1Init;
1454
1571
  var dt2 = dt2Init;
1455
- var tol = dx / 1.0E7;
1572
+ // Inline function 'kotlin.math.max' call
1573
+ var a = dx / 1.0E7;
1574
+ var tol = Math.max(a, 1.0E-12);
1456
1575
  while (dt2 - dt1 >= tol) {
1457
1576
  var dtMid = (dt1 + dt2) / 2.0;
1458
1577
  var dxMid = $this.getDx_xtszre_k$(pSum, equivalentMass, currentSpeed, dtMid);
@@ -1464,6 +1583,7 @@
1464
1583
  return (dt1 + dt2) / 2.0;
1465
1584
  }
1466
1585
  function PowerComputer() {
1586
+ this.MIN_DT_TOLERANCE_1 = 1.0E-12;
1467
1587
  }
1468
1588
  protoOf(PowerComputer).getNewPower_puvq9i_k$ = function (course, path, pointIndex, withCyclist) {
1469
1589
  var pSum = 0.0;
@@ -1477,12 +1597,14 @@
1477
1597
  return pSum;
1478
1598
  };
1479
1599
  protoOf(PowerComputer).getDx_xtszre_k$ = function (pSum, equivalentMass, currentSpeed, dt) {
1600
+ // Inline function 'kotlin.math.max' call
1601
+ var b = dt * pSum / (0.5 * equivalentMass) + currentSpeed * currentSpeed;
1480
1602
  // Inline function 'kotlin.math.sqrt' call
1481
- var x = dt * pSum / (0.5 * equivalentMass) + currentSpeed * currentSpeed;
1603
+ var x = Math.max(0.0, b);
1482
1604
  var tmp0 = Math.sqrt(x);
1483
1605
  // Inline function 'kotlin.math.max' call
1484
- var b = 0.5555555555555556;
1485
- var newSpeed = Math.max(tmp0, b);
1606
+ var b_0 = 0.5555555555555556;
1607
+ var newSpeed = Math.max(tmp0, b_0);
1486
1608
  return (currentSpeed + newSpeed) * dt / 2.0;
1487
1609
  };
1488
1610
  protoOf(PowerComputer).getTotPower_kfbciq_k$ = function (equivalentMass, s1, s2, dt) {
@@ -1497,17 +1619,28 @@
1497
1619
  };
1498
1620
  protoOf(PowerComputer).computeCyclistPower_kgcsa3_k$ = function (course, path, equivalentMass, i) {
1499
1621
  if (i === 0) {
1622
+ path.setPComputedPower_c3m6yw_k$(i, 0.0);
1623
+ path.setPBrake_iza4qj_k$(i, 0.0);
1624
+ return Unit_instance;
1625
+ }
1626
+ var dtSeconds = path.dt_17uzp4_k$(i) / 1000.0;
1627
+ if (dtSeconds <= 0.0) {
1628
+ path.setPComputedTotalPower_wm6di_k$(i, 0.0);
1629
+ path.setPComputedWheelPower_qplog3_k$(i, 0.0);
1630
+ path.setPBrake_iza4qj_k$(i, 0.0);
1500
1631
  path.setPComputedPower_c3m6yw_k$(i, 0.0);
1501
1632
  return Unit_instance;
1502
1633
  }
1503
1634
  var resistive = this.getNewPower_puvq9i_k$(course, path, i - 1 | 0, false);
1504
1635
  var s1 = path.speed_npav2n_k$(i - 1 | 0);
1505
1636
  var s2 = path.speed_npav2n_k$(i);
1506
- var dtSeconds = path.dt_17uzp4_k$(i) / 1000.0;
1507
1637
  var totPower = this.getTotPower_kfbciq_k$(equivalentMass, s1, s2, dtSeconds);
1508
1638
  path.setPComputedTotalPower_wm6di_k$(i, totPower);
1509
1639
  var powerWheel = totPower - resistive;
1510
1640
  path.setPComputedWheelPower_qplog3_k$(i, powerWheel);
1641
+ // Inline function 'kotlin.math.min' call
1642
+ var tmp$ret$0 = Math.min(0.0, powerWheel);
1643
+ path.setPBrake_iza4qj_k$(i, tmp$ret$0);
1511
1644
  // Inline function 'kotlin.math.max' call
1512
1645
  var computed = Math.max(0.0, powerWheel) / course.get_bike_wojgoa_k$().efficiency_1;
1513
1646
  path.setPComputedPower_c3m6yw_k$(i, computed);
@@ -1533,24 +1666,86 @@
1533
1666
  protoOf(PowerProviderConstant).optimalPower_36kg19_k$ = function (course, path, pointIndex) {
1534
1667
  return this.power_1;
1535
1668
  };
1536
- function PowerProviderConstantWithTiring(power, useHarmonics, durationSeconds, random) {
1669
+ function Companion_6() {
1670
+ this.DEFAULT_DECLINE_PER_KJ_PER_KG_1 = 0.006666666666666667;
1671
+ this.DEFAULT_MAX_DECLINE_1 = 0.2;
1672
+ }
1673
+ var Companion_instance_6;
1674
+ function Companion_getInstance_9() {
1675
+ return Companion_instance_6;
1676
+ }
1677
+ function PowerProviderDurability(powerW, criticalPowerW, declinePerKjPerKg, maxDecline, useHarmonics, random) {
1678
+ criticalPowerW = criticalPowerW === VOID ? 250.0 : criticalPowerW;
1679
+ declinePerKjPerKg = declinePerKjPerKg === VOID ? 0.006666666666666667 : declinePerKjPerKg;
1680
+ maxDecline = maxDecline === VOID ? 0.2 : maxDecline;
1537
1681
  useHarmonics = useHarmonics === VOID ? false : useHarmonics;
1538
1682
  random = random === VOID ? Default_getInstance() : random;
1539
1683
  CyclistPowerProviderBase.call(this, useHarmonics, random);
1540
- this.power_1 = power;
1541
- this.durationSeconds_1 = durationSeconds;
1684
+ this.powerW_1 = powerW;
1685
+ this.criticalPowerW_1 = criticalPowerW;
1686
+ this.declinePerKjPerKg_1 = declinePerKjPerKg;
1687
+ this.maxDecline_1 = maxDecline;
1542
1688
  // Inline function 'kotlin.require' call
1543
- if (!(this.durationSeconds_1 > 0.0)) {
1544
- var message = 'durationSeconds must be > 0, got ' + this.durationSeconds_1;
1689
+ if (!(this.powerW_1 > 0.0)) {
1690
+ var message = 'powerW must be > 0, got ' + this.powerW_1;
1545
1691
  throw IllegalArgumentException_init_$Create$(toString(message));
1546
1692
  }
1547
- }
1548
- protoOf(PowerProviderConstantWithTiring).optimalPower_36kg19_k$ = function (course, path, pointIndex) {
1549
- var elapsedS = path.elapsed_7307rw_k$(pointIndex) / 1000.0;
1550
- // Inline function 'kotlin.math.max' call
1551
- var b = 1.0 - 0.6 * elapsedS / this.durationSeconds_1;
1552
- var c = Math.max(0.5, b);
1553
- return this.power_1 * c;
1693
+ // Inline function 'kotlin.require' call
1694
+ if (!(this.criticalPowerW_1 > 0.0)) {
1695
+ var message_0 = 'criticalPowerW must be > 0, got ' + this.criticalPowerW_1;
1696
+ throw IllegalArgumentException_init_$Create$(toString(message_0));
1697
+ }
1698
+ // Inline function 'kotlin.require' call
1699
+ if (!(this.declinePerKjPerKg_1 >= 0.0)) {
1700
+ var message_1 = 'declinePerKjPerKg must be >= 0, got ' + this.declinePerKjPerKg_1;
1701
+ throw IllegalArgumentException_init_$Create$(toString(message_1));
1702
+ }
1703
+ var containsArg = this.maxDecline_1;
1704
+ // Inline function 'kotlin.require' call
1705
+ if (!(0.0 <= containsArg ? containsArg <= 1.0 : false)) {
1706
+ var message_2 = 'maxDecline must be in [0, 1], got ' + this.maxDecline_1;
1707
+ throw IllegalArgumentException_init_$Create$(toString(message_2));
1708
+ }
1709
+ this.lastIndex_1 = -1;
1710
+ this.lastElapsedS_1 = 0.0;
1711
+ this.lastPowerW_1 = 0.0;
1712
+ this.supraCriticalWorkJ_1 = 0.0;
1713
+ this.massKgForDose_1 = 80.0;
1714
+ }
1715
+ protoOf(PowerProviderDurability).get_decline_qrtukt_k$ = function () {
1716
+ var tmp0 = this.maxDecline_1;
1717
+ // Inline function 'kotlin.math.min' call
1718
+ var b = this.declinePerKjPerKg_1 * this.supraCriticalWorkJ_1 / 1000.0 / this.massKgForDose_1;
1719
+ return Math.min(tmp0, b);
1720
+ };
1721
+ protoOf(PowerProviderDurability).optimalPower_36kg19_k$ = function (course, path, pointIndex) {
1722
+ this.massKgForDose_1 = course.get_cyclist_lkc0de_k$().massKg_1;
1723
+ if (pointIndex < this.lastIndex_1) {
1724
+ this.reset_5u6xz3_k$();
1725
+ }
1726
+ if (pointIndex > this.lastIndex_1) {
1727
+ var elapsedS = path.elapsed_7307rw_k$(pointIndex) / 1000.0;
1728
+ var dtS = elapsedS - this.lastElapsedS_1;
1729
+ if (dtS > 0.0 && isFinite(dtS)) {
1730
+ var tmp = this;
1731
+ var tmp_0 = this.supraCriticalWorkJ_1;
1732
+ // Inline function 'kotlin.math.max' call
1733
+ var b = this.lastPowerW_1 - this.criticalPowerW_1;
1734
+ tmp.supraCriticalWorkJ_1 = tmp_0 + Math.max(0.0, b) * dtS;
1735
+ }
1736
+ if (isFinite(elapsedS))
1737
+ this.lastElapsedS_1 = elapsedS;
1738
+ this.lastIndex_1 = pointIndex;
1739
+ }
1740
+ var faded = this.powerW_1 * (1.0 - this.get_decline_qrtukt_k$());
1741
+ this.lastPowerW_1 = faded;
1742
+ return faded;
1743
+ };
1744
+ protoOf(PowerProviderDurability).reset_5u6xz3_k$ = function () {
1745
+ this.lastIndex_1 = -1;
1746
+ this.lastElapsedS_1 = 0.0;
1747
+ this.lastPowerW_1 = 0.0;
1748
+ this.supraCriticalWorkJ_1 = 0.0;
1554
1749
  };
1555
1750
  function PowerProviderFromData() {
1556
1751
  }
@@ -1644,8 +1839,19 @@
1644
1839
  out.setVirtSpeedCurrent_kvg8yv_k$(0, speed);
1645
1840
  var i = 1;
1646
1841
  var iter = 0;
1647
- $l$loop: while (i < n) {
1842
+ $l$loop_0: while (i < n) {
1648
1843
  var dx = input.distance_5s4s77_k$(i) - input.distance_5s4s77_k$(i - 1 | 0);
1844
+ if (dx <= 0.0) {
1845
+ copyAllFields(this, input, i, out, i);
1846
+ out.setTime_rfmvcd_k$(i, timeMs);
1847
+ out.setElapsed_916ug_k$(i, timeMs - startTimeMs);
1848
+ out.setDx_uk0ky4_k$(i, 0.0);
1849
+ out.setDt_sgarxs_k$(i, 0.0);
1850
+ out.setSpeed_1slan1_k$(i, speed);
1851
+ out.setVirtSpeedCurrent_kvg8yv_k$(i, speed);
1852
+ i = i + 1 | 0;
1853
+ continue $l$loop_0;
1854
+ }
1649
1855
  var pSum = PowerComputer_instance.getNewPower_puvq9i_k$(course, out, i - 1 | 0, true);
1650
1856
  var dt = PowerComputer_instance.getDt_t0pcee_k$(pSum, mEq, speed, dx);
1651
1857
  var speedNew = 2.0 * dx / dt - speed;
@@ -1667,7 +1873,7 @@
1667
1873
  var _unary__edvuaz = iter;
1668
1874
  iter = _unary__edvuaz + 1 | 0;
1669
1875
  if (_unary__edvuaz > 100000)
1670
- break $l$loop;
1876
+ break $l$loop_0;
1671
1877
  }
1672
1878
  var progression = out.get_indices_xelk8u_k$();
1673
1879
  var inductionVariable = progression.first_1;
@@ -1698,18 +1904,18 @@
1698
1904
  function WheelBearingsPowerProvider_getInstance() {
1699
1905
  return WheelBearingsPowerProvider_instance;
1700
1906
  }
1701
- function Companion_6() {
1702
- Companion_instance_6 = this;
1907
+ function Companion_7() {
1908
+ Companion_instance_7 = this;
1703
1909
  this.NONE_1 = new Wind(0.0, 0.0);
1704
1910
  }
1705
- var Companion_instance_6;
1706
- function Companion_getInstance_9() {
1707
- if (Companion_instance_6 == null)
1708
- new Companion_6();
1709
- return Companion_instance_6;
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;
1710
1916
  }
1711
1917
  function Wind(speedMS, directionRad) {
1712
- Companion_getInstance_9();
1918
+ Companion_getInstance_10();
1713
1919
  this.speedMS_1 = speedMS;
1714
1920
  this.directionRad_1 = directionRad;
1715
1921
  }
@@ -1735,7 +1941,7 @@
1735
1941
  function WindProviderNone() {
1736
1942
  }
1737
1943
  protoOf(WindProviderNone).wind_umf2tf_k$ = function (course, path, pointIndex) {
1738
- return Companion_getInstance_9().NONE_1;
1944
+ return Companion_getInstance_10().NONE_1;
1739
1945
  };
1740
1946
  var WindProviderNone_instance;
1741
1947
  function WindProviderNone_getInstance() {
@@ -1747,6 +1953,50 @@
1747
1953
  protoOf(WindProviderConstant).wind_umf2tf_k$ = function (course, path, pointIndex) {
1748
1954
  return this.wind_1;
1749
1955
  };
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;
1967
+ if (inductionVariable < last)
1968
+ do {
1969
+ var i = inductionVariable;
1970
+ 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);
1975
+ }
1976
+ path.setWPrimeBalance_stwqkw_k$(i, balance);
1977
+ }
1978
+ while (inductionVariable < last);
1979
+ };
1980
+ protoOf(WPrimeBalanceComputer).step_447nu7_k$ = function (balance, power, cp, wPrime, dtSeconds) {
1981
+ var tmp;
1982
+ if (power >= cp) {
1983
+ tmp = balance - (power - cp) * dtSeconds;
1984
+ } 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);
1989
+ }
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);
1995
+ };
1996
+ var WPrimeBalanceComputer_instance;
1997
+ function WPrimeBalanceComputer_getInstance() {
1998
+ return WPrimeBalanceComputer_instance;
1999
+ }
1750
2000
  function parseGpxWaypoints(xml) {
1751
2001
  // Inline function 'kotlin.collections.map' call
1752
2002
  var this_0 = GpxParser_instance.parse$default_ez0f31_k$(xml).waypoints_1;
@@ -2013,7 +2263,13 @@
2013
2263
  function toBike(_this__u8e3s4) {
2014
2264
  if (_this__u8e3s4 == null)
2015
2265
  return new Bike();
2016
- return new Bike(_this__u8e3s4.crr, _this__u8e3s4.inertiaFront, _this__u8e3s4.inertiaRear, _this__u8e3s4.wheelRadiusM, _this__u8e3s4.efficiency);
2266
+ var tmp = _this__u8e3s4.crr;
2267
+ var tmp_0 = _this__u8e3s4.inertiaFront;
2268
+ var tmp_1 = _this__u8e3s4.inertiaRear;
2269
+ var tmp_2 = _this__u8e3s4.wheelRadiusM;
2270
+ var tmp_3 = _this__u8e3s4.efficiency;
2271
+ var tmp0_elvis_lhs = _this__u8e3s4.maxPedalingLeanAngleDeg;
2272
+ return new Bike(tmp, tmp_0, tmp_1, tmp_2, tmp_3, tmp0_elvis_lhs == null ? 20.0 : tmp0_elvis_lhs);
2017
2273
  }
2018
2274
  function toWindProvider(_this__u8e3s4) {
2019
2275
  if (_this__u8e3s4 == null)
@@ -2031,13 +2287,13 @@
2031
2287
  var tmp2_elvis_lhs = _this__u8e3s4.useHarmonics;
2032
2288
  tmp = new PowerProviderConstant(tmp_0, tmp2_elvis_lhs == null ? false : tmp2_elvis_lhs);
2033
2289
  break;
2034
- case 'constant_tiring':
2290
+ case 'durability':
2035
2291
  var tmp3_elvis_lhs = _this__u8e3s4.power;
2036
2292
  var tmp_1 = tmp3_elvis_lhs == null ? 250.0 : tmp3_elvis_lhs;
2037
- var tmp4_elvis_lhs = _this__u8e3s4.useHarmonics;
2038
- var tmp_2 = tmp4_elvis_lhs == null ? false : tmp4_elvis_lhs;
2039
- var tmp5_elvis_lhs = _this__u8e3s4.tiringDuration;
2040
- tmp = new PowerProviderConstantWithTiring(tmp_1, tmp_2, tmp5_elvis_lhs == null ? 7200.0 : tmp5_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);
2041
2297
  break;
2042
2298
  case 'from_data':
2043
2299
  tmp = PowerProviderFromData_instance;
@@ -2223,6 +2479,7 @@
2223
2479
  MaxSpeedComputer_instance = new MaxSpeedComputer();
2224
2480
  MuscularPowerProvider_instance = new MuscularPowerProvider();
2225
2481
  PowerComputer_instance = new PowerComputer();
2482
+ Companion_instance_6 = new Companion_6();
2226
2483
  PowerProviderFromData_instance = new PowerProviderFromData();
2227
2484
  RhoProviderDefault_instance = new RhoProviderDefault();
2228
2485
  RhoProviderEstimate_instance = new RhoProviderEstimate();
@@ -2230,6 +2487,7 @@
2230
2487
  VirtualizeService_instance = new VirtualizeService();
2231
2488
  WheelBearingsPowerProvider_instance = new WheelBearingsPowerProvider();
2232
2489
  WindProviderNone_instance = new WindProviderNone();
2490
+ WPrimeBalanceComputer_instance = new WPrimeBalanceComputer();
2233
2491
  //endregion
2234
2492
  //region block: exports
2235
2493
  function $jsExportAll$(_) {