Rev | Line | |
---|
[37] | 1 | function z = isocomplex(q) |
---|
| 2 | % Construct a complex number from a quaternion, with the same modulus and |
---|
| 3 | % argument as those of the quaternion. |
---|
| 4 | |
---|
| 5 | % Copyright © 2006 Stephen J. Sangwine and Nicolas Le Bihan. |
---|
| 6 | % See the file : Copyright.m for further details. |
---|
| 7 | |
---|
| 8 | error(nargchk(1, 1, nargin)), error(nargoutchk(0, 1, nargout)) |
---|
| 9 | |
---|
| 10 | % First extract the scalar part and the modulus of the vector part of the |
---|
| 11 | % quaternion array q. |
---|
| 12 | |
---|
| 13 | s = scalar(q); |
---|
| 14 | v = abs(vector(q)); |
---|
| 15 | |
---|
| 16 | % Either of both of s and v may be complex, in which case we cannot create |
---|
| 17 | % an isomorphic complex number. |
---|
| 18 | |
---|
| 19 | if isreal(s) & isreal(v) |
---|
| 20 | z = complex(s, v); |
---|
| 21 | else |
---|
| 22 | error('Private function isocomplex called with complex quaternion argument') |
---|
| 23 | end; |
---|
| 24 | |
---|
| 25 | % Notes: the result will always have an argument in the range 0 to pi. |
---|
Note: See
TracBrowser
for help on using the repository browser.