RegionMemberFunction[reg,…]
represents a function whose values give whether a point is in a region reg or not.
RegionMemberFunction
RegionMemberFunction[reg,…]
represents a function whose values give whether a point is in a region reg or not.
Details
- RegionMemberFunction works like Function.
- RegionMemberFunction is generated by RegionMember[reg].
- RegionMemberFunction[reg,…][{x,y,…}] gives True if the numerical point {x,y,…} is a member of the constant region reg where ConstantRegionQ[reg] is True.
Examples
open all close allBasic Examples (1)
RegionMember for a region generates a RegionMemberFunction:
mf = RegionMember[Disk[]]Apply function repeatedly for member tests:
Map[mf, RandomReal[{-1, 1}, {10, 2}]]Scope (20)
Special Regions (5)
Use RegionMember to generate a RegionMemberFunction:
ℛ = Polygon[{{0, 0}, {2, -1}, {1, 0}, {2, 1}}];
Region[ℛ]mf = RegionMember[ℛ]Apply it to a list of points to test membership:
mf[{{1 / 2, 0}, {3, 4}}]pts = RandomVariate[UniformDistribution[RegionBounds[ℛ]], 10 ^ 3];
col = mf[pts] /. {False -> Gray, True -> Red};Graphics[{ℛ, AbsolutePointSize[1.6], {col, Point /@ pts}}]Test for points within an Interval:
ℛ = Interval[{0, 1}];
gr = NumberLinePlot[ℛ]mf = RegionMember[ℛ]Apply it to a list of points to test membership:
pts = RandomVariate[UniformDistribution[{{-0.5, 1.5}}], 100];
col = mf[pts] /. {False -> Gray, True -> Red};gp = Graphics[{AbsolutePointSize[1.6], Table[{col[[i]], Point[{pts[[i, 1]], 3}]}, {i, 100}]}];Show[gr, gp, PlotRange -> All]Test for points within a Disk:
ℛ = Disk[{0, 0}, 2];
Region[ℛ]mf = RegionMember[ℛ]Apply it to a list of points to test membership:
pts = RandomVariate[UniformDistribution[RegionBounds[ℛ]], 10 ^ 3];
col = mf[pts] /. {False -> Gray, True -> Red};Graphics[{ℛ, AbsolutePointSize[1.6], {col, Point /@ pts}}]Test for points within a Cylinder:
ℛ = Cylinder[{{0, 0, 0}, {2, 2, 2}}, 2];
gr = Graphics3D[{Opacity[0.3], ℛ}, Boxed -> False, Lighting -> "Neutral"]mf = RegionMember[ℛ]Apply it to a list of points to test membership:
pts = RandomVariate[UniformDistribution[RegionBounds[ℛ]], 10 ^ 3];
col = mf[pts] /. {False -> Gray, True -> Red};Show[gr, Graphics3D[{AbsolutePointSize[2], {col, Point /@ pts}}]]ℛ = Ball[{0, 0, 0, 0, 0, 0, 0}, 1];
pl = RandomReal[{0, 0.7}, {7, 7}];mf = RegionMember[ℛ];mf /@ plFormula Regions (3)
A union of two disks as an ImplicitRegion:
ℛ = ImplicitRegion[x^2 + y^2 ≤ 4∨(x - 3)^2 + y^2 ≤ 3, {x, y}];
DiscretizeRegion[ℛ, {{-6, 6}, {-2, 2}}]mf = RegionMember[ℛ]Apply it to a list of points to test membership:
mf[{{1, 1}, {2, 2}}]pts = RandomVariate[UniformDistribution[RegionBounds[ℛ]], 10 ^ 4];
col = mf[pts] /. {False -> Gray, True -> Red};Graphics[{AbsolutePointSize[1], {col, Point /@ pts}}]A union of two cylinders as an ImplicitRegion:
ℛ = ImplicitRegion[x^2 + y^2 ≤ 2∨(x - 2)^2 + y^2 ≤ 1, {x, y, {z, 0, 2}}];
DiscretizeRegion[ℛ, {2{-2, 2}, {-2, 2}, {0, 2}}]mf = RegionMember[ℛ]Apply it to a list of points to test membership:
pts = RandomVariate[UniformDistribution[RegionBounds[ℛ]], 10 ^ 4];
col = mf[pts] /. {False -> Gray, True -> Red};Graphics3D[{AbsolutePointSize[1.6], {col, Point /@ pts}}]A disk represented as a ParametricRegion:
ℛ = ParametricRegion[{r Cos[θ], r Sin[θ]}, {{r, 0, 1}, {θ, 0, 2π}}];mf = RegionMember[ℛ]Apply it to a list of points to test membership:
pts = RandomVariate[UniformDistribution[RegionBounds[ℛ]], 10 ^ 4];
col = mf[pts] /. {False -> Gray, True -> Red};Graphics[{AbsolutePointSize[1], {col, Point /@ pts}}]Mesh Regions (6)
MeshRegion in 1D:
ℛ = DelaunayMesh[RandomReal[1, {10, 1}]]mf = RegionMember[ℛ]Apply it to a list of points to test membership:
mf[{{1 / 2}, {3}}]ℛ = DelaunayMesh[RandomReal[2, {50, 2}]]mf = RegionMember[ℛ]Apply it to a list of points to test membership:
pts = RandomVariate[UniformDistribution[RegionBounds[ℛ]], 10 ^ 4];
col = mf[pts] /. {False -> Gray, True -> Red};Graphics[{AbsolutePointSize[1], {col, Point /@ pts}}]ℛ = DelaunayMesh[RandomReal[1, {100, 3}]]mf = RegionMember[ℛ]Apply it to a list of points to test membership:
pts = RandomVariate[UniformDistribution[RegionBounds[ℛ]], 10 ^ 4];
col = mf[pts] /. {False -> Gray, True -> Red};Graphics3D[{AbsolutePointSize[1], {col, Point /@ pts}}]BoundaryMeshRegion in 1D:
ℛ = ConvexHullMesh[RandomReal[1, {10, 1}]]mf = RegionMember[ℛ]Apply it to a list of points to test membership:
mf[{{1 / 2}, {3}}]ℛ = ConvexHullMesh[RandomReal[1, {50, 2}]]mf = RegionMember[ℛ]Apply it to a list of points to test membership:
pts = RandomVariate[UniformDistribution[RegionBounds[ℛ]], 10 ^ 4];
col = mf[pts] /. {False -> Gray, True -> Red};Graphics[{AbsolutePointSize[1], {col, Point /@ pts}}]ℛ = ConvexHullMesh[RandomReal[1, {100, 3}]]mf = RegionMember[ℛ]MeshCoordinates are always members of the region:
AllTrue[MeshCoordinates[ℛ], mf]Derived Regions (2)
RegionIntersection of two regions:
ℛ = RegionIntersection[Disk[{0, 0}, 1], Disk[{0, 1}, 1]];Region[ℛ]mf = RegionMember[ℛ]Apply it to a list of points to test membership:
mf[{{0, 1}, {3, 4}}]pts = RandomVariate[UniformDistribution[RegionBounds[ℛ]], 10 ^ 4];
col = mf[pts] /. {False -> Gray, True -> Red};Graphics[{AbsolutePointSize[1], {col, Point /@ pts}}]ℛ = TransformedRegion[Disk[{0, 0}, 1], ScalingTransform[{3, 2}]];DiscretizeRegion[ℛ, {{-3, 3}, {-2, 2}}]mf = RegionMember[ℛ]Apply it to a list of points to test membership:
pts = RandomVariate[UniformDistribution[RegionBounds[ℛ]], 10 ^ 4];
col = mf[pts] /. {False -> Gray, True -> Red};Graphics[{AbsolutePointSize[1], {col, Point /@ pts}}]CSG Regions (2)
CSGRegion in 2D:
ℛ = CSGRegion["Difference", {Disk[], Disk[{1 / 2, 1 / 2}]}];mf = RegionMember[ℛ]Apply it to a list of points to test membership:
pts = RandomVariate[UniformDistribution[RegionBounds[ℛ]], 10 ^ 4];
col = mf[pts] /. {False -> Gray, True -> Red};Graphics[{AbsolutePointSize[1], {col, Point /@ pts}}]CSGRegion in 3D:
ℛ = CSGRegion["Difference", {Cube[3], Cuboid[{-1, -3, -1}, {3, 3, 3}]}];mf = RegionMember[ℛ]Apply it to a list of points to test membership:
pts = RandomVariate[UniformDistribution[RegionBounds[ℛ]], 10 ^ 4];
col = mf[pts] /. {False -> Gray, True -> Red};Graphics3D[{AbsolutePointSize[1], {col, Point /@ pts}}]Subdivision Regions (2)
SubdivisionRegion in 2D:
ℛ = SubdivisionRegion[Rectangle[]];mf = RegionMember[ℛ]Apply it to a list of points to test membership:
pts = RandomVariate[UniformDistribution[RegionBounds[ℛ]], 10 ^ 4];
col = mf[pts] /. {False -> Gray, True -> Red};Graphics[{AbsolutePointSize[1], {col, Point /@ pts}}]SubdivisionRegion in 3D:
ℛ = SubdivisionRegion[Tetrahedron[]];mf = RegionMember[ℛ]Apply it to a list of points to test membership:
pts = RandomVariate[UniformDistribution[RegionBounds[ℛ]], 10 ^ 4];
col = mf[pts] /. {False -> Gray, True -> Red};Graphics3D[{AbsolutePointSize[1], {col, Point /@ pts}}]Applications (3)
Generate points on a region by filtering a uniform set of points:
ℛ = BoundaryDiscretizeGraphics[CountryData["US", {"Polygon", "Equirectangular"}]];bounds = RegionBounds[ℛ];Uniformly sample over the bounding box of the region:
pts = RandomVariate[UniformDistribution[bounds], 10 ^ 4];mpts = Select[pts, RegionMember[ℛ]];Graphics[{AbsolutePointSize[1], Point[mpts]}]Color points based on which region they belong to:
Subscript[ℛ, 1] = BoundaryDiscretizeGraphics[CountryData["US", {"Polygon", "Equirectangular"}]];
Subscript[ℛ, 2] = BoundaryDiscretizeGraphics[CountryData["Canada", {"Polygon", "Equirectangular"}]];Create membership functions for each:
mf1 = RegionMember[Subscript[ℛ, 1]];
mf2 = RegionMember[Subscript[ℛ, 2]];Generate points over a bounding box of both regions:
pts = RandomVariate[UniformDistribution[RegionBounds[RegionUnion[Subscript[ℛ, 1], Subscript[ℛ, 2]]]], 10 ^ 4];Graphics[{AbsolutePointSize[1], {Red, Point@Select[pts, mf1]}, {Blue, Point@Select[pts, mf2]}, {Black, Point@Select[pts, !mf1[#] && !mf2[#]&]}}]Use random points in a region to perform Monte Carlo integration:
ℛ = ImplicitRegion[2 ≤ x^2 + y^2 ≤ 4, {x, y}];
mf = RegionMember[ℛ];
pts = Select[RandomVariate[UniformDistribution[RegionBounds[ℛ]], 10 ^ 5], mf];Evaluate a function at each sample point and take their average:
f[x_, y_] := x^3 + y^4;
intVal = Mean[f@@@pts] * RegionMeasure[ℛ]Integrate[f[x, y], {x, y}∈ℛ]%//NProperties & Relations (1)
RegionMemberFunction is generated by RegionMember:
mf = RegionMember[Disk[{0, 0}, 1]]mf@RandomReal[1, {7, 2}]Possible Issues (1)
RegionMemberFunction can only be generated for ConstantRegionQ regions:
ℛ = Disk[{x, y}, r]ConstantRegionQ[ℛ]RegionMember[ℛ]Generate the member function for a specific instance:
mf = RegionMember[ℛ /. {x -> 0, y -> 2, r -> 1}]mf[{{0, 1}, {10, 10}}]Related Guides
History
Text
Wolfram Research (2014), RegionMemberFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/RegionMemberFunction.html.
CMS
Wolfram Language. 2014. "RegionMemberFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RegionMemberFunction.html.
APA
Wolfram Language. (2014). RegionMemberFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RegionMemberFunction.html
BibTeX
@misc{reference.wolfram_2026_regionmemberfunction, author="Wolfram Research", title="{RegionMemberFunction}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/RegionMemberFunction.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_regionmemberfunction, organization={Wolfram Research}, title={RegionMemberFunction}, year={2014}, url={https://reference.wolfram.com/language/ref/RegionMemberFunction.html}, note=[Accessed: 13-June-2026]}