1 Attachment(s)

should this algorithm work?

I am trying to randomly place stars a fixed distance away from a fixed point in space so it creates a sphere-like formation. So far it seems to be working, as in the stars look like they're in a sphere (as shown in the picture)

Here is my algorithm:

randomly choose x, y and z positions so that it is between positive and negative 600

Normalize the Position, this means it will have a distance of one from the center of the sphere (this is where I'm not sure if its true, I'm trying to test but I am getting screwy values)

Then multiply the position by the distance away from the center that you want (again, i am getting screwy values testing but my math in the testing phase could be wrong)

Does the algorithm seem like it should work? The sphere to the left is what I'm creating, but I'm not sure if the distance from the center to each star is what I want