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

Signed distance field for a cut sphere: the part of a sphere above a horizontal plane, a dome or a sphere with a flat bottom. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Public Member Functions

 CutSphereSDF ()=default
 Default constructor. Constructs the upper half of the unit sphere at the origin.
 
 CutSphereSDF (const Vec3T< T > &a_center, const T a_radius, const T a_height)
 Full constructor.
 
 CutSphereSDF (const CutSphereSDF &)=default
 Copy constructor.
 
 CutSphereSDF (CutSphereSDF &&)=default
 Move constructor.
 
CutSphereSDF & operator= (const CutSphereSDF &)=default
 Copy assignment.
 
CutSphereSDF & operator= (CutSphereSDF &&)=default
 Move assignment.
 
const Vec3T< T > & getCenter () const noexcept
 Get the center of the sphere.
 
const T & getRadius () const noexcept
 Get the radius.
 
const T & getHeight () const noexcept
 Get the height of the cut plane above the center.
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 Signed distance function for the cut sphere.
 
uint32_t getNumParts () const noexcept
 How many parts the shape has (see hasParts): 2.
 
uint32_t closestPart (const Vec3T< T > &a_point) const noexcept
 The part whose term decides the value at a point (see hasParts): 0 the sphere, 1 the flat cut face (its rim included).
 
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 of the sphere.
 
T m_radius = T(1)
 Radius.
 
T m_height = T(0)
 Height of the cut plane above the center.
 
T m_rim = T(1)
 Radius of the rim, sqrt(radius^2 - height^2).
 

Detailed Description

template<class T>
class EBGeometry::CutSphereSDF< T >

Signed distance field for a cut sphere: the part of a sphere above a horizontal plane, a dome or a sphere with a flat bottom.

The solid is the part of the sphere at y >= center.y + height: a dome (a spherical cap) for a positive height, more than a hemisphere for a negative one. The distance is exact (Quilez's cut sphere): in the plane through the y axis, the point is nearest the sphere, the flat face or the rim between them. Turn it with Rotate. By default it is the upper half of the unit sphere at the origin.

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ CutSphereSDF()

template<class T >
EBGeometry::CutSphereSDF< T >::CutSphereSDF ( const Vec3T< T > &  a_center,
const T  a_radius,
const T  a_height 
)
inline

Full constructor.

Parameters
[in]a_centerCenter of the sphere.
[in]a_radiusRadius, finite and positive.
[in]a_heightHeight of the cut plane above the center, between -a_radius and a_radius.

Member Function Documentation

◆ closestPart()

template<class T >
uint32_t EBGeometry::CutSphereSDF< T >::closestPart ( const Vec3T< T > &  a_point) const
inlinenoexcept

The part whose term decides the value at a point (see hasParts): 0 the sphere, 1 the flat cut face (its rim included).

Parameters
[in]a_pointPosition.
Returns
The part.

◆ computeBoundingVolume()

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

The shape's axis-aligned bounding box.

Returns
The bounding box.

◆ getCenter()

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

Get the center of the sphere.

Returns
m_center.

◆ getHeight()

template<class T >
const T & EBGeometry::CutSphereSDF< T >::getHeight ( ) const
inlinenoexcept

Get the height of the cut plane above the center.

Returns
m_height.

◆ getNumParts()

template<class T >
uint32_t EBGeometry::CutSphereSDF< T >::getNumParts ( ) const
inlinenoexcept

How many parts the shape has (see hasParts): 2.

Returns
The count.

◆ getRadius()

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

Get the radius.

Returns
m_radius.

◆ operator=() [1/2]

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

Copy assignment.

Returns
Reference to (*this).

◆ operator=() [2/2]

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

Move assignment.

Returns
Reference to (*this).

◆ signedDistance()

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

Signed distance function for the cut sphere.

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

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