ArticleslgStudy

mathematics

Signed distance function

Signed distance function is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Signed distance function rather than just read about it. In short: In mathematics and its applications, the signed distance function or signed distance field (SDF) is the orthogonal distance of a given point x to the boundary of a set Ω in a metric space (such as the surface of a geometric shape), with the sign determined by whether or not x is in the interior of Ω. The function has positive values at points x inside Ω, it decreases in value as x approaches the boundary of Ω where…

Signed distance function — main illustration
Signed distance function — illustration

Key takeaways

  • Signed distance function belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Signed distance function to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Signed distance function from memory before moving on to harder problems.

Reference excerpt

In mathematics and its applications, the signed distance function or signed distance field (SDF) is the orthogonal distance of a given point x to the boundary of a set Ω in a metric space (such as the surface of a geometric shape), with the sign determined by whether or not x is in the interior of Ω. The function has positive values at points x inside Ω, it decreases in value as x approaches the boundary of Ω where the signed distance function is zero, and it takes negative values outside of Ω. However, the alternative convention is also sometimes taken instead (i.e., negative inside Ω and positive outside). The concept also sometimes goes by the name oriented distance function/field.

Definition Let Ω be a subset of a metric space X with metric d, and ∂Ω be its boundary. The distance between a point x of X and the subset ∂Ω of X is defined as usual as d(x,∂Ω)=infy∈∂Ωd(x,y), where inf denotes the infimum. The signed distance function from a point x of X to Ω is defined by f(x)={d(x,∂Ω)if x∈Ω−d(x,∂Ω)if x∉Ω0if x∈∂Ω.

Properties in Euclidean space If Ω is a subset of the Euclidean space Rn with piecewise smooth boundary, then the signed distance function is differentiable almost everywhere, and its gradient satisfies the eikonal equation |∇f|=1. If the boundary of Ω is Ck for k ≥ 2 (see Differentiability classes) then d is Ck on points sufficiently close to the boundary of Ω. In particular, on the boundary f satisfies ∇f(x)=N(x), where N is the inward normal vector field. The signed distance function is thus a differentiable extension of the normal vector field. In particular, the Hessian of the signed distance function on the boundary of Ω gives the Weingarten map. If, further, Γ is a region sufficiently close to the boundary of Ω that f is twice continuously differentiable on it, then there is an explicit formula involving the Weingarten map Wx for the Jacobian of changing variables in terms of the signed distance function and nearest boundary point. Specifically, if T(∂Ω, μ) is the set of points within distance μ of the boundary of Ω (i.e. the tubular neighbourhood of radius μ), and g is an absolutely integrable function on Γ, then ∫T(∂Ω,μ)g(x)dx=∫∂Ω∫−μμg(u+λN(u))det⁡(I−λWu)dλdSu, where det denotes the determinant and dSu indicates that we are taking the surface integral.

Algorithms Algorithms for calculating the signed distance function include the efficient fast marching method, fast sweeping method and the more general level-set method. For voxel rendering, a fast algorithm for calculating the SDF in taxicab geometry uses summed-area tables.

Applications

Signed distance functions are applied, for example, in real-time rendering, for instance the method of SDF ray marching, and computer vision. SDF has been used to describe object geometry in real-time rendering, usually in a raymarching context, starting in the mid 2000s. By 2007, Valve was using SDFs to render large pixel-size (or high DPI) smooth fonts with GPU acceleration in its games. Valve's method is not perfect as it runs in raster space in order to avoid the computational complexity of solving the problem in the (continuous) vector space. The rendered text often loses sharp corners. In 2014, an improved method was presented by Behdad Esfahbod. Behdad's GLyphy approximates the font's Bézier curves with arc splines, accelerated by grid-based discretization techniques (which culls too-far-away points) to run in real time. A modified version of SDF was introduced as a loss function to minimise the error in interpenetration of pixels while rendering multiple objects. In particular, for any pixel that does not belong to an object, if it lies outside the object in rendition, no penalty is imposed; if it does, a positive value proportional to its distance inside the object is imposed. f(x)={0if x∈Ωcd(x,∂Ω)if x∈Ω In 2020, the FOSS game engine Godot 4.0 received SDF-based real-time global illumination (SDFGI), that became a compromise between more realistic voxel-based GI and baked GI. Its core advantage is that it can be applied to infinite space, which allows developers to use it for open-world games. In 2023, the authors of the Zed text editor announced a GPUI framework that draws all UI elements using the GPU at 120 fps. The work makes use of Inigo Quilez's list of geometric primitives in SDF, Figma co-founder Evan Wallace's Gaussian blur in SDF, and a new rounded rectangle SDF.

See also Distance function Level-set method Eikonal equation Parallel curve (also known as offset curve) Signed arc length Signed area Signed measure Signed volume

Notes

References Stanley J. Osher and Ronald P. Fedkiw (2003). Level Set Methods and Dynamic Implicit Surfaces. Springer. doi:10.1007/b98879. ISBN 9780387227467. Gilbarg, D.; Trudinger, N. S. (1983). Elliptic Partial Differential Equations of Second Order. Grundlehren der mathematischen Wissenschaften. Vol. 224 (2nd ed.). Springer-Verlag. doi:10.1007/978-3-642-61798-0. (or the Appendix of the 1977 1st ed.)

Illustrations

Signed distance function: The graph (bottom, in red) of the signed distance between the points on the xy plane (in blue) and a fixed disk (also represented on top, in gray)
The graph (bottom, in red) of the signed distance between the points on the xy plane (in blue) and a fixed disk (also represented on top, in gray)
Signed distance function: A more complicated set (top) and the graph of its signed distance function (bottom, in red).
A more complicated set (top) and the graph of its signed distance function (bottom, in red).
Signed distance function: Signed distance fields stored as raster images can be used to represent shapes.
Signed distance fields stored as raster images can be used to represent shapes.

Worked examples

Example 1 — a first encounter with Signed distance function

Start with the simplest possible case. Write down what Signed distance function claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Signed distance function before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Signed distance function ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Signed distance function

In research
Signed distance function appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Signed distance function in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Signed distance function is common in secondary-school and first-year university syllabi. It links to neighbouring topics Applied mathematics, Distance, Implicit surface modeling, so understanding it makes those chapters shorter.
In everyday life
Look for Signed distance function outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Signed distance function” →

How to study Signed distance function in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Signed distance function means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Signed distance function out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Signed distance function in simple terms?

In mathematics and its applications, the signed distance function or signed distance field (SDF) is the orthogonal distance of a given point x to the boundary of a set Ω in a metric space (such as the surface of a geometric shape), with the sign determined by whether or not x is in the interior of…

Why does Signed distance function matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Signed distance function?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Signed distance function.

Tags

  • Applied mathematics
  • Distance
  • Implicit surface modeling
  • Sign (mathematics)

Keep exploring