| 47 | } |
| 48 | |
| 49 | std::optional<Rectangle> |
| 50 | Rectangle::computeIntersection(const Rectangle& other) const noexcept { |
| 51 | const double left = glm::max(this->minimumX, other.minimumX); |
| 52 | const double bottom = glm::max(this->minimumY, other.minimumY); |
| 53 | const double right = glm::min(this->maximumX, other.maximumX); |
| 54 | const double top = glm::min(this->maximumY, other.maximumY); |
| 55 | |
| 56 | if (bottom >= top || left >= right) { |
| 57 | return std::nullopt; |
| 58 | } |
| 59 | |
| 60 | return Rectangle(left, bottom, right, top); |
| 61 | } |
| 62 | |
| 63 | Rectangle Rectangle::computeUnion(const Rectangle& other) const noexcept { |
| 64 | return Rectangle( |
no test coverage detected