2
$\begingroup$

The parametric equation of the heart curve is from this link

$$\left\{\quad \begin{array}{rcl} x&=&\cos {t} \cdot\sin {t} \cdot\ln \left| t\right| \\[10pt] y&=&\left| t\right| ^{0.3} \cdot\sqrt{\cos {t}} \\ \end{array} \right.\quad t\in[-1,1]$$

Below the code visualizes the curve:

ParametricPlot[{Sin@t Cos@t Log@Abs@t,(Abs@t)^.3 Sqrt[Cos@t]}(*u,{u,0,1}*),{t,-1,1},PlotRange->All,PlotStyle->Red,MeshFunctions->{#3&  },MeshStyle->None]

enter image description here

I also want to fill the closed curve with some solid color, for instance, red. The following code:

ParametricPlot[{Sin@t Cos@t Log@Abs@t,(Abs@t)^.3 Sqrt[Cos@t]}u,{u,0,1},{t,-1,1},PlotRange->All,PlotStyle->Red,MeshFunctions->{#3&  },MeshStyle->None]

gives:

enter image description here

Let $O(0,0)$ be the coordinate system's origin, and $P(x,y)$ a moving point on the curve. Then it seems when there is intersection points between the segment connecting $O(0,0)$ and $P(x,y)$ and the closed curve, then there will be filling problem (filling color overflow).

When I move the curve to let $O$ inside the curve exactly problem will be solved relatively easier...(though still a little weird if the PlotPoints is still the default number)

enter image description here

Code:

ParametricPlot[{ Sin@t Cos@t Log@Abs@t,(Abs@t)^.3  Sqrt[Cos@t]-.71}u,{u,0,1},{t,-1,1},PlotRange->All,PlotStyle->Directive[Opacity[0,Red],Red],MeshShading->{Red, Red},MeshFunctions->{#3&},Mesh->Automatic,MeshStyle->Red,PlotPoints->200,Axes->None,Frame->None]

gives:

enter image description here

which is closer to the target but has the following disadvantages:

  1. It is too slow;
  2. There are white noise;

I wonder only for such a parameric equation without any coordinate transform, how can i fill it will solid color /pattern with options in ParametricPlot? I understand by approximating the closed curve with a polygon, things will also be easier, the key is whether it is possible to handle it with ParametricPlot's MeshFunction related options?

$\endgroup$
2
  • 1
    $\begingroup$ I would say this is a dupe of this. For your specific case: ParametricPlot[{Sin@t Cos@t Log@Abs@t, (Abs@t)^.3 Sqrt[Cos@t]}, {t, -1, 1}, Axes -> None, Frame -> True, PlotRange -> All] /. Line[l_List] :> {Directive[EdgeForm[Opacity[1/2, Black]], Opacity[1, Red]], Polygon[l]} $\endgroup$ Jun 3, 2016 at 7:36
  • $\begingroup$ thank you! I am interested in how to realize it with the MeshFunctions option in ParametricPlot itself. $\endgroup$ Jun 3, 2016 at 7:50

1 Answer 1

3
$\begingroup$

Try this:

lst = Table[{Sin@t Cos@t Log@Abs@t, (Abs@t)^.3 Sqrt[Cos@t]}, {t, -1, 
1, 0.0001}];

and then

 ListLinePlot[lst, PlotStyle -> Red, PlotRange -> All, 
 Filling -> Bottom, FillingStyle -> Red]

yielding the following

enter image description here

Have fun!

$\endgroup$

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