• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

AxisAngle.h

Go to the documentation of this file.
00001 // GMTL is (C) Copyright 2001-2010 by Allen Bierbaum
00002 // Distributed under the GNU Lesser General Public License 2.1 with an
00003 // addendum covering inlined code. (See accompanying files LICENSE and
00004 // LICENSE.addendum or http://www.gnu.org/copyleft/lesser.txt)
00005 
00006 #ifndef _GMTL_AXISANGLE_H_
00007 #define _GMTL_AXISANGLE_H_
00008 
00009 #include <gmtl/Math.h>     // for rotation order
00010 #include <gmtl/VecBase.h>  // base class of AxisAngle
00011 #include <gmtl/Vec.h>      // axis data format
00012  
00013 namespace gmtl
00014 {
00015 
00034 template <typename DATA_TYPE>
00035 class AxisAngle : public VecBase<DATA_TYPE, 4>
00036 {
00037 public:
00038    enum Params { Size = 4 };
00039    
00041    AxisAngle() : 
00042       VecBase<DATA_TYPE, 4>( (DATA_TYPE)0.0, (DATA_TYPE)1.0, 
00043                              (DATA_TYPE)0.0, (DATA_TYPE)0.0 )
00044    {
00045    }
00046    
00048    AxisAngle( const AxisAngle& e ) : VecBase<DATA_TYPE, 4>( e )
00049    {
00050    }
00051    
00053    AxisAngle( const DATA_TYPE& rad_angle, const DATA_TYPE& x, 
00054               const DATA_TYPE& y, const DATA_TYPE& z ) :
00055             VecBase<DATA_TYPE, 4>( rad_angle, x, y, z )
00056    {
00057    }
00058    
00060    AxisAngle( const DATA_TYPE& rad_angle, const Vec<DATA_TYPE, 3>& axis ) :
00061             VecBase<DATA_TYPE, 4>( rad_angle, axis[0], axis[1], axis[2] )
00062    {
00063    }
00064    
00066    void set( const DATA_TYPE& rad_angle, const DATA_TYPE& x, 
00067              const DATA_TYPE& y, const DATA_TYPE& z )
00068    {
00069       VecBase<DATA_TYPE, 4>::set( rad_angle, x, y, z );
00070    }
00071    
00073    void set( const DATA_TYPE& rad_angle, const Vec<DATA_TYPE, 3>& axis )
00074    {
00075       VecBase<DATA_TYPE, 4>::set( rad_angle, axis[0], axis[1], axis[2] );
00076    }
00077    
00082    void setAxis( const Vec<DATA_TYPE, 3>& axis ) 
00083    { 
00084       VecBase<DATA_TYPE, 4>::operator[]( 1 ) = axis[0];
00085       VecBase<DATA_TYPE, 4>::operator[]( 2 ) = axis[1];
00086       VecBase<DATA_TYPE, 4>::operator[]( 3 ) = axis[2];
00087    }
00088    
00093    void setAngle( const DATA_TYPE& rad_angle ) 
00094    {
00095       VecBase<DATA_TYPE, 4>::operator[]( 0 ) = rad_angle;
00096    }
00097    
00101    Vec<DATA_TYPE, 3> getAxis() const 
00102    { 
00103       return Vec<DATA_TYPE, 3>( VecBase<DATA_TYPE, 4>::operator[]( 1 ),
00104                                 VecBase<DATA_TYPE, 4>::operator[]( 2 ),
00105                                 VecBase<DATA_TYPE, 4>::operator[]( 3 ) );
00106    }
00107    
00111    const DATA_TYPE& getAngle() const 
00112    {
00113       return VecBase<DATA_TYPE, 4>::operator[]( 0 );
00114    }
00115 };
00116 
00117 const AxisAngle<float> AXISANGLE_IDENTITYF( 0.0f, 1.0f, 0.0f, 0.0f );
00118 const AxisAngle<double> AXISANGLE_IDENTITYD( 0.0, 1.0, 0.0, 0.0 );
00119 
00120 typedef AxisAngle<float> AxisAnglef;
00121 typedef AxisAngle<double> AxisAngled;
00122 
00123 } // end of namespace gmtl
00124 
00125 #endif

Generated on Sun Sep 19 2010 14:35:14 for GenericMathTemplateLibrary by  doxygen 1.7.1