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 |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
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 |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
3224
|
19 |
3452
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} qtransvmat (@var{qib}) |
|
22 ## Construct a 3x3 transformation matrix from quaternion @var{qib} that |
|
23 ## is equivalent to rotation of th radians about axis @var{vv}, where |
|
24 ## @code{[@var{vv}, @var{th}] = quaternion (@var{qib})}. |
|
25 ## @end deftypefn |
|
26 |
|
27 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
28 ## Adapted-By: jwe |
|
29 |
|
30 function Aib = qtransvmat (qib) |
3224
|
31 |
4030
|
32 if (! isvector(qib) || length (qib) != 4) |
3452
|
33 error ("qtransvmat: q(%d,%d) must be a quaternion", rows (qib), \ |
|
34 columns (qib)); |
|
35 elseif (max (abs (imag (qib))) != 0) |
3458
|
36 error ("qtransvmat: input values must be real"); |
3452
|
37 endif |
|
38 |
4877
|
39 |
|
40 Aib = [(2.*(qib(1)^2 + qib(4)^2) -1.), ... |
|
41 (2.*(qib(1)*qib(2)-qib(3)*qib(4))), ... |
3452
|
42 (2.*(qib(1)*qib(3)+qib(2)*qib(4))); |
4877
|
43 (2.*(qib(1)*qib(2)+qib(3)*qib(4))), ... |
|
44 (2.*(qib(2)*qib(2)+qib(4)*qib(4))-1.), ... |
3452
|
45 (2.*(qib(2)*qib(3)-qib(1)*qib(4))); |
4877
|
46 (2.*(qib(1)*qib(3)-qib(2)*qib(4))), ... |
|
47 (2.*(qib(2)*qib(3)+qib(1)*qib(4))), ... |
3452
|
48 (2.*(qib(3)*qib(3)+qib(4)*qib(4))-1.)]; |
|
49 |
3224
|
50 endfunction |