17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 07:29:20 +02:00

feat(editor): digitizing reads more of the old tracks: curves of the same hand meeting through their transitions with no straight between are separate vertices, a run turning over 150 degrees is split into vertices at track joints, a curve made of two transitions with no arc is read with the radius at their joint; digitizing tries both transition shapes, then without the minimum arc length when a short curve would lose its transitions; the reason names the track left by how much at any distance

This commit is contained in:
maj00r
2026-10-12 03:45:12 +02:00
parent f5895abfa8
commit 096122bcc3
4 changed files with 74 additions and 6 deletions

View File

@@ -1130,6 +1130,24 @@ bool tangent_intersection(design const &Design, glm::dvec2 &Point)
return true;
}
bool spiral_tangents(transition_shape const Shape, double const TurnIn, double const TurnOut, double &TangentIn, double &TangentOut)
{
auto const length = [&](double const Turn) { return Shape == transition_shape::clothoid ? 2.0 * Turn : 2.0 * std::tan(Turn); };
if (TurnIn <= 0.0 || TurnOut <= 0.0 || TurnIn >= 0.5 * kPi || TurnOut >= 0.5 * kPi)
return false;
auto const in{transition_point(Shape, length(TurnIn), 1.0, 1.0)};
auto const out{transition_point(Shape, length(TurnOut), 1.0, 1.0)};
auto const deflection{in.angle + out.angle};
if (deflection >= kPi - 1e-3)
return false;
glm::dvec2 const direction{std::cos(deflection), std::sin(deflection)};
glm::dvec2 const normal{-direction.y, direction.x};
auto const end{glm::dvec2{in.x, in.y} + direction * out.x - normal * out.y};
TangentOut = end.y / std::sin(deflection);
TangentIn = end.x - TangentOut * std::cos(deflection);
return TangentIn > 0.0 && TangentOut > 0.0;
}
bool collinear(design const &Design)
{
auto const offset{plan_of(Design.end) - plan_of(Design.start)};