EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Classes | Namespaces | Functions
EBGeometry_AnalyticDistanceFunctions.hpp File Reference

File containing various analytic signed distance fields. More...

#include <algorithm>
#include <cmath>
#include <cstddef>
#include <random>
#include <type_traits>
#include "EBGeometry_Array.hpp"
#include "EBGeometry_BoundingVolumes.hpp"
#include "EBGeometry_Constants.hpp"
#include "EBGeometry_DistanceQuality.hpp"
#include "EBGeometry_GPU.hpp"
#include "EBGeometry_Macros.hpp"
#include "EBGeometry_Math.hpp"
#include "EBGeometry_Vec.hpp"
#include "EBGeometry_AnalyticRayForms.hpp"
Include dependency graph for EBGeometry_AnalyticDistanceFunctions.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  EBGeometry::PlaneSDF< T >
 Signed distance function for a plane. More...
 
class  EBGeometry::SphereSDF< T >
 Signed distance field for a sphere. More...
 
class  EBGeometry::BoxSDF< T >
 Signed distance field for an axis-aligned box (AABB). More...
 
class  EBGeometry::TorusSDF< T >
 Signed distance field for a torus. More...
 
class  EBGeometry::CylinderSDF< T >
 Signed distance field for a finite, flat-capped cylinder. More...
 
class  EBGeometry::InfiniteCylinderSDF< T >
 Signed distance field for an infinitely long cylinder. More...
 
class  EBGeometry::CapsuleSDF< T >
 Signed distance field for a capsule (pill shape): a cylinder capped with hemispheres. More...
 
class  EBGeometry::InfiniteConeSDF< T >
 Signed distance field for an infinite cone. More...
 
class  EBGeometry::ConeSDF< T >
 Signed distance field for a finite cone. More...
 
class  EBGeometry::RoundedBoxSDF< T >
 Signed distance field for an axis-aligned box with rounded edges and corners. More...
 
class  EBGeometry::PerlinSDF< T >
 Ken Perlin's gradient-noise implicit function. More...
 
class  EBGeometry::RoundedCylinderSDF< T >
 Signed distance field for a cylinder with rounded (toroidal) edges. More...
 
struct  EBGeometry::AnalyticDetail::AxialCoordinates< T >
 A point's coordinates around an axis: its distance from the axis line, and its position along it. More...
 
class  EBGeometry::EllipsoidSDF< T >
 Signed distance field for an ellipsoid with its semi-axes along x, y and z. More...
 
class  EBGeometry::CappedConeSDF< T >
 Signed distance field for a capped cone (a frustum): a cone cut flat at both ends, between two end centers, with a radius at each. More...
 
class  EBGeometry::RoundConeSDF< T >
 Signed distance field for a round cone: two spheres, of different radii, and the cone tangent to both, like a capsule with a radius at each end. More...
 
class  EBGeometry::PolygonPrismSDF< T >
 Signed distance field for a regular prism: a regular polygon of n sides, extruded between two end centers. More...
 
class  EBGeometry::TubeSDF< T >
 Signed distance field for a tube (a pipe): the space between two coaxial cylinders, cut flat at two end centers. More...
 
class  EBGeometry::CappedTorusSDF< T >
 Signed distance field for a capped torus: an arc of a torus with flat ends, such as a pipe elbow. More...
 
class  EBGeometry::CutSphereSDF< T >
 Signed distance field for a cut sphere: the part of a sphere above a horizontal plane, a dome or a sphere with a flat bottom. More...
 
class  EBGeometry::CutHollowSphereSDF< T >
 Signed distance field for a cut hollow sphere: a spherical shell of some thickness, the part above a horizontal plane, such as a dome or a radome. More...
 
class  EBGeometry::WedgeSDF< T >
 Signed distance field for an infinite wedge: a knife edge. More...
 

Namespaces

namespace  EBGeometry
 Namespace containing all of EBGeometry's functionality.
 

Functions

template<class T >
AxialCoordinates< T > EBGeometry::AnalyticDetail::axialCoordinates (const Vec3T< T > &a_point, const Vec3T< T > &a_start, const Vec3T< T > &a_axis) noexcept
 A point's coordinates around the axis that starts at a_start and runs along the unit a_axis.
 
template<class T >
T EBGeometry::AnalyticDetail::extrusion (const T a_profile, const T a_slab) noexcept
 The signed distance to a 2D profile extruded between two parallel planes: the exact distance, from the profile's signed distance and the signed distance to the slab between the planes.
 
template<class T >
bool EBGeometry::AnalyticDetail::isFinite (const Vec3T< T > &a_point) noexcept
 Checks that a point given to a constructor is finite.
 
template<class T , size_t N>
T EBGeometry::AnalyticDetail::ellipsoidRoot (const T(&a_r)[N], const T(&a_n)[N], const T a_lo, const T a_hi) noexcept
 The root of Eberly's function F(s) = sum_i (a_n[i] / (s + a_r[i]))^2 - 1 over the components with a_n[i] > 0, for the closest point on an ellipse or ellipsoid scaled so that its smallest semi-axis is 1.
 
template<class T >
T EBGeometry::AnalyticDetail::ellipseDistance (const T a_e0, const T a_e1, const T a_y0, const T a_y1) noexcept
 The distance from a point to an ellipse with semi-axes a_e0 >= a_e1 > 0, for a point with coordinates a_y0, a_y1 >= 0 (Eberly's algorithm).
 
template<class T >
T EBGeometry::AnalyticDetail::ellipsoidDistance (const T a_e0, const T a_e1, const T a_e2, const T a_y0, const T a_y1, const T a_y2) noexcept
 The distance from a point to an ellipsoid with semi-axes a_e0 >= a_e1 >= a_e2 > 0, for a point with coordinates a_y0, a_y1, a_y2 >= 0 (Eberly's algorithm).
 

Detailed Description

File containing various analytic signed distance fields.

Every shape here is a plain, trivially copyable value type with no base class and no virtual functions. Its signedDistance() and accessors are callable on the host and on a device, so a shape can be copied into a kernel by value and evaluated there. Constructors run on the host. Every shape is a shape in the sense of isShape, so it can be composed with the expression builder (Union, Translate, ...; see EBGeometry_Expr.hpp) and compiled into a Tape.

Conventions shared by every shape:

Function Documentation

◆ axialCoordinates()

template<class T >
AxialCoordinates< T > EBGeometry::AnalyticDetail::axialCoordinates ( const Vec3T< T > &  a_point,
const Vec3T< T > &  a_start,
const Vec3T< T > &  a_axis 
)
inlineprotectednoexcept

A point's coordinates around the axis that starts at a_start and runs along the unit a_axis.

Internal helper; not part of the public API. The radial distance is the length of the point's offset across the axis, not sqrt(|p|^2 - axial^2), which cancels near the axis.

Template Parameters
TFloating-point precision.
Parameters
[in]a_pointPoint.
[in]a_startStart of the axis.
[in]a_axisUnit axis.
Returns
The coordinates.

◆ ellipseDistance()

template<class T >
T EBGeometry::AnalyticDetail::ellipseDistance ( const T  a_e0,
const T  a_e1,
const T  a_y0,
const T  a_y1 
)
inlineprotectednoexcept

The distance from a point to an ellipse with semi-axes a_e0 >= a_e1 > 0, for a point with coordinates a_y0, a_y1 >= 0 (Eberly's algorithm).

Internal helper; not part of the public API.

Template Parameters
TFloating-point precision.
Parameters
[in]a_e0Larger semi-axis.
[in]a_e1Smaller semi-axis.
[in]a_y0Coordinate along a_e0.
[in]a_y1Coordinate along a_e1.
Returns
The unsigned distance to the ellipse curve.

◆ ellipsoidDistance()

template<class T >
T EBGeometry::AnalyticDetail::ellipsoidDistance ( const T  a_e0,
const T  a_e1,
const T  a_e2,
const T  a_y0,
const T  a_y1,
const T  a_y2 
)
inlineprotectednoexcept

The distance from a point to an ellipsoid with semi-axes a_e0 >= a_e1 >= a_e2 > 0, for a point with coordinates a_y0, a_y1, a_y2 >= 0 (Eberly's algorithm).

Internal helper; not part of the public API. A point on a coordinate plane is handled by the planar cases of the algorithm: its closest point is on the ellipse in that plane, or, for a point inside near the plane of the two larger axes, off it.

Template Parameters
TFloating-point precision.
Parameters
[in]a_e0Largest semi-axis.
[in]a_e1Middle semi-axis.
[in]a_e2Smallest semi-axis.
[in]a_y0Coordinate along a_e0.
[in]a_y1Coordinate along a_e1.
[in]a_y2Coordinate along a_e2.
Returns
The unsigned distance to the ellipsoid surface.

◆ ellipsoidRoot()

template<class T , size_t N>
T EBGeometry::AnalyticDetail::ellipsoidRoot ( const T(&)  a_r[N],
const T(&)  a_n[N],
const T  a_lo,
const T  a_hi 
)
inlineprotectednoexcept

The root of Eberly's function F(s) = sum_i (a_n[i] / (s + a_r[i]))^2 - 1 over the components with a_n[i] > 0, for the closest point on an ellipse or ellipsoid scaled so that its smallest semi-axis is 1.

Internal helper; not part of the public API. F is decreasing and convex for s > -min(a_r), and its root lies in [a_lo, a_hi], where F(a_lo) >= 0 (Eberly, "Distance from a point to an ellipse, an ellipsoid, or a hyperellipsoid", 2013). Newton's method from a_lo therefore increases monotonically to the root and never overshoots it; a step that would leave the bracket (by rounding) is replaced by bisection. It stops when F is no longer positive, when a step makes no progress or changes s by no more than a few units in the last place, or after MaxIterations.

Template Parameters
TFloating-point precision.
NNumber of components (2 or 3).
Parameters
[in]a_rThe squared ratios of the semi-axes to the smallest one.
[in]a_nThe scaled coordinates of the point, a_r[i] times the point's coordinate over the semi-axis.
[in]a_loLower end of the bracket, with F(a_lo) >= 0.
[in]a_hiUpper end of the bracket, with F(a_hi) <= 0.
Returns
The root.

◆ extrusion()

template<class T >
T EBGeometry::AnalyticDetail::extrusion ( const T  a_profile,
const T  a_slab 
)
inlineprotectednoexcept

The signed distance to a 2D profile extruded between two parallel planes: the exact distance, from the profile's signed distance and the signed distance to the slab between the planes.

Internal helper; not part of the public API.

Template Parameters
TFloating-point precision.
Parameters
[in]a_profileSigned distance to the profile, in the cross-section.
[in]a_slabSigned distance to the slab, along the axis.
Returns
The signed distance to the extruded solid.

◆ isFinite()

template<class T >
bool EBGeometry::AnalyticDetail::isFinite ( const Vec3T< T > &  a_point)
inlineprotectednoexcept

Checks that a point given to a constructor is finite.

Internal helper; not part of the public API.

Template Parameters
TFloating-point precision.
Parameters
[in]a_pointThe point.
Returns
Whether every coordinate is finite.