Wrong calculation of bounding box in WorldObjectAdapter
There is a function for calculating bounding box:
const polygon_t WorldObjectAdapter::CalculateBoundingBox()
If we look at the calculation of the bounding box, there is a little mis-calculation. Lines 106 and 107 are returning back coordinates of the object located at objects center of rear axle.
const auto x = units::unit_cast<double>(GetPositionX());
const auto y = units::unit_cast<double>(GetPositionY());
Then there is a line 109 and lines 115-119 which are calculating points of the bounding box.
const auto center = GetDistanceReferencePointToLeadingEdge();
const auto halfWidth = width / 2.0;
const auto widthLeft = halfWidth * units::math::cos(roll) + (roll < 0_rad ? height * units::math::sin(-roll) : 0_m);
const auto widthRight = halfWidth * units::math::cos(roll) + (roll > 0_rad ? height * units::math::sin(roll) : 0_m);
std::vector<point_t> boxPoints{{units::unit_cast<double>(center - length), units::unit_cast<double>(-widthRight)},
{units::unit_cast<double>(center - length), units::unit_cast<double>(widthLeft)},
{units::unit_cast<double>(center), units::unit_cast<double>(widthLeft)},
{units::unit_cast<double>(center), units::unit_cast<double>(-widthRight)},
{units::unit_cast<double>(center - length), units::unit_cast<double>(-widthRight)}};
The problem occures when local coordinates are translated to the global reference system at line 131.
polygon_t box;
polygon_t boxTemp;
bg::append(box, boxPoints);
bt::translate_transformer<double, 2, 2> translate(x, y);
// rotation in mathematical negativ order (boost) -> invert to match
bt::rotate_transformer<bg::radian, double, 2, 2> rotate(-rotation.value());
bg::transform(box, boxTemp, rotate);
bg::transform(boxTemp, box, translate);
x and y coordinates are center of rear axle while bounding box points are defined with respect to center of bounding box. This mismatch of local coordinates create an error for detecting collisions described within the class. It seems to be fixed at a later computation stage but the mentioned function has a misleading behaviour.