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

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

Added original make3d

File size: 1.0 KB
Line 
1function n = length(q)
2% LENGTH   Length of vector.
3% (Quaternion overloading of standard Matlab function.)
4
5% Copyright © 2005 Stephen J. Sangwine and Nicolas Le Bihan.
6% See the file : Copyright.m for further details.
7
8% This was written because length appears not to work correctly for arrays
9% of structs, as can be demonstrated by:
10%
11% a.x = randn(5,1), length(a)
12%
13% which gives 1, and
14%
15% a = randn(5,1), length(a)
16%
17% which gives 5, as expected.
18
19error(nargchk(1, 1, nargin)), error(nargoutchk(0, 1, nargout))
20
21if ispure(q)
22    if length(x(q)) ~= length(y(q)) | length(x(q)) ~= length(z(q))
23        error('Sizes within object differ.')
24    end
25else
26    if length(s(q)) ~= length(x(q)) | length(s(q)) ~= length(y(q)) | length(s(q)) ~= length(z(q))
27        error('Sizes within object differ.')
28    end
29end
30
31% In what follows, we use the length of the x component, not the length of the scalar part,
32% since this could be empty. Otherwise the choice is arbitrary, since the code above checks
33% that all components of q have the same length.
34
35n = length(x(q));
Note: See TracBrowser for help on using the repository browser.