Quaternion Function Reference

quaternion

Quaternion constructor

Syntax

q = quaternion(w, x, y, z)

Description

This function constructs quaternion (arrays) from components. It accepts from zero to four arguments. The permissible cases are set out in the following paragraphs.

Given no arguments, this function constructs an empty quaternion.

Given one argument which is already a quaternion, the function returns the argument unchanged. If the argument is not a quaternion, the function constructs a quaternion with the argument in the scalar part and supplies a zero vector part of the same type as the argument. Thus if the argument is a double, the resulting quaternion will have a vector part with double zeros as components.

If two arguments are supplied, the first must be numeric, and the second must be a pure quaternion of the same size. The result will be a full quaternion. The first argument must have the same class as the components of the second. This is to prevent the creation of quaternion arrays of mixed class.

If three arguments are supplied, they must be numeric and of the same size and class. The result is a pure quaternion.

If four arguments are supplied, they must be numeric and of the same size and class. The result is a full quaternion.

Examples

>> quaternion()
 
ans = [] quaternion

>> quaternion(randn('single'), randv('single'))
 
ans = 0.7677 + 0.06019 * I + 0.8961 * J - 0.4397 * K
 
>> class(x(ans))

ans = single
 
>> quaternion(1, 2, 3)
 
ans = 1 * I + 2 * J + 3 * K
 
>> quaternion(1, 2, 3, 4)
 
ans = 1 + 2 * I + 3 * J + 4 * K

>> quaternion(randn(2))
 
ans = 2x2 quaternion array

© 2008-2013 Stephen J. Sangwine and Nicolas Le Bihan

License terms.