19#ifndef PECLET_CORE_GEOM_SDF_HPP
20#define PECLET_CORE_GEOM_SDF_HPP
32 return {a[0] - b[0], a[1] - b[1], a[2] - b[2]};
35 return std::sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
71 const double r = std::sqrt(
d[
a0] *
d[
a0] +
d[
a1] *
d[
a1]);
88 for (
int i = 0;
i < 3; ++
i) {
92 g[
i] = (shape.eval(
pp) - shape.eval(
pm)) / (2.0 * h);
97#if defined(__cpp_concepts)
101 { s.eval(p) } -> std::convertible_to<double>;
double norm(const Vec< 3 > &a)
Vec< 3 > sub(const Vec< 3 > &a, const Vec< 3 > &b)
Vec< 3 > gradient(const S &shape, const Vec< 3 > &p, double h=1e-4)
Generic outward normal via central differences; works for any shape with eval().
Kokkos::View< T *, MemSpace > View
1D device array.
Axis-aligned solid box of half-extents half: standard exact box SDF, negative inside.
double eval(const Vec< 3 > &p) const
Negation: the solid and the void swap (sdf -> -sdf).
double eval(const Vec< 3 > &p) const
Solid hollow cylinder (a tube wall) of given outer/inner radius and height about axis.
double eval(const Vec< 3 > &p) const
Solid ball: negative inside.
double eval(const Vec< 3 > &p) const
Axis-aligned solid box of half-extents (hx, hy, hz), centred on the origin.
PECLET_HD Real eval(Vec3< Real > p) const
Solid tube wall about the z axis as a CSG intersection of half-spaces: max(r - rOuter,...
PECLET_HD Real evalRZ(Real r, Real z) const
Cross-section form: r is the in-plane radius, z the axial coordinate.
Solid ball of radius radius, centred on the origin.
PECLET_HD Real eval(Vec3< Real > p) const