compact

Convert quaternion array to N-by-4 matrix

Description

example

matrix = compact(quat) converts the quaternion array, quat, to an N-by-4 matrix. The columns are made from the four quaternion parts. The ith row of the matrix corresponds to quat(i).

Examples

collapse all

Create a scalar quaternion with random parts. Convert the parts to a 1-by-4 vector using compact.

randomParts = randn(1,4)
randomParts = 1×4

0.5377    1.8339   -2.2588    0.8622

quat = quaternion(randomParts)
quat = quaternion
0.53767 +  1.8339i -  2.2588j + 0.86217k

quatParts = compact(quat)
quatParts = 1×4

0.5377    1.8339   -2.2588    0.8622

Create a 2-by-2 array of quaternions, then convert the representation to a matrix of quaternion parts. The output rows correspond to the linear indices of the quaternion array.

quatArray = [quaternion([1:4;5:8]),quaternion([9:12;13:16])]
quatArray = 2x2 quaternion array
1 +  2i +  3j +  4k      9 + 10i + 11j + 12k
5 +  6i +  7j +  8k     13 + 14i + 15j + 16k

quatArrayParts = compact(quatArray)
quatArrayParts = 4×4

1     2     3     4
5     6     7     8
9    10    11    12
13    14    15    16

Input Arguments

collapse all

Quaternion to convert, specified as scalar, vector, matrix, or multidimensional array of quaternions.

Data Types: quaternion

Output Arguments

collapse all

Quaternion in matrix form, returned as an N-by-4 matrix, where N = numel(quat).

Data Types: single | double

Extended Capabilities

Objects

Introduced in R2021a 