cesium-native 0.64.0
Loading...
Searching...
No Matches
AxisAlignedBox.h
1#pragma once
2
3#include <CesiumGeometry/Library.h>
4
5#include <glm/ext/vector_double3.hpp>
6
7#include <vector>
8
9namespace CesiumGeometry {
11
16struct CESIUMGEOMETRY_API AxisAlignedBox final {
17
22 constexpr AxisAlignedBox() noexcept
23 : minimumX(0.0),
24 minimumY(0.0),
25 minimumZ(0.0),
26 maximumX(0.0),
27 maximumY(0.0),
28 maximumZ(0.0),
29 lengthX(0.0),
30 lengthY(0.0),
31 lengthZ(0.0),
32 center(0.0) {}
33
44 constexpr AxisAlignedBox(
45 double minimumX_,
46 double minimumY_,
47 double minimumZ_,
48 double maximumX_,
49 double maximumY_,
50 double maximumZ_) noexcept
51 : minimumX(minimumX_),
52 minimumY(minimumY_),
53 minimumZ(minimumZ_),
54 maximumX(maximumX_),
55 maximumY(maximumY_),
56 maximumZ(maximumZ_),
60 center(
61 0.5 * (maximumX + minimumX),
62 0.5 * (maximumY + minimumY),
63 0.5 * (maximumZ + minimumZ)) {}
64
68 double minimumX;
69
73 double minimumY;
74
78 double minimumZ;
79
83 double maximumX;
84
88 double maximumY;
89
93 double maximumZ;
94
98 double lengthX;
99
103 double lengthY;
104
108 double lengthZ;
109
113 glm::dvec3 center;
114
121 constexpr bool contains(const glm::dvec3& position) const noexcept {
122 return position.x >= this->minimumX && position.x <= this->maximumX &&
123 position.y >= this->minimumY && position.y <= this->maximumY &&
124 position.z >= this->minimumZ && position.z <= this->maximumZ;
125 }
126
134 static AxisAlignedBox fromPositions(const std::vector<glm::dvec3>& positions);
135};
136
144bool CESIUMGEOMETRY_API
146
156
157} // namespace CesiumGeometry
A bounding volume defined as a closed and convex cuboid with any orientation.
Basic geometry classes for Cesium.
bool intersects(const AxisAlignedBox &b0, const AxisAlignedBox &b1)
Test if two axis-aligned boxes intersect.
OrientedBoundingBox toOrientedBoundingBox(const AxisAlignedBox &box)
Return the equivalent OrientedBoundingBox for an AxisAlignedBox. The axes will be the principal axes.
An Axis-Aligned Bounding Box (AABB), where the axes of the box are aligned with the axes of the coord...
double maximumY
The maximum y-coordinate.
constexpr AxisAlignedBox() noexcept
Creates an empty AABB with a length, width, and height of zero, with the center located at (0,...
double lengthY
The length of the box on the y-axis.
constexpr AxisAlignedBox(double minimumX_, double minimumY_, double minimumZ_, double maximumX_, double maximumY_, double maximumZ_) noexcept
Creates a new AABB using the range of coordinates the box covers.
double lengthX
The length of the box on the x-axis.
double minimumY
The minimum y-coordinate.
double minimumZ
The minimum z-coordinate.
static AxisAlignedBox fromPositions(const std::vector< glm::dvec3 > &positions)
Creates a tight-fitting, axis-aligned bounding box that contains all of the input positions.
double maximumX
The maximum x-coordinate.
glm::dvec3 center
The center of the box.
constexpr bool contains(const glm::dvec3 &position) const noexcept
Checks if this AABB contains the given position.
double minimumX
The minimum x-coordinate.
double maximumZ
The maximum z-coordinate.
double lengthZ
The length of the box on the z-axis.