28#ifndef EBGEOMETRY_ANALYTICDISTANCEFUNCTIONS_HPP
29#define EBGEOMETRY_ANALYTICDISTANCEFUNCTIONS_HPP
61 static_assert(std::is_floating_point_v<T>,
"PlaneSDF<T>: T must be a floating-point type");
83 EBGEOMETRY_REQUIRE(std::isfinite(a_point[0]) && std::isfinite(a_point[1]) && std::isfinite(a_point[2]),
84 "PlaneSDF: the point must be finite (%g, %g, %g)",
88 EBGEOMETRY_REQUIRE(std::isfinite(a_normal[0]) && std::isfinite(a_normal[1]) && std::isfinite(a_normal[2]),
89 "PlaneSDF: the normal must be finite (%g, %g, %g)",
94 "PlaneSDF: the normal must be nonzero (%g, %g, %g)",
100 m_normal = a_normal / a_normal.length();
200 static_assert(std::is_floating_point_v<T>,
"SphereSDF<T>: T must be a floating-point type");
220 EBGEOMETRY_REQUIRE(std::isfinite(a_center[0]) && std::isfinite(a_center[1]) && std::isfinite(a_center[2]),
221 "SphereSDF: the center must be finite (%g, %g, %g)",
224 double(a_center[2]));
226 "SphereSDF: the radius must be finite and positive (%g)",
352 static_assert(std::is_floating_point_v<T>,
"BoxSDF<T>: T must be a floating-point type");
373 EBGEOMETRY_REQUIRE(std::isfinite(a_loCorner[0]) && std::isfinite(a_loCorner[1]) && std::isfinite(a_loCorner[2]),
374 "BoxSDF: the low corner must be finite (%g, %g, %g)",
375 double(a_loCorner[0]),
376 double(a_loCorner[1]),
377 double(a_loCorner[2]));
378 EBGEOMETRY_REQUIRE(std::isfinite(a_hiCorner[0]) && std::isfinite(a_hiCorner[1]) && std::isfinite(a_hiCorner[2]),
379 "BoxSDF: the high corner must be finite (%g, %g, %g)",
380 double(a_hiCorner[0]),
381 double(a_hiCorner[1]),
382 double(a_hiCorner[2]));
384 a_loCorner[0] < a_hiCorner[0] && a_loCorner[1] < a_hiCorner[1] && a_loCorner[2] < a_hiCorner[2],
385 "BoxSDF: the low corner (%g, %g, %g) must be below the high corner (%g, %g, %g) in every direction",
386 double(a_loCorner[0]),
387 double(a_loCorner[1]),
388 double(a_loCorner[2]),
389 double(a_hiCorner[0]),
390 double(a_hiCorner[1]),
391 double(a_hiCorner[2]));
534 static_assert(std::is_floating_point_v<T>,
"TorusSDF<T>: T must be a floating-point type");
553 TorusSDF(
const Vec3T<T>& a_center,
const T& a_majorRadius,
const T& a_minorRadius)
noexcept
555 EBGEOMETRY_REQUIRE(std::isfinite(a_center[0]) && std::isfinite(a_center[1]) && std::isfinite(a_center[2]),
556 "TorusSDF: the center must be finite (%g, %g, %g)",
559 double(a_center[2]));
561 "TorusSDF: the major radius must be finite and positive (%g)",
562 double(a_majorRadius));
564 "TorusSDF: the minor radius must be finite and positive (%g)",
565 double(a_minorRadius));
567 "TorusSDF: the minor radius (%g) must be less than the major radius (%g)",
568 double(a_minorRadius),
569 double(a_majorRadius));
679 const T rho = std::sqrt(p[0] * p[0] + p[2] * p[2]) -
m_majorRadius;
680 const T d = std::sqrt(rho * rho + p[1] * p[1]) -
m_minorRadius;
729 static_assert(std::is_floating_point_v<T>,
"CylinderSDF<T>: T must be a floating-point type");
751 EBGEOMETRY_REQUIRE(std::isfinite(a_center1[0]) && std::isfinite(a_center1[1]) && std::isfinite(a_center1[2]),
752 "CylinderSDF: the first center must be finite (%g, %g, %g)",
753 double(a_center1[0]),
754 double(a_center1[1]),
755 double(a_center1[2]));
756 EBGEOMETRY_REQUIRE(std::isfinite(a_center2[0]) && std::isfinite(a_center2[1]) && std::isfinite(a_center2[2]),
757 "CylinderSDF: the second center must be finite (%g, %g, %g)",
758 double(a_center2[0]),
759 double(a_center2[1]),
760 double(a_center2[2]));
762 "CylinderSDF: the radius must be finite and positive (%g)",
765 "CylinderSDF: the two centers must differ, but both are (%g, %g, %g)",
766 double(a_center1[0]),
767 double(a_center1[1]),
768 double(a_center1[2]));
861 const T h = std::abs(para) - T(0.5) *
m_length;
863 constexpr T zero = T(0.0);
865 if (w <= zero && h <= zero) {
867 d = (std::abs(w) < std::abs(h)) ? w : h;
869 else if (w <= zero && h > zero) {
873 else if (w > zero && h < zero) {
878 d = std::sqrt(w * w + h * h);
897 for (
size_t dir = 0; dir < 3; dir++) {
948 static_assert(std::is_floating_point_v<T>,
"InfiniteCylinderSDF<T>: T must be a floating-point type");
970 EBGEOMETRY_REQUIRE(std::isfinite(a_center[0]) && std::isfinite(a_center[1]) && std::isfinite(a_center[2]),
971 "InfiniteCylinderSDF: the center must be finite (%g, %g, %g)",
974 double(a_center[2]));
976 "InfiniteCylinderSDF: the radius must be finite and positive (%g)",
978 EBGEOMETRY_REQUIRE(a_axis < 3U,
"InfiniteCylinderSDF: the axis must be 0, 1 or 2 (%zu)", a_axis);
1118 static_assert(std::is_floating_point_v<T>,
"CapsuleSDF<T>: T must be a floating-point type");
1146 EBGEOMETRY_REQUIRE(std::isfinite(a_tip1[0]) && std::isfinite(a_tip1[1]) && std::isfinite(a_tip1[2]),
1147 "CapsuleSDF: the first tip must be finite (%g, %g, %g)",
1151 EBGEOMETRY_REQUIRE(std::isfinite(a_tip2[0]) && std::isfinite(a_tip2[1]) && std::isfinite(a_tip2[2]),
1152 "CapsuleSDF: the second tip must be finite (%g, %g, %g)",
1157 "CapsuleSDF: the radius must be finite and positive (%g)",
1160 "CapsuleSDF: the tips must be at least two radii apart (distance %g, radius %g)",
1161 double((a_tip2 - a_tip1).
length()),
1164 const Vec3T<T> axis = (a_tip2 - a_tip1) /
length(a_tip2 - a_tip1);
1213 const T len2 =
dot(v2, v2);
1215 const T h = (len2 > T(0)) ?
Math::clamp(
dot(v1, v2) / len2, T(0.0), T(1.0)) : T(0.0);
1302 static_assert(std::is_floating_point_v<T>,
"InfiniteConeSDF<T>: T must be a floating-point type");
1324 EBGEOMETRY_REQUIRE(std::isfinite(a_tip[0]) && std::isfinite(a_tip[1]) && std::isfinite(a_tip[2]),
1325 "InfiniteConeSDF: the tip must be finite (%g, %g, %g)",
1330 "InfiniteConeSDF: the angle must be in (0, 180) degrees (%g)",
1334 m_c[0] = std::sin(T(0.5) * a_angle * pi<T> / T(180));
1335 m_c[1] = std::cos(T(0.5) * a_angle * pi<T> / T(180));
1377 const Vec2T<T> q(std::sqrt(delta[0] * delta[0] + delta[2] * delta[2]), -delta[1]);
1380 const T d2 = d1 * ((q[0] *
m_c[1] - q[1] *
m_c[0] < T(0.0)) ? T(-1.0) : T(1.0));
1428 static_assert(std::is_floating_point_v<T>,
"ConeSDF<T>: T must be a floating-point type");
1450 EBGEOMETRY_REQUIRE(std::isfinite(a_tip[0]) && std::isfinite(a_tip[1]) && std::isfinite(a_tip[2]),
1451 "ConeSDF: the tip must be finite (%g, %g, %g)",
1456 "ConeSDF: the height must be finite and positive (%g)",
1459 a_angle > T(0) && a_angle < T(180),
"ConeSDF: the angle must be in (0, 180) degrees (%g)",
double(a_angle));
1463 m_c[0] = std::sin(T(0.5) * a_angle * pi<T> / T(180));
1464 m_c[1] = std::cos(T(0.5) * a_angle * pi<T> / T(180));
1507 const T dr = std::sqrt(delta[0] * delta[0] + delta[2] * delta[2]);
1508 const T dz = delta[1];
1510 constexpr T zero = T(0.0);
1511 constexpr T one = T(1.0);
1518 auto sign = [](
const T& x) ->
int {
return (x > zero) - (x < zero); };
1520 const T k = sign(q[1]);
1522 const T s =
Math::max(k * (w[0] * q[1] - w[1] * q[0]), k * (w[1] - q[1]));
1524 return std::sqrt(d) * sign(s);
1571 static_assert(std::is_floating_point_v<T>,
"RoundedBoxSDF<T>: T must be a floating-point type");
1594 EBGEOMETRY_REQUIRE(std::isfinite(a_center[0]) && std::isfinite(a_center[1]) && std::isfinite(a_center[2]),
1595 "RoundedBoxSDF: the center must be finite (%g, %g, %g)",
1596 double(a_center[0]),
1597 double(a_center[1]),
1598 double(a_center[2]));
1600 "RoundedBoxSDF: the curvature must be finite and positive (%g)",
1601 double(a_curvature));
1602 EBGEOMETRY_REQUIRE(std::isfinite(a_size[0]) && std::isfinite(a_size[1]) && std::isfinite(a_size[2]) &&
1603 a_size[0] > T(2) * a_curvature && a_size[1] > T(2) * a_curvature &&
1604 a_size[2] > T(2) * a_curvature,
1605 "RoundedBoxSDF: the size (%g, %g, %g) must be finite and exceed twice the curvature (%g)",
1609 double(a_curvature));
1717 static_assert(std::is_floating_point_v<T>,
"PerlinSDF<T>: T must be a floating-point type");
1743 const T a_noisePersistence,
1744 const unsigned int a_noiseOctaves)
noexcept
1747 std::isfinite(a_noiseAmplitude),
"PerlinSDF: the noise amplitude must be finite (%g)",
double(a_noiseAmplitude));
1748 EBGEOMETRY_REQUIRE(std::isfinite(a_noiseFrequency[0]) && std::isfinite(a_noiseFrequency[1]) &&
1749 std::isfinite(a_noiseFrequency[2]),
1750 "PerlinSDF: the noise frequency must be finite (%g, %g, %g)",
1751 double(a_noiseFrequency[0]),
1752 double(a_noiseFrequency[1]),
1753 double(a_noiseFrequency[2]));
1755 "PerlinSDF: the noise persistence must be finite (%g)",
1756 double(a_noisePersistence));
1816 for (
unsigned int curOctave = 0; curOctave <
m_noiseOctaves; curOctave++) {
1817 ret += T(0.5) * curAmp * (T(1) + this->
noise(a_point * curFreq));
1838 template <
class URNG>
1843 for (
unsigned int i = 0; i < 256; i++) {
1849 for (
int i = 0; i < 256; i++) {
1913 lerp(
const T t,
const T a,
const T b)
const noexcept
1915 return a + t * (b - a);
1927 return t * t * t * (t * (t * 6 - 15) + 10);
1940 grad(
const int hash,
const T x,
const T y,
const T z)
const noexcept
1942 const int h = hash & 15;
1943 const T u = h < 8 ? x : y;
1944 const T v = h < 4 ? y : h == 12 || h == 14 ? x : z;
1945 return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v);
1958 const int X =
static_cast<int>(std::floor(a_point[0])) & 255;
1959 const int Y =
static_cast<int>(std::floor(a_point[1])) & 255;
1960 const int Z =
static_cast<int>(std::floor(a_point[2])) & 255;
1963 const T x = a_point[0] - std::floor(a_point[0]);
1964 const T y = a_point[1] - std::floor(a_point[1]);
1965 const T z = a_point[2] - std::floor(a_point[2]);
1968 const T u =
fade(x);
1969 const T v =
fade(y);
1970 const T w =
fade(z);
2019 static_assert(std::is_floating_point_v<T>,
"RoundedCylinderSDF<T>: T must be a floating-point type");
2043 EBGEOMETRY_REQUIRE(std::isfinite(a_center[0]) && std::isfinite(a_center[1]) && std::isfinite(a_center[2]),
2044 "RoundedCylinderSDF: the center must be finite (%g, %g, %g)",
2045 double(a_center[0]),
2046 double(a_center[1]),
2047 double(a_center[2]));
2049 "RoundedCylinderSDF: the radius must be finite and positive (%g)",
2052 "RoundedCylinderSDF: the curvature must be finite and positive (%g)",
2053 double(a_curvature));
2055 "RoundedCylinderSDF: the height must be finite and positive (%g)",
2058 "RoundedCylinderSDF: the curvature (%g) must be less than the radius (%g)",
2059 double(a_curvature),
2062 "RoundedCylinderSDF: twice the curvature (%g) must be less than the height (%g)",
2063 double(a_curvature),
2069 m_height = T(0.5) * a_height - a_curvature;
2110 const T xz = std::sqrt(p[2] * p[2] + p[0] * p[0]);
2158static_assert(std::is_trivially_copyable_v<PlaneSDF<float>>,
"PlaneSDF<float> must be trivially copyable");
2159static_assert(std::is_trivially_copyable_v<PlaneSDF<double>>,
"PlaneSDF<double> must be trivially copyable");
2160static_assert(std::is_trivially_copyable_v<SphereSDF<float>>,
"SphereSDF<float> must be trivially copyable");
2161static_assert(std::is_trivially_copyable_v<SphereSDF<double>>,
"SphereSDF<double> must be trivially copyable");
2162static_assert(std::is_trivially_copyable_v<BoxSDF<float>>,
"BoxSDF<float> must be trivially copyable");
2163static_assert(std::is_trivially_copyable_v<BoxSDF<double>>,
"BoxSDF<double> must be trivially copyable");
2164static_assert(std::is_trivially_copyable_v<TorusSDF<float>>,
"TorusSDF<float> must be trivially copyable");
2165static_assert(std::is_trivially_copyable_v<TorusSDF<double>>,
"TorusSDF<double> must be trivially copyable");
2166static_assert(std::is_trivially_copyable_v<CylinderSDF<float>>,
"CylinderSDF<float> must be trivially copyable");
2167static_assert(std::is_trivially_copyable_v<CylinderSDF<double>>,
"CylinderSDF<double> must be trivially copyable");
2168static_assert(std::is_trivially_copyable_v<InfiniteCylinderSDF<float>>,
2169 "InfiniteCylinderSDF<float> must be trivially copyable");
2170static_assert(std::is_trivially_copyable_v<InfiniteCylinderSDF<double>>,
2171 "InfiniteCylinderSDF<double> must be trivially copyable");
2172static_assert(std::is_trivially_copyable_v<CapsuleSDF<float>>,
"CapsuleSDF<float> must be trivially copyable");
2173static_assert(std::is_trivially_copyable_v<CapsuleSDF<double>>,
"CapsuleSDF<double> must be trivially copyable");
2174static_assert(std::is_trivially_copyable_v<InfiniteConeSDF<float>>,
2175 "InfiniteConeSDF<float> must be trivially copyable");
2176static_assert(std::is_trivially_copyable_v<InfiniteConeSDF<double>>,
2177 "InfiniteConeSDF<double> must be trivially copyable");
2178static_assert(std::is_trivially_copyable_v<ConeSDF<float>>,
"ConeSDF<float> must be trivially copyable");
2179static_assert(std::is_trivially_copyable_v<ConeSDF<double>>,
"ConeSDF<double> must be trivially copyable");
2180static_assert(std::is_trivially_copyable_v<RoundedBoxSDF<float>>,
"RoundedBoxSDF<float> must be trivially copyable");
2181static_assert(std::is_trivially_copyable_v<RoundedBoxSDF<double>>,
"RoundedBoxSDF<double> must be trivially copyable");
2182static_assert(std::is_trivially_copyable_v<PerlinSDF<float>>,
"PerlinSDF<float> must be trivially copyable");
2183static_assert(std::is_trivially_copyable_v<PerlinSDF<double>>,
"PerlinSDF<double> must be trivially copyable");
2184static_assert(std::is_trivially_copyable_v<RoundedCylinderSDF<float>>,
2185 "RoundedCylinderSDF<float> must be trivially copyable");
2186static_assert(std::is_trivially_copyable_v<RoundedCylinderSDF<double>>,
2187 "RoundedCylinderSDF<double> must be trivially copyable");
A fixed-size array that compiles for both host and device.
Declarations of bounding volume types used in bounding volume hierarchies.
Mathematical constants for EBGeometry.
How far a function's value can be trusted as a distance: DistanceQuality, and the distanceQualityOf t...
GPU portability layer: host/device decoration macros and backend detection.
#define EBGEOMETRY_HOST_DEVICE
Mark a function as callable from both host and device code (no-op on host compilers).
Definition EBGeometry_GPU.hpp:80
Utility macros for EBGeometry.
#define EBGEOMETRY_REQUIRE(cond,...)
Always-on check of user input and one-time host setup.
Definition EBGeometry_Macros.hpp:84
#define EBGEOMETRY_EXPECT(cond)
Runtime precondition assertion for EBGeometry.
Definition EBGeometry_Macros.hpp:155
Scalar helpers and numeric limits that compile for both host and device.
Declaration of 2D and 3D point/vector classes with templated precision, and free functions on them.
Axis-aligned bounding box (AABB) enclosing a set of 3D points.
Definition EBGeometry_BoundingVolumes.hpp:37
Signed distance field for an axis-aligned box (AABB).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:351
BoxSDF & operator=(const BoxSDF &)=default
Copy assignment.
BoxSDF()=default
Default constructor. Constructs a unit cube centered at the origin: [-0.5, 0.5]^3.
BoxSDF(const BoxSDF &)=default
Copy constructor.
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:503
Vec3T< T > m_loCorner
Low box corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:512
Vec3T< T > & getHighCorner() noexcept
Get upper-right corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:460
Vec3T< T > & getLowCorner() noexcept
Get lower-left corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:438
BoxSDF & operator=(BoxSDF &&)=default
Move assignment.
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the axis-aligned box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:472
const Vec3T< T > & getHighCorner() const noexcept
Get upper-right corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:449
const Vec3T< T > & getLowCorner() const noexcept
Get lower-left corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:427
Vec3T< T > m_hiCorner
High box corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:517
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:358
BoxSDF(BoxSDF &&)=default
Move constructor.
BoxSDF(const Vec3T< T > &a_loCorner, const Vec3T< T > &a_hiCorner) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:371
Signed distance field for a capsule (pill shape): a cylinder capped with hemispheres.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1117
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1124
const Vec3T< T > & getCenter2() const noexcept
Get the center of the second hemispherical cap.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1251
CapsuleSDF & operator=(const CapsuleSDF &)=default
Copy assignment.
Vec3T< T > m_center2
Center of the other hemispherical cap.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1276
CapsuleSDF()=default
Default constructor. Constructs a capsule with tips at (0,-1,0) and (0,1,0), radius 0....
const T & getRadius() const noexcept
Get the radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1262
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1228
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the capsule.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1202
CapsuleSDF(const CapsuleSDF &)=default
Copy constructor.
CapsuleSDF & operator=(CapsuleSDF &&)=default
Move assignment.
T m_radius
Capsule radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1281
CapsuleSDF(const Vec3T< T > &a_tip1, const Vec3T< T > &a_tip2, const T &a_radius) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1144
const Vec3T< T > & getCenter1() const noexcept
Get the center of the first hemispherical cap.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1240
CapsuleSDF(CapsuleSDF &&)=default
Move constructor.
Vec3T< T > m_center1
Center of one hemispherical cap.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1271
Signed distance field for a finite cone.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1427
ConeSDF()=default
Default constructor. Constructs a finite cone with its tip at the origin, height 1,...
Vec3T< T > m_tip
Tip position.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1547
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1535
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the finite cone.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1498
ConeSDF & operator=(ConeSDF &&)=default
Move assignment.
ConeSDF & operator=(const ConeSDF &)=default
Copy assignment.
ConeSDF(ConeSDF &&)=default
Move constructor.
T m_height
Cone height (tip to base).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1557
ConeSDF(const Vec3T< T > &a_tip, const T &a_height, const T &a_angle) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1448
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1434
ConeSDF(const ConeSDF &)=default
Copy constructor.
Vec2T< T > m_c
(sin, cos) of the half opening-angle. Default: 45° full angle → half-angle 22.5°.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1552
Signed distance field for a finite, flat-capped cylinder.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:728
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:893
T m_length
Distance between the two endpoints.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:928
Vec3T< T > m_center1
One endpoint (cap center).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:908
const Vec3T< T > & getCenter2() const noexcept
Get the other endpoint.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:820
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the cylinder.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:843
Vec3T< T > m_center2
Other endpoint (cap center).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:913
CylinderSDF(const Vec3T< T > &a_center1, const Vec3T< T > &a_center2, const T &a_radius) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:749
CylinderSDF()=default
Default constructor. Constructs a unit cylinder of radius 1 and height 1, centered at the origin with...
CylinderSDF(const CylinderSDF &)=default
Copy constructor.
Vec3T< T > m_center
Midpoint of m_center1 and m_center2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:918
const T & getRadius() const noexcept
Get radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:831
Vec3T< T > m_axis
Unit axis pointing from m_center1 to m_center2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:923
const Vec3T< T > & getCenter1() const noexcept
Get one endpoint.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:809
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:735
T m_radius
Cylinder radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:933
CylinderSDF(CylinderSDF &&)=default
Move constructor.
CylinderSDF & operator=(CylinderSDF &&)=default
Move assignment.
CylinderSDF & operator=(const CylinderSDF &)=default
Copy assignment.
Signed distance field for an infinite cone.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1301
InfiniteConeSDF(const InfiniteConeSDF &)=default
Copy constructor.
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1392
InfiniteConeSDF()=default
Default constructor. Constructs an infinite cone with tip at the origin, 45° full opening angle,...
Vec3T< T > m_tip
Tip position.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1405
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1308
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the infinite cone.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1369
Vec2T< T > m_c
(sin, cos) of the half opening-angle. Default: 45° full angle → half-angle 22.5°.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1410
InfiniteConeSDF(const Vec3T< T > &a_tip, const T &a_angle) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1322
InfiniteConeSDF(InfiniteConeSDF &&)=default
Move constructor.
InfiniteConeSDF & operator=(InfiniteConeSDF &&)=default
Move assignment.
InfiniteConeSDF & operator=(const InfiniteConeSDF &)=default
Copy assignment.
Signed distance field for an infinitely long cylinder.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:947
T m_radius
Cylinder radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1090
InfiniteCylinderSDF & operator=(const InfiniteCylinderSDF &)=default
Copy assignment.
const size_t & getAxis() const noexcept
Get the coordinate axis the cylinder runs along.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1076
InfiniteCylinderSDF(const Vec3T< T > &a_center, const T &a_radius, const size_t a_axis) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:968
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the infinite cylinder.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1016
InfiniteCylinderSDF(const InfiniteCylinderSDF &)=default
Copy constructor.
Vec3T< T > m_center
Center point on the cylinder axis.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1085
InfiniteCylinderSDF(InfiniteCylinderSDF &&)=default
Move constructor.
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1037
const Vec3T< T > & getCenter() const noexcept
Get the point on the axis.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1054
InfiniteCylinderSDF()=default
Default constructor. Constructs an infinite cylinder of radius 1 centered at the origin with its axis...
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:954
size_t m_axis
Coordinate axis index (0 = x, 1 = y, 2 = z).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1095
const T & getRadius() const noexcept
Get the radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1065
InfiniteCylinderSDF & operator=(InfiniteCylinderSDF &&)=default
Move assignment.
Ken Perlin's gradient-noise implicit function.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1716
PerlinSDF(const T a_noiseAmplitude, const Vec3T< T > a_noiseFrequency, const T a_noisePersistence, const unsigned int a_noiseOctaves) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1741
Array< int, 512 > m_permutationTable
Integer hash permutation table (512 entries: [0..255] mirrored).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1897
unsigned int m_noiseOctaves
Number of noise octaves.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1902
Vec3T< T > m_noiseFrequency
Spatial noise frequency along each Cartesian axis.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1880
PerlinSDF & operator=(const PerlinSDF &)=default
Copy assignment.
PerlinSDF(const PerlinSDF &)=default
Copy constructor.
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: not at all. The value is noise,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1724
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function. Generates a noise value on [0, m_noiseAmplitude] for one octave.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1805
T noise(const Vec3T< T > &a_point) const noexcept
Single-octave Perlin noise evaluation.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1955
T grad(const int hash, const T x, const T y, const T z) const noexcept
Ken Perlin's gradient hash function.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1940
T lerp(const T t, const T a, const T b) const noexcept
Ken Perlin's linear interpolation helper.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1913
Array< int, 512 > & getPermutationTable() noexcept
Get the internal permutation table.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1859
PerlinSDF(PerlinSDF &&)=default
Move constructor.
T fade(const T t) const noexcept
Ken Perlin's fade (smoothstep) function: 6t^5 - 15t^4 + 10t^3.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1925
PerlinSDF & operator=(PerlinSDF &&)=default
Move assignment.
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1871
T m_noiseAmplitude
Noise amplitude (output scale).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1885
PerlinSDF() noexcept
Default constructor. Constructs a single-octave Perlin noise field with unit amplitude,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1730
T m_noisePersistence
Per-octave amplitude decay factor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1890
void shuffle(URNG &g) noexcept
Shuffle the permutation table with the provided uniform random number generator.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1840
Signed distance function for a plane.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:60
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:67
const Vec3T< T > & getPoint() const noexcept
Get the point on the plane.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:162
PlaneSDF()=default
Default constructor. Constructs the y = 0 plane with outward normal (0, 1, 0).
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:151
PlaneSDF(const Vec3T< T > &a_point, const Vec3T< T > &a_normal) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:81
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the plane.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:134
PlaneSDF(const PlaneSDF &)=default
Copy constructor.
const Vec3T< T > & getNormal() const noexcept
Get the unit normal of the plane.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:173
PlaneSDF & operator=(PlaneSDF &&)=default
Move assignment.
PlaneSDF(PlaneSDF &&)=default
Move constructor.
Vec3T< T > m_point
Point on plane.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:182
Vec3T< T > m_normal
Plane normal vector (unit length).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:187
PlaneSDF & operator=(const PlaneSDF &)=default
Copy assignment.
Signed distance field for an axis-aligned box with rounded edges and corners.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1570
RoundedBoxSDF()=default
Default constructor. Constructs a rounded unit cube, [-0.5, 0.5]^3, centered at the origin,...
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1673
T m_curvature
Corner rounding radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1684
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1577
RoundedBoxSDF & operator=(RoundedBoxSDF &&)=default
Move assignment.
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the rounded box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1647
RoundedBoxSDF(const Vec3T< T > &a_center, const Vec3T< T > &a_size, const T a_curvature) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1592
RoundedBoxSDF(const RoundedBoxSDF &)=default
Copy constructor.
Vec3T< T > m_dimensions
Half-extents of the inner box (= 0.5 * outer size - curvature).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1694
Vec3T< T > m_center
Box center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1689
RoundedBoxSDF(RoundedBoxSDF &&)=default
Move constructor.
RoundedBoxSDF & operator=(const RoundedBoxSDF &)=default
Copy assignment.
Signed distance field for a cylinder with rounded (toroidal) edges.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2018
RoundedCylinderSDF(RoundedCylinderSDF &&)=default
Move constructor.
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2124
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2025
RoundedCylinderSDF & operator=(RoundedCylinderSDF &&)=default
Move assignment.
RoundedCylinderSDF(const RoundedCylinderSDF &)=default
Copy constructor.
T m_height
Inner half-height (= 0.5*height - curvature).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2151
RoundedCylinderSDF & operator=(const RoundedCylinderSDF &)=default
Copy assignment.
Vec3T< T > m_center
Cylinder center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2136
T m_majorRadius
Inner cylinder radius (= outer radius - curvature).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2141
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the rounded cylinder.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2103
RoundedCylinderSDF(const Vec3T< T > &a_center, const T a_radius, const T a_curvature, const T a_height) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2041
T m_minorRadius
Edge rounding radius (= curvature).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2146
RoundedCylinderSDF()=default
Default constructor. Constructs a rounded cylinder centered at the origin, axis along y,...
Signed distance field for a sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:199
Vec3T< T > & getCenter() noexcept
Get sphere center (mutable).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:274
SphereSDF()=default
Default constructor. Constructs a unit sphere centered at the origin.
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:308
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:324
SphereSDF & operator=(SphereSDF &&)=default
Move assignment.
SphereSDF & operator=(const SphereSDF &)=default
Copy assignment.
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:206
const Vec3T< T > & getCenter() const noexcept
Get sphere center (const).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:263
Vec3T< T > m_center
Sphere center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:333
T m_radius
Sphere radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:338
const T & getRadius() const noexcept
Get sphere radius (const).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:285
SphereSDF(SphereSDF &&)=default
Move constructor.
SphereSDF(const SphereSDF &)=default
Copy constructor.
T & getRadius() noexcept
Get sphere radius (mutable).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:296
SphereSDF(const Vec3T< T > &a_center, const T &a_radius) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:218
Signed distance field for a torus.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:533
TorusSDF & operator=(const TorusSDF &)=default
Copy assignment.
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the torus.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:672
T m_minorRadius
Minor (tube) radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:714
Vec3T< T > & getCenter() noexcept
Get torus center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:617
T m_majorRadius
Major (ring) radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:709
TorusSDF(const Vec3T< T > &a_center, const T &a_majorRadius, const T &a_minorRadius) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:553
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:540
const T & getMinorRadius() const noexcept
Get minor radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:650
TorusSDF(TorusSDF &&)=default
Move constructor.
TorusSDF(const TorusSDF &)=default
Copy constructor.
const T & getMajorRadius() const noexcept
Get major radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:628
T & getMajorRadius() noexcept
Get major radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:639
Vec3T< T > m_center
Torus center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:704
TorusSDF & operator=(TorusSDF &&)=default
Move assignment.
T & getMinorRadius() noexcept
Get minor radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:661
TorusSDF()=default
Default constructor. Constructs a torus centered at the origin with major radius 1 and minor radius 0...
const Vec3T< T > & getCenter() const noexcept
Get torus center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:606
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:692
Two-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:37
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
static constexpr Vec3T< T > max() noexcept
Return the most-positive representable vector.
size_t maxDir(const bool a_doAbs) const noexcept
Return the direction which has the largest component (can be absolute)
T length() const noexcept
Compute vector length.
static constexpr Vec3T< T > ones() noexcept
Return a vector with x = y = z = 1.
static constexpr Vec3T< T > zeros() noexcept
Return a vector with x = y = z = 0.
constexpr T clamp(const T &a_value, const T &a_lo, const T &a_hi) noexcept
A value limited to [lo, hi].
Definition EBGeometry_Math.hpp:78
constexpr T max(const T &a_a, const T &a_b) noexcept
The larger of two values.
Definition EBGeometry_Math.hpp:61
constexpr T min(const T &a_a, const T &a_b) noexcept
The smaller of two values.
Definition EBGeometry_Math.hpp:44
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
Vec2T< T > min(const Vec2T< T > &u, const Vec2T< T > &v) noexcept
Component-wise minimum of two vectors.
T length(const Vec2T< T > &v) noexcept
Euclidean length of a 2D vector.
T dot(const Vec2T< T > &u, const Vec2T< T > &v) noexcept
Dot product of two 2D vectors.
DistanceQuality
How far the value of a signed distance function can be trusted, from strongest to weakest.
Definition EBGeometry_DistanceQuality.hpp:25
@ Exact
The value's magnitude is the Euclidean distance to the surface.
@ NotADistance
Only the sign is meaningful, so the function describes a surface (its zero level set) but says nothin...
Vec2T< T > max(const Vec2T< T > &u, const Vec2T< T > &v) noexcept
Component-wise maximum of two vectors.
Fixed-size array with host- and device-callable members.
Definition EBGeometry_Array.hpp:33
constexpr T * begin() noexcept
Iterator to the first element.
Definition EBGeometry_Array.hpp:104
Numeric limits, with the meanings of the std::numeric_limits members of the same names.
Definition EBGeometry_Math.hpp:91