"Fossies" - the Fresh Open Source Software Archive

Member "asymptote-2.61/examples/polararea.asy" (18 Nov 2019, 930 Bytes) of package /linux/misc/asymptote-2.61.src.tgz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 import math;
    2 import graph;
    3 
    4 size(0,150);
    5 
    6 real f(real t) {return 5+cos(10*t);}
    7 
    8 xaxis("$x$");
    9 yaxis("$y$");
   10 
   11 real theta1=pi/8;
   12 real theta2=pi/3;
   13 path k=graph(f,theta1,theta2,operator ..);
   14 real rmin=min(k).y;
   15 real rmax=max(k).y;
   16 draw((0,0)--rmax*expi(theta1),dotted);
   17 draw((0,0)--rmax*expi(theta2),dotted);
   18 
   19 path g=polargraph(f,theta1,theta2,operator ..);
   20 path h=(0,0)--g--cycle;
   21 fill(h,lightgray);
   22 draw(h);
   23 
   24 real thetamin=3*pi/10;
   25 real thetamax=2*pi/10;
   26 pair zmin=polar(f(thetamin),thetamin);
   27 pair zmax=polar(f(thetamax),thetamax);
   28 draw((0,0)--zmin,dotted+red);
   29 draw((0,0)--zmax,dotted+blue);
   30 
   31 draw("$\theta_*$",arc((0,0),0.5*rmin,0,degrees(thetamin)),red+fontsize(10pt),
   32      PenMargins);
   33 draw("$\theta^*$",arc((0,0),0.5*rmax,0,degrees(thetamax)),blue+fontsize(10pt),
   34      PenMargins);
   35 
   36 draw(arc((0,0),rmin,degrees(theta1),degrees(theta2)),red,PenMargins);
   37 draw(arc((0,0),rmax,degrees(theta1),degrees(theta2)),blue,PenMargins);
   38