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

Signed distance field for a capped torus: an arc of a torus with flat ends, such as a pipe elbow. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Public Member Functions

 CappedTorusSDF ()=default
 Default constructor. Constructs an arc of 90 degrees, centered at the origin, with major radius 1 and minor radius 0.25.
 
 CappedTorusSDF (const Vec3T< T > &a_center, const T a_majorRadius, const T a_minorRadius, const T a_angle)
 Full constructor.
 
 CappedTorusSDF (const CappedTorusSDF &)=default
 Copy constructor.
 
 CappedTorusSDF (CappedTorusSDF &&)=default
 Move constructor.
 
CappedTorusSDF & operator= (const CappedTorusSDF &)=default
 Copy assignment.
 
CappedTorusSDF & operator= (CappedTorusSDF &&)=default
 Move assignment.
 
const Vec3T< T > & getCenter () const noexcept
 Get the center.
 
const T & getMajorRadius () const noexcept
 Get the major (ring) radius.
 
const T & getMinorRadius () const noexcept
 Get the minor (tube) radius.
 
const T & getAngle () const noexcept
 Get the angle the arc sweeps, in degrees.
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 Signed distance function for the capped torus.
 
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 tube, 1 the end disc at the positive angle, 2 the one at the negative; a whole torus is all tube.
 
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()
 Center of the torus.
 
T m_majorRadius = T(1)
 Major (ring) radius.
 
T m_minorRadius = T(0.25)
 Minor (tube) radius.
 
T m_angle = T(90)
 The angle the arc sweeps, in degrees.
 
T m_cos = T(0.70710678118654752)
 Cosine of half the arc's angle.
 
T m_sin = T(0.70710678118654752)
 Sine of half the arc's angle.
 
bool m_whole = false
 Whether the arc is the whole torus, with no ends.
 

Detailed Description

template<class T>
class EBGeometry::CappedTorusSDF< T >

Signed distance field for a capped torus: an arc of a torus with flat ends, such as a pipe elbow.

The torus' ring lies in the xz-plane around an axis along y through the center, like TorusSDF's. The arc sweeps the given angle, symmetric about +x, and each end is the disc where the tube is cut by the half-plane through the axis at that angle. The distance is exact. Inside the arc's angle, the nearest point of the solid is that of the whole torus, unless the point is inside and an end disc is nearer. Outside the angle, it is on an end disc: any point of the solid turned around the axis toward the point stays in the solid, and is nearer, until it reaches an end. An angle of 360 degrees is the whole torus. By default the arc sweeps 90 degrees, with major radius 1 and minor radius 0.25.

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ CappedTorusSDF()

template<class T >
EBGeometry::CappedTorusSDF< T >::CappedTorusSDF ( const Vec3T< T > &  a_center,
const T  a_majorRadius,
const T  a_minorRadius,
const T  a_angle 
)
inline

Full constructor.

Parameters
[in]a_centerCenter of the torus.
[in]a_majorRadiusMajor (ring) radius.
[in]a_minorRadiusMinor (tube) radius, positive and less than the major radius.
[in]a_angleThe angle the arc sweeps, in degrees, in (0, 360].

Member Function Documentation

◆ closestPart()

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

The part whose term decides the value at a point (see hasParts): 0 the tube, 1 the end disc at the positive angle, 2 the one at the negative; a whole torus is all tube.

Parameters
[in]a_pointPosition.
Returns
The part.

◆ computeBoundingVolume()

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

The shape's axis-aligned bounding box.

Every point of the solid lies in a half-plane through the axis within the arc, at a distance from the axis between the major radius less the minor one and their sum.

Returns
The bounding box.

◆ getAngle()

template<class T >
const T & EBGeometry::CappedTorusSDF< T >::getAngle ( ) const
inlinenoexcept

Get the angle the arc sweeps, in degrees.

Returns
m_angle.

◆ getCenter()

template<class T >
const Vec3T< T > & EBGeometry::CappedTorusSDF< T >::getCenter ( ) const
inlinenoexcept

Get the center.

Returns
m_center.

◆ getMajorRadius()

template<class T >
const T & EBGeometry::CappedTorusSDF< T >::getMajorRadius ( ) const
inlinenoexcept

Get the major (ring) radius.

Returns
m_majorRadius.

◆ getMinorRadius()

template<class T >
const T & EBGeometry::CappedTorusSDF< T >::getMinorRadius ( ) const
inlinenoexcept

Get the minor (tube) radius.

Returns
m_minorRadius.

◆ getNumParts()

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

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

Returns
The count.

◆ operator=() [1/2]

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

Move assignment.

Returns
Reference to (*this).

◆ operator=() [2/2]

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

Copy assignment.

Returns
Reference to (*this).

◆ signedDistance()

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

Signed distance function for the capped torus.

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

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