Oriented Distance Function
   HOME

TheInfoList



OR:

In
mathematics Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
and its applications, the signed distance function (or oriented distance function) is the orthogonal distance of a given point ''x'' to the boundary of a
set Set, The Set, SET or SETS may refer to: Science, technology, and mathematics Mathematics *Set (mathematics), a collection of elements *Category of sets, the category whose objects and morphisms are sets and total functions, respectively Electro ...
Ω in a metric space, with the
sign A sign is an object, quality, event, or entity whose presence or occurrence indicates the probable presence or occurrence of something else. A natural sign bears a causal relation to its object—for instance, thunder is a sign of storm, or me ...
determined by whether or not ''x'' is in the
interior Interior may refer to: Arts and media * ''Interior'' (Degas) (also known as ''The Rape''), painting by Edgar Degas * ''Interior'' (play), 1895 play by Belgian playwright Maurice Maeterlinck * ''The Interior'' (novel), by Lisa See * Interior de ...
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).


Definition

If Ω is a
subset In mathematics, Set (mathematics), set ''A'' is a subset of a set ''B'' if all Element (mathematics), elements of ''A'' are also elements of ''B''; ''B'' is then a superset of ''A''. It is possible for ''A'' and ''B'' to be equal; if they are ...
of a metric space ''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 of For any : d(x, \partial \Omega) := \inf_d(x, y) where denotes the infimum.


Properties in Euclidean space

If Ω is a subset of the Euclidean space R''n'' with piecewise smooth boundary, then the signed distance function is differentiable almost everywhere, and its gradient satisfies the
eikonal equation An eikonal equation (from Greek εἰκών, image) is a non-linear first-order partial differential equation that is encountered in problems of wave propagation. The classical eikonal equation in geometric optics is a differential equation of ...
: , \nabla f, =1. If the boundary of Ω is ''C''''k'' for ''k'' ≥ 2 (see
Differentiability classes In mathematical analysis, the smoothness of a function is a property measured by the number of continuous derivatives it has over some domain, called ''differentiability class''. At the very minimum, a function could be considered smooth if i ...
) 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 A Hessian is an inhabitant of the German state of Hesse. Hessian may also refer to: Named from the toponym *Hessian (soldier), eighteenth-century German regiments in service with the British Empire **Hessian (boot), a style of boot **Hessian f ...
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 In mathematics, a tubular neighborhood of a submanifold of a smooth manifold is an open set around it resembling the normal bundle. The idea behind a tubular neighborhood can be explained in a simple example. Consider a smooth curve in the pl ...
of radius ''μ''), and ''g'' is an
absolutely integrable function In mathematics, an absolutely integrable function is a function whose absolute value is integrable, meaning that the integral of the absolute value over the whole domain is finite. For a real-valued function, since \int , f(x), \, dx = \int f^+(x) ...
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 and ''dS''''u'' indicates that we are taking the
surface integral In mathematics, particularly multivariable calculus, a surface integral is a generalization of multiple integrals to integration over surfaces. It can be thought of as the double integral analogue of the line integral. Given a surface, one may ...
.


Algorithms

Algorithms for calculating the signed distance function include the efficient
fast marching method The fast marching methodJ.A. Sethian. A Fast Marching Level Set Method for Monotonically Advancing Fronts, Proc. Natl. Acad. Sci., 93, 4, pp.1591--1595, 1996/ref> is a numerical method created by James Sethian for solving boundary value problems ...
,
fast sweeping method In applied mathematics, the fast sweeping method is a numerical method for solving boundary value problems of the Eikonal equation. : , \nabla u(\mathbf), = \frac 1 \text \mathbf \in \Omega : u(\mathbf) = 0 \text \mathbf \in \partial \Omega ...
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 Computer vision is an interdisciplinary scientific field that deals with how computers can gain high-level understanding from digital images or videos. From the perspective of engineering, it seeks to understand and automate tasks that the hum ...
. A modified version of SDF was introduced as a
loss function In mathematical optimization and decision theory, a loss function or cost function (sometimes also called an error function) is a function that maps an event or values of one or more variables onto a real number intuitively representing some "cost ...
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) to render
smooth font Font rasterization is the process of converting text from a vector description (as found in scalable fonts such as TrueType fonts) to a raster or bitmap description. This often involves some anti-aliasing on screen text to make it smoother ...
s at large sizes (or alternatively at high DPI) using GPU acceleration. Valve's method computed signed distance fields 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 In applied mathematics, discretization is the process of transferring continuous functions, models, variables, and equations into discrete counterparts. This process is usually carried out as a first step toward making them suitable for numerical ...
techniques to approximate (and cull from the computation) the distance to points that are too far away. 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.


See also

*
Distance function 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 settin ...
* Level-set method *
Eikonal equation An eikonal equation (from Greek εἰκών, image) is a non-linear first-order partial differential equation that is encountered in problems of wave propagation. The classical eikonal equation in geometric optics is a differential equation of ...
* Parallel (aka offset) curve *
Signed arc length Signing may refer to: * Using sign language * Signature, placing one's name on a document * Signature (disambiguation) * Manual communication, signing as a form of communication using the hands in place of the voice * Digital signature A digit ...


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