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

Signed distance field for a solid angle: the part of a ball inside a cone from its center, around +y. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Public Member Functions

 SolidAngleSDF ()=default
 Default constructor. Constructs a solid angle at the origin, with radius 1 and an opening of 60 degrees.
 
 SolidAngleSDF (const Vec3T< T > &a_center, const T a_radius, const T a_angle)
 Full constructor.
 
 SolidAngleSDF (const SolidAngleSDF &)=default
 Copy constructor.
 
 SolidAngleSDF (SolidAngleSDF &&)=default
 Move constructor.
 
SolidAngleSDF & operator= (const SolidAngleSDF &)=default
 Copy assignment.
 
SolidAngleSDF & operator= (SolidAngleSDF &&)=default
 Move assignment.
 
const Vec3T< T > & getCenter () const noexcept
 Get the center.
 
const T & getRadius () const noexcept
 Get the radius.
 
const T & getAngle () const noexcept
 Get the full opening angle, in degrees.
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 Signed distance function for the solid angle.
 
uint32_t getNumParts () const noexcept
 How many parts the shape has (see hasParts): 2, the spherical cap (0) and the cone's side (1).
 
uint32_t closestPart (const Vec3T< T > &a_point) const noexcept
 The part whose term decides the value at a point (see hasParts): 0 the cap, 1 the cone's side.
 
BoundingVolumes::AABBT< T > computeBoundingVolume () const noexcept
 The shape's axis-aligned bounding box: that of the ball.
 

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 Member Functions

void terms (const Vec3T< T > &a_point, T &a_sphere, T &a_side) const noexcept
 The two terms of the distance: to the sphere, and the signed distance to the cone's side segment.
 

Protected Attributes

Vec3T< T > m_center = Vec3T<T>::zeros()
 Center.
 
T m_radius = T(1)
 Radius.
 
T m_angle = T(60)
 Full opening angle, in degrees.
 
T m_sin = T(0.5)
 Sine of half the opening angle.
 
T m_cos = T(0.86602540378443865)
 Cosine of half the opening angle.
 

Detailed Description

template<class T>
class EBGeometry::SolidAngleSDF< T >

Signed distance field for a solid angle: the part of a ball inside a cone from its center, around +y.

The cone has its tip at the ball's center and opens toward +y with the given full angle; above 180 degrees the solid is the ball less a cone opening toward -y. The distance is exact (Quilez's solid angle): in the cross-section through the axis, that to the arc or to the cone's side line. Turn it with Rotate. By default the solid angle is centered at the origin, with radius 1 and an opening of 60 degrees.

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ SolidAngleSDF()

template<class T >
EBGeometry::SolidAngleSDF< T >::SolidAngleSDF ( const Vec3T< T > &  a_center,
const T  a_radius,
const T  a_angle 
)
inline

Full constructor.

Parameters
[in]a_centerThe center of the ball, the cone's tip.
[in]a_radiusThe radius, finite and positive.
[in]a_angleThe cone's full opening angle, in degrees, in (0, 360).

Member Function Documentation

◆ closestPart()

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

The part whose term decides the value at a point (see hasParts): 0 the cap, 1 the cone's side.

Parameters
[in]a_pointPosition.
Returns
The part.

◆ computeBoundingVolume()

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

The shape's axis-aligned bounding box: that of the ball.

Returns
The bounding box.

◆ getAngle()

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

Get the full opening angle, in degrees.

Returns
m_angle.

◆ getCenter()

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

Get the center.

Returns
m_center.

◆ getNumParts()

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

How many parts the shape has (see hasParts): 2, the spherical cap (0) and the cone's side (1).

Returns
The count.

◆ getRadius()

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

Get the radius.

Returns
m_radius.

◆ operator=() [1/2]

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

Copy assignment.

Returns
Reference to (*this).

◆ operator=() [2/2]

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

Move assignment.

Returns
Reference to (*this).

◆ signedDistance()

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

Signed distance function for the solid angle.

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

◆ terms()

template<class T >
void EBGeometry::SolidAngleSDF< T >::terms ( const Vec3T< T > &  a_point,
T &  a_sphere,
T &  a_side 
) const
inlineprotectednoexcept

The two terms of the distance: to the sphere, and the signed distance to the cone's side segment.

Parameters
[in]a_pointPosition.
[out]a_sphereThe signed distance to the sphere.
[out]a_sideThe distance to the side segment, from the center to the rim, negative inside the cone.

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