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

Signed distance field for a finite cone. More...

#include <EBGeometry_AnalyticDistanceFunctions.hpp>

Public Member Functions

 ConeSDF ()=default
 Default constructor. Constructs a finite cone with its tip at the origin, height 1, and a 45-degree opening angle, body extending in the -y direction.
 
 ConeSDF (const Vec3T< T > &a_tip, const T &a_height, const T &a_angle) noexcept
 Full constructor.
 
 ConeSDF (const ConeSDF &)=default
 Copy constructor.
 
 ConeSDF (ConeSDF &&)=default
 Move constructor.
 
ConeSDF & operator= (const ConeSDF &)=default
 Copy assignment.
 
ConeSDF & operator= (ConeSDF &&)=default
 Move assignment.
 
T signedDistance (const Vec3T< T > &a_point) const noexcept
 Signed distance function for the finite cone.
 
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_tip = Vec3T<T>::zeros()
 Tip position.
 
Vec2T< T > m_c = Vec2T<T>(std::sin(pi<T> / T(8)), std::cos(pi<T> / T(8)))
 (sin, cos) of the half opening-angle. Default: 45° full angle → half-angle 22.5°.
 
T m_height = T(1)
 Cone height (tip to base).
 

Detailed Description

template<class T>
class EBGeometry::ConeSDF< T >

Signed distance field for a finite cone.

The cone tip is at m_tip and the body opens in the -y direction, so the base disc lies at m_tip + (0, -m_height, 0). The full opening angle a_angle is the tip-to-tip apex angle; internally the half-angle is encoded as m_c = (std::sin(half_angle), std::cos(half_angle)). The base radius equals m_height * std::tan(half_angle) = m_height * m_c[0] / m_c[1].

The SDF is negative inside the solid cone (including the base disc) and positive outside. By default the tip is at the origin, the height is 1, and the full opening angle is 45°, giving a base radius of std::tan(22.5°) ≈ 0.414.

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ ConeSDF()

template<class T >
EBGeometry::ConeSDF< T >::ConeSDF ( const Vec3T< T > &  a_tip,
const T &  a_height,
const T &  a_angle 
)
inlinenoexcept

Full constructor.

Parameters
[in]a_tipCone tip position.
[in]a_heightCone height (tip to base).
[in]a_angleFull opening angle in degrees (must be in (0°, 180°)).

Member Function Documentation

◆ computeBoundingVolume()

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

The shape's axis-aligned bounding box.

In y, from the base disc a height below the tip up to the tip; in x and z, the base radius (the height times the tangent of the half-angle) either side of the axis.

Returns
The bounding box.

◆ operator=() [1/2]

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

Move assignment.

Returns
Reference to (*this).

◆ operator=() [2/2]

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

Copy assignment.

Returns
Reference to (*this).

◆ signedDistance()

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

Signed distance function for the finite cone.

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

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