4 // kinematic constraints
5 bool BicycleCar::drivable(BicycleCar *bc)
8 pow(this->ccl()->x() - bc->x(), 2)
9 + pow(this->ccl()->y() - bc->y(), 2)
10 <= pow(this->mtr(), 2)
14 pow(this->ccr()->x() - bc->x(), 2)
15 + pow(this->ccr()->y() - bc->y(), 2)
16 <= pow(this->mtr(), 2)
23 double BicycleCar::lfx()
25 double lfx = this->x();
26 lfx += (this->w() / 2) * cos(this->h() + M_PI / 2);
27 lfx += this->df() * cos(this->h());
28 lfx += this->sd() * cos(this->h());
32 double BicycleCar::lfy()
34 double lfy = this->y();
35 lfy += (this->w() / 2) * sin(this->h() + M_PI / 2);
36 lfy += this->df() * sin(this->h());
37 lfy += this->sd() * sin(this->h());
41 double BicycleCar::lrx()
43 double lrx = this->x();
44 lrx += (this->w() / 2) * cos(this->h() + M_PI / 2);
45 lrx += -this->dr() * cos(this->h());
46 lrx += -this->sd() * cos(this->h());
50 double BicycleCar::lry()
52 double lry = this->y();
53 lry += (this->w() / 2) * sin(this->h() + M_PI / 2);
54 lry += -this->dr() * sin(this->h());
55 lry += -this->sd() * sin(this->h());
59 double BicycleCar::rrx()
61 double rrx = this->x();
62 rrx += (this->w() / 2) * cos(this->h() - M_PI / 2);
63 rrx += -this->dr() * cos(this->h());
64 rrx += -this->sd() * cos(this->h());
68 double BicycleCar::rry()
70 double rry = this->y();
71 rry += (this->w() / 2) * sin(this->h() - M_PI / 2);
72 rry += -this->dr() * sin(this->h());
73 rry += -this->sd() * sin(this->h());
77 double BicycleCar::rfx()
79 double rfx = this->x();
80 rfx += (this->w() / 2) * cos(this->h() - M_PI / 2);
81 rfx += this->df() * cos(this->h());
82 rfx += this->sd() * cos(this->h());
86 double BicycleCar::rfy()
88 double rfy = this->y();
89 rfy += (this->w() / 2) * sin(this->h() - M_PI / 2);
90 rfy += this->df() * sin(this->h());
91 rfy += this->sd() * sin(this->h());
95 double BicycleCar::ralx()
97 double lrx = this->x();
98 lrx += (this->w() / 2) * cos(this->h() + M_PI / 2);
101 double BicycleCar::raly()
103 double lry = this->y();
104 lry += (this->w() / 2) * sin(this->h() + M_PI / 2);
108 double BicycleCar::rarx()
110 double rrx = this->x();
111 rrx += (this->w() / 2) * cos(this->h() - M_PI / 2);
115 double BicycleCar::rary()
117 double rry = this->y();
118 rry += (this->w() / 2) * sin(this->h() - M_PI / 2);
122 BicycleCar *BicycleCar::ccl()
124 BicycleCar *bc = new BicycleCar();
125 bc->x(this->x() + this->mtr() * cos(this->h() + M_PI / 2));
126 bc->y(this->y() + this->mtr() * sin(this->h() + M_PI / 2));
131 BicycleCar *BicycleCar::ccr()
133 BicycleCar *bc = new BicycleCar();
134 bc->x(this->x() + this->mtr() * cos(this->h() - M_PI / 2));
135 bc->y(this->y() + this->mtr() * sin(this->h() - M_PI / 2));
141 void BicycleCar::next()
143 if (this->st() > this->wb() / this->mtr())
144 this->st(this->wb() / this->mtr());
145 if (this->st() < -this->wb() / this->mtr())
146 this->st(-this->wb() / this->mtr());
147 this->h(this->h() + this->sp() / this->wb() * tan(this->st()));
148 this->x(this->x() + this->sp() * cos(this->h()));
149 this->y(this->y() + this->sp() * sin(this->h()));
152 BicycleCar::BicycleCar()