functionalize.functionalize

functionalize.functionalize(sdf)

Compile an SDF to a pure function with free and fixed parameters.

Returns a curried function with signature

sdf_fn(free_params, fixed_params) -> (point -> distance)

Nodes are built once per object and repeated nodes are outlined, so a pattern of N instances and a subtree used by two parents each cost one copy in the emitted program rather than N and two.

Parameters

Name Type Description Default
sdf The SDF to compile required

Returns

Name Type Description
Callable Callable Curried function sdf_fn(free_params, fixed_params) -> (point -> distance) mapping parameter dicts to a callable point: Array (3,) -> distance: Array ().

Example

radius = Scalar(value=1.0, free=True, name='radius')
sphere = Sphere(radius=radius)
sdf_fn = functionalize(sphere)
distance = sdf_fn({'sphere_0.radius': 2.0}, {})(jnp.array([0., 0., 0.]))