Quaternions (The Class quaternion)

class representing orientations

On this page ...
Class Description
Defining three dimensional vectors
Calculating with three dimensional vectors
Conversion
Plotting quaternions
Complete Function list

Class Description

The class quaternion allows to work with rotations in MTEX, as they occur e.g. as crystal orientation or symmetries. Quaternions may be multiplied with three dimensional vecotors which means rotating the vector or may by multiplied with another quaternion which means to concatenate both rotations.

Defining three dimensional vectors

The standard way is to define a quaternion q is to give its coordinates (a,b,c,d). However making use of one of the following conversion methods is much more human readable.

q = quaternion(a,b,c,d)          % by coordinates
q = axis2quat(axis,angle);       % by rotational axis and rotational angle
q = euler2quat(alpha,beta,gamma) % by Euler angles
q = Miller2quat([h k l],[u v w],symmetry); % by Miller indece
q = idquaternion;                % identical quaternion
q = vec42quat(u1,v1,u2,v2);      % by four vectors

Additional methods to define a rotation are hr2quat and vec42quat. Using the brackets q = [q1,q2] two quaternions can be concatened. Now each single quaternion is accesable via q(1) and q(2).

Calculating with three dimensional vectors

Beside the standard linear algebra operations there are also the following functions available in MTEX.

angle(q); % rotational angle
axis(q);  % rotational axis
inverse(q);  % inverse rotation

Conversion

There are methods to transform quaternion in almost any other parameterization of rotations as they are:

Euler(q)     % in Euler angle
Rodrigues(q) % in Rodrigues parameter

Plotting quaternions

The plot function allows you to visualize an quaternion by plotting how the standard basis x,y,z transforms under the rotation.

plot(Miller2quat([-1 -1 -1],[1 -2 1]))

Complete Function list

Eulerquaternion to euler angle
Rodriguesquaternion to rodrigues representation
anglecalcualtes the rotational angle between rotations q1 and q2
angle_outercalcualtes the rotational angle between all rotations q1 and q2
axisrotational axis of the quaternion
calcVoronoicompute the the Voronoi decomposition for unit quaternions
charquaternion to char
crosspointwise cross product of three quaternions
ctransposetranspose quaternion
displaystandart output
dotinner product of quaternions g1 and g2
dot_anglecompute minimum q1 . q2 modulo rotation about zaxis and angle omega
dot_outerouter inner product between two quaternions
doublequaternion to double
endoverloads end function
eq? q1 == q2
exportquaternions to a ascii file
findreturn indece and distance of all nodes within a eps neighborhood
horzcatimplements [q1,q2,q3..]
invquaternion of the inverse roation
isemptyoverloads isempty
lengthoverloads length
matrixquaternion to direction cosine matrix conversion
meanof a list of quaternions, principle axes and moments of inertia
mean_CSfast mean of
minusoverloads minus
mpowerq^n
mrdividescalar division
mtimesquaternionen multiplication q1 * q2
ndimsoverloads ndims
neq1 ~= q2 ?
normquaternion norm sqrt(a^2+b^2+c^2+c^2)
normalizequaternion
permuteoverloads permute
pertubedata randomly by epsilon
perturbepertube data randomly by epsilon
pluspointwise addition
powerq.^n
prodoverloads q1 * q2 * q3
project2EulerFRprojects quaternions to a fundamental region
project2FundamentalRegionprojects quaternions to a fundamental region
qmatrixreturns the quaternion multiplication matrix
qqreturns w * q' * q
rdividescalar division
realpart of of quaternion
repmatoverloads repmat
reshapeoverloads reshape
scatterplot function
setSubSetindexing of quaternions
sizeoverloads size
subSetindexing of quaternions
subsasgnoverloads subsasgn
subsrefoverloads subsref
sumoverloads sum
symmetrisesymmetrcially equivalent orientations
timesimplements quaternion .* quaternion and quaternion .* vector3d
transposearray of quaternions
uminusoverload unitary minus
uniquedisjoint list of quaternions
vertcatimplements [q1;q2;q3..]