[metapost] intersectiontimes
Troy Henderson
thenders at gmail.com
Wed Oct 15 23:45:17 CEST 2008
Try this:
--- begin cut code ---
path p,q,r;
p:=fullcircle xscaled 72 yscaled 36;
q:=fullcircle xscaled 36 yscaled 72;
r:=p;
draw p withcolor green;
draw q withcolor red;
for n=1 upto 4:
(t[n],whatever) = r intersectiontimes q;
z[n] = point t[n] of r;
r:= subpath (t[n]+epsilon,length r) of r;
fill fullcircle scaled 2 shifted z[n] withcolor blue;
endfor;
--- end cut code ---
In this case, p and q are the two paths and r is simply a copy of p
that is going to be trimmed along the way. Basically, you continually
trim r so that the "first" point for which r intersects q is
*strictly* further (hence the need for epsilon) along than the
previous intersection point. Repeating this process 4 times gets them
all. I hope this is not too difficult to understand. Also, anyone
with a better solution please let me know as I would love to hear it.
Troy
More information about the metapost
mailing list