@willcgage/module-schematic 0.59.0 → 0.60.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
@@ -1475,6 +1475,32 @@ function turnoutClosure(size, opts = {}) {
1475
1475
  }
1476
1476
  };
1477
1477
  }
1478
+ function frogCasting(cl, opts = {}) {
1479
+ const g = opts.gaugeInches ?? RAIL_GAUGE_INCHES;
1480
+ const w = opts.reachInches ?? g * 1.5;
1481
+ const fw = opts.flangewayInches ?? g * 0.12;
1482
+ const m = cl.frogSlope;
1483
+ const lead = cl.lead;
1484
+ const apex = { x: lead, y: g / 2 };
1485
+ const point = [
1486
+ { x: lead + w, y: g / 2 },
1487
+ apex,
1488
+ { x: lead + w, y: g / 2 + m * w }
1489
+ ];
1490
+ const wings = [
1491
+ [
1492
+ { x: lead - w, y: g / 2 - fw },
1493
+ { x: lead - w * 0.35, y: g / 2 - fw },
1494
+ { x: lead + w * 0.35, y: g / 2 - fw * 0.5 }
1495
+ ],
1496
+ [
1497
+ { x: lead - w, y: g / 2 + m * -w + fw },
1498
+ { x: lead - w * 0.35, y: g / 2 + m * -w * 0.35 + fw },
1499
+ { x: lead + w * 0.35, y: g / 2 + m * w * 0.35 + fw * 0.5 }
1500
+ ]
1501
+ ];
1502
+ return { point, wings, apex };
1503
+ }
1478
1504
  function divergeSideForHand(kind, stubDir, flipped) {
1479
1505
  if (kind !== "left" && kind !== "right") return 0;
1480
1506
  const s = (stubDir >= 0 ? 1 : -1) * (flipped ? -1 : 1);
@@ -1541,7 +1567,7 @@ function moduleFeatures(doc) {
1541
1567
  if (parentLane === 0) {
1542
1568
  const [from, to] = ext;
1543
1569
  const far = Math.abs(to - sw.pos) >= Math.abs(from - sw.pos) ? to : from;
1544
- const s = divergeSideForHand(sw.kind, far - sw.pos);
1570
+ const s = divergeSideForHand(sw.kind, far - sw.pos, sw.flipped);
1545
1571
  sign = s !== 0 ? s : Math.sign(trk.lane) || 1;
1546
1572
  } else {
1547
1573
  sign = Math.sign(parentLane) || 1;
@@ -2021,6 +2047,7 @@ exports.endplateLead = endplateLead;
2021
2047
  exports.endplateTrackOffsetFor = endplateTrackOffsetFor;
2022
2048
  exports.endplateTrackOffsetInches = endplateTrackOffsetInches;
2023
2049
  exports.endplateWidthInches = endplateWidthInches;
2050
+ exports.frogCasting = frogCasting;
2024
2051
  exports.frogNumberFromName = frogNumberFromName;
2025
2052
  exports.fromSectionRelative = fromSectionRelative;
2026
2053
  exports.geometryTurnDegrees = geometryTurnDegrees;