I need to equally distribute N points on a rectangle with a certain width and height.
Ex. given a 10×10 box and 100 points, the points would be set as:
(1,1) (1,2) (1,3) (1,4) (1,5) (1,6) (1,7) (1,8) (1,9) (1,10)
(2,1) (2,2) (2,3) (2,4) (2,5) (2,6) (2,7) (2,8) (2,9) (2,10)
(3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7) (3,8) (3,9) (3,10)
...
...
How can I generalize this for any N points, width and height combination?
Note: It doesn’t needs to be perfect, but close, I’m going to randomize this a little bit anyway (move the point +/- x pixels from this “starting point” on X and Y axis), so having a leftover of a few points to randomly add at the end could be just fine.
I’m looking for something like this (quasirandom):

I managed to make this, if anybody else is looking to accomplish this here’s how:
First you calculate the total area of the rectangle, then you calculate the area every point should use, and then calculate its own pointWidth and pointHeight (length), then iterate to make cols and rows, here’s an example.
PHP code:
I also needed to randomize the position of the dot a little bit, I made this by placing this in the 2nd “for” instead of the code above.
Hope this helps somebody out there.