EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Protected Member Functions | Protected Attributes | List of all members
EBGeometry::QuadricSDF< T > Class Template Reference

Signed distance field for a quadric of revolution around y: a hyperboloid of one sheet, a hyperboloid of two sheets, or a paraboloid. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Public Types

enum class  Kind : uint32_t { HyperboloidOneSheet , HyperboloidTwoSheets , Paraboloid }
 Which quadric, with r the distance from the axis and y the height above the center (or the tip). More...
 

Public Member Functions

 QuadricSDF ()=default
 Default constructor. Constructs the paraboloid with its tip at the origin, opening toward -y, with a tip radius of 1.
 
 QuadricSDF (const QuadricSDF &)=default
 Copy constructor.
 
 QuadricSDF (QuadricSDF &&)=default
 Move constructor.
 
QuadricSDF & operator= (const QuadricSDF &)=default
 Copy assignment.
 
QuadricSDF & operator= (QuadricSDF &&)=default
 Move assignment.
 
Kind getKind () const noexcept
 Get which quadric this is.
 
const Vec3T< T > & getCenter () const noexcept
 Get the center (a hyperboloid) or the tip (a paraboloid).
 
const T & getA () const noexcept
 Get the semi-axis across y, a, of a hyperboloid, or the tip radius of a paraboloid.
 
const T & getC () const noexcept
 Get the semi-axis along y, c, of a hyperboloid; for a paraboloid, its tip radius.
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 Signed distance function for the quadric.
 
BoundingVolumes::AABBT< T > computeBoundingVolume () const noexcept
 The shape's axis-aligned bounding box: unbounded, but above the tip of a paraboloid.
 

Static Public Member Functions

static QuadricSDF hyperboloid (const Vec3T< T > &a_center, const T a_waist, const T a_angle)
 A hyperboloid of one sheet around the y axis through the center: a waisted tower, unbounded along y.
 
static QuadricSDF hyperboloidTwoSheets (const Vec3T< T > &a_center, const T a_tipDistance, const T a_angle)
 A hyperboloid of two sheets around the y axis through the center: two cups, with their tips on the axis at the given distance above and below the center, each opening away from it, unbounded along y.
 
static QuadricSDF paraboloid (const Vec3T< T > &a_tip, const T a_tipRadius)
 A paraboloid around the y axis through its tip, opening toward -y, as the cones do, unbounded below.
 

Static Public Attributes

static constexpr DistanceQuality distanceQuality = DistanceQuality::Exact
 How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
 

Static Protected Member Functions

static QuadricSDF checked (const Vec3T< T > &a_center, const T a_size, const T a_angle, const char *a_who)
 Checks a factory's arguments, and makes a quadric at the center.
 

Protected Attributes

Kind m_kind = Kind::Paraboloid
 Which quadric.
 
Vec3T< T > m_center = Vec3T<T>::zeros()
 The center (a hyperboloid) or the tip (a paraboloid).
 
T m_a = T(1)
 The semi-axis across y, a (a hyperboloid), or the tip radius rho (a paraboloid).
 
T m_c = T(1)
 The semi-axis along y, c (a hyperboloid); the tip radius for a paraboloid.
 

Detailed Description

template<class T>
class EBGeometry::QuadricSDF< T >

Signed distance field for a quadric of revolution around y: a hyperboloid of one sheet, a hyperboloid of two sheets, or a paraboloid.

The three share their code: in the cross-section through the axis, the surface is a conic (a hyperbola or a parabola), and the distance to it is exact, from the closest point on the conic: the root of a scalar equation found by safeguarded Newton steps for a hyperbola, as for EllipsoidSDF, and a cubic solved in closed form for a parabola. Each is unbounded: cut it with an Intersection, or use it to cut. They are made by the static functions hyperboloid(), hyperboloidTwoSheets() and paraboloid(), which return a QuadricSDF; turn them with Rotate. By default the quadric is the paraboloid with its tip at the origin and a tip radius of 1.

Template Parameters
TFloating-point precision.

Member Enumeration Documentation

◆ Kind

template<class T >
enum class EBGeometry::QuadricSDF::Kind : uint32_t
strong

Which quadric, with r the distance from the axis and y the height above the center (or the tip).

Enumerator
HyperboloidOneSheet 

r^2 / a^2 - y^2 / c^2 <= 1: a waisted tower, one piece.

HyperboloidTwoSheets 

y^2 / c^2 - r^2 / a^2 >= 1: two cups facing away from each other.

Paraboloid 

y <= -r^2 / (2 rho): a cup opening toward -y from its tip.

Member Function Documentation

◆ checked()

template<class T >
static QuadricSDF EBGeometry::QuadricSDF< T >::checked ( const Vec3T< T > &  a_center,
const T  a_size,
const T  a_angle,
const char *  a_who 
)
inlinestaticprotected

Checks a factory's arguments, and makes a quadric at the center.

Parameters
[in]a_centerThe center or tip.
[in]a_sizeThe size, finite and positive.
[in]a_angleThe angle in degrees, in (0, 180).
[in]a_whoThe factory, for the messages.
Returns
A quadric with its center set.

◆ computeBoundingVolume()

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

The shape's axis-aligned bounding box: unbounded, but above the tip of a paraboloid.

Returns
The bounding box.

◆ getA()

template<class T >
const T & EBGeometry::QuadricSDF< T >::getA ( ) const
inlinenoexcept

Get the semi-axis across y, a, of a hyperboloid, or the tip radius of a paraboloid.

Returns
m_a.

◆ getC()

template<class T >
const T & EBGeometry::QuadricSDF< T >::getC ( ) const
inlinenoexcept

Get the semi-axis along y, c, of a hyperboloid; for a paraboloid, its tip radius.

Returns
m_c.

◆ getCenter()

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

Get the center (a hyperboloid) or the tip (a paraboloid).

Returns
m_center.

◆ getKind()

template<class T >
Kind EBGeometry::QuadricSDF< T >::getKind ( ) const
inlinenoexcept

Get which quadric this is.

Returns
m_kind.

◆ hyperboloid()

template<class T >
static QuadricSDF EBGeometry::QuadricSDF< T >::hyperboloid ( const Vec3T< T > &  a_center,
const T  a_waist,
const T  a_angle 
)
inlinestatic

A hyperboloid of one sheet around the y axis through the center: a waisted tower, unbounded along y.

Parameters
[in]a_centerThe center, on the axis at the narrowest point.
[in]a_waistThe radius at the narrowest point, finite and positive.
[in]a_angleThe full opening angle of the asymptotic cone, in degrees, in (0, 180): the hyperboloid widens toward that cone far from the center.
Returns
The hyperboloid.

◆ hyperboloidTwoSheets()

template<class T >
static QuadricSDF EBGeometry::QuadricSDF< T >::hyperboloidTwoSheets ( const Vec3T< T > &  a_center,
const T  a_tipDistance,
const T  a_angle 
)
inlinestatic

A hyperboloid of two sheets around the y axis through the center: two cups, with their tips on the axis at the given distance above and below the center, each opening away from it, unbounded along y.

The solid is inside the two cups. The radius of curvature at a tip is a_tipDistance tan^2(angle / 2).

Parameters
[in]a_centerThe center, midway between the tips.
[in]a_tipDistanceThe distance from the center to each tip, finite and positive.
[in]a_angleThe full opening angle of the asymptotic cone, in degrees, in (0, 180).
Returns
The hyperboloid.

◆ operator=() [1/2]

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

Copy assignment.

Returns
Reference to (*this).

◆ operator=() [2/2]

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

Move assignment.

Returns
Reference to (*this).

◆ paraboloid()

template<class T >
static QuadricSDF EBGeometry::QuadricSDF< T >::paraboloid ( const Vec3T< T > &  a_tip,
const T  a_tipRadius 
)
inlinestatic

A paraboloid around the y axis through its tip, opening toward -y, as the cones do, unbounded below.

Parameters
[in]a_tipThe tip.
[in]a_tipRadiusThe radius of curvature at the tip, finite and positive: the paraboloid is y = -r^2 / (2 a_tipRadius) below the tip.
Returns
The paraboloid.

◆ signedDistance()

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

Signed distance function for the quadric.

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: