Feature request: uniform random rotation sampling
See original GitHub issueI’d like to be able to apply a random rotation to an object. There are a couple of ways I initially thought to do this: random euler angles, random (normalized) rotation matrix values, and random (normalized) quaternion values.
The problem is, none of these random rotation methods sample uniformly from SO(3), the set of all 3D rotations. From the (admittedly, limited) research I’ve done, it appears that there are two methods that do sample uniformly from SO(3):
-
Generate a random point along the surface of a unit sphere, convert the point to a vector, and combine the vector with a random rotation 0 < u < 2*PI to form an axis-angle rotation representation. For generating a random point on the surface of a unit sphere, see the following: https://mathworld.wolfram.com/SpherePointPicking.html
-
Generate a random quaternion. The method described in the link below samples uniformly from SO(3): http://planning.cs.uiuc.edu/node198.html
Method 2 seems easy enough, and I plan to use it in my application.
Reading through some of the discussion in https://github.com/mrdoob/three.js/issues/18996, it seems like this may be a compelling enough use case to either:
-
Add a random method to the quaternion class that implements the logic described in method 2 above, or
-
Add this logic to
examples/jsm/math/Sampling.js
orexamples/jsm/math/Random.js
, as discussed in https://github.com/mrdoob/three.js/issues/18996#issuecomment-606243878
What do you all think? I’d understand if you think it’s too application-specific, but I figured I’d raise the idea anyway. I’d be happy to write a PR for either solution if you’d like.
All the best, Cameron
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:17 (12 by maintainers)
Top GitHub Comments
How is this (too) complicated?
that would be non-uniform, @mrdoob