A Boolean operation combines two shapes by asking, at every location, whether that location belongs to each input. Union keeps locations inside either shape; intersection keeps only locations inside both; subtraction keeps locations inside the first shape but outside the second. The same idea applies to implicit functions, voxel masks, and boundary-based CAD models, although the cost and reliability differ sharply between them. section 10.2.2 section 12.3.4 section 11.1.2
For signed distance functions (SDFs), shape composition becomes simple array arithmetic:
- Union: take minimum(a, b). The result is negative wherever either input is negative. section 10.2.2
- Intersection: take maximum(a, b). The result is negative only wherever both inputs are negative. section 10.2.2
- Subtraction: take maximum(a, -b). Inverting the second function turns removal into an intersection. section 10.2.2
Cutting one circle from another
Start with two circle SDFs. Combine them with maximum(SDF1, -SDF2) to retain the first circle except where the second circle overlaps it. This creates a crescent-like result without explicitly finding curve intersections or splitting geometry. section 10.2.2 section 11.1.2
def circle(X, Y, r): #1
return np.sqrt(X*X + Y*Y) - r
N = 100 #2
x = np.linspace(-10., 10., N) #2
y = np.linspace(-10., 10., N) #2
X, Y = np.meshgrid(x, y) #3
SDF1 = circle(X+2, Y, 6) #4
SDF2 = circle(X-2, Y, 6) #4
This NumPy setup samples two circle SDFs on a grid, providing operands for minimum, maximum, and inverted-operand Boolean combinations. section 10.2.2
Boolean results from SDFs still describe shapes, but they are not necessarily true distance functions. That matters when an algorithm needs exact Euclidean distance: applying a simple dilation or erosion after a Boolean can produce an incorrect offset, such as sharp rather than rounded features. Treat post-Boolean offsets as a point to verify, not a harmless final step. section 10.2.2 section 10.2.3
Representation choice changes the engineering trade-off. Voxel and image-mask Booleans are direct true/false operations and are fast and reliable when operands share a grid, making them useful in multistep cleanup workflows. Boundary representations require intersections, splitting, classification, and orientation handling; supporting more curve or surface types adds substantially more cases. SDFs make Boolean composition cheap and robust, but sacrifice exact distance values after composition. section 12.3.4 section 12.3.6 section 11.1.2 section 12.5
Booleans also underpin familiar modeling operations. In CAD-style workflows, chamfers and fillets can be assembled from offsets, generated surfaces, and Boolean trimming. In voxel models, Boolean operations combine with dilation, erosion, and cavity fill to remove noise, smooth borders, and fill enclosed pores. section 11.1.2 section 12.3
