]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/blobdiff - src/bcar.cc
Add line middle point getter
[hubacji1/bcar.git] / src / bcar.cc
index d64f27fe29d07e6fa51b4c26bc430f92537ce035..b3748dbe9ca0c3cbae6dce9c82a201ab796daa8e 100644 (file)
@@ -95,6 +95,13 @@ Point::on_right_side_of(Line const& li) const
        }
 }
 
+void
+Point::translate(Point const& p)
+{
+       this->x_ += p.x();
+       this->y_ += p.y();
+}
+
 void
 Point::rotate(Point const& c, double const angl)
 {
@@ -153,6 +160,13 @@ Line::e() const&
        return this->e_;
 }
 
+Point
+Line::m() const
+{
+       return Point((this->b_.x() + this->e_.x()) / 2.0,
+               (this->b_.y() + this->e_.y()) / 2.0);
+}
+
 Point
 Line::i1() const&
 {
@@ -338,6 +352,11 @@ PoseRange::PoseRange(Pose bp, Pose ep) : bp_(bp), ep_(ep)
        }
 }
 
+PoseRange::PoseRange(double x, double y, double b, double e)
+               : PoseRange(Pose(x, y, b), Pose(x, y, e))
+{
+}
+
 Pose
 PoseRange::bp() const
 {
@@ -362,6 +381,14 @@ PoseRange::e() const
        return std::max(this->bp_.h(), this->ep_.h());
 }
 
+void
+PoseRange::translate(Point const& p)
+{
+       this->bp_.translate(p);
+       this->ep_.translate(p);
+       this->set_xyh();
+}
+
 void
 PoseRange::rotate(Point const& c, double const angl)
 {