2
$\begingroup$

I have the following function

partitionfunction[d_][q_] := 
  Piecewise[{
    {Sin[(Pi*q)/(2*d)]^2, Inequality[0, LessEqual, q, Less, d]}, 
    {1, Inequality[d, LessEqual, q, Less, 2*Pi - d]}, 
    {Sin[(Pi*(2*Pi - q))/(2*d)]^2, 2*Pi - d <= q <= 2*Pi}}]

radius[d_][q_] := 1 + 1.5*partitionfunction[d][q]*BesselJ[5, (13/(2*Pi))*q + 5]

curve[d_][q_] := radius[d][q]*{Cos[q], Sin[q]}

which I use to generate the following plot

ParametricPlot[curve[1][q], {q, 0, 2*Pi}, 
  Axes -> False, 
  PlotPoints -> 50, 
  PlotStyle -> Thickness[0.007]] 

enter image description here

So far so good. But when I try to fill the enclosed area, I get a strange white polygon.

ParametricPlot[curve[1][q], {q, 0, 2*Pi}, 
  Axes -> False, 
  PlotPoints -> 50, 
  PlotStyle -> Thickness[0.007]] /. 
  Line[l_List] :> {{Orange, Polygon[l]}, {Black, Line[l]}}

enter image description here

Also the filling goes outside the boundary.

Any ideas to fix this behavior?

EDIT

Searching here I try this

g = 
  ParametricPlot[curve[1][q], {q, 0, 2*Pi}, 
    Axes -> False, 
    PlotPoints -> 50, 
    PlotStyle -> Thickness[0.007]] 

line = Cases[g, l_Line :> First @ l, Infinity];

Graphics[
  {Opacity[0.4], Darker @ Orange, EdgeForm[Darker @ Orange], Polygon[line]}, 
  Options[g]]

enter image description here

The polygon is still evident, but this time the filling does not go outside the boundary.

$\endgroup$

closed as off-topic by Dr. belisarius, ybeltukov, ilian, user9660, MarcoB Nov 18 '15 at 17:08

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Dr. belisarius, ybeltukov, ilian, Community, MarcoB
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ What is curve? $\endgroup$ – eldo Nov 18 '15 at 15:23
  • 1
    $\begingroup$ Even without curve I think that the problem can be solved with Exclusions->None. $\endgroup$ – ybeltukov Nov 18 '15 at 15:25
  • $\begingroup$ Sorry! I forgot to add the definitions. Not it should be ok! $\endgroup$ – Dimitris Nov 18 '15 at 15:28
  • $\begingroup$ @ybeltukov: You are right! Adding Exclusions->None did indeed solve the issue! Amazing without even seeing the definitions. Thanks! $\endgroup$ – Dimitris Nov 18 '15 at 15:31
  • $\begingroup$ Why Exclusions->None is necessary here? $\endgroup$ – Dimitris Nov 18 '15 at 16:32
3
$\begingroup$

I don't know if it is worth posting an answer, but nevertheless here it goes (code adopted by a discussion with David Park several years ago; then working with Mathematica 5.2. I tried to upgrade it in order to fit Graphics structure of recent versions):

partitionfunction[d_][q_] := 
  Piecewise[{
    {Sin[(Pi*q)/(2*d)]^2, Inequality[0, LessEqual, q, Less, d]}, 
    {1, Inequality[d, LessEqual, q, Less, 2*Pi - d]}, 
    {Sin[(Pi*(2*Pi - q))/(2*d)]^2, 2*Pi - d <= q <= 2*Pi}}]

radius[d_][q_] := 1 + 1.5*partitionfunction[d][q]*BesselJ[5, (13/(2*Pi))*q + 5]

curve[d_][q_] := radius[d][q]*{Cos[q], Sin[q]}

g = 
  ParametricPlot[curve[1][q], {q, 0, 2*Pi}, 
    Axes -> False, 
    PlotPoints -> 50, 
    PlotStyle -> Thickness[0.007], 
    Exclusions -> None];

line = Cases[g, l_Line :> First@l, Infinity];

Graphics[
  {Opacity[0.4], Darker @ Orange, EdgeForm[Darker @ Orange], Polygon[line]}, 
  Options[g]]

enter image description here

This question and answer is related to the reply I wanted to give here

Thanks to ybeltukov for pointing out Exclusions (which I should have known that it has to be applied here).

$\endgroup$

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