Documentation


basicFrames.inl

Go to the documentation of this file.
00001 #ifndef animal_frame_inl______________________________
00002 #define animal_frame_inl______________________________
00003 
00004 #include <animal/linear.h>
00005 #include <animal/quaternion.h>
00006 
00007 namespace animal
00008 {
00009 
00010 //======================= Bases ==================================
00011 
00015 template<class Vec1, class Basis, class Vec2>
00016 void v_eq_project_vec( Vec1& v, const Basis& b, const Vec2& a )
00017 {
00018     v_eq_Ab(v,b,a);
00019 }
00020 
00024 template<class Basis1, class Basis2>
00025 void b_eq_inverse( Basis1& b, const Basis2& a )
00026 {
00027     m_eq_luinv(a);
00028 }
00029 
00032 template<class Basis,class Real>
00033 void b_eq_eulerX( Basis& b, Real a )
00034 {
00035     b[0][0] = 1;
00036     b[1][0] = 0;
00037     b[2][0] = 0;
00038     b[0][1] = 0;
00039     b[1][1] = cos(a);
00040     b[2][1] = -sin(a);
00041     b[0][2] = 0;
00042     b[1][2] = sin(a);
00043     b[2][2] = cos(a);
00044 }
00045 
00048 template<class Basis,class Real>
00049 void b_eq_eulerY( Basis& b, Real a )
00050 {
00051     b[0][0] = -sin(a);
00052     b[1][0] = 0;
00053     b[2][0] = cos(a);
00054     b[0][1] = 0;
00055     b[1][1] = 1;
00056     b[2][1] = 0;
00057     b[0][2] = cos(a);
00058     b[1][2] = 0
00059     b[2][2] = sin(a);
00060 }
00061 
00064 template<class Basis,class Real>
00065 void b_eq_eulerZ( Basis& b, Real a )
00066 {
00067     b[0][0] = cos(a);
00068     b[1][0] = sin(a);
00069     b[2][0] = 0;
00070     b[0][1] = -sin(a);
00071     b[1][1] = cos(a);
00072     b[2][1] = 0;
00073     b[0][2] = 0;
00074     b[1][2] = 0
00075     b[2][2] = 1;
00076 }
00077 
00078 
00082 template<class Basis,class Real>
00083 void b_eq_eulerXYZ( Basis& b, Real a, Real b, Real c )
00084 {
00085     b_eq_eulerX(b,a);     
00086     // b == Mx
00087     Array< 3, Array <3, Real > > aux;  // auxiliary matrix
00088     b_eq_eulerY(aux,a);
00089     m_eq_AB( b, b, aux );  
00090     // b==MxMy
00091     b_eq_eulerZ(aux,c);
00092     m_eq_AB( b, b, aux );
00093     // b==MxMyMz    
00094 }
00095 
00096 /* TODO: 
00097 
00098 template<class Real, class Basis>
00099 void getEulerXYZ( Real& a, Real& b, Real& c, const Basis&b );
00100 
00101 template<class Real, class Basis>
00102 void b_eq_rotationAxisAngle( Basis& b, Real ax, Real ay, Real az, Real angle );
00103 
00104 template<class Real, class Basis>
00105 void getRotationAxisAngle( Real& ax, Real& ay, Real& az, Real& angle, const Basis& b);
00106 
00107 template<class Quaternion, class Basis>
00108 void getQuaternion( Quaternion& q, const Basis& b );
00109 
00110 template<class Quaternion, class Basis>
00111 void b_eq_quaternion( Basis& b, const Quaternion& q );
00112 */
00113 
00114 //======================= Frames ==================================
00115 
00116 
00117 /* Project point a from frame f to another frame.
00118 f (typically a basis and a translation vector) defines the reference frame of point a with respect to the other reference frame.
00119 \sa{f_eq_inverse}
00120 */
00121 template<class Vec1, class Frame, class Vec2>
00122 void v_eq_project_point( Vec1& v, const Frame& f, const Vec2& a )
00123 {
00124     v_eq_Ab( v, get_basis(f), a );
00125     v_peq( v, get_translation(f) );
00126 }
00127 
00128 /* Compute inverse of frame transform a and stores it in f. 
00129 Frame f can then be used to project points to frame a.
00130 \pre{ a must not be singular }
00131 \sa{v_eq_project_point}
00132 */
00133 template<class Frame>
00134 void f_eq_inverse( Frame& f, const Frame& a )
00135 {
00136     b_eq_inverse( set_basis(f), get_basis(a) );
00137     v_eq_Ab( set_translation(f), get_translation(a) );
00138     v_teq( set_translation(f), -1.0 ); 
00139 }
00140 
00141 
00142 
00143 
00144 
00145 //======================= default Frame class =============================
00148 template<class Basis_, class Vec_>
00149 struct Frame
00150 {
00151     typedef Basis_ Basis; 
00152     typedef Vec_ Vec;     
00153     
00155     Frame(){}
00156     
00158     Frame( const Basis& b, const Vec& t )
00159         : basis(b)
00160         , displacement(t)
00161     {}
00162 
00163     Basis basis; 
00164     Vec displacement; 
00165 };
00166 
00168 template<class Basis, class Vec>
00169 const Vec& get_translation( const Frame<Basis,Vec>& f )
00170 { return t.displacement; }
00171  
00173 template<class Basis, class Vec>
00174 Vec& set_translation( Frame<Basis,Vec>& f )
00175 { return t.displacement; }
00176  
00178 template<class Basis, class Vec>
00179 const Basis& get_basis( const Frame<Basis,Vec>& f )
00180 { return t.basis; }
00181  
00183 template<class Basis, class Vec>
00184 Basis& set_basis( Frame<Basis,Vec>& f )
00185 { return t.basis; }
00186  
00187 
00188 
00189 }// animal
00190 
00191 
00192 
00193 
00194 #endif

Generated on Thu Dec 23 13:52:23 2004 by doxygen 1.3.6