\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:
// 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; }
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 */
+#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;
+}