sdf_subtract — 3D sdf_csg op

• Data kinds: sdf × sdf → sdf

• Call: import fullseye as fs; fs.ledger.sdf_subtract(a, b) (to call the implementation directly, import sdf_ops; sdf_ops.sdf_subtract(a, b); from the registry, ops3d.get("sdf_subtract"))

Usage

The difference A\B = max(a, −b) (inside A and outside B = inside −b).

Flipping the sign of b inverts "outside B to inside, inside B to outside" (the complement), so the product with A becomes A with B hollowed out. Not commutative: sdf_subtract(a,b) != sdf_subtract(b,a).

Computation: np.maximum(np.asarray(a, float64), -np.asarray(b, float64)). Same as sdf_intersect(a, -b). The shapes must be broadcast-compatible (otherwise numpy raises ValueError), and nothing else is checked. NaN propagates, and ±inf also propagates exactly (at a point with b = +inf, -b = -inf, so a remains as is = a point where "B is infinitely far" stays A).

Input: 2 SDFs on the same grid (negative inside, positive outside). a is the shape to keep, b the shape to hollow out. The distance unit is that of the input.

Returns: float64 of the broadcast shape. <= 0 is the occupancy of A\B.

Notes:

• Inside B the value becomes -b > 0 (the distance to the surface of B), so the distance to the inner wall of the hollowed hole is exact outside and a lower bound inside A (a standard property of CSG).

• If B fully contains A, every element is positive (empty set). This is not an error.

• Used for drilling, pocket machining and shells (the difference of a and sdf_offset(a, -t) gives a shell of thickness t).

References (sample data, literature)

• Sample-data catalog (download URLs / licences) — 2-D uses skimage.data (BSD/public domain) plus synthetic images; 3-D lists download URLs for real data sources (Stanford, PDS, …).

• Operator provenance and references — the sources of the research/methods this op family came from.

Runnable examples (verified samples that actually call this op)

• sdf_csg — py -3.11 examples_3d/sdf_csg.py

Ops the type connects to (they accept sdf as input)

sdf_to_occupancy · fuse_to_voxel · integrate · extract_surface_points · query_distance · sdf_union · sdf_intersect · sdf_smooth_union

Same category (sdf_csg)

grid_coords · sphere_sdf · box_sdf · plane_sdf · cylinder_sdf · torus_sdf · capsule_sdf · sdf_union


*Provenance: sdf_ops.py — 3D operator registry. This per-op note is generated by tools/opdocs.py md (do not hand-edit).*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.