/* 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 #include #include // 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 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 ramp_ends(std::vector 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 notes; std::vector warnings; }; // 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 switch_report check(std::vector const &Main, std::vector const &Branch, std::vector const &Line, double const From, double const To, double const Radius, double const Ratio, double const Straight = 0.0); // a slip switch bent into a curve, as ST-T1-A6 sees it: in a side track only (11.4 pkt 4b), 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 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 notes; std::vector warnings; }; // 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> const &Tracks, std::vector> const &Curves, std::vector 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 warnings; }; exit_report check_exit(double const Curvature, double const Straight, std::vector> 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 const &Ramps, double const Pressed, double const Length, int const Direction, double const Reach, std::string *What = nullptr); } // namespace switch_curve