random

Overview

rowan.random.rand Generate random rotations uniformly distributed on a unit sphere.
rowan.random.random_sample Generate random rotations uniformly.

Details

Various functions for generating random sets of rotation quaternions.

Random quaternions in general can be generated by simply randomly sampling 4-vectors, and they can be converted into rotation quaternions by normalizing them. This package is strictly focused on generating uniform samples on \(SO(3)\), ensuring that rotations are uniformly sampled rather than just the space of unit quaternions.

rowan.random.rand(*args)

Generate random rotations uniformly distributed on a unit sphere.

This is a convenience function a la np.random.rand. If you want a function that takes a tuple as input, use random_sample() instead.

Parameters:shape (tuple) – The shape of the array to generate.
Returns:Random quaternions of the shape provided with an additional axis of length 4.
Return type:numpy.ndarray

Example:

>>> rowan.random.rand(3, 3, 2) 
rowan.random.random_sample(size=None)

Generate random rotations uniformly.

In general, sampling from the space of all quaternions will not generate uniform rotations. What we want is a distribution that accounts for the density of rotations, i.e., a distribution that is uniform with respect to the appropriate measure. The algorithm used here is detailed in [Shoe92].

[Shoe92]Shoemake, K.: Uniform random rotations. In: D. Kirk, editor, Graphics Gems III, pages 124-132. Academic, New York, 1992.
Parameters:size (tuple) – The shape of the array to generate.
Returns:Random quaternions of the shape provided with an additional axis of length 4.
Return type:numpy.ndarray

Example:

>>> rowan.random.random_sample((3, 3, 2))