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]);
70 const int a0 = (
axis + 1) % 3, a1 = (
axis + 2) % 3;
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)
100concept Sdf =
requires(
const S s,
Vec<3> p) {
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().
std::array< Real, Dim > Vec
Multi-dimensional real vector.
Real-templated POD 3-vector — the geometry layer's point type on host and device.
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