I am trying to reproduce the construction of bisectors with compass.
Here is what I managed to get so far
vardef bisector(expr A, O, B, r) =
save arc, E, F, I;
path arc[] ; pair E, F, I[];
% Draw one arc of radius \r\ around center \O\ such that
% it cuts \OA\ and \OB\ respectively at points \E\ and \F\.
arc[0] = fullcircle scaled r shifted O;
E = (O--A) intersectiontimes arc[0];
F = (O--B) intersectiontimes arc[0];
% With the same length \r\, draw two arcs respectively around
% centers \E\ and \F\ intersecting each other.
arc[1] = fullcircle scaled r shifted point (ypart E) of arc[0];
arc[2] = fullcircle scaled r shifted point (ypart F) of arc[0];
% That intersection point is \I\.
I[0] = (reverse arc[1]) intersectionpoint (reverse arc[2]) ;
I[1] = (reverse arc[1]) intersectiontimes (reverse arc[2]) ;
I[2] = arc[2] intersectiontimes arc[1] ;
save rad ; numeric rad ; rad = .33 ;
% Draw the arc around points \E\ and \F\ on rays \OA\ and \OB\.
draw subpath(ypart E - rad, ypart E + rad) of arc[0] withcolor .8[black,white];
draw subpath(ypart F - rad, ypart F + rad) of arc[0] withcolor .8[black,white];
% Draw arcs around point \I\.
draw subpath(ypart I[1] - rad, ypart I[1] + rad) of arc[1] withcolor .5[black,white] ;
draw subpath(xpart I[2] - rad, xpart I[2] + rad) of arc[2] withcolor .5[black,white] ;
I[0]
enddef;
Which, when used in this piece of code
\startMPpage[offset=1dk]
u = cm ;
pair O, x, y, A, B, M[] ;
O = origin ;
x = (4u,2u) ;
y = (5u,-3u) ;
M[0] = bisector(x,O,y,30) ;
M[1] = bisector(O,x,y,30) ;
M[2] = bisector(x,y,O,30) ;
draw O -- x -- y -- cycle ;
draw O -- y ;
draw O -- M[0] shortened -u;
draw x -- M[1] shortened -u;
draw y -- M[2] shortened -u;
dotlabel.top("O", O) ;
dotlabel.top("x", x) ;
dotlabel.top("y", y) ;
\stopMPpage
produces
And I do not understand why this is working in some cases but not in others… In fact, I am not even sure how it even works in the working cases.
What I am doing wrong?
I[0] = (reverse arc[1]) intersectionpoint (reverse arc[2]) ; I[1] = (reverse arc[1]) intersectiontimes (reverse arc[2]) ;
It is almost deliberately obfusticated.