source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/qtfm/@quaternion/private/isoquaternion.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 1.1 KB
Line 
1function q = isoquaternion(z, a)
2% Construct a quaternion from a complex number, preserving the modulus and
3% argument, and using the axis of the second argument as the axis of the
4% result.
5
6% Copyright © 2006 Stephen J. Sangwine and Nicolas Le Bihan.
7% See the file : Copyright.m for further details.
8
9error(nargchk(2, 2, nargin)), error(nargoutchk(0, 1, nargout))
10
11if ~isa(a, 'quaternion')
12    error('Second argument must be a quaternion.')
13end;
14
15if isa(z,'quaternion')
16    error('First argument must not be a quaternion.')
17end;
18
19if isreal(z)
20    % The imaginary part of z is zero, therefore so must be the vector part
21    % of the result. We use special code for this case to avoid calling the
22    % axis function, because axis(a) is almost certainly undefined.
23   
24    q = quaternion(real(z), 0, 0, 0);
25else
26    q = quaternion(real(z), imag(z) .* axis(a));
27end;
28
29% Note: the complex argument z may be in any of the four quadrants of the
30% plane, and so may the quaternion result. This means that if the axis is
31% extracted from the quaternion result, it may point in the opposite
32% direction to the axis of the second argument, a.
Note: See TracBrowser for help on using the repository browser.