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

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

Added original make3d

File size: 1.3 KB
Line 
1function r = rdivide(a, b)
2% ./  Right array divide.
3% (Quaternion overloading of standard Matlab function.)
4
5% Copyright © 2005, 2006 Stephen J. Sangwine and Nicolas Le Bihan.
6% See the file : Copyright.m for further details.
7
8error(nargchk(2, 2, nargin)), error(nargoutchk(0, 1, nargout))
9
10% There are three cases to be handled:
11%
12% 1. Left and right arguments are quaternions.
13% 2. The left argument is a quaternion, the right is not.
14% 3. The right argument is a quaternion, the left is not.
15%
16% In fact, cases 1 and 3 can be handled by the same code. Case 2
17% requires different handling.
18
19if isa(b, 'quaternion')
20   
21    % The right argument is a quaternion. We can handle this case by
22    % forming its elementwise inverse and then multiplying. Of course,
23    % if any elements have zero norm, this will result in NaNs.
24     
25    r = a .* b .^ -1; % Changed 24/2/2006 to use .^ -1 instead of inv.
26   
27else
28   
29    % The right argument is not a quaternion. We assume therefore
30    % that if we divide components of the left argument by the right
31    % argument, that Matlab will do the rest. Obviously if the right
32    % argument is zero, there will be a divide by zero error.
33   
34    if ispure(a)
35        r = quaternion(           x(a) ./ b, y(a) ./ b, z(a) ./ b);
36    else
37        r = quaternion(s(a) ./ b, x(a) ./ b, y(a) ./ b, z(a) ./ b);
38    end
39end
Note: See TracBrowser for help on using the repository browser.