1
## Copyright (C) 2002 Etienne Grossmann. All rights reserved.
3
## This program is free software; you can redistribute it and/or modify it
4
## under the terms of the GNU General Public License as published by the
5
## Free Software Foundation; either version 2, or (at your option) any
8
## This is distributed in the hope that it will be useful, but WITHOUT
9
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
## @deftypefn{Function File} {@var{[vstacked, astacked]} = } rotparams ( rstacked )
16
## The function w = rotparams (r) - Inverse to rotv().
17
## Using, @var{w} = rotparams(@var{r}) is such that
18
## rotv(w)*r' == eye(3).
20
## If used as, [v,a]=rotparams(r) , idem, with v (1 x 3) s.t. w == a*v.
22
## 0 <= norm(w)==a <= pi
24
## :-O !! Does not check if 'r' is a rotation matrix.
26
## Ignores matrices with zero rows or with NaNs. (returns 0 for them)
31
## Author: Etienne Grossmann <etienne@cs.uky.edu>
33
function [vstacked, astacked] = rotparams (rstacked)
35
N = size (rstacked,1) / 3;
38
## if length(varargin),
39
## if strcmp(varargin{1},'ang'), ang = 1; end
41
ok = all ( ! isnan (rstacked') ) & any ( rstacked' );
42
ok = min ( reshape (ok,3,N) );
45
vstacked = zeros (N,3);
46
astacked = zeros (N,1);
48
r = rstacked(3*j-2:3*j,:);
52
[m,i] = min (abs (real (f)-1));
59
a = real (acos (u'*r*u));
65
if v'*[0 -u(3) u(2); u(3) 0 -u(1);-u(2) u(1) 0]*x < 0, v=-v; end
68
if nargout <= 1, v = v*a; end