I've read Knuth's explanation of how "intersectiontimes" works when two paths intersect in multiple points (in Chapter 14 of the METAFONTbook), but I cannot seem to figure out how to FORCE lexicographic ordering of the intersection times.<br>
<br>For example, if paths p and q intersect in multiple points, I would like to, somehow, have<br><br>(s,whatever) = q intersectiontimes p;<br><br>return the "first" (i.e., smallest "time") for q in which q and p intersect.  This is illustrated in the code below (which generates the attached figure).<br>
<br>Notice that q intersects p at times (and these times are for q) 0.07144, 0.35716, 0.64287, and 0.92859 which correspond to the points (1,-5), (1,-3), (1,-1) and (1,1), respectively.  However, the command<br><br>(s,whatever) = q intersectiontimes p;<br>
<br>returns the last (namely 0.92859) time for q instead of the first (namely 0.07144) time for the intersection.  Is there a way to FORCE "q intersectiontimes p" to always return the smallest time for q?<br><br>
Thanks in advance,<br><br>Troy<br><br>--<br><br>path p,q,r;<br>p:=(0,0){up}..(1,1){right}..(4,-2){down}..(1,-5){left}..(0,-4){up}..(2,-2){up}..cycle;<br>q:=(1,-5.5)--(1,1.5);<br>r:=subpath (0,1/4) of q;<br><br>numeric s,t;<br>
(s,whatever)=q intersectiontimes p;<br>(t,whatever)=r intersectiontimes p;<br><br>beginfig(0);<br>    u:=28;<br>    draw p scaled u;<br>    drawarrow subpath (0,1/6) of q scaled u withcolor red;<br>    drawarrow subpath (1/6,1/2) of q scaled u withcolor red;<br>
    drawarrow subpath (1/2,5/6) of q scaled u withcolor red;<br>    draw subpath (5/6,1) of q scaled u withcolor red;<br>    fill fullcircle scaled 4 shifted (point s of q scaled u) withcolor blue;<br>    fill fullcircle scaled 4 shifted (point t of r scaled u) withcolor (7/8*green);<br>
endfig;<br><br>end<br>