Signed distance function
   HOME

TheInfoList



OR:

In mathematics and its applications, the signed distance function (or oriented distance function) is the
orthogonal distance In geometry, the perpendicular distance between two objects is the distance from one to the other, measured along a line that is perpendicular to one or both. The distance from a point to a line is the distance to the nearest point on that line. Th ...
of a given point ''x'' to the
boundary Boundary or Boundaries may refer to: * Border, in political geography Entertainment * ''Boundaries'' (2016 film), a 2016 Canadian film * ''Boundaries'' (2018 film), a 2018 American-Canadian road trip film *Boundary (cricket), the edge of the pla ...
of a set Ω in a
metric space In mathematics, a metric space is a set together with a notion of '' distance'' between its elements, usually called points. The distance is measured by a function called a metric or distance function. Metric spaces are the most general set ...
, with the sign determined by whether or not ''x'' is in the interior of Ω. The
function Function or functionality may refer to: Computing * Function key, a type of key on computer keyboards * Function model, a structured representation of processes in a system * Function object or functor or functionoid, a concept of object-oriente ...
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).


Definition

If Ω is a subset of a
metric space In mathematics, a metric space is a set together with a notion of '' distance'' between its elements, usually called points. The distance is measured by a function called a metric or distance function. Metric spaces are the most general set ...
''X'' with metric ''d'', then the ''signed distance function'' ''f'' is defined by :f(x) = \begin d(x, \partial \Omega) & \mbox\, x \in \Omega \\ -d(x, \partial \Omega) & \mbox\, x \in \Omega^c \end where \partial \Omega denotes the
boundary Boundary or Boundaries may refer to: * Border, in political geography Entertainment * ''Boundaries'' (2016 film), a 2016 Canadian film * ''Boundaries'' (2018 film), a 2018 American-Canadian road trip film *Boundary (cricket), the edge of the pla ...
of For any : d(x, \partial \Omega) := \inf_d(x, y) where denotes the
infimum In mathematics, the infimum (abbreviated inf; plural infima) of a subset S of a partially ordered set P is a greatest element in P that is less than or equal to each element of S, if such an element exists. Consequently, the term ''greatest lo ...
.


Properties in Euclidean space

If Ω is a subset of the
Euclidean space Euclidean space is the fundamental space of geometry, intended to represent physical space. Originally, that is, in Euclid's ''Elements'', it was the three-dimensional space of Euclidean geometry, but in modern mathematics there are Euclidean ...
R''n'' with piecewise
smooth Smooth may refer to: Mathematics * Smooth function, a function that is infinitely differentiable; used in calculus and topology * Smooth manifold, a differentiable manifold for which all the transition maps are smooth functions * Smooth algebrai ...
boundary, then the signed distance function is differentiable
almost everywhere In measure theory (a branch of mathematical analysis), a property holds almost everywhere if, in a technical sense, the set for which the property holds takes up nearly all possibilities. The notion of "almost everywhere" is a companion notion to ...
, and its
gradient In vector calculus, the gradient of a scalar-valued differentiable function of several variables is the vector field (or vector-valued function) \nabla f whose value at a point p is the "direction and rate of fastest increase". If the gr ...
satisfies the eikonal equation : , \nabla f, =1. If the boundary of Ω is ''C''''k'' for ''k'' ≥ 2 (see Differentiability classes) then ''d'' is ''C''''k'' on points sufficiently close to the boundary of Ω. In particular, ''on'' the boundary ''f'' satisfies :\nabla 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 ''W''''x'' 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 :\int_ g(x)\,dx = \int_\int_^\mu g(u+\lambda N(u))\, \det(I-\lambda W_u) \,d\lambda \,dS_u, where denotes the
determinant In mathematics, the determinant is a scalar value that is a function of the entries of a square matrix. It characterizes some properties of the matrix and the linear map represented by the matrix. In particular, the determinant is nonzero if a ...
and ''dS''''u'' indicates that we are taking the surface integral.


Algorithms

Algorithm In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific problems or to perform a computation. Algorithms are used as specifications for performing ...
s for calculating the signed distance function include the efficient fast marching method, fast sweeping method and the more general
level-set method Level-set methods (LSM) are a conceptual framework for using level sets as a tool for numerical analysis of surfaces and shapes. The advantage of the level-set model is that one can perform numerical computations involving curves and surfaces o ...
. For
voxel In 3D computer graphics, a voxel represents a value on a regular grid in three-dimensional space. As with pixels in a 2D bitmap, voxels themselves do not typically have their position (i.e. coordinates) explicitly encoded with their values. I ...
rendering, a fast algorithm for calculating the SDF in
taxicab geometry A taxicab geometry or a Manhattan geometry is a geometry whose usual distance function or metric of Euclidean geometry is replaced by a new metric in which the distance between two points is the sum of the absolute differences of their Cartesian c ...
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. 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) = \begin 0 & \text\, x \in \Omega^c\\ d(x, \partial\Omega) & \text\, x \in \Omega \end They have also been used in a method (advanced by
Valve A valve is a device or natural object that regulates, directs or controls the flow of a fluid (gases, liquids, fluidized solids, or slurries) by opening, closing, or partially obstructing various passageways. Valves are technically fitting ...
) to render smooth fonts at large sizes (or alternatively at high DPI) using
GPU A graphics processing unit (GPU) is a specialized electronic circuit designed to manipulate and alter memory to accelerate the creation of images in a frame buffer intended for output to a display device. GPUs are used in embedded systems, mobi ...
acceleration. Valve's method computed signed
distance field A distance transform, also known as distance map or distance field, is a derived representation of a digital image. The choice of the term depends on the point of view on the object in question: whether the initial image is transformed into anoth ...
s in raster space in order to avoid the computational complexity of solving the problem in the (continuous) vector space. More recently piece-wise approximation solutions have been proposed (which for example approximate a Bézier with arc splines), but even this way the computation can be too slow for real-time rendering, and it has to be assisted by grid-based discretization techniques to approximate (and cull from the computation) the distance to points that are too far away. In 2020, the
FOSS Fos or FOSS may refer to: Companies * Foss A/S, a Danish analytical instrument company *Foss Brewery, a former brewery in Oslo, Norway * Foss Maritime, a tugboat and shipping company Historic houses * Foss House (New Brighton, Minnesota), Unite ...
game engine Godot 4.0 received SDF-based real-time
global illumination Global illumination (GI), or indirect illumination, is a group of algorithms used in 3D computer graphics that are meant to add more realistic lighting to 3D scenes. Such algorithms take into account not only the light that comes directly fro ...
(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.


See also

* Distance function *
Level-set method Level-set methods (LSM) are a conceptual framework for using level sets as a tool for numerical analysis of surfaces and shapes. The advantage of the level-set model is that one can perform numerical computations involving curves and surfaces o ...
* Eikonal equation * Parallel (aka offset) curve * Signed arc length


Notes


References

* *{{cite book , author1=Gilbarg, D. , author2=Trudinger, N. S. , year=1983 , edition=2nd , title=Elliptic Partial Differential Equations of Second Order , publisher=Springer-Verlag , volume=224 , series=Grundlehren der mathematischen Wissenschaften (or the Appendix of the 1977 1st ed.) Applied mathematics Distance