EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
EBGeometry::SphereSDF< T > Class Template Reference

Signed distance field for a sphere. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Public Member Functions

 SphereSDF ()=default
 Default constructor. Constructs a unit sphere centered at the origin.
 
 SphereSDF (const Vec3T< T > &a_center, const T &a_radius) noexcept
 Full constructor.
 
 SphereSDF (const SphereSDF &)=default
 Copy constructor.
 
 SphereSDF (SphereSDF &&)=default
 Move constructor.
 
SphereSDF & operator= (const SphereSDF &)=default
 Copy assignment.
 
SphereSDF & operator= (SphereSDF &&)=default
 Move assignment.
 
const Vec3T< T > & getCenter () const noexcept
 Get sphere center (const).
 
Vec3T< T > & getCenter () noexcept
 Get sphere center (mutable).
 
const T & getRadius () const noexcept
 Get sphere radius (const).
 
T & getRadius () noexcept
 Get sphere radius (mutable).
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 Signed distance function for the sphere.
 
BoundingVolumes::AABBT< T > computeBoundingVolume () const noexcept
 The shape's axis-aligned bounding box.
 

Static Public Attributes

static constexpr DistanceQuality distanceQuality = DistanceQuality::Exact
 How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
 

Protected Attributes

Vec3T< T > m_center = Vec3T<T>::zeros()
 Sphere center.
 
T m_radius = T(1)
 Sphere radius.
 

Detailed Description

template<class T>
class EBGeometry::SphereSDF< T >

Signed distance field for a sphere.

The sphere is placed at m_center with radius m_radius. The SDF is negative inside the sphere and positive outside. By default the sphere is centered at the origin with radius 1.

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ SphereSDF()

template<class T >
EBGeometry::SphereSDF< T >::SphereSDF ( const Vec3T< T > &  a_center,
const T &  a_radius 
)
inlinenoexcept

Full constructor.

Parameters
[in]a_centerSphere center.
[in]a_radiusSphere radius.

Member Function Documentation

◆ computeBoundingVolume()

template<class T >
BoundingVolumes::AABBT< T > EBGeometry::SphereSDF< T >::computeBoundingVolume ( ) const
inlinenoexcept

The shape's axis-aligned bounding box.

The center plus and minus the radius along each axis.

Returns
The bounding box.

◆ getCenter() [1/2]

template<class T >
const Vec3T< T > & EBGeometry::SphereSDF< T >::getCenter ( ) const
inlinenoexcept

Get sphere center (const).

Returns
Const reference to the center position.

◆ getCenter() [2/2]

template<class T >
Vec3T< T > & EBGeometry::SphereSDF< T >::getCenter ( )
inlinenoexcept

Get sphere center (mutable).

Returns
Mutable reference to the center position.

◆ getRadius() [1/2]

template<class T >
const T & EBGeometry::SphereSDF< T >::getRadius ( ) const
inlinenoexcept

Get sphere radius (const).

Returns
Const reference to the radius.

◆ getRadius() [2/2]

template<class T >
T & EBGeometry::SphereSDF< T >::getRadius ( )
inlinenoexcept

Get sphere radius (mutable).

Returns
Mutable reference to the radius.

◆ operator=() [1/2]

template<class T >
SphereSDF & EBGeometry::SphereSDF< T >::operator= ( const SphereSDF< T > &  )
default

Copy assignment.

Returns
Reference to (*this).

◆ operator=() [2/2]

template<class T >
SphereSDF & EBGeometry::SphereSDF< T >::operator= ( SphereSDF< T > &&  )
default

Move assignment.

Returns
Reference to (*this).

◆ signedDistance()

template<class T >
T EBGeometry::SphereSDF< T >::signedDistance ( const Vec3T< T > &  a_point) const
inlinenoexcept

Signed distance function for the sphere.

Parameters
[in]a_pointPosition.
Returns
Signed distance from a_point to the sphere surface; negative inside the sphere.

The documentation for this class was generated from the following file: