blob: 29d370d8ee6885b0e6ef7fa561e5b7481a2359fd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
%%%%
%%%% This file belongs to the MFTOEPS package.
%%%%
% ---
% POLYGONS.MF
% ---
vardef regular_polygon(expr n) =
% |n| is the number of vertices; the diameter of the circumscribed circle
% is equal to 1, its center is in the origin
(up % first vertex
for i:=1 upto n-1:
-- (up rotated (i*(360/n))) % next vertices
endfor
-- cycle) scaled .5
enddef;
vardef flex_polygon(expr n,a,b) =
% |n| is the number of vertices, |a|, |b| are the angles (at vertices)
% between a tangent to a ``flex side'' and the corresponding secant
save zz; pair zz[ ]; % array of vertices
for i:=0 upto n-1:
zz[i]:=up rotated (i*(360/n));
endfor
(zz[0] {(zz[1]-zz[0]) rotated a}
for i:=1 upto n-1:
.. {(zz[i]-zz[i-1]) rotated b}
zz[i]
{(zz[(i+1) mod n]-zz[i]) rotated a}
endfor
.. {(zz[0]-zz[n-1]) rotated b} cycle)
scaled .5
enddef;
endinput
|