]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/commitdiff
Add and use point, pose translate method
authorJiri Vlasak <jiri.vlasak.2@cvut.cz>
Tue, 20 Jul 2021 12:33:10 +0000 (14:33 +0200)
committerJiri Vlasak <jiri.vlasak.2@cvut.cz>
Tue, 20 Jul 2021 14:49:17 +0000 (16:49 +0200)
incl/bcar.hh
src/bcar.cc
src/pslot.cc

index 357d21960aad3587c1866368f353f621d3de5019..7591d7213682ce162ccee308350c1a27bb31f90a 100644 (file)
@@ -58,6 +58,12 @@ public:
         */
        bool on_right_side_of(Line const& li) const;
 
+       /*! \brief Translate self.
+        *
+        * \param p `Point` offset to translate by.
+        */
+       void translate(Point const& p);
+
        /*! \brief Rotate self around the point.
 
        \param c Rotation center `Point`.
@@ -172,8 +178,8 @@ public:
        /*! Get heading's end in the interval [-pi, +pi] radians. */
        double e() const;
 
+       void translate(Point const& p);
        void rotate(Point const& c, double const angl);
-
        void reflect(Line const& li);
 
        friend std::ostream& operator<<(std::ostream& out, PoseRange const& p);
index 673ec198853baafcfec05e29f46e2b25c9dfc007..84a3bcb74699b2e64caf12b4efad3a16e1eb7736 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)
 {
@@ -367,6 +374,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)
 {
index 6966377bf8999107a36f3b24645fbdeacccf6b71..4644375e20c6e22871690cf62439f6ac21d40c30 100644 (file)
@@ -209,7 +209,6 @@ ParkingSlot::steer_in_slot(BicycleCar c)
                        c.st(c.st() * -1.0);
                }
        }
-       path.push_back(c);
        return path;
 }
 
@@ -266,8 +265,7 @@ PoseRange
 ParkingSlot::recompute_entry(PoseRange p)
 {
        p.rotate(Point(0.0, 0.0), this->h());
-       p.x(p.x() + this->lrx());
-       p.y(p.y() + this->lry());
+       p.translate(this->border_[0]);
        if (!this->right()) {
                p.reflect(this->entry_);
        }