Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to sample uniformly in SO(3) #192

Closed
qqfly opened this issue Feb 19, 2019 · 4 comments
Closed

How to sample uniformly in SO(3) #192

qqfly opened this issue Feb 19, 2019 · 4 comments

Comments

@qqfly
Copy link

qqfly commented Feb 19, 2019

There are serveral realization of SO(3) sampling.

In Sophus, we firstly uniformly sample a point on a sphere (unit rotation axis), then uniformly sample a rotation angle: Sophus::SO3d::sampleUniform()

But in Eigen, Eigen::Quaterniond::unitRandom() is based on http://planning.cs.uiuc.edu/node198.html

Besides, in manif, they generate a random tangent space element and expMap to Lie group: LieGroupBase::setRandom().

Which sampling is better? Or, why doesn't Sophus use the Eigen's realization?

Besides, I also open a discussion in Manif.

@strasdat
Copy link
Owner

The discussion is quite interesting...

@dllu
Copy link

dllu commented Sep 19, 2019

Any method that uniformly randomly samples from the 4D hypersphere, treated as a unit quaternion, will be a uniformly random element of SO(3) because of the 2-to-1 mapping from unit quaternions to SO(3).

I would be curious to know if the method cited in the Eigen docs is faster than generating a unit quaternion using Marsaglia's method here: http://mathworld.wolfram.com/HyperspherePointPicking.html

It would seem to me that Marsaglia's method might be faster due to avoiding the sin and cos. At any rate it must be faster three calls to normal which is currently used. Incidentally, a related method, also due to Marsaglia, is used for generating pairs of normal-distributed numbers.

In my experience, rejection sampling is faster than carefully doing sin and cos, for example, when generating points in a unit disk.

You guys may find the following meme amusing: pic

@jlblancoc
Copy link
Contributor

+💯 for the meme! 😃

@UnixJunkie
Copy link

Look this paper:
cf. "Super-Fibonacci Spirals: Fast, Low-Discrepancy Sampling of SO(3)"
by Marc Alexa
Quite simple method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants