Symbolic Regions

Adam Strzebonski

Wolfram Research, Inc.

Specifying regions

A region is a subset R⊆(ℝ^n) for some n∈(SubPlus[ℤ]).

2D and 3D graphics primitives

• Point
• Line
• Rectangle
• Polygon
• Disk
• Circle
• Tetrahedron
• Pyramid
• Prism
• Hexahedron
• Cuboid
• Sphere
• Cylinder
• Cone

n-dimensional special regions

• EmptyRegion
• FullRegion
• Point
• Line
• BoxRegion
• Simplex
• Ball
• Ellipsoid
• InfiniteLine
• HalfLine
• InfinitePlane
• HalfPlane
• ConicHullRegion

General regions

• ImplicitRegion
• ParametricRegion
• MeshRegion
• BoundaryMeshRegion

Derived regions

• RegionUnion
• RegionIntersection
• RegionDifference
• RegionSymmetricDifference
• BooleanRegion
• RegionProduct
• TransformedRegion
• InverseTransformedRegion

Implicit regions

A region defined as the solution set of a condition

{((Subscript[x, 1]),…,(Subscript[x, n]))∈(ℝ^n): Φ((Subscript[x, 1]),…,(Subscript[x, n]))}

is represented as

ImplictRegion[Φ,{(Subscript[x, 1]),…,(Subscript[x, n])}]

R=ImplicitRegion[(x^2)+(y^2)<7&&(x^6)-5 (x^4) y+3 (x^4) (y^2)+10 (x^2) (y^3)+3 (x^2) (y^4)-(y^5)+(y^6)≥0,{x,y}]

Region`SemialgebraicRegionPlot[R,{{-3,3},{-3,3}}]

Parametric regions

A parametric region with unrestricted parameters

{((Subscript[f, 1])((Subscript[t, 1]),…,(Subscript[t, m])),…,(Subscript[f, n])((Subscript[t, 1]),…,(Subscript[t, m])))∈(ℝ^n):((Subscript[t, 1]),…,(Subscript[t, m]))∈(ℝ^m)}

is represented as

ParametricRegion[{(Subscript[f, 1]),…,(Subscript[f, m])},{(Subscript[x, 1]),…,(Subscript[x, n])}]

R=ParametricRegion[{((1-(t^2))/(1+(t^2))),((2 t (7-182 (t^2)+1001 (t^4)-1716 (t^6)+1001 (t^8)-182 (t^10)+7 (t^12)))/(((1+(t^2)))^7))},{t}]

Region`SemialgebraicRegionPlot[R,{{-1.5,1.5},{-1.5,1.5}}]

RegionElement[{x,y},R]

A parametric region with restrictions on parameters

{((Subscript[f, 1])((Subscript[t, 1]),…,(Subscript[t, m])),…,(Subscript[f, n])((Subscript[t, 1]),…,(Subscript[t, m])))∈(ℝ^n):Φ((Subscript[t, 1]),…,(Subscript[t, m]))}

is represented as

ParametricRegion[{{(Subscript[f, 1]),…,(Subscript[f, m])},Φ},{(Subscript[x, 1]),…,(Subscript[x, n])}]

R=ParametricRegion[{{Exp[x+y],Cos[7 x y]},(x^2)+(y^2)≤(1/2)},{x,y}]

Region`SemialgebraicRegionPlot[R,{{0,3},{-0.5,1.5}}]

{1,(1/2)}∈R

Boolean operations on regions

A Boolean combination of regions.

(Subscript[R, 1])=Disk[];
(Subscript[R, 2])=Rectangle[{(1/2),(1/2)},{(3/2),(3/2)}];
(Subscript[R, 3])=ImplicitRegion[(x^4)+(y^4)≤1,{x,y}];
(Subscript[R, 4])=RegionSymmetricDifference[(Subscript[R, 3]),RegionUnion[(Subscript[R, 1]),(Subscript[R, 2])]]

Region`SemialgebraicRegionPlot[(Subscript[R, 4]),{{-(3/2),2},{-(3/2),2}}]

The same region expressed as a single BooleanRegion.

(Subscript[R, 5])=BooleanRegion[#3⊻(#1||#2)&,{(Subscript[R, 1]),(Subscript[R, 2]),(Subscript[R, 3])}]

RegionElement[{x,y},RegionSymmetricDifference[(Subscript[R, 4]),(Subscript[R, 5])]]

Transformed regions

The image of a region through a mapping.

R=TransformedRegion[Disk[],{Indexed[#1, 1]^3 + Indexed[#1, 2], 
     Indexed[#1, 1] Indexed[#1, 2]}&]

Region`SemialgebraicRegionPlot[R,{{-(3/2),(3/2)},{-1,1}}]

The inverse image of a region through a mapping.

R=InverseTransformedRegion[Disk[],{Indexed[#1, 1]^3 + Indexed[#1, 2], 
     Indexed[#1, 1] Indexed[#1, 2]}&]

Region`SemialgebraicRegionPlot[R,{{-(3/2),(3/2)},{-(3/2),(3/2)}}]

Properties of regions

Point membership

• Element
• RegionElement

Dimension properties

• RegionEmbeddingDimension
• RegionDimension

Distance properties

• RegionDistance
• SignedRegionDistance
• RegionNearest
• BoundedRegionQ

Convexity

• ConvexRegionQ

Measure properties

• RegionMeasure
• RegionCentroid

Regions as input to solvers…

Point membership

A somewhat more complicated BooleanRegion.

regs={ParametricRegion[{{t,((t^2)/2)},-3≤t≤3},{t}],Disk[{0,0},4],Ellipsoid[{0,-1},{(7/4),2}],Disk[{0,-(1/2)},2],Disk[{-(3/2),1},(3/4)],Disk[{(3/2),1},(3/4)],Disk[{-(14/10),(11/10)},(1/4)],Disk[{(16/10),(11/10)},(1/4)],Circle[{-(46/15),(1058/225)},((Sqrt[9181])/450)],Circle[{(46/15),(1058/225)},((Sqrt[9181])/450)]};
R=BooleanRegion[((#1||(#2&&!#3)||#4)&&!#5&&!#6)||#7||#8||#9||#10&,regs];

Region`SemialgebraicRegionPlot[R,{{-5,5},{-5,5}}]

Element[{0,0},R]

Element[{-2,1},R]

Element[{x,y},R]

RegionElement[{x,y},R]

Dimension properties

R=ImplicitRegion[(x^2)+(y^2)+(z^2)+(t^2)==1,{x,y,z,t}]

The dimension of the space in which the region is embeded (simple structural check).

RegionEmbeddingDimension[R]

The dimension of the region (requires nontrivial computation in general).

RegionDimension[R]

Distance properties

RegionDistance[R, p] - the distance from the point p to the region R.
RegionNearest[R, p] - a point in the region R nearest to the point p.
SignedRegionDistance[R, p] - the signed distance from the point p to the region R.

R=ImplicitRegion[-(x^2) (-(5/4)+(x^2))+(y^2) (-1+(y^2))≤0,{x,y}];
pl=Region`SemialgebraicRegionPlot[R,{{-3,3},{-3,3}}];
Manipulate[Show[{pl,Graphics[{Text[Style[N[RegionDistance[R,p]],Large],{0,2.75}],Text[Style[N[SignedRegionDistance[R,p]],Large],{0,2.25}],{Red,Line[{N[RegionNearest[R,p]],p}]}}]}],{{p,{0.5,0}},Locator}]

BoundedRegionQ[R]

Convexity

R=ImplicitRegion[(x^3)-(y^2)≥x,{x,y}];Region`SemialgebraicRegionPlot[R,{{-2,2},{-2,2}}]

ConvexRegionQ[R]

S=RegionIntersection[R,HalfPlane[{0,0},{0,1},{-1,0}]];

ConvexRegionQ[S]

Measure properties

The area and centroid of a deltoid.

R=ImplicitRegion[-27-8 x ((x^2)-3 (y^2))+18 ((x^2)+(y^2))+((((x^2)+(y^2)))^2)≤0,{x,y}];
Region`SemialgebraicRegionPlot[R,{{-2,3.5},{-3,3}}]

RegionMeasure[R]//Timing

Together[%[[2]]]

RegionCentroid[R]//Timing

For most special regions measure and centroid are found using closed form formulas.

R=Cone[{{1,2,3},{4,5,6}},7];

RegionMeasure[R]

RegionCentroid[R]

Graphics3D[{{Green,Opacity[0.5],R},{Red,PointSize[Large],Point[%]}}]