WOLFRAM

RegionWithin[reg1,reg2]

returns True if reg2 is contained within reg1.

Details and Options

  • The region reg2 is contained within reg1 if every point that belongs to reg2 also belongs to reg1.
  • 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 RegionWithin will attempt to compute conditions on parameters such that reg2 is contained within reg1.
  • The following options can be given:
  • Assumptions $Assumptionsassumptions to make about parameters
    GenerateConditions Falsewhether to generate conditions on parameters

Examples

open allclose all

Basic Examples  (2)Summary of the most common use cases

Test whether a region is contained within another:

Out[3]=3

Visualize them:

Out[4]=4

Generate conditions for which a region is contained within another:

Out[2]=2

Scope  (15)Survey of the scope of standard use cases

Basic Uses  (3)

Test for membership:

Out[3]=3
Out[4]=4

Show a region is not within another:

Out[2]=2
Out[3]=3

Find conditions that make a region a subset of another:

Out[2]=2

Basic Regions  (4)

Regions in including Line and Interval:

Out[1]=1

Point:

Out[2]=2

Ball:

Out[3]=3

InfiniteLine:

Out[4]=4

Regions in including Point:

Out[2]=2

Line:

Out[4]=4
Out[5]=5

Polygon:

Out[7]=7
Out[8]=8

Disk and Ellipsoid:

Out[10]=10

Rectangle and RegularPolygon:

Out[11]=11

Regions in including Point:

Out[2]=2

Line:

Out[4]=4

Polygon:

Out[6]=6
Out[7]=7

Cuboid and Hexahedron:

Out[9]=9

Ball and Ellipsoid:

Out[11]=11

Tetrahedron and Simplex:

Out[13]=13

Regions in including Cuboid and Parallelepiped in :

Out[2]=2

Ellipsoid and Ball in :

Out[4]=4

Formula Regions  (4)

Implicit regions:

Out[3]=3

Parametric regions:

Out[2]=2

Compare two formula regions:

Out[2]=2

Nonconstant formula regions:

Out[1]=1

Mesh Regions  (3)

Compare MeshRegion in :

Out[3]=3

In :

Out[6]=6
Out[7]=7

In :

Out[10]=10
Out[11]=11

Compare BoundaryMeshRegion in :

Out[2]=2

In :

Out[4]=4
Out[5]=5

In :

Out[7]=7
Out[8]=8

Compare MeshRegion with BoundaryMeshRegion in :

Out[2]=2
Out[3]=3

In :

Out[5]=5
Out[6]=6

Derived Regions  (1)

Compare BooleanRegion:

Out[4]=4

Options  (2)Common values & functionality for each option

Assumptions  (1)

Find all disks that contain the unit circle:

Out[3]=3

Find only the positive radii:

Out[4]=4

GenerateConditions  (1)

Find when the unit disk lies within an implicitly described annulus:

Out[3]=3

Show the conditions for which the result is valid:

Out[3]=3

Explicitly allow for degenerate cases:

Out[5]=5

Applications  (7)Sample problems that can be solved with this function

All convex combinations of points lie within their convex hull:

Out[3]=3
Out[4]=4

Find the largest disk contained in a given triangle:

Out[3]=3
Out[4]=4
Out[5]=5

Approximate the largest axes-aligned ellipse contained in the triangle:

Out[7]=7
Out[8]=8

Find the smallest disk that contains a given triangle:

Out[3]=3
Out[4]=4

Find the smallest axes-aligned ellipse that contains the triangle:

Out[6]=6
Out[7]=7
Out[8]=8

Find all countries that lie completely within the Caribbean Sea:

The polygons of each country:

Select the countries whose polygons lie within the Caribbean Sea:

Out[3]=3

Verify the results:

Out[4]=4

View these countries on a map:

Out[5]=5

Find and visualize all positions where a unit rectangle lies within an annulus:

Out[3]=3

Perform a random walk inside a region:

Define a function to walk a point in a random direction, staying inside a region:

Simulate a random walk from an initial point:

Visualize the walk:

Out[5]=5

Use RegionWithin as a partial ordering to visualize concentric disks:

Disks with larger radii can completely cover other disks:

Out[3]=3

Sort the regions according to membership:

Visualize the rearranged disks:

Out[5]=5

Properties & Relations  (5)Properties of the function, and connections to other functions

Use RegionMember to test the membership of a point:

Out[2]=2

Use RegionWithin to test the membership of a region:

Out[3]=3
Out[4]=4

When 2 is within 1, all points in 2 are members of 1:

Out[2]=2
Out[3]=3

Check if two regions are equal:

Out[2]=2
Out[3]=3

For nonempty regions, RegionDisjoint returns False when RegionWithin returns True:

Out[2]=2
Out[3]=3

Use FindInstance to find points that violate the subset condition:

Out[2]=2
Out[4]=4

Use RandomPoint to find a uniform sampling of points that violate the subset condition:

Out[6]=6

Use Reduce to find where the subset condition is violated:

Out[7]=7
Out[8]=8
Wolfram Research (2017), RegionWithin, Wolfram Language function, https://reference.wolfram.com/language/ref/RegionWithin.html.
Wolfram Research (2017), RegionWithin, Wolfram Language function, https://reference.wolfram.com/language/ref/RegionWithin.html.

Text

Wolfram Research (2017), RegionWithin, Wolfram Language function, https://reference.wolfram.com/language/ref/RegionWithin.html.

Wolfram Research (2017), RegionWithin, Wolfram Language function, https://reference.wolfram.com/language/ref/RegionWithin.html.

CMS

Wolfram Language. 2017. "RegionWithin." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RegionWithin.html.

Wolfram Language. 2017. "RegionWithin." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RegionWithin.html.

APA

Wolfram Language. (2017). RegionWithin. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RegionWithin.html

Wolfram Language. (2017). RegionWithin. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RegionWithin.html

BibTeX

@misc{reference.wolfram_2025_regionwithin, author="Wolfram Research", title="{RegionWithin}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/RegionWithin.html}", note=[Accessed: 26-March-2025 ]}

@misc{reference.wolfram_2025_regionwithin, author="Wolfram Research", title="{RegionWithin}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/RegionWithin.html}", note=[Accessed: 26-March-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_regionwithin, organization={Wolfram Research}, title={RegionWithin}, year={2017}, url={https://reference.wolfram.com/language/ref/RegionWithin.html}, note=[Accessed: 26-March-2025 ]}

@online{reference.wolfram_2025_regionwithin, organization={Wolfram Research}, title={RegionWithin}, year={2017}, url={https://reference.wolfram.com/language/ref/RegionWithin.html}, note=[Accessed: 26-March-2025 ]}