EBGeometry 1.0
Loading...
Searching...
No Matches
EBGeometry_AnalyticDistanceFunctions.hpp
Go to the documentation of this file.
1/* EBGeometry
2 * Copyright © 2022 Robert Marskar
3 * Please refer to Copyright.txt and LICENSE in the EBGeometry root directory.
4 */
5
15#ifndef EBGeometry_AnalyticDistanceFunctions
16#define EBGeometry_AnalyticDistanceFunctions
17
18// Std includes
19#include <algorithm>
20#include <random>
21
22// Our includes
26
34template <class T>
35constexpr const T
36clamp(const T& v, const T& lo, const T& hi)
37{
38 return (v < lo) ? lo : (v > hi) ? hi : v;
39}
40
48template <class T>
49constexpr const Vec3T<T>
50clamp(const Vec3T<T>& v, const Vec3T<T>& lo, const Vec3T<T>& hi)
51{
52 return Vec3T<T>(clamp(v[0], lo[0], hi[0]), clamp(v[1], lo[1], hi[1]), clamp(v[2], lo[2], hi[2]));
53}
54
58constexpr static std::array<int, 256> s_perlinPermutationTable = {
59 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142,
60 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203,
61 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165,
62 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41,
63 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89,
64 18, 169, 200, 196, 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250,
65 124, 123, 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189,
66 28, 42, 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9,
67 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228, 251, 34,
68 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31,
69 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, 93, 222, 114,
70 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180};
71
75template <class T>
77{
78public:
82 PlaneSDF() = delete;
83
89 PlaneSDF(const Vec3T<T>& a_point, const Vec3T<T>& a_normal) noexcept
90 {
93 }
94
99 virtual T
100 signedDistance(const Vec3T<T>& a_point) const noexcept override
101 {
102 return dot((a_point - m_point), m_normal);
103 }
104
105protected:
110
115};
116
120template <class T>
122{
123public:
127 SphereSDF() = delete;
128
134 SphereSDF(const Vec3T<T>& a_center, const T& a_radius) noexcept
135 {
136 this->m_center = a_center;
137 this->m_radius = a_radius;
138 }
139
143 SphereSDF(const SphereSDF& a_other) noexcept
144 {
145 this->m_center = a_other.m_center;
146 this->m_radius = a_other.m_radius;
147 }
148
153
157 const Vec3T<T>&
159 {
160 return m_center;
161 }
162
166 Vec3T<T>&
168 {
169 return m_center;
170 }
171
175 const T&
177 {
178 return m_radius;
179 }
180
184 T&
186 {
187 return m_radius;
188 }
189
194 virtual T
195 signedDistance(const Vec3T<T>& a_point) const noexcept override
196 {
197 return (a_point - m_center).length() - m_radius;
198 }
199
200protected:
205
210};
211
215template <class T>
217{
218public:
222 BoxSDF() = delete;
223
230 {
231 this->m_loCorner = a_loCorner;
232 this->m_hiCorner = a_hiCorner;
233 }
234
239 {}
240
245 const Vec3T<T>&
247 {
248 return m_loCorner;
249 }
250
255 Vec3T<T>&
257 {
258 return m_loCorner;
259 }
260
265 const Vec3T<T>&
267 {
268 return m_hiCorner;
269 }
270
275 Vec3T<T>&
277 {
278 return m_hiCorner;
279 }
280
285 virtual T
286 signedDistance(const Vec3T<T>& a_point) const noexcept override
287 {
288 // For each coordinate direction, we have delta[dir] if a_point[dir] falls
289 // between xLo and xHi. In this case delta[dir] will be the signed distance
290 // to the closest box face in the dir-direction. Otherwise, if a_point[dir]
291 // is outside the corner we have delta[dir] > 0.
292 const Vec3T<T> delta(std::max(m_loCorner[0] - a_point[0], a_point[0] - m_hiCorner[0]),
293 std::max(m_loCorner[1] - a_point[1], a_point[1] - m_hiCorner[1]),
294 std::max(m_loCorner[2] - a_point[2], a_point[2] - m_hiCorner[2]));
295
296 // Note: max is max(Vec3T<T>, Vec3T<T>) and not std::max. It returns a
297 // vector with coordinate-wise largest components. Note that the first part
298 // std::min(...) is the signed distance on the inside of the box (delta will
299 // have negative components). The other part max(Vec3T<T>::zero(), ...) is
300 // for outside the box.
301 const T d = std::min(T(0.0), delta[delta.maxDir(false)]) + max(Vec3T<T>::zero(), delta).length();
302
303 return d;
304 }
305
306protected:
311
316};
317
322template <class T>
324{
325public:
329 TorusSDF() = delete;
330
337 TorusSDF(const Vec3T<T>& a_center, const T& a_majorRadius, const T& a_minorRadius) noexcept
338 {
339 this->m_center = a_center;
342 }
343
348 {}
349
354 const Vec3T<T>&
356 {
357 return m_center;
358 }
359
364 Vec3T<T>&
366 {
367 return m_center;
368 }
369
374 const T&
376 {
377 return m_majorRadius;
378 }
379
384 T&
386 {
387 return m_majorRadius;
388 }
389
394 const T&
396 {
397 return m_minorRadius;
398 }
399
404 T&
406 {
407 return m_minorRadius;
408 }
413 virtual T
414 signedDistance(const Vec3T<T>& a_point) const noexcept override
415 {
416 const Vec3T<T> p = a_point - m_center;
417 const T rho = sqrt(p[0] * p[0] + p[1] * p[1]) - m_majorRadius;
418 const T d = sqrt(rho * rho + p[2] * p[2]) - m_minorRadius;
419
420 return d;
421 }
422
423protected:
428
433
438};
439
443template <class T>
445{
446public:
450 CylinderSDF() = delete;
451
458 CylinderSDF(const Vec3T<T>& a_center1, const Vec3T<T>& a_center2, const T& a_radius) noexcept
459 {
460 this->m_center1 = a_center1;
461 this->m_center2 = a_center2;
462 this->m_radius = a_radius;
463
464 // Some derived quantities that are needed for SDF computations.
465 m_center = (m_center2 + m_center1) * 0.5;
468 }
469
474 {}
475
480 const Vec3T<T>&
482 {
483 return m_center1;
484 }
485
490 const Vec3T<T>&
492 {
493 return m_center2;
494 }
495
500 const T&
502 {
503 return m_radius;
504 }
505
510 virtual T
511 signedDistance(const Vec3T<T>& a_point) const noexcept override
512 {
513 T d = std::numeric_limits<T>::infinity();
514
515 if (m_length > 0.0 && m_radius > 0.0) {
516 const Vec3T<T> point = a_point - m_center;
517 const T para = dot(point, m_axis);
518 const Vec3T<T> ortho = point - para * m_axis; // Distance from cylinder axis.
519
520 const T w = ortho.length() - m_radius; // Distance from cylinder wall. < 0
521 // on inside and > 0 on outside.
522 const T h = std::abs(para) - 0.5 * m_length; // Distance from cylinder top. < 0 on
523 // inside and > 0 on outside.
524
525 constexpr T zero = T(0.0);
526
527 if (w <= zero && h <= zero) { // Inside cylinder
528 d = (std::abs(w) < std::abs(h)) ? w : h;
529 }
530 else if (w <= zero && h > zero) { // Above one of the endcaps.
531 d = h;
532 }
533 else if (w > zero && h < zero) { // Outside radius but between the
534 // endcaps.
535 d = w;
536 }
537 else {
538 d = sqrt(w * w + h * h);
539 }
540 }
541
542 return d;
543 }
544
545protected:
550
555
560
565
570
575};
576
580template <class T>
582{
583public:
588
595 InfiniteCylinderSDF(const Vec3T<T>& a_center, const T& a_radius, const size_t a_axis) noexcept
596 {
599 m_axis = a_axis;
600 }
601
606 virtual T
607 signedDistance(const Vec3T<T>& a_point) const noexcept override
608 {
610 delta[m_axis] = 0.0;
611
612 const T d = delta.length() - m_radius;
613
614 return d;
615 }
616
617protected:
622
627
631 size_t m_axis;
632};
633
638template <class T>
640{
641public:
645 CapsuleSDF() = delete;
646
653 CapsuleSDF(const Vec3T<T>& a_tip1, const Vec3T<T> a_tip2, const T& a_radius) noexcept
654 {
655 const Vec3T<T> axis = (a_tip2 - a_tip1) / length(a_tip2 - a_tip1);
659 }
660
665 virtual T
666 signedDistance(const Vec3T<T>& a_point) const noexcept override
667 {
668 const Vec3T<T> v1 = a_point - m_center1;
669 const Vec3T<T> v2 = m_center2 - m_center1;
670
671 const T h = clamp(dot(v1, v2) / dot(v2, v2), T(0.0), T(1.0));
672 const T d = length(v1 - h * v2) - m_radius;
673
674 return d;
675 }
676
677protected:
682
687
692};
693
697template <class T>
699{
700public:
704 InfiniteConeSDF() = delete;
705
711 InfiniteConeSDF(const Vec3T<T>& a_tip, const T& a_angle) noexcept
712 {
713 constexpr T pi = 3.14159265358979323846;
714
715 m_tip = a_tip;
716 m_c.x = std::sin(0.5 * a_angle * pi / 180.0);
717 m_c.y = std::cos(0.5 * a_angle * pi / 180.0);
718 }
719
724 {}
725
730 virtual T
731 signedDistance(const Vec3T<T>& a_point) const noexcept override
732 {
733 const Vec3T<T> delta = a_point - m_tip;
734 const Vec2T<T> q(sqrt(delta[0] * delta[0] + delta[1] * delta[1]), -delta[2]);
735
736 const T d1 = length(q - m_c * std::max(dot(q, m_c), T(0.0)));
737 const T d2 = d1 * ((q.x * m_c.y - q.y * m_c.x < 0.0) ? -1.0 : 1.0);
738
739 return d2;
740 }
741
742protected:
747
752};
753
757template <class T>
759{
760public:
764 ConeSDF() = delete;
765
772 ConeSDF(const Vec3T<T>& a_tip, const T& a_height, const T& a_angle) noexcept
773 {
774 constexpr T pi = 3.14159265358979323846;
775
776 m_tip = a_tip;
778 m_c.x = std::sin(0.5 * a_angle * pi / 180.0);
779 m_c.y = std::cos(0.5 * a_angle * pi / 180.0);
780 }
781
785 virtual ~ConeSDF()
786 {}
787
792 virtual T
793 signedDistance(const Vec3T<T>& a_point) const noexcept override
794 {
795 const Vec3T<T> delta = a_point - m_tip;
796 const T dr = sqrt(delta[0] * delta[0] + delta[1] * delta[1]);
797 const T dz = delta[2];
798
799 constexpr T zero = T(0.0);
800 constexpr T one = T(1.0);
801
802 const Vec2T<T> q = m_height * Vec2T<T>(m_c.x / m_c.y, -1.0);
803 const Vec2T<T> w = Vec2T<T>(dr, dz);
804 const Vec2T<T> a = w - clamp(dot(w, q) / dot(q, q), zero, one) * q;
805 const Vec2T<T> b = w - Vec2T<T>(q.x * clamp(w.x / q.x, zero, one), q.y);
806
807 auto sign = [](const T& x) { return (x > zero) - (x < zero); };
808
809 const T k = sign(q.y);
810 const T d = std::min(dot(a, a), dot(b, b));
811 const T s = std::max(k * (w.x * q.y - w.y * q.x), k * (w.y - q.y));
812
813 return sqrt(d) * sign(s);
814 }
815
816protected:
821
826
831};
832
836template <class T>
838{
839public:
843 RoundedBoxSDF() = delete;
844
853 {
854 this->m_dimensions = 0.5 * a_dimensions;
855
856 m_sphere = std::make_shared<SphereSDF<T>>(Vec3T<T>::zero(), a_curvature);
857 }
858
863 {}
864
868 virtual T
869 signedDistance(const Vec3T<T>& a_point) const noexcept override
870 {
872 }
873
874protected:
878 std::shared_ptr<SphereSDF<T>> m_sphere;
879
884};
885
889template <class T>
891{
892public:
902 const T a_noisePersistence,
903 const unsigned int a_noiseOctaves) noexcept
904 {
907 m_noisePersistence = std::min(1.0, a_noisePersistence);
908 m_noiseOctaves = std::max(static_cast<unsigned int>(1), a_noiseOctaves);
909
910 // By default, use Ken Perlin's original permutation table
911 for (int i = 0; i < 256; i++) {
912 m_permutationTable[i] = s_perlinPermutationTable[i];
913 m_permutationTable[i + 256] = s_perlinPermutationTable[i];
914 }
915
916#if 1 // Development code
917 std::random_device rd;
918 std::mt19937 g(0);
919
920 this->shuffle(g);
921#endif
922 }
923
928 {}
929
934 virtual T
935 signedDistance(const Vec3T<T>& a_point) const noexcept override
936 {
937 T ret = 0.0;
938
940 T curAmp = 1.0;
941
942 for (unsigned int curOctave = 0; curOctave < m_noiseOctaves; curOctave++) {
943 ret += 0.5 * curAmp * (1 + this->noise(a_point * curFreq));
944
947 }
948
949 return ret * m_noiseAmplitude;
950 };
951
960 template <class URNG>
961 void
962 shuffle(URNG& g) noexcept
963 {
964
965 for (unsigned int i = 0; i < 256; i++) {
967 }
968
969 std::shuffle(m_permutationTable.begin(), m_permutationTable.begin() + 256, g);
970
971 for (int i = 0; i < 256; i++) {
973 }
974 }
975
980 std::array<int, 512>&
985
986protected:
991
996
1001
1005 std::array<T, 512> m_permutationTable;
1006
1010 unsigned int m_noiseOctaves;
1011
1018 virtual T
1019 lerp(const T t, const T a, const T b) const noexcept
1020 {
1021 return a + t * (b - a);
1022 };
1023
1028 virtual T
1029 fade(const T t) const noexcept
1030 {
1031 return t * t * t * (t * (t * 6 - 15) + 10);
1032 };
1033
1041 T
1042 grad(const int hash, const T x, const T y, const T z) const noexcept
1043 {
1044 const int h = hash & 15;
1045 const T u = h < 8 ? x : y;
1046 const T v = h < 4 ? y : h == 12 || h == 14 ? x : y;
1047 return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v);
1048 }
1049
1054 T
1055 noise(const Vec3T<T>& a_point) const noexcept
1056 {
1057 // Lower cube corner
1058 const int X = static_cast<int>(std::floor(a_point[0])) & 255;
1059 const int Y = static_cast<int>(std::floor(a_point[1])) & 255;
1060 const int Z = static_cast<int>(std::floor(a_point[2])) & 255;
1061
1062 // Relative distance wrt lower cube corner
1063 const double x = a_point[0] - std::floor(a_point[0]);
1064 const double y = a_point[1] - std::floor(a_point[1]);
1065 const double z = a_point[2] - std::floor(a_point[2]);
1066
1067 // Fade curves
1068 const double u = fade(x);
1069 const double v = fade(y);
1070 const double w = fade(z);
1071
1072 // Hash coordinates of 8 cube corners
1073 const int A = m_permutationTable[X] + Y;
1074 const int AA = m_permutationTable[A] + Z;
1075 const int AB = m_permutationTable[A + 1] + Z;
1076 const int B = m_permutationTable[X + 1] + Y;
1077 const int BA = m_permutationTable[B] + Z;
1078 const int BB = m_permutationTable[B + 1] + Z;
1079
1080 // Add blended results from 8 corners of cube
1081 return lerp(
1082 w,
1083 lerp(v,
1084 lerp(u, grad(m_permutationTable[AA], x, y, z), grad(m_permutationTable[BA], x - 1, y, z)),
1085 lerp(u, grad(m_permutationTable[AB], x, y - 1, z), grad(m_permutationTable[BB], x - 1, y - 1, z))),
1086 lerp(v,
1087 lerp(u, grad(m_permutationTable[AA + 1], x, y, z - 1), grad(m_permutationTable[BA + 1], x - 1, y, z - 1)),
1088 lerp(u,
1089 grad(m_permutationTable[AB + 1], x, y - 1, z - 1),
1090 grad(m_permutationTable[BB + 1], x - 1, y - 1, z - 1))));
1091 };
1092};
1093
1095
1096#endif
constexpr const T clamp(const T &v, const T &lo, const T &hi)
Clamp function. Returns lo if v < lo and hi if v > hi. Otherwise returns v.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:36
Declaration of a various bounding volumes used for bounding volume hierarchy.
Abstract base class for representing a signed distance function.
Vec2T< T > max(const Vec2T< T > &u, const Vec2T< T > &v) noexcept
Maximum function. Returns new vector with component-wise minimums.
T length(const Vec2T< T > &v) noexcept
Length function.
T dot(const Vec2T< T > &u, const Vec2T< T > &v) noexcept
Dot product function.
Signed distance field for an axis-aligned box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:217
const Vec3T< T > & getHighCorner() const noexcept
Get upper-right corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:266
Vec3T< T > & getLowCorner() noexcept
Get lower-left corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:256
BoxSDF()=delete
Disallowed default constructor.
Vec3T< T > & getHighCorner() noexcept
Get upper-right corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:276
virtual T signedDistance(const Vec3T< T > &a_point) const noexcept override
Signed distance function for sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:286
Vec3T< T > m_loCorner
Low box corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:310
Vec3T< T > m_hiCorner
High box corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:315
const Vec3T< T > & getLowCorner() const noexcept
Get lower-left corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:246
BoxSDF(const Vec3T< T > &a_loCorner, const Vec3T< T > &a_hiCorner) noexcept
Full constructor. Sets the low and high corner.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:229
virtual ~BoxSDF() noexcept
Destructor (does nothing).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:238
Capsulate/pill SDF. Basically a cylinder with spherical endcaps, oriented along the specified axis.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:640
virtual T signedDistance(const Vec3T< T > &a_point) const noexcept override
Implementation of the signed distance function.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:666
Vec3T< T > m_center1
Capsule center1.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:681
CapsuleSDF(const Vec3T< T > &a_tip1, const Vec3T< T > a_tip2, const T &a_radius) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:653
T m_radius
Capsule radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:691
Vec3T< T > m_center2
Capsule center2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:686
CapsuleSDF()=delete
No weak construction.
Signed distance field for an finite cone. Oriented along +z.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:759
T m_height
Cone height.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:830
virtual ~ConeSDF()
Destructor – does nothing.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:785
virtual T signedDistance(const Vec3T< T > &a_point) const noexcept override
Implementation of the signed distance function.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:793
Vec3T< T > m_tip
Tip position.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:820
Vec2T< T > m_c
Sine/cosine of angle.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:825
ConeSDF(const Vec3T< T > &a_tip, const T &a_height, const T &a_angle) noexcept
Finite cone function.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:772
ConeSDF()=delete
Disallowed weak construction.
Signed distance field for a cylinder.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:445
Vec3T< T > m_center2
The other endpoint.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:554
Vec3T< T > m_axis
"Axis", pointing from m_center1 to m_center2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:564
virtual T signedDistance(const Vec3T< T > &a_point) const noexcept override
Signed distance function for a torus.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:511
const Vec3T< T > & getCenter1() const noexcept
Get one endpoint.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:481
Vec3T< T > m_center
Halfway between center1 and m_center2.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:559
const Vec3T< T > & getCenter2() const noexcept
Get the other endpoint.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:491
CylinderSDF()=delete
Disallowed weak construction. Use one of the full constructors.
CylinderSDF(const Vec3T< T > &a_center1, const Vec3T< T > &a_center2, const T &a_radius) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:458
T m_length
Cylinder length.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:569
virtual ~CylinderSDF() noexcept
Destructor (does nothing).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:473
Vec3T< T > m_center1
One endpoint.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:549
T m_radius
radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:574
const T & getRadius() const noexcept
Get radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:501
Signed distance field for an infinite cone. Oriented along +z.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:699
Vec2T< T > m_c
Sine/cosine of angle.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:751
InfiniteConeSDF()=delete
Disallowed weak construction.
InfiniteConeSDF(const Vec3T< T > &a_tip, const T &a_angle) noexcept
Infinite cone function.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:711
virtual T signedDistance(const Vec3T< T > &a_point) const noexcept override
Implementation of the signed distance function.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:731
virtual ~InfiniteConeSDF()
Destructor – does nothing.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:723
Vec3T< T > m_tip
Tip position.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:746
Inifinitely long cylinder class. Oriented along the y-axis.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:582
Vec3T< T > m_center
Cylinder center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:621
virtual T signedDistance(const Vec3T< T > &a_point) const noexcept override
Signed distance function.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:607
InfiniteCylinderSDF(const Vec3T< T > &a_center, const T &a_radius, const size_t a_axis) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:595
T m_radius
Cylinder radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:626
InfiniteCylinderSDF()=delete
No weak construction.
size_t m_axis
Axis.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:631
Ken Perlins gradient noise function.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:891
void shuffle(URNG &g) noexcept
Shuffle the permutation with the input RNG.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:962
unsigned int m_noiseOctaves
Number of noise octaves.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1010
T m_noisePersistence
Noise persistence.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1000
virtual T fade(const T t) const noexcept
Ken Perlin's fade function.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1029
virtual ~PerlinSDF() noexcept
Destructor (does nothing)
Definition EBGeometry_AnalyticDistanceFunctions.hpp:927
PerlinSDF(const T a_noiseAmplitude, const Vec3T< T > a_noiseFrequency, const T a_noisePersistence, const unsigned int a_noiseOctaves) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:900
T noise(const Vec3T< T > &a_point) const noexcept
Octave noise function.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1055
T grad(const int hash, const T x, const T y, const T z) const noexcept
Ken Perlins grad function.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1042
std::array< T, 512 > m_permutationTable
Permutation table.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1005
virtual T lerp(const T t, const T a, const T b) const noexcept
Ken Perlin's lerp function.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:1019
std::array< int, 512 > & getPermutationTable() noexcept
Get the internal permutation table.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:981
Vec3T< T > m_noiseFrequency
Noise frequency.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:990
T m_noiseAmplitude
Noise amplitude.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:995
virtual T signedDistance(const Vec3T< T > &a_point) const noexcept override
Signed distance function. Generates a distance on [0,curAmplitude].
Definition EBGeometry_AnalyticDistanceFunctions.hpp:935
Signed distance function for a plane.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:77
Vec3T< T > m_normal
Plane normal vector.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:114
PlaneSDF(const Vec3T< T > &a_point, const Vec3T< T > &a_normal) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:89
Vec3T< T > m_point
Point on plane.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:109
virtual T signedDistance(const Vec3T< T > &a_point) const noexcept override
Signed distance function for sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:100
PlaneSDF()=delete
Disallowed weak construction.
Box of arbitrary dimensions centered at the origin, with rounded corners.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:838
std::shared_ptr< SphereSDF< T > > m_sphere
Sphere at origin with radius a_curvature.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:878
RoundedBoxSDF(const Vec3T< T > &a_dimensions, const T a_curvature) noexcept
Full constructor. User inputs dimensions and corner curvature.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:852
RoundedBoxSDF()=delete
Disallowed default constructor.
virtual ~RoundedBoxSDF() noexcept
Destructor (does nothing).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:862
virtual T signedDistance(const Vec3T< T > &a_point) const noexcept override
Signed distance function for the rounded box.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:869
Vec3T< T > m_dimensions
Box dimensions.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:883
Abstract representation of a signed distance function.
Definition EBGeometry_SignedDistanceFunction.hpp:32
Signed distance field for sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:122
const T & getRadius() const noexcept
Get radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:176
virtual ~SphereSDF() noexcept=default
Destructor.
SphereSDF(const Vec3T< T > &a_center, const T &a_radius) noexcept
Default constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:134
Vec3T< T > & getCenter() noexcept
Get center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:167
virtual T signedDistance(const Vec3T< T > &a_point) const noexcept override
Signed distance function for sphere.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:195
SphereSDF(const SphereSDF &a_other) noexcept
Copy constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:143
Vec3T< T > m_center
Sphere center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:204
const Vec3T< T > & getCenter() const noexcept
Get center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:158
T m_radius
Sphere radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:209
SphereSDF()=delete
Disallowed weak construction.
T & getRadius() noexcept
Get radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:185
Signed distance field for a torus.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:324
Vec3T< T > & getCenter() noexcept
Get torus center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:365
T m_majorRadius
Major torus radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:432
virtual T signedDistance(const Vec3T< T > &a_point) const noexcept override
Signed distance function for a torus.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:414
TorusSDF()=delete
Disallowed weak construction.
const Vec3T< T > & getCenter() const noexcept
Get torus center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:355
const T & getMajorRadius() const noexcept
Get major radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:375
T & getMajorRadius() noexcept
Get major radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:385
TorusSDF(const Vec3T< T > &a_center, const T &a_majorRadius, const T &a_minorRadius) noexcept
Full constructor.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:337
Vec3T< T > m_center
Torus center.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:427
const T & getMinorRadius() const noexcept
Get minor radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:395
virtual ~TorusSDF() noexcept
Destructor (does nothing).
Definition EBGeometry_AnalyticDistanceFunctions.hpp:347
T & getMinorRadius() noexcept
Get minor radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:405
T m_minorRadius
Minor torus radius.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:437
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:218
constexpr T length() const noexcept
Compute vector length.
size_t maxDir(const bool a_doAbs) const noexcept
Return the direction which has the largest component (can be absolute)
static constexpr Vec3T< T > zero() noexcept
Return av vector with x = y = z = 0.