Packing a rectangle with equal sized circles python -


i have rectangular bounding box defined width w , height h , area a.

how can pack n number of circles of equal area a inside rectangle such a-n*a minimal.

in other words, how can calculate optimal number of equal sized circles can packed inside rectangle

my use case: using kmeans clustering algorithm clustering vehicles in geographical bounding box. in order set number of clusters kmeans algorithm, experimenting circle packing 1 way of deriving number of clusters before apply kmeans algorithm.

edit: edited op number can in deciding number of k-means clusters based on fitting circles in plane , minimizing uncovered places.

from math import sqrt, pi  def get_approximate_k(rectangle_area, circle_area):     # making use of fact in infinite hexagonal packing, packing ratio (pi*sqrt(3)/6)     return int((rectangle_area * pi * sqrt(3))/(6 * circle_area))  print get_approximate_k(10*100, 12) # returns 75 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

unity3d - Fatal error- Monodevelop-Unity failed to start -