## MetaPost Macro for drawing arcs and circles

``````
% This macro draws arcs (or whole circles) if you specify the
% center m=(px,py), the radius r and the angles for the
% beginning and ending, b and e, in pi.
``````
``````
% scaling factor
u=100;
% definition pi
pi=3.141592653689793238462643;
``````
``````
def cos(expr x) = cosd(x*180/pi) enddef;
def sin(expr x) = sind(x*180/pi) enddef;
``````
``````
def kreis(expr px, py, r, b, e) = subpath (b*(4/pi),e*(4/pi)) of
fullcircle xscaled (2*u*r) yscaled (2*u*r) shifted (u*px,u*py) enddef;
``````

Thanks to AndrĂ© for helping me with this one!

This draws the module figure:

``````
beginfig(1);
% Modulfigur
draw kreis(0,0,1,0,2*pi);
% largest arcs
draw kreis(0,-2,sqrt(3),2*pi/6, 4*pi/6);
draw kreis(2*cos(pi/6),2*sin(pi/6),sqrt(3),6*pi/6,8*pi/6);
draw kreis(-2*cos(pi/6),2*sin(pi/6),sqrt(3),-2*pi/6,0);
% middle arcs
draw kreis(-2/sqrt(3)*sin(pi/6),-2/sqrt(3)*cos(pi/6),1/sqrt(3),0,4*pi/6);
draw kreis(2/sqrt(3)*sin(pi/6),-2/sqrt(3)*cos(pi/6),1/sqrt(3),2*pi/6,pi);
draw kreis(2/sqrt(3),0,1/sqrt(3),4*pi/6,8*pi/6);
draw kreis(-2/sqrt(3),0,1/sqrt(3),-2*pi/6,2*pi/6);
draw kreis(-2/sqrt(3)*sin(pi/6),2/sqrt(3)*cos(pi/6),1/sqrt(3),-4*pi/6,0);
draw kreis(2/sqrt(3)*sin(pi/6),2/sqrt(3)*cos(pi/6),1/sqrt(3),pi,10pi/6);
% small arcs
draw kreis(-sin(pi/9)/cos(pi/9),1,sin(pi/9)/cos(pi/9),11pi/9,2*pi);
draw kreis(sin(pi/9)/cos(pi/9),1,sin(pi/9)/cos(pi/9),pi,16*pi/9);
draw kreis(-cos(pi/18)/cos(pi/9),-sin(pi/18)/cos(pi/9),sin(pi/9)/cos(pi/9),-3pi/9,4*pi/9);
draw kreis(cos(pi/18)/cos(pi/9),-sin(pi/18)/cos(pi/9),sin(pi/9)/cos(pi/9),5pi/9,12*pi/9);
draw kreis(-cos(5pi/18)/cos(pi/9),-sin(5pi/18)/cos(pi/9),sin(pi/9)/cos(pi/9),-pi/9,6*pi/9);
draw kreis(cos(5pi/18)/cos(pi/9),-sin(5pi/18)/cos(pi/9),sin(pi/9)/cos(pi/9),3pi/9,10pi/9);
% smallest arcs
draw kreis(-sin(pi/18)/cos(pi/18),-1,sin(pi/18)/cos(pi/18),0,16*pi/18);
draw kreis(sin(pi/18)/cos(pi/18),-1,sin(pi/18)/cos(pi/18),2*pi/18,pi);
draw kreis(cos(pi/9)/cos(pi/18),sin(pi/9)/cos(pi/18),sin(pi/18)/cos(pi/18),6*pi/9,14*pi/9);
draw kreis(-cos(pi/9)/cos(pi/18),sin(pi/9)/cos(pi/18),sin(pi/18)/cos(pi/18),-5pi/9,3pi/9);
draw kreis(cos(2*pi/9)/cos(pi/18),sin(2*pi/9)/cos(pi/18),sin(pi/18)/cos(pi/18),7pi/9,15pi/9);
draw kreis(-cos(2*pi/9)/cos(pi/18),sin(2*pi/9)/cos(pi/18),sin(pi/18)/cos(pi/18),-6*pi/9,2*pi/9);
endfig;
end
``````