34#ifndef EBGEOMETRY_ANALYTICDISTANCEFUNCTIONS_HPP
35#define EBGEOMETRY_ANALYTICDISTANCEFUNCTIONS_HPP
70 static_assert(std::is_floating_point_v<T>,
"PlaneSDF<T>: T must be a floating-point type");
92 EBGEOMETRY_REQUIRE(std::isfinite(a_point[0]) && std::isfinite(a_point[1]) && std::isfinite(a_point[2]),
93 "PlaneSDF: the point must be finite (%g, %g, %g)",
97 EBGEOMETRY_REQUIRE(std::isfinite(a_normal[0]) && std::isfinite(a_normal[1]) && std::isfinite(a_normal[2]),
98 "PlaneSDF: the normal must be finite (%g, %g, %g)",
101 double(a_normal[2]));
103 "PlaneSDF: the normal must be nonzero (%g, %g, %g)",
106 double(a_normal[2]));
209 static_assert(std::is_floating_point_v<T>,
"SphereSDF<T>: T must be a floating-point type");
229 EBGEOMETRY_REQUIRE(std::isfinite(a_center[0]) && std::isfinite(a_center[1]) && std::isfinite(a_center[2]),
230 "SphereSDF: the center must be finite (%g, %g, %g)",
233 double(a_center[2]));
235 "SphereSDF: the radius must be finite and positive (%g)",
361 static_assert(std::is_floating_point_v<T>,
"BoxSDF<T>: T must be a floating-point type");
382 EBGEOMETRY_REQUIRE(std::isfinite(a_loCorner[0]) && std::isfinite(a_loCorner[1]) && std::isfinite(a_loCorner[2]),
383 "BoxSDF: the low corner must be finite (%g, %g, %g)",
384 double(a_loCorner[0]),
385 double(a_loCorner[1]),
386 double(a_loCorner[2]));
387 EBGEOMETRY_REQUIRE(std::isfinite(a_hiCorner[0]) && std::isfinite(a_hiCorner[1]) && std::isfinite(a_hiCorner[2]),
388 "BoxSDF: the high corner must be finite (%g, %g, %g)",
389 double(a_hiCorner[0]),
390 double(a_hiCorner[1]),
391 double(a_hiCorner[2]));
393 a_loCorner[0] < a_hiCorner[0] && a_loCorner[1] < a_hiCorner[1] && a_loCorner[2] < a_hiCorner[2],
394 "BoxSDF: the low corner (%g, %g, %g) must be below the high corner (%g, %g, %g) in every direction",
395 double(a_loCorner[0]),
396 double(a_loCorner[1]),
397 double(a_loCorner[2]),
398 double(a_hiCorner[0]),
399 double(a_hiCorner[1]),
400 double(a_hiCorner[2]));
529 const size_t axis = delta.
maxDir(
false);
531 return 2U * uint32_t(axis) + ((hi[axis] > lo[axis]) ? 1U : 0U);
572 static_assert(std::is_floating_point_v<T>,
"TorusSDF<T>: T must be a floating-point type");
593 EBGEOMETRY_REQUIRE(std::isfinite(a_center[0]) && std::isfinite(a_center[1]) && std::isfinite(a_center[2]),
594 "TorusSDF: the center must be finite (%g, %g, %g)",
597 double(a_center[2]));
599 "TorusSDF: the major radius must be finite and positive (%g)",
600 double(a_majorRadius));
602 "TorusSDF: the minor radius must be finite and positive (%g)",
603 double(a_minorRadius));
605 "TorusSDF: the minor radius (%g) must be less than the major radius (%g)",
606 double(a_minorRadius),
607 double(a_majorRadius));
717 const T rho = std::sqrt(p[0] * p[0] + p[2] * p[2]) -
m_majorRadius;
718 const T d = std::sqrt(rho * rho + p[1] * p[1]) -
m_minorRadius;
767 static_assert(std::is_floating_point_v<T>,
"CylinderSDF<T>: T must be a floating-point type");
789 EBGEOMETRY_REQUIRE(std::isfinite(a_center1[0]) && std::isfinite(a_center1[1]) && std::isfinite(a_center1[2]),
790 "CylinderSDF: the first center must be finite (%g, %g, %g)",
791 double(a_center1[0]),
792 double(a_center1[1]),
793 double(a_center1[2]));
794 EBGEOMETRY_REQUIRE(std::isfinite(a_center2[0]) && std::isfinite(a_center2[1]) && std::isfinite(a_center2[2]),
795 "CylinderSDF: the second center must be finite (%g, %g, %g)",
796 double(a_center2[0]),
797 double(a_center2[1]),
798 double(a_center2[2]));
800 "CylinderSDF: the radius must be finite and positive (%g)",
803 "CylinderSDF: the two centers must differ, but both are (%g, %g, %g)",
804 double(a_center1[0]),
805 double(a_center1[1]),
806 double(a_center1[2]));
899 const T h = std::abs(para) - T(0.5) *
m_length;
901 constexpr T zero = T(0.0);
903 if (w <= zero && h <= zero) {
905 d = (std::abs(w) < std::abs(h)) ? w : h;
907 else if (w <= zero && h > zero) {
911 else if (w > zero && h < zero) {
916 d = std::sqrt(w * w + h * h);
946 const T h = std::abs(para) - T(0.5) *
m_length;
949 const bool side = (w <= T(0) && h <= T(0)) ? (std::abs(w) < std::abs(h)) : (w > h);
951 return side ? 0U : ((para < T(0)) ? 1U : 2U);
966 for (
size_t dir = 0; dir < 3; dir++) {
1017 static_assert(std::is_floating_point_v<T>,
"InfiniteCylinderSDF<T>: T must be a floating-point type");
1039 EBGEOMETRY_REQUIRE(std::isfinite(a_center[0]) && std::isfinite(a_center[1]) && std::isfinite(a_center[2]),
1040 "InfiniteCylinderSDF: the center must be finite (%g, %g, %g)",
1041 double(a_center[0]),
1042 double(a_center[1]),
1043 double(a_center[2]));
1045 "InfiniteCylinderSDF: the radius must be finite and positive (%g)",
1047 EBGEOMETRY_REQUIRE(a_axis < 3U,
"InfiniteCylinderSDF: the axis must be 0, 1 or 2 (%zu)", a_axis);
1187 static_assert(std::is_floating_point_v<T>,
"CapsuleSDF<T>: T must be a floating-point type");
1215 EBGEOMETRY_REQUIRE(std::isfinite(a_tip1[0]) && std::isfinite(a_tip1[1]) && std::isfinite(a_tip1[2]),
1216 "CapsuleSDF: the first tip must be finite (%g, %g, %g)",
1220 EBGEOMETRY_REQUIRE(std::isfinite(a_tip2[0]) && std::isfinite(a_tip2[1]) && std::isfinite(a_tip2[2]),
1221 "CapsuleSDF: the second tip must be finite (%g, %g, %g)",
1226 "CapsuleSDF: the radius must be finite and positive (%g)",
1229 "CapsuleSDF: the tips must be at least two radii apart (distance %g, radius %g)",
1230 double((a_tip2 - a_tip1).
length()),
1233 const Vec3T<T> axis = (a_tip2 - a_tip1) /
length(a_tip2 - a_tip1);
1282 const T len2 =
dot(v2, v2);
1284 const T h = (len2 > T(0)) ?
Math::clamp(
dot(v1, v2) / len2, T(0.0), T(1.0)) : T(0.0);
1312 const T len2 =
dot(v2, v2);
1313 const T t = (len2 > T(0)) ?
dot(v1, v2) / len2 : T(0);
1315 return (t <= T(0)) ? 1U : ((t >= T(1)) ? 2U : 0U);
1399 static_assert(std::is_floating_point_v<T>,
"InfiniteConeSDF<T>: T must be a floating-point type");
1421 EBGEOMETRY_REQUIRE(std::isfinite(a_tip[0]) && std::isfinite(a_tip[1]) && std::isfinite(a_tip[2]),
1422 "InfiniteConeSDF: the tip must be finite (%g, %g, %g)",
1427 "InfiniteConeSDF: the angle must be in (0, 180) degrees (%g)",
1431 m_c[0] = std::sin(T(0.5) * a_angle * pi<T> / T(180));
1432 m_c[1] = std::cos(T(0.5) * a_angle * pi<T> / T(180));
1474 const Vec2T<T> q(std::sqrt(delta[0] * delta[0] + delta[2] * delta[2]), -delta[1]);
1477 const T d2 = d1 * ((q[0] *
m_c[1] - q[1] *
m_c[0] < T(0.0)) ? T(-1.0) : T(1.0));
1525 static_assert(std::is_floating_point_v<T>,
"ConeSDF<T>: T must be a floating-point type");
1547 EBGEOMETRY_REQUIRE(std::isfinite(a_tip[0]) && std::isfinite(a_tip[1]) && std::isfinite(a_tip[2]),
1548 "ConeSDF: the tip must be finite (%g, %g, %g)",
1553 "ConeSDF: the height must be finite and positive (%g)",
1556 a_angle > T(0) && a_angle < T(180),
"ConeSDF: the angle must be in (0, 180) degrees (%g)",
double(a_angle));
1560 m_c[0] = std::sin(T(0.5) * a_angle * pi<T> / T(180));
1561 m_c[1] = std::cos(T(0.5) * a_angle * pi<T> / T(180));
1604 const T dr = std::sqrt(delta[0] * delta[0] + delta[2] * delta[2]);
1605 const T dz = delta[1];
1607 constexpr T zero = T(0.0);
1608 constexpr T one = T(1.0);
1615 auto sign = [](
const T& x) ->
int {
return (x > zero) - (x < zero); };
1617 const T k = sign(q[1]);
1619 const T s =
Math::max(k * (w[0] * q[1] - w[1] * q[0]), k * (w[1] - q[1]));
1621 return std::sqrt(d) * sign(s);
1646 const Vec2T<T> w =
Vec2T<T>(std::sqrt(delta[0] * delta[0] + delta[2] * delta[2]), delta[1]);
1650 return (
dot(a, a) <=
dot(b, b)) ? 0U : 1U;
1697 static_assert(std::is_floating_point_v<T>,
"RoundedBoxSDF<T>: T must be a floating-point type");
1720 EBGEOMETRY_REQUIRE(std::isfinite(a_center[0]) && std::isfinite(a_center[1]) && std::isfinite(a_center[2]),
1721 "RoundedBoxSDF: the center must be finite (%g, %g, %g)",
1722 double(a_center[0]),
1723 double(a_center[1]),
1724 double(a_center[2]));
1726 "RoundedBoxSDF: the curvature must be finite and positive (%g)",
1727 double(a_curvature));
1728 EBGEOMETRY_REQUIRE(std::isfinite(a_size[0]) && std::isfinite(a_size[1]) && std::isfinite(a_size[2]) &&
1729 a_size[0] > T(2) * a_curvature && a_size[1] > T(2) * a_curvature &&
1730 a_size[2] > T(2) * a_curvature,
1731 "RoundedBoxSDF: the size (%g, %g, %g) must be finite and exceed twice the curvature (%g)",
1735 double(a_curvature));
1816 const size_t axis = q.
maxDir(
false);
1818 return 2U * uint32_t(axis) + ((p[axis] > T(0)) ? 1U : 0U);
1872 static_assert(std::is_floating_point_v<T>,
"PerlinSDF<T>: T must be a floating-point type");
1898 const T a_noisePersistence,
1899 const unsigned int a_noiseOctaves)
1902 std::isfinite(a_noiseAmplitude),
"PerlinSDF: the noise amplitude must be finite (%g)",
double(a_noiseAmplitude));
1903 EBGEOMETRY_REQUIRE(std::isfinite(a_noiseFrequency[0]) && std::isfinite(a_noiseFrequency[1]) &&
1904 std::isfinite(a_noiseFrequency[2]),
1905 "PerlinSDF: the noise frequency must be finite (%g, %g, %g)",
1906 double(a_noiseFrequency[0]),
1907 double(a_noiseFrequency[1]),
1908 double(a_noiseFrequency[2]));
1910 "PerlinSDF: the noise persistence must be finite (%g)",
1911 double(a_noisePersistence));
1971 for (
unsigned int curOctave = 0; curOctave <
m_noiseOctaves; curOctave++) {
1972 ret += T(0.5) * curAmp * (T(1) + this->
noise(a_point * curFreq));
1993 template <
class URNG>
1998 for (
unsigned int i = 0; i < 256; i++) {
2004 for (
int i = 0; i < 256; i++) {
2068 lerp(
const T t,
const T a,
const T b)
const noexcept
2070 return a + t * (b - a);
2082 return t * t * t * (t * (t * 6 - 15) + 10);
2095 grad(
const int hash,
const T x,
const T y,
const T z)
const noexcept
2097 const int h = hash & 15;
2098 const T u = h < 8 ? x : y;
2099 const T v = h < 4 ? y : h == 12 || h == 14 ? x : z;
2100 return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v);
2113 const int X =
static_cast<int>(std::floor(a_point[0])) & 255;
2114 const int Y =
static_cast<int>(std::floor(a_point[1])) & 255;
2115 const int Z =
static_cast<int>(std::floor(a_point[2])) & 255;
2118 const T x = a_point[0] - std::floor(a_point[0]);
2119 const T y = a_point[1] - std::floor(a_point[1]);
2120 const T z = a_point[2] - std::floor(a_point[2]);
2123 const T u =
fade(x);
2124 const T v =
fade(y);
2125 const T w =
fade(z);
2174 static_assert(std::is_floating_point_v<T>,
"RoundedCylinderSDF<T>: T must be a floating-point type");
2198 EBGEOMETRY_REQUIRE(std::isfinite(a_center[0]) && std::isfinite(a_center[1]) && std::isfinite(a_center[2]),
2199 "RoundedCylinderSDF: the center must be finite (%g, %g, %g)",
2200 double(a_center[0]),
2201 double(a_center[1]),
2202 double(a_center[2]));
2204 "RoundedCylinderSDF: the radius must be finite and positive (%g)",
2207 "RoundedCylinderSDF: the curvature must be finite and positive (%g)",
2208 double(a_curvature));
2210 "RoundedCylinderSDF: the height must be finite and positive (%g)",
2213 "RoundedCylinderSDF: the curvature (%g) must be less than the radius (%g)",
2214 double(a_curvature),
2217 "RoundedCylinderSDF: twice the curvature (%g) must be less than the height (%g)",
2218 double(a_curvature),
2224 m_height = T(0.5) * a_height - a_curvature;
2265 const T xz = std::sqrt(p[2] * p[2] + p[0] * p[0]);
2293 const T xz = std::sqrt(p[2] * p[2] + p[0] * p[0]);
2295 const T y = std::abs(p[1]) -
m_height;
2297 return (r >= y) ? 0U : ((p[1] < T(0)) ? 1U : 2U);
2337namespace AnalyticDetail {
2373 const Vec3T<T> w = a_point - a_start;
2374 const T along =
dot(w, a_axis);
2393 const T outsideProfile =
Math::max(a_profile, T(0));
2394 const T outsideSlab =
Math::max(a_slab, T(0));
2397 std::sqrt(outsideProfile * outsideProfile + outsideSlab * outsideSlab);
2408[[nodiscard]]
inline bool
2411 return std::isfinite(a_point[0]) && std::isfinite(a_point[1]) && std::isfinite(a_point[2]);
2431template <
class T,
size_t N>
2434ellipsoidRoot(
const T (&a_r)[N],
const T (&a_n)[N],
const T a_lo,
const T a_hi)
noexcept
2436 constexpr int MaxIterations = 64;
2445 for (
int i = 0; i < MaxIterations; i++) {
2449 for (
size_t k = 0; k < N; k++) {
2450 const T ratio = a_n[k] / (s + a_r[k]);
2453 df -= T(2) * ratio * ratio / (s + a_r[k]);
2460 T next = (df < T(0)) ? s - f / df : hi;
2467 next = T(0.5) * (s + hi);
2470 const bool converged = next - s <= T(4) * eps *
Math::max(T(1), std::abs(s));
2500 const T z0 = a_y0 / a_e0;
2501 const T z1 = a_y1 / a_e1;
2502 const T g = z0 * z0 + z1 * z1 - T(1);
2508 const T r0 = (a_e0 / a_e1) * (a_e0 / a_e1);
2509 const T r[2]{r0, T(1)};
2510 const T n[2]{r0 * z0, z1};
2511 const T s = ellipsoidRoot<T, 2>(r, n, z1 - T(1), (g < T(0)) ? T(0) : std::sqrt(n[0] * n[0] + z1 * z1) - T(1));
2513 const T x0 = r0 * a_y0 / (s + r0);
2514 const T x1 = a_y1 / (s + T(1));
2516 return std::sqrt((x0 - a_y0) * (x0 - a_y0) + (x1 - a_y1) * (x1 - a_y1));
2519 return std::abs(a_y1 - a_e1);
2522 const T numer0 = a_e0 * a_y0;
2523 const T denom0 = a_e0 * a_e0 - a_e1 * a_e1;
2525 if (numer0 < denom0) {
2526 const T xde0 = numer0 / denom0;
2527 const T x0 = a_e0 * xde0;
2528 const T x1 = a_e1 * std::sqrt(
Math::max(T(0), T(1) - xde0 * xde0));
2530 return std::sqrt((x0 - a_y0) * (x0 - a_y0) + x1 * x1);
2533 return std::abs(a_y0 - a_e0);
2557ellipsoidDistance(
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
2562 const T z0 = a_y0 / a_e0;
2563 const T z1 = a_y1 / a_e1;
2564 const T z2 = a_y2 / a_e2;
2565 const T g = z0 * z0 + z1 * z1 + z2 * z2 - T(1);
2571 const T r0 = (a_e0 / a_e2) * (a_e0 / a_e2);
2572 const T r1 = (a_e1 / a_e2) * (a_e1 / a_e2);
2573 const T r[3]{r0, r1, T(1)};
2574 const T n[3]{r0 * z0, r1 * z1, z2};
2575 const T hi = (g < T(0)) ? T(0) : std::sqrt(n[0] * n[0] + n[1] * n[1] + z2 * z2) - T(1);
2576 const T s = ellipsoidRoot<T, 3>(r, n, z2 - T(1), hi);
2578 const T x0 = r0 * a_y0 / (s + r0);
2579 const T x1 = r1 * a_y1 / (s + r1);
2580 const T x2 = a_y2 / (s + T(1));
2582 return std::sqrt((x0 - a_y0) * (x0 - a_y0) + (x1 - a_y1) * (x1 - a_y1) + (x2 - a_y2) * (x2 - a_y2));
2592 return std::abs(a_y2 - a_e2);
2595 const T denom0 = a_e0 * a_e0 - a_e2 * a_e2;
2596 const T denom1 = a_e1 * a_e1 - a_e2 * a_e2;
2597 const T numer0 = a_e0 * a_y0;
2598 const T numer1 = a_e1 * a_y1;
2600 if (numer0 < denom0 && numer1 < denom1) {
2601 const T xde0 = numer0 / denom0;
2602 const T xde1 = numer1 / denom1;
2603 const T discr = T(1) - xde0 * xde0 - xde1 * xde1;
2606 const T x0 = a_e0 * xde0;
2607 const T x1 = a_e1 * xde1;
2608 const T x2 = a_e2 * std::sqrt(discr);
2610 return std::sqrt((x0 - a_y0) * (x0 - a_y0) + (x1 - a_y1) * (x1 - a_y1) + x2 * x2);
2633 static_assert(std::is_floating_point_v<T>,
"EllipsoidSDF<T>: T must be a floating-point type");
2654 "EllipsoidSDF: the center must be finite (%g, %g, %g)",
2655 double(a_center[0]),
2656 double(a_center[1]),
2657 double(a_center[2]));
2658 EBGEOMETRY_REQUIRE(AnalyticDetail::isFinite(a_radii) && a_radii[0] > T(0) && a_radii[1] > T(0) && a_radii[2] > T(0),
2659 "EllipsoidSDF: the radii must be finite and positive (%g, %g, %g)",
2662 double(a_radii[2]));
2730 T y[3]{std::abs(a_point[0] -
m_center[0]), std::abs(a_point[1] -
m_center[1]), std::abs(a_point[2] -
m_center[2])};
2732 const T inside = (y[0] / e[0]) * (y[0] / e[0]) + (y[1] / e[1]) * (y[1] / e[1]) + (y[2] / e[2]) * (y[2] / e[2]);
2735 const auto order = [&e, &y](
const size_t a_i,
const size_t a_j)
noexcept {
2736 if (e[a_i] < e[a_j]) {
2737 const T axis = e[a_i];
2738 const T coord = y[a_i];
2751 const T distance = AnalyticDetail::ellipsoidDistance(e[0], e[1], e[2], y[0], y[1], y[2]);
2753 return (inside < T(1)) ? -distance : distance;
2791 static_assert(std::is_floating_point_v<T>,
"CappedConeSDF<T>: T must be a floating-point type");
2814 "CappedConeSDF: the first center must be finite (%g, %g, %g)",
2815 double(a_center1[0]),
2816 double(a_center1[1]),
2817 double(a_center1[2]));
2819 "CappedConeSDF: the second center must be finite (%g, %g, %g)",
2820 double(a_center2[0]),
2821 double(a_center2[1]),
2822 double(a_center2[2]));
2824 "CappedConeSDF: the two centers must differ, but both are (%g, %g, %g)",
2825 double(a_center1[0]),
2826 double(a_center1[1]),
2827 double(a_center1[2]));
2828 EBGEOMETRY_REQUIRE(std::isfinite(a_radius1) && std::isfinite(a_radius2) && a_radius1 >= T(0) && a_radius2 >= T(0) &&
2829 a_radius1 + a_radius2 > T(0),
2830 "CappedConeSDF: the radii must be finite, at least 0 and not both 0 (%g, %g)",
2931 const T capY = std::abs(y - T(0.5) * h) - T(0.5) * h;
2937 const T sideY = y - f * h;
2939 const T sign = (sideX < T(0) && capY < T(0)) ? T(-1) : T(1);
2941 return sign * std::sqrt(
Math::min(capX * capX + capY * capY, sideX * sideX + sideY * sideY));
2971 const T capY = std::abs(y - T(0.5) * h) - T(0.5) * h;
2976 const T sideY = y - f * h;
2978 if (sideX * sideX + sideY * sideY <= capX * capX + capY * capY) {
2982 return (y < T(0.5) * h) ? 1U : 2U;
2998 for (
size_t dir = 0; dir < 3; dir++) {
3052 static_assert(std::is_floating_point_v<T>,
"RoundConeSDF<T>: T must be a floating-point type");
3077 "RoundConeSDF: the first center must be finite (%g, %g, %g)",
3078 double(a_center1[0]),
3079 double(a_center1[1]),
3080 double(a_center1[2]));
3082 "RoundConeSDF: the second center must be finite (%g, %g, %g)",
3083 double(a_center2[0]),
3084 double(a_center2[1]),
3085 double(a_center2[2]));
3086 EBGEOMETRY_REQUIRE(std::isfinite(a_radius1) && std::isfinite(a_radius2) && a_radius1 >= T(0) && a_radius2 >= T(0) &&
3087 a_radius1 + a_radius2 > T(0),
3088 "RoundConeSDF: the radii must be finite, at least 0 and not both 0 (%g, %g)",
3092 "RoundConeSDF: the difference of the radii (%g, %g) must be less than the distance between "
3096 double((a_center2 - a_center1).
length()));
3200 return std::sqrt(x * x + y * y) -
m_radius1;
3233 return (k < T(0)) ? 1U : ((k >
m_cos *
m_length) ? 2U : 0U);
3306 static_assert(std::is_floating_point_v<T>,
"PolygonPrismSDF<T>: T must be a floating-point type");
3332 const unsigned a_sides,
3336 "PolygonPrismSDF: the first center must be finite (%g, %g, %g)",
3337 double(a_center1[0]),
3338 double(a_center1[1]),
3339 double(a_center1[2]));
3341 "PolygonPrismSDF: the second center must be finite (%g, %g, %g)",
3342 double(a_center2[0]),
3343 double(a_center2[1]),
3344 double(a_center2[2]));
3346 "PolygonPrismSDF: the two centers must differ, but both are (%g, %g, %g)",
3347 double(a_center1[0]),
3348 double(a_center1[1]),
3349 double(a_center1[2]));
3351 "PolygonPrismSDF: the radius must be finite and positive (%g)",
3353 EBGEOMETRY_REQUIRE(a_sides >= 3U,
"PolygonPrismSDF: the number of sides must be at least 3 (%u)", a_sides);
3357 const Vec3T<T> across = a_vertexDirection -
dot(a_vertexDirection, axis) * axis;
3360 "PolygonPrismSDF: the vertex direction (%g, %g, %g) must have a part across the axis",
3361 double(a_vertexDirection[0]),
3362 double(a_vertexDirection[1]),
3363 double(a_vertexDirection[2]));
3469 const T half = pi<T> / T(
m_sides);
3472 const T angle = std::atan2(a_v, a_u);
3473 const T turn = angle - T(2) * half * std::floor(angle / (T(2) * half)) - half;
3474 const T r = std::sqrt(a_u * a_u + a_v * a_v);
3477 const T x = r * std::cos(turn) -
m_radius * std::cos(half);
3478 T y = r * std::abs(std::sin(turn)) -
m_radius * std::sin(half);
3482 const T
length = std::sqrt(x * x + y * y);
3535 if (profile >= slab) {
3536 const T sector = T(2) * pi<T> / T(
m_sides);
3537 T angle = std::atan2(v, u);
3540 angle += T(2) * pi<T>;
3561 for (
size_t dir = 0; dir < 3; dir++) {
3621 static_assert(std::is_floating_point_v<T>,
"TubeSDF<T>: T must be a floating-point type");
3645 "TubeSDF: the first center must be finite (%g, %g, %g)",
3646 double(a_center1[0]),
3647 double(a_center1[1]),
3648 double(a_center1[2]));
3650 "TubeSDF: the second center must be finite (%g, %g, %g)",
3651 double(a_center2[0]),
3652 double(a_center2[1]),
3653 double(a_center2[2]));
3655 "TubeSDF: the two centers must differ, but both are (%g, %g, %g)",
3656 double(a_center1[0]),
3657 double(a_center1[1]),
3658 double(a_center1[2]));
3659 EBGEOMETRY_REQUIRE(std::isfinite(a_outerRadius) && a_innerRadius > T(0) && a_innerRadius < a_outerRadius,
3660 "TubeSDF: the radii must satisfy 0 < inner (%g) < outer (%g)",
3661 double(a_innerRadius),
3662 double(a_outerRadius));
3787 if (annulus >= slab) {
3788 return (q.
m_radial >= middle) ? 0U : 1U;
3804 for (
size_t dir = 0; dir < 3; dir++) {
3857 static_assert(std::is_floating_point_v<T>,
"CappedTorusSDF<T>: T must be a floating-point type");
3881 "CappedTorusSDF: the center must be finite (%g, %g, %g)",
3882 double(a_center[0]),
3883 double(a_center[1]),
3884 double(a_center[2]));
3885 EBGEOMETRY_REQUIRE(std::isfinite(a_majorRadius) && a_minorRadius > T(0) && a_minorRadius < a_majorRadius,
3886 "CappedTorusSDF: the radii must satisfy 0 < minor (%g) < major (%g)",
3887 double(a_minorRadius),
3888 double(a_majorRadius));
3890 "CappedTorusSDF: the angle must be in (0, 360] degrees (%g)",
3897 m_whole = !(a_angle < T(360));
3898 m_cos = std::cos(T(0.5) * a_angle * pi<T> / T(180));
3899 m_sin = std::sin(T(0.5) * a_angle * pi<T> / T(180));
3984 const T rho = std::sqrt(p[0] * p[0] + p[2] * p[2]);
3995 const auto disc = [&p,
this](
const T a_sin)
noexcept {
3996 const T across = p[2] *
m_cos - p[0] * a_sin;
3997 const T radial = p[0] *
m_cos + p[2] * a_sin;
4001 return std::sqrt(across * across + rim * rim);
4007 if (p[0] >= rho *
m_cos) {
4008 return (torus >= T(0)) ? torus : -
Math::min(-torus, ends);
4039 const T rho = std::sqrt(p[0] * p[0] + p[2] * p[2]);
4042 const auto disc = [&p,
this](
const T a_sin)
noexcept {
4043 const T across = p[2] *
m_cos - p[0] * a_sin;
4044 const T radial = p[0] *
m_cos + p[2] * a_sin;
4048 return std::sqrt(across * across + rim * rim);
4051 const T positive = disc(
m_sin);
4052 const T negative = disc(-
m_sin);
4053 const uint32_t end = (positive <= negative) ? 1U : 2U;
4055 if (p[0] >= rho *
m_cos) {
4056 return (torus >= T(0) || -torus <=
Math::min(positive, negative)) ? 0U : end;
4077 const T zHigh = (
m_cos <= T(0)) ? outer : outer *
m_sin;
4132 static_assert(std::is_floating_point_v<T>,
"CutSphereSDF<T>: T must be a floating-point type");
4154 "CutSphereSDF: the center must be finite (%g, %g, %g)",
4155 double(a_center[0]),
4156 double(a_center[1]),
4157 double(a_center[2]));
4159 "CutSphereSDF: the radius must be finite and positive (%g)",
4162 "CutSphereSDF: the height (%g) must be between minus and plus the radius (%g)",
4169 m_rim = std::sqrt(a_radius * a_radius - a_height * a_height);
4243 const T x = std::sqrt(p[0] * p[0] + p[2] * p[2]);
4250 const T s =
Math::max((h - r) * x * x + w * w * (h + r - T(2) * y), h * x - w * y);
4253 return std::sqrt(x * x + y * y) - r;
4259 return std::sqrt((x - w) * (x - w) + (y - h) * (y - h));
4283 const T x = std::sqrt(p[0] * p[0] + p[2] * p[2]);
4289 return (s < T(0)) ? 0U : 1U;
4342 static_assert(std::is_floating_point_v<T>,
"CutHollowSphereSDF<T>: T must be a floating-point type");
4366 "CutHollowSphereSDF: the center must be finite (%g, %g, %g)",
4367 double(a_center[0]),
4368 double(a_center[1]),
4369 double(a_center[2]));
4371 "CutHollowSphereSDF: the radius must be finite and positive (%g)",
4374 "CutHollowSphereSDF: the height (%g) must be between minus and plus the radius (%g)",
4378 "CutHollowSphereSDF: the thickness (%g) must be positive and less than twice the radius (%g)",
4379 double(a_thickness),
4386 m_rim = std::sqrt(a_radius * a_radius - a_height * a_height);
4471 const T x = std::sqrt(p[0] * p[0] + p[2] * p[2]);
4476 : std::abs(std::sqrt(x * x + y * y) -
m_radius);
4502 const T x = std::sqrt(p[0] * p[0] + p[2] * p[2]);
4561 static_assert(std::is_floating_point_v<T>,
"WedgeSDF<T>: T must be a floating-point type");
4582 "WedgeSDF: the tip must be finite (%g, %g, %g)",
4587 a_angle > T(0) && a_angle < T(180),
"WedgeSDF: the angle must be in (0, 180) degrees (%g)",
double(a_angle));
4591 m_sin = std::sin(T(0.5) * a_angle * pi<T> / T(180));
4592 m_cos = std::cos(T(0.5) * a_angle * pi<T> / T(180));
4666 const T x = std::abs(a_point[0] -
m_tip[0]);
4667 const T y = a_point[1] -
m_tip[1];
4673 if (plane <= T(0) || along >= T(0)) {
4677 return std::sqrt(x * x + y * y);
4700 return (a_point[0] >=
m_tip[0]) ? 1U : 0U;
4758 static_assert(std::is_floating_point_v<T>,
"ConvexPolyhedronSDF<T>: T must be a floating-point type");
4872 const Vec3T<T>& a_vertexDirection);
4985 return m_edges[2U * a_edge + a_end];
5041 build(const std::vector<
Vec3T<
double>>& a_points, const std::vector<
Vec3T<
double>>& a_normals,
double a_epsilon);
5057 static std::vector<
Vec3T<T>>
5072 const std::vector<
Vec3T<T>>& a_vertexDirections,
5073 const std::vector<
Vec3T<T>>& a_normals,
5126 static_assert(std::is_floating_point_v<T>,
"BoxFrameSDF<T>: T must be a floating-point type");
5259 barTerms(
const Vec3T<T>& a_point)
const noexcept;
5274 T m_thickness = T(0.1);
5277namespace AnalyticDetail {
5293 std::vector<std::pair<uint32_t, uint32_t>>
m_edges;
5314 const std::vector<double>& a_offsets,
5315 const double a_epsilon,
5316 const double a_magnitude,
5319 const size_t numPlanes = a_normals.size();
5323 for (
const double h : a_offsets) {
5324 scale = Math::max(scale, std::abs(h));
5329 const double tol = 256.0 * a_epsilon * Math::max(scale + a_magnitude, 1.E-300);
5333 for (
size_t i = 0; i < numPlanes; i++) {
5334 for (
size_t j = i + 1; j < numPlanes; j++) {
5335 for (
size_t k = j + 1; k < numPlanes; k++) {
5341 const double det =
dot(a, bc);
5343 if (std::abs(det) < 1.E-12) {
5352 for (
size_t m = 0; m < numPlanes && behind; m++) {
5353 behind =
dot(a_normals[m], x) - a_offsets[m] <= tol;
5363 known = known || (v - x).
length() <= 10.0 * tol;
5373 const size_t numVertices = topology.
m_vertices.size();
5376 std::vector<std::vector<bool>> on(numVertices, std::vector<bool>(numPlanes,
false));
5378 for (
size_t v = 0; v < numVertices; v++) {
5379 for (
size_t m = 0; m < numPlanes; m++) {
5380 on[v][m] = std::abs(
dot(a_normals[m], topology.
m_vertices[v]) - a_offsets[m]) <= 10.0 * tol;
5384 for (
size_t m = 0; m < numPlanes; m++) {
5387 for (
size_t v = 0; v < numVertices; v++) {
5388 count += on[v][m] ? 1U : 0U;
5392 count >= 3U,
"%s: plane %zu does not bound a face of the solid, or the solid is not finite", a_who, m);
5395 for (
size_t v = 0; v < numVertices; v++) {
5396 for (
size_t w = v + 1; w < numVertices; w++) {
5399 for (
size_t m = 0; m < numPlanes; m++) {
5400 shared += (on[v][m] && on[w][m]) ? 1U : 0U;
5404 topology.
m_edges.emplace_back(uint32_t(v), uint32_t(w));
5410 "%s: the planes do not bound a finite solid with a volume (%zu vertices, %zu edges, %zu faces)",
5422inline std::vector<PlaneSDF<T>>
5425 std::vector<PlaneSDF<T>> planes;
5427 for (
size_t dir = 0; dir < 3; dir++) {
5428 for (
const T side : {T(-1), T(1)}) {
5447 std::vector<Vec3T<double>> points;
5448 std::vector<Vec3T<double>> normals;
5451 points.emplace_back(
double(plane.getPoint()[0]), double(plane.getPoint()[1]), double(plane.getPoint()[2]));
5452 normals.emplace_back(
double(plane.getNormal()[0]), double(plane.getNormal()[1]), double(plane.getNormal()[2]));
5462 const double a_epsilon)
5465 "ConvexPolyhedronSDF: a polyhedron has from 4 to %u planes (%zu)",
5480 reference = reference / double(a_points.size());
5482 std::vector<Vec3T<double>> normals;
5483 std::vector<double> offsets;
5485 for (
size_t k = 0; k < a_points.size(); k++) {
5490 "ConvexPolyhedronSDF: plane %zu must have a finite point and a finite, nonzero normal",
5494 offsets.push_back(
dot(normals.back(), point - reference));
5501 Math::max(std::abs(reference[0]),
Math::max(std::abs(reference[1]), std::abs(reference[2]))),
5502 "ConvexPolyhedronSDF");
5505 "ConvexPolyhedronSDF: a polyhedron has at most %u vertices (%zu)",
5506 unsigned(MaxVertices),
5509 m_numFaces = uint32_t(normals.size());
5510 m_numVertices = uint32_t(topology.
m_vertices.size());
5511 m_numEdges = uint32_t(topology.
m_edges.size());
5513 for (uint32_t f = 0; f < m_numFaces; f++) {
5514 m_normals[f] =
Vec3T<T>(T(normals[f][0]), T(normals[f][1]), T(normals[f][2]));
5515 m_offsets[f] = T(offsets[f] +
dot(normals[f], reference));
5518 for (uint32_t v = 0; v < m_numVertices; v++) {
5521 m_vertices[v] =
Vec3T<T>(T(x[0]), T(x[1]), T(x[2]));
5524 for (uint32_t e = 0; e < m_numEdges; e++) {
5525 m_edges[2U * e] = uint8_t(topology.
m_edges[e].first);
5526 m_edges[2U * e + 1U] = uint8_t(topology.
m_edges[e].second);
5533 const std::vector<
Vec3T<T>>& a_vertexDirections,
5534 const std::vector<
Vec3T<T>>& a_normals,
5539 "%s: the center must be finite (%g, %g, %g)",
5541 double(a_center[0]),
5542 double(a_center[1]),
5543 double(a_center[2]));
5545 "%s: the radius must be finite and positive (%g)",
5553 const auto unit = [](
const Vec3T<T>& a_v) {
5559 std::vector<Vec3T<double>> points;
5560 std::vector<Vec3T<double>> normals;
5562 for (
const Vec3T<T>& n : a_normals) {
5565 double height = -1.0;
5567 for (
const Vec3T<T>& d : a_vertexDirections) {
5571 points.push_back(center + height *
double(a_radius) *
normal);
5572 normals.push_back(
normal);
5586 const std::vector<Vec3T<T>> vertices{
Vec3T<T>(T(1), T(1), T(1)),
5591 std::vector<Vec3T<T>> normals;
5593 for (
const Vec3T<T>& v : vertices) {
5594 normals.push_back(-v);
5597 return fromNormals(a_center, vertices, normals, a_radius,
"ConvexPolyhedronSDF::tetrahedron");
5604 std::vector<Vec3T<T>> vertices;
5605 std::vector<Vec3T<T>> normals;
5607 for (
size_t dir = 0; dir < 3; dir++) {
5612 for (uint32_t f = 0; f < 8U; f++) {
5613 normals.emplace_back((f & 4U) ? T(-1) : T(1), (f & 2U) ? T(-1) : T(1), (f & 1U) ? T(-1) : T(1));
5616 return fromNormals(a_center, vertices, normals, a_radius,
"ConvexPolyhedronSDF::octahedron");
5620inline std::vector<Vec3T<T>>
5623 std::vector<Vec3T<T>> directions;
5625 for (
const T s : {T(1), T(-1)}) {
5626 for (
const T t : {T(1), T(-1)}) {
5627 directions.emplace_back(T(0), s * a_small, t * a_large);
5631 for (
const T s : {T(1), T(-1)}) {
5632 for (
const T t : {T(1), T(-1)}) {
5633 directions.emplace_back(s * a_small, t * a_large, T(0));
5637 for (
const T s : {T(1), T(-1)}) {
5638 for (
const T t : {T(1), T(-1)}) {
5639 directions.emplace_back(s * a_large, T(0), t * a_small);
5650 const T phi = (T(1) + std::sqrt(T(5))) / T(2);
5652 std::vector<Vec3T<T>> vertices;
5654 for (uint32_t c = 0; c < 8U; c++) {
5655 vertices.emplace_back((c & 4U) ? T(-1) : T(1), (c & 2U) ? T(-1) : T(1), (c & 1U) ? T(-1) : T(1));
5658 for (
const Vec3T<T>& v : goldenDirections(T(1) / phi, phi)) {
5659 vertices.push_back(v);
5662 return fromNormals(a_center, vertices, goldenDirections(phi, T(1)), a_radius,
"ConvexPolyhedronSDF::dodecahedron");
5669 const T phi = (T(1) + std::sqrt(T(5))) / T(2);
5671 std::vector<Vec3T<T>> normals;
5673 for (uint32_t c = 0; c < 8U; c++) {
5674 normals.emplace_back((c & 4U) ? T(-1) : T(1), (c & 2U) ? T(-1) : T(1), (c & 1U) ? T(-1) : T(1));
5677 for (
const Vec3T<T>& n : goldenDirections(phi, T(1) / phi)) {
5678 normals.push_back(n);
5681 return fromNormals(a_center, goldenDirections(T(1), phi), normals, a_radius,
"ConvexPolyhedronSDF::icosahedron");
5689 const unsigned a_sides,
5693 "ConvexPolyhedronSDF::pyramid: the base center must be finite (%g, %g, %g)",
5694 double(a_baseCenter[0]),
5695 double(a_baseCenter[1]),
5696 double(a_baseCenter[2]));
5698 "ConvexPolyhedronSDF::pyramid: the apex must be finite (%g, %g, %g)",
5703 (a_apex - a_baseCenter).
length() > T(0),
5704 "ConvexPolyhedronSDF::pyramid: the apex must differ from the base center, but both are (%g, %g, %g)",
5709 "ConvexPolyhedronSDF::pyramid: the radius must be finite and positive (%g)",
5712 "ConvexPolyhedronSDF::pyramid: the number of sides must be from 3 to %u (%u)",
5713 unsigned(MaxVertices - 1U),
5717 const auto toDouble = [](
const Vec3T<T>& a_v) {
5718 return Vec3T<double>(
double(a_v[0]),
double(a_v[1]),
double(a_v[2]));
5728 "ConvexPolyhedronSDF::pyramid: the vertex direction (%g, %g, %g) must have a part across the axis",
5729 double(a_vertexDirection[0]),
5730 double(a_vertexDirection[1]),
5731 double(a_vertexDirection[2]));
5736 std::vector<Vec3T<double>> corners;
5738 for (
unsigned k = 0; k < a_sides; k++) {
5739 const double angle = 2.0 * pi<double> * double(k) / double(a_sides);
5741 corners.push_back(base +
double(a_radius) * (std::cos(angle) * u + std::sin(angle) * v));
5744 std::vector<Vec3T<double>> points;
5745 std::vector<Vec3T<double>> normals;
5747 for (
unsigned k = 0; k < a_sides; k++) {
5758 points.push_back(a);
5762 points.push_back(base);
5763 normals.push_back(-axis);
5778 T best =
dot(m_normals[0], a_point) - m_offsets[0];
5780 for (uint32_t f = 1; f < m_numFaces; f++) {
5781 const T d =
dot(m_normals[f], a_point) - m_offsets[f];
5801 const uint32_t face = this->closestPart(a_point);
5802 const T d =
dot(m_normals[face], a_point) - m_offsets[face];
5811 const Vec3T<T> foot = a_point - d * m_normals[face];
5814 for (uint32_t f = 0; f < m_numFaces; f++) {
5815 if (f != face &&
dot(m_normals[f], foot) - m_offsets[f] > T(0)) {
5827 for (uint32_t e = 0; e < m_numEdges; e++) {
5828 const Vec3T<T>& a = m_vertices[m_edges[2U * e]];
5829 const Vec3T<T> ab = m_vertices[m_edges[2U * e + 1U]] - a;
5837 return std::sqrt(squared);
5848 for (uint32_t v = 1; v < m_numVertices; v++) {
5849 lo =
min(lo, m_vertices[v]);
5850 hi =
max(hi, m_vertices[v]);
5860 "BoxFrameSDF: the low corner must be finite (%g, %g, %g)",
5861 double(a_loCorner[0]),
5862 double(a_loCorner[1]),
5863 double(a_loCorner[2]));
5865 "BoxFrameSDF: the high corner must be finite (%g, %g, %g)",
5866 double(a_hiCorner[0]),
5867 double(a_hiCorner[1]),
5868 double(a_hiCorner[2]));
5870 a_loCorner[0] < a_hiCorner[0] && a_loCorner[1] < a_hiCorner[1] && a_loCorner[2] < a_hiCorner[2],
5871 "BoxFrameSDF: the low corner (%g, %g, %g) must be below the high corner (%g, %g, %g) in every direction",
5872 double(a_loCorner[0]),
5873 double(a_loCorner[1]),
5874 double(a_loCorner[2]),
5875 double(a_hiCorner[0]),
5876 double(a_hiCorner[1]),
5877 double(a_hiCorner[2]));
5879 const Vec3T<T> size = a_hiCorner - a_loCorner;
5882 EBGEOMETRY_REQUIRE(std::isfinite(a_thickness) && a_thickness > T(0) && T(2) * a_thickness < side,
5883 "BoxFrameSDF: the thickness must be positive and less than half the shortest side %g (%g)",
5885 double(a_thickness));
5887 m_loCorner = a_loCorner;
5888 m_hiCorner = a_hiCorner;
5889 m_thickness = a_thickness;
5897 const T e = T(0.5) * m_thickness;
5898 const Vec3T<T> c = T(0.5) * (m_loCorner + m_hiCorner);
5899 const Vec3T<T> b = T(0.5) * (m_hiCorner - m_loCorner);
5906 for (
size_t dir = 0; dir < 3; dir++) {
5907 p[dir] = std::abs(a_point[dir] - c[dir]) - b[dir];
5908 q[dir] = std::abs(p[dir] + e) - e;
5912 const auto bar = [](
const T a_x,
const T a_y,
const T a_z)
noexcept {
5920 return Vec3T<T>(bar(p[0], q[1], q[2]), bar(q[0], p[1], q[2]), bar(q[0], q[1], p[2]));
5932 const Vec3T<T> terms = this->barTerms(a_point);
5935 if (outside >= T(0)) {
5941 const Vec3T<T> c = T(0.5) * (m_loCorner + m_hiCorner);
5942 const Vec3T<T> b = T(0.5) * (m_hiCorner - m_loCorner);
5947 for (
size_t dir = 0; dir < 3; dir++) {
5948 depth[dir] = b[dir] - std::abs(a_point[dir] - c[dir]);
5949 opening[dir] =
Math::max(m_thickness - depth[dir], T(0));
5954 inside =
Math::min(inside, std::sqrt(opening[0] * opening[0] + opening[1] * opening[1]));
5955 inside =
Math::min(inside, std::sqrt(opening[0] * opening[0] + opening[2] * opening[2]));
5956 inside =
Math::min(inside, std::sqrt(opening[1] * opening[1] + opening[2] * opening[2]));
5966 const Vec3T<T> terms = this->barTerms(a_point);
5967 const Vec3T<T> c = T(0.5) * (m_loCorner + m_hiCorner);
5971 if (terms[1] < terms[axis]) {
5974 if (terms[2] < terms[axis]) {
5978 const uint32_t first = (axis == 0U) ? 1U : 0U;
5979 const uint32_t second = (axis == 2U) ? 1U : 2U;
5981 return 4U * axis + ((a_point[first] >= c[first]) ? 2U : 0U) + ((a_point[second] >= c[second]) ? 1U : 0U);
5984namespace AnalyticDetail {
6009 const T A2 = a_A * a_A;
6010 const T B2 = a_B * a_B;
6011 const T S = A2 + B2;
6013 if (!(a_y > T(0))) {
6014 const T foot = a_x * A2 / S;
6017 const T Y = a_B * std::sqrt(foot * foot / A2 - T(1));
6019 return std::sqrt((foot - a_x) * (foot - a_x) + Y * Y);
6022 return std::abs(a_x - a_A);
6025 if (!(a_x > T(0))) {
6026 const T Y = a_y * B2 / S;
6027 const T X = a_A * std::sqrt(T(1) + Y * Y / B2);
6029 return std::sqrt(X * X + (Y - a_y) * (Y - a_y));
6032 const T xA = a_x * a_A;
6033 const T yB = a_y * a_B;
6038 constexpr int MaxIterations = 160;
6046 for (
int i = 0; i < MaxIterations; i++) {
6047 const T first = xA / u;
6048 const T second = yB / (S - u);
6049 const T f = first * first - second * second - T(1);
6062 const T df = -T(2) * first * first / u - T(2) * second * second / (S - u);
6064 T next = u - f / df;
6066 if (!(next > lo && next < hi)) {
6067 next = T(0.5) * (lo + hi);
6070 const bool converged = std::abs(next - u) <= T(4) * eps * u;
6079 const T X = xA * a_A / u;
6080 const T Y = yB * a_B / (S - u);
6082 return std::sqrt((X - a_x) * (X - a_x) + (Y - a_y) * (Y - a_y));
6107 constexpr int MaxIterations = 64;
6109 const T P = T(2) * a_rho * (a_rho + a_y);
6110 const T Q = -T(2) * a_rho * a_rho * a_r;
6112 T s = std::sqrt(
Math::max(-P, T(0))) + std::cbrt(-Q);
6114 for (
int i = 0; i < MaxIterations; i++) {
6115 const T g = s * s * s + P * s + Q;
6116 const T slope = T(3) * s * s + P;
6118 if (!(g > T(0)) || !(slope > T(0))) {
6122 const T next =
Math::max(s - g / slope, T(0));
6131 const T dr = s - a_r;
6132 const T dy = a_y + s * s / (T(2) * a_rho);
6134 return std::sqrt(dr * dr + dy * dy);
6149pNorm(
const T a_a,
const T a_b,
const T a_p)
noexcept
6157 return m * std::pow(std::pow(a_a / m, a_p) + std::pow(a_b / m, a_p), T(1) / a_p);
6176[[nodiscard]]
inline T
6179 const auto factor = [](
const T a_e) {
return std::pow(T(2),
Math::max(T(0), T(0.5) * (a_e - T(1)))); };
6181 return Math::min(a_radii[0],
Math::min(a_radii[1], a_radii[2])) / (factor(a_exponent1) * factor(a_exponent2));
6200 const double rate = a_pitch / (2.0 * pi<double>);
6202 const auto squared = [&](
const double a_theta) {
6203 return 2.0 * a_radius * a_radius * (1.0 - std::cos(a_theta)) + rate * rate * a_theta * a_theta;
6206 constexpr int Samples = 4096;
6208 const double step = 4.0 * pi<double> / double(Samples);
6212 double prev = squared(step);
6214 while (i < Samples && squared(
double(i + 1) * step) >= prev) {
6216 prev = squared(
double(i) * step);
6224 double minimum = prev;
6226 for (
int j = i; j <= Samples; j++) {
6227 if (squared(
double(j) * step) < minimum) {
6228 minimum = squared(
double(j) * step);
6234 const double golden = 0.5 * (std::sqrt(5.0) - 1.0);
6236 double lo = double(best - 1) * step;
6237 double hi = double(best + 1) * step;
6239 for (
int k = 0; k < 100; k++) {
6240 const double a = hi - golden * (hi - lo);
6241 const double b = lo + golden * (hi - lo);
6243 if (squared(a) < squared(b)) {
6251 return std::sqrt(
Math::min(minimum, squared(0.5 * (lo + hi))));
6270 static_assert(std::is_floating_point_v<T>,
"QuadricSDF<T>: T must be a floating-point type");
6309 q.
m_c = T(
double(a_waist) / std::tan(0.5 *
double(a_angle) * pi<double> / 180.0));
6329 q.
m_c = a_tipDistance;
6330 q.
m_a = T(
double(a_tipDistance) * std::tan(0.5 *
double(a_angle) * pi<double> / 180.0));
6348 q.
m_a = a_tipRadius;
6349 q.
m_c = a_tipRadius;
6436 const T r = std::sqrt(w[0] * w[0] + w[2] * w[2]);
6440 const T d = AnalyticDetail::parabolaDistance(
m_a, r, y);
6442 return (y + r * r / (T(2) *
m_a) < T(0)) ? -d : d;
6447 const T X = oneSheet ? r : std::abs(y);
6448 const T Y = oneSheet ? std::abs(y) : r;
6449 const T A = oneSheet ?
m_a :
m_c;
6450 const T B = oneSheet ?
m_c :
m_a;
6452 const T d = AnalyticDetail::hyperbolaDistance(A, B, X, Y);
6453 const T g = (X / A) * (X / A) - (Y / B) * (Y / B) - T(1);
6454 const bool inside = oneSheet ? (g < T(0)) : (g > T(0));
6456 return inside ? -d : d;
6486 "%s: the center must be finite (%g, %g, %g)",
6488 double(a_center[0]),
6489 double(a_center[1]),
6490 double(a_center[2]));
6492 std::isfinite(a_size) && a_size > T(0),
"%s: the size must be finite and positive (%g)", a_who,
double(a_size));
6494 a_angle > T(0) && a_angle < T(180),
"%s: the angle must be in (0, 180) degrees (%g)", a_who,
double(a_angle));
6539 static_assert(std::is_floating_point_v<T>,
"SuperellipsoidSDF<T>: T must be a floating-point type");
6562 "SuperellipsoidSDF: the center must be finite (%g, %g, %g)",
6563 double(a_center[0]),
6564 double(a_center[1]),
6565 double(a_center[2]));
6566 EBGEOMETRY_REQUIRE(AnalyticDetail::isFinite(a_radii) && a_radii[0] > T(0) && a_radii[1] > T(0) && a_radii[2] > T(0),
6567 "SuperellipsoidSDF: the semi-axes must be finite and positive (%g, %g, %g)",
6570 double(a_radii[2]));
6571 EBGEOMETRY_REQUIRE(a_exponent1 >= T(0.1) && a_exponent1 <= T(2) && a_exponent2 >= T(0.1) && a_exponent2 <= T(2),
6572 "SuperellipsoidSDF: the exponents must be in [0.1, 2] (%g, %g)",
6573 double(a_exponent1),
6574 double(a_exponent2));
6580 m_scale = AnalyticDetail::superellipsoidScale(a_radii, a_exponent1, a_exponent2);
6643 const T x = std::abs(w[0] /
m_radii[0]);
6644 const T y = std::abs(w[1] /
m_radii[1]);
6645 const T z = std::abs(w[2] /
m_radii[2]);
6647 const T across = AnalyticDetail::pNorm(x, z, T(2) /
m_exponent2);
6649 return AnalyticDetail::pNorm(across, y, T(2) /
m_exponent1);
6717 static_assert(std::is_floating_point_v<T>,
"SolidAngleSDF<T>: T must be a floating-point type");
6739 "SolidAngleSDF: the center must be finite (%g, %g, %g)",
6740 double(a_center[0]),
6741 double(a_center[1]),
6742 double(a_center[2]));
6744 "SolidAngleSDF: the radius must be finite and positive (%g)",
6747 a_angle > T(0) && a_angle < T(360),
"SolidAngleSDF: the angle must be in (0, 360) degrees (%g)",
double(a_angle));
6752 m_sin = T(std::sin(0.5 *
double(a_angle) * pi<double> / 180.0));
6753 m_cos = T(std::cos(0.5 *
double(a_angle) * pi<double> / 180.0));
6829 this->
terms(a_point, sphere, side);
6857 this->
terms(a_point, sphere, side);
6859 return (sphere >= side) ? 0U : 1U;
6885 const T r = std::sqrt(w[0] * w[0] + w[2] * w[2]);
6889 const T dr = r - along *
m_sin;
6890 const T dy = y - along *
m_cos;
6893 a_sphere = std::sqrt(r * r + y * y) -
m_radius;
6894 a_side = std::sqrt(dr * dr + dy * dy) * ((
cross > T(0)) ? T(1) : ((
cross < T(0)) ? T(-1) : T(0)));
6934 static_assert(std::is_floating_point_v<T>,
"VesicaSDF<T>: T must be a floating-point type");
6956 EBGEOMETRY_REQUIRE(AnalyticDetail::isFinite(a_tip1) && AnalyticDetail::isFinite(a_tip2),
6957 "VesicaSDF: the tips must be finite (%g, %g, %g) and (%g, %g, %g)",
6965 const T half = T(0.5) * (a_tip2 - a_tip1).
length();
6968 "VesicaSDF: the two tips must differ, but both are (%g, %g, %g)",
6973 std::isfinite(a_radius) && a_radius > T(0) && a_radius < half,
6974 "VesicaSDF: the radius must be positive and less than half the distance between the tips %g (%g)",
7058 const T along =
dot(w, v);
7059 const T qx = (w - along * v).
length();
7060 const T qy = std::abs(along);
7061 const T half = T(0.5) *
length;
7067 if (half * qx < d * (qy - half)) {
7068 return std::sqrt(qx * qx + (qy - half) * (qy - half));
7071 return std::sqrt((qx + d) * (qx + d) + qy * qy) - (d +
m_radius);
7121 static_assert(std::is_floating_point_v<T>,
"HelixSDF<T>: T must be a floating-point type");
7148 const T a_helixRadius,
7150 const T a_tubeRadius,
7153 EBGEOMETRY_REQUIRE(AnalyticDetail::isFinite(a_center1) && AnalyticDetail::isFinite(a_center2),
7154 "HelixSDF: the centers must be finite (%g, %g, %g) and (%g, %g, %g)",
7155 double(a_center1[0]),
7156 double(a_center1[1]),
7157 double(a_center1[2]),
7158 double(a_center2[0]),
7159 double(a_center2[1]),
7160 double(a_center2[2]));
7165 "HelixSDF: the two centers must differ, but both are (%g, %g, %g)",
7166 double(a_center1[0]),
7167 double(a_center1[1]),
7168 double(a_center1[2]));
7170 "HelixSDF: the helix radius must be finite and positive (%g)",
7171 double(a_helixRadius));
7173 "HelixSDF: the number of turns must be finite and positive (%g)",
7176 const T apart = T(AnalyticDetail::helixTurnDistance(
double(a_helixRadius),
double(
length) /
double(a_turns)));
7178 EBGEOMETRY_REQUIRE(std::isfinite(a_tubeRadius) && a_tubeRadius > T(0) && a_tubeRadius < a_helixRadius &&
7179 T(2) * a_tubeRadius < apart,
7180 "HelixSDF: the tube radius must be positive and less than the helix radius %g and half the "
7181 "distance between turns %g (%g)",
7182 double(a_helixRadius),
7183 double(T(0.5) * apart),
7184 double(a_tubeRadius));
7187 const Vec3T<T> across = a_startDirection -
dot(a_startDirection, axis) * axis;
7190 "HelixSDF: the start direction (%g, %g, %g) must have a part across the axis",
7191 double(a_startDirection[0]),
7192 double(a_startDirection[1]),
7193 double(a_startDirection[2]));
7322 const T twoPi = T(2) * pi<T>;
7329 const T rho = std::sqrt(x * x + z * z);
7330 const T phi = std::atan2(z, x);
7334 const T last = twoPi *
m_turns;
7337 const T kLow = std::ceil((-pi<T> - phi) / twoPi);
7338 const T kHigh = std::floor((last + pi<T> - phi) / twoPi);
7339 const T kNear =
Math::clamp(std::round((y / rate - phi) / twoPi), kLow, kHigh);
7347 bool belowDone =
false;
7348 bool aboveDone =
false;
7350 const int count = 2 * int(kHigh - kLow) + 1;
7352 for (
int i = 0; i < count && !(belowDone && aboveDone); i++) {
7353 const bool below = (i % 2) == 1;
7354 const T step = T((i + 1) / 2);
7355 const T k = below ? kNear - step : kNear + step;
7357 if ((i > 0 && below && belowDone) || (i > 0 && !below && aboveDone)) {
7361 const T lo =
Math::max(phi + twoPi * k - T(0.5) * twoPi, T(0));
7362 const T hi =
Math::min(phi + twoPi * k + T(0.5) * twoPi, last);
7364 const T rule = across + gap * gap;
7366 if (k < kLow || k > kHigh || rule >= best) {
7418 windowMinimum(
const T a_k,
const T a_rho,
const T a_phi,
const T a_y,
const T a_rate,
const T a_last)
const noexcept
7420 const T halfTurn = pi<T>;
7421 const T base = a_phi + T(2) * halfTurn * a_k;
7422 const T Y = a_y - a_rate * base;
7424 const T rate2 = a_rate * a_rate;
7427 const T sLo =
Math::max(-halfTurn, -base);
7428 const T sHi =
Math::min(halfTurn, a_last - base);
7430 const auto f = [&](
const T a_s)
noexcept {
7431 const T v = Y - a_rate * a_s;
7433 return A - T(2) * rR * std::cos(a_s) + v * v;
7436 const auto g = [&](
const T a_s)
noexcept {
return rR * std::sin(a_s) + rate2 * a_s - a_rate * Y; };
7440 const T sc = (rR > rate2) ? std::acos(-rate2 / rR) : halfTurn;
7444 if (lo < hi && g(lo) < T(0) && g(hi) > T(0)) {
7445 constexpr int MaxIterations = 64;
7451 for (
int i = 0; i < MaxIterations; i++) {
7452 const T value = g(s);
7454 if (value == T(0)) {
7465 const T slope = rR * std::cos(s) + rate2;
7467 T next = (slope > T(0)) ? s - value / slope : T(0.5) * (lo + hi);
7469 if (!(next > lo && next < hi)) {
7470 next = T(0.5) * (lo + hi);
7473 const bool converged = std::abs(next - s) <= T(4) * eps *
Math::max(T(1), std::abs(s)) ||
7474 hi - lo <= T(4) * eps *
Math::max(T(1), std::abs(s));
7539 static_assert(std::is_floating_point_v<T>,
"LatticeSDF<T>: T must be a floating-point type");
7572 EBGEOMETRY_REQUIRE(AnalyticDetail::isFinite(a_cellSize) && a_cellSize[0] > T(0) && a_cellSize[1] > T(0) &&
7573 a_cellSize[2] > T(0),
7574 "LatticeSDF: the cell size must be finite and positive (%g, %g, %g)",
7575 double(a_cellSize[0]),
7576 double(a_cellSize[1]),
7577 double(a_cellSize[2]));
7579 const T smallest =
Math::min(a_cellSize[0],
Math::min(a_cellSize[1], a_cellSize[2]));
7581 EBGEOMETRY_REQUIRE(std::isfinite(a_thickness) && a_thickness > T(0) && a_thickness < smallest,
7582 "LatticeSDF: the thickness must be positive and less than the smallest cell size %g (%g)",
7584 double(a_thickness));
7587 "LatticeSDF: unknown kind %u",
7666 const T twoPi = T(2) * pi<T>;
7668 const T x = twoPi * a_point[0] /
m_cellSize[0];
7669 const T y = twoPi * a_point[1] /
m_cellSize[1];
7670 const T z = twoPi * a_point[2] /
m_cellSize[2];
7672 const T sx = std::sin(x);
7673 const T sy = std::sin(y);
7674 const T sz = std::sin(z);
7675 const T cx = std::cos(x);
7676 const T cy = std::cos(y);
7677 const T cz = std::cos(z);
7681 return cx + cy + cz;
7684 return sx * sy * sz + sx * cy * cz + cx * sy * cz + cx * cy * sz;
7687 return T(3) * (cx + cy + cz) + T(4) * cx * cy * cz;
7690 return sx * cy + sy * cz + sz * cx;
7743 T
m_scale = T(1) / (T(2) * pi<T> * T(1.7320508075688772));
7750static_assert(std::is_trivially_copyable_v<PlaneSDF<float>>,
"PlaneSDF<float> must be trivially copyable");
7751static_assert(std::is_trivially_copyable_v<PlaneSDF<double>>,
"PlaneSDF<double> must be trivially copyable");
7752static_assert(std::is_trivially_copyable_v<SphereSDF<float>>,
"SphereSDF<float> must be trivially copyable");
7753static_assert(std::is_trivially_copyable_v<SphereSDF<double>>,
"SphereSDF<double> must be trivially copyable");
7754static_assert(std::is_trivially_copyable_v<BoxSDF<float>>,
"BoxSDF<float> must be trivially copyable");
7755static_assert(std::is_trivially_copyable_v<BoxSDF<double>>,
"BoxSDF<double> must be trivially copyable");
7756static_assert(std::is_trivially_copyable_v<TorusSDF<float>>,
"TorusSDF<float> must be trivially copyable");
7757static_assert(std::is_trivially_copyable_v<TorusSDF<double>>,
"TorusSDF<double> must be trivially copyable");
7758static_assert(std::is_trivially_copyable_v<CylinderSDF<float>>,
"CylinderSDF<float> must be trivially copyable");
7759static_assert(std::is_trivially_copyable_v<CylinderSDF<double>>,
"CylinderSDF<double> must be trivially copyable");
7760static_assert(std::is_trivially_copyable_v<InfiniteCylinderSDF<float>>,
7761 "InfiniteCylinderSDF<float> must be trivially copyable");
7762static_assert(std::is_trivially_copyable_v<InfiniteCylinderSDF<double>>,
7763 "InfiniteCylinderSDF<double> must be trivially copyable");
7764static_assert(std::is_trivially_copyable_v<CapsuleSDF<float>>,
"CapsuleSDF<float> must be trivially copyable");
7765static_assert(std::is_trivially_copyable_v<CapsuleSDF<double>>,
"CapsuleSDF<double> must be trivially copyable");
7766static_assert(std::is_trivially_copyable_v<InfiniteConeSDF<float>>,
7767 "InfiniteConeSDF<float> must be trivially copyable");
7768static_assert(std::is_trivially_copyable_v<InfiniteConeSDF<double>>,
7769 "InfiniteConeSDF<double> must be trivially copyable");
7770static_assert(std::is_trivially_copyable_v<ConeSDF<float>>,
"ConeSDF<float> must be trivially copyable");
7771static_assert(std::is_trivially_copyable_v<ConeSDF<double>>,
"ConeSDF<double> must be trivially copyable");
7772static_assert(std::is_trivially_copyable_v<RoundedBoxSDF<float>>,
"RoundedBoxSDF<float> must be trivially copyable");
7773static_assert(std::is_trivially_copyable_v<RoundedBoxSDF<double>>,
"RoundedBoxSDF<double> must be trivially copyable");
7774static_assert(std::is_trivially_copyable_v<PerlinSDF<float>>,
"PerlinSDF<float> must be trivially copyable");
7775static_assert(std::is_trivially_copyable_v<PerlinSDF<double>>,
"PerlinSDF<double> must be trivially copyable");
7776static_assert(std::is_trivially_copyable_v<RoundedCylinderSDF<float>>,
7777 "RoundedCylinderSDF<float> must be trivially copyable");
7778static_assert(std::is_trivially_copyable_v<RoundedCylinderSDF<double>>,
7779 "RoundedCylinderSDF<double> must be trivially copyable");
7781static_assert(std::is_trivially_copyable_v<EllipsoidSDF<float>>,
"EllipsoidSDF<float> must be trivially copyable");
7782static_assert(std::is_trivially_copyable_v<EllipsoidSDF<double>>,
"EllipsoidSDF<double> must be trivially copyable");
7783static_assert(std::is_trivially_copyable_v<CappedConeSDF<float>>,
"CappedConeSDF<float> must be trivially copyable");
7784static_assert(std::is_trivially_copyable_v<CappedConeSDF<double>>,
"CappedConeSDF<double> must be trivially copyable");
7785static_assert(std::is_trivially_copyable_v<RoundConeSDF<float>>,
"RoundConeSDF<float> must be trivially copyable");
7786static_assert(std::is_trivially_copyable_v<RoundConeSDF<double>>,
"RoundConeSDF<double> must be trivially copyable");
7787static_assert(std::is_trivially_copyable_v<PolygonPrismSDF<float>>,
7788 "PolygonPrismSDF<float> must be trivially copyable");
7789static_assert(std::is_trivially_copyable_v<PolygonPrismSDF<double>>,
7790 "PolygonPrismSDF<double> must be trivially copyable");
7791static_assert(std::is_trivially_copyable_v<TubeSDF<float>>,
"TubeSDF<float> must be trivially copyable");
7792static_assert(std::is_trivially_copyable_v<TubeSDF<double>>,
"TubeSDF<double> must be trivially copyable");
7793static_assert(std::is_trivially_copyable_v<CappedTorusSDF<float>>,
"CappedTorusSDF<float> must be trivially copyable");
7794static_assert(std::is_trivially_copyable_v<CappedTorusSDF<double>>,
7795 "CappedTorusSDF<double> must be trivially copyable");
7796static_assert(std::is_trivially_copyable_v<CutSphereSDF<float>>,
"CutSphereSDF<float> must be trivially copyable");
7797static_assert(std::is_trivially_copyable_v<CutSphereSDF<double>>,
"CutSphereSDF<double> must be trivially copyable");
7798static_assert(std::is_trivially_copyable_v<CutHollowSphereSDF<float>>,
7799 "CutHollowSphereSDF<float> must be trivially copyable");
7800static_assert(std::is_trivially_copyable_v<CutHollowSphereSDF<double>>,
7801 "CutHollowSphereSDF<double> must be trivially copyable");
7802static_assert(std::is_trivially_copyable_v<WedgeSDF<float>>,
"WedgeSDF<float> must be trivially copyable");
7803static_assert(std::is_trivially_copyable_v<WedgeSDF<double>>,
"WedgeSDF<double> must be trivially copyable");
7805static_assert(std::is_trivially_copyable_v<ConvexPolyhedronSDF<float>>,
7806 "ConvexPolyhedronSDF<float> must be trivially copyable");
7807static_assert(std::is_trivially_copyable_v<ConvexPolyhedronSDF<double>>,
7808 "ConvexPolyhedronSDF<double> must be trivially copyable");
7809static_assert(std::is_trivially_copyable_v<BoxFrameSDF<float>>,
"BoxFrameSDF<float> must be trivially copyable");
7810static_assert(std::is_trivially_copyable_v<BoxFrameSDF<double>>,
"BoxFrameSDF<double> must be trivially copyable");
7811static_assert(std::is_trivially_copyable_v<QuadricSDF<float>>,
"QuadricSDF<float> must be trivially copyable");
7812static_assert(std::is_trivially_copyable_v<QuadricSDF<double>>,
"QuadricSDF<double> must be trivially copyable");
7813static_assert(std::is_trivially_copyable_v<SuperellipsoidSDF<float>>,
7814 "SuperellipsoidSDF<float> must be trivially copyable");
7815static_assert(std::is_trivially_copyable_v<SuperellipsoidSDF<double>>,
7816 "SuperellipsoidSDF<double> must be trivially copyable");
7817static_assert(std::is_trivially_copyable_v<SolidAngleSDF<float>>,
"SolidAngleSDF<float> must be trivially copyable");
7818static_assert(std::is_trivially_copyable_v<SolidAngleSDF<double>>,
"SolidAngleSDF<double> must be trivially copyable");
7819static_assert(std::is_trivially_copyable_v<VesicaSDF<float>>,
"VesicaSDF<float> must be trivially copyable");
7820static_assert(std::is_trivially_copyable_v<VesicaSDF<double>>,
"VesicaSDF<double> must be trivially copyable");
7821static_assert(std::is_trivially_copyable_v<HelixSDF<float>>,
"HelixSDF<float> must be trivially copyable");
7822static_assert(std::is_trivially_copyable_v<HelixSDF<double>>,
"HelixSDF<double> must be trivially copyable");
7823static_assert(std::is_trivially_copyable_v<LatticeSDF<float>>,
"LatticeSDF<float> must be trivially copyable");
7824static_assert(std::is_trivially_copyable_v<LatticeSDF<double>>,
"LatticeSDF<double> must be trivially copyable");
bool isFinite(const Vec3T< T > &a_point) noexcept
Checks that a point given to a constructor is finite.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2409
T 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,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2557
T superellipsoidScale(const Vec3T< T > &a_radii, const T a_exponent1, const T a_exponent2) noexcept
One over the largest slope of a superellipsoid's gauge: its smallest semi-axis, over the largest rati...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6177
T pNorm(const T a_a, const T a_b, const T a_p) noexcept
The p-norm (|a|^p + |b|^p)^(1/p) of two values at least 0, scaled by the larger so that no power over...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6149
T hyperbolaDistance(const T a_A, const T a_B, const T a_x, const T a_y) noexcept
The distance from a point to the branch X^2 / A^2 - Y^2 / B^2 = 1, X > 0, of a hyperbola,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6007
T parabolaDistance(const T a_rho, const T a_r, const T a_y) noexcept
The distance from a point to the parabola y = -r^2 / (2 rho), for a point with coordinates a_r >= 0 a...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6105
double helixTurnDistance(const double a_radius, const double a_pitch)
The closest distance between a helix' center line and its neighboring turns: twice the largest tube r...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6198
T 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,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2391
T 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...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2434
AxialCoordinates< T > 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.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2371
T 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...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2496
PolyhedronTopology polyhedronTopology(const std::vector< Vec3T< double > > &a_normals, const std::vector< double > &a_offsets, const double a_epsilon, const double a_magnitude, const char *a_who)
Finds the vertices and edges of the convex polyhedron behind a set of planes, and checks that every p...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5313
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_DEVICE_NOINLINE
Keep a function out of line in the device pass (CUDA/HIP); nothing on the host.
Definition EBGeometry_GPU.hpp:110
#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:200
#define EBGEOMETRY_EXPECT(cond)
Runtime precondition assertion for EBGeometry.
Definition EBGeometry_Macros.hpp:269
Scalar helpers and numeric limits that compile for both host and device.
Profiles: closed outlines of straight edges, circular arcs and quadratic Bezier curves in a plane (Pr...
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 the frame of a box: its twelve edges, as bars of square cross-section.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5125
Vec3T< T > barTerms(const Vec3T< T > &a_point) const noexcept
The three bars that meet at the corner of the octant a point is in: the signed distance to the one al...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5895
BoxFrameSDF & operator=(BoxFrameSDF &&)=default
Move assignment.
uint32_t closestPart(const Vec3T< T > &a_point) const noexcept
The part whose term decides the value at a point (see hasParts): the nearest bar, 4 a + 2 i + j for t...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5964
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the frame.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5926
const Vec3T< T > & getHighCorner() const noexcept
Get the upper corner of the box the frame fits.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5188
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box: the box the frame fits.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5241
BoxFrameSDF(const BoxFrameSDF &)=default
Copy constructor.
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): its twelve bars.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5219
const Vec3T< T > & getLowCorner() const noexcept
Get the lower corner of the box the frame fits.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5177
const T & getThickness() const noexcept
Get the thickness of a bar.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5199
BoxFrameSDF()=default
Default constructor. Constructs the frame of the cube [-0.5, 0.5]^3, with bars 0.1 thick.
BoxFrameSDF & operator=(const BoxFrameSDF &)=default
Copy assignment.
BoxFrameSDF(BoxFrameSDF &&)=default
Move constructor.
Signed distance field for an axis-aligned box (AABB).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:360
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:541
Vec3T< T > m_loCorner
Low box corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:550
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): 6.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:511
Vec3T< T > & getHighCorner() noexcept
Get upper-right corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:469
Vec3T< T > & getLowCorner() noexcept
Get lower-left corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:447
uint32_t closestPart(const Vec3T< T > &a_point) const noexcept
The part whose term decides the value at a point (see hasParts): 2 axis + 0 for the face at the low c...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:523
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:481
const Vec3T< T > & getHighCorner() const noexcept
Get upper-right corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:458
const Vec3T< T > & getLowCorner() const noexcept
Get lower-left corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:436
Vec3T< T > m_hiCorner
High box corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:555
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:367
BoxSDF(const Vec3T< T > &a_loCorner, const Vec3T< T > &a_hiCorner)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:380
BoxSDF(BoxSDF &&)=default
Move constructor.
Signed distance field for a capped cone (a frustum): a cone cut flat at both ends,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2790
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2797
CappedConeSDF(const CappedConeSDF &)=default
Copy constructor.
Vec3T< T > m_center1
Center of one end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3012
CappedConeSDF(const Vec3T< T > &a_center1, const Vec3T< T > &a_center2, const T a_radius1, const T a_radius2)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2811
Vec3T< T > m_axis
Unit axis from m_center1 to m_center2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3022
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): 3.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2950
CappedConeSDF()=default
Default constructor. Constructs a frustum from (0,-0.5,0) with radius 1 to (0,0.5,...
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2993
const T & getRadius2() const noexcept
Get the radius at m_center2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2905
const Vec3T< T > & getCenter1() const noexcept
Get the center of one end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2872
T m_length
Distance between the end centers.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3027
T m_radius1
Radius at m_center1.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3032
const Vec3T< T > & getCenter2() const noexcept
Get the center of the other end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2883
CappedConeSDF(CappedConeSDF &&)=default
Move constructor.
CappedConeSDF & operator=(const CappedConeSDF &)=default
Copy assignment.
T m_radius2
Radius at m_center2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3037
uint32_t closestPart(const Vec3T< T > &a_point) const noexcept
The part whose term decides the value at a point (see hasParts): 0 the slanted side,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2962
Vec3T< T > m_center2
Center of the other end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3017
const T & getRadius1() const noexcept
Get the radius at m_center1.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2894
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the frustum.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2917
CappedConeSDF & operator=(CappedConeSDF &&)=default
Move assignment.
Signed distance field for a capped torus: an arc of a torus with flat ends, such as a pipe elbow.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3856
T m_angle
The angle the arc sweeps, in degrees.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4102
const T & getMinorRadius() const noexcept
Get the minor (tube) radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3954
T m_minorRadius
Minor (tube) radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4097
T m_majorRadius
Major (ring) radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4092
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4070
const T & getAngle() const noexcept
Get the angle the arc sweeps, in degrees.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3965
CappedTorusSDF(const CappedTorusSDF &)=default
Copy constructor.
CappedTorusSDF()=default
Default constructor. Constructs an arc of 90 degrees, centered at the origin, with major radius 1 and...
CappedTorusSDF(CappedTorusSDF &&)=default
Move constructor.
T m_sin
Sine of half the arc's angle.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4112
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3863
T m_cos
Cosine of half the arc's angle.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4107
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): 3.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4020
const Vec3T< T > & getCenter() const noexcept
Get the center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3932
Vec3T< T > m_center
Center of the torus.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4087
CappedTorusSDF & operator=(CappedTorusSDF &&)=default
Move assignment.
CappedTorusSDF(const Vec3T< T > &a_center, const T a_majorRadius, const T a_minorRadius, const T a_angle)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3878
bool m_whole
Whether the arc is the whole torus, with no ends.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4117
const T & getMajorRadius() const noexcept
Get the major (ring) radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3943
uint32_t closestPart(const Vec3T< T > &a_point) const noexcept
The part whose term decides the value at a point (see hasParts): 0 the tube, 1 the end disc at the po...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4032
CappedTorusSDF & operator=(const CappedTorusSDF &)=default
Copy assignment.
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the capped torus.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3977
Signed distance field for a capsule (pill shape): a cylinder capped with hemispheres.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1186
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1193
const Vec3T< T > & getCenter2() const noexcept
Get the center of the second hemispherical cap.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1348
CapsuleSDF & operator=(const CapsuleSDF &)=default
Copy assignment.
Vec3T< T > m_center2
Center of the other hemispherical cap.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1373
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:1359
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1325
uint32_t closestPart(const Vec3T< T > &a_point) const noexcept
The part whose term decides the value at a point (see hasParts): 0 the side, 1 the hemisphere at the ...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1308
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the capsule.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1271
CapsuleSDF(const CapsuleSDF &)=default
Copy constructor.
CapsuleSDF & operator=(CapsuleSDF &&)=default
Move assignment.
T m_radius
Capsule radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1378
CapsuleSDF(const Vec3T< T > &a_tip1, const Vec3T< T > &a_tip2, const T &a_radius)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1213
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): 3.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1296
const Vec3T< T > & getCenter1() const noexcept
Get the center of the first hemispherical cap.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1337
CapsuleSDF(CapsuleSDF &&)=default
Move constructor.
Vec3T< T > m_center1
Center of one hemispherical cap.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1368
Signed distance field for a finite cone.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1524
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:1673
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1661
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the finite cone.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1595
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): 2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1630
uint32_t closestPart(const Vec3T< T > &a_point) const noexcept
The part whose term decides the value at a point (see hasParts): 0 the slanted side,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1642
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:1683
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1531
ConeSDF(const ConeSDF &)=default
Copy constructor.
ConeSDF(const Vec3T< T > &a_tip, const T &a_height, const T &a_angle)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1545
Vec2T< T > m_c
(sin, cos) of the half opening-angle. Default: 45° full angle → half-angle 22.5°.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1678
Signed distance field for a convex polyhedron: the intersection of the half-spaces behind a set of pl...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4757
static ConvexPolyhedronSDF fromNormals(const Vec3T< T > &a_center, const std::vector< Vec3T< T > > &a_vertexDirections, const std::vector< Vec3T< T > > &a_normals, T a_radius, const char *a_who)
A regular solid from the directions of its vertices and of its faces' normals: each face's plane is a...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5532
static std::vector< Vec3T< T > > goldenDirections(T a_small, T a_large)
The twelve directions (0, +-a, +-b), (+-a, +-b, 0) and (+-b, 0, +-a), in that order,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5621
ConvexPolyhedronSDF()
Default constructor. Constructs the cube [-0.5, 0.5]^3.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5441
ConvexPolyhedronSDF & operator=(ConvexPolyhedronSDF &&)=default
Move assignment.
const T & getOffset(const uint32_t a_face) const noexcept
Get the offset of a face's plane: the plane is the points x with dot(getNormal(a_face),...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4930
uint32_t closestPart(const Vec3T< T > &a_point) const noexcept
The part whose term decides the value at a point (see hasParts): the face whose plane is farthest abo...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5775
static ConvexPolyhedronSDF dodecahedron(const Vec3T< T > &a_center, T a_radius)
A regular dodecahedron.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5648
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box: that of its vertices.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5843
const Vec3T< T > & getNormal(const uint32_t a_face) const noexcept
Get the unit outward normal of a face.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4916
static constexpr uint32_t MaxEdges
The most edges a polyhedron can have, from Euler's formula: MaxFaces + MaxVertices - 2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4779
ConvexPolyhedronSDF(ConvexPolyhedronSDF &&)=default
Move constructor.
uint32_t getNumFaces() const noexcept
Get the number of faces.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4904
Array< Vec3T< T >, MaxVertices > m_vertices
The vertices.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5105
Array< Vec3T< T >, MaxFaces > m_normals
Unit outward normal of each face.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5095
static std::vector< PlaneSDF< T > > cubePlanes()
The six planes of the cube [-0.5, 0.5]^3, the default polyhedron.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5423
static constexpr uint32_t MaxFaces
The most faces a polyhedron can have: those of the icosahedron.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4769
uint32_t getEdgeVertex(const uint32_t a_edge, const uint32_t a_end) const noexcept
Get one end of an edge.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4981
uint32_t getNumVertices() const noexcept
Get the number of vertices.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4943
static ConvexPolyhedronSDF tetrahedron(const Vec3T< T > &a_center, T a_radius)
A regular tetrahedron.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5584
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4764
void build(const std::vector< Vec3T< double > > &a_points, const std::vector< Vec3T< double > > &a_normals, double a_epsilon)
Sets the polyhedron to the one bounded by planes given in double precision: finds its vertices and ed...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5460
ConvexPolyhedronSDF(const ConvexPolyhedronSDF &)=default
Copy constructor.
static constexpr uint32_t MaxVertices
The most vertices a polyhedron can have: those of the dodecahedron.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4774
uint32_t m_numVertices
Number of vertices.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5085
uint32_t m_numEdges
Number of edges.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5090
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): its faces, getNumFaces().
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5007
uint32_t m_numFaces
Number of faces.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5080
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the polyhedron.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5795
Array< T, MaxFaces > m_offsets
Offset of each face's plane along its normal.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5100
Array< uint8_t, 2U *MaxEdges > m_edges
The edges, as the indices of their two vertices: edge e from m_edges[2 e] to m_edges[2 e + 1].
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5110
static ConvexPolyhedronSDF icosahedron(const Vec3T< T > &a_center, T a_radius)
A regular icosahedron.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5667
ConvexPolyhedronSDF & operator=(const ConvexPolyhedronSDF &)=default
Copy assignment.
const Vec3T< T > & getVertex(const uint32_t a_vertex) const noexcept
Get a vertex.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4955
static ConvexPolyhedronSDF pyramid(const Vec3T< T > &a_baseCenter, const Vec3T< T > &a_apex, T a_radius, unsigned a_sides, const Vec3T< T > &a_vertexDirection)
A right pyramid on a regular polygon: a square pyramid with four sides, a tetrahedron-like one with t...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5686
static ConvexPolyhedronSDF octahedron(const Vec3T< T > &a_center, T a_radius)
A regular octahedron.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5602
uint32_t getNumEdges() const noexcept
Get the number of edges.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4968
Signed distance field for a cut hollow sphere: a spherical shell of some thickness,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4341
T m_radius
Radius of the shell's middle surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4531
CutHollowSphereSDF & operator=(const CutHollowSphereSDF &)=default
Copy assignment.
CutHollowSphereSDF(const Vec3T< T > &a_center, const T a_radius, const T a_height, const T a_thickness)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4363
CutHollowSphereSDF(const CutHollowSphereSDF &)=default
Copy constructor.
CutHollowSphereSDF(CutHollowSphereSDF &&)=default
Move constructor.
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): 2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4487
T m_height
Height of the cut plane above the center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4536
const T & getRadius() const noexcept
Get the radius of the shell's middle surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4430
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4513
CutHollowSphereSDF & operator=(CutHollowSphereSDF &&)=default
Move assignment.
CutHollowSphereSDF()=default
Default constructor. Constructs the upper half of a shell of thickness 0.1 around the unit sphere at ...
Vec3T< T > m_center
Center of the sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4526
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4348
T m_rim
Radius of the rim, sqrt(radius^2 - height^2).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4546
const T & getHeight() const noexcept
Get the height of the cut plane above the center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4441
uint32_t closestPart(const Vec3T< T > &a_point) const noexcept
The part whose term decides the value at a point (see hasParts): 0 the shell, 1 its rounded rim.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4499
const Vec3T< T > & getCenter() const noexcept
Get the center of the sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4419
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the cut hollow sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4464
T m_thickness
The shell's thickness.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4541
const T & getThickness() const noexcept
Get the shell's thickness.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4452
Signed distance field for a cut sphere: the part of a sphere above a horizontal plane,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4131
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): 2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4268
CutSphereSDF & operator=(const CutSphereSDF &)=default
Copy assignment.
const T & getHeight() const noexcept
Get the height of the cut plane above the center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4224
T m_radius
Radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4315
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the cut sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4236
CutSphereSDF(const CutSphereSDF &)=default
Copy constructor.
const T & getRadius() const noexcept
Get the radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4213
CutSphereSDF()=default
Default constructor. Constructs the upper half of the unit sphere at the origin.
CutSphereSDF(CutSphereSDF &&)=default
Move constructor.
CutSphereSDF(const Vec3T< T > &a_center, const T a_radius, const T a_height)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4151
T m_rim
Radius of the rim, sqrt(radius^2 - height^2).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4325
CutSphereSDF & operator=(CutSphereSDF &&)=default
Move assignment.
Vec3T< T > m_center
Center of the sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4310
T m_height
Height of the cut plane above the center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4320
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4138
uint32_t closestPart(const Vec3T< T > &a_point) const noexcept
The part whose term decides the value at a point (see hasParts): 0 the sphere, 1 the flat cut face (i...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4280
const Vec3T< T > & getCenter() const noexcept
Get the center of the sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4202
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4298
Signed distance field for a finite, flat-capped cylinder.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:766
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:962
T m_length
Distance between the two endpoints.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:997
Vec3T< T > m_center1
One endpoint (cap center).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:977
const Vec3T< T > & getCenter2() const noexcept
Get the other endpoint.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:858
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the cylinder.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:881
Vec3T< T > m_center2
Other endpoint (cap center).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:982
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:987
const T & getRadius() const noexcept
Get radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:869
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): 3.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:929
CylinderSDF(const Vec3T< T > &a_center1, const Vec3T< T > &a_center2, const T &a_radius)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:787
Vec3T< T > m_axis
Unit axis pointing from m_center1 to m_center2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:992
const Vec3T< T > & getCenter1() const noexcept
Get one endpoint.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:847
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:773
T m_radius
Cylinder radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1002
CylinderSDF(CylinderSDF &&)=default
Move constructor.
uint32_t closestPart(const Vec3T< T > &a_point) const noexcept
The part whose term decides the value at a point (see hasParts): 0 the side, 1 the cap at the first c...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:941
CylinderSDF & operator=(CylinderSDF &&)=default
Move assignment.
CylinderSDF & operator=(const CylinderSDF &)=default
Copy assignment.
Signed distance field for an ellipsoid with its semi-axes along x, y and z.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2632
EllipsoidSDF & operator=(EllipsoidSDF &&)=default
Move assignment.
EllipsoidSDF & operator=(const EllipsoidSDF &)=default
Copy assignment.
EllipsoidSDF(const Vec3T< T > &a_center, const Vec3T< T > &a_radii)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2651
Vec3T< T > m_radii
Semi-axes along x, y and z.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2776
EllipsoidSDF(const EllipsoidSDF &)=default
Copy constructor.
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2639
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2762
EllipsoidSDF()=default
Default constructor. Constructs the unit sphere at the origin.
const Vec3T< T > & getCenter() const noexcept
Get the center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2698
const Vec3T< T > & getRadii() const noexcept
Get the semi-axes.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2709
Vec3T< T > m_center
Center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2771
EllipsoidSDF(EllipsoidSDF &&)=default
Move constructor.
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the ellipsoid.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2723
Signed distance field for a helical tube: a spring, a coil or a thread, with rounded ends.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7120
HelixSDF(HelixSDF &&)=default
Move constructor.
T m_helixRadius
The helix radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7512
HelixSDF & operator=(const HelixSDF &)=default
Copy assignment.
const Vec3T< T > & getStartDirection() const noexcept
Get the unit direction from the axis to the center line at the first end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7289
Vec3T< T > centerLine(const T a_angle) const noexcept
Get the point on the center line at a helix angle.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7301
T m_tubeRadius
The tube's radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7522
Vec3T< T > m_center2
The axis point at the second end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7497
HelixSDF & operator=(HelixSDF &&)=default
Move assignment.
const Vec3T< T > & getCenter1() const noexcept
Get the axis point at the first end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7234
T m_turns
The number of turns.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7517
Vec3T< T > m_start
Unit direction to the center line at the first end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7507
const T & getTubeRadius() const noexcept
Get the tube radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7278
Vec3T< T > m_center1
The axis point at the first end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7492
HelixSDF(const Vec3T< T > &a_center1, const Vec3T< T > &a_center2, const T a_helixRadius, const T a_turns, const T a_tubeRadius, const Vec3T< T > &a_startDirection)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7146
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the helix.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7316
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7127
const T & getTurns() const noexcept
Get the number of turns.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7267
const T & getHelixRadius() const noexcept
Get the helix radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7256
const Vec3T< T > & getCenter2() const noexcept
Get the axis point at the second end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7245
Vec3T< T > m_axis
Unit axis from m_center1 to m_center2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7502
T windowMinimum(const T a_k, const T a_rho, const T a_phi, const T a_y, const T a_rate, const T a_last) const noexcept
The smallest squared distance from a point to the center line over one window of helix angles,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7418
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box: that of the cylinder the tube fits in.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7389
HelixSDF()=default
Default constructor. Constructs a helix from (0,-1,0) to (0,1,0) in 4 turns of radius 0....
HelixSDF(const HelixSDF &)=default
Copy constructor.
Signed distance field for an infinite cone.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1398
InfiniteConeSDF(const InfiniteConeSDF &)=default
Copy constructor.
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1489
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:1502
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1405
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the infinite cone.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1466
InfiniteConeSDF(const Vec3T< T > &a_tip, const T &a_angle)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1419
Vec2T< T > m_c
(sin, cos) of the half opening-angle. Default: 45° full angle → half-angle 22.5°.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1507
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:1016
T m_radius
Cylinder radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1159
InfiniteCylinderSDF & operator=(const InfiniteCylinderSDF &)=default
Copy assignment.
InfiniteCylinderSDF(const Vec3T< T > &a_center, const T &a_radius, const size_t a_axis)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1037
const size_t & getAxis() const noexcept
Get the coordinate axis the cylinder runs along.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1145
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the infinite cylinder.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1085
InfiniteCylinderSDF(const InfiniteCylinderSDF &)=default
Copy constructor.
Vec3T< T > m_center
Center point on the cylinder axis.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1154
InfiniteCylinderSDF(InfiniteCylinderSDF &&)=default
Move constructor.
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1106
const Vec3T< T > & getCenter() const noexcept
Get the point on the axis.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1123
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:1023
size_t m_axis
Coordinate axis index (0 = x, 1 = y, 2 = z).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1164
const T & getRadius() const noexcept
Get the radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1134
InfiniteCylinderSDF & operator=(InfiniteCylinderSDF &&)=default
Move assignment.
Signed distance field for a lattice of walls along a triply periodic minimal surface: a gyroid,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7538
LatticeSDF()=default
Default constructor. Constructs a gyroid of unit cells, with walls 0.1 thick.
T m_scale
One over the field's largest slope in space.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7743
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the lattice: a bound.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7702
Kind
Which surface, in coordinates scaled so that a cell is 2 pi.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7551
@ Neovius
3 (cos x + cos y + cos z) + 4 cos x cos y cos z.
@ SchwarzP
cos x + cos y + cos z.
@ Gyroid
sin x cos y + sin y cos z + sin z cos x.
@ SchwarzD
The diamond: sin x sin y sin z + sin x cos y cos z + cos x sin y cos z + cos x cos y sin z.
LatticeSDF(const Kind a_kind, const Vec3T< T > &a_cellSize, const T a_thickness)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7570
LatticeSDF(LatticeSDF &&)=default
Move constructor.
T field(const Vec3T< T > &a_point) const noexcept
The surface's field f at a point, zero on the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7664
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box: unbounded.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7717
Vec3T< T > m_cellSize
The cell size.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7733
Kind getKind() const noexcept
Get which surface this is.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7626
LatticeSDF(const LatticeSDF &)=default
Copy constructor.
const T & getThickness() const noexcept
Get the walls' thickness.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7648
LatticeSDF & operator=(LatticeSDF &&)=default
Move assignment.
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: never more than the Euclidean distance.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7545
LatticeSDF & operator=(const LatticeSDF &)=default
Copy assignment.
T m_thickness
The walls' thickness.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7738
const Vec3T< T > & getCellSize() const noexcept
Get the cell size.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7637
Kind m_kind
Which surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7728
Ken Perlin's gradient-noise implicit function.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1871
PerlinSDF(const T a_noiseAmplitude, const Vec3T< T > a_noiseFrequency, const T a_noisePersistence, const unsigned int a_noiseOctaves)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1896
Array< int, 512 > m_permutationTable
Integer hash permutation table (512 entries: [0..255] mirrored).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2052
unsigned int m_noiseOctaves
Number of noise octaves.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2057
Vec3T< T > m_noiseFrequency
Spatial noise frequency along each Cartesian axis.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2035
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:1879
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:1960
T noise(const Vec3T< T > &a_point) const noexcept
Single-octave Perlin noise evaluation.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2110
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:2095
T lerp(const T t, const T a, const T b) const noexcept
Ken Perlin's linear interpolation helper.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2068
Array< int, 512 > & getPermutationTable() noexcept
Get the internal permutation table.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2014
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:2080
PerlinSDF & operator=(PerlinSDF &&)=default
Move assignment.
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2026
T m_noiseAmplitude
Noise amplitude (output scale).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2040
PerlinSDF() noexcept
Default constructor. Constructs a single-octave Perlin noise field with unit amplitude,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1885
T m_noisePersistence
Per-octave amplitude decay factor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2045
void shuffle(URNG &g) noexcept
Shuffle the permutation table with the provided uniform random number generator.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1995
Signed distance function for a plane.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:69
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:76
const Vec3T< T > & getPoint() const noexcept
Get the point on the plane.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:171
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:160
PlaneSDF(const Vec3T< T > &a_point, const Vec3T< T > &a_normal)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:90
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the plane.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:143
PlaneSDF(const PlaneSDF &)=default
Copy constructor.
const Vec3T< T > & getNormal() const noexcept
Get the unit normal of the plane.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:182
PlaneSDF & operator=(PlaneSDF &&)=default
Move assignment.
PlaneSDF(PlaneSDF &&)=default
Move constructor.
Vec3T< T > m_point
Point on plane.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:191
Vec3T< T > m_normal
Plane normal vector (unit length).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:196
PlaneSDF & operator=(const PlaneSDF &)=default
Copy assignment.
Signed distance field for a regular prism: a regular polygon of n sides, extruded between two end cen...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3305
Vec3T< T > m_center2
Center of the other end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3577
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the prism.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3494
Vec3T< T > m_side
Unit direction across the axis and m_vertex, cross(m_axis, m_vertex).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3592
T m_length
Distance between the end centers.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3597
Vec3T< T > m_vertex
Unit direction from the axis toward the first vertex.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3587
Vec3T< T > m_axis
Unit axis from m_center1 to m_center2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3582
const Vec3T< T > & getCenter2() const noexcept
Get the center of the other end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3416
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3557
PolygonPrismSDF(const Vec3T< T > &a_center1, const Vec3T< T > &a_center2, const T a_radius, const unsigned a_sides, const Vec3T< T > &a_vertexDirection)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3329
Vec3T< T > m_center1
Center of one end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3572
PolygonPrismSDF & operator=(PolygonPrismSDF &&)=default
Move assignment.
T m_radius
Circumradius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3602
unsigned m_sides
Number of sides.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3607
PolygonPrismSDF(const PolygonPrismSDF &)=default
Copy constructor.
PolygonPrismSDF()=default
Default constructor. Constructs a hexagonal prism from (0,-0.5,0) to (0,0.5,0), of circumradius 1,...
const T & getRadius() const noexcept
Get the circumradius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3427
const Vec3T< T > & getCenter1() const noexcept
Get the center of one end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3405
const Vec3T< T > & getVertexDirection() const noexcept
Get the unit direction from the axis toward the first vertex, across the axis.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3449
PolygonPrismSDF & operator=(const PolygonPrismSDF &)=default
Copy assignment.
T polygonDistance(const T a_u, const T a_v) const noexcept
The signed distance to the polygon in the cross-section, at coordinates a_u along the vertex directio...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3467
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): the sides and the two caps, getSides() + 2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3513
unsigned getSides() const noexcept
Get the number of sides.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3438
uint32_t closestPart(const Vec3T< T > &a_point) const noexcept
The part whose term decides the value at a point (see hasParts): the side k from 0 to getSides() - 1,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3525
PolygonPrismSDF(PolygonPrismSDF &&)=default
Move constructor.
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3312
Signed distance field for a quadric of revolution around y: a hyperboloid of one sheet,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6269
QuadricSDF(QuadricSDF &&)=default
Move constructor.
const T & getA() const noexcept
Get the semi-axis across y, a, of a hyperboloid, or the tip radius of a paraboloid.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6406
T m_a
The semi-axis across y, a (a hyperboloid), or the tip radius rho (a paraboloid).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6516
static QuadricSDF hyperboloid(const Vec3T< T > &a_center, const T a_waist, const T a_angle)
A hyperboloid of one sheet around the y axis through the center: a waisted tower, unbounded along y.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6303
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6276
Kind m_kind
Which quadric.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6506
QuadricSDF(const QuadricSDF &)=default
Copy constructor.
const Vec3T< T > & getCenter() const noexcept
Get the center (a hyperboloid) or the tip (a paraboloid).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6395
QuadricSDF & operator=(const QuadricSDF &)=default
Copy assignment.
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box: unbounded, but above the tip of a paraboloid.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6465
static QuadricSDF paraboloid(const Vec3T< T > &a_tip, const T a_tipRadius)
A paraboloid around the y axis through its tip, opening toward -y, as the cones do,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6343
T m_c
The semi-axis along y, c (a hyperboloid); the tip radius for a paraboloid.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6521
QuadricSDF()=default
Default constructor. Constructs the paraboloid with its tip at the origin, opening toward -y,...
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the quadric.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6429
Vec3T< T > m_center
The center (a hyperboloid) or the tip (a paraboloid).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6511
Kind getKind() const noexcept
Get which quadric this is.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6384
QuadricSDF & operator=(QuadricSDF &&)=default
Move assignment.
static QuadricSDF hyperboloidTwoSheets(const Vec3T< T > &a_center, const T a_tipDistance, const T a_angle)
A hyperboloid of two sheets around the y axis through the center: two cups, with their tips on the ax...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6324
const T & getC() const noexcept
Get the semi-axis along y, c, of a hyperboloid; for a paraboloid, its tip radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6417
static QuadricSDF checked(const Vec3T< T > &a_center, const T a_size, const T a_angle, const char *a_who)
Checks a factory's arguments, and makes a quadric at the center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6483
Kind
Which quadric, with r the distance from the axis and y the height above the center (or the tip).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6282
@ HyperboloidOneSheet
r^2 / a^2 - y^2 / c^2 <= 1: a waisted tower, one piece.
@ HyperboloidTwoSheets
y^2 / c^2 - r^2 / a^2 >= 1: two cups facing away from each other.
@ Paraboloid
y <= -r^2 / (2 rho): a cup opening toward -y from its tip.
Signed distance field for a round cone: two spheres, of different radii, and the cone tangent to both...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3051
RoundConeSDF & operator=(RoundConeSDF &&)=default
Move assignment.
const T & getRadius1() const noexcept
Get the radius of the sphere at m_center1.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3160
const T & getRadius2() const noexcept
Get the radius of the sphere at m_center2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3171
T m_cos
Cosine of the cone's half-angle.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3288
RoundConeSDF()=default
Default constructor. Constructs a round cone from (0,-0.5,0) with radius 0.5 to (0,...
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3058
RoundConeSDF(const Vec3T< T > &a_center1, const Vec3T< T > &a_center2, const T a_radius1, const T a_radius2)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3074
Vec3T< T > m_axis
Unit axis from m_center1 to m_center2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3263
uint32_t closestPart(const Vec3T< T > &a_point) const noexcept
The part whose term decides the value at a point (see hasParts): 0 the slanted side,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3227
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): 3.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3215
Vec3T< T > m_center2
Center of the other sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3258
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box: the box around the two spheres.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3242
RoundConeSDF(RoundConeSDF &&)=default
Move constructor.
RoundConeSDF(const RoundConeSDF &)=default
Copy constructor.
T m_radius2
Radius of the sphere at m_center2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3278
T m_length
Distance between the centers.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3268
const Vec3T< T > & getCenter2() const noexcept
Get the center of the other sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3149
RoundConeSDF & operator=(const RoundConeSDF &)=default
Copy assignment.
T m_sin
Sine of the cone's half-angle, (m_radius1 - m_radius2) / m_length.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3283
Vec3T< T > m_center1
Center of one sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3253
T m_radius1
Radius of the sphere at m_center1.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3273
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the round cone.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3185
const Vec3T< T > & getCenter1() const noexcept
Get the center of one sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3138
Signed distance field for an axis-aligned box with rounded edges and corners.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1696
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:1828
T m_curvature
Corner rounding radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1839
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1703
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:1773
RoundedBoxSDF(const Vec3T< T > &a_center, const Vec3T< T > &a_size, const T a_curvature)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1718
uint32_t closestPart(const Vec3T< T > &a_point) const noexcept
The part whose term decides the value at a point (see hasParts): 2 axis + 0 for the face on the negat...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1810
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:1849
Vec3T< T > m_center
Box center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1844
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): 6.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1798
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:2173
RoundedCylinderSDF(RoundedCylinderSDF &&)=default
Move constructor.
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2307
uint32_t closestPart(const Vec3T< T > &a_point) const noexcept
The part whose term decides the value at a point (see hasParts): 0 the side, 1 the cap at -y,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2290
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2180
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:2334
RoundedCylinderSDF & operator=(const RoundedCylinderSDF &)=default
Copy assignment.
Vec3T< T > m_center
Cylinder center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2319
T m_majorRadius
Inner cylinder radius (= outer radius - curvature).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2324
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the rounded cylinder.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2258
RoundedCylinderSDF(const Vec3T< T > &a_center, const T a_radius, const T a_curvature, const T a_height)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2196
T m_minorRadius
Edge rounding radius (= curvature).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2329
RoundedCylinderSDF()=default
Default constructor. Constructs a rounded cylinder centered at the origin, axis along y,...
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): 3.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2278
Signed distance field for a solid angle: the part of a ball inside a cone from its center,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6716
SolidAngleSDF(SolidAngleSDF &&)=default
Move constructor.
const T & getAngle() const noexcept
Get the full opening angle, in degrees.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6808
SolidAngleSDF & operator=(const SolidAngleSDF &)=default
Copy assignment.
T m_cos
Cosine of half the opening angle.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6920
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6723
SolidAngleSDF()=default
Default constructor. Constructs a solid angle at the origin, with radius 1 and an opening of 60 degre...
SolidAngleSDF(const Vec3T< T > &a_center, const T a_radius, const T a_angle)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6736
const Vec3T< T > & getCenter() const noexcept
Get the center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6786
T m_radius
Radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6905
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box: that of the ball.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6868
SolidAngleSDF(const SolidAngleSDF &)=default
Copy constructor.
T m_angle
Full opening angle, in degrees.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6910
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.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6852
const T & getRadius() const noexcept
Get the radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6797
Vec3T< T > m_center
Center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6900
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the solid angle.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6820
SolidAngleSDF & operator=(SolidAngleSDF &&)=default
Move assignment.
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): 2, the spherical cap (0) and the cone's side (1).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6840
T m_sin
Sine of half the opening angle.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6915
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.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6882
Signed distance field for a sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:208
Vec3T< T > & getCenter() noexcept
Get sphere center (mutable).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:283
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:317
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:333
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:215
const Vec3T< T > & getCenter() const noexcept
Get sphere center (const).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:272
Vec3T< T > m_center
Sphere center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:342
T m_radius
Sphere radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:347
const T & getRadius() const noexcept
Get sphere radius (const).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:294
SphereSDF(SphereSDF &&)=default
Move constructor.
SphereSDF(const SphereSDF &)=default
Copy constructor.
T & getRadius() noexcept
Get sphere radius (mutable).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:305
SphereSDF(const Vec3T< T > &a_center, const T &a_radius)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:227
Signed distance field for a superellipsoid (Barr's superquadric): from an ellipsoid to a rounded box,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6538
const Vec3T< T > & getRadii() const noexcept
Get the semi-axes.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6624
SuperellipsoidSDF & operator=(const SuperellipsoidSDF &)=default
Copy assignment.
T gauge(const Vec3T< T > &a_point) const noexcept
The superquadric's gauge at a point: below 1 inside, 1 on the surface, above 1 outside.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6640
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the superellipsoid: a bound.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6659
T m_scale
One over the gauge's largest slope.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6703
SuperellipsoidSDF(const Vec3T< T > &a_center, const Vec3T< T > &a_radii, const T a_exponent1, const T a_exponent2)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6559
T m_exponent2
The exponent across it.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6698
SuperellipsoidSDF()=default
Default constructor. Constructs a superellipsoid at the origin, with semi-axes 1 and both exponents 0...
SuperellipsoidSDF(const SuperellipsoidSDF &)=default
Copy constructor.
SuperellipsoidSDF & operator=(SuperellipsoidSDF &&)=default
Move assignment.
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: never more than the Euclidean distance.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6545
SuperellipsoidSDF(SuperellipsoidSDF &&)=default
Move constructor.
Vec3T< T > m_center
Center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6683
Vec3T< T > m_radii
Semi-axes.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6688
T m_exponent1
The exponent through the y axis.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6693
const Vec3T< T > & getCenter() const noexcept
Get the center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6613
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box: the center plus and minus the semi-axes.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6674
Signed distance field for a torus.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:571
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:710
T m_minorRadius
Minor (tube) radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:752
Vec3T< T > & getCenter() noexcept
Get torus center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:655
T m_majorRadius
Major (ring) radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:747
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:578
const T & getMinorRadius() const noexcept
Get minor radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:688
TorusSDF(TorusSDF &&)=default
Move constructor.
TorusSDF(const TorusSDF &)=default
Copy constructor.
const T & getMajorRadius() const noexcept
Get major radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:666
T & getMajorRadius() noexcept
Get major radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:677
Vec3T< T > m_center
Torus center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:742
TorusSDF(const Vec3T< T > &a_center, const T &a_majorRadius, const T &a_minorRadius)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:591
TorusSDF & operator=(TorusSDF &&)=default
Move assignment.
T & getMinorRadius() noexcept
Get minor radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:699
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:644
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:730
Signed distance field for a tube (a pipe): the space between two coaxial cylinders,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3620
Vec3T< T > m_axis
Unit axis from m_center1 to m_center2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3825
TubeSDF & operator=(TubeSDF &&)=default
Move assignment.
uint32_t closestPart(const Vec3T< T > &a_point) const noexcept
The part whose term decides the value at a point (see hasParts): 0 the outer wall,...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3779
TubeSDF & operator=(const TubeSDF &)=default
Copy assignment.
const T & getInnerRadius() const noexcept
Get the inner radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3724
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box: the box of the outer cylinder.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3800
TubeSDF(const TubeSDF &)=default
Copy constructor.
const Vec3T< T > & getCenter2() const noexcept
Get the center of the other end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3713
TubeSDF()=default
Default constructor. Constructs a tube from (0,-0.5,0) to (0,0.5,0), with inner radius 0....
T m_length
Distance between the end centers.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3830
const T & getOuterRadius() const noexcept
Get the outer radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3735
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): 4.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3767
TubeSDF(TubeSDF &&)=default
Move constructor.
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3627
T m_outerRadius
Outer radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3840
const Vec3T< T > & getCenter1() const noexcept
Get the center of one end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3702
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the tube.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3747
TubeSDF(const Vec3T< T > &a_center1, const Vec3T< T > &a_center2, const T a_innerRadius, const T a_outerRadius)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3642
Vec3T< T > m_center2
Center of the other end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3820
T m_innerRadius
Inner radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3835
Vec3T< T > m_center1
Center of one end.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:3815
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.
Signed distance field for a revolved vesica: a lens between two tips, the vesica (the overlap of two ...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6933
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7080
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the vesica.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7047
VesicaSDF(VesicaSDF &&)=default
Move constructor.
VesicaSDF()=default
Default constructor. Constructs a vesica from (0,-1,0) to (0,1,0), with radius 0.5.
VesicaSDF & operator=(const VesicaSDF &)=default
Copy assignment.
const Vec3T< T > & getTip2() const noexcept
Get the other tip.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7024
VesicaSDF(const VesicaSDF &)=default
Copy constructor.
Vec3T< T > m_tip2
The other tip.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7095
T m_radius
Radius at the middle.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7100
const T & getRadius() const noexcept
Get the radius at the middle.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7035
const Vec3T< T > & getTip1() const noexcept
Get one tip.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7013
Vec3T< T > m_tip1
One tip.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:7090
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6940
VesicaSDF(const Vec3T< T > &a_tip1, const Vec3T< T > &a_tip2, const T a_radius)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:6954
VesicaSDF & operator=(VesicaSDF &&)=default
Move assignment.
Signed distance field for an infinite wedge: a knife edge.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4560
T signedDistance(const Vec3T< T > &a_point) const noexcept
Signed distance function for the wedge.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4659
WedgeSDF & operator=(const WedgeSDF &)=default
Copy assignment.
WedgeSDF()=default
Default constructor. Constructs a wedge with its tip at the origin and an opening of 60 degrees.
WedgeSDF(const Vec3T< T > &a_tip, const T a_angle)
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4579
T m_sin
Sine of half the opening angle.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4730
const T & getAngle() const noexcept
Get the opening angle, in degrees.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4636
BoundingVolumes::AABBT< T > computeBoundingVolume() const noexcept
The shape's axis-aligned bounding box: unbounded but above the tip.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4709
WedgeSDF & operator=(WedgeSDF &&)=default
Move assignment.
WedgeSDF(const WedgeSDF &)=default
Copy constructor.
uint32_t closestPart(const Vec3T< T > &a_point) const noexcept
The part whose term decides the value at a point (see hasParts): 0 the face on the -x side of the tip...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4698
uint32_t getNumParts() const noexcept
How many parts the shape has (see hasParts): 2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4686
Vec3T< T > getFaceNormal() const noexcept
The unit outward normal of the face on the +x side; the other face's is mirrored in x.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4647
Vec3T< T > m_tip
A point on the edge.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4720
WedgeSDF(WedgeSDF &&)=default
Move constructor.
static constexpr DistanceQuality distanceQuality
How far signedDistance() can be trusted as a distance: the Euclidean distance to the surface.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4567
T m_cos
Cosine of half the opening angle.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4735
const Vec3T< T > & getTip() const noexcept
Get the tip, a point on the edge.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4625
T m_angle
The opening angle, in degrees.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:4725
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.
constexpr Vec3T< T > cross(const Vec3T< T > &u, const Vec3T< T > &v) noexcept
Cross product of two 3D vectors.
T dot(const Vec2T< T > &u, const Vec2T< T > &v) noexcept
Dot product of two 2D vectors.
Vec3T< T > normal(const F &a_function, const Vec3T< T > &a_point, const T &a_delta) noexcept
Outward unit normal of a function's level set, by central finite differences.
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.
@ Bound
The value's magnitude never exceeds the distance to the surface: it may underestimate,...
@ 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.
A point's coordinates around an axis: its distance from the axis line, and its position along it.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2346
T m_radial
Distance from the axis line (never negative).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2350
T m_axial
Position along the axis, from the axis' start point.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:2355
A convex polyhedron's faces, vertices and edges, found on the host from its planes in double precisio...
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5284
std::vector< std::pair< uint32_t, uint32_t > > m_edges
The edges, as pairs of vertex indices.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5293
std::vector< Vec3T< double > > m_vertices
The vertices.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:5288
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