17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 10:59:20 +02:00
Files
maszyna/editor/turnouts.cpp
maj00r 8cd42980e6 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.
2026-08-27 19:36:56 +02:00

38 lines
1.5 KiB
C++

/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "stdafx.h"
#include "editor/turnouts.h"
namespace editor
{
std::vector<turnout_preset> const &turnout_presets()
{
// the standard PKP rozjazdy zwyczajne (49E1 / 60E1). crossing mark, radius and catalogue length
// (PR→KR along the through track). the crossing angles check out as atan(1/n); the lengths follow
// the type tables (metres). the diverging leaves not tangent but at the blade angle (beta) after a
// straight pre-blade lead, then arcs by (alfa - beta) to the frog.
//
// blade_angle, pre_blade and blade_length are NOT yet from Id-1 - left at 0, which lays a tangent
// arc straight from PR. Fill them per type when the catalogue figures are in; the geometry
// (domain::lay_turnout) already lays the pre-blade lead, the blade break and the shortened arc.
static std::vector<turnout_preset> const presets{
{"Rz 1:7,5 R190", 7.5, 190.0, 25.222, 0.0, 0.0, 0.0},
{"Rz 1:9 R190", 9.0, 190.0, 27.138, 0.0, 0.0, 0.0},
{"Rz 1:9 R300", 9.0, 300.0, 33.230, 0.0, 0.0, 0.0},
{"Rz 1:12 R500", 12.0, 500.0, 41.594, 0.0, 0.0, 0.0},
{"Rz 1:14 R500", 14.0, 500.0, 42.371, 0.0, 0.0, 0.0},
{"Rz 1:14 R760", 14.0, 760.0, 54.216, 0.0, 0.0, 0.0},
{"Rz 1:18,5 R1200", 18.5, 1200.0, 64.818, 0.0, 0.0, 0.0}};
return presets;
}
} // namespace editor