4
$\begingroup$

I can get the region of a disk $\{x,y\}\in\{x^2+y^2 \leq 1\}$ as follows:

Region[Disk[]]

enter image description here

Now my question is: Is there also an automated way to get the perimeter region ?

$$\{x,y\}\in\{x^2+y^2=1\}$$

Many thanks !

$\endgroup$
1
  • 2
    $\begingroup$ RegionBoundary[Region[Disk[]]]? $\endgroup$
    – kglr
    Commented Apr 6, 2020 at 6:18

1 Answer 1

7
$\begingroup$

Update: Composing RegionMember, RegionBoundary and FullSimplify:

ClearAll[boundaryRF]
boundaryRF = FullSimplify[RegionMember[RegionBoundary @ #, #2], #2 ∈ Reals] &;

Examples:

Grid[{#, boundaryRF[#, {x, y}]} & /@ 
   {Disk[], Disk[{a, b}, r], Rectangle[], Triangle[]}, 
 Dividers -> All]

enter image description here

Grid[{#, boundaryRF[#, {x, y, z}]} & /@ 
   {Ball[], Ball[{a, b, c}, r], Tetrahedron[], Cone[]}, 
  Dividers -> All]

enter image description here Original answer:

For Disk yes:

RegionBoundary[Disk[]]
Circle[{0, 0}]
RegionMember[%, {x, y}]
(x | y) ∈ Reals && x^2 + y^2 == 1

Works with symbolic parameters too:

RegionBoundary[Disk[{a, b}, r]]
Circle[{a, b}, r]
RegionMember[%, {x, y}]
(x | y) ∈ Reals && r > 0 && (-a + x)^2 + (-b + y)^2 == r^2

... and few other primitives:

RegionBoundary[Ball[]]
 Sphere[{0, 0, 0}]
RegionMember[%, {x, y, z}]
(x | y | z) ∈ Reals && x^2 + y^2 + z^2 == 1
RegionBoundary[Rectangle[]]
 Line[{{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}}]
RegionMember[%, {x, y}] // FullSimplify
 (x | y) ∈ Reals && ((0 <= y <= 1 && (x == 0 || x == 1)) || (0 <= x <= 
  1 && (y == 0 || y == 1)))

Acknowledgement: Thank you Chip Hurst for reminding me that we can use RegionMember instead of

Region`RegionProperty[%, {x, y}, "FastDescription"][[1, -1]]

to get the region function.

$\endgroup$
8
  • $\begingroup$ Very nice ! Thank you very much !! One question: when you type Region`RegionProperty[... what does the ` stand for ? $\endgroup$
    – james
    Commented Apr 6, 2020 at 6:49
  • 1
    $\begingroup$ @james, see tutorial/Contexts $\endgroup$
    – kglr
    Commented Apr 6, 2020 at 6:53
  • 2
    $\begingroup$ Why not avoid the internal functions and use RegionMember[RegionBoundary[Disk[]], {x, y}]? $\endgroup$
    – Greg Hurst
    Commented Apr 6, 2020 at 12:19
  • 1
    $\begingroup$ @ChipHurst, yes off course!. It just did not occur to me. Perhaps you should post that as an answer? $\endgroup$
    – kglr
    Commented Apr 6, 2020 at 12:38
  • 1
    $\begingroup$ I think you should update your post to avoid one thinking an internal function is needed. $\endgroup$
    – Greg Hurst
    Commented Apr 6, 2020 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.