# How to choose the correct area to fill using build cycle in asymptote for strophoid?

I had asked this question earlier here How to choose the correct area to fill using buildcycle in asymptote? and got the correct answer from Thruston. I have run into a similar problem, this time with a strophoid instead of ellipse.

`````` `/* Geogebra to Asymptote conversion, documentation at artofproblemsolving.com/Wiki go to User:Azjps/geogebra */
import contour; import graph; size(7cm);
import patterns;
string blank(real x) {return "";}
real labelscalefactor = 0.5; /* changes label-to-point distance */
pen dps = linewidth(0.7) + fontsize(10); defaultpen(dps); /* default pen style */
pen dotstyle = black; /* point style */
real xmin = -5.5, xmax = 6.86, ymin = -6, ymax = 6.9;  /* image dimensions */

Label laxis; laxis.p = fontsize(10);
xaxis(-5.5, xmax, Ticks(laxis,blank, Step = 1, Size = 2, NoZero),EndArrow(6), above = true);
yaxis(-6.5, ymax, Ticks(laxis, blank, Step = 1, Size = 2, NoZero),EndArrow(6), above = true); /* draws axes; NoZero hides '0' label */
/* draw figures */
real implicitf1 (real x, real y) { return (5.0+x)*y^2-x^2*(5.0-x); }
guide[][] cf=contour(implicitf1, (xmin,ymin), (xmax,ymax), new real[]{0}, 500);
draw(cf[0][0], linewidth(1));
path p1=(5,1.5) -- (0,-6);
draw(p1,linewidth(1));
path p2=buildcycle(p1,cf[0][0]);
fill(p2,pattern("hatch"));
clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle);
/* end of picture */`
``````

Here is the resulting image. I want the other part to be shaded. Can anyone explain how buildcycle works?

• Geogebra is for intuition, Asymptote is programming language for drawing. They are too different in principle. "Geogebra to Asymptote conversion" is almost nonsense IMHO! If you want to draw with Asymptote, start with Asymptote! – Black Mild Apr 15 '19 at 11:09
• @BlackMild I like to convert from geogebra because I can play around with the parameters. I essentially use geogebra as a drawing tool, not a teaching/learning tool. Converting from geogebra takes care of considerable amount of routine stuff. – S. Venkataraman Apr 16 '19 at 5:24
• @S.Venkataraman Please only use GeoGebra when you are a complete novice. Any conversion will reduce the quality of the picture. If you want to have your figure in Asymptote, draw it using Asymptote instead of using your mouse. – user156344 Apr 16 '19 at 5:37

I finally settled for the following:

``````import contour; import graph; size(7cm);
import patterns;
string blank(real x) {return "";}
real labelscalefactor = 0.5; /* changes label-to-point distance */
pen dps = linewidth(0.7) + fontsize(10); defaultpen(dps); /* default pen style */
pen dotstyle = black; /* point style */
real xmin = -5.5, xmax = 6.86, ymin = -6, ymax = 6.9;  /* image dimensions */

Label laxis; laxis.p = fontsize(10);
xaxis(-5.5, xmax, Ticks(laxis,blank, Step = 1, Size = 2, NoZero),EndArrow(6), above = true);
yaxis(-6.5, ymax, Ticks(laxis, blank, Step = 1, Size = 2, NoZero),EndArrow(6), above = true); /* draws axes; NoZero hides '0' label */
/* draw figures */
real implicitf1 (real x, real y) { return (5.0+x)*y^2-x^2*(5.0-x); }
guide[][] cf=contour(implicitf1, (xmin,ymin), (xmax,ymax), new real[]{0}, 500);
draw(cf[0][0], linewidth(1));
real f1(real x){ return sqrt((x^2*(5-x))/(5.0+x));}
real f2(real x){ return -sqrt((x^2*(5-x))/(5.0+x));}
fill(graph(f1,0,4.61) -- (3,-1.5) -- graph(f2,3,0)-- cycle,pattern("hatch"));
path p1=(0,-6) -- (5,1.5);
draw(p1,linewidth(1));
dot((4.61,0.92),linewidth(4)+dotstyle);
label("\$A\$",(4.7,0.94),E*labelscalefactor);
label("\$B\$",(3,-1.6),S*labelscalefactor);
dot((3,-1.5),linewidth(4)+dotstyle);
clip((xmin,ymin)--(xmin,ymax)--(xmax,ymax)--(xmax,ymin)--cycle);
/* end of picture */
``````

I get the following picture (What I want.): Of course I can draw the curve without using `contour`. Still, it will be nice, if there is a solution using asymptote. Asymptote documentation assumes that one is familiar with metapost documentation. So, it seems that one needs to dig into metapost documentation if we want to understand buildcycle better.