Signed distance turns a shape boundary into a useful number field. For every point in space, it reports the distance to the nearest boundary, but adds a sign: normally negative inside the body, positive outside, and exactly zero on its border. In 2D that border is a curve; in 3D it is a surface. The sign makes one function answer both “how far away?” and “which side?” section 10.1 section 10.1.5
Read the field as a map around a disk: values change continuously, cross zero at the contour, and switch from negative inside to positive outside. section 10.1
A signed distance function (SDF) represents a whole body rather than only its outline. For a unit circle centered at the origin, the expression sqrt(x² + y²) − 1 is negative within the circle, zero on it, and positive beyond it. This representation is attractive in CAD because many modeling operations are simpler and faster than equivalent surface or triangle-mesh operations. section 2.4.2 section 10.1.2
Program a circle field
In Python, evaluate d = (x**2 + y**2)**0.5 - 1. Sample x and y over a grid with NumPy, then plot the resulting values. The zero contour draws the circle; negative and positive regions reveal its interior and exterior. If a function uses scalar if statements, array evaluation may need np.vectorize. section 10.1.2
Not every sign-correct shape function is a true signed-distance function. A circle expression with its square root removed still has the same negative, zero, and positive regions, so it models the same circle, but its values no longer measure Euclidean distance. That shortcut can save computation, yet operations that depend on genuine distances—especially offsets and contouring methods tailored to Euclidean distance—may no longer behave properly. section 10.1.1 section 10.2.5
Signed distance makes common shape operations unusually direct:
- Translate, rotate, or scale the field with geometric transformations. section 10.2.5
- Unite two shapes with minimum: the result remains negative wherever either input is negative. section 10.2.2
- Intersect two shapes with maximum: the result is negative only where both inputs are negative. section 10.2.2
- Subtract one shape by intersecting the first field with the negated second field. section 10.2.2
For polygonal geometry, distance requires care. A plane can supply a signed distance because it partitions space into sides. A segment cannot enclose a 3D body by itself, so its distance is unsigned; computing distance to a triangle mesh combines plane signs with nearest-edge or nearest-feature distances. In 2D, a rectangle can be built by finding the nearest edge and applying the appropriate line-distance sign. section 10.1.3 section 10.1.4
SDFs are especially useful when shapes need repeated modification or conversion. They support cheap offsets, shells, and Boolean-style composition, and contouring algorithms can convert an SDF back to a triangle mesh. The trade-off is resolution: more accurate contouring costs substantially more computation. section 10.2 section 11.3.4
