[metapost] MetaFont: Unexpected behavior of intersections times

Dan Luecking luecking at uark.edu
Tue Apr 5 00:45:20 CEST 2011


At 11:48 PM 4/2/2011, you wrote:
> > p1:=(33.09007380767,-33.8895224139) .. controls
> > (33.370612519531,-33.905534970703) and (33.65115125,-33.9215475) ..
> > (33.93169,-33.93756);
> >
> > p2:=(38.1058,-34.00049) .. controls (36.39993,-34.00049) and
> > (34.44913,-34.0004125) .. (32.79190125,-33.86743875);
[...]
>Hm p1 isn't  a sub path of p2
>
>With a subpath
>p3 := subpath(0.4,0.8) of p2;
>message "p3 := subpath(0.4,0.8) of p2;";
>numeric t,u;
>(t,u) = p3 intersectiontimes p2;
>show t,u
>
>gives
>
>t = 0.2179 , u =  0.48718 (but why t is not 0 or 1 ?)

[See my previous message to the metapost list, in reply to Nicola.]

Metapost keeps subdividing the two paths, testing which
pairs of quadrilaterals overlap until the moment it finds a
pair that overlap to the precision of its algorithm.

Then it stops.

Since every subdivision of the subpath theoretically intersects
the larger path, it is pretty much random which one will hit
the precision limit first. Also, at finite precision it is even
likely that some of these subdivided paths of p3 are judged
_not_ to intersect with p2.


Dan


Daniel H. Luecking
Department of Mathematical Sciences
Fayetteville, Arkansas
http://www-cs-faculty.stanford.edu/~knuth/iaq.html 



More information about the metapost mailing list