this->ps().x2() - this->ps().x1()
);
while (h < 0) h += 2 * M_PI;
- x += this->gc().dr() * cos(h + M_PI);
- y += this->gc().dr() * sin(h + M_PI);
+ x += 2 * this->gc().dr() * cos(h);
+ y += 2 * this->gc().dr() * sin(h);
#else
// Backward parking
double entry_width = edist(
// zig-zag out from the slot
this->cc() = BicycleCar(this->gc());
this->cc().sp(0.1);
+ lm.push_back(BicycleCar(this->cc()));
while (!this->left()) {
while (!this->collide() && !this->left()) {
this->cc().next();
return pi;
}
+void PSPlanner::shrink_to_perfect_len()
+{
+ if (!this->ps().parallel())
+ return;
+ double perfect_len = this->gc().perfect_parking_slot_len();
+ if (edist(
+ this->ps().x1(), this->ps().y1(),
+ this->ps().x4(), this->ps().y4()
+ ) < perfect_len)
+ return;
+ double h = this->ps().heading();
+ h -= M_PI;
+ while (h < 0) h += 2 * M_PI;
+ double ch = perfect_len * cos(h);
+ double sh = perfect_len * sin(h);
+ this->ps().border(
+ this->ps().x4() + ch, this->ps().y4() + sh,
+ this->ps().x3() + ch, this->ps().y3() + sh,
+ this->ps().x3(), this->ps().y3(),
+ this->ps().x4(), this->ps().y4()
+ );
+}
+
// find entry
void PSPlanner::fe()
{
void PSPlanner::fe_parallel()
{
+ this->shrink_to_perfect_len();
BicycleCar bco = BicycleCar(this->gc());
this->cc() = BicycleCar();
this->cc().sp(-0.01);