source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/qtfm/@quaternion/char.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 str = char(q)
2% CHAR Create character array (string).
3% (Quaternion overloading of standard Matlab function.)
4
5% Note: the Matlab char function converts arrays of numeric values into
6% character strings. This is not what this function does, but the Matlab
7% guidance on user-defined classes suggests writing a char function and
8% a disp/display function. This advice has been followed.
9
10% Copyright © 2005 Stephen J. Sangwine and Nicolas Le Bihan.
11% See the file : Copyright.m for further details.
12
13error(nargchk(1, 1, nargin)), error(nargoutchk(0, 1, nargout))
14
15[r, c] = size(q);
16if r > 1 | c > 1
17    error('Argument cannot be a vector or a matrix.')
18end
19
20% There are three cases to be handled.
21% The argument is one of: empty, a pure quaternion, a full quaternion.
22% The format is similar to the built in Matlab format for complex numbers.
23
24if isempty(q)
25    str = '[]';
26elseif ispure(q)
27    str = [                    num2str(x(q)) ' I + ' num2str(y(q)) ' J + ' num2str(z(q)) ' K'];
28else
29    str = [num2str(s(q)) ' + ' num2str(x(q)) ' I + ' num2str(y(q)) ' J + ' num2str(z(q)) ' K'];
30end
31
Note: See TracBrowser for help on using the repository browser.