]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/commitdiff
Merge branch 'feature/car-frame'
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Wed, 10 Jul 2019 12:03:51 +0000 (14:03 +0200)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Wed, 10 Jul 2019 12:03:51 +0000 (14:03 +0200)
CHANGELOG.md
api/bcar.h
src/bcar.cc

index c1b453c70aacfac0a274a7ae17bd80335360994c..b2888b91a90294d447a04acbec5f64dd64df3a53 100644 (file)
@@ -11,3 +11,4 @@ The format is based on [Keep a Changelog][] and this project adheres to
 ### Added
 - Changelog, license, readme.
 - Bicycle car parameters.
+- Bicycle car frame coordinates.
index dbee0f473d1c292e5c45c4f6c81541886a6c9f54..a2f1dc4a8ec56974a7db7b5d1949e461973f2101 100644 (file)
@@ -12,7 +12,10 @@ This class contains some geometrical computations of bicycle car.
 \param wb Wheelbase.
 \param w The width of the car.
 \param l The length of the car.
-\param h The height of the car.
+\param he The height of the car.
+\param sd The safety distance.
+\param df Distance from rear axle center to the front of the car.
+\param dr Distance from rear axle center to the back of the car.
 */
 class BicycleCar {
         private:
@@ -26,8 +29,21 @@ class BicycleCar {
                 // dimensions
                 double w_ = 1.625;
                 double l_ = 3.760;
-                double h_ = 1.450;
+                double he_ = 1.450;
+                double sd_ = 0;
+                double df_ = 3.105;
+                double dr_ = 0.655;
         public:
+                // car frame
+                double lfx(); double lfy();
+                double lrx(); double lry();
+                double rrx(); double rry();
+                double rfx(); double rfy();
+
+                double ralx(); double raly();
+                double rarx(); double rary();
+
+                // getters, setters
                 double x() { return this->x_; }
                 void x(double x) { this->x_ = x; }
 
@@ -49,8 +65,17 @@ class BicycleCar {
                 double l() { return this->l_; }
                 void l(double l) { this->l_ = l; }
 
-                double h() { return this->h_; }
-                void h(double h) { this->h_ = h; }
+                double he() { return this->he_; }
+                void he(double he) { this->he_ = he; }
+
+                double sd() { return this->sd_; }
+                void sd(double sd) { this->sd_ = sd; }
+
+                double df() { return this->df_; }
+                void df(double df) { this->df_ = df; }
+
+                double dr() { return this->dr_; }
+                void dr(double dr) { this->dr_ = dr; }
 };
 
 #endif /* BCAR_H */
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1d3cecc5486392f75a9a3b869fab771ed7e90d61 100644 (file)
@@ -0,0 +1,102 @@
+#include <cmath>
+#include "bcar.h"
+
+// car frame
+double BicycleCar::lfx()
+{
+        double lfx = this->x();
+        lfx += (this->w() / 2) * cos(this->h() + M_PI / 2);
+        lfx += this->df() * cos(this->h());
+        lfx += this->sd() * cos(this->h());
+        return lfx;
+}
+
+double BicycleCar::lfy()
+{
+        double lfy = this->y();
+        lfy += (this->w() / 2) * sin(this->h() + M_PI / 2);
+        lfy += this->df() * sin(this->h());
+        lfy += this->sd() * sin(this->h());
+        return lfy;
+}
+
+double BicycleCar::lrx()
+{
+        double lrx = this->x();
+        lrx += (this->w() / 2) * cos(this->h() + M_PI / 2);
+        lrx += -this->dr() * cos(this->h());
+        lrx += -this->sd() * cos(this->h());
+        return lrx;
+}
+
+double BicycleCar::lry()
+{
+        double lry = this->y();
+        lry += (this->w() / 2) * sin(this->h() + M_PI / 2);
+        lry += -this->dr() * sin(this->h());
+        lry += -this->sd() * sin(this->h());
+        return lry;
+}
+
+double BicycleCar::rrx()
+{
+        double rrx = this->x();
+        rrx += (this->w() / 2) * cos(this->h() - M_PI / 2);
+        rrx += -this->dr() * cos(this->h());
+        rrx += -this->sd() * cos(this->h());
+        return rrx;
+}
+
+double BicycleCar::rry()
+{
+        double rry = this->y();
+        rry += (this->w() / 2) * sin(this->h() - M_PI / 2);
+        rry += -this->dr() * sin(this->h());
+        rry += -this->sd() * sin(this->h());
+        return rry;
+}
+
+double BicycleCar::rfx()
+{
+        double rfx = this->x();
+        rfx += (this->w() / 2) * cos(this->h() - M_PI / 2);
+        rfx += this->df() * cos(this->h());
+        rfx += this->sd() * cos(this->h());
+        return rfx;
+}
+
+double BicycleCar::rfy()
+{
+        double rfy = this->y();
+        rfy += (this->w() / 2) * sin(this->h() - M_PI / 2);
+        rfy += this->df() * sin(this->h());
+        rfy += this->sd() * sin(this->h());
+        return rfy;
+}
+
+double BicycleCar::ralx()
+{
+        double lrx = this->x();
+        lrx += (this->w() / 2) * cos(this->h() + M_PI / 2);
+        return lrx;
+}
+double BicycleCar::raly()
+{
+        double lry = this->y();
+        lry += (this->w() / 2) * sin(this->h() + M_PI / 2);
+        return lry;
+}
+
+double BicycleCar::rarx()
+{
+        double rrx = this->x();
+        rrx += (this->w() / 2) * cos(this->h() - M_PI / 2);
+        return rrx;
+}
+
+double BicycleCar::rary()
+{
+        double rry = this->y();
+        rry += (this->w() / 2) * sin(this->h() - M_PI / 2);
+        return rry;
+}