|
EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
|
Bounding sphere — an approximation to the smallest sphere enclosing a set of 3D points. More...
#include <EBGeometry_BoundingVolumes.hpp>
Public Types | |
| enum class | BuildAlgorithm { Ritter } |
| Algorithm used to compute a bounding sphere for a set of 3D points. More... | |
| using | Vec3 = Vec3T< T > |
| Alias to cut down on typing. | |
Public Member Functions | |
| SphereT () noexcept=default | |
| Default constructor. Sets radius to -1 (invalid sentinel). | |
| SphereT (const Vec3T< T > &a_center, const T &a_radius) noexcept | |
| Construct a sphere with an explicit centre and radius. | |
| SphereT (const std::vector< SphereT< T > > &a_otherSpheres) noexcept | |
Construct the smallest sphere enclosing all a_otherSpheres. | |
| SphereT (const SphereT &a_other) noexcept | |
| Copy constructor. | |
| template<class P > | |
| SphereT (const std::vector< Vec3T< P > > &a_points, const BuildAlgorithm &a_alg=BuildAlgorithm::Ritter) noexcept | |
| Construct a bounding sphere enclosing a set of 3D points. | |
| ~SphereT () noexcept | |
| Destructor. | |
| SphereT & | operator= (const SphereT &a_other)=default |
| Copy assignment operator. | |
| SphereT (SphereT &&a_other) noexcept=default | |
| Move constructor. | |
| SphereT & | operator= (SphereT &&a_other) noexcept=default |
| Move assignment operator. | |
| template<class P > | |
| void | define (const std::vector< Vec3T< P > > &a_points, const BuildAlgorithm &a_alg) noexcept |
| Fit this sphere to a set of 3D points using the specified algorithm. | |
| bool | intersects (const SphereT &a_other) const noexcept |
Test whether this bounding sphere intersects a_other. | |
| T & | getRadius () noexcept |
| Get a modifiable reference to the sphere radius. | |
| const T & | getRadius () const noexcept |
| Get the sphere radius. | |
| Vec3 & | getCentroid () noexcept |
| Get a modifiable reference to the sphere centroid. | |
| const Vec3 & | getCentroid () const noexcept |
| Get the sphere centroid. | |
| T | getOverlappingVolume (const SphereT< T > &a_other) const noexcept |
Compute the overlapping volume between this sphere and a_other. | |
| T | getDistance (const Vec3 &a_x0) const noexcept |
Compute the unsigned distance from a_x0 to this sphere. | |
| T | getDistance2 (const Vec3 &a_x0) const noexcept |
Compute the squared unsigned distance from a_x0 to this sphere. | |
| T | getVolume () const noexcept |
| Compute the sphere volume (4/3 * pi * r^3). | |
| T | getArea () const noexcept |
| Compute the sphere surface area (4 * pi * r^2). | |
Protected Member Functions | |
| template<class P > | |
| void | buildRitter (const std::vector< Vec3T< P > > &a_points) noexcept |
Fit a bounding sphere to a_points using Ritter's algorithm. | |
Protected Attributes | |
| T | m_radius = T(-1) |
| Sphere radius. Initialised to -1 (invalid sentinel). | |
| Vec3 | m_center = Vec3::zeros() |
| Sphere centre. Initialised to the origin. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const SphereT< T > &sphere) |
| Output a bounding sphere to a stream in the form "(centroid, radius)". | |
Bounding sphere — an approximation to the smallest sphere enclosing a set of 3D points.
| T | Floating-point precision (e.g., float or double). |
|
strong |
|
defaultnoexcept |
Default constructor. Sets radius to -1 (invalid sentinel).
Any geometric method called on a default-constructed sphere will fire an EBGEOMETRY_EXPECT assertion. Call define() or use the explicit constructor before use.
|
inlinenoexcept |
Construct a sphere with an explicit centre and radius.
| [in] | a_center | Sphere centre. |
| [in] | a_radius | Sphere radius. |
|
inlinenoexcept |
Construct the smallest sphere enclosing all a_otherSpheres.
| [in] | a_otherSpheres | Spheres to enclose. |
|
inlinenoexcept |
Copy constructor.
| [in] | a_other | Sphere to copy. |
|
inlinenoexcept |
Construct a bounding sphere enclosing a set of 3D points.
Mixed floating-point precision is allowed: P may differ from T.
| P | Floating-point precision of the input points. |
| [in] | a_points | Set of 3D points. |
| [in] | a_alg | Algorithm to use (default: Ritter). |
|
defaultnoexcept |
Move constructor.
| [in] | a_other | Sphere to move from. |
|
inlineprotectednoexcept |
Fit a bounding sphere to a_points using Ritter's algorithm.
| P | Floating-point precision of the input points. |
| [in] | a_points | Set of 3D points to enclose. |
|
inlinenoexcept |
Fit this sphere to a set of 3D points using the specified algorithm.
Mixed floating-point precision is allowed: P may differ from T.
| P | Floating-point precision of the input points. |
| [in] | a_points | Set of 3D points. |
| [in] | a_alg | Algorithm to use. |
|
inlinenoexcept |
Compute the sphere surface area (4 * pi * r^2).
|
inlinenoexcept |
Get the sphere centroid.
|
inlinenoexcept |
Get a modifiable reference to the sphere centroid.
|
inlinenoexcept |
Compute the unsigned distance from a_x0 to this sphere.
| [in] | a_x0 | 3D query point. |
a_x0 to the sphere surface; zero if a_x0 is inside.
|
inlinenoexcept |
Compute the squared unsigned distance from a_x0 to this sphere.
Mirrors AABBT::getDistance2(), giving both bounding volumes a uniform squared-distance query (e.g. for a BVH's sqrt-free pruning). Unlike the box, a sphere's surface distance is inherently radial, so this cannot avoid the square root the way AABBT::getDistance2() does – it is simply getDistance() squared.
| [in] | a_x0 | 3D query point. |
a_x0 to the sphere surface; zero if a_x0 is inside.
|
inlinenoexcept |
Compute the overlapping volume between this sphere and a_other.
| [in] | a_other | Other bounding sphere. |
|
inlinenoexcept |
Get the sphere radius.
|
inlinenoexcept |
Get a modifiable reference to the sphere radius.
|
inlinenoexcept |
Compute the sphere volume (4/3 * pi * r^3).
|
inlinenoexcept |
Test whether this bounding sphere intersects a_other.
| [in] | a_other | Other bounding sphere. |
|
default |
Copy assignment operator.
| [in] | a_other | Sphere to copy. |
|
defaultnoexcept |
Move assignment operator.
| [in] | a_other | Sphere to move from. |
|
friend |
Output a bounding sphere to a stream in the form "(centroid, radius)".
| [in,out] | os | Output stream. |
| [in] | sphere | Bounding sphere to print. |
os to allow chaining.