[metapost] Re: all intersections between two paths

Laurence Finston lfinsto1 at gwdg.de
Sun Jan 16 19:05:34 CET 2005


Larry Siebenmann wrote:

> 
> I too feel that loosening constraints is the better option
> but I may be wrong.

I think so too, if you've got a clever algorithm.  I didn't have one.

> By playing with the control vectors
> one can group the intersection points more or less at will, thus
> frustrating naive recipes to split *automatically* into two segments
> to which Jacko's 'intersect_curves' function directly applies.

I confess to the charge of naivete.  One nice thing about C++ is that it
supports a style of programming that allows one to change the implementation
without changing the interface.  As I learn or develop less naive algorithms,
I can incorporate them into my program without having to rewrite it
completely.  

The point I'd like to make is that one doesn't have to be a computer scientist
and a mathematician to write a program that does something useful.  These are
two wonderful things to be, but it's not _necessary_.  
If my work has a point, I hope it is to encourage others to say "hey, if he
can do it, anyone can", and program something themselves.

> May fail for over 30 intersection points since recursion used.

I _always_ try to eliminate recursion in my programs wherever possible, and it
often is.  I haven't read your code, so I don't know whether it is in this
case.  However, I think it would be worthwhile to consider whether you
couldn't just put the subpaths onto an array and loop over the array until
some condition is met.

> but the truth is that I feel a complete beginner every time I start to
> program again with MP!

That's a good way to feel.  As Shunryu Suzuki Roshi said,
"Beginners have many possibilities, experts only a few."  
(_Zen Spirit, Beginner's Spirit_.
This is my translation back into English of the German translation, so it may
diverge a little from the original English.)

Laurence
 

      



More information about the metapost mailing list