M-File Help: Quaternion View code for Quaternion

Quaternion

Quaternion class

A quaternion is 4-element mathematical object comprising a scalar s, and a vector v and is typically written: q = s <<vx, vy, vz>>.

A quaternion of unit length can be used to represent 3D orientation and is implemented by the subclass UnitQuaternion.

Constructors

Quaternion general constructor
Quaternion.pure pure quaternion

Display methods

display print in human readable form

Operation methods

inv inverse
conj conjugate
norm norm, or length
unit unitized quaternion
inner inner product

Conversion methods

char convert to string
double quaternion elements as 4-vector
matrix quaternion as a 4x4 matrix

Overloaded operators

q*q2 quaternion (Hamilton) product
s*q elementwise multiplication of quaternion by scalar
q/q2 q*q2.inv
q^n q to power n (integer only)
q+q2 elementwise sum of quaternion elements
q-q2 elementwise difference of quaternion elements
q1==q2 test for quaternion equality
q1~=q2 test for quaternion inequalityq = rx*ry*rz;

Properties (read only)

s real part
v vector part

Notes

References

See also

UnitQuaternion


Quaternion.Quaternion

Construct a quaternion object

Q = Quaternion is a zero quaternion

Q = Quaternion([S V1 V2 V3]) is a quaternion formed by specifying directly its 4 elements

q = Quaternion(s, v) is a quaternion formed from the scalar s and vector part v (1x3)

Notes


Quaternion.char

Convert to string

s = Q.char() is a compact string representation of the quaternion's value as a 4-tuple. If Q is a vector then s has one line per element.


Quaternion.conj

Conjugate of a quaternion

qi = Q.conj() is a quaternion object representing the conjugate of Q.

Notes

See also

Quaternion.inv


Quaternion.display

Display quaternion

Q.display() displays a compact string representation of the quaternion's value as a 4-tuple. If Q is a vector then S has one line per element.

Notes

See also

Quaternion.char


Quaternion.double

Convert a quaternion to a 4-element vector

v = Q.double() is a row vector (1x4) comprising the quaternion elements, scalar then vector. If Q is a vector (1xN) of Quaternion objects then v is a matrix (Nx4) with rows corresponding to the Quaternion elements.

elements [s vx vy vz].


Quaternion.eq

Test quaternion equality

Q1==Q2 is true if the quaternions Q1 and Q2 are equal.

Notes

See also

Quaternion.ne


Quaternion.inner

Quaternion inner product

v = Q1.inner(q2) is the inner (dot) product of two vectors (1x4), comprising the elements of Q1 and q2 respectively.

Notes

See also

Quaternion.norm


Quaternion.inv

Invert a quaternion

qi = Q.inv() is a quaternion object representing the inverse of Q.

Notes

See also

Quaternion.conj


Quaternion.isequal

Test quaternion element equality

ISEQUAL(q1,q2) is true if the quaternions q1 and q2 are equal.

Notes

See also

Quaternion.eq


Quaternion.matrix

Matrix representation of Quaternion

m = Q.matrix() is a matrix (4x4) representation of the Quaternion Q.

Quaternion, or Hamilton, multiplication can be implemented as a matrix-vector product, where the column-vector is the elements of a second quaternion:

matrix(Q1) * double(Q2)'

Notes

See also

Quaternion.double, Quaternion.mtimes


Quaternion.minus

Subtract quaternions

Q1-Q2 is a Quaternion formed from the element-wise difference of quaternion elements.

Q1-V is a Quaternion formed from the element-wise difference of Q1 and the vector V (1x4).

Notes

See also

Quaternion.plus


Quaternion.mpower

Raise quaternion to integer power

QˆN is the Quaternion Q raised to the integer power N.

Notes

See also

Quaternion.mtimes


Quaternion.mrdivide

Quaternion quotient.

Q1/Q2 is a quaternion formed by Hamilton product of Q1 and inv(Q2).
Q/S is the element-wise division of quaternion elements by the scalar S.

Notes

See also

Quaternion.mtimes, Quaternion.mpower, Quaternion.plus, Quaternion.minus


Quaternion.mtimes

Multiply a quaternion object

Q1*Q2 is a quaternion formed by the Hamilton product of two quaternions.
Q*S is the element-wise multiplication of quaternion elements by the scalar S.
S*Q is the element-wise multiplication of quaternion elements by the scalar S.

Notes

See also

Quaternion.mrdivide, Quaternion.mpower


Quaternion.ne

Test quaternion inequality

Q1 ~= Q2 is true if the quaternions Q1 and Q2 are not equal.

Notes

See also

Quaternion.eq


Quaternion.new

Construct a new quaternion

qn = Q.new() constructs a new Quaternion object of the same type as Q.

qn = Q.new([S V1 V2 V3]) as above but specified directly by its 4 elements.

qn = Q.new(s, v) as above but specified directly by the scalar s and vector part v (1x3)

Notes


Quaternion.norm

Quaternion magnitude

qn = q.norm(q) is the scalar norm or magnitude of the quaternion q.

Notes

See also

Quaternion.inner, Quaternion.unit


Quaternion.plus

Add quaternions

Q1+Q2 is a Quaternion formed from the element-wise sum of quaternion elements.

Q1+V is a Quaternion formed from the element-wise sum of Q1 and the vector V (1x4).

Notes

See also

Quaternion.minus


Quaternion.pure

Construct a pure quaternion

q = Quaternion.pure(v) is a pure quaternion formed from the vector v (1x3) and has a zero scalar part.


Quaternion.set.s

Set scalar component

Q.s = S sets the scalar part of the Quaternion object to S.


Quaternion.set.v

Set vector component

Q.v = V sets the vector part of the Quaternion object to V (1x3).


Quaternion.unit

Unitize a quaternion

qu = Q.unit() is a UnitQuaternion object representing the same orientation as Q.

Notes

See also

Quaternion.norm, UnitQuaternion


 

© 1990-2014 Peter Corke.