Taco Hoekwater wrote:
Zhichu Chen wrote:
Seems that I don't have too many choices. Maybe using lua to do the
math and throwing the result to metapost is faster? I think I can do
this, but I don't know how. The documents are a little limited.
For circles, probably lua calculations will be faster because the
data manipulation will be a bit easier. But for non-circle paths,
you are better off with a metapost solution because of lua not
knowing about the actual paths.
linear search does seem to do that badly, here is a stub:
path p[];
path m;
pair n;
i := 0;
forever:
exitif i > 99;
m := fullcircle scaled (uniformdeviate 20)
shifted (uniformdeviate 100, uniformdeviate 100);
n := (-1,-1);
if i<>0:
for j = 0 upto (i-1):
n := m intersectiontimes p[j];
exitif (xpart n)>=0;
endfor;
fi
if (xpart n)<0:
p[i] := m ;
i := i + 1;
message(decimal(i));
fi
endfor;
beginfig(1);
for i:=0 upto 99:
fill p[i];
endfor;
currentpicture := currentpicture scaled 5;
endfig;
end.
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________