Rev | Line | |
---|
[37] | 1 | function y = axis(x) |
---|
| 2 | % AXIS Axis of quaternion. |
---|
| 3 | % If Q = A + mu .* B where A and B are real/complex, and mu is a unit pure |
---|
| 4 | % quaternion, then axis(Q) = mu. |
---|
| 5 | |
---|
| 6 | % Copyright © 2005 Stephen J. Sangwine and Nicolas Le Bihan. |
---|
| 7 | % See the file : Copyright.m for further details. |
---|
| 8 | |
---|
| 9 | error(nargchk(1, 1, nargin)), error(nargoutchk(0, 1, nargout)) |
---|
| 10 | |
---|
| 11 | % In the warning check that follows, abs is used twice in order to handle |
---|
| 12 | % complexified quaternions with a complex modulus. |
---|
| 13 | |
---|
| 14 | if any(abs(abs(v(x))) < eps) |
---|
| 15 | warning('At least one element may have an undefined axis.'); |
---|
| 16 | end |
---|
| 17 | |
---|
| 18 | % Make a unit version of x before taking the vector part. This is essential |
---|
| 19 | % in the case where x is a complex quaternion, but has no effect when x is |
---|
| 20 | % a real quaternion. SJS 20 September 2005. |
---|
| 21 | |
---|
| 22 | y = unit(v(unit(x))); |
---|
Note: See
TracBrowser
for help on using the repository browser.