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

Coord.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_COORD_H_
00007 #define _GMTL_COORD_H_
00008 
00009 #include <gmtl/Defines.h>
00010 #include <gmtl/Vec.h>
00011 #include <gmtl/AxisAngle.h>
00012 #include <gmtl/EulerAngle.h>
00013 #include <gmtl/Quat.h>
00014 #include <gmtl/Util/Meta.h>
00015 #include <gmtl/Util/StaticAssert.h>
00016 
00017 namespace gmtl
00018 {
00019    
00036 template <typename POS_TYPE, typename ROT_TYPE>
00037 class Coord
00038 {
00039 public:
00040    Coord() : mPos(), mRot()
00041    {
00042    }
00043    
00044    typedef typename POS_TYPE::DataType DataType;
00045    typedef POS_TYPE PosDataType;
00046    typedef ROT_TYPE RotDataType;
00047    enum Params
00048    {
00049        PosSize = POS_TYPE::Size,
00050        RotSize = ROT_TYPE::Size
00051    };
00052     
00053    Coord( const Coord<POS_TYPE, ROT_TYPE>& coord ) : mPos( coord.mPos ), mRot( coord.mRot )
00054    {
00055    }
00056    
00057    Coord( const POS_TYPE& pos, const ROT_TYPE& rot ) : mPos( pos ), mRot( rot )
00058    {
00059    }
00060 
00066    Coord( DataType a0, DataType a1, DataType a2, DataType a3, DataType a4, DataType a5 )
00067    {
00068       GMTL_STATIC_ASSERT(PosSize == 3, Using_incorrect_number_of_args_for_type_size);
00069       GMTL_STATIC_ASSERT(RotSize == 3, Using_incorrect_number_of_args_for_type_size);
00070       if(PosSize == 3)
00071       {
00072          mPos[0] = a0; mPos[1] = a1; mPos[2] = a2;
00073          mRot[0] = a3; mRot[1] = a4; mRot[2] = a5; 
00074       }
00075       else
00076       {
00077          gmtlASSERT(false && "Constructor not supported for pos size");
00078       }
00079    }
00080 
00081    Coord( DataType a0, DataType a1, DataType a2, DataType a3, DataType a4, DataType a5, DataType a6 )
00082    {
00083       GMTL_STATIC_ASSERT( (PosSize == 3 && RotSize == 4) || (PosSize == 4 && RotSize == 3), Using_incorrect_number_of_args_for_type_size);
00084       if(PosSize == 3)
00085       {
00086          mPos[0] = a0; mPos[1] = a1; mPos[2] = a2;
00087          mRot[0] = a3; mRot[1] = a4; mRot[2] = a5; mRot[3] = a6; 
00088       }
00089       else if(PosSize == 4)
00090       {
00091          mPos[0] = a0; mPos[1] = a1; mPos[2] = a2; mPos[3] = a3;
00092          mRot[0] = a4; mRot[1] = a5; mRot[2] = a6; 
00093       }
00094       else
00095       {
00096          gmtlASSERT(false && "Constructor not supported for pos size");
00097       }
00098 
00099    }
00100   
00101    Coord( DataType a0, DataType a1, DataType a2, DataType a3, DataType a4, DataType a5, DataType a6, DataType a7 )
00102    {
00103       GMTL_STATIC_ASSERT(PosSize == 4, Using_incorrect_number_of_args_for_type_size);
00104       GMTL_STATIC_ASSERT(RotSize == 4, Using_incorrect_number_of_args_for_type_size);
00105       if(PosSize == 4)
00106       {
00107          mPos[0] = a0; mPos[1] = a1; mPos[2] = a2; mPos[3] = a3;
00108          mRot[0] = a4; mRot[1] = a5; mRot[2] = a6; mRot[3] = a7;   
00109       }
00110       else
00111       {
00112          gmtlASSERT(false && "Constructor not supported for pos size");
00113       }
00114    }
00116 
00117    const POS_TYPE& getPos() const { return mPos; }
00118    const ROT_TYPE& getRot() const { return mRot; }
00119    
00122    
00124    POS_TYPE& pos() { return mPos; }
00125 
00127    ROT_TYPE& rot() { return mRot; }
00128    
00130    //const POS_TYPE& pos() const { return mPos; }
00131 
00133    //const ROT_TYPE& rot() const  { return mRot; }
00134 
00135 public:
00136    POS_TYPE mPos;
00137    ROT_TYPE mRot;
00138 };
00139 
00140 typedef Coord<Vec3d, EulerAngleXYZd> CoordVec3EulerAngleXYZd;
00141 typedef Coord<Vec3f, EulerAngleXYZf> CoordVec3EulerAngleXYZf;
00142 typedef Coord<Vec4d, EulerAngleXYZd> CoordVec4EulerAngleXYZd;
00143 typedef Coord<Vec4f, EulerAngleXYZf> CoordVec4EulerAngleXYZf;
00144 
00145 typedef Coord<Vec3d, EulerAngleZYXd> CoordVec3EulerAngleZYXd;
00146 typedef Coord<Vec3f, EulerAngleZYXf> CoordVec3EulerAngleZYXf;
00147 typedef Coord<Vec4d, EulerAngleZYXd> CoordVec4EulerAngleZYXd;
00148 typedef Coord<Vec4f, EulerAngleZYXf> CoordVec4EulerAngleZYXf;
00149 
00150 typedef Coord<Vec3d, EulerAngleZXYd> CoordVec3EulerAngleZXYd;
00151 typedef Coord<Vec3f, EulerAngleZXYf> CoordVec3EulerAngleZXYf;
00152 typedef Coord<Vec4d, EulerAngleZXYd> CoordVec4EulerAngleZXYd;
00153 typedef Coord<Vec4f, EulerAngleZXYf> CoordVec4EulerAngleZXYf;
00154 
00155 typedef Coord<Vec3d, AxisAngled> CoordVec3AxisAngled;
00156 typedef Coord<Vec3f, AxisAnglef> CoordVec3AxisAnglef;
00157 typedef Coord<Vec4d, AxisAngled> CoordVec4AxisAngled;
00158 typedef Coord<Vec4f, AxisAnglef> CoordVec4AxisAnglef;
00159 
00160 
00161 
00163 typedef Coord<Vec3f, EulerAngleXYZf> Coord3fXYZ;
00164 typedef Coord<Vec3f, EulerAngleZYXf> Coord3fZYX;
00165 typedef Coord<Vec3f, EulerAngleZXYf> Coord3fZXY;
00166 typedef Coord<Vec3d, EulerAngleXYZd> Coord3dXYZ;
00167 typedef Coord<Vec3d, EulerAngleZYXd> Coord3dZYX;
00168 typedef Coord<Vec3d, EulerAngleZXYd> Coord3dZXY;
00169 
00171 typedef Coord<Vec4f, EulerAngleXYZf> Coord4fXYZ;
00172 typedef Coord<Vec4f, EulerAngleZYXf> Coord4fZYX;
00173 typedef Coord<Vec4f, EulerAngleZXYf> Coord4fZXY;
00174 typedef Coord<Vec4d, EulerAngleXYZd> Coord4dXYZ;
00175 typedef Coord<Vec4d, EulerAngleZYXd> Coord4dZYX;
00176 typedef Coord<Vec4d, EulerAngleZXYd> Coord4dZXY;
00177 
00179 typedef Coord<Vec3f, Quatf> Coord3fQuat;
00180 typedef Coord<Vec3d, Quatd> Coord3dQuat;
00181 
00183 typedef Coord<Vec4f, Quatf> Coord4fQuat;
00184 typedef Coord<Vec4d, Quatd> Coord4dQuat;
00185 
00186 
00188 typedef Coord<Vec3f, AxisAnglef> Coord3fAxisAngle;
00189 typedef Coord<Vec3d, AxisAngled> Coord3dAxisAngle;
00190 
00192 typedef Coord<Vec4f, AxisAnglef> Coord4fAxisAngle;
00193 typedef Coord<Vec4d, AxisAngled> Coord4dAxisAngle;
00194 
00195 }
00196 
00197 #endif

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