MCPcopy Create free account
hub / github.com/CesiumGS/cesium-native / _computeBoundingBox

Method _computeBoundingBox

CesiumGeospatial/src/BoundingRegion.cpp:274–474  ·  view source on GitHub ↗

static*/

Source from the content-addressed store, hash-verified

272} // namespace
273
274/*static*/ OrientedBoundingBox BoundingRegion::_computeBoundingBox(
275 const GlobeRectangle& rectangle,
276 double minimumHeight,
277 double maximumHeight,
278 const Ellipsoid& ellipsoid) {
279 //>>includeStart('debug', pragmas.debug);
280 if (!Math::equalsEpsilon(
281 ellipsoid.getRadii().x,
282 ellipsoid.getRadii().y,
283 Math::Epsilon15)) {
284 throw std::runtime_error(
285 "Ellipsoid must be an ellipsoid of revolution (radii.x == radii.y)");
286 }
287 //>>includeEnd('debug');
288
289 double minX, maxX, minY, maxY, minZ, maxZ;
290 Plane plane(glm::dvec3(0.0, 0.0, 1.0), 0.0);
291
292 if (rectangle.computeWidth() <= Math::OnePi) {
293 // The bounding box will be aligned with the tangent plane at the center of
294 // the rectangle.
295 const Cartographic tangentPointCartographic = rectangle.computeCenter();
296 const glm::dvec3 tangentPoint =
297 ellipsoid.cartographicToCartesian(tangentPointCartographic);
298 const EllipsoidTangentPlane tangentPlane(tangentPoint, ellipsoid);
299 plane = tangentPlane.getPlane();
300
301 // If the rectangle spans the equator, CW is instead aligned with the
302 // equator (because it sticks out the farthest at the equator).
303 const double lonCenter = tangentPointCartographic.longitude;
304 const double latCenter =
305 rectangle.getSouth() < 0.0 && rectangle.getNorth() > 0.0
306 ? 0.0
307 : tangentPointCartographic.latitude;
308
309 // Compute XY extents using the rectangle at maximum height
310 const Cartographic perimeterCartographicNC(
311 lonCenter,
312 rectangle.getNorth(),
313 maximumHeight);
314 Cartographic perimeterCartographicNW(
315 rectangle.getWest(),
316 rectangle.getNorth(),
317 maximumHeight);
318 const Cartographic perimeterCartographicCW(
319 rectangle.getWest(),
320 latCenter,
321 maximumHeight);
322 Cartographic perimeterCartographicSW(
323 rectangle.getWest(),
324 rectangle.getSouth(),
325 maximumHeight);
326 const Cartographic perimeterCartographicSC(
327 lonCenter,
328 rectangle.getSouth(),
329 maximumHeight);
330
331 const glm::dvec3 perimeterCartesianNC =

Callers

nothing calls this directly

Calls 10

fromPlaneExtentsFunction · 0.85
normalizeFunction · 0.85
computeCenterMethod · 0.80
getPointDistanceMethod · 0.80
projectPointOntoPlaneMethod · 0.80
equalsEpsilonFunction · 0.50
CartographicClass · 0.50
PlaneClass · 0.50

Tested by

no test coverage detected