bool BoundingBox::Intersects(BoundingBox otherBox) { bool hasCollided = false; float distance = sqrt (pow(position[0] - otherBox.position[0], 2) + pow(position[1] - otherBox.position[1], 2) + pow(position[2] - otherBox.position[2], 2));//distance between two boxes positions //only do more accurate detection if boxes are near enough to each other if (distance < maxOuterBoundary + otherBox.maxOuterBoundary) { SetCorners(); cml::vector3f minPosOtherBox = otherBox.GetMinPosition(); cml::vector3f maxPosOtherBox = otherBox.GetMaxPosition(); for (std::vector<cml::vector3f>::size_type i = 0; i < corners.size(); i++) { if (corners[i][0] <= maxPosOtherBox[0] && corners[i][0] >= minPosOtherBox[0] && corners[i][1] <= maxPosOtherBox[1] && corners[i][1] >= minPosOtherBox[1] && corners[i][2] <= maxPosOtherBox[2] && corners[i][2] >= minPosOtherBox[2]) { hasCollided = true; break; } } } return hasCollided; }
void Legend::SetOrientation(Orientation orientation, std::vector<std::string> const& entries, std::string const& title) { INFO0; auto width = Width(entries); auto height = Height(entries, title); auto min = Position(orientation, width, height); SetCorners(boca::Rectangle<double>(min, width, height)); }
void Legend::Set(boca::Rectangle<double> const& rectangle, std::string const& title) { INFO0; SetCorners(rectangle); SetTitle(title); }