D:/WorkDir/SugoiProjects/SugoiTools/include/SugoiTools/cl_vector2.h

00001 /* LICENSE_BEGIN
00002 SutoiTools library supply support for debugging, testing and 
00003 setting good bases for you application. It is part of the 
00004 SugoiEngine project.
00005 Copyright (C) 2006 Allusse Yannick (yannick dot allusse at laposte dot net)
00006 
00007 
00008 This program is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU General Public License
00010 as published by the Free Software Foundation; either version 2
00011 of the License, or (at your option) any later version.
00012 
00013 This program is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 GNU General Public License for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with this program; if not, write to the Free Software
00020 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00021 LICENSE_END
00022 */
00023 
00024 /* \file SG_TLS_cl_vector_tmpl_2.h
00025  * \brief Basic template vector class of any type and size 2.
00026  * \author Yannick Allusse
00027 */
00028 
00029 #ifndef CL_VECTORS_TMPL_2_h
00030 #define CL_VECTORS_TMPL_2_h
00031 
00032 #include "SugoiTools\cl_vectors_template.h"
00033 
00034 #if SG_TLS_MEMORY_MANAGER
00035           #include "SugoiTools\debug_new.h"
00036 #endif 
00037 
00038 
00039 namespace SGE{
00040 
00041 template <typename TType> class CL_Vector2D;
00042 typedef CL_Vector2D<float>              CL_Vector2Df;
00043 typedef CL_Vector2D<int>                CL_Vector2Di;
00044 typedef CL_Vector2D<double>             CL_Vector2Dd;
00045 
00046 //=========================================================
00047 //=========================================================
00048 //        CL_Vector2D
00049 //=========================================================
00050 //=========================================================
00057 template <typename TType> class CL_Vector2D : public CLT_Vector<TType>
00058 {
00059 public :
00060           TType &x; 
00061           TType &y; 
00062 
00063 //Contructors / Destructors   =================================
00064 
00069           CL_Vector2D()
00070                     :CLT_Vector<TType>(2,0.),
00071                     x( CLT_Vector<TType>::vec[0]),
00072                     y( CLT_Vector<TType>::vec[1])
00073                     {};
00074 
00075 
00080           CL_Vector2D(const CLT_Vector<TType> &_Vec) 
00081                     : CLT_Vector<TType>(_Vec), 
00082                     x( CLT_Vector<TType>::vec[0]), 
00083                     y( CLT_Vector<TType>::vec[1])
00084                     {};
00085 
00086 
00092           CL_Vector2D(const CL_Vector2D<TType> &_Vec)
00093                     :CLT_Vector<TType>(_Vec), 
00094                     x( CLT_Vector<TType>::vec[0]), 
00095                     y( CLT_Vector<TType>::vec[1])
00096                     {};
00097 
00103           CL_Vector2D(const TType * _Val)
00104                     :CLT_Vector<TType>(2, _Val), 
00105                     x( CLT_Vector<TType>::vec[0]), 
00106                     y( CLT_Vector<TType>::vec[1])
00107                     {};
00108 
00109 
00115           CL_Vector2D(const TType _Val)
00116                     :CLT_Vector<TType>(2, _Val), 
00117                     x( CLT_Vector<TType>::vec[0]), 
00118                     y( CLT_Vector<TType>::vec[1])
00119                     {};
00120 
00127           CL_Vector2D(const TType _x, const TType _y)
00128                     :CLT_Vector<TType>(2,0.), 
00129                     x( CLT_Vector<TType>::vec[0]), 
00130                     y( CLT_Vector<TType>::vec[1])
00131                     {
00132                               Set(_x, _y);
00133                     };
00134 
00139                     ~CL_Vector2D()
00140                               {};
00141 
00142 //===========================================================
00143 
00150           void 
00151                     Set(const TType _x, const TType _y)
00152                     {         x=_x; y=_y; }
00153 
00154 
00155           CL_Vector2D<TType> & 
00156                     operator= (const CL_Vector2D<TType> & _Vec2)
00157                     {
00158                               VECTOR_OP_EQUAL(this, _Vec2.vec[i], , GetDim());
00159                               return(*this);
00160                     }
00161 
00162 
00163           CL_Vector2D<TType> & 
00164                     operator= (const TType * _Val)
00165           {
00166                     SG_Assert(_Val, "Given Value is NULL");
00167                     VECTOR_OP_EQUAL(this, _Val[i], , GetDim());
00168                     return(*this);
00169           }
00170 
00171           CL_Vector2D<TType> &
00172                     operator= (const TType _Val)
00173                     {
00174                               VECTOR_OP_EQUAL(this, _Val, , GetDim());
00175                               return(*this);
00176                     }
00177 
00178 /*        
00179           _SG_TLS_INLINE const TType              operator %          (const CL_Vector2D &) const;          
00180           _SG_TLS_INLINE const CL_Vector2D        operator ^          (const CL_Vector2D &) const;           
00181           _SG_TLS_INLINE const CL_Vector2D&       operator ^= (const CL_Vector2D &);
00182           _SG_TLS_INLINE const TType              operator !          () const;                        // Distance from [0, 0, 0]
00183           _SG_TLS_INLINE const CL_Vector2D        operator |          (const TType &) const;       // Sets distance from [0, 0, 0]
00184           _SG_TLS_INLINE                  CL_Vector2D&      operator |= (const TType &);
00185           const TType                   Angle               (const CL_Vector2D &) const;                 // Calculates angle between this and another point
00186           const CL_Vector2D   Reflection          (const CL_Vector2D &) const;             // Mirrors the direction of this point to [0, 0, 0] using the line from [0, 0, 0] to the other point
00187           const CL_Vector2D   Rotate              (const TType &, const CL_Vector2D &) const; // Rotates and stuff
00188 
00189 */
00190 };
00191 
00192 _SG_TLS_EXPORT _SG_TLS_INLINE std::ostream& operator<< (std::ostream& s, const CL_Vector2D<typename>& _v);
00193 
00194 
00195 
00196 //============================================================================
00197 //CL_Vector2D START==============================================================
00198 //============================================================================
00199 
00200 //============================================================================
00201 //CL_Vector2D END================================================================
00202 //============================================================================
00203 
00204 
00205 };//namespace SGE
00206 
00207 #if SG_TLS_MEMORY_MANAGER
00208           #include "SugoiTools\debug_new_off.h"//Must be the last....
00209 #endif 
00210 
00211 
00212 
00213 #endif//CL_VECTORS_TMPL_2_h

Generated on Mon Mar 19 23:15:10 2007 for SugoiTools by  doxygen 1.4.6-NO