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::EllipsoidSDF< T > Class Template Reference

Signed distance field for an ellipsoid with its semi-axes along x, y and z. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Public Member Functions

 EllipsoidSDF ()=default
 Default constructor. Constructs the unit sphere at the origin.
 
 EllipsoidSDF (const Vec3T< T > &a_center, const Vec3T< T > &a_radii)
 Full constructor.
 
 EllipsoidSDF (const EllipsoidSDF &)=default
 Copy constructor.
 
 EllipsoidSDF (EllipsoidSDF &&)=default
 Move constructor.
 
EllipsoidSDF & operator= (const EllipsoidSDF &)=default
 Copy assignment.
 
EllipsoidSDF & operator= (EllipsoidSDF &&)=default
 Move assignment.
 
const Vec3T< T > & getCenter () const noexcept
 Get the center.
 
const Vec3T< T > & getRadii () const noexcept
 Get the semi-axes.
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 Signed distance function for the ellipsoid.
 
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()
 Center.
 
Vec3T< T > m_radii = Vec3T<T>::ones()
 Semi-axes along x, y and z.
 

Detailed Description

template<class T>
class EBGeometry::EllipsoidSDF< T >

Signed distance field for an ellipsoid with its semi-axes along x, y and z.

The value is the exact signed distance. There is no closed form for it: the closest point on the surface is the root of a scalar equation (Eberly, "Distance from a point to an ellipse, an ellipsoid, or a hyperellipsoid", 2013), found by safeguarded Newton steps from a bracket, a few iterations for most points and at most 64. An ellipsoid therefore costs several times as much to evaluate as the other shapes here. The common formula |p / r| (|p / r| - 1) / |p / r^2| is cheaper, but it can overestimate the distance, which a DistanceQuality::Bound may not. Turn the ellipsoid with Rotate. By default the ellipsoid is the unit sphere at the origin.

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ EllipsoidSDF()

template<class T >
EBGeometry::EllipsoidSDF< T >::EllipsoidSDF ( const Vec3T< T > &  a_center,
const Vec3T< T > &  a_radii 
)
inline

Full constructor.

Parameters
[in]a_centerCenter.
[in]a_radiiThe semi-axes along x, y and z, each finite and positive.

Member Function Documentation

◆ computeBoundingVolume()

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

The shape's axis-aligned bounding box.

Returns
The bounding box.

◆ getCenter()

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

Get the center.

Returns
m_center.

◆ getRadii()

template<class T >
const Vec3T< T > & EBGeometry::EllipsoidSDF< T >::getRadii ( ) const
inlinenoexcept

Get the semi-axes.

Returns
m_radii.

◆ operator=() [1/2]

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

Copy assignment.

Returns
Reference to (*this).

◆ operator=() [2/2]

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

Move assignment.

Returns
Reference to (*this).

◆ signedDistance()

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

Signed distance function for the ellipsoid.

The point is folded into the first octant and the axes sorted from largest to smallest, as Eberly's algorithm takes them.

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

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