sdf.Sphere
sdf.Sphere(radius, material=None)
Sphere centered at origin with given radius.
This is a thin wrapper that provides: - Fluent API: sphere.translate().rotate() - Operator overloading: sphere | box - Parameter storage for compilation
The actual SDF computation is in the static sdf() method.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| radius | float | Scalar | Sphere radius (float or Scalar parameter) | required |
Example
Direct creation
sphere = Sphere(radius=1.0)
With parameter for optimization
from cadjoint.geometry.parameters import Scalar radius = Scalar(value=1.0, free=True, name=‘radius’) sphere = Sphere(radius=radius)
Fluent API
shape = Sphere(1.0).translate([1, 0, 0]).scale(2.0)
Direct pure function call
distance = Sphere.sdf(point, radius=1.0)
Methods
| Name | Description |
|---|---|
| patch_fields | Single smooth patch: the sphere surface has no feature edges. |
| sdf | Pure SDF function for sphere. |
patch_fields
sdf.Sphere.patch_fields()
Single smooth patch: the sphere surface has no feature edges.
sdf
sdf.Sphere.sdf(p, radius)
Pure SDF function for sphere.
This is the source of truth for sphere SDF computation. Used directly during JAX compilation and tracing.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| p | Array | Point(s) to evaluate, shape (…, 3) | required |
| radius | float | Sphere radius | required |
Returns
| Name | Type | Description |
|---|---|---|
| Array | Signed distance: ||p|| - radius |