| 72 | } |
| 73 | |
| 74 | std::optional<GlobeRectangle> GlobeRectangle::computeIntersection( |
| 75 | const GlobeRectangle& other) const noexcept { |
| 76 | double rectangleEast = this->_east; |
| 77 | double rectangleWest = this->_west; |
| 78 | |
| 79 | double otherRectangleEast = other._east; |
| 80 | double otherRectangleWest = other._west; |
| 81 | |
| 82 | if (rectangleEast < rectangleWest && otherRectangleEast > 0.0) { |
| 83 | rectangleEast += CesiumUtility::Math::TwoPi; |
| 84 | } else if (otherRectangleEast < otherRectangleWest && rectangleEast > 0.0) { |
| 85 | otherRectangleEast += CesiumUtility::Math::TwoPi; |
| 86 | } |
| 87 | |
| 88 | if (rectangleEast < rectangleWest && otherRectangleWest < 0.0) { |
| 89 | otherRectangleWest += CesiumUtility::Math::TwoPi; |
| 90 | } else if (otherRectangleEast < otherRectangleWest && rectangleWest < 0.0) { |
| 91 | rectangleWest += CesiumUtility::Math::TwoPi; |
| 92 | } |
| 93 | |
| 94 | const double west = CesiumUtility::Math::negativePiToPi( |
| 95 | glm::max(rectangleWest, otherRectangleWest)); |
| 96 | const double east = CesiumUtility::Math::negativePiToPi( |
| 97 | glm::min(rectangleEast, otherRectangleEast)); |
| 98 | |
| 99 | if ((this->_west < this->_east || other._west < other._east) && |
| 100 | east <= west) { |
| 101 | return std::nullopt; |
| 102 | } |
| 103 | |
| 104 | const double south = glm::max(this->_south, other._south); |
| 105 | const double north = glm::min(this->_north, other._north); |
| 106 | |
| 107 | if (south >= north) { |
| 108 | return std::nullopt; |
| 109 | } |
| 110 | |
| 111 | return GlobeRectangle(west, south, east, north); |
| 112 | } |
| 113 | |
| 114 | GlobeRectangle |
| 115 | GlobeRectangle::computeUnion(const GlobeRectangle& other) const noexcept { |
no test coverage detected