17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-18 11:29:20 +02:00

Switches: lay the pre-blade lead and the blade, not a tangent arc

A turnout's diverging track does not leave the through track tangentially. It
runs straight along the through track to the blade tip (odcinek przediglicowy),
breaks away there by the blade angle (kąt nagięcia iglicy, beta), runs straight
over the blade to its heel, and only then curves - through alfa - beta, not the
whole crossing angle - to the frog.

Give TurnoutSegment a turn_in: a signed heading break applied before the segment
is laid, which is the only way to express a track leaving by an angle rather than
a tangent. lay_turnout then places the lead, the break and the blade ahead of the
curve and hands the curve the angle that is actually left to spend; a zero blade
length keeps the break and starts the curve at the tip. Reject a blade angle that
is negative or already reaches the crossing angle.

All-zero blade figures lay exactly the old tangent arc from PR, so existing
layouts are untouched. Junction and turnout_preset carry the three new figures
through to the panel; the presets themselves still hold zeros until the Id-1
catalogue numbers are in.

Add test_turnout: the lead sits on the through track, the blade breaks by beta,
and the frog still lands on the full crossing angle and the catalogue length,
mirrored for a right-hand turnout.
This commit is contained in:
maj00r
2026-08-27 19:36:52 +02:00
parent 4ae24114ba
commit 8cd42980e6
10 changed files with 223 additions and 25 deletions

View File

@@ -281,7 +281,9 @@ domain::Turnout to_turnout(const Junction& junction) {
return domain::Turnout{
domain::CrossingMark{junction.crossing_n},
junction.side == 0 ? domain::DivergeSide::Left : domain::DivergeSide::Right,
std::move(curve), junction.length};
std::move(curve), junction.length,
junction.pre_blade, junction.blade_angle,
junction.blade_length};
}
// The drawable geometry of one switch. @p station is the switch's start on the
@@ -319,6 +321,13 @@ JunctionGeom solve_junction(const Junction& junction,
std::abs(segment.k1 - segment.k0) >= 1e-12 ? render::ElementKind::Transition
: std::abs(segment.k0) >= 1e-12 ? render::ElementKind::Arc
: render::ElementKind::Straight;
// the blade's heading break happens in place, before the segment is laid
if (segment.turn_in != 0.0) {
const double c = std::cos(segment.turn_in);
const double s = std::sin(segment.turn_in);
pose = Pose{pose.x, pose.y, pose.hx * c - pose.hy * s,
pose.hx * s + pose.hy * c};
}
pose = layout_segment(segment.k0, segment.k1, segment.length, pose, &pts);
element.points.reserve(pts.size());
for (const auto& p : pts) element.points.push_back(render::Point{p.x, p.y});