]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/commitdiff
Add line len computation
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Wed, 14 Jul 2021 21:10:57 +0000 (23:10 +0200)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Wed, 14 Jul 2021 21:10:57 +0000 (23:10 +0200)
incl/bcar.hh
src/bcar.cc

index 1e0b61bf2c1de59076729a28dac3324a26f7eaf2..faa8470bbe74e2f89445735f4cd77f4636f3f2ee 100644 (file)
@@ -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`. */
index 75f220c9d3668c1462eeb49af00e9c3dcf2ed7ed..96a2c8c82ecc5db43f62683fac03b1171999b24b 100644 (file)
@@ -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()
 {
 }