y += (this->gc().w() / 2 + 0.01) * sin(h + dts);
y += (this->gc().dr() + 0.01) * sin(h);
} else {
- dts = atan2(
- this->ps().y2() - this->ps().y1(),
- this->ps().x2() - this->ps().x1()
- );
- dts *= 1.01; // precision workaround
- if (std::abs(dts - this->ps().heading()) < M_PI / 2) {
+ if (std::abs(
+ atan2(
+ this->ps().y2() - this->ps().y1(),
+ this->ps().x2() - this->ps().x1()
+ )
+ - this->ps().heading()
+ ) < M_PI / 2) {
+ // forward parking
x = this->ps().x4();
y = this->ps().y4();
h = dts;
x += (this->gc().w() / 2 + 0.01) * cos(dts);
y += (this->gc().w() / 2 + 0.01) * sin(dts);
} else {
+ dts = atan2(
+ this->ps().y2() - this->ps().y1(),
+ this->ps().x2() - this->ps().x1()
+ );
+ dts *= 1.01; // precision workaround
+ // backward parking
h = dts + M_PI;
x += -(this->gc().df() + 0.01) * cos(h);
y += -(this->gc().df() + 0.01) * sin(h);