Debian Codegraph @

texmf-dist/metapost/luamesh/luamesh.mp

raw
1 % metapost library for the lualatex package luamesh
2 %
3 vardef circumcircle(expr M,N,P)=
4 % Compute center and radius of the circoncircle of the triangle M N P
5 save a,b,c,circle,rad,center,x,y;
6 path circle;
7 pair center;
8 numeric a,b,c,x[],y[];
9 x1 := xpart M;
10 y1 := ypart M;
11 x2 := xpart N;
12 y2 := ypart N;
13 x3 := xpart P;
14 y3 := ypart P;
15 2*x1*a+2*y1*b+c=-(x1**2+y1**2);
16 2*x2*a+2*y2*b+c=-(x2**2+y2**2);
17 2*x3*a+2*y3*b+c=-(x3**2+y3**2);
18 center := (-a,-b);
19 rad := sqrt(a**2+b**2-c**2);
20 circle := fullcircle scaled (2.0*rad) shifted center;
21 circle
22 enddef