Main Content

randrot

Uniformly distributed random rotations

Description

R= randrotreturns a unit quaternion drawn from a uniform distribution of random rotations.

example

R= randrot(m)returns anm-by-mmatrix of unit quaternions drawn from a uniform distribution of random rotations.

example

R= randrot(m1,...,mN)returns anm1-by-...-by-mNarray of random unit quaternions, wherem1,…,mNindicate the size of each dimension. For example,randrot(3、4)returns a 3-by-4 matrix of random unit quaternions.

R= randrot((m1,...,mN])returns anm1-by-...-by-mNarray of random unit quaternions, wherem1,…,mNindicate the size of each dimension. For example,randrot([3,4])returns a 3-by-4 matrix of random unit quaternions.

Examples

collapse all

Generate a 3-by-3 matrix of uniformly distributed random rotations.

r = randrot(3)
r =3x3 quaternion array0.17446 + 0.59506i - 0.73295j + 0.27976k 0.69704 - 0.060589i + 0.68679j - 0.19695k 0.35191 + 0.74478i + 0.52322j - 0.21842k 0.21908 - 0.89875i - 0.298j + 0.23548k -0.049744 + 0.59691i + 0.56459j + 0.56786k 0.17527 - 0.46955i + 0.52986j - 0.68414k 0.6375 + 0.49338i - 0.24049j + 0.54068k 0.2979 - 0.53568i + 0.31819j + 0.72323k -0.30189 - 0.22864i - 0.83159j + 0.40626k

500年创建一个向量随机四元数。使用rotatepointto visualize the distribution of the random rotations applied to point (1, 0, 0).

q = randrot(500,1); pt = rotatepoint(q, [1 0 0]); figure scatter3(pt(:,1), pt(:,2), pt(:,3)) axisequal

Figure contains an axes object. The axes object contains an object of type scatter.

Input Arguments

collapse all

Size of square quaternion matrix, specified as an integer value. Ifmis0or negative, thenRis returned as an empty matrix.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Size of each dimension, specified as two or more integer values. If the size of any dimension is0or negative, thenRis returned as an empty array.

Example:randrot(2,3)returns a 2-by-3 matrix of random quaternions.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Vector of size of each dimension, specified as a row vector of two or more integer values. If the size of any dimension is0or negative, thenRis returned as an empty array.

Example:randrot([2,3])returns a 2-by-3 matrix of random quaternions.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64

Output Arguments

collapse all

Random quaternions, returned as a quaternion or array of quaternions.

Data Types:quaternion

References

(1] Shoemake, K. "Uniform Random Rotations."Graphics Gems III(K. David, ed.). New York: Academic Press, 1992.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2019a