@willcgage/module-schematic 0.72.0 → 0.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -577,6 +577,20 @@ function scaleFeetToInches(feet, ratio = N_SCALE_RATIO) {
577
577
  return feet * 12 / ratio;
578
578
  }
579
579
  var N_CAR_LENGTH_INCHES = 3.3;
580
+ function spanOverhang(input) {
581
+ const lo = Math.min(input.fromPos, input.toPos);
582
+ const hi = Math.max(input.fromPos, input.toPos);
583
+ const tLo = Math.min(input.trackFromPos, input.trackToPos);
584
+ const tHi = Math.max(input.trackFromPos, input.trackToPos);
585
+ const before = Math.max(0, tLo - lo);
586
+ const after = Math.max(0, hi - tHi);
587
+ return {
588
+ beforeInches: before,
589
+ afterInches: after,
590
+ onTrackInches: Math.max(0, Math.min(hi, tHi) - Math.max(lo, tLo)),
591
+ overhangInches: before + after
592
+ };
593
+ }
580
594
  function carCapacity(fromPos, toPos, carLengthInches = N_CAR_LENGTH_INCHES) {
581
595
  if (!(carLengthInches > 0)) return 0;
582
596
  return Math.max(0, Math.floor(Math.abs(toPos - fromPos) / carLengthInches));
@@ -2414,6 +2428,7 @@ exports.sectionSpansOrWhole = sectionSpansOrWhole;
2414
2428
  exports.sectionedCenterline = sectionedCenterline;
2415
2429
  exports.sectionedEndPose = sectionedEndPose;
2416
2430
  exports.sliceCenterline = sliceCenterline;
2431
+ exports.spanOverhang = spanOverhang;
2417
2432
  exports.stateToDoc = stateToDoc;
2418
2433
  exports.storedPartToTrackPart = storedPartToTrackPart;
2419
2434
  exports.toSectionRelative = toSectionRelative;