%% MACROS
%% define draw_mark (crossmarks on lines) and similar angle marking operations
%%
%% These macros are stolen from mpman.ps and manfig.mp
marksize:=4pt; % how big the tics on lines are
% how big the arc in an angle is. We define it using := rather than = so that
% it can easily be overridden later if desired.
default_angle_radius:=28pt;
angle_radius:=default_angle_radius ;
% don't use this; it is used by draw_marked. Use that instead.
def draw_mark(expr p, a) =
begingroup
save t, dm; pair dm;
t = arctime a of p;
dm = marksize*unitvector direction t of p
rotated 90;
draw (-.5dm.. .5dm) shifted point t of p;
endgroup
enddef;
% draws n tics in the middle of path p
def draw_marked(expr p, n) =
begingroup
save amid;
amid = .5*arclength p;
for i=-(n-1)/2 upto (n-1)/2:
draw_mark(p, amid+.6marksize*i);
endfor
draw p;
endgroup
enddef;
% draw an angle arc and label it with n tics.
def mark_angle(expr a, b, c, n) =
begingroup
save s, p; path p;
p = unitvector(a-b){(a-b)rotated 90}..unitvector(c-b);
s = .9marksize/length(point 1 of p - point 0 of p);
if s