|
EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
|
Signed distance field for a capsule (pill shape): a cylinder capped with hemispheres. More...
#include <EBGeometry_AnalyticDistanceFunctions.hpp>
Public Member Functions | |
| CapsuleSDF ()=default | |
| Default constructor. Constructs a capsule with tips at (0,-1,0) and (0,1,0), radius 0.5. | |
| CapsuleSDF (const Vec3T< T > &a_tip1, const Vec3T< T > &a_tip2, const T &a_radius) noexcept | |
| Full constructor. | |
| CapsuleSDF (const CapsuleSDF &)=default | |
| Copy constructor. | |
| CapsuleSDF (CapsuleSDF &&)=default | |
| Move constructor. | |
| CapsuleSDF & | operator= (const CapsuleSDF &)=default |
| Copy assignment. | |
| CapsuleSDF & | operator= (CapsuleSDF &&)=default |
| Move assignment. | |
| T | signedDistance (const Vec3T< T > &a_point) const noexcept |
| Signed distance function for the capsule. | |
| BoundingVolumes::AABBT< T > | computeBoundingVolume () const noexcept |
| The shape's axis-aligned bounding box. | |
| const Vec3T< T > & | getCenter1 () const noexcept |
| Get the center of the first hemispherical cap. | |
| const Vec3T< T > & | getCenter2 () const noexcept |
| Get the center of the second hemispherical cap. | |
| const T & | getRadius () const noexcept |
| Get the radius. | |
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_center1 = Vec3T<T>(T(0), T(-0.5), T(0)) |
| Center of one hemispherical cap. | |
| Vec3T< T > | m_center2 = Vec3T<T>(T(0), T(0.5), T(0)) |
| Center of the other hemispherical cap. | |
| T | m_radius = T(0.5) |
| Capsule radius. | |
Signed distance field for a capsule (pill shape): a cylinder capped with hemispheres.
A capsule is defined by two outer tip positions and a radius. The tips are the outermost points of each hemispherical endcap. The total length (tip to tip) equals distance(tip1, tip2). The internal cylindrical body has length distance(tip1, tip2) - 2 * radius, and the two hemispheres each contribute a further radius to each end.
Internally the hemisphere centers are stored as m_center1 and m_center2 (inset from the tips by radius along the capsule axis). These are not the same as the tip positions passed to the constructor.
The SDF is negative inside the capsule and positive outside. By default the capsule is centered at the origin, aligned along y, with tips at (0,-1,0) and (0,1,0) and radius 0.5, giving a total height of 2 and a cylindrical body of length 1.
| T | Floating-point precision. |
|
default |
Default constructor. Constructs a capsule with tips at (0,-1,0) and (0,1,0), radius 0.5.
Total height = 2, cylindrical body length = 1, aligned along y, centered at origin. The stored hemisphere centers are at (0,-0.5,0) and (0,0.5,0).
|
inlinenoexcept |
Full constructor.
The hemisphere centers stored internally are derived from the tips: m_center1 = a_tip1 + a_radius * axis and m_center2 = a_tip2 - a_radius * axis, where axis = (a_tip2 - a_tip1) / distance(a_tip1, a_tip2). The cylindrical body length is distance(a_tip1, a_tip2) - 2 * a_radius, which must not be negative: distance(a_tip1, a_tip2) >= 2 * a_radius. At equality the capsule is a sphere.
| [in] | a_tip1 | Outer tip of one hemispherical cap (outermost point in that direction). |
| [in] | a_tip2 | Outer tip of the other hemispherical cap. |
| [in] | a_radius | Capsule radius (applied to both the tube and the hemispherical caps). |
|
inlinenoexcept |
The shape's axis-aligned bounding box.
The two hemisphere centers plus and minus the radius along each axis.
|
inlinenoexcept |
Get the center of the first hemispherical cap.
|
inlinenoexcept |
Get the center of the second hemispherical cap.
|
inlinenoexcept |
Get the radius.
|
default |
Move assignment.
|
default |
Copy assignment.
|
inlinenoexcept |
Signed distance function for the capsule.
| [in] | a_point | Position. |