Signed distance function
≈ 5 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
(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) 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.
(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)]] 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 with metric , and \partial\Omega be its boundary. The distance between a point of and the subset \partial\Omega of is defined as usual as d(x, \partial \Omega) = \inf_{y \in \partial \Omega}d(x, y), where \inf denotes the infimum. The signed distance function from a point of to \Omega is defined by f(x) = \begin{cases} d(x, \partial \Omega) & \text{if } x \in \Omega \\ -d(x, \partial \Omega) & \text{if }\, x \notin \Omega\\ 0 & \text{if }\, x \in \partial \Omega. \end{cases} ==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 |\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_{T(\partial\Omega,\mu)} g(x)\,dx = \int_{\partial\Omega}\int_{-\mu}^\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. ==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. f(x) = \begin{cases} 0 & \text{if }\, x \in \Omega^c\\ d(x, \partial\Omega) & \text{if }\, x \in \Omega \end{cases} 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. ==Notes== ==References== (or the Appendix of the 1977 1st ed.)
Text derived from https://en.wikipedia.org/w/index.php?oldid=1358889003 under CC BY-SA 4.0; modifications have been made.