This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 823 - Provide static Quaternion method for uniform random rotation
Summary: Provide static Quaternion method for uniform random rotation
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Geometry (show other bugs)
Version: unspecified
Hardware: All All
: Low Feature Request
Assignee: Nobody
URL:
Whiteboard:
Keywords: JuniorJob
Depends on:
Blocks:
 
Reported: 2014-06-06 10:43 UTC by edx
Modified: 2019-12-04 13:23 UTC (History)
5 users (show)



Attachments
Add uniformly random quaternion (2.26 KB, patch)
2016-03-21 14:45 UTC, Joseph Mirabel
no flags Details | Diff

Description edx 2014-06-06 10:43:22 UTC
Please implement some algorithm for generating uniformly-distributed random orientation; an algorithm is decribed in http://planning.cs.uiuc.edu/node198.html (references Shoemaker's Uniform random rotations from Graphic Gems III).

A tentative implementation  goes like this (with UnitRandom returning uniform in 0..1):

  template<typename Scalar>
  Quaternion<Scalar> UniformRandomRotation(){
    Scalar u1=UnitRandom(), u2=UnitRandom(), u3=UnitRandom();
    return Quaternion<Scalar>(/*w*/sqrt(u1)*cos(2*M_PI*u3),/*x*/sqrt(1-u1)*sin(2*M_PI*u2),/*y*/sqrt(1-u1)*cos(2*M_PI*u2),/*z*/sqrt(u1)*sin(2*M_PI*u3));
  }
Comment 1 Gael Guennebaud 2014-06-06 11:35:06 UTC
Please provide a clean patch with documentation and its respective unit test (added in test/geo_quaternion.cpp) so that it can be integrated quickly.

For "UnitRandom" you can use internal::random<Scalar>(0,1);

Thanks.
Comment 2 Joseph Mirabel 2016-03-21 14:45:46 UTC
Created attachment 669 [details]
Add uniformly random quaternion

Would this fit the Eigen coding standards ?
Comment 3 Gael Guennebaud 2016-05-20 11:24:11 UTC
Sorry for the delay, but it's now in devel branch:

https://bitbucket.org/eigen/eigen/commits/423d3da0e233/
Summary: Bug 823: add static method to Quaternion for uniform random rotations. 

https://bitbucket.org/eigen/eigen/commits/5d78b569eac3/
Summary: Fix coding practice in Quaternion::UniformRandom

https://bitbucket.org/eigen/eigen/commits/20c444245e5c/
Summary: Rename UniformRandom to UnitRandom.
Comment 4 Nobody 2019-12-04 13:23:23 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/823.

Note You need to log in before you can comment on or make changes to this bug.