samedi 6 janvier 2018

javascript: generate random number that are separated by a specific "margin"

I would like to generate x random number between a and b. Each of this x random number should not be closer that y to the others ones:

If y = 100 then I shouldn't have 500 and 555 generated but 500 and 601 would be okay.


More context: I would like to generate x circles with d3.js, that don't touch each other (so y would be the radius of the the bigger circle). I could use something like this but I would prefer something without using force().




Aucun commentaire:

Enregistrer un commentaire