Hi all,
I want to draw some paths that won't intersect with each other
in metapost. Those paths are generated "randomly," e.g., draw
100 circles without any intersections. I use a very stupid
way like:
=============================================
% randomseed:= day + time*epsilon ;
save minL ; numeric minL ; minL = infinity ;
z[0] = origin;
for i=1 upto 99 :
z[i] = (uniformdeviate 1 , uniformdeviate 1 ) ;
for j=0 upto i-1 :
if abs(z[i]-z[j])<minL : minL := abs(z[i]-z[j]) ; fi
endfor
endfor
for i=0 upto 99 :
draw fullcircle scaled 2cm shifted (z[i] scaled (2cm/minL))
withcolor (i/100, (100-i)/100, abs(50-i)/100);
endfor
=============================================
The randomseed made me crazy, for one time it compiles
fine and sometimes it just flows out which I think may due
to the size of the picture becomes big enough.
I think a better way could be like this:
pick a random point, fill it with color, pick another point and
use "clip currentpicture to somepath" and determine whether
it is blank or not. But "if currentpicture=nullpicture" won't work,
so I'm stunned.
Thank you for your time.
--
Best Regards
Chen
----------------------------------------------------------------
Zhi-chu Chen | Shanghai Synchrotron Radiation Facility
No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China
tel: 086 21 5955 3405 | zhichu.chen.googlepages.com
| www.sinap.ac.cn
----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] / 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
___________________________________________________________________________________