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

Signed distance field for a capsule (pill shape): a cylinder capped with hemispheres. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Inheritance diagram for EBGeometry::CapsuleSDF< T >:
Inheritance graph
[legend]
Collaboration diagram for EBGeometry::CapsuleSDF< T >:
Collaboration graph
[legend]

Public Member Functions

 CapsuleSDF ()=default
 Default constructor. Constructs a capsule with tips at (0,-1,0) and (0,1,0), radius 0.5.
 
 CapsuleSDF (const Vec3T< T > &a_tip1, const Vec3T< T > &a_tip2, const T &a_radius) noexcept
 Full constructor.
 
 CapsuleSDF (const CapsuleSDF &)=default
 Copy constructor.
 
 CapsuleSDF (CapsuleSDF &&)=default
 Move constructor.
 
CapsuleSDFoperator= (const CapsuleSDF &)=default
 Copy assignment.
 
CapsuleSDFoperator= (CapsuleSDF &&)=default
 Move assignment.
 
 ~CapsuleSDF () override=default
 Destructor.
 
signedDistance (const Vec3T< T > &a_point) const noexcept override
 Signed distance function for the capsule.
 
- Public Member Functions inherited from EBGeometry::SignedDistanceFunction< T >
 SignedDistanceFunction ()=default
 Default constructor.
 
 ~SignedDistanceFunction () override=default
 Destructor.
 
value (const Vec3T< T > &a_point) const noexcept final
 Implementation of ImplicitFunction::value; delegates to signedDistance().
 
virtual Vec3T< T > normal (const Vec3T< T > &a_point, const T &a_delta) const noexcept
 Compute the outward normal using central finite differences.
 
- Public Member Functions inherited from EBGeometry::ImplicitFunction< T >
 ImplicitFunction ()=default
 Default constructor.
 
virtual ~ImplicitFunction ()=default
 Default destructor.
 
operator() (const Vec3T< T > &a_point) const noexcept
 Call operator — alternative signature for the value function.
 
template<class BV >
BV approximateBoundingVolumeOctree (const Vec3T< T > &a_initialLowCorner, const Vec3T< T > &a_initialHighCorner, const unsigned int a_maxTreeDepth, const T &a_safety=0.0) const
 Compute an approximation to the bounding volume for the implicit surface using octree subdivision.
 

Protected Attributes

Vec3T< T > m_center1 = Vec3T<T>(T(0), T(-0.5), T(0))
 Center of one hemispherical cap.
 
Vec3T< T > m_center2 = Vec3T<T>(T(0), T(0.5), T(0))
 Center of the other hemispherical cap.
 
m_radius = T(0.5)
 Capsule radius.
 

Detailed Description

template<class T>
class EBGeometry::CapsuleSDF< T >

Signed distance field for a capsule (pill shape): a cylinder capped with hemispheres.

A capsule is defined by two outer tip positions and a radius. The tips are the outermost points of each hemispherical endcap. The total length (tip to tip) equals distance(tip1, tip2). The internal cylindrical body has length distance(tip1, tip2) - 2 * radius, and the two hemispheres each contribute a further radius to each end.

Internally the hemisphere centres are stored as m_center1 and m_center2 (inset from the tips by radius along the capsule axis). These are not the same as the tip positions passed to the constructor.

The SDF is negative inside the capsule and positive outside. By default the capsule is centred at the origin, aligned along y, with tips at (0,-1,0) and (0,1,0) and radius 0.5, giving a total height of 2 and a cylindrical body of length 1.

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ CapsuleSDF() [1/2]

template<class T >
EBGeometry::CapsuleSDF< T >::CapsuleSDF ( )
default

Default constructor. Constructs a capsule with tips at (0,-1,0) and (0,1,0), radius 0.5.

Total height = 2, cylindrical body length = 1, aligned along y, centred at origin. The stored hemisphere centres are at (0,-0.5,0) and (0,0.5,0).

◆ CapsuleSDF() [2/2]

template<class T >
EBGeometry::CapsuleSDF< T >::CapsuleSDF ( const Vec3T< T > &  a_tip1,
const Vec3T< T > &  a_tip2,
const T &  a_radius 
)
inlinenoexcept

Full constructor.

The hemisphere centres stored internally are derived from the tips: m_center1 = a_tip1 + a_radius * axis and m_center2 = a_tip2 - a_radius * axis, where axis = (a_tip2 - a_tip1) / distance(a_tip1, a_tip2). The cylindrical body length is distance(a_tip1, a_tip2) - 2 * a_radius; for a valid non-degenerate shape this must be positive, i.e. distance(a_tip1, a_tip2) > 2 * a_radius.

Parameters
[in]a_tip1Outer tip of one hemispherical cap (outermost point in that direction).
[in]a_tip2Outer tip of the other hemispherical cap.
[in]a_radiusCapsule radius (applied to both the tube and the hemispherical caps).

Member Function Documentation

◆ operator=() [1/2]

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

Move assignment.

Returns
Reference to (*this).

◆ operator=() [2/2]

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

Copy assignment.

Returns
Reference to (*this).

◆ signedDistance()

template<class T >
T EBGeometry::CapsuleSDF< T >::signedDistance ( const Vec3T< T > &  a_point) const
inlineoverridevirtualnoexcept

Signed distance function for the capsule.

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

Implements EBGeometry::SignedDistanceFunction< T >.


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