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

Signed distance field for an axis-aligned box with rounded edges and corners. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Public Member Functions

 RoundedBoxSDF ()=default
 Default constructor. Constructs a rounded unit cube, [-0.5, 0.5]^3, centered at the origin, with rounding radius 0.1.
 
 RoundedBoxSDF (const Vec3T< T > &a_center, const Vec3T< T > &a_size, const T a_curvature) noexcept
 Full constructor.
 
 RoundedBoxSDF (const RoundedBoxSDF &)=default
 Copy constructor.
 
 RoundedBoxSDF (RoundedBoxSDF &&)=default
 Move constructor.
 
RoundedBoxSDF & operator= (const RoundedBoxSDF &)=default
 Copy assignment.
 
RoundedBoxSDF & operator= (RoundedBoxSDF &&)=default
 Move assignment.
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 Signed distance function for the rounded box.
 
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

T m_curvature = T(0.1)
 Corner rounding radius.
 
Vec3T< T > m_center = Vec3T<T>::zeros()
 Box center.
 
Vec3T< T > m_dimensions = Vec3T<T>(T(0.4), T(0.4), T(0.4))
 Half-extents of the inner box (= 0.5 * outer size - curvature).
 

Detailed Description

template<class T>
class EBGeometry::RoundedBoxSDF< T >

Signed distance field for an axis-aligned box with rounded edges and corners.

The constructor takes the box's center, its outer size (the full side lengths of the finished, rounded box, which is also its bounding box) and the rounding radius. The rounding is a sphere of that radius swept over an inner box whose half-extents, m_dimensions = 0.5 * size - curvature, are stored. The SDF is negative inside and positive outside.

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ RoundedBoxSDF()

template<class T >
EBGeometry::RoundedBoxSDF< T >::RoundedBoxSDF ( const Vec3T< T > &  a_center,
const Vec3T< T > &  a_size,
const T  a_curvature 
)
inlinenoexcept

Full constructor.

Parameters
[in]a_centerBox center.
[in]a_sizeOuter size: the full side lengths of the rounded box. Each must exceed twice the rounding radius.
[in]a_curvatureRounding radius of the edges and corners. Must be > 0.

Member Function Documentation

◆ computeBoundingVolume()

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

The shape's axis-aligned bounding box.

The center plus and minus half the outer size.

Returns
The bounding box.

◆ operator=() [1/2]

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

Copy assignment.

Returns
Reference to (*this).

◆ operator=() [2/2]

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

Move assignment.

Returns
Reference to (*this).

◆ signedDistance()

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

Signed distance function for the rounded box.

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

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