SLAMflex SE  0.1.0
SLAMflex provides detection and tracking of dominant planes for smartphone devices. This plane can then be used to show AR content relative to the plane orientation. The detection of plane is performed in the field of view of the smartphone camera. In subsequent frames it is tracked. The interface returns the plane position and orientation.
fadbad.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 
3 // Copyright (C) 2005,2009 Tom Drummond (twd20@cam.ac.uk)
4 //
5 // This file is part of the TooN Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
10 
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19 // USA.
20 
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
29 
30 #ifndef TOON_FADBAD_INTEGATION_H
31 #define TOON_FADBAD_INTEGATION_H
32 
33 #include <iostream>
34 
35 #include "TooN.h"
36 #include "se3.h"
37 #include "se2.h"
38 
39 #include <FADBAD++/fadiff.h>
40 
41 namespace fadbad {
42 
43 template <typename P>
44 inline std::ostream & operator<<( std::ostream & out, const F<P> & val ){
45  return out << val.val();
46 }
47 
48 }
49 
50 namespace TooN {
51 
52 template<class C> struct IsField<fadbad::F<C> >
53 {
54  static const int value = numeric_limits<C>::is_specialized;
55 };
56 
57 template <int N>
58 inline Vector<N, fadbad::F<double> > make_fad_vector( const Vector<N, double> & val, const int start = 0, const int size = N ){
59  using std::min;
60  Vector<N, fadbad::F<double> > result = val;
61  for(int i = start; i < min(size, start+N); ++i)
62  result[i].diff(i,size);
63  return result;
64 }
65 
66 template <int N>
67 inline Vector<N, double> get_derivative( const Vector<N, fadbad::F<double> > & val, const int D ){
69  for(int i = 0; i < N; ++i)
70  r[i] = val[i].deriv(D);
71  return r;
72 }
73 
74 template <int N, int D>
75 inline Matrix<N, D, double> get_jacobian( const Vector<N, fadbad::F<double> > & val ){
76  Matrix<N, D, double> result;
77  for(int i = 0; i < D; ++i)
78  result.T()[i] = get_derivative( val, i );
79  return result;
80 }
81 
82 template <int R, int C>
83 inline Matrix<R, C, double> get_derivative( const Matrix<R,C, fadbad::F<double> > & val, const int D ){
84  Matrix<R, C, double> result;
85  for(int r = 0; r < R; ++r)
86  for(int c = 0; c < C; ++c)
87  result[r][c] = val[r][c].deriv(D);
88  return result;
89 }
90 
93  return SO3<fadbad::F<double> >(p);
94 }
95 
97  const Vector<6, fadbad::F<double> > p = make_fad_vector(makeVector(0.0, 0, 0, 0, 0, 0));
98  return SE3<fadbad::F<double> >(p);
99 }
100 
102  return SE2<fadbad::F<double> >(make_fad_vector(makeVector(0.0, 0, 0)));
103 }
104 
106  fadbad::F<double> r = 0.0;
107  r.diff(0,1) = 1.0;
108  return SO2<fadbad::F<double> >(r);
109 }
110 
112  return make_fad_so3() * r;
113 }
114 
116  return make_fad_se3() * t;
117 }
118 
120  return make_fad_so2() * r;
121 }
122 
124  return make_fad_se2() * t;
125 }
126 
127 }
128 
129 #endif // TOON_FADBAD_INTEGATION_H
130 
SO2< fadbad::F< double > > make_left_fad_so2(const SO2< double > &r)
Definition: fadbad.h:119
Definition: so3.h:39
static const int value
Is C a field?
Definition: TooN.h:103
SE3< fadbad::F< double > > make_left_fad_se3(const SE3< double > &t)
Definition: fadbad.h:115
SO3< fadbad::F< double > > make_left_fad_so3(const SO3< double > &r)
Definition: fadbad.h:111
Matrix< N, D, double > get_jacobian(const Vector< N, fadbad::F< double > > &val)
Definition: fadbad.h:75
Everything lives inside this namespace.
Definition: allocator.hh:48
Definition: se2.h:52
Vector< N, fadbad::F< double > > make_fad_vector(const Vector< N, double > &val, const int start=0, const int size=N)
Definition: fadbad.h:58
Vector< N, double > get_derivative(const Vector< N, fadbad::F< double > > &val, const int D)
Definition: fadbad.h:67
SE2< fadbad::F< double > > make_left_fad_se2(const SE2< double > &t)
Definition: fadbad.h:123
Definition: se3.h:50
SE3< fadbad::F< double > > make_fad_se3()
Definition: fadbad.h:96
SO2< fadbad::F< double > > make_fad_so2()
Definition: fadbad.h:105
SE2< fadbad::F< double > > make_fad_se2()
Definition: fadbad.h:101
Vector< 1 > makeVector(double x1)
Definition: make_vector.hh:4
Definition: fadbad.h:41
Definition: so2.h:39
SO3< fadbad::F< double > > make_fad_so3()
Definition: fadbad.h:91