feat: expose the Cartesian position of a ray behind a segment

Line already holds the scan it was fitted from, so pointAt() is a lookup and
not a conversion. A consumer that wants to say something about the individual
rays behind a segment - which of them are bright, where along the segment they
sit - would otherwise have to be handed the whole scan alongside the segment
and re-derive what the segment already knows.

The index is a ray number, the same numbering getIndices() returns, so it also
reaches rays the segment dropped as outliers or that a split pushed into a
neighbouring segment.
This commit is contained in:
2026-08-26 16:46:17 +07:00
parent fc4c5a9a12
commit 524f3432e2
2 changed files with 18 additions and 0 deletions

View File

@@ -92,6 +92,19 @@ public:
return indices_;
}
/**
* @brief [m] Cartesian position of ray @p index in the sensor frame, as {x, y}.
*
* The segment already holds the scan it was fitted from, so this is a lookup, not a conversion.
* It exists because a consumer that wants to say something about the individual rays behind a
* segment - which of them are bright, where along the segment they sit - would otherwise have to
* be handed the whole scan alongside the segment and re-derive what the segment already knows.
*
* @warning @p index is a RAY number, the same numbering @ref getIndices returns. It is not a
* position within this segment's support.
*/
std::array<double, 2> pointAt(unsigned int index) const;
/// @brief [m] Perpendicular distance from ray @p index to this line.
double distToPoint(unsigned int index) const;

View File

@@ -53,6 +53,11 @@ Line::Line(double angle, double radius, const std::array<double, 4>& covariance,
// Geometry
// ================================================================================================
std::array<double, 2> Line::pointAt(unsigned int index) const
{
return { { r_data_.xs[index], r_data_.ys[index] } };
}
double Line::distToPoint(unsigned int index) const
{
const double p_rad = std::hypot(r_data_.xs[index], r_data_.ys[index]);