cesium-native  0.41.0
BoundingSphere.h
1 #pragma once
2 
3 #include "CullingResult.h"
4 #include "Library.h"
5 
6 #include <glm/fwd.hpp>
7 #include <glm/vec3.hpp>
8 
9 namespace CesiumGeometry {
10 
11 class Plane;
12 
16 class CESIUMGEOMETRY_API BoundingSphere final {
17 public:
24  constexpr BoundingSphere(const glm::dvec3& center, double radius) noexcept
25  : _center(center), _radius(radius) {}
26 
30  constexpr const glm::dvec3& getCenter() const noexcept {
31  return this->_center;
32  }
33 
37  constexpr double getRadius() const noexcept { return this->_radius; }
38 
50  CullingResult intersectPlane(const Plane& plane) const noexcept;
51 
62  double
63  computeDistanceSquaredToPosition(const glm::dvec3& position) const noexcept;
64 
72  bool contains(const glm::dvec3& position) const noexcept;
73 
84  BoundingSphere transform(const glm::dmat4& transformation) const noexcept;
85 
86 private:
87  glm::dvec3 _center;
88  double _radius;
89 };
90 
91 } // namespace CesiumGeometry
A bounding sphere with a center and a radius.
CullingResult intersectPlane(const Plane &plane) const noexcept
Determines on which side of a plane this boundings sphere is located.
bool contains(const glm::dvec3 &position) const noexcept
Computes whether the given position is contained within the bounding sphere.
constexpr const glm::dvec3 & getCenter() const noexcept
Gets the center of the bounding sphere.
constexpr BoundingSphere(const glm::dvec3 &center, double radius) noexcept
Construct a new instance.
double computeDistanceSquaredToPosition(const glm::dvec3 &position) const noexcept
Computes the distance squared from a position to the closest point on this bounding sphere....
constexpr double getRadius() const noexcept
Gets the radius of the bounding sphere.
BoundingSphere transform(const glm::dmat4 &transformation) const noexcept
Transforms this bounding sphere to another coordinate system using a 4x4 matrix.
A plane in Hessian Normal Format.
Definition: Plane.h:12
Basic geometry classes for Cesium.
CullingResult
The result of culling an object.
Definition: CullingResult.h:10