MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / unitDir

Function unitDir

app/src/UI/Widgets/PlotCurve.cpp:63–73  ·  view source on GitHub ↗

* @brief Computes the unit direction between two pixel-space points; returns false for * degenerate (near zero-length) segments. */

Source from the content-addressed store, hash-verified

61 * degenerate (near zero-length) segments.
62 */
63static bool unitDir(const QPointF& from, const QPointF& to, QPointF& dir)
64{
65 const double dx = to.x() - from.x();
66 const double dy = to.y() - from.y();
67 const double len = std::sqrt(dx * dx + dy * dy);
68 if (!(len > 1e-6))
69 return false;
70
71 dir = QPointF(dx / len, dy / len);
72 return true;
73}
74
75/**
76 * @brief Arc-segment count for the round join between two unit segment directions: the exterior

Callers 2

countRunMethod · 0.85
emitRunMethod · 0.85

Calls 2

sqrtFunction · 0.85
xMethod · 0.80

Tested by

no test coverage detected