sdf.Difference
sdf.Difference(*sdfs, smoothness=0.1)
Difference of SDFs (subtract all subsequent from first).
Uses smooth maximum for differentiable blending.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| sdfs | Tuple of SDFs; first is the base, rest are subtracted | () |
|
| smoothness | float | Blend half-width in model units, not a fillet radius. 0 is a sharp boolean; the default of 0.1 blends, so a plain Difference(a, b) is a blended one and a caller who wants the sharp operation has to ask for smoothness=0. The value does not scale with the part: 0.1 is a tenth of a unit whatever the unit stands for, enough on a large part to erase a thin internal feature. See :mod:cadjoint.sdf.boolean.smooth for what the blend costs — it moves the field by up to smoothness per operation, and by the full amount wherever the operands agree. |
0.1 |
Methods
| Name | Description |
|---|---|
| material_at | The body’s material, tinted by each tool near the surface that tool cut. |
| patch_fields | Body patches then tool patches, operand-major, for a sharp cut only. |
| sdf | Pure function for difference operation. |
material_at
sdf.Difference.material_at(p)
The body’s material, tinted by each tool near the surface that tool cut.
Folds over every tool, the way :meth:Union.material_at folds over every operand, so a part cut by more than one tool takes its material from every cut, not just the first.
patch_fields
sdf.Difference.patch_fields()
Body patches then tool patches, operand-major, for a sharp cut only.
max(body, -tool_1, -tool_2, ...), so the result’s surface is the body’s surface where no tool reaches plus each tool’s surface where it cut into the body — pieces of the operands’ surfaces and nothing else. The fields are theirs concatenated in operand order, with every tool negated, exactly as the composition negates it: a tool’s own field reads positive outside the tool, which is inside the cavity it left, so leaving it alone would hand the consumer a patch whose normal points into the material. Negating flips it to positive outside the result, and leaves the zero set — hence argmin |f_i| ownership — untouched.
See :func:~cadjoint.sdf.boolean.base._operand_patch_fields for the order’s guarantees and why a smoothness > 0 difference declines.
sdf
sdf.Difference.sdf(child_sdfs, p, smoothness)
Pure function for difference operation.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| child_sdfs | Tuple of SDF functions; first is base, rest are subtracted | required | |
| p | Array | Query point(s) | required |
| smoothness | float | Blend radius | required |
Returns
| Name | Type | Description |
|---|---|---|
| Array | Difference SDF value |