diff --git a/include/robot_line_extraction/line.h b/include/robot_line_extraction/line.h index a1cabab..7aab599 100644 --- a/include/robot_line_extraction/line.h +++ b/include/robot_line_extraction/line.h @@ -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 pointAt(unsigned int index) const; + /// @brief [m] Perpendicular distance from ray @p index to this line. double distToPoint(unsigned int index) const; diff --git a/src/line.cpp b/src/line.cpp index 2e68c04..893e815 100644 --- a/src/line.cpp +++ b/src/line.cpp @@ -53,6 +53,11 @@ Line::Line(double angle, double radius, const std::array& covariance, // Geometry // ================================================================================================ +std::array 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]);