pytransform3d.rotations.random_quaternion#
- pytransform3d.rotations.random_quaternion(rng=Generator(PCG64) at 0x7FE8976AE180)[source]#
Generate uniform random quaternion.
This is similar to scipy’s implementation of uniform random sampling of rotations. It is based on Shoemake’s algorithm [1], but we simplify the implementation by sampling a quaternion from a multivariate standard normal distribution and normalize it. In this way, we obtain a uniform distribution over rotation axes and a distribution proportional to \(\sin^2(\theta/2)\) over the rotation angles, which together constitute the Haar measure on \(SO(3)\).
- Parameters:
- rngnp.random.Generator, optional (default: random seed 0)
Random number generator
- Returns:
- qarray, shape (4,)
Unit quaternion to represent rotation: (w, x, y, z)
References
[1]Shoemake, K. (1992). Uniform Random Rotations. Graphics Gems III, pages 124-132. Academic, New York. DOI: 10.1016/B978-0-08-050755-2.50036-1