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

Signed distance field for a superellipsoid (Barr's superquadric): from an ellipsoid to a rounded box, and toward a box or an octahedron, with its semi-axes along x, y and z. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Public Member Functions

 SuperellipsoidSDF ()=default
 Default constructor. Constructs a superellipsoid at the origin, with semi-axes 1 and both exponents 0.5.
 
 SuperellipsoidSDF (const Vec3T< T > &a_center, const Vec3T< T > &a_radii, const T a_exponent1, const T a_exponent2)
 Full constructor.
 
 SuperellipsoidSDF (const SuperellipsoidSDF &)=default
 Copy constructor.
 
 SuperellipsoidSDF (SuperellipsoidSDF &&)=default
 Move constructor.
 
SuperellipsoidSDF & operator= (const SuperellipsoidSDF &)=default
 Copy assignment.
 
SuperellipsoidSDF & operator= (SuperellipsoidSDF &&)=default
 Move assignment.
 
const Vec3T< T > & getCenter () const noexcept
 Get the center.
 
const Vec3T< T > & getRadii () const noexcept
 Get the semi-axes.
 
T gauge (const Vec3T< T > &a_point) const noexcept
 The superquadric's gauge at a point: below 1 inside, 1 on the surface, above 1 outside.
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 Signed distance function for the superellipsoid: a bound.
 
BoundingVolumes::AABBT< T > computeBoundingVolume () const noexcept
 The shape's axis-aligned bounding box: the center plus and minus the semi-axes.
 

Static Public Attributes

static constexpr DistanceQuality distanceQuality = DistanceQuality::Bound
 How far signedDistance() can be trusted as a distance: never more than the Euclidean distance.
 

Protected Attributes

Vec3T< T > m_center = Vec3T<T>::zeros()
 Center.
 
Vec3T< T > m_radii = Vec3T<T>::ones()
 Semi-axes.
 
T m_exponent1 = T(0.5)
 The exponent through the y axis.
 
T m_exponent2 = T(0.5)
 The exponent across it.
 
T m_scale = T(1)
 One over the gauge's largest slope.
 

Detailed Description

template<class T>
class EBGeometry::SuperellipsoidSDF< T >

Signed distance field for a superellipsoid (Barr's superquadric): from an ellipsoid to a rounded box, and toward a box or an octahedron, with its semi-axes along x, y and z.

The surface is (|x/a|^(2/e2) + |z/c|^(2/e2))^(e2/e1) + |y/b|^(2/e1) = 1 around the center: e1 shapes the cross-sections through the y axis, e2 those across it. Both exponents are in [0.1, 2], where the solid is convex: 1 gives an ellipsoid, toward 0.1 a box, 2 an octahedron (a double cone where only one is 2). The value is a bound: the superquadric's gauge (the left side above, to the power e1 / 2, which is a norm of the scaled point) less 1, divided by the gauge's largest slope, so that it never exceeds the distance. Far from the surface, and for unequal semi-axes, it is well below it. Turn it with Rotate. By default the superellipsoid is centered at the origin, with semi-axes 1 and both exponents 0.5.

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ SuperellipsoidSDF()

template<class T >
EBGeometry::SuperellipsoidSDF< T >::SuperellipsoidSDF ( const Vec3T< T > &  a_center,
const Vec3T< T > &  a_radii,
const T  a_exponent1,
const T  a_exponent2 
)
inline

Full constructor.

Parameters
[in]a_centerCenter.
[in]a_radiiSemi-axes along x, y and z, finite and positive.
[in]a_exponent1The exponent e1 of the cross-sections through the y axis, in [0.1, 2].
[in]a_exponent2The exponent e2 of the cross-sections across it, in [0.1, 2].

Member Function Documentation

◆ computeBoundingVolume()

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

The shape's axis-aligned bounding box: the center plus and minus the semi-axes.

Returns
The bounding box.

◆ gauge()

template<class T >
T EBGeometry::SuperellipsoidSDF< T >::gauge ( const Vec3T< T > &  a_point) const
inlinenoexcept

The superquadric's gauge at a point: below 1 inside, 1 on the surface, above 1 outside.

Out of line on a device (the superellipsoid's solver): inlined, it would be copied into every level of every tape kernel, whatever shapes the tape holds, which makes the device compile of every tape kernel much slower. A call costs little beside its powers.

Parameters
[in]a_pointPosition.
Returns
The gauge.

◆ getCenter()

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

Get the center.

Returns
m_center.

◆ getRadii()

template<class T >
const Vec3T< T > & EBGeometry::SuperellipsoidSDF< T >::getRadii ( ) const
inlinenoexcept

Get the semi-axes.

Returns
m_radii.

◆ operator=() [1/2]

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

Copy assignment.

Returns
Reference to (*this).

◆ operator=() [2/2]

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

Move assignment.

Returns
Reference to (*this).

◆ signedDistance()

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

Signed distance function for the superellipsoid: a bound.

Parameters
[in]a_pointPosition.
Returns
A signed value whose magnitude never exceeds the distance from a_point to the surface; negative inside.

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