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

Signed distance field for a round cone: two spheres, of different radii, and the cone tangent to both, like a capsule with a radius at each end. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Public Member Functions

 RoundConeSDF ()=default
 Default constructor. Constructs a round cone from (0,-0.5,0) with radius 0.5 to (0,0.5,0) with radius 0.25.
 
 RoundConeSDF (const Vec3T< T > &a_center1, const Vec3T< T > &a_center2, const T a_radius1, const T a_radius2)
 Full constructor.
 
 RoundConeSDF (const RoundConeSDF &)=default
 Copy constructor.
 
 RoundConeSDF (RoundConeSDF &&)=default
 Move constructor.
 
RoundConeSDF & operator= (const RoundConeSDF &)=default
 Copy assignment.
 
RoundConeSDF & operator= (RoundConeSDF &&)=default
 Move assignment.
 
const Vec3T< T > & getCenter1 () const noexcept
 Get the center of one sphere.
 
const Vec3T< T > & getCenter2 () const noexcept
 Get the center of the other sphere.
 
const T & getRadius1 () const noexcept
 Get the radius of the sphere at m_center1.
 
const T & getRadius2 () const noexcept
 Get the radius of the sphere at m_center2.
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 Signed distance function for the round cone.
 
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 sphere at the first center, 2 the one at the second.
 
BoundingVolumes::AABBT< T > computeBoundingVolume () const noexcept
 The shape's axis-aligned bounding box: the box around the two spheres.
 

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 sphere.
 
Vec3T< T > m_center2 = Vec3T<T>(T(0), T(0.5), T(0))
 Center of the other sphere.
 
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 centers.
 
T m_radius1 = T(0.5)
 Radius of the sphere at m_center1.
 
T m_radius2 = T(0.25)
 Radius of the sphere at m_center2.
 
T m_sin = T(0.25)
 Sine of the cone's half-angle, (m_radius1 - m_radius2) / m_length.
 
T m_cos = T(0.96824583655185422)
 Cosine of the cone's half-angle.
 

Detailed Description

template<class T>
class EBGeometry::RoundConeSDF< T >

Signed distance field for a round cone: two spheres, of different radii, and the cone tangent to both, like a capsule with a radius at each end.

The distance is exact (Quilez's round cone). The spheres are centered at the two end centers; the smaller one must not lie inside the larger, so the difference of the radii must be less than the distance between the centers. By default the round cone runs from (0,-0.5,0) with radius 0.5 to (0,0.5,0) with radius 0.25.

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ RoundConeSDF()

template<class T >
EBGeometry::RoundConeSDF< T >::RoundConeSDF ( 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 sphere.
[in]a_center2Center of the other sphere.
[in]a_radius1Radius of the sphere at a_center1, at least 0.
[in]a_radius2Radius of the sphere at a_center2, at least 0; not both radii may be 0, and their difference must be less than the distance between the centers.

Member Function Documentation

◆ closestPart()

template<class T >
uint32_t EBGeometry::RoundConeSDF< 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 sphere 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::RoundConeSDF< T >::computeBoundingVolume ( ) const
inlinenoexcept

The shape's axis-aligned bounding box: the box around the two spheres.

Returns
The bounding box.

◆ getCenter1()

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

Get the center of one sphere.

Returns
m_center1.

◆ getCenter2()

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

Get the center of the other sphere.

Returns
m_center2.

◆ getNumParts()

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

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

Returns
The count.

◆ getRadius1()

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

Get the radius of the sphere at m_center1.

Returns
m_radius1.

◆ getRadius2()

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

Get the radius of the sphere at m_center2.

Returns
m_radius2.

◆ operator=() [1/2]

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

Copy assignment.

Returns
Reference to (*this).

◆ operator=() [2/2]

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

Move assignment.

Returns
Reference to (*this).

◆ signedDistance()

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

Signed distance function for the round cone.

In the plane through the axis, the point is nearest the first sphere, the second sphere or the tangent line between them, as its position along the line's direction says.

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

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