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

Coord.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: Coord.h,v $
00010  * Date modified: $Date: 2003/03/29 22:02:18 $
00011  * Version:       $Revision: 1.14 $
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_COORD_H_
00036 #define _GMTL_COORD_H_
00037 
00038 #include <gmtl/Vec.h>
00039 #include <gmtl/AxisAngle.h>
00040 #include <gmtl/EulerAngle.h>
00041 #include <gmtl/Quat.h>
00042 #include <gmtl/Util/Meta.h>
00043 #include <gmtl/Util/StaticAssert.h>
00044 
00045 namespace gmtl
00046 {
00047    
00064 template <typename POS_TYPE, typename ROT_TYPE>
00065 class Coord
00066 {
00067 public:
00068    Coord() : mPos(), mRot()
00069    {
00070    }
00071    
00072    typedef typename POS_TYPE::DataType DataType;
00073    typedef POS_TYPE PosDataType;
00074    typedef ROT_TYPE RotDataType;
00075    enum Params
00076    {
00077        PosSize = POS_TYPE::Size,
00078        RotSize = ROT_TYPE::Size
00079    };
00080     
00081    Coord( const Coord<POS_TYPE, ROT_TYPE>& coord ) : mPos( coord.mPos ), mRot( coord.mRot )
00082    {
00083    }
00084    
00085    Coord( const POS_TYPE& pos, const ROT_TYPE& rot ) : mPos( pos ), mRot( rot )
00086    {
00087    }
00088 
00094    Coord( DataType a0, DataType a1, DataType a2, DataType a3, DataType a4, DataType a5 )
00095    {
00096       GMTL_STATIC_ASSERT(PosSize == 3);   // "Using incorrect number of args for type size");
00097       GMTL_STATIC_ASSERT(RotSize == 3);   // "Using incorrect number of args for type size");
00098       if(PosSize == 3)
00099       {
00100          mPos[0] = a0; mPos[1] = a1; mPos[2] = a2;
00101          mRot[0] = a3; mRot[1] = a4; mRot[2] = a5; 
00102       }
00103       else
00104       {
00105          gmtlASSERT(false && "Constructor not supported for pos size");
00106       }
00107    }
00108 
00109    Coord( DataType a0, DataType a1, DataType a2, DataType a3, DataType a4, DataType a5, DataType a6 )
00110    {
00111       GMTL_STATIC_ASSERT( (PosSize == 3 && RotSize == 4) || (PosSize == 4 && RotSize == 3)); // "Using incorrect number of args for type size");
00112       if(PosSize == 3)
00113       {
00114          mPos[0] = a0; mPos[1] = a1; mPos[2] = a2;
00115          mRot[0] = a3; mRot[1] = a4; mRot[2] = a5; mRot[3] = a6; 
00116       }
00117       else if(PosSize == 4)
00118       {
00119          mPos[0] = a0; mPos[1] = a1; mPos[2] = a2; mPos[3] = a3;
00120          mRot[0] = a4; mRot[1] = a5; mRot[2] = a6; 
00121       }
00122       else
00123       {
00124          gmtlASSERT(false && "Constructor not supported for pos size");
00125       }
00126 
00127    }
00128   
00129    Coord( DataType a0, DataType a1, DataType a2, DataType a3, DataType a4, DataType a5, DataType a6, DataType a7 )
00130    {
00131       GMTL_STATIC_ASSERT(PosSize == 4);    // "Using incorrect number of args for type size"
00132       GMTL_STATIC_ASSERT(RotSize == 4);    // "Using incorrect number of args for type size"
00133       if(PosSize == 4)
00134       {
00135          mPos[0] = a0; mPos[1] = a1; mPos[2] = a2; mPos[3] = a3;
00136          mRot[0] = a4; mRot[1] = a5; mRot[2] = a6; mRot[3] = a7;   
00137       }
00138       else
00139       {
00140          gmtlASSERT(false && "Constructor not supported for pos size");
00141       }
00142    }
00144 
00145    const POS_TYPE& getPos() const { return mPos; }
00146    const ROT_TYPE& getRot() const { return mRot; }
00147    
00150    
00152    POS_TYPE& pos() { return mPos; }
00153 
00155    ROT_TYPE& rot() { return mRot; }
00156    
00158    //const POS_TYPE& pos() const { return mPos; }
00159 
00161    //const ROT_TYPE& rot() const  { return mRot; }
00162 
00163 public:
00164    POS_TYPE mPos;
00165    ROT_TYPE mRot;
00166 };
00167 
00168 typedef Coord<Vec3d, EulerAngleXYZd> CoordVec3EulerAngleXYZd;
00169 typedef Coord<Vec3f, EulerAngleXYZf> CoordVec3EulerAngleXYZf;
00170 typedef Coord<Vec4d, EulerAngleXYZd> CoordVec4EulerAngleXYZd;
00171 typedef Coord<Vec4f, EulerAngleXYZf> CoordVec4EulerAngleXYZf;
00172 
00173 typedef Coord<Vec3d, EulerAngleZYXd> CoordVec3EulerAngleZYXd;
00174 typedef Coord<Vec3f, EulerAngleZYXf> CoordVec3EulerAngleZYXf;
00175 typedef Coord<Vec4d, EulerAngleZYXd> CoordVec4EulerAngleZYXd;
00176 typedef Coord<Vec4f, EulerAngleZYXf> CoordVec4EulerAngleZYXf;
00177 
00178 typedef Coord<Vec3d, EulerAngleZXYd> CoordVec3EulerAngleZXYd;
00179 typedef Coord<Vec3f, EulerAngleZXYf> CoordVec3EulerAngleZXYf;
00180 typedef Coord<Vec4d, EulerAngleZXYd> CoordVec4EulerAngleZXYd;
00181 typedef Coord<Vec4f, EulerAngleZXYf> CoordVec4EulerAngleZXYf;
00182 
00183 typedef Coord<Vec3d, AxisAngled> CoordVec3AxisAngled;
00184 typedef Coord<Vec3f, AxisAnglef> CoordVec3AxisAnglef;
00185 typedef Coord<Vec4d, AxisAngled> CoordVec4AxisAngled;
00186 typedef Coord<Vec4f, AxisAnglef> CoordVec4AxisAnglef;
00187 
00188 
00189 
00191 typedef Coord<Vec3f, EulerAngleXYZf> Coord3fXYZ;
00192 typedef Coord<Vec3f, EulerAngleZYXf> Coord3fZYX;
00193 typedef Coord<Vec3f, EulerAngleZXYf> Coord3fZXY;
00194 typedef Coord<Vec3d, EulerAngleXYZd> Coord3dXYZ;
00195 typedef Coord<Vec3d, EulerAngleZYXd> Coord3dZYX;
00196 typedef Coord<Vec3d, EulerAngleZXYd> Coord3dZXY;
00197 
00199 typedef Coord<Vec4f, EulerAngleXYZf> Coord4fXYZ;
00200 typedef Coord<Vec4f, EulerAngleZYXf> Coord4fZYX;
00201 typedef Coord<Vec4f, EulerAngleZXYf> Coord4fZXY;
00202 typedef Coord<Vec4d, EulerAngleXYZd> Coord4dXYZ;
00203 typedef Coord<Vec4d, EulerAngleZYXd> Coord4dZYX;
00204 typedef Coord<Vec4d, EulerAngleZXYd> Coord4dZXY;
00205 
00207 typedef Coord<Vec3f, Quatf> Coord3fQuat;
00208 typedef Coord<Vec3d, Quatd> Coord3dQuat;
00209 
00211 typedef Coord<Vec4f, Quatf> Coord4fQuat;
00212 typedef Coord<Vec4d, Quatd> Coord4dQuat;
00213 
00214 
00216 typedef Coord<Vec3f, AxisAnglef> Coord3fAxisAngle;
00217 typedef Coord<Vec3d, AxisAngled> Coord3dAxisAngle;
00218 
00220 typedef Coord<Vec4f, AxisAnglef> Coord4fAxisAngle;
00221 typedef Coord<Vec4d, AxisAngled> Coord4dAxisAngle;
00222 
00223 }
00224 
00225 #endif

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