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

EulerAngle.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: EulerAngle.h,v $
00010  * Date modified: $Date: 2003/03/29 22:02:18 $
00011  * Version:       $Revision: 1.10 $
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_EULERANGLE_H_
00036 #define _GMTL_EULERANGLE_H_
00037 
00038 #include <gmtl/Math.h>     // for rotation order
00039  
00040 namespace gmtl
00041 {
00042 
00066 template <typename DATA_TYPE, typename ROTATION_ORDER>
00067 class EulerAngle
00068 {
00069 public:
00070    enum Params { Size = 3, Order = ROTATION_ORDER::ID };
00071 
00073    EulerAngle()
00074    {
00075       gmtlASSERT( ROTATION_ORDER::IS_ROTORDER == 1 && 
00076             "you must specify a RotationOrder derived type for the rotationorder in euler angle." );
00077       mData[0] = DATA_TYPE( 0 );
00078       mData[1] = DATA_TYPE( 0 );
00079       mData[2] = DATA_TYPE( 0 );
00080    }
00081 
00083    EulerAngle( const EulerAngle& e )
00084    {
00085       mData[0] = e.mData[0];
00086       mData[1] = e.mData[1];
00087       mData[2] = e.mData[2];
00088    }
00089 
00091    EulerAngle( DATA_TYPE p0, DATA_TYPE p1, DATA_TYPE p2 )
00092    {
00093       mData[0] = p0;
00094       mData[1] = p1;
00095       mData[2] = p2;
00096    }
00097    
00099    void set( const DATA_TYPE& p0, const DATA_TYPE& p1, 
00100              const DATA_TYPE& p2 )
00101    {
00102       mData[0] = p0;
00103       mData[1] = p1;
00104       mData[2] = p2;
00105    }
00106    
00108 
00113    inline DATA_TYPE& operator[]( const unsigned i )
00114    {
00115       gmtlASSERT( i < Size );
00116       return mData[i];
00117    }
00118    inline const DATA_TYPE&  operator[]( const unsigned i ) const
00119    {
00120       gmtlASSERT( i < Size );
00121       return mData[i];
00122    }
00124    
00126 
00129    DATA_TYPE* getData() { return mData; }
00130    
00134    const DATA_TYPE* getData() const { return mData; }
00136    
00137 private:
00138    DATA_TYPE mData[Size];
00139 };
00140 
00141 const EulerAngle<float, XYZ> EULERANGLE_IDENTITY_XYZF( 0.0f, 0.0f, 0.0f );
00142 const EulerAngle<double, XYZ> EULERANGLE_IDENTITY_XYZD( 0.0, 0.0, 0.0 );
00143 const EulerAngle<float, ZYX> EULERANGLE_IDENTITY_ZYXF( 0.0f, 0.0f, 0.0f );
00144 const EulerAngle<double, ZYX> EULERANGLE_IDENTITY_ZYXD( 0.0, 0.0, 0.0 );
00145 const EulerAngle<float, ZXY> EULERANGLE_IDENTITY_ZXYF( 0.0f, 0.0f, 0.0f );
00146 const EulerAngle<double, ZXY> EULERANGLE_IDENTITY_ZXYD( 0.0, 0.0, 0.0 );
00147 
00148 typedef EulerAngle<float, XYZ> EulerAngleXYZf;
00149 typedef EulerAngle<double, XYZ> EulerAngleXYZd;
00150 typedef EulerAngle<float, ZYX> EulerAngleZYXf;
00151 typedef EulerAngle<double, ZYX> EulerAngleZYXd;
00152 typedef EulerAngle<float, ZXY> EulerAngleZXYf;
00153 typedef EulerAngle<double, ZXY> EulerAngleZXYd;
00154 
00155 } // end of namespace gmtl
00156 
00157 #endif

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