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

1 Answer 1

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$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.