[metapost] all intersections between two paths

Laurence Finston lfinsto1 at gwdg.de
Wed Jan 5 19:51:47 CET 2005

I'd try something like the following.
Please note that it's a sort of pseudo-code, since I don't have time
(or the inclination) to work out a real example.  This means you'll
probably have to fiddle with it.
You'll also have to catch the cases that the subpaths don't
intersect and eliminate duplicate `pairs' (if it's possible
to have them).

Unfortunately, I'm not a good enough mathematician to be able to
tell you whether `paths' of length 1 can have discontinuities,
or whether two of them can have more than one intersection.



path a, b;

a = [...]
b = [...]

length_a = length a;
length_b = length b;

pair p[];

ctr = 0;

for i = 0 upto length_a - 1:
   for j = 0 upto length_b - 1:
      p[ctr] = subpath (i, i + 1) of a intersectionpoint
               subpath (j, j + 1) of b;
      ctr = incr ctr;

On Wed, 5 Jan 2005, Antonio Ramirez wrote:

> For what it's worth, below is my last attempt at writing the macro,
> [...]

More information about the metapost mailing list