M-File Help: Quaternion View code for Quaternion

Quaternion

Quaternion class

A quaternion is a compact method of representing a 3D rotation that has computational advantages including speed and numerical robustness. A quaternion has 2 parts, a scalar s, and a vector v and is typically written: q = s &lt;vx, vy, vz&gt;. A unit quaternion is one for which s^2+vx^2+vy^2+vz^2 = 1. It can be considered as a rotation about a vector in space where q = cos (theta/2) &lt; v sin(theta/2)&gt; where v is a unit vector. q = inv return inverse of quaterion norm return norm of quaternion unit return unit quaternion unitize unitize this quaternion plot same options as trplot() interp interpolation (slerp) between q and q2, 0<=s<=1 scale interpolation (slerp) between identity and q, 0<=s<=1 dot derivative of quaternion with angular velocity w R 3x3 rotation matrix T 4x4 homogeneous transform matrix

Arithmetic operators are overloaded

q+q2 return elementwise sum of quaternions
q-q2 return elementwise difference of quaternions
q*q2 return quaternion product
q*v rotate vector by quaternion, v is 3x1
q/q2 return q*q2.inv
q^n return q to power n (integer only)

Properties (read only)

s real part
v vector part

Notes

See also

trinterp, trplot


Quaternion.Quaternion

Constructor for quaternion objects

q = Quaternion(q1) is a copy of the quaternion q1 q = Quaternion(s) is a quaternion formed from the scalar s and zero vector part: s&lt;0,0,0&gt; q = Quaternion(th, v) is a unit quaternion corresponding to rotation of th about the vector v. q = Quaternion(T) is a unit quaternion equivalent to the rotational part of the homogeneous transform T.

Notes


Quaternion.R

Return equivalent orthonormal rotation matrix

R = Q.R is the equivalent 3x3 orthonormal rotation matrix. Notes:

Quaternion.T

Return equivalent homogeneous transformationmatrix

T = Q.T is the equivalent 4x4 homogeneous transformation matrix. Notes:

Quaternion.char

Create string representation of quaternion object

s = Q.

Quaternion.display

Display the value of a quaternion object

Q.Quaternion.char


Quaternion.double

Convert a quaternion object to a 4-element vector

v = Q.

Quaternion.interp

Interpolate rotations expressed by quaternion objects

qi = Q1.ctraj, Quaternion.scale


Quaternion.inv

Invert a unit-quaternion

qi = Q.

Quaternion.minus

Subtract two quaternion objects

Q1-Q2 is the element-wise difference of quaternion elements.

Quaternion.mpower

Raise quaternion to integer power

Q^N is quaternion Q raised to the integer power N, and computed by repeated multiplication.

Quaternion.mrdivide

Compute 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 by the scalar S

Quaternion.mtimes

Multiply a quaternion object

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

Quaternion.norm

Compute the norm of a quaternion

qn = q.norm or magnitude of the quaternion q.

Quaternion.plot

Plot a quaternion object

Q.trplot


Quaternion.plus

Add two quaternion objects

Q1+Q2 is the element-wise sum of quaternion elements.

Quaternion.scale

Interpolate rotations expressed by quaternion objects

qi = Q.ctraj, Quaternion.interp


Quaternion.unit

Unitize a quaternion

qu = Q.  

© 1990-2011 Peter Corke.