SignedRegionDistance[reg,p]
gives the minimum distance from the point p to the region reg if p is outside the region and the minimum distance to the complement of reg if p is inside the region.
SignedRegionDistance[reg]
gives a RegionDistanceFunction[…] that can be applied repeatedly to different points.
SignedRegionDistance
SignedRegionDistance[reg,p]
gives the minimum distance from the point p to the region reg if p is outside the region and the minimum distance to the complement of reg if p is inside the region.
SignedRegionDistance[reg]
gives a RegionDistanceFunction[…] that can be applied repeatedly to different points.
Details and Options
- SignedRegionDistance is also known as signed distance function and signed distance transform.
- SignedRegionDistance is positive for points outside the region and negative for points inside the region. The absolute value measures how close the point is to the boundary.
- The distance between points q and p is taken to be Norm[p-q].
- SignedRegionDistance is effectively MinValue[{Norm[p-q],q∈reg},q∈reg] when p is not in reg and -MinValue[{Norm[p-q],q∉reg},q] otherwise.
- SignedRegionDistance can be used with symbolic regions and points in GeometricScene.
Examples
open all close allBasic Examples (2)
Find the signed distance from a point inside to the unit disk:
SignedRegionDistance[Disk[], {0, 0}]SignedRegionDistance[Disk[], {1, 1}]Plot the distance as a function of position:
Plot3D[SignedRegionDistance[Disk[], {x, y}], {x, -2, 2}, {y, -2, 2}]Find the signed distance from a point to a MeshRegion:
DelaunayMesh[RandomReal[1, {25, 2}]]With one argument, you get a RegionDistanceFunction:
df = SignedRegionDistance[%]df[{{1 / 2, 1 / 2}, {2, 2}}]Scope (19)
Special Regions (8)
The signed distance to a Point is always non-negative, as it has no interior:
SignedRegionDistance[Point[{{1, 1}, {1, 2}}], {3, 4}]SignedRegionDistance[Point[{{0, 0, 0}, {1, 2, 3}}], {1, 1, 1}]Plot the signed distance from a three-point set:
ℛ = Point[{{1, 2}, {3, 4}, {5, 6}}];Plot3D[SignedRegionDistance[ℛ, {x, y}], {x, 0, 7}, {y, 0, 7}, MeshFunctions -> {#3&}, Mesh -> 5]The signed distance to a Line can be negative in 1D:
SignedRegionDistance[Line[{{0}, {1}}], {1 / 2}]But in 2D and above, it is always non-negative:
SignedRegionDistance[Line[{{0, 0}, {1, 1}}], {3, 4}]Plot the signed distance from a line in 2D:
ℛ = Line[{{0, 0}, {1, 1}}];Plot3D[SignedRegionDistance[ℛ, {x, y}], {x, -1, 2}, {y, -1, 2}, MeshFunctions -> {#3&}, Mesh -> 5]SignedRegionDistance[Rectangle[{0, 0}, {3, 2}], {1, 1}]The signed distance from a Cuboid can be negative in any dimension:
SignedRegionDistance[Cuboid[{0, 0, 0, 0}, {2, 2, 2, 2}], {1, 1, 1, 1}]Plot the signed distance to a rectangle:
ℛ = Rectangle[{-1, -1}, {1, 1}];Plot3D[SignedRegionDistance[ℛ, {x, y}], {x, -2, 2}, {y, -2, 2}, MeshFunctions -> {#3&}, Mesh -> {{0}}, MeshShading -> {Red, Green}, Exclusions -> Norm[{x, y}, ∞] == 1]The signed distance from a full-dimensional Simplex can be negative:
SignedRegionDistance[Simplex[1], {1 / 2}]SignedRegionDistance[Simplex[2], {1 / 3, 1 / 3}]But the signed distance to a lower-dimensional simplex cannot:
SignedRegionDistance[Simplex[{{0, 0}, {1, 1}}], {1 / 2, 1 / 2}]Plot the signed distance to a 2D simplex:
ℛ = Simplex[2];Plot3D[SignedRegionDistance[ℛ, {x, y}], {x, -1, 2}, {y, -1, 2}, MeshFunctions -> {#3&}, Mesh -> {{0}}, MeshShading -> {Red, Green}]The signed distance to a Disk can be negative:
SignedRegionDistance[Disk[{0, 0}, 1], {1 / 2, 1 / 2}]Ball generalizes Disk to any dimension:
SignedRegionDistance[Ball[{0, 0, 0, 0}, 1], {1 / 3, 1 / 3, 1 / 3, 1 / 3}]Plot the signed distance to a disk:
ℛ = Disk[];Plot3D[SignedRegionDistance[ℛ, {x, y}], {x, -2, 2}, {y, -2, 2}, MeshFunctions -> {#3&}, Mesh -> {{0}}, MeshShading -> {Red, Green}]The signed distance to an Ellipsoid can be negative in any dimension:
SignedRegionDistance[Ellipsoid[{0, 0, 0}, {3, 2, 1}], {2, 0, 0}]Plot the signed distance to an ellipsoid in 2D:
ℛ = Ellipsoid[{0, 0}, {1, 2}];Plot3D[SignedRegionDistance[ℛ, {x, y}], {x, -2, 2}, {y, -3, 3}, MeshFunctions -> {#3&}, Mesh -> {{0}}, MeshShading -> {Red, Green}]The distance to a Circle is always non-negative, as it has no interior:
SignedRegionDistance[Circle[{0, 0}, 1], {1 / 2, 1 / 2}]The same goes for Sphere in any dimension:
SignedRegionDistance[Sphere[{0, 0, 0}, 1], {1 / 2, 1 / 2, 1 / 2}]Plot the signed distance to a circle:
ℛ = Circle[];Plot3D[RegionDistance[ℛ, {x, y}], {x, -2, 2}, {y, -2, 2}, MeshFunctions -> {#3&}, Mesh -> 5, Exclusions -> Norm[{x, y}] == 1]SignedRegionDistance[Cylinder[{{0, 0, 0}, {0, 0, 2}}, 1], {1 / 2, 1 / 2, 1}]Cone:
SignedRegionDistance[Cone[{{0, 0, 0}, {0, 0, 2}}, 1], {1 / 2, 1 / 2, 1 / 2}]Formula Regions (2)
The signed distance to a disk represented as an ImplicitRegion:
ℛ = ImplicitRegion[x^2 + y^2 ≤ 1, {x, y}];Region[ℛ]SignedRegionDistance[ℛ, {1 / 2, 1 / 2}]ℛ = ImplicitRegion[x^2 + y^2 ≤ 1.5, {x, y, {z, 0, 2}}];SignedRegionDistance[ℛ, {1, 2, 3}]The distance to a disk represented as a ParametricRegion:
ℛ = ParametricRegion[{r Cos[θ], r Sin[θ]}, {{r, 0, 1}, {θ, 0, 2π}}];SignedRegionDistance[ℛ, {1 / 2, 1 / 2}]Using a rational parametrization of the disk:
ℛ = ParametricRegion[{r(1 - t^2/1 + t^2), r(2t/1 + t^2)}, {t, {r, 0, 1}}];SignedRegionDistance[ℛ, {1 / 2, 1 / 2}]Mesh Regions (4)
The signed distance to a BoundaryMeshRegion can be negative in any dimension:
ℛ = BoundaryMeshRegion[{{0}, {1}}, Point[{{1}, {2}}]]SignedRegionDistance[ℛ, {1 / 2}]ℛ = ConvexHullMesh[RandomReal[1, {10, 2}]];Show[ℛ, Graphics[{Red, Point[{1 / 2, 1 / 2}]}]]SignedRegionDistance[ℛ, {1 / 2, 1 / 2}]ℛ = ConvexHullMesh[RandomReal[1, {20, 3}]];Show[HighlightMesh[ℛ, Style[2, Opacity[0.5]]], Graphics3D[{Red, Point[{1 / 2, 1 / 2, 1 / 2}]}]]SignedRegionDistance[ℛ, {1 / 2, 1 / 2, 1 / 2}]Signed distance cannot be negative to a 0D MeshRegion in 1D:
ℛ = MeshRegion[{{0}, {1}}, Point[{{1}, {2}}]]SignedRegionDistance[ℛ, {1 / 2}]But it can for a 1D MeshRegion:
ℛ = MeshRegion[{{0}, {1}}, Line[{1, 2}]]SignedRegionDistance[ℛ, {1 / 2}]Signed distance cannot be negative to a 0D MeshRegion in 2D:
ℛ = MeshRegion[{{0, 0}, {1, 0}, {0, 1}}, Point[{{1}, {2}, {3}}]];Show[ℛ, Graphics[{Red, Point[{1 / 3, 1 / 3}]}]]SignedRegionDistance[ℛ, {1 / 3, 1 / 3}]Nor for a 1D MeshRegion:
ℛ = MeshRegion[{{0, 0}, {1, 0}, {0, 1}}, Line[{1, 2, 3, 1}]];Show[ℛ, Graphics[{Red, Point[{1 / 3, 1 / 3}]}]]SignedRegionDistance[ℛ, {1 / 3, 1 / 3}]But it can for a 2D MeshRegion:
ℛ = MeshRegion[{{0, 0}, {1, 0}, {0, 1}}, Polygon[{1, 2, 3}]];Show[ℛ, Graphics[{Red, Point[{1 / 3, 1 / 3}]}]]SignedRegionDistance[ℛ, {1 / 3, 1 / 3}]Signed distance cannot be negative to a 0D MeshRegion in 3D:
ℛ = MeshRegion[{{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}}, Point[{{1}, {2}, {3}, {4}}]];Show[ℛ, Graphics3D[{Red, Point[{1 / 4, 1 / 4, 1 / 4}]}]]SignedRegionDistance[ℛ, {1 / 4, 1 / 4, 1 / 4}]Nor for a 1D MeshRegion:
ℛ = MeshRegion[{{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}}, Line[{{1, 2, 3, 4, 1}}]];Show[ℛ, Graphics3D[{Red, Point[{1 / 4, 1 / 4, 1 / 4}]}]]SignedRegionDistance[ℛ, {1 / 4, 1 / 4, 1 / 4}]Nor for a 2D MeshRegion:
ℛ = MeshRegion[{{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}}, Polygon[{{1, 2, 3}, {2, 3, 4}}]];Show[ℛ, Graphics3D[{Red, Point[{1 / 4, 1 / 4, 1 / 4}]}]]SignedRegionDistance[ℛ, {1 / 4, 1 / 4, 1 / 4}]But it can for a 3D MeshRegion:
ℛ = MeshRegion[{{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {1, 0, 0}}, Tetrahedron[{{1, 2, 3, 4}}]];Show[HighlightMesh[ℛ, Style[2, Opacity[0.5]]], Graphics3D[{Red, Point[{1 / 4, 1 / 4, 1 / 4}]}]]SignedRegionDistance[ℛ, {1 / 4, 1 / 4, 1 / 4}]Derived Regions (3)
The signed distance to a RegionIntersection:
ℛ = RegionIntersection[Disk[{0, 0}, 1], Disk[{0, 1}, 1]];SignedRegionDistance[ℛ, {0, 1 / 2}]Show[DiscretizeRegion[ℛ], Graphics[{Red, Point[{0, 1 / 2}]}]]The signed distance to a TransformedRegion:
ℛ = TransformedRegion[Disk[], ScalingTransform[{3, 2}]];SignedRegionDistance[ℛ, {2, 1}]Show[DiscretizeRegion[ℛ, {{-3, 3}, {-2, 2}}], Graphics[{Red, Point[{2, 1}]}]]The signed distance to a RegionBoundary is always non-negative:
ℛ = RegionBoundary[Disk[]];SignedRegionDistance[ℛ, {1 / 2, 1 / 2}]Graphics[{ℛ, Red, Point[{1 / 2, 1 / 2}]}]CSG Regions (1)
The signed distance to a CSGRegion in 2D:
ℛ = CSGRegion["Difference", {Disk[], Disk[{1 / 2, 1 / 2}]}];SignedRegionDistance[ℛ, {-3 / 4, 0}]Show[ℛ, Graphics[{Red, Point[{-3 / 4, 0}]}]]ℛ = CSGRegion["Difference", {Cube[2], Cylinder[{{1, 1, 1}, {1, -1, 1}}]}];SignedRegionDistance[ℛ, {1 / 2, 1, 1 / 2}]Show[ℛ, Graphics3D[{Red, Point[{1 / 2, 1, 1 / 2}]}]]Subdivision Regions (1)
The signed distance to a SubdivisionRegion in 2D:
ℛ = SubdivisionRegion[Rectangle[]];SignedRegionDistance[ℛ, {1 / 2, 1 / 2}]Show[ℛ, Graphics[{Red, Point[{1 / 2, 1 / 2}]}]]ℛ = SubdivisionRegion[Cuboid[]];SignedRegionDistance[ℛ, {1, 1, 1}]Show[ℛ, Graphics3D[{Red, Point[{1, 1, 1}]}]]Applications (2)
If
is a region that is full-dimensional, then the depth of a point
is the negative signed region distance. Find the depth of {1,1} in Disk[{0,0},5]:
ℛ = Disk[{0, 0}, 5];
p = {1, 1};-SignedRegionDistance[ℛ, p]To illustrate it, you need to compute the nearest point in
:
q = RegionNearest[RegionDifference[FullRegion[2], ℛ], p]Graphics[{{StandardYellow, EdgeForm[StandardGray], ℛ}, {Red, Point[{p, q}]}, {Dashed, Line[{p, q}]}}]Find the depth of the point {1,1,1} in Cuboid[{0,0,0},{2,2,2}]:
ℛ = Cuboid[{0, 0, 0}, {2, 2, 2}];
p = {1, 1, 1};-SignedRegionDistance[ℛ, p]To illustrate it, you need to compute the nearest point in
:
q = RegionNearest[RegionDifference[FullRegion[3], ℛ], p]Graphics3D[{{Opacity[0.5], ℛ}, {Red, Point[{p, q}]}, {Dashed, Line[{p, q}]}}]Properties & Relations (5)
A point is a RegionMember if the signed distance to the region is non-positive:
ℛ = Disk[];Reduce[RegionMember[ℛ, {x, y}]⧦SignedRegionDistance[ℛ, {x, y}] ≤ 0, {x, y}, Reals]A point on the RegionBoundary has signed distance 0:
ℛ = Disk[];Reduce[RegionMember[RegionBoundary[ℛ], {x, y}]⧦SignedRegionDistance[ℛ, {x, y}] == 0, {x, y}, Reals]A point is in the interior of the region if the signed distance to the region is negative:
ℛ = Disk[];Reduce[RegionMember[ℛ, {x, y}] && !RegionMember[RegionBoundary[ℛ], {x, y}]⧦SignedRegionDistance[ℛ, {x, y}] < 0, {x, y}, Reals]Abs of SignedRegionDistance is the MinValue of the distance to the RegionBoundary:
ℛ = Disk[{0, 0}, {3, 2}];d1 = Abs[SignedRegionDistance[ℛ, {5, 5}]];d2 = MinValue[Norm[{5 - x, 5 - y}], {x, y}∈RegionBoundary[ℛ]];FullSimplify[d1 == d2]For a point outside the region, RegionDistance and SignedRegionDistance are the same:
ℛ = Disk[];Reduce[!RegionMember[ℛ, {x, y}]RegionDistance[ℛ, {x, y}] == SignedRegionDistance[ℛ, {x, y}], {x, y}, Reals]Related Guides
History
Text
Wolfram Research (2014), SignedRegionDistance, Wolfram Language function, https://reference.wolfram.com/language/ref/SignedRegionDistance.html.
CMS
Wolfram Language. 2014. "SignedRegionDistance." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SignedRegionDistance.html.
APA
Wolfram Language. (2014). SignedRegionDistance. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SignedRegionDistance.html
BibTeX
@misc{reference.wolfram_2026_signedregiondistance, author="Wolfram Research", title="{SignedRegionDistance}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/SignedRegionDistance.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_signedregiondistance, organization={Wolfram Research}, title={SignedRegionDistance}, year={2014}, url={https://reference.wolfram.com/language/ref/SignedRegionDistance.html}, note=[Accessed: 13-June-2026]}