Vector3d has Vector3d.createRandomDirection(rdm) but what would be the best / clean way to get a *fair* random direction without implementing it yourself?

Maybe a PR to Flow Math would be appreciated?

Vector3d has Vector3d.createRandomDirection(rdm) but what would be the best / clean way to get a *fair* random direction without implementing it yourself?

Maybe a PR to Flow Math would be appreciated?

couldn’t you use the vector as a direction?

Flow math uses spherical coordinates to pick a point on a sphere, but I’m not sure if the distribution is really uniform. You could also try generating a random pitch and yaw, converting it to a quaternion using the static constructor, then getting the direction using the provided method. Although I think this is just a more contrived way of doing the same thing, so it’s not better.

Just realized that I missed saying I was looking for a Vector3i, it was mentioned in the title but it wasn’t clear.

I don’t see how a random direction for Vector3i even makes sense. Are you more talking about a random offset with a specific amount? If that’s the case I’d start with a random Vector3d and then offset it a random direction, and then convert it to a Vector3i. You could probably create an extra function for the last two steps to avoid an object creation.

Pick random angles that are multiples of 90˚.