]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/commitdiff
Add rotation ut, declaration
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 26 Aug 2019 11:58:34 +0000 (13:58 +0200)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 26 Aug 2019 12:08:33 +0000 (14:08 +0200)
api/bcar.h
src/bcar.cc
ut/bcar.t.cc

index 5139ed9cd47d201a6b3b065aaba16c39c191ce9e..f698ecfc88c8705d579514d121f4bfe68a15cdc1 100644 (file)
@@ -104,6 +104,13 @@ class BicycleCar {
                 Where `sp` is speed and `st` is steering of the car.
                 */
                 void next();
+                /*! \brief Rotate self around the point.
+
+                \param cx Horizontal coordinate of rotation center.
+                \param cy Vertical coordinate of rotation center.
+                \param angl Angle of rotation.
+                */
+                void rotate(double cx, double cy, double angl);
 
                 // getters, setters
                 double x() const { return this->x_; }
index 4f0654c27fc1717a9e61289bdc0f6b969179aa49..932ec1d178ed10f1dcc36abb48f183fc40e72f90 100644 (file)
@@ -164,6 +164,10 @@ void BicycleCar::next()
         this->y(this->y() + this->sp() * sin(this->h()));
 }
 
+void BicycleCar::rotate(double cx, double cy, double angl)
+{
+}
+
 BicycleCar::BicycleCar()
 {
 }
index 848eae029eb51585278fe61f10efb3a8c3e1fee3..e9c03352e056d19661e167df9e56820dd1361ea0 100644 (file)
@@ -80,6 +80,19 @@ WVTEST_MAIN("bcar basic geometry")
         bc.st(-M_PI);
         bc.next();
         WVPASSEQ_DOUBLE(-0.2, bc.st(), 0.00001);
+
+        // rotate
+        bc.x(-1);
+        bc.y(1);
+        bc.h(0);
+        bc.rotate(-1, 1, M_PI);
+        WVPASSEQ_DOUBLE(-1, bc.x(), 0.00001);
+        WVPASSEQ_DOUBLE(1, bc.y(), 0.00001);
+        WVPASSEQ_DOUBLE(M_PI, bc.h(), 0.00001);
+        bc.rotate(0, 1, -M_PI / 2);
+        WVPASSEQ_DOUBLE(0, bc.x(), 0.00001);
+        WVPASSEQ_DOUBLE(2, bc.y(), 0.00001);
+        WVPASSEQ_DOUBLE(M_PI / 2, bc.h(), 0.00001);
 }
 
 WVTEST_MAIN("test collide functions")