Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

AxisAngle.h

Go to the documentation of this file.
00001 /************************************************************** ggt-head beg
00002  *
00003  * GGT: Generic Graphics Toolkit
00004  *
00005  * Original Authors:
00006  *   Allen Bierbaum
00007  *
00008  * -----------------------------------------------------------------
00009  * File:          $RCSfile: AxisAngle.h,v $
00010  * Date modified: $Date: 2003/03/30 00:56:58 $
00011  * Version:       $Revision: 1.4 $
00012  * -----------------------------------------------------------------
00013  *
00014  *********************************************************** ggt-head end */
00015 /*************************************************************** ggt-cpr beg
00016 *
00017 * GGT: The Generic Graphics Toolkit
00018 * Copyright (C) 2001,2002 Allen Bierbaum
00019 *
00020 * This library is free software; you can redistribute it and/or
00021 * modify it under the terms of the GNU Lesser General Public
00022 * License as published by the Free Software Foundation; either
00023 * version 2.1 of the License, or (at your option) any later version.
00024 *
00025 * This library is distributed in the hope that it will be useful,
00026 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00027 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00028 * Lesser General Public License for more details.
00029 *
00030 * You should have received a copy of the GNU Lesser General Public
00031 * License along with this library; if not, write to the Free Software
00032 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00033 *
00034  ************************************************************ ggt-cpr end */
00035 #ifndef _GMTL_AXISANGLE_H_
00036 #define _GMTL_AXISANGLE_H_
00037 
00038 #include <gmtl/Math.h>     // for rotation order
00039 #include <gmtl/VecBase.h>  // base class of AxisAngle
00040 #include <gmtl/Vec.h>      // axis data format
00041  
00042 namespace gmtl
00043 {
00044 
00063 template <typename DATA_TYPE>
00064 class AxisAngle : public VecBase<DATA_TYPE, 4>
00065 {
00066 public:
00067    enum Params { Size = 4 };
00068    
00070    AxisAngle() : 
00071       VecBase<DATA_TYPE, 4>( (DATA_TYPE)0.0, (DATA_TYPE)1.0, 
00072                              (DATA_TYPE)0.0, (DATA_TYPE)0.0 )
00073    {
00074    }
00075    
00077    AxisAngle( const AxisAngle& e ) : VecBase<DATA_TYPE, 4>( e )
00078    {
00079    }
00080    
00082    AxisAngle( const DATA_TYPE& rad_angle, const DATA_TYPE& x, 
00083               const DATA_TYPE& y, const DATA_TYPE& z ) :
00084             VecBase<DATA_TYPE, 4>( rad_angle, x, y, z )
00085    {
00086    }
00087    
00089    AxisAngle( const DATA_TYPE& rad_angle, const Vec<DATA_TYPE, 3>& axis ) :
00090             VecBase<DATA_TYPE, 4>( rad_angle, axis[0], axis[1], axis[2] )
00091    {
00092    }
00093    
00095    void set( const DATA_TYPE& rad_angle, const DATA_TYPE& x, 
00096              const DATA_TYPE& y, const DATA_TYPE& z )
00097    {
00098       VecBase<DATA_TYPE, 4>::set( rad_angle, x, y, z );
00099    }
00100    
00102    void set( const DATA_TYPE& rad_angle, const Vec<DATA_TYPE, 3>& axis )
00103    {
00104       VecBase<DATA_TYPE, 4>::set( rad_angle, axis[0], axis[1], axis[2] );
00105    }
00106    
00111    void setAxis( const Vec<DATA_TYPE, 3>& axis ) 
00112    { 
00113       VecBase<DATA_TYPE, 4>::operator[]( 1 ) = axis[0];
00114       VecBase<DATA_TYPE, 4>::operator[]( 2 ) = axis[1];
00115       VecBase<DATA_TYPE, 4>::operator[]( 3 ) = axis[2];
00116    }
00117    
00122    void setAngle( const DATA_TYPE& rad_angle ) 
00123    {
00124       VecBase<DATA_TYPE, 4>::operator[]( 0 ) = rad_angle;
00125    }
00126    
00130    Vec<DATA_TYPE, 3> getAxis() const 
00131    { 
00132       return Vec<DATA_TYPE, 3>( VecBase<DATA_TYPE, 4>::operator[]( 1 ),
00133                                 VecBase<DATA_TYPE, 4>::operator[]( 2 ),
00134                                 VecBase<DATA_TYPE, 4>::operator[]( 3 ) );
00135    }
00136    
00140    const DATA_TYPE& getAngle() const 
00141    {
00142       return VecBase<DATA_TYPE, 4>::operator[]( 0 );
00143    }
00144 };
00145 
00146 const AxisAngle<float> AXISANGLE_IDENTITYF( 0.0f, 1.0f, 0.0f, 0.0f );
00147 const AxisAngle<double> AXISANGLE_IDENTITYD( 0.0, 1.0, 0.0, 0.0 );
00148 
00149 typedef AxisAngle<float> AxisAnglef;
00150 typedef AxisAngle<double> AxisAngled;
00151 
00152 } // end of namespace gmtl
00153 
00154 #endif

Generated on Mon Apr 7 15:28:54 2003 for GenericMathTemplateLibrary by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002