From: Jiri Vlasak Date: Mon, 26 Aug 2019 11:58:34 +0000 (+0200) Subject: Add rotation ut, declaration X-Git-Tag: v0.4.0~18^2~2 X-Git-Url: https://rtime.felk.cvut.cz/gitweb/hubacji1/bcar.git/commitdiff_plain/9a366942eedc8e10cf97a170a49e657125704bc0 Add rotation ut, declaration --- diff --git a/api/bcar.h b/api/bcar.h index 5139ed9..f698ecf 100644 --- a/api/bcar.h +++ b/api/bcar.h @@ -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_; } diff --git a/src/bcar.cc b/src/bcar.cc index 4f0654c..932ec1d 100644 --- a/src/bcar.cc +++ b/src/bcar.cc @@ -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() { } diff --git a/ut/bcar.t.cc b/ut/bcar.t.cc index 848eae0..e9c0335 100644 --- a/ut/bcar.t.cc +++ b/ut/bcar.t.cc @@ -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")