weldx.WXRotation.random#
- WXRotation.random(type cls, num=None, random_state=None)#
Generate uniformly distributed rotations.
- Parameters:
num (int or None, optional) – Number of random rotations to generate. If None (default), then a single rotation is generated.
random_state ({None, int,
numpy.random.Generator
,) –numpy.random.RandomState
}, optionalIf
seed
is None (ornp.random
), thenumpy.random.RandomState
singleton is used. Ifseed
is an int, a newRandomState
instance is used, seeded withseed
. Ifseed
is already aGenerator
orRandomState
instance then that instance is used.
- Returns:
random_rotation – Contains a single rotation if
num
is None. Otherwise contains a stack ofnum
rotations.- Return type:
Rotation
instance
Notes
This function is optimized for efficiently sampling random rotation matrices in three dimensions. For generating random rotation matrices in higher dimensions, see
scipy.stats.special_ortho_group
.Examples
>>> from scipy.spatial.transform import Rotation as R
Sample a single rotation:
>>> R.random().as_euler('zxy', degrees=True) array([-110.5976185 , 55.32758512, 76.3289269 ]) # random
Sample a stack of rotations:
>>> R.random(5).as_euler('zxy', degrees=True) array([[-110.5976185 , 55.32758512, 76.3289269 ], # random [ -91.59132005, -14.3629884 , -93.91933182], [ 25.23835501, 45.02035145, -121.67867086], [ -51.51414184, -15.29022692, -172.46870023], [ -81.63376847, -27.39521579, 2.60408416]])
See also