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

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

Added original make3d

File size: 982 bytes
Line 
1function d = dot(a, b)
2% DOT  Quaternion dot product.
3% The dot (scalar) product of two quaternions is the sum of the products of
4% the (s, x, y, z) components of the two quaternions.
5
6% Copyright © 2005 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') | ~isa(b, 'quaternion')
12    error('Dot product is not defined for a quaternion and a non-quaternion.')
13end
14
15% This function is defined for full and pure quaternions, and combinations
16% of full and pure, in which case we assume a zero scalar part for the pure
17% argument.
18
19if ispure(a) | ispure(b)
20    % This covers the case where either or both are pure. We can ignore the
21    % scalar part of the other, since it is implicitly multiplied by zero.
22   
23    d =                x(a) .* x(b) + y(a) .* y(b) + z(a) .* z(b);
24else
25    d = s(a) .* s(b) + x(a) .* x(b) + y(a) .* y(b) + z(a) .* z(b);
26end
Note: See TracBrowser for help on using the repository browser.