From: Jiri Vlasak Date: Wed, 14 Jul 2021 21:10:57 +0000 (+0200) Subject: Add line len computation X-Git-Tag: v0.6.0~12 X-Git-Url: https://rtime.felk.cvut.cz/gitweb/hubacji1/bcar.git/commitdiff_plain/d444b68e57a7517dce27273c26e3ea1222b00cc4 Add line len computation --- diff --git a/incl/bcar.hh b/incl/bcar.hh index 1e0b61b..faa8470 100644 --- a/incl/bcar.hh +++ b/incl/bcar.hh @@ -100,6 +100,8 @@ public: * \param p The point to consider. */ bool is_on_right_side(Point const& p) const; + + double len() const; }; /*! Store coordinates `x`, `y`, and heading `h`. */ diff --git a/src/bcar.cc b/src/bcar.cc index 75f220c..96a2c8c 100644 --- a/src/bcar.cc +++ b/src/bcar.cc @@ -191,6 +191,14 @@ Line::is_on_right_side(Point const& p) const } } +double +Line::len() const +{ + double dx = this->lp().x() - this->fp().x(); + double dy = this->lp().y() - this->fp().y(); + return sqrt(dx * dx + dy * dy); +} + Pose::Pose() : Point() { }