Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

coordonate.h

Go to the documentation of this file.
00001 /* ***********************************************************************************
00002         Writer:         Sebastien Bloc
00003         Copyright:      2003-2004
00004         eMail:          sebastien.bloc@free.fr
00005         URL:            http://mignonsoft.free.fr
00006 
00007         This program is free software; you can redistribute it and/or
00008         modify it under the terms of the GNU General Public License
00009         as published by the Free Software Foundation; either version 2
00010         of the License, or (at your option) any later version.
00011 
00012         This program is distributed in the hope that it will be useful,
00013         but WITHOUT ANY WARRANTY; without even the implied warranty of
00014         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015         GNU General Public License for more details.
00016 http://www.gnu.org/copyleft/gpl.html
00017 *********************************************************************************** */
00018 
00023 #ifndef INCLUDE_3D_COORDONATE_H
00024 #define INCLUDE_3D_COORDONATE_H
00025 
00031 template <class T> class Coordonate
00032 {
00033 public: 
00034         union 
00035         {
00036                 T value[4];
00037                 struct 
00038                 {
00039                         T x;
00040                         T y;
00041                         T z;
00042                         T w;
00043                 };
00044         };
00045         BOOL isEnable;
00046 
00047 public:
00048         Coordonate()
00049         {
00050                 Zero();
00051         }
00052 
00053         void Zero()
00054         {
00055                 x=0;
00056                 y=0;
00057                 z=0;
00058                 isEnable = FALSE;
00059         }
00060 
00061         void operator=(Coordonate &src)
00062         {
00063                 isEnable = src.isEnable;
00064                 x = src.x;
00065                 y = src.y;
00066                 z = src.z;
00067                 w = src.w;
00068         }
00069 
00070         void Set(T _x,T _y,T _z=0,T _w=0)
00071         {
00072                 x = _x;
00073                 y = _y;
00074                 z = _z;
00075                 w = _w;
00076                 isEnable = TRUE;
00077         }
00078 
00079         BOOL operator!=(Coordonate &src)
00080         {
00081                 return !operator==(src);
00082         }
00083 
00084         BOOL operator==(Coordonate &src)
00085         {
00086                 return isEnable==src.isEnable&&x==src.x&&y==src.y&&z==src.z&&w==src.w;
00087         }
00088 
00089         operator T *() const 
00090         {
00091                 return (T *)&value;
00092         }
00093 
00094         void ToString (MyString &source)
00095         {
00096                 source<<"[enable,x,y,z,w]: "<<isEnable<<" , "<<x<<" , "<<y<<" , "<<z<<" , "<<w;
00097         }
00098 };
00099 
00100 #endif

Generated on Fri Aug 20 19:19:44 2004 for 3d Controls by doxygen 1.3.6