[ucc] Drawing circles
Grahame Bowland
grahame at angrygoats.net
Fri Jul 6 00:16:02 WST 2007
Hey
Thinking about this for a minute, why don't you:
1. Pick a point in the x,y coordinates of the rectangle
2. Draw a circle of some radius r, determined randomly (pick a sensible min/max)
3. Pick a point on that circle (x^2 + y^2 = r^2) randomly. You know r,
you can generate x or y randomly and thus determine the remaining
variable. You can even impose sensible constraints on the random
value, so that you get a point in a spot that makes sense (eg. not
within min(r) of one of the rectangle edges.)
4. Draw a circle that neatly touches that point, and does not pass
through any other circle, with a random radius as in 2.
5. Select one of the existing circles randomly, and goto 3.
As all the circles touch each other, you should get something that
looks swiss cheese-ish by just drawing all circles with some constant
subtracted from the radius. This obviously doesn't hold all of the
time as we only consider a single circle when picking circle radii for
new circles. It might look okay though, and perhaps even more random
and realistic?
I think with a bit of work to pick random numbers in an intelligent
fashion this should work. Someone else is bound to respond with
something more elegant though. This page seems interesting:
http://york.cuny.edu/~malk/tidbits/tidbit-geometric-packing.html
On 05/07/07, Antony N. Lord <antony.lord at empresa.com.au> wrote:
>
>
> I have an odd problem that I thought someone might be able to help with :
>
> I need to draw a pattern - a series of circles of random sizes filling a
> rectangle with the distance between the outsides of each circle being the
> same. i.e. a swiss cheese kind of effect. I've been doing it by hand in
> Illustrator but it doesn't look nearly random or interesting enough (and
> making the spacing the same sucks!)
>
> It needs (ideally) to be a PDF or vector output as the destination is going
> to be a sheet of laser cut MDF.
>
> Coding it up shouldn't be that hard, its more the maths that I need at this
> point.
>
> Cheers, Antony.
>
More information about the ucc
mailing list