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

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

Added original make3d

File size: 1.9 KB
Line 
1function r = eq(a, b)
2% ==  Equal.
3% (Quaternion overloading of standard Matlab function.)
4%
5% If one of the operands is not a quaternion and the other has zero vector part,
6% the result is obtained by comparing the non-quaternion operand with the scalar
7% part of the quaternion operand.
8
9% Copyright © 2005 Stephen J. Sangwine and Nicolas Le Bihan.
10% See the file : Copyright.m for further details.
11
12error(nargchk(2, 2, nargin)), error(nargoutchk(0, 1, nargout))
13
14if isa(a, 'quaternion') & isa(b, 'quaternion')
15   
16    if ispure(a) & ispure(b)
17        r = x(a) == x(b) & y(a) == y(b) & z(a) == z(b);
18    elseif ispure(a)
19        % a is pure, but b isn't, so they can only be equal if the
20        % scalar part of b is zero and the vector parts are equal.
21       
22        r = s(b) == 0 & v(a) == v(b);
23    elseif ispure(b)
24        % b is pure, but a isn't, so they can only be equal if the
25        % scalar part of a is zero and the vector parts are equal.
26       
27        r = s(a) == 0 & v(a) == v(b);
28    else
29        r = s(a) == s(b) & v(a) == v(b);
30    end
31   
32else
33    % One of the arguments is not a quaternion (the other must be,
34    % otherwise Matlab would not call this function).
35   
36    if isa(a, 'quaternion')
37        if ispure(a)
38            % a has no scalar part, and b has no vector part, since it is not
39            % a quaternion. The result can only be true if b is zero, and a
40            % has zero vector part.
41           
42            r = b == 0 & a == quaternion(0, 0, 0);
43        else
44            % a is a full quaternion, so the result can be true only if a has
45            % zero vector part, and b is equal to the scalar part of a.
46           
47            r = s(a) == b & v(a) == quaternion(0, 0, 0);
48        end
49    elseif isa(b, 'quaternion')
50        r = b == a; % Swap the order and compare them using the code above.
51    else
52        error('Programming error: neither argument is a quaternion?');   
53    end
54end
Note: See TracBrowser for help on using the repository browser.