random#
- Quaternion.random() ndarray#
Generate a random quaternion
A mapping in SO(3) is first created and then transformed as explained originally by [Sho92]. It calls the function
random_attitudes()withn=1.Warning
The generated random quaternion is returned as a NumPy array, but it is not set in the object. To create a
Quaternionobject with random values, we can indicate this when creating the object. See examples below.- Returns:
q – Random array corresponding to a valid quaternion
- Return type:
numpy.ndarray
Examples
>>> q = Quaternion() >>> q Quaternion([1., 0., 0., 0.]) >>> q.random() array([-0.13952338, 0.96330741, -0.18034361, -0.14159178]) >>> q Quaternion([1., 0., 0., 0.])
It can be called when the Quaternion object is created:
>>> Quaternion(random=True) Quaternion([-0.51862103, -0.23740681, 0.32023593, 0.75638561])
See also
random_attitudesGenerate random attitudes