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

Point.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: Point.h,v $
00010  * Date modified: $Date: 2003/03/29 22:02:19 $
00011  * Version:       $Revision: 1.16 $
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_POINT_H_
00036 #define _GMTL_POINT_H_
00037 
00038 #include <gmtl/VecBase.h>
00039 
00040 namespace gmtl
00041 {
00042 
00057 template<class DATA_TYPE, unsigned SIZE>
00058 class Point : public VecBase<DATA_TYPE, SIZE>
00059 {
00060 public:
00061    typedef DATA_TYPE DataType;
00062    enum Params { Size = SIZE };
00063 
00065    typedef VecBase<DATA_TYPE, SIZE> BaseType;
00066 
00067 public:
00070    Point()
00071    {
00072       for (unsigned i = 0; i < SIZE; ++i)
00073          this->mData[i] = (DATA_TYPE)0;
00074    }
00075 
00080    Point(const Point<DATA_TYPE, SIZE>& rVec)
00081       : BaseType(static_cast<BaseType>(rVec))
00082    {;}
00083    Point(const VecBase<DATA_TYPE, SIZE>& rVec)
00084       : BaseType(rVec)
00085    {;}
00086 
00090    Point(const DATA_TYPE& val0,const DATA_TYPE& val1)
00091    : BaseType(val0, val1)
00092    {
00093       // @todo need compile time assert
00094       gmtlASSERT( SIZE == 2 && "out of bounds element access in Point" );
00095    }
00096 
00100    Point(const DATA_TYPE& val0,const DATA_TYPE& val1,const DATA_TYPE& val2)
00101    : BaseType(val0, val1, val2)
00102    {
00103       // @todo need compile time assert
00104       gmtlASSERT( SIZE == 3 && "out of bounds element access in Point" );
00105    }
00106 
00110    Point(const DATA_TYPE& val0,const DATA_TYPE& val1,const DATA_TYPE& val2,const DATA_TYPE& val3)
00111    : BaseType(val0, val1, val2, val3)
00112    {
00113       // @todo need compile time assert
00114       gmtlASSERT( SIZE == 4 && "out of bounds element access in Point" );
00115    }
00117 
00118 };
00119 
00120 // --- helper types --- //
00121 typedef Point<int,2> Point2i;
00122 typedef Point<float,2> Point2f;
00123 typedef Point<double,2> Point2d;
00124 typedef Point<int, 3> Point3i;
00125 typedef Point<float,3> Point3f;
00126 typedef Point<double,3> Point3d;
00127 typedef Point<int, 4> Point4i;
00128 typedef Point<float,4> Point4f;
00129 typedef Point<double,4> Point4d;
00130 
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