A bounding volume defined as a closed and convex cuboid with any orientation.
More...
#include <CesiumGeometry/OrientedBoundingBox.h>
|
| OrientedBoundingBox (const glm::dvec3 ¢er, const glm::dmat3 &halfAxes) noexcept |
| Constructs a new instance. More...
|
|
constexpr const glm::dvec3 & | getCenter () const noexcept |
| Gets the center of the box.
|
|
constexpr const glm::dmat3 & | getHalfAxes () const noexcept |
| Gets the three orthogonal half-axes of the bounding box. Equivalently, the transformation matrix to rotate and scale a 2x2x2 cube centered at the origin.
|
|
constexpr const glm::dmat3 & | getInverseHalfAxes () const noexcept |
| Gets the inverse transformation matrix, to rotate from world space to local space relative to the box.
|
|
constexpr const glm::dvec3 & | getLengths () const noexcept |
| Gets the lengths of the box on each local axis respectively.
|
|
CullingResult | intersectPlane (const Plane &plane) const noexcept |
| Determines on which side of a plane the bounding box is located. More...
|
|
double | computeDistanceSquaredToPosition (const glm::dvec3 &position) const noexcept |
| Computes the distance squared from a given position to the closest point on this bounding volume. The bounding volume and the position must be expressed in the same coordinate system. More...
|
|
bool | contains (const glm::dvec3 &position) const noexcept |
| Computes whether the given position is contained within the bounding box. More...
|
|
OrientedBoundingBox | transform (const glm::dmat4 &transformation) const noexcept |
| Transforms this bounding box to another coordinate system using a 4x4 matrix. More...
|
|
AxisAlignedBox | toAxisAligned () const noexcept |
| Converts this oriented bounding box to an axis-aligned bounding box.
|
|
BoundingSphere | toSphere () const noexcept |
| Converts this oriented bounding box to a bounding sphere.
|
|
A bounding volume defined as a closed and convex cuboid with any orientation.
- See also
- BoundingSphere
-
BoundingRegion
Definition at line 22 of file OrientedBoundingBox.h.
◆ OrientedBoundingBox()
CesiumGeometry::OrientedBoundingBox::OrientedBoundingBox |
( |
const glm::dvec3 & |
center, |
|
|
const glm::dmat3 & |
halfAxes |
|
) |
| |
|
inlinenoexcept |
Constructs a new instance.
- Parameters
-
center | The center of the box. |
halfAxes | The three orthogonal half-axes of the bounding box. Equivalently, the transformation matrix to rotate and scale a 2x2x2 cube centered at the origin. |
glm::dvec3 center = glm::dvec3(1.0, 0.0, 0.0);
glm::dmat3 halfAxes = glm::dmat3(
glm::dvec3(1.0, 0.0, 0.0),
glm::dvec3(0.0, 3.0, 0.0),
glm::dvec3(0.0, 0.0, 2.0));
OrientedBoundingBox(const glm::dvec3 ¢er, const glm::dmat3 &halfAxes) noexcept
Constructs a new instance.
Definition at line 34 of file OrientedBoundingBox.h.
◆ computeDistanceSquaredToPosition()
double CesiumGeometry::OrientedBoundingBox::computeDistanceSquaredToPosition |
( |
const glm::dvec3 & |
position | ) |
const |
|
noexcept |
Computes the distance squared from a given position to the closest point on this bounding volume. The bounding volume and the position must be expressed in the same coordinate system.
- Parameters
-
- Returns
- The estimated distance squared from the bounding box to the point.
glm::dvec3 cameraPosition = anyOldCameraPosition();
std::vector<OrientedBoundingBox> boxes = anyOldBoxArray();
std::sort(boxes.begin(), boxes.end(), [&cameraPosition](auto& a, auto& b) {
return a.computeDistanceSquaredToPosition(cameraPosition) >
b.computeDistanceSquaredToPosition(cameraPosition);
});
◆ contains()
bool CesiumGeometry::OrientedBoundingBox::contains |
( |
const glm::dvec3 & |
position | ) |
const |
|
noexcept |
Computes whether the given position is contained within the bounding box.
- Parameters
-
- Returns
- Whether the position is contained within the bounding box.
◆ intersectPlane()
CullingResult CesiumGeometry::OrientedBoundingBox::intersectPlane |
( |
const Plane & |
plane | ) |
const |
|
noexcept |
Determines on which side of a plane the bounding box is located.
- Parameters
-
plane | The plane to test against. |
- Returns
- The CullingResult:
Inside
if the entire box is on the side of the plane the normal is pointing.
Outside
if the entire box is on the opposite side.
Intersecting
if the box intersects the plane.
◆ transform()
OrientedBoundingBox CesiumGeometry::OrientedBoundingBox::transform |
( |
const glm::dmat4 & |
transformation | ) |
const |
|
noexcept |
Transforms this bounding box to another coordinate system using a 4x4 matrix.
- Parameters
-
transformation | The transformation. |
- Returns
- The oriented bounding box in the new coordinate system.
The documentation for this class was generated from the following file:
- /home/runner/work/cesium-native/cesium-native/CesiumGeometry/include/CesiumGeometry/OrientedBoundingBox.h