A bounding sphere with a center and a radius.
More...
#include <CesiumGeometry/BoundingSphere.h>
|
constexpr | BoundingSphere (const glm::dvec3 ¢er, double radius) noexcept |
| Construct a new instance. More...
|
|
constexpr const glm::dvec3 & | getCenter () const noexcept |
| Gets the center of the bounding sphere.
|
|
constexpr double | getRadius () const noexcept |
| Gets the radius of the bounding sphere.
|
|
CullingResult | intersectPlane (const Plane &plane) const noexcept |
| Determines on which side of a plane this boundings sphere is located. More...
|
|
double | computeDistanceSquaredToPosition (const glm::dvec3 &position) const noexcept |
| Computes the distance squared from a position to the closest point on this bounding sphere. Returns 0 if the point is inside the sphere. More...
|
|
bool | contains (const glm::dvec3 &position) const noexcept |
| Computes whether the given position is contained within the bounding sphere. More...
|
|
BoundingSphere | transform (const glm::dmat4 &transformation) const noexcept |
| Transforms this bounding sphere to another coordinate system using a 4x4 matrix. More...
|
|
A bounding sphere with a center and a radius.
Definition at line 16 of file BoundingSphere.h.
◆ BoundingSphere()
constexpr CesiumGeometry::BoundingSphere::BoundingSphere |
( |
const glm::dvec3 & |
center, |
|
|
double |
radius |
|
) |
| |
|
inlineconstexprnoexcept |
Construct a new instance.
- Parameters
-
center | The center of the bounding sphere. |
radius | The radius of the bounding sphere. |
Definition at line 24 of file BoundingSphere.h.
◆ computeDistanceSquaredToPosition()
double CesiumGeometry::BoundingSphere::computeDistanceSquaredToPosition |
( |
const glm::dvec3 & |
position | ) |
const |
|
noexcept |
Computes the distance squared from a position to the closest point on this bounding sphere. Returns 0 if the point is inside the sphere.
- Parameters
-
- Returns
- The distance squared from the position to the closest point on this bounding sphere.
glm::dvec3 cameraPosition = anyOldCameraPosition();
std::vector<BoundingSphere> spheres = anyOldSphereArray();
std::sort(
spheres.begin(),
spheres.end(),
[&cameraPosition](auto& a, auto& b) {
return a.computeDistanceSquaredToPosition(cameraPosition) >
b.computeDistanceSquaredToPosition(cameraPosition);
});
◆ contains()
bool CesiumGeometry::BoundingSphere::contains |
( |
const glm::dvec3 & |
position | ) |
const |
|
noexcept |
Computes whether the given position is contained within the bounding sphere.
- Parameters
-
- Returns
- Whether the position is contained within the bounding sphere.
◆ intersectPlane()
Determines on which side of a plane this boundings sphere is located.
- Parameters
-
plane | The plane to test against. |
- Returns
- The CullingResult:
Inside
if the entire sphere is on the side of the plane the normal is pointing.
Outside
if the entire sphere is on the opposite side.
Intersecting
if the sphere intersects the plane.
◆ transform()
BoundingSphere CesiumGeometry::BoundingSphere::transform |
( |
const glm::dmat4 & |
transformation | ) |
const |
|
noexcept |
Transforms this bounding sphere to another coordinate system using a 4x4 matrix.
If the transformation has non-uniform scale, the bounding sphere's radius is scaled by the largest scale value among the transformation's axes.
- Parameters
-
transformation | The transformation. |
- Returns
- The bounding sphere 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/BoundingSphere.h