Constructive solid geometry

Basic transformations

Implicit functions, and by extension also signed distance fields, can be manipulated using basic transformations (like rotations). Every such transformation takes an implicit function \(I\) and produces a new implicit function \(I^\prime\), defined by evaluating \(I\) at a suitably transformed query point.

Warning

Some of these operations preserve the signed distance property, and others do not.

EBGeometry supports many such transformations, for example:

Translation

Translating by a vector \(\mathbf{t}\) shifts the query point back by \(\mathbf{t}\) before evaluating the original function:

\[I^\prime(\mathbf{x}) = I\left(\mathbf{x} - \mathbf{t}\right).\]

Rotation

Rotating by an angle \(\theta\) about one of the coordinate axes \(a \in \{x, y, z\}\) applies the inverse rotation to the query point:

\[I^\prime(\mathbf{x}) = I\left(R_a(-\theta)\,\mathbf{x}\right),\]

where \(R_a(\theta)\) is the standard rotation matrix by angle \(\theta\) about axis \(a\). Rotating the query point by \(-\theta\) is what makes the shape itself appear rotated by \(+\theta\).

Scaling

Uniform scaling by a non-zero factor \(s\) shrinks the query point by \(s\) before evaluating the original function, and scales the result back up by \(s\):

\[I^\prime(\mathbf{x}) = s \, I\left(\mathbf{x}/s\right).\]

Rescaling the value by \(s\) alongside the query point is what preserves the signed distance property (see Geometry representations) for a scaled signed distance function – omitting it would still shrink or grow the shape correctly, but the result would no longer report true distances.

Complement

The complement simply negates the function value, swapping the roles of “inside” and “outside”:

\[I^\prime(\mathbf{x}) = -I(\mathbf{x}).\]

Reflection

Reflecting across one of the three coordinate planes (the \(yz\)-, \(xz\)-, or \(xy\)-plane) flips the sign of the one coordinate normal to that plane (\(x\), \(y\), or \(z\) respectively) before evaluating the original function. Writing \(\mathbf{r}\) for the vector that is \(+1\) in the two unaffected coordinates and \(-1\) in the flipped one, and \(\odot\) for the component-wise product:

\[I^\prime(\mathbf{x}) = I\left(\mathbf{r} \odot \mathbf{x}\right).\]

EBGeometry supports several further transformations beyond these five, including shell extraction (hollowing out a solid into a shell of a given thickness) and mollification (smoothing a sharp surface by locally averaging the function value), among others.

Combining objects

EBGeometry supports the standard operations for combining implicit functions: union, intersection, and difference. Smooth equivalents of each are also available, which smooth the transition between the combined objects (controlled by a blending length) instead of leaving a sharp crease where the objects meet.

Fast CSG operations are also supported by EBGeometry, e.g. the BVH-accelerated CSG union where one uses the BVH when searching for the relevant geometric primitive(s). This functionality is motivated by the fact that a CSG union is normally implemented as \(\min\left(I_1, I_2, I_3, \ldots,I_N\right)\), which has \(\mathcal{O}\left(N\right)\) complexity when there are \(N\) objects. BVH trees can reduce this to \(\mathcal{O}\left(\log N\right)\) complexity, using the same BVH traversal-and-pruning machinery described in Bounding volume hierarchies for mesh signed distances.