mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-03 17:50:21 +01:00
Checkpoint of the editor branch so work isn't carried loose across a branch switch. Builds. - maj0sted turnout geometry moved into the domain: domain::lay_turnout lays the diverging path (pre-blade lead, blade at beta, arc of alfa-beta, frog rail) and solve_junction is a thin adapter onto it. - the maj0sted web/ tree renamed to editor/ (namespace and paths) - there is no WASM here, it's plain native C++ the editor calls. - click places the switch at its start (początek rozjazdu); the branch's leaving straight is locked tangent to the frog; switches can be slid along the through track and flipped L/P. - Polish turnout templates carry catalogue length (Id-1-consistent lengths), plus blade-angle and pre-blade fields (left 0 until the catalogue figures are in). - TURNOUT_SPEC.md: the Bezier-based runtime/model contract. - also folds in other pending branch changes (scenery, tests) to leave a clean tree.
40 lines
1.8 KiB
C++
40 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include "maj0sted/domain/geometry/plan_element.hpp"
|
|
#include "maj0sted/domain/parallelism/track_parallelism.hpp"
|
|
#include "maj0sted/domain/value_objects/track_offset.hpp"
|
|
|
|
namespace maj0sted::domain {
|
|
|
|
/// Domain Service: creates and reasons about parallelism between straight
|
|
/// segments.
|
|
class ParallelismService {
|
|
public:
|
|
/// Marks @p origin as the origin of a parallel relation with @p parallel,
|
|
/// separated by @p offset. Both straights must be identified.
|
|
/// @throws std::invalid_argument if a straight has no id or the two are the
|
|
/// same straight.
|
|
static TrackParallelism mark_parallel(const Straight& origin,
|
|
const Straight& parallel,
|
|
TrackOffset offset);
|
|
|
|
/// Are two straights parallel as lines (same or opposite azimuth)?
|
|
static bool are_parallel(const Straight& a, const Straight& b,
|
|
double tolerance_rad = 1e-9);
|
|
|
|
/// The line the parallel straight lies on: @p origin shifted sideways by
|
|
/// @p offset, perpendicular to its direction of travel. Same length and
|
|
/// azimuth as the origin; the returned straight is anonymous.
|
|
static Straight derive_parallel_line(const Straight& origin, TrackOffset offset);
|
|
|
|
/// Perpendicular distance (>= 0) from @p other's start point to the
|
|
/// (infinite) line carrying @p origin.
|
|
static double perpendicular_distance(const Straight& origin, const Straight& other);
|
|
|
|
[[nodiscard]] static Straight project_onto_offset_line(const Straight& origin,
|
|
double offset_m,
|
|
const Straight& segment);
|
|
};
|
|
|
|
} // namespace maj0sted::domain
|