]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/commitdiff
Add perfect parking slot length computation
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 13 Jan 2020 08:36:05 +0000 (09:36 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Mon, 13 Jan 2020 10:48:21 +0000 (11:48 +0100)
api/bcar.h
src/bcar.cc

index 836f725c2d13ef21d11c51371b89c839e0a50fdf..716adab2b50022c1fcea1d4fc2321dab75abf466 100644 (file)
@@ -77,6 +77,12 @@ class BicycleCar {
                 the rear (from the rear axle view) part of the car.
                 */
                 double orradi() const;
+                /*! \brief Return length of perfect parking slot.
+
+                The width of the slot is the same as the width of the
+                car.
+                */
+                double perfect_parking_slot_len() const;
                 /*! \brief Set maximum steering angle.
                 */
                 void set_max_steer();
index a882488f207ce6fb6abdc29db79a73185025cf02..a161a0090f19e4fee0b2b17ed02714548cdc0e49 100644 (file)
@@ -34,6 +34,26 @@ double BicycleCar::orradi() const
         return sqrt(pow(this->mtr() + this->w() / 2, 2) + pow(this->dr(), 2));
 }
 
+double BicycleCar::perfect_parking_slot_len() const
+{
+        // see Simon R. Blackburn *The Geometry of Perfect Parking*
+        // see https://www.ma.rhul.ac.uk/SRBparking
+        double r = this->ctc() / 2;
+        double l = this->wb();
+        double k = this->df() - this->wb();
+        double w = this->w();
+        return
+                this->l()
+                + sqrt(
+                        (r*r - l*l)
+                        + pow(l + k, 2)
+                        - pow(sqrt(r*r - l*l) - w, 2)
+                )
+                - l
+                - k
+        ;
+}
+
 void BicycleCar::set_max_steer()
 {
         this->st(asin(this->wb() / (10.82 / 2)));