PLOTTING THE REGION COMMON TO TWO CLOSED CURVES

Creating a plot with selected regions filled

This package illustrates how to create a plot using polar coordinates with selected regions filled.

Getting the necessary functions

We begin by loading the two packages which are required for the program:

<<Graphics`Graphics`

<<Graphics`FilledPlot`

Creating our plot

We will make use of the function FilledListPlot. This function allows us to fill the interior of a region defined by a collection of points. First, let's look at what we are trying to do. We would like to emphasize the region common to the two curves shown below.

g3=PolarPlot[{Sin[ x],Sin[2 x]},{x,0,2 Pi},PlotStyle->{RGBColor[0,1,0],RGBColor[1,0,0]}]

Getting the bounds of our variables.

The first part of the intersection region may be obtained using the polar equations of the curves, as follows. The Reverse command ensures that the correct pairs of points are compared.  This requires a little experimentation. (A small adjustment has been made in the x- range to ensure that the region is completely filled) :

g1=FilledListPlot[Table[{Sin[x]*Cos[x],Sin[x]^2},{x,0,Pi/3,0.001}],Reverse[Table[{Sin[2 x]*Cos[x],Sin[2 x]*Sin[x]},{x,Pi/3-0.001,Pi/2,0.001}]],AspectRatio->1.05,PlotStyle->{RGBColor[0,1,0],RGBColor[1,0,0]}]

The second part of the intersection region is obtained in a similar manner:

g2=FilledListPlot[Table[{Sin[ x]*Cos[x],Sin[ x]^2},{x,5 Pi/3-0.01,2 Pi,0.001}],Reverse[Table[{Sin[2 x]*Cos[x],Sin[2 x]*Sin[x]},{x,3Pi/2,5Pi/3,0.001}]],AspectRatio->1.05,PlotStyle->{RGBColor[0,1,0],RGBColor[1,0,0]}]

Assembling our plot.

We will now put the pieces together to obtain the final plot. Here is the original plot of the two curves:

g3=PolarPlot[{Sin[ x],Sin[2 x]},{x,0,2 Pi},PlotStyle->{RGBColor[0,1,0],RGBColor[1,0,0]}]

Finally, we use Show to combine the graphics and obtain the required plot:

Show[{g1,g2,g3},ImageSize->380,AspectRatio -> Automatic]