~ubuntu-branches/ubuntu/wily/octave-miscellaneous/wily

« back to all changes in this revision

Viewing changes to inst/rotparams.m

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot, Rafael Laboissiere, Sébastien Villemot
  • Date: 2012-10-17 13:40:55 UTC
  • mfrom: (1.2.1) (12 sid)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: package-import@ubuntu.com-20121017134055-vatltexghy77fnv7
Tags: 1.2.0-1
[ Rafael Laboissiere ]
* Imported Upstream version 1.2.0
* Bump Standards-Version to 3.9.4 (no changes needed)
* Refresh for new upstream release
* Use Sébastien Villemot's @debian.org email address
* Remove obsolete DM-Upload-Allowed flag
* Add patch autoload-yes.patch
* Add copyright info for file lauchli.m (included in a Debian patch)
* Add patch partcnt-test-succeeds.patch
* Build-depends on octave-pkg-dev >= 1.0.3

[ Sébastien Villemot ]
* debian/control: fix versioned dependency on debhelper
* Add lintian override for false positive on hardening (fortify)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
## Copyright (C) 2002 Etienne Grossmann.  All rights reserved.
2
 
##
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
6
 
## later version.
7
 
##
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
11
 
## for more details.
12
 
 
13
 
## -*- texinfo -*-
14
 
## @deftypefn{Function File} {@var{[vstacked, astacked]} = } rotparams ( rstacked ) 
15
 
## @cindex  
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). 
19
 
##
20
 
##  If used as, [v,a]=rotparams(r) ,  idem, with v (1 x 3) s.t. w == a*v.
21
 
## 
22
 
##     0 <= norm(w)==a <= pi
23
 
## 
24
 
##     :-O !!  Does not check if 'r' is a rotation matrix.
25
 
##
26
 
##  Ignores matrices with zero rows or with NaNs. (returns 0 for them)
27
 
##
28
 
## @seealso{rotv}
29
 
## @end deftypefn
30
 
 
31
 
## Author:        Etienne Grossmann <etienne@cs.uky.edu>
32
 
 
33
 
function [vstacked, astacked] = rotparams (rstacked)
34
 
 
35
 
N = size (rstacked,1) / 3;
36
 
 
37
 
## ang = 0 ;
38
 
## if length(varargin),
39
 
##   if strcmp(varargin{1},'ang'),    ang = 1;  end
40
 
## end
41
 
ok = all ( ! isnan (rstacked') ) & any ( rstacked' );
42
 
ok = min ( reshape (ok,3,N) );
43
 
ok = find (ok) ;
44
 
## keyboard
45
 
vstacked = zeros (N,3);
46
 
astacked = zeros (N,1);
47
 
for j = ok,
48
 
  r = rstacked(3*j-2:3*j,:);
49
 
  [v,f] = eig (r); 
50
 
  f = diag(f);
51
 
 
52
 
  [m,i] = min (abs (real (f)-1));
53
 
  v = v(:,i);
54
 
 
55
 
  w = null (v');
56
 
  u = w(:,1);
57
 
  a = u'*r*u;
58
 
  if a<1,
59
 
    a = real (acos (u'*r*u));
60
 
  else
61
 
    a = 0;
62
 
  end
63
 
  ## Check orientation
64
 
  x=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 
66
 
 
67
 
 
68
 
  if nargout <= 1,   v = v*a; end
69
 
  vstacked(j,:) = -v';
70
 
  astacked(j) = a;
71
 
end