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

Vec.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: Vec.h,v $
00010  * Date modified: $Date: 2003/03/29 22:02:19 $
00011  * Version:       $Revision: 1.17 $
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_VEC_H_
00036 #define _GMTL_VEC_H_
00037 
00038 #include <gmtl/VecBase.h>
00039  
00040 namespace gmtl
00041 {
00042 
00055 template<class DATA_TYPE, unsigned SIZE>
00056 class Vec : public VecBase<DATA_TYPE, SIZE>
00057 {
00058 public:
00060    typedef DATA_TYPE DataType;
00061 
00063    enum Params { Size = SIZE };
00064 
00066    typedef VecBase<DATA_TYPE, SIZE> BaseType;
00067 
00068 public:
00072    Vec()
00073    {
00074       for (unsigned i = 0; i < SIZE; ++i)
00075          this->mData[i] = (DATA_TYPE)0;
00076    }
00077 
00079 
00080 
00085    Vec( const Vec<DATA_TYPE, SIZE>& rVec )
00086       : BaseType( static_cast<BaseType>( rVec ) )
00087    {
00088    }
00089    
00090    Vec( const VecBase<DATA_TYPE, SIZE>& rVec )
00091       : BaseType( rVec )
00092    {
00093    }
00094 
00098    Vec(const DATA_TYPE& val0,const DATA_TYPE& val1)
00099    : BaseType(val0, val1)
00100    {
00101       // @todo compile time assert is needed here
00102       gmtlASSERT( SIZE == 2 && "out of bounds element access in Point" );
00103    }
00104 
00105    Vec(const DATA_TYPE& val0,const DATA_TYPE& val1,const DATA_TYPE& val2)
00106    : BaseType(val0, val1, val2)
00107    {
00108       // @todo compile time assert is needed here
00109       gmtlASSERT( SIZE == 3 && "out of bounds element access in Point" );
00110    }
00111 
00112    Vec(const DATA_TYPE& val0,const DATA_TYPE& val1,const DATA_TYPE& val2,const DATA_TYPE& val3)
00113    : BaseType(val0, val1, val2, val3)
00114    {
00115       // @todo compile time assert is needed here
00116       gmtlASSERT( SIZE == 4 && "out of bounds element access in Point" );
00117    }
00119 };
00120 
00121 // --- helper types --- //
00122 typedef Vec<int, 2> Vec2i;
00123 typedef Vec<float,2> Vec2f;
00124 typedef Vec<double,2> Vec2d;
00125 typedef Vec<int, 3> Vec3i;
00126 typedef Vec<float,3> Vec3f;
00127 typedef Vec<double,3> Vec3d;
00128 typedef Vec<int, 4> Vec4i;
00129 typedef Vec<float,4> Vec4f;
00130 typedef Vec<double,4> Vec4d;
00131 
00132 };
00133 
00134 #endif

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