mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 09:27:10 +01:00
31dc959cec
The formula Q2 gave the editor (editor_mode::branch_speed_of) taken out into a pure function of the switch curve module, which the domain model of the track geometry (editor/layout, E2b) calls for its turnouts too, so the two write the same speed. - switch_curve::branch_speed(): of the basic switch of R and 1:n, its main track bent by table 11.8, the cant with its sign toward the side the diverging track leaves to: formula 9.9 with the normal deficiency of the frog (table 9.7), rounded down to the steps of the speed limits, no more than table 11.2 gives the basic switch. It reports the radius, the cant into the turn, the deficiency, the formula, the rounded speed and the table, which the editor's message tells. - switch_curve::basic_speed(): table 11.2, moved from editor_track::diverging_speed(), which now returns it. - switch_curve::written_velocity(): the one velocity a switch keeps, the main limit for both where it's the lower, else the diverging one below 0; write_switch_speed() calls it. - speed_check::suggested() inline in editorSpeed.hpp, so the switch curve module takes it in the unit tests, which don't build the checks of the speed. The editor computes the same numbers the same way: the basic radius and the bent main radius as before (bent only where the type is known), the cant toward the diverging side the same product, its sign flipped by the bent radius as before (a multiplication by -1, exact), then the same calls in the same order. tests/unit/test_switch_curve.cpp unchanged and passing. Tests (U): the examples of Q2 through branch_speed (Rz 60E1-500-1:12 outward in R 1200 m with 60 mm 60 km/h, inward 60 by the table; Rz 60E1-190-1:9 in R 600 m with 60 mm 30 and 40 km/h), the table of the basic switches, a movable nose kept to 130 km/h, a diverging track bent straight, the editor's table the same, the velocity written.
167 lines
9.2 KiB
C++
167 lines
9.2 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/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <array>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
// a switch laid into a curve or into a transition curve, as the standard of PKP PLK ST-T1-A6 sees it: the curvatures of its tracks
|
|
// (9.7 pkt 12, 11.4, table 11.9) and the cant along it, which is to stay the same over it or be ramped from its ends (9.6 pkt
|
|
// 16-17, 11.4 pkt 7, table 9.6)
|
|
namespace switch_curve
|
|
{
|
|
|
|
// a point of a track in the plan: how far along it, which way it heads (radians, growing as it turns to the left), its cant (mm)
|
|
struct track_point
|
|
{
|
|
double station{0.0};
|
|
double heading{0.0};
|
|
double cant{0.0};
|
|
};
|
|
|
|
// the curvature of the track at the station, from its headings a metre either side of it, 1/m positive to the left
|
|
double curvature_at(std::vector<track_point> const &Track, double const Station);
|
|
|
|
// the stations where the cant of the track starts or stops changing: the ends of its cant ramps
|
|
std::vector<double> ramp_ends(std::vector<track_point> const &Track);
|
|
|
|
struct switch_report
|
|
{
|
|
// at the start and at the end of the switch, 1/m, positive turning the way the line does
|
|
double main_start{0.0};
|
|
double main_end{0.0};
|
|
double branch_start{0.0};
|
|
double branch_end{0.0};
|
|
// of the main track, mm
|
|
double cant_start{0.0};
|
|
double cant_end{0.0};
|
|
bool curved{false}; // the main track bent
|
|
bool transition{false}; // its curvature changing along the switch
|
|
std::vector<std::string> notes;
|
|
std::vector<std::string> warnings;
|
|
// the hard rules broken (11.4 pkt 4 and 7, 9.6 pkt 16, 9.7 pkt 12): the switch isn't laid nor moved so
|
|
std::vector<std::string> refusals;
|
|
};
|
|
|
|
// Main, Branch: the tracks of the switch from its start, the stations from 0 there; Line: the track it's laid into, From and To the
|
|
// stations of the start and the end of the switch along it, From after To where it goes back along the line. Radius and Ratio:
|
|
// of the diverging track of the basic switch it's bent from; Straight: how far both tracks keep straight at the end of the switch, over
|
|
// a straight frog, the switch bent up to it as the DB bends such switches; Double: a double switch, which isn't bent (11.4 pkt 4a)
|
|
switch_report check(std::vector<track_point> const &Main, std::vector<track_point> const &Branch, std::vector<track_point> const &Line, double const From, double const To, double const Radius,
|
|
double const Ratio, double const Straight = 0.0, bool const Double = false);
|
|
// a switch laid into a straight: the cant of the line over it alone, as check() judges it
|
|
switch_report check_line(std::vector<track_point> const &Line, double const From, double const To);
|
|
|
|
// the switches bent one-sided from the basic ones, table 11.9: the radius of the basic switch, the limiting curvature of the diverging
|
|
// track (1/m) and the least radius of the main track (m); the values in its brackets are allowed only by way of exception, after the
|
|
// agreement of the Zaklad Linii Kolejowych, the same as the others where it has none
|
|
struct bent_limit
|
|
{
|
|
double radius;
|
|
double branch;
|
|
double main;
|
|
double branch_exception;
|
|
double main_exception;
|
|
};
|
|
std::optional<bent_limit> bent_limit_of(double const Radius);
|
|
|
|
// the radius of the diverging track of a switch bent from the basic one of Radius and 1:Ratio, its main track bent to Main, table 11.8:
|
|
// Main above 0 bent the way the diverging track turns off it (one-sided), below 0 the other way (two-sided), 0 not bent. The tangent of
|
|
// the diverging curve of the basic switch, t = r tan(a/2), corrects the plain sum of the curvatures. Above 0 the diverging track turns
|
|
// off the way it does in the basic switch, below 0 the other way (bent past straight by a main track sharper than its own curve), 0 for
|
|
// a straight one
|
|
double bent_radius(double const Main, double const Radius, double const Ratio);
|
|
|
|
// the cant deficiency over a switch, table 9.7, mm: recommended (P0), normal (P1) and the limit (P2); of a fixed frog up to 160 km/h,
|
|
// of a movable nose up to 230 km/h, which take in any diverging track of the catalogue
|
|
struct deficiency
|
|
{
|
|
double recommended;
|
|
double normal;
|
|
double limit;
|
|
};
|
|
deficiency switch_deficiency(bool const Movable);
|
|
|
|
// the speed with the cant deficiency I up to Deficiency (mm) on a track of Radius (m) under the Cant (mm, above 0 leaning into its
|
|
// turn, below 0 against it), formula 9.9 the other way round: V = sqrt((I + D) R / 11.8), km/h. Infinite for a straight, 0 where the
|
|
// cant against the turn takes up all the deficiency already
|
|
double curve_speed(double const Radius, double const Cant, double const Deficiency);
|
|
|
|
// the speed on the diverging track of the basic switch of the Radius (m), table 11.2, km/h
|
|
double basic_speed(double const Radius);
|
|
|
|
// the speed on the diverging track of a switch: of the basic switch of Basic (m) and 1:Ratio, its main track bent to Main (m, signed as
|
|
// bent_radius() takes it, 0 not bent) under the Cant (mm, above 0 leaning to the side the diverging track leaves to), by formula 9.9
|
|
// with the normal cant deficiency of its frog (table 9.7), rounded down to the steps of the speed limits and no more than table 11.2
|
|
// gives the basic switch; a movable nose kept to it as Id-4 keeps it. The editor writes it when a switch is laid, and so does the
|
|
// domain model of the track geometry (editor/layout)
|
|
struct branch_speed_report
|
|
{
|
|
double speed{0.0}; // km/h
|
|
double radius{0.0}; // m, of the diverging track, bent by table 11.8, signed as bent_radius() gives it
|
|
double cant{0.0}; // mm, above 0 leaning into the turn of the diverging track, below 0 against it
|
|
double deficiency{0.0}; // mm, the normal one of the frog
|
|
double formula{0.0}; // km/h, of formula 9.9, infinite on a straight diverging track
|
|
double rounded{0.0}; // km/h, the formula rounded down to the steps of the speed limits
|
|
double table{0.0}; // km/h, of the basic switch, table 11.2
|
|
};
|
|
branch_speed_report branch_speed(double const Basic, double const Ratio, double const Main, double const Cant, bool const Movable);
|
|
|
|
// the one velocity a switch keeps for both its tracks, km/h: the limit of the main track for both where it's the lower one, else the one
|
|
// of the diverging track for it alone, below 0 (TTrack: -40 limits the diverging track only)
|
|
double written_velocity(double const Main, double const Diverging);
|
|
|
|
// a slip switch bent into a curve, as ST-T1-A6 sees it: none is bent (11.4 pkt 4b, the editor telling no main track from a side
|
|
// one), the curvature of each track through it of one sign all along it (9.7 pkt 12), its slip curves no sharper than a side track may
|
|
// be (table 9.2), the cant as over a switch bent, none recommended in a side track (9.3 pkt 5)
|
|
struct slip_report
|
|
{
|
|
// of the two tracks through the slip in its middle, 1/m, positive turning the way the line does
|
|
double first{0.0};
|
|
double second{0.0};
|
|
// of the slip curves at their sharpest, 1/m
|
|
std::vector<double> curves;
|
|
// of the line, mm
|
|
double cant_start{0.0};
|
|
double cant_end{0.0};
|
|
bool curved{false}; // the tracks through it bent
|
|
std::vector<std::string> notes;
|
|
std::vector<std::string> warnings;
|
|
// as of a switch: a slip isn't bent (11.4 pkt 4b)
|
|
std::vector<std::string> refusals;
|
|
};
|
|
|
|
// Tracks: the two tracks through the slip, Curves: its slip curves, each from its start, the stations from 0 there; Line as for a switch,
|
|
// From and To the stations of the ends of the first track through the slip along it
|
|
slip_report check_slip(std::vector<std::vector<track_point>> const &Tracks, std::vector<std::vector<track_point>> const &Curves, std::vector<track_point> const &Line, double const From, double const To);
|
|
|
|
// a line laid on from the end of the diverging track of a switch, as ST-T1-A6 sees the sudden changes of the cant deficiency right behind
|
|
// the switch (9.11): Curvature the switch ends with (1/m, positive to the left as the line runs on), Straight metres before its end
|
|
// over a straight frog, then the pieces of the line, each its length and its curvature at its start and at its end. The first two
|
|
// sudden changes nearer than the intermediate element of table 9.16 taken together, else each one alone, against table 9.15 for track
|
|
// connections at the Speed (km/h); Gauge between the axes of the rails, mm
|
|
struct exit_report
|
|
{
|
|
double apart{-1.0}; // m, from the end of the curve of the switch to the next sudden change, -1 none
|
|
double change{0.0}; // mm, the largest sudden change of the cant deficiency judged
|
|
double allowed{0.0}; // mm, table 9.15
|
|
double element{0.0}; // m, the intermediate element of table 9.16
|
|
std::vector<std::string> warnings;
|
|
};
|
|
exit_report check_exit(double const Curvature, double const Straight, std::vector<std::array<double, 3>> const &Line, double const Speed, double const Gauge = 1500.0);
|
|
|
|
// the start of a switch Length long, going Direction along the line, drawn to where its start or its end meets an end of a cant ramp,
|
|
// or to where it keeps the 6 m off it, when the station pressed is within Reach of that; What receives which of them, empty for none
|
|
double snapped_start(std::vector<double> const &Ramps, double const Pressed, double const Length, int const Direction, double const Reach, std::string *What = nullptr);
|
|
|
|
} // namespace switch_curve
|