3452
|
1 ## Copyright (C) 1998 Auburn University. All rights reserved. |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
3452
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
3224
|
18 |
3452
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {} qtransvmat (@var{qib}) |
|
21 ## Construct a 3x3 transformation matrix from quaternion @var{qib} that |
|
22 ## is equivalent to rotation of th radians about axis @var{vv}, where |
|
23 ## @code{[@var{vv}, @var{th}] = quaternion (@var{qib})}. |
|
24 ## @end deftypefn |
|
25 |
|
26 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
27 ## Adapted-By: jwe |
|
28 |
|
29 function Aib = qtransvmat (qib) |
3224
|
30 |
4030
|
31 if (! isvector(qib) || length (qib) != 4) |
3452
|
32 error ("qtransvmat: q(%d,%d) must be a quaternion", rows (qib), \ |
|
33 columns (qib)); |
|
34 elseif (max (abs (imag (qib))) != 0) |
3458
|
35 error ("qtransvmat: input values must be real"); |
3452
|
36 endif |
|
37 |
4877
|
38 |
|
39 Aib = [(2.*(qib(1)^2 + qib(4)^2) -1.), ... |
|
40 (2.*(qib(1)*qib(2)-qib(3)*qib(4))), ... |
3452
|
41 (2.*(qib(1)*qib(3)+qib(2)*qib(4))); |
4877
|
42 (2.*(qib(1)*qib(2)+qib(3)*qib(4))), ... |
|
43 (2.*(qib(2)*qib(2)+qib(4)*qib(4))-1.), ... |
3452
|
44 (2.*(qib(2)*qib(3)-qib(1)*qib(4))); |
4877
|
45 (2.*(qib(1)*qib(3)-qib(2)*qib(4))), ... |
|
46 (2.*(qib(2)*qib(3)+qib(1)*qib(4))), ... |
3452
|
47 (2.*(qib(3)*qib(3)+qib(4)*qib(4))-1.)]; |
|
48 |
3224
|
49 endfunction |