3
$\begingroup$

Suppose we consider two dimensional cartesian coordinates x,y and pick a parametrization

x = r Cos[phi];
y = r Sin[phi];

I would like to plot the region in x,y-plane that is covered by the range 0<r<Infinity and 0<phi<PI/3 in the new variables. Does mathematica have a function that does this?

The plot should look something like enter image description here

EDIT:

I believe there is a problem in the solution of the current answer with the plot function for a hyperbolic case:

prs = {ParametricRegion[{r Sinh[phi], r Cosh[phi]}, {{r, 0, Infinity}, {phi, -Infinity, Infinity}}],
       ParametricRegion[{r Cosh[phi], r Sinh[phi]}, {{r, 0, Infinity}, {phi, 0, Infinity}}], 
       ParametricRegion[{-r Cosh[phi], r Sinh[phi]}, {{r, 0, Infinity}, {phi, 0, Infinity}}]}; 

I believe the three regions should be exactly touching each other along the adjacent straight lines, while the plot does not seem to reflect that:

Show[MapIndexed[RegionPlot[#, PlotStyle -> ColorData[97][#2[[1]]]] &, prs], AspectRatio -> 1]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ does pr = ParametricRegion[{r Cos[phi], r Sin[phi]}, {{r, 0, Infinity} , {phi, 0, Pi/3}}]; Region[pr] give what you need? $\endgroup$ – kglr Nov 29 '18 at 18:35
  • $\begingroup$ @kglr looks close, but it would be nice if it had axes with numbers as well. $\endgroup$ – Kagaratsch Nov 29 '18 at 18:37
3
$\begingroup$

Update 2:

If you examine the prs,

 prs

{ParametricRegion[{{r Sinh[phi], Cosh[phi] r}, r >= 0}, {r, phi}],
ParametricRegion[{{Cosh[phi] r, r Sinh[phi]}, r >= 0 && phi >= 0}, {r, phi}],
ParametricRegion[{{-Cosh[phi] r, r Sinh[phi]}, r >= 0 && phi >= 0}, {r, phi}]}

it doesn't contain any information on plot region bounds. Intersecting each element of prs with RegionUnion[prs] eliminates the issue:

Show[MapIndexed[RegionPlot[RegionIntersection[#, RegionUnion @@ prs], 
    PlotStyle -> ColorData[97][#2[[1]]]] &, prs], AspectRatio -> 1]

enter image description here

Alternatively, we can RegionPlot the intersection of each element of prs with, say, Rectangle[{-50, 0}, {50, 50}]:

Show[MapIndexed[RegionPlot[RegionIntersection[#, Rectangle[{-50, 0}, {50, 50}]], 
    PlotStyle -> ColorData[97][#2[[1]]]] &, prs], AspectRatio -> 1]

enter image description here

You can use ParametricRegion:

pr = ParametricRegion[{r Cos[phi], r Sin[phi]}, {{r, 0, Infinity} , {phi, 0, Pi/3}}];
RegionPlot[pr]

enter image description here

Update: Is there a way to glue several parametric regions together?

prs = ParametricRegion[{r Cos[phi], r Sin[phi]}, {{r, 0, Infinity}, {phi, ##}}] & @@@ 
  {{0, Pi/3}, {2 Pi/3, Pi}};

Show[MapIndexed[RegionPlot[#, PlotStyle -> ColorData[97][#2[[1]]]] &,  prs], 
 PlotRange -> {-1, 1}, AspectRatio -> 1]

enter image description here

$\endgroup$
  • $\begingroup$ Is there a way to glue several parametric regions together? Like for {phi, 0, Pi/3} and {phi,2Pi/3, Pi} for instance? $\endgroup$ – Kagaratsch Nov 29 '18 at 18:59
  • 1
    $\begingroup$ @Kagaratsch, please see the update. $\endgroup$ – kglr Nov 29 '18 at 19:06
  • $\begingroup$ I believe there is a problem with the plot function for a hyperbolic case: prs = {ParametricRegion[{r Sinh[phi], r Cosh[phi]}, {{r, 0, Infinity}, {phi, -Infinity, Infinity}}], ParametricRegion[{r Cosh[phi], r Sinh[phi]}, {{r, 0, Infinity}, {phi, 0, Infinity}}], ParametricRegion[{-r Cosh[phi], r Sinh[phi]}, {{r, 0, Infinity}, {phi, 0, Infinity}}]}; I believe the three regions should be exactly touching each other along the adjacent straight lines, while the plot does not seem to reflect that. $\endgroup$ – Kagaratsch Nov 29 '18 at 19:29
1
$\begingroup$

I have noticed before that, as mentioned by OP, region functions do seem to have numerical problems which causes them not to render regions, other than simple ones, correctly. But there is also ParametricPlot which seems to work:

Show[
 ParametricPlot[
  {r Sinh[phi], r Cosh[phi]},
  {r, 0, 10^5}, {phi, -10^3, 10^3},
  PlotStyle -> ColorData[97, 1],
  PlotRange -> {{-1.5, 1.5}, {0, 2}}
  ],
 ParametricPlot[
  {r Cosh[phi], r Sinh[phi]},
  {r, 0, 10^5}, {phi, -10^3, 10^3},
  PlotStyle -> ColorData[97, 2],
  PlotRange -> {{-1.5, 1.5}, {0, 2}}
  ],
 ParametricPlot[
  {-r Cosh[phi], r Sinh[phi]},
  {r, 0, 10^5}, {phi, -10^3, 10^3},
  PlotStyle -> ColorData[97, 3],
  PlotRange -> {{-1.5, 1.5}, {0, 2}}
  ]
 ]

Mathematica graphics

ParametricPlot[{r Cos[phi], r Sin[phi]}, {r, 0, 10}, {phi, 0, Pi/3}]

Mathematica graphics

Note that this function was introduced in 1988 and ParametricRegion in 2014. This is the function that would traditionally be used for this task, whereas ParametricRegion is not just for visualizing but also for doing computations on said regions. A ParametricRegion represents an object which we can e.g. use Area on.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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