algorithm - How to effectively distribute points on plane -


i have plane (screen) width , height (monitor resolution, not square). , i'd distribute points on plane (approximately) same distance each other.

for example:

  • 1 point in middle,
  • 2 points in middle of y axis, , x axis divided 3
  • 3 points may triangle, if sceen wide enough, thay can alighned in same y
  • 4 second part of above, or rectangle..
  • etc 8 points max

is there algorithm this?

thank time!

edit: same distance each other , plane border

edit2: compute centers of mass groups of objects on behavior simulate on plane.

depending on precision want:

  • you can stochasticaly correct answer poisson disk sampling. specifically, poisson disk sampling random sampling such no points closer specified radius. such thing can efficiently (linear time) implemented in high dimension - e.g. : c++ code robert bridson : http://www.cs.ubc.ca/~rbridson/download/curlnoise.tar.gz implementing paper http://www.cs.ubc.ca/~rbridson/docs/bridson-siggraph07-poissondisk.pdf

  • you can optimize position of points. leads lloyd algorithms , similar optimization procedures : compute voronoi diagram of initial set of points, , move these points the centroid of voronoi cell. can done efficiently, , can sped using newton's method rather lloyd iteration. ultimately, if domain square, should obtain hexagonal grid (which minimizes function above).

if need approximate results, i'd suggest first approach should faster.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -