1
$\begingroup$

Let' s take a most simple example for a polar plot, the Archimede's spiral.

{p1, p2} =  MapThread[PolarPlot[t , {t, 0,8 Pi}, 
RegionFunction -> #1,PlotStyle -> #2 ] &,
{{( 2 Pi <= #3 <= 5 Pi/2 || 4 Pi <= #3 <= 9 Pi/2 &), (0 <= #3 < 2 Pi || 
    5 Pi/2 < #3 < 4 Pi || #3 > 9 Pi/2 & )}, {Red, Blue}}];
Show[p1, p2]

How can I use here RegionPlot for the area between the two red arcs?
It takes two parameters as input and here there is only one to be given (by #3) and I could not find out a way to circumvent that.
As I want to practise with the new Region Properties and Measures MMA V10 functions, an answer using RegionPlot of region which can be reused for RegionMeasure (for example) is needed.

$\endgroup$
  • $\begingroup$ I think ImplicitRegion[{2 Pi < Sqrt[x^2 + y^2] - ArcTan[x, y] < 4 Pi, x > 0, y > 0}, {x, y}] should give the region you want, but it doesn't seem to work. $\endgroup$ – Simon Woods Dec 28 '14 at 16:53
  • $\begingroup$ With reg=ParametricRegion[{r Cos[\[Theta]], r Sin[\[Theta]]}, {{\[Theta], 0, \[Pi]/2}, {r, 2 \[Pi] + \[Theta], 4 \[Pi] + \[Theta]}}]; some region properties seem to work, e.g. {RegionDimension[reg],RegionEmbeddingDimension[reg]} gives {2,2}. Could you try if it works for other region functions such as RegionMeasure[reg] or `RegionMember[reg, {10,4}]? $\endgroup$ – kglr Dec 28 '14 at 17:25
  • 1
    $\begingroup$ @SigismondKmiecik, for some questions it takes a while to get the attention of someone in the know. $\endgroup$ – kglr Jan 6 '15 at 21:04
3
$\begingroup$

As this question had been asked while I had a MMA 10.0 version and did not get an answer after many weeks I’ll provide my own borrowing from comments received then and new elements after my upgrade to subsequent versions of MMA.

The area I want to measure using the new MMA V10 functions for region properties and measures is the colored section of the ParametricPlot below

 parmplot = ParametricPlot[
            r {Cos[t], Sin[t]}, {t, 0, Pi/2}, {r, 2 Pi + t, 4 Pi + t}, 
            ColorFunction -> "RustTones"];
 Show[ParametricPlot[t {Cos[t], Sin[t]}, {t, 0, 6 Pi}], parmplot]

Image

I know what to expect as the right figure can be obtained with a double integral, probably available since the early MMA versions.

exactarea = Integrate[r, {\[Theta], 2 Pi, 5 Pi/2}, {r, \[Theta],\[Theta] + 2 Pi}] (* (13 \[Pi]^3)/4 *)

Parametric Coordinates

Using the ParametricPlot code as a template for the ParametricRegion code:

parmreg = ParametricRegion[{r Cos[t], r Sin[t]}, {{t, 0, \[Pi]/2},{r, 2 Pi + t, 4 Pi + t}}];
RegionQ[%] (* True *)
RegionMeasure[parmreg]   (* V 10.0 loop - had to abort *)
                         (* V 10.1 (13 \[Pi]^3)/4 OK *)  

With MMA 10.0 I spent hours to understand where my mistake was (because I thought there was one) and find a bypass, eventually giving up. Lo and behold after my MMA upgrade, the same code runs now OK!

Let's go further:

DiscretizeRegion[parmreg]   (* V10.0 loop - had to abort *)
                            (* V10.1 loop - had to abort *)
                            (* V10.2 loop - had to abort *)

This time, I knew better, contacting Wolfram support which acknowledged there was a problem and forwarded to the development team.

                          ` (* V10.4  Corrected:RegionArea 100.77*)` 

Cartesian coordinates

Any parametric coordinates can be transformed into cartesian coordinates, here put into an ImplicitRegion expression:

cartreg = ImplicitRegion[2 \[Pi] < Sqrt[x^2 + y^2] - ArcTan[x, y] < 4 \[Pi] && 
          0 <= x <= 15 && 0 <= y <= 15 , {x, y}];
RegionMeasure[cartreg] (* MMA V10.0 and V10.1 and V10.2 - error message: Unable to compute the measure of region...*) 

No loop here as before but an error straight away. MMA currently cannot handle this. However the next steps were fruitful:

regiontoplot = DiscretizeRegion[cartreg, AccuracyGoal -> 5];
NumberForm[#, {8, 5}] & @Area[regiontoplot] (* 100.77034 OK *) 
NumberForm[Integrate[1, {x, y} \[Element] regiontoplot ], {8, 5}] (* OK*)
% / exactarea (* 0.999999 *);
pt = RegionCentroid[regiontoplot] ;

And a final plot to visualize the answers above and to assure oneself of their correctness:

Show[ParametricPlot[t {Cos[t], Sin[t]}, {t, 0, 6 Pi}], regiontoplot, 
     Graphics[{PointSize[Large], Red, Point[pt]}]]

Image

My conclusion is that at least for the new functions I was interested in and even afer two successive MMA versions they are still error prone which is most frustating.Is it reasonable to expect corrective updates in the near future?

| improve this answer | |
$\endgroup$
  • $\begingroup$ MMA 10.4 brought one improvement but problems remain $\endgroup$ – Sigis K Aug 1 '16 at 10:32

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.