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

Signed distance field for a finite, flat-capped cylinder. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Public Member Functions

 CylinderSDF ()=default
 Default constructor. Constructs a unit cylinder of radius 1 and height 1, centered at the origin with its axis along y (cap centers at (0,-0.5,0) and (0,0.5,0)).
 
 CylinderSDF (const Vec3T< T > &a_center1, const Vec3T< T > &a_center2, const T &a_radius) noexcept
 Full constructor.
 
 CylinderSDF (const CylinderSDF &)=default
 Copy constructor.
 
 CylinderSDF (CylinderSDF &&)=default
 Move constructor.
 
CylinderSDF & operator= (const CylinderSDF &)=default
 Copy assignment.
 
CylinderSDF & operator= (CylinderSDF &&)=default
 Move assignment.
 
const Vec3T< T > & getCenter1 () const noexcept
 Get one endpoint.
 
const Vec3T< T > & getCenter2 () const noexcept
 Get the other endpoint.
 
const T & getRadius () const noexcept
 Get radius.
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 Signed distance function for the 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_center1 = Vec3T<T>(T(0), T(-0.5), T(0))
 One endpoint (cap center).
 
Vec3T< T > m_center2 = Vec3T<T>(T(0), T(0.5), T(0))
 Other endpoint (cap center).
 
Vec3T< T > m_center = Vec3T<T>::zeros()
 Midpoint of m_center1 and m_center2.
 
Vec3T< T > m_axis = Vec3T<T>(T(0), T(1), T(0))
 Unit axis pointing from m_center1 to m_center2.
 
T m_length = T(1)
 Distance between the two endpoints.
 
T m_radius = T(1)
 Cylinder radius.
 

Detailed Description

template<class T>
class EBGeometry::CylinderSDF< T >

Signed distance field for a finite, flat-capped cylinder.

The cylinder is defined by two cap-center positions m_center1 and m_center2 and a radius m_radius. The cylinder axis is the unit vector from m_center1 to m_center2, and its height (distance between the two flat caps) equals distance(m_center1, m_center2). The SDF is negative inside the cylinder and positive outside. By default the cylinder has radius 1 and height 1, centered at the origin with its axis along y (cap centers at (0,-0.5,0) and (0,0.5,0)).

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ CylinderSDF()

template<class T >
EBGeometry::CylinderSDF< T >::CylinderSDF ( const Vec3T< T > &  a_center1,
const Vec3T< T > &  a_center2,
const T &  a_radius 
)
inlinenoexcept

Full constructor.

Parameters
[in]a_center1One endpoint (cap center).
[in]a_center2Other endpoint (cap center).
[in]a_radiusCylinder radius.

Member Function Documentation

◆ computeBoundingVolume()

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

The shape's axis-aligned bounding box.

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

Returns
The bounding box.

◆ getCenter1()

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

Get one endpoint.

Returns
m_center1

◆ getCenter2()

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

Get the other endpoint.

Returns
m_center2

◆ getRadius()

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

Get radius.

Returns
m_radius.

◆ operator=() [1/2]

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

Copy assignment.

Returns
Reference to (*this).

◆ operator=() [2/2]

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

Move assignment.

Returns
Reference to (*this).

◆ signedDistance()

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

Signed distance function for the cylinder.

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

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