Random.rotationUniform clarification

In the doc it says:

Random.rotation
Returns a random rotation (Read Only).

Random.rotationUniform
Returns a random rotation with uniform distribution(Read Only).

I’m not sure at 100% that I understand correctly this property. If I generate 10 random rotation with Random.rotation I’ll get 10 totally random rotation and it’s technically possible (but improbable) that I can get almost the same rotation twice.

If I use Random.rotationUniform, I’ll have 10 really distinct rotation.

Right or wrong?

EDIT: My question was probably not enough clear (sorry, english is my second language). You basically said the same thing has I thought.
I run some test to see the difference graphically, but I can’t see any difference. I generate random rotation with both method for a vector and the randomUniform is not more uniform. So I’m a bit confuse about this property

Wrong. ‘Random.rotationUniform’ means that all possible rotations have equal probability of occurring. I expect if you tested the original Random.rotation you would find some clustering in the rotation. That is if you use the rotation to rotate a vector and then plotted the tip of each vector, Random.rotationUniform would produce a sphere where the points were generally uniformly distributed. With the Random.rotaition you’d likely see some clusters of points.

I would assume that the first implementation just generates three random values for the Yaw, Pitch and Roll of the rotation. While this seem random there are multiple combinations of Yaw, Pitch and Roll that will represent the same direction. This means those directions have a increased chance to be generated.

What I’m wondering is how they solved this to make the distribution truly uniform.

I’m late here, but the problem doesn’t seem to have been addressed after more than five years now. I mean, nothing official, only guesses.

I don’t have much more to say than
@robertbu. As he said, Random.rotationUniform doesn’t guarantee that different rotations will be drawn, but if I’m correct, does give rotations uniformly distributed on the hypersphere. So one would say, why use Random.rotation ? It’s because rotationUniform is likely more demanding, hence Random.rotation sacrifices uniformity to performance.

Problem is it’s on a 4 dimensional hypersphere, hence it could be difficult to notice visually. The clusters are probably around the 16 projections of the corners of the unit hypercube on the hypersphere. After some thought, I suppose it could still be seen on a projection of the w = 0 hyperplan (or x = 0, or y = 0, or z = 0), where the clusters would be around the 8 projections of the cube corners on the sphere.

But that’s my idea of it and I can’t say for sure…

My guess is that rotationUniform works by randomizing the Euler angles, which makes the rotation indeed uniform across all axes, while (non-uniform) rotation works by randomizing the xyzw values, then normalizing the quaternion.

As other commenters already noticed, rotation sacrifices uniformity to performance, because on one hand you have to convert Euler angles to quaternion, and on the other, you have no true guarantee of a proper distribution on a 3D sphere.

Normalization isn’t cheap either, so I’m thinking that rotation doesn’t even do that, but actually manipulates the values in such a way so that the resulting quaternion is already on a hypersphere, in order to maximize the calculation speed, but the points (being linearly distributed each in its own dimension) likely converge to some hyperplanes (where exactly is beyond me, without further research).