This may be more of a search for a term, but solutions are also welcome. I’m looking to create n amount of random x,y coordinates. The issue I am having is that I would like the coordinates to be “weighted” or have more of a chance of falling closer to a specific point. I’ve created something close by using this pseudo code:
x = rand(100) //random integer between 0 and 100
x = rand(x) //random number between 0 and the previous rand value
//randomize x to positive or negative
//repeat for y
This works to pull objects toward 0,0 - however if you create enough points, you can see a pattern of the x and y axis. This is because the even if x manages to get to 100, the chances are high that y will then be closer to.
I’m looking to avoid the formation of this x,y line. Bonus points if there is a way to throw in multiple “weighted coordinates” that the random coordinates would sort of gravitate to, instead of statically to 0,0.
If you want to see what I’ve currently written up out of curiosity, you can find it here: https://gist.github.com/KyleWolfe/d03144aa43819d3ecb3d. You can fire this up with golang, and throw this project (https://github.com/thunder9/xy.js/tree/master) into a folder called static, at the same level you are running the binary. Change the ‘points’ global var to something larger to see what I mean about seeing the x, y axis