sdf.Box

sdf.Box(size, material=None)

Axis-aligned box centered at origin.

Parameters

Name Type Description Default
size Vector Half-extents in each dimension (x, y, z) - Vector parameter required

Example

box = Box(size=Vector([1, 2, 3], free=True, name=‘size’))

Methods

Name Description
patch_fields Six face half-space distances, derived from the sdf structure.
sdf Pure SDF function for box.

patch_fields

sdf.Box.patch_fields()

Six face half-space distances, derived from the sdf structure.

:meth:sdf is (inside) max_a(|p_a| - size_a), and each term splits as |p_a| - size_a = max(p_a - size_a, -p_a - size_a) — so the box is the max composition of six half-space distances, one per face. Order: [+x, -x, +y, -y, +z, -z] (index 2*axis + side with side 0 for the positive face).

sdf

sdf.Box.sdf(p, size)

Pure SDF function for box.

Parameters

Name Type Description Default
p Array Point(s) to evaluate, shape (…, 3) required
size Array Half-extents [x, y, z] required

Returns

Name Type Description
Array Signed distance to box

Note

Branches on inside/outside instead of smoothing the outside norm with an epsilon: points exactly on a face then differentiate through the inside branch and receive a valid one-sided subgradient. An epsilon-regularized sqrt has an exact stationary point on the face plane, which silently zeroes parameter gradients for on-surface samples.