Need help witht he math

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
Post Reply
User avatar
Zacariaz
Member
Member
Posts: 1069
Joined: Tue May 22, 2007 2:36 pm
Contact:

Need help witht he math

Post by Zacariaz »

I, as so many times before, have a problem which is starting to give me brain cancer or something. At least my head hurts.

Anyway, the problem is this.

I have a rectangular 2d surface and this area need to be covered circular areas, the centre of which cannot lie outside the borders of the rectangle. The trick is then to use the least amounts of circles.

I know this all sounds very odd because I don't really know how to explain the problem, so I've made an example.

For my purpose the rectangle is 479*989 and the circles all have a radius of 21.6.
In this example 432 circles are used.
http://myhideout.eu/temp/cnd.svg

The above example don't quite follow the rules though, as several of the circles have a centre lying outside the bounds of the rectangle.

I should think that this is not a new problem and that probably there's some fancy formula or something.
In any case, if you're able to help, I'll be very grateful ;)


Best regards.
This was supposed to be a cool signature...
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Need help witht he math

Post by Combuster »

Its to be done with floors/ceils. Since you know how the pattern must be, you can calculate how much space each circle can fill up, then divide that over the size of the image, no?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Thomas
Member
Member
Posts: 281
Joined: Thu Jun 04, 2009 11:12 pm

Re: Need help witht he math

Post by Thomas »

Hi,
Idea would be create an equation or function that describes the situation and find out the maxima and minima using differential calculus.But I myself am not quite clear with the rules from the example you gave.Hope it gives you some direction.

Hopefully this gives you a start : http://en.wikipedia.org/wiki/Maxima_and_minima

--Thomas
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Need help witht he math

Post by gerryg400 »

The way you allow those circles to overlap, it looks like a hexagonal tesselation problem. You ought to be able to express the hexagon's dimensions in terms of the circle's radius. Not too difficult from there.
If a trainstation is where trains stop, what is a workstation ?
Post Reply