From: Jiri Vlasak Date: Tue, 20 Jul 2021 10:35:08 +0000 (+0200) Subject: Add operator== for pose X-Git-Tag: v0.6.0~3^2~5 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/hubacji1/bcar.git/commitdiff_plain/e30226d3f50ec045f70f8aedf5c5c42254bd218b?ds=sidebyside Add operator== for pose --- diff --git a/incl/bcar.hh b/incl/bcar.hh index 095c221..5370934 100644 --- a/incl/bcar.hh +++ b/incl/bcar.hh @@ -74,6 +74,7 @@ public: /*! Return Euclidean distance to `p`. */ double edist(Point const& p) const; + bool operator==(Point const& p); friend std::ostream& operator<<(std::ostream& out, Point const& p); }; @@ -149,6 +150,7 @@ public: void reflect(Line const& li); + bool operator==(Pose const& p); friend std::ostream& operator<<(std::ostream& out, Pose const& p); }; diff --git a/src/bcar.cc b/src/bcar.cc index 0cdb078..93f017e 100644 --- a/src/bcar.cc +++ b/src/bcar.cc @@ -124,6 +124,12 @@ Point::edist(Point const& p) const return sqrt(pow(p.x() - this->x_, 2.0) + pow(p.y() - this->y_, 2.0)); } +bool +Point::operator==(Point const& p) +{ + return this->x() == p.x() && this->y() == p.y(); +} + std::ostream& operator<<(std::ostream& out, Point const& p) { @@ -290,6 +296,12 @@ Pose::reflect(Line const& li) this->h(this->h() + 2.0 * dh); } +bool +Pose::operator==(Pose const& p) +{ + return this->x() == p.x() && this->y() == p.y() && this->h() == p.h(); +} + std::ostream& operator<<(std::ostream& out, Pose const& p) {