M-File Help: Quaternion | View code for 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 <vx, vy, vz>. 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) < v sin(theta/2)> where v is a unit vector. q =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) |
s | real part |
v | vector part |
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<0,0,0> 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.Return equivalent orthonormal rotation matrix
R = Q.R is the equivalent 3x3 orthonormal rotation matrix. Notes:Return equivalent homogeneous transformationmatrix
T = Q.T is the equivalent 4x4 homogeneous transformation matrix. Notes:Create string representation of quaternion object
s = Q.Display the value of a quaternion object
Q.Quaternion.charConvert a quaternion object to a 4-element vector
v = Q.Interpolate rotations expressed by quaternion objects
qi = Q1.ctraj, Quaternion.scaleInvert a unit-quaternion
qi = Q.Subtract two quaternion objects
Q1-Q2 is the element-wise difference of quaternion elements.Raise quaternion to integer power
Q^N is quaternion Q raised to the integer power N, and computed by repeated multiplication.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 |
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 |
Compute the norm of a quaternion
qn = q.norm or magnitude of the quaternion q.Plot a quaternion object
Q.trplotAdd two quaternion objects
Q1+Q2 is the element-wise sum of quaternion elements.Interpolate rotations expressed by quaternion objects
qi = Q.ctraj, Quaternion.interpUnitize a quaternion
qu = Q.© 1990-2011 Peter Corke.