1 | % Quaternion Toolbox |
---|
2 | % Version 1.0 14-December-2006 |
---|
3 | % --------------------------------------------------------------------- |
---|
4 | % Copyright © 2005-6 Stephen J. Sangwine (S.Sangwine@IEEE.org) |
---|
5 | % Nicolas Le Bihan (nicolas.le-bihan@lis.inpg.fr) |
---|
6 | % See the file Copyright.m for further details. |
---|
7 | % --------------------------------------------------------------------- |
---|
8 | % |
---|
9 | % quaternion is a Matlab class library designed to extend Matlab in as |
---|
10 | % natural a way as possible to handle quaternions. Many standard Matlab |
---|
11 | % features have been implemented, including standard operators such as |
---|
12 | % the arithmetic operators, matrix and elementwise products, indexing |
---|
13 | % and indexed assignment using the colon operator, concatenation, end |
---|
14 | % indexing, transpose and conjugate transpose, raising to a power, etc. |
---|
15 | % |
---|
16 | % A major objective has been to make it possible to write code that can |
---|
17 | % work unchanged for real, complex, quaternion, and even complexified |
---|
18 | % quaternion arrays, and for this reason standard Matlab functions have |
---|
19 | % been overloaded for quaternion arrays. |
---|
20 | % |
---|
21 | % A quaternion object, as implemented by this class, has a private |
---|
22 | % implementation based on a structure array storing the four components |
---|
23 | % of the quaternion. As with any standard Matlab type, a quaternion is by |
---|
24 | % default a matrix. A single quaternion is simply a matrix of one element. |
---|
25 | % |
---|
26 | % Quaternions may be pure or full. Pure quaternions have no scalar part |
---|
27 | % and operations that attempt to access the scalar part will result in an |
---|
28 | % error. The quaternions in a vector or matrix are either all pure or all |
---|
29 | % full -- it is not possible to construct a vector or matrix with a mix |
---|
30 | % of the two. A full quaternion with a scalar part which is zero differs |
---|
31 | % from a pure quaternion, which has no scalar part. |
---|
32 | % |
---|
33 | % Quaternion matrices can be constructed either by using a constructor |
---|
34 | % function, like this: |
---|
35 | % |
---|
36 | % q = quaternion(eye(5,5), zeros(5,5), randn(5,5), ones(5,5)) |
---|
37 | % |
---|
38 | % or by using the three quaternion operators, named q1, q2 and q3, (these |
---|
39 | % three operators are also available under the names qi, qj and qk) like this: |
---|
40 | % |
---|
41 | % q = eye(5,5) + zeros(5,5) * q1 + randn(5,5) * q2 + ones(5,5) * q3 |
---|
42 | % |
---|
43 | % The components of the quaternion so constructed will have a type determined |
---|
44 | % by the type supplied for the components (e.g. double, uint8, int16 ....). |
---|
45 | % The components may be REAL or COMPLEX. A complex quaternion can also be |
---|
46 | % constructed like this: |
---|
47 | % |
---|
48 | % q = complex(quaternion(1,2,3,4), 3) |
---|
49 | % |
---|
50 | % or using the Matlab value i: |
---|
51 | % |
---|
52 | % q = quaternion(1,2,3,4) + quaternion(5,6,7,8) .* i |
---|
53 | % |
---|
54 | % The components of a quaternion can be extracted using the five functions: |
---|
55 | % |
---|
56 | % scalar - Scalar part of a quaternion. |
---|
57 | % vector, v - Vector part of a quaternion (synonyms). |
---|
58 | % s, x, y, z - Components of a quaternion. |
---|
59 | % |
---|
60 | % real - Real part of a (complex) quaternion. |
---|
61 | % imag - Imaginary part of a (complex) quaternion. |
---|
62 | % complex - Construct a complex quaternion from real quaternions. |
---|
63 | % quaternion - Construct a quaternion from real or complex values. |
---|
64 | % |
---|
65 | % Other functions implemented are: |
---|
66 | % |
---|
67 | % abs - Modulus of a quaternion. |
---|
68 | % conj - Conjugate (quaternion, complex or total). |
---|
69 | % unit - Normalise a quaternion. |
---|
70 | % sign - Equivalent to unit, cf Matlab sign.m. |
---|
71 | % inv - Matrix and quaternion inverse. |
---|
72 | % axis - Axis of a quaternion. |
---|
73 | % angle - Angle or argument of a quaternion. |
---|
74 | % |
---|
75 | % ceil, floor - Round elements of quaternion towards plus or minus |
---|
76 | % fix, round infinity, zero, or nearest integer. |
---|
77 | % |
---|
78 | % display - Display array (does not show values) |
---|
79 | % disp - Display without array name. |
---|
80 | % displayall - Display components of quaternion. |
---|
81 | % show - Shorter synonym for displayall. |
---|
82 | % char - Convert quaternion to string. |
---|
83 | % fprintf - Output quaternions to file. |
---|
84 | % write - Write a quaternion array to a text file. |
---|
85 | % read - Read a quaternion array from a text file. |
---|
86 | % |
---|
87 | % convert - Convert components of quaternion to a different type. |
---|
88 | % |
---|
89 | % dot - Dot product. |
---|
90 | % cross - Vector product. |
---|
91 | % |
---|
92 | % exp - Exponential function. |
---|
93 | % log - Natural logarithm. |
---|
94 | % |
---|
95 | % sqrt - Square root. |
---|
96 | % |
---|
97 | % sin, cos, tan - Trigonometric functions. |
---|
98 | % asin, acos, |
---|
99 | % atan - Inverse trigonometric functions. |
---|
100 | % sinh, cosh, |
---|
101 | % tanh - Hyperbolic functions. |
---|
102 | % asinh, acosh, |
---|
103 | % atanh - Inverse hyperbolic functions. |
---|
104 | % |
---|
105 | % diag - Extract or construct a diagonal. |
---|
106 | % triu/tril - Extract upper or lower triangular. |
---|
107 | % norm - Vector and matrix norms. |
---|
108 | % sum - Sum elements or columns. |
---|
109 | % mean - Mean of elements or columns. |
---|
110 | % |
---|
111 | % ispure - Test whether a quaternion (array) is pure. |
---|
112 | % isempty - Test whether a quaternion (array) is empty. |
---|
113 | % isfinite - Test whether a quaternion (array) is finite. |
---|
114 | % isinf - Test whether a quaternion (array) is infinite. |
---|
115 | % isnan - Test whether a quaternion (array) is NaN. |
---|
116 | % isreal - Test whether a quaternion (array) is real. |
---|
117 | % ishermitian - Test whether a quaternion (array) is Hermitian. |
---|
118 | % isunitary - Test whether a quaternion (array) is unitary. |
---|
119 | % |
---|
120 | % length - Length of a quaternion vector. |
---|
121 | % size - Size of a quaternion array. |
---|
122 | % numel - Number of elements in a quaternion array. |
---|
123 | % repmat - Replicate and tile a quaternion array. |
---|
124 | % cat - Concatenate arrays. |
---|
125 | % |
---|
126 | % det - Determinant. |
---|
127 | % svd - Singular value decomposition. |
---|
128 | % eig - Eigenvalue decomposition. |
---|
129 | % |
---|
130 | % adjoint - The complex adjoint of a quaternion array. |
---|
131 | % unadjoint - Construct a quaternion array from an adjoint array. |
---|
132 | % |
---|
133 | % conv, conv2 - Convolution. |
---|
134 | % |
---|
135 | % fft - One dimensional (default) quaternion Fourier transform. |
---|
136 | % fft2 - Two dimensional (default) quaternion Fourier transform. |
---|
137 | % qfft - One dimensional left or right one-dimensional QFFT. |
---|
138 | % qdft - One dimensional left or right one-dimensional QDFT. |
---|
139 | % qfft2 - Two dimensional left or right two-dimensional QFFT. |
---|
140 | % qdft2 - Two dimensional left or right two-dimensional QDFT. |
---|
141 | % fftshift - Quaternion overloading of the standard Matlab function. |
---|
142 | % ............. - All of the above have inverses, prefixed with 'i'. |
---|
143 | % |
---|
144 | % The following builtin Matlab functions also work for quaternion arrays: |
---|
145 | % |
---|
146 | % flipud, fliplr, rot90, ndims, trace, isequal, isvector |
---|
147 | % |
---|
148 | % The following Matlab functions also work for quaternion arrays: |
---|
149 | % |
---|
150 | % cov, princomp, rank, var (there may be others) |
---|
151 | % |
---|
152 | % The following function is not yet usable: reshape. |
---|
153 | % |
---|
154 | % There are some auxiliary functions which are used to compute some of the |
---|
155 | % more elaborate functions above, such as svd, eig and qdft. These are: |
---|
156 | % |
---|
157 | % change_basis, orthonormal_basis, orthogonal. |
---|
158 | % householder_vector, householder_matrix, bidiagonalize, tridiagonalize. |
---|
159 | % |
---|
160 | % Some test code is provided in the directory 'test'. To run it set the |
---|
161 | % working directory to 'test' and type 'test'. This runs all the test |
---|
162 | % code. |
---|
163 | % |
---|
164 | % For more information, use help. |
---|