From 05452d0c45fdf2c00541a9db7a0923590a565646 Mon Sep 17 00:00:00 2001 From: Jiri Vlasak Date: Mon, 13 Jan 2020 09:36:05 +0100 Subject: [PATCH] Add perfect parking slot length computation --- api/bcar.h | 6 ++++++ src/bcar.cc | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/api/bcar.h b/api/bcar.h index 836f725..716adab 100644 --- a/api/bcar.h +++ b/api/bcar.h @@ -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(); diff --git a/src/bcar.cc b/src/bcar.cc index a882488..a161a00 100644 --- a/src/bcar.cc +++ b/src/bcar.cc @@ -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))); -- 2.39.2