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

Signed distance field for a capped cone (a frustum): a cone cut flat at both ends, between two end centers, with a radius at each. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Public Member Functions

 CappedConeSDF ()=default
 Default constructor. Constructs a frustum from (0,-0.5,0) with radius 1 to (0,0.5,0) with radius 0.5.
 
 CappedConeSDF (const Vec3T< T > &a_center1, const Vec3T< T > &a_center2, const T a_radius1, const T a_radius2)
 Full constructor.
 
 CappedConeSDF (const CappedConeSDF &)=default
 Copy constructor.
 
 CappedConeSDF (CappedConeSDF &&)=default
 Move constructor.
 
CappedConeSDF & operator= (const CappedConeSDF &)=default
 Copy assignment.
 
CappedConeSDF & operator= (CappedConeSDF &&)=default
 Move assignment.
 
const Vec3T< T > & getCenter1 () const noexcept
 Get the center of one end.
 
const Vec3T< T > & getCenter2 () const noexcept
 Get the center of the other end.
 
const T & getRadius1 () const noexcept
 Get the radius at m_center1.
 
const T & getRadius2 () const noexcept
 Get the radius at m_center2.
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 Signed distance function for the frustum.
 
uint32_t getNumParts () const noexcept
 How many parts the shape has (see hasParts): 3.
 
uint32_t closestPart (const Vec3T< T > &a_point) const noexcept
 The part whose term decides the value at a point (see hasParts): 0 the slanted side, 1 the end disc at the first center, 2 the one at the second.
 
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_center1 = Vec3T<T>(T(0), T(-0.5), T(0))
 Center of one end.
 
Vec3T< T > m_center2 = Vec3T<T>(T(0), T(0.5), T(0))
 Center of the other end.
 
Vec3T< T > m_axis = Vec3T<T>(T(0), T(1), T(0))
 Unit axis from m_center1 to m_center2.
 
T m_length = T(1)
 Distance between the end centers.
 
T m_radius1 = T(1)
 Radius at m_center1.
 
T m_radius2 = T(0.5)
 Radius at m_center2.
 

Detailed Description

template<class T>
class EBGeometry::CappedConeSDF< T >

Signed distance field for a capped cone (a frustum): a cone cut flat at both ends, between two end centers, with a radius at each.

One radius may be zero, which makes a cone with its tip at that end, pointing anywhere (ConeSDF points along y). The distance is exact (Quilez's capped cone): in the plane through the axis, the nearer of the distances to the end discs and to the slanted side. By default the frustum runs from (0,-0.5,0) with radius 1 to (0,0.5,0) with radius 0.5.

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ CappedConeSDF()

template<class T >
EBGeometry::CappedConeSDF< T >::CappedConeSDF ( const Vec3T< T > &  a_center1,
const Vec3T< T > &  a_center2,
const T  a_radius1,
const T  a_radius2 
)
inline

Full constructor.

Parameters
[in]a_center1Center of one end.
[in]a_center2Center of the other end; it must differ from a_center1.
[in]a_radius1Radius at a_center1, at least 0.
[in]a_radius2Radius at a_center2, at least 0; not both radii may be 0.

Member Function Documentation

◆ closestPart()

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

The part whose term decides the value at a point (see hasParts): 0 the slanted side, 1 the end disc at the first center, 2 the one at the second.

Parameters
[in]a_pointPosition.
Returns
The part.

◆ computeBoundingVolume()

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

The shape's axis-aligned bounding box.

The box around the two end discs: along axis i, each disc reaches its radius times sqrt(1 - axis_i^2) beyond its center.

Returns
The bounding box.

◆ getCenter1()

template<class T >
const Vec3T< T > & EBGeometry::CappedConeSDF< T >::getCenter1 ( ) const
inlinenoexcept

Get the center of one end.

Returns
m_center1.

◆ getCenter2()

template<class T >
const Vec3T< T > & EBGeometry::CappedConeSDF< T >::getCenter2 ( ) const
inlinenoexcept

Get the center of the other end.

Returns
m_center2.

◆ getNumParts()

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

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

Returns
The count.

◆ getRadius1()

template<class T >
const T & EBGeometry::CappedConeSDF< T >::getRadius1 ( ) const
inlinenoexcept

Get the radius at m_center1.

Returns
m_radius1.

◆ getRadius2()

template<class T >
const T & EBGeometry::CappedConeSDF< T >::getRadius2 ( ) const
inlinenoexcept

Get the radius at m_center2.

Returns
m_radius2.

◆ operator=() [1/2]

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

Move assignment.

Returns
Reference to (*this).

◆ operator=() [2/2]

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

Copy assignment.

Returns
Reference to (*this).

◆ signedDistance()

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

Signed distance function for the frustum.

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

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