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

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

Added original make3d

File size: 1.2 KB
Line 
1function B = orthonormal_basis(V, W);
2% ORTHONORMAL_BASIS creates an orthonormal basis from a pure quaternion V,
3% and an optional pure quaternion W, which need not be perpendicular to V,
4% but must not be parallel.
5%
6% The result is represented as a 3 by 3 orthogonal matrix, which may be
7% complex if V and/or W are complex pure quaternions.
8
9% Copyright © 2005 Stephen J. Sangwine and Nicolas Le Bihan.
10% See the file : Copyright.m for further details.
11
12error(nargchk(1, 2, nargin)), error(nargoutchk(0, 1, nargout))
13
14if size(V) ~= [1, 1]
15    error('V must not be a vector or matrix.');
16end
17
18if ~isa(V, 'quaternion') | ~ispure(V)
19    error('V must be a pure quaternion.')
20end
21
22V = unit(V); % Ensure that V is a unit pure quaternion.
23
24if nargin == 1
25    W = orthogonal(V);
26else
27    W = orthogonal(V, W);
28end
29
30X = orthogonal(V, W);
31
32B = [x(V), y(V), z(V); x(W), y(W), z(W); x(X), y(X), z(X)];
33
34% It is possible for the result to be inaccurate, and therefore we check
35% that B is sufficiently orthogonal before returning. Error is particularly
36% likely in the complex case if V and/or W is not defined accurately.
37% (See the discussion note in the function unit.m.)
38
39if norm(B * B.' - eye(3)) > 5.*eps
40    warning('The basis matrix is not accurately orthogonal.');
41end
Note: See TracBrowser for help on using the repository browser.