11#ifndef PECLET_CORE_GEOM_SDF_HPP
12#define PECLET_CORE_GEOM_SDF_HPP
23 return {
a[0] - b[0],
a[1] - b[1],
a[2] - b[2]};
26 return std::sqrt(
a[0] *
a[0] +
a[1] *
a[1] +
a[2] *
a[2]);
45 double inside = std::min(std::max(
q[0], std::max(
q[1],
q[2])), 0.0);
62 double r = std::sqrt(d[
a0] * d[
a0] + d[
a1] * d[
a1]);
80 for (
int i = 0;
i < 3; ++
i) {
84 g[
i] = (shape.eval(
pp) - shape.eval(
pm)) / (2.0 *
h);
89#if defined(__cpp_concepts)
93 {
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