mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 04:47:06 +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.
89 lines
3.3 KiB
C++
89 lines
3.3 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 <algorithm>
|
|
#include <cmath>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <glm/glm.hpp>
|
|
|
|
#include "editor/editorAlignment.hpp"
|
|
|
|
class TTrack;
|
|
|
|
// speed the geometry of the paths allows, set against the speed limits written in them
|
|
namespace speed_check
|
|
{
|
|
|
|
enum class cause
|
|
{
|
|
none,
|
|
radius, // unbalanced acceleration in the curve
|
|
cant_rate, // cant changes too fast for the passengers
|
|
cant_ramp, // the cant ramp is too steep for the wheels
|
|
jerk, // the unbalanced acceleration changes too fast, curves without the transitions
|
|
branch // diverging track of a switch, without cant
|
|
};
|
|
char const *describe(cause const Cause);
|
|
|
|
struct options
|
|
{
|
|
alignment::limits norms;
|
|
double branch_unbalanced{0.65}; // m/s2, for the diverging tracks of the switches
|
|
double reference_length{20.0}; // m, over which an abrupt change of the curvature or of the cant is felt
|
|
double step{2.0}; // m, between the checked points
|
|
double top{300.0}; // km/h, nothing above is looked into
|
|
};
|
|
|
|
struct verdict
|
|
{
|
|
TTrack *track{nullptr};
|
|
int path{0};
|
|
double set{-1.0}; // km/h, -1: no limit of its own
|
|
double safe{0.0}; // km/h, Options.top when the geometry allows any speed
|
|
cause why{cause::none};
|
|
glm::dvec3 position{0.0}; // where the geometry is the tightest
|
|
double radius{0.0}; // m, there
|
|
double cant{0.0}; // mm, there
|
|
// over the reference length around the point: the radius and the cant at its ends, 0 m for a straight.
|
|
// negative where the curve turns the other way than at the point
|
|
double radius_from{0.0}, radius_to{0.0};
|
|
double cant_from{0.0}, cant_to{0.0}; // mm
|
|
double cant_slope{0.0}; // mm per m
|
|
// km/h, the safe speed without the limit of the switch branches, which is only a warning
|
|
double hard{0.0};
|
|
cause hard_why{cause::none};
|
|
// true when the speed set is above the safe one, or isn't set over a tight geometry; the switch branches not counted
|
|
bool violated(options const &Options) const;
|
|
// true when only the limit of a switch branch is exceeded
|
|
bool warned(options const &Options) const;
|
|
};
|
|
// what limits the speed, with the numbers which do
|
|
std::string explain(verdict const &Verdict, options const &Options);
|
|
|
|
verdict check(TTrack &Track, int const Path, options const &Options);
|
|
// the safe speed rounded down to the usual steps of the speed limits; inline, so the speed of the switches (editorSwitchCurve) takes it
|
|
// where the checks of the speed aren't built
|
|
inline double suggested(double const Safe)
|
|
{
|
|
if (Safe >= 40.0)
|
|
return std::floor(Safe / 10.0) * 10.0;
|
|
return std::max(5.0, std::floor(Safe / 5.0) * 5.0);
|
|
}
|
|
// speed limit in force on the path, -1 for none. a switch keeps one for both its tracks: positive applies to both,
|
|
// -2 and below only to the diverging one, its main track having no limit then
|
|
double path_velocity(TTrack const &Track, int const Path);
|
|
// velocity of a switch which keeps its tracks to the limits given, -1 for none. one written value can't hold
|
|
// a limit on each track, the main one gets the diverging one's limit too when that's lower
|
|
double switch_velocity(double const Main, double const Diverging);
|
|
|
|
} // namespace speed_check
|