RegionDisjoint[reg1,reg2]
returns True if the regions reg1 and reg2 are disjoint.
RegionDisjoint[reg1,reg2,reg3,…]
returns True if the regions reg1, reg2, reg3, … are pairwise disjoint.
RegionDisjoint
RegionDisjoint[reg1,reg2]
returns True if the regions reg1 and reg2 are disjoint.
RegionDisjoint[reg1,reg2,reg3,…]
returns True if the regions reg1, reg2, reg3, … are pairwise disjoint.
Details and Options
- The regions reg1 and reg2 are disjoint if there are no points that belong to both reg1 and reg2.
- If all regi are parameter-free regions, i.e. ConstantRegionQ[regi] is True, the regions are point sets, and typically True or False is returned.
- If some regi depend on parameters, i.e. ConstantRegionQ[regi] is False, then regi represents a family of regions, and RegionDisjoint will attempt to compute conditions on parameters such that the regions are disjoint.
- The following options can be given:
-
Assumptions $Assumptions assumptions to make about parameters GenerateConditions False whether to generate conditions on parameters
Examples
open all close allBasic Examples (2)
Test whether two regions are disjoint:
Subscript[ℛ, 1] = Triangle[];
Subscript[ℛ, 2] = Disk[{1, 1}, 1 / 2];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Graphics[{Opacity[0.5], {Red, Subscript[ℛ, 1]}, {Green, Subscript[ℛ, 2]}}]Generate conditions for which regions are disjoint:
Subscript[ℛ, 1] = Annulus[];
Subscript[ℛ, 2] = ImplicitRegion[Subsuperscript[r, 1, 2] ≤ x^2 + y^2 ≤ Subsuperscript[r, 2, 2], {x, y}];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Scope (17)
Basic Uses (5)
Show two regions are disjoint:
Subscript[ℛ, 1] = Rectangle[];
Subscript[ℛ, 2] = Disk[{2, 2}, 1];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Graphics[{Opacity[0.5], {Red, Subscript[ℛ, 1]}, {Green, Subscript[ℛ, 2]}}]Subscript[ℛ, 1] = Rectangle[];
Subscript[ℛ, 2] = Disk[];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Graphics[{Opacity[0.5], {Red, Subscript[ℛ, 1]}, {Green, Subscript[ℛ, 2]}}]Find conditions that make regions disjoint:
Subscript[ℛ, 1] = Disk[{x, y}];
Subscript[ℛ, 2] = Annulus[];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Show multiple regions are pairwise disjoint:
Subscript[ℛ, 1] = Disk[{-2, 1}];
Subscript[ℛ, 2] = Disk[];
Subscript[ℛ, 3] = Disk[{2, 1}];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2], Subscript[ℛ, 3]]Graphics[{Opacity[0.5], {Red, Subscript[ℛ, 1]}, {Green, Subscript[ℛ, 2]}, {Blue, Subscript[ℛ, 3]}}]Show multiple regions are not pairwise disjoint:
Subscript[ℛ, 1] = Disk[{-1, 1}];
Subscript[ℛ, 2] = Disk[];
Subscript[ℛ, 3] = Disk[{2, 1}];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2], Subscript[ℛ, 3]]Graphics[{Opacity[0.5], {Red, Subscript[ℛ, 1]}, {Green, Subscript[ℛ, 2]}, {Blue, Subscript[ℛ, 3]}}]Basic Regions (4)
Regions in
including Line and Interval:
RegionDisjoint[Line[{{0}, {1}}], Interval[{2, 4}]]RegionDisjoint[Point[{2}], Interval[{1, 3}]]Ball:
RegionDisjoint[Ball[1], Interval[{2, 3}]]RegionDisjoint[InfiniteLine[{0}, {1}], InfiniteLine[{-3}, {1}]]Regions in
including Point:
Subscript[ℛ, 1] = Point[RandomReal[1, {10, 2}]];
Subscript[ℛ, 2] = Point[RandomReal[1, {10, 2}]];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Graphics[{{Red, Subscript[ℛ, 1]}, {Green, Subscript[ℛ, 2]}}]Line:
Subscript[ℛ, 1] = Line[{{0, 0}, {1, 1}}];
Subscript[ℛ, 2] = Line[RandomReal[1, {10, 2}]];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Graphics[{{Red, Subscript[ℛ, 1]}, {Green, Subscript[ℛ, 2]}}]Subscript[ℛ, 1] = Polygon[{{1, 1 / 2}, {0, 3 / 2}, {-1 / 2, 1 / 2}, {0, 11 / 10}}];
Subscript[ℛ, 2] = Triangle[];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Graphics[{Opacity[0.5], {Red, Subscript[ℛ, 1]}, {Green, Subscript[ℛ, 2]}}]Subscript[ℛ, 1] = Disk[];
Subscript[ℛ, 2] = Ellipsoid[{1, 0}, {3, 2}];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Rectangle and RegularPolygon:
RegionDisjoint[Rectangle[{x, y}], RegularPolygon[4]]Regions in
including Point:
Subscript[ℛ, 1] = Point[RandomReal[1, {10, 3}]];
Subscript[ℛ, 2] = Point[RandomReal[1, {10, 3}]];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Line:
Subscript[ℛ, 1] = Line[RandomReal[1, {10, 3}]];
Subscript[ℛ, 2] = Line[RandomReal[1, {10, 3}]];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Subscript[ℛ, 1] = Polygon[{{1, 0, 1}, {0, 1, 2}, {1, 1, 1}, {2, 0, 0}}];
Subscript[ℛ, 2] = Triangle[{{0, 0, -1}, {2, -1, 1}, {2, 2, 1}}];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Graphics3D[{{Red, Subscript[ℛ, 1]}, {Green, Subscript[ℛ, 2]}}, Boxed -> False]Cuboid and Hexahedron:
Subscript[ℛ, 1] = Cuboid[];
Subscript[ℛ, 2] = Hexahedron[{{0, 0, 0}, {1, 0, 0}, {2, 1, 0}, {1, 1, 0}, {0, 0, 1}, {1, 0, 1}, {2, 1, 1}, {1, 1, 1}}];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Subscript[ℛ, 1] = Ball[3];
Subscript[ℛ, 2] = Ellipsoid[{1, 1, 2}, {3, 2, 1}];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Tetrahedron and Simplex:
Subscript[ℛ, 1] = Tetrahedron[];
Subscript[ℛ, 2] = Simplex[{{1, 0, 1}, {1, 0, 0}, {0, 0, 1}, {1, 1, 1}}];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Regions in
including Cuboid and Parallelepiped in
:
Subscript[ℛ, 1] = Cuboid[{0, 0, 0, 0}, {1, 1, 1, 1}];
Subscript[ℛ, 2] = Parallelepiped[{-1, -1, -1, -1}, -IdentityMatrix[4]];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Subscript[ℛ, 1] = Ellipsoid[Table[1, 10], Table[i, {i, 10}]];
Subscript[ℛ, 2] = Ball[10];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Formula Regions (4)
Subscript[ℛ, 1] = ImplicitRegion[1 / 2 ≤ x^2 + y^2 ≤ 1, {x, y}];
Subscript[ℛ, 2] = ImplicitRegion[(x - 1)^2 + y^2 == 9, {x, y}];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Subscript[ℛ, 1] = ParametricRegion[{2x y, x - y}, {{x, 0, 1}, {y, 0, 1}}];
Subscript[ℛ, 2] = ParametricRegion[{r Cos[θ] + 1, r Sin[θ]}, {{r, 0, 2}, {θ, 0, 2π}}];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Subscript[ℛ, 1] = ImplicitRegion[(x - 2)^4 + (y - 2)^4 + (z - 2)^4 ≤ 1, {x, y, z}];
Subscript[ℛ, 2] = ParametricRegion[{ρSqrt[4 - u^2]Cos[θ], ρSqrt[4 - u^2]Sin[θ], ρ u}, {{ρ, 0, 1}, {θ, 0, 2π}, {u, -2, 2}}];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]RegionDisjoint[Annulus[], ImplicitRegion[Subsuperscript[r, 1, 2] ≤ x^2 + y^2 ≤ Subsuperscript[r, 2, 2], {x, y}]]Mesh Regions (3)
Compare MeshRegion in
:
Subscript[ℛ, 1] = MeshRegion[{{0}, {2}}, Line[{1, 2}]];
Subscript[ℛ, 2] = MeshRegion[{{1}, {3}}, Line[{1, 2}]];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Subscript[ℛ, 1] = DiscretizeGraphics[Annulus[]];
Subscript[ℛ, 2] = DiscretizeGraphics[Disk[{1 / 3, 0}, 1 / 4]];Show[Subscript[ℛ, 1], Subscript[ℛ, 2]]RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Subscript[ℛ, 1] = DiscretizeGraphics[Ball[]];
Subscript[ℛ, 2] = DiscretizeGraphics[Cuboid[{1, 1, 1}]];Show[Subscript[ℛ, 2], Subscript[ℛ, 1]]RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Compare BoundaryMeshRegion in
:
Subscript[ℛ, 1] = BoundaryMeshRegion[{{0}, {2}}, Point[{1, 2}]];
Subscript[ℛ, 2] = BoundaryMeshRegion[{{1}, {3}}, Point[{1, 2}]];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Subscript[ℛ, 1] = BoundaryDiscretizeGraphics[Annulus[]];
Subscript[ℛ, 2] = BoundaryDiscretizeGraphics[Disk[{1 / 3, 0}, 1 / 4]];Show[Subscript[ℛ, 1], Subscript[ℛ, 2]]RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Subscript[ℛ, 1] = BoundaryDiscretizeGraphics[Ball[]];
Subscript[ℛ, 2] = BoundaryDiscretizeGraphics[Cuboid[{1, 1, 1}]];Show[Subscript[ℛ, 2], Subscript[ℛ, 1]]RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Compare MeshRegion with BoundaryMeshRegion in
:
Subscript[ℛ, 1] = DelaunayMesh[RandomReal[{-2, 0}, {25, 2}]];
Subscript[ℛ, 2] = ConvexHullMesh[RandomReal[{0, 2}, {25, 2}]];Show[Subscript[ℛ, 1], Subscript[ℛ, 2]]RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Subscript[ℛ, 1] = DelaunayMesh[RandomReal[{-1, 1}, {25, 3}]];
Subscript[ℛ, 2] = ConvexHullMesh[RandomReal[{0, 1}, {25, 3}]];Show[Subscript[ℛ, 1], Subscript[ℛ, 2]]RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Derived Regions (1)
Compare BooleanRegion:
Subscript[ℛ, 1] = Rectangle[{2, 0}];
Subscript[ℛ, 2] = BooleanRegion[Xnor, {Disk[], Disk[{2, 0}, 2]}];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Options (2)
Assumptions (1)
Find all radii where a concentric disk and annulus are disjoint:
Subscript[ℛ, 1] = Disk[];
Subscript[ℛ, 2] = ImplicitRegion[Subsuperscript[r, 1, 2] ≤ x^2 + y^2 ≤ Subsuperscript[r, 2, 2], {x, y}];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2], Assumptions -> 0 < Subscript[r, 1] < Subscript[r, 2]]GenerateConditions (1)
Find when the unit disk is disjoint with an implicitly described annulus:
Subscript[ℛ, 1] = Disk[];
Subscript[ℛ, 2] = ImplicitRegion[Subscript[r, 1] ≤ x^2 + y^2 ≤ Subscript[r, 2], {x, y}];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]Show the conditions for which the result is valid:
RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2], GenerateConditions -> True]Explicitly allow for degenerate cases:
RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2], Assumptions -> Subscript[r, 1]∈Reals]Applications (6)
Estimate
by simulating Buffon's needle problem:
d = 0.2;n = 1000;lines = MeshRegion[
Join@@Table[{{-1 - d, y}, {1 + d, y}}, {y, -1 - d, 1 + d, d}],
Line[Partition[Range[2Floor[2 / d + 3]], 2]]
];Create randomly orientated line segments of length
:
needles = Table[Line[{pt, RandomPoint[Circle[pt, d]]}], {pt, RandomReal[{-1, 1}, {n, 2}]}];Select line segments that overlap the grid of lines:
overlap = Select[needles, !RegionDisjoint[lines, #]&];Visualize overlapping line segments (red):
Show[lines, Graphics[{Red, overlap, StandardGray, Complement[needles, overlap]}]]N[(2n/Length[overlap])]Detect collisions between an object and a collection of walls:
cow = ExampleData[{"Geometry3D", "Cow"}, "MeshRegion"];w1 = Hyperplane[{1, 0, 0}, 0.39];
w2 = Hyperplane[{1, 0, 0}, -0.45];Color walls that do not collide with the cow green, and red otherwise:
wallColor[reg_] := If[RegionDisjoint[cow, reg], Green, Red]Show[cow, Graphics3D[{{wallColor[w1], w1}, {wallColor[w2], w2}}], PlotRangePadding -> .04]Find all countries that share a border with France:
c = Entity["Country", "France"];
p = c["Polygon"] /. GeoPosition -> Identity;all = EntityValue["Country", "Polygon", "EntityAssociation"] /. GeoPosition -> Identity;Select the countries whose polygons are not disjoint from France's polygon:
DeleteCases[Keys[Select[all, !RegionDisjoint[p, #]&]], c]//Sortc["BorderingCountries"]View these countries on a map:
GeoGraphics[{EdgeForm[Black], GeoStyling[LightGray], Polygon[%], GeoStyling[Red], Polygon[c]}]Find and visualize all positions where a unit rectangle is disjoint from an annulus:
Subscript[ℛ, 1] = Rectangle[{x, y}];
Subscript[ℛ, 2] = Annulus[{0, 0}, {1, 2}];cond = RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]RegionPlot[cond, {x, -4, 3}, {y, -4, 3}, Epilog -> {Red, Opacity[0.1], Subscript[ℛ, 2]}]Perform a random walk outside of a region:
ℛ = Annulus[{0, 0}, {1 / 2, 1}, {π / 12, 23π / 12}];Define a function to walk a point in a random direction, staying outside of a region:
walkPoint[pt_, r_, reg_] :=
Block[{npt = RandomPoint[Sphere[pt, r]]},
While[!RegionDisjoint[Line[{pt, npt}], reg],
npt = RandomPoint[Sphere[pt, r]]
];
npt
]Simulate a random walk from an initial point:
start = {0, 0};path = NestList[walkPoint[#, 0.1, ℛ]&, start, 500];Graphics[{{Green, ℛ}, {Line[path]}, {Red, Point[start]}}]Create a network that connects two US states if they share a border:
usa = EntityClass["AdministrativeDivision", "ContinentalUSStates"];polys = EntityValue[usa, "Polygon", "EntityAssociation"] /. {GeoPosition -> Identity, {x_Real, y_} :> {y, x}};Two state's polygons share a border when RegionDisjoint returns False:
statesBorderQ[loc1_, loc2_] := loc1 =!= loc2 && !RegionDisjoint[polys[loc1], polys[loc2]]g = RelationGraph[statesBorderQ, Keys[polys]]Style this network atop a map of the United States:
coords = EntityValue[usa, "Coordinates"];g = Graph[g, VertexCoordinates -> Reverse /@ coords, EdgeStyle -> Directive[{Red, Thick}], Prolog -> {EdgeForm[Thin], LightGreen, Values[polys]}, PlotRange -> RegionBounds[RegionUnion@@Values[polys]]]The largest disconnect is between Maine and the westernmost states:
GraphPeriphery[g]Find and highlight a path from Maine to California:
path = FindShortestPath[g, Entity["AdministrativeDivision", {"Maine", "UnitedStates"}], Entity["AdministrativeDivision", {"California", "UnitedStates"}]];HighlightGraph[g, Style[PathGraph[path], Blue]]Properties & Relations (4)
A region and its complement are always disjoint:
ℛ = Disk[];RegionDisjoint[ℛ, BooleanRegion[Not, {ℛ}]]Disjoint regions share no common point:
Subscript[ℛ, 1] = Disk[];
Subscript[ℛ, 2] = Rectangle[{2, 0}];Resolve[Exists[{x, y}, {x, y}∈Subscript[ℛ, 1]∧{x, y}∈Subscript[ℛ, 2]]]RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]For non‐empty regions, RegionEqual and RegionWithin return False when RegionDisjoint returns True:
Subscript[ℛ, 1] = Disk[];
Subscript[ℛ, 2] = Disk[{2, 1}];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]RegionWithin[Subscript[ℛ, 1], Subscript[ℛ, 2]]Use FindInstance to find points that lie in the intersection of two regions:
Subscript[ℛ, 1] = Rectangle[];
Subscript[ℛ, 2] = Parallelogram[];RegionDisjoint[Subscript[ℛ, 1], Subscript[ℛ, 2]]pts = {x, y} /. FindInstance[{x, y}∈Subscript[ℛ, 1]∧{x, y}∈Subscript[ℛ, 2], {x, y}, 100];Graphics[{Point[pts], Opacity[0.5], {Red, Subscript[ℛ, 1]}, {Green, Subscript[ℛ, 2]}}]Use RandomPoint to find a uniform sampling of points that lie in the intersection of two regions:
pts = RandomPoint[BooleanRegion[#1∧#2&, {Subscript[ℛ, 1], Subscript[ℛ, 2]}], 100];Graphics[{Point[pts], Opacity[0.5], {Red, Subscript[ℛ, 1]}, {Green, Subscript[ℛ, 2]}}]Use Reduce to find where two regions overlap:
Reduce[{x, y}∈Subscript[ℛ, 1]∧{x, y}∈Subscript[ℛ, 2], {x, y}]RegionPlot[%, {x, -1, 3}, {y, -3 / 2, 5 / 2}, PlotPoints -> 60]Neat Examples (1)
Create a scene of randomly placed, disjoint balls:
randomBall[dim_] := Ball[{RandomReal[{0, 10}, dim]}, {RandomReal[{1 / 4, 1}]}]appendDisjointBall[dim_][reg : Ball[pts_, rs_]] :=
Block[{ball = randomBall[dim]},
While[!RegionDisjoint[ball, reg],
ball = randomBall[dim]
];
Ball[Join[pts, #1], Join[rs, #2]]&@@ball
]disjointBalls[n_, dim_] := Nest[appendDisjointBall[dim], randomBall[dim], n - 1]n = 40;
scene2D = disjointBalls[n, 2];Graphics[{EdgeForm[StandardGray], Thread[{RandomColor[Hue[_], n], Thread[scene2D]}]}]n = 100;
scene3D = disjointBalls[n, 3];Graphics3D[Thread[{RandomColor[Hue[_], n], Thread[scene3D]}], Lighting -> "Neutral"]Related Guides
History
Text
Wolfram Research (2017), RegionDisjoint, Wolfram Language function, https://reference.wolfram.com/language/ref/RegionDisjoint.html.
CMS
Wolfram Language. 2017. "RegionDisjoint." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RegionDisjoint.html.
APA
Wolfram Language. (2017). RegionDisjoint. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RegionDisjoint.html
BibTeX
@misc{reference.wolfram_2026_regiondisjoint, author="Wolfram Research", title="{RegionDisjoint}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/RegionDisjoint.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_regiondisjoint, organization={Wolfram Research}, title={RegionDisjoint}, year={2017}, url={https://reference.wolfram.com/language/ref/RegionDisjoint.html}, note=[Accessed: 13-June-2026]}