ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* How can I compare picture variables in metapost?
@ 2009-05-05 12:27 Zhichu Chen
  2009-05-05 12:51 ` Taco Hoekwater
  0 siblings, 1 reply; 14+ messages in thread
From: Zhichu Chen @ 2009-05-05 12:27 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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 : 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
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-05-06  9:06 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-05 12:27 How can I compare picture variables in metapost? Zhichu Chen
2009-05-05 12:51 ` Taco Hoekwater
2009-05-05 13:51   ` Zhichu Chen
2009-05-05 15:04     ` Taco Hoekwater
2009-05-05 15:19       ` Zhichu Chen
2009-05-05 16:06         ` Taco Hoekwater
2009-05-05 16:54           ` Taco Hoekwater
2009-05-05 21:42             ` Peter Rolf
2009-05-05 23:28               ` Aditya Mahajan
2009-05-06  1:46                 ` Zhichu Chen
2009-05-06  2:10                   ` Aditya Mahajan
2009-05-06  3:09                     ` Aditya Mahajan
2009-05-06  9:06                 ` Peter Rolf
2009-05-05 22:57         ` Aditya Mahajan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).