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

Signed distance field for a cylinder with rounded (toroidal) edges. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Public Member Functions

 RoundedCylinderSDF ()=default
 Default constructor. Constructs a rounded cylinder centered at the origin, axis along y, with outer radius 1, total height 1, and edge curvature 0.1.
 
 RoundedCylinderSDF (const Vec3T< T > &a_center, const T a_radius, const T a_curvature, const T a_height) noexcept
 Full constructor.
 
 RoundedCylinderSDF (const RoundedCylinderSDF &)=default
 Copy constructor.
 
 RoundedCylinderSDF (RoundedCylinderSDF &&)=default
 Move constructor.
 
RoundedCylinderSDF & operator= (const RoundedCylinderSDF &)=default
 Copy assignment.
 
RoundedCylinderSDF & operator= (RoundedCylinderSDF &&)=default
 Move assignment.
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 Signed distance function for the rounded cylinder.
 
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()
 Cylinder center.
 
T m_majorRadius = T(0.9)
 Inner cylinder radius (= outer radius - curvature).
 
T m_minorRadius = T(0.1)
 Edge rounding radius (= curvature).
 
T m_height = T(0.4)
 Inner half-height (= 0.5*height - curvature).
 

Detailed Description

template<class T>
class EBGeometry::RoundedCylinderSDF< T >

Signed distance field for a cylinder with rounded (toroidal) edges.

The cylinder is centered at m_center with its axis along y. The constructor takes the center, the outer radius, the edge curvature radius and the total height. The curvature rounds the sharp edges where the flat caps meet the cylindrical wall; the resulting shape is sometimes called a "stadium of revolution" or a "pill cylinder".

Internally three derived parameters are stored:

The outer bounding cylinder has radius m_majorRadius + m_minorRadius = a_radius and half-height m_height + m_minorRadius = 0.5 * a_height. For the geometry to be valid, a_curvature must be strictly less than a_radius and less than 0.5 * a_height.

The SDF is negative inside and positive outside. By default the cylinder has outer radius 1, height 1, and edge curvature 0.1 (stored as m_majorRadius=0.9, m_minorRadius=0.1, m_height=0.4).

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ RoundedCylinderSDF()

template<class T >
EBGeometry::RoundedCylinderSDF< T >::RoundedCylinderSDF ( const Vec3T< T > &  a_center,
const T  a_radius,
const T  a_curvature,
const T  a_height 
)
inlinenoexcept

Full constructor.

Parameters
[in]a_centerCylinder center.
[in]a_radiusOuter cylinder radius. Must be > 0 and > a_curvature.
[in]a_curvatureEdge rounding radius. Must be > 0 and satisfy a_curvature < a_radius and 2 * a_curvature < a_height.
[in]a_heightTotal cylinder height. Must be > 0 and > 2 * a_curvature.

Member Function Documentation

◆ computeBoundingVolume()

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

The shape's axis-aligned bounding box.

The outer radius either side of the axis in x and z, and half the height in y.

Returns
The bounding box.

◆ operator=() [1/2]

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

Copy assignment.

Returns
Reference to (*this).

◆ operator=() [2/2]

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

Move assignment.

Returns
Reference to (*this).

◆ signedDistance()

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

Signed distance function for the rounded cylinder.

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

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