CEGUIVector.h

00001 /************************************************************************
00002         filename:       CEGUIVector.h
00003         created:        14/3/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Defines interfaces for Vector classes
00007 *************************************************************************/
00008 /*************************************************************************
00009     Crazy Eddie's GUI System (http://www.cegui.org.uk)
00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
00011 
00012     This library is free software; you can redistribute it and/or
00013     modify it under the terms of the GNU Lesser General Public
00014     License as published by the Free Software Foundation; either
00015     version 2.1 of the License, or (at your option) any later version.
00016 
00017     This library is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020     Lesser General Public License for more details.
00021 
00022     You should have received a copy of the GNU Lesser General Public
00023     License along with this library; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 *************************************************************************/
00026 #ifndef _CEGUIVector_h_
00027 #define _CEGUIVector_h_
00028 
00029 #include "CEGUIBase.h"
00030 #include "CEGUISize.h"
00031 
00032 
00033 // Start of CEGUI namespace section
00034 namespace CEGUI
00035 {
00036 
00041 class CEGUIEXPORT Vector2
00042 {
00043 public:
00044         Vector2(void) {}
00045         Vector2(float x, float y) : d_x(x), d_y(y) {}
00046 
00047         Vector2& operator*=(const Vector2& vec)
00048         {
00049                 d_x *= vec.d_x;
00050                 d_y *= vec.d_y;
00051 
00052                 return *this;
00053         }
00054 
00055         Vector2& operator/=(const Vector2& vec)
00056         {
00057                 d_x /= vec.d_x;
00058                 d_y /= vec.d_y;
00059 
00060                 return *this;
00061         }
00062 
00063         Vector2& operator+=(const Vector2& vec)
00064         {
00065                 d_x += vec.d_x;
00066                 d_y += vec.d_y;
00067 
00068                 return *this;
00069         }
00070 
00071         Vector2& operator-=(const Vector2& vec)
00072         {
00073                 d_x -= vec.d_x;
00074                 d_y -= vec.d_y;
00075 
00076                 return *this;
00077         }
00078 
00079         Vector2 operator+(const Vector2& vec) const
00080         {
00081                 return Vector2(d_x + vec.d_x, d_y + vec.d_y);
00082         }
00083 
00084         Vector2 operator-(const Vector2& vec) const
00085         {
00086                 return Vector2(d_x - vec.d_x, d_y - vec.d_y);
00087         }
00088 
00089         Vector2 operator*(const Vector2& vec) const
00090         {
00091                 return Vector2(d_x * vec.d_x, d_y * vec.d_y);
00092         }
00093 
00094         bool    operator==(const Vector2& vec) const
00095         {
00096                 return ((d_x == vec.d_x) && (d_y == vec.d_y));
00097         }
00098 
00099         bool    operator!=(const Vector2& vec) const
00100         {
00101                 return !(operator==(vec));
00102         }
00103 
00104     Size asSize() const     { return Size(d_x, d_y); }
00105 
00106         float d_x, d_y;
00107 };
00108 
00113 typedef Vector2         Point;
00114 
00115 
00120 class CEGUIEXPORT Vector3
00121 {
00122 public:
00123         Vector3(void) {}
00124         Vector3(float x, float y, float z) : d_x(x), d_y(y), d_z(z) {}
00125 
00126         float   d_x, d_y, d_z;
00127 };
00128 
00129 } // End of  CEGUI namespace section
00130 
00131 
00132 #endif  // end of guard _CEGUIVector_h_

Generated on Sat Nov 26 09:34:49 2005 for Crazy Eddies GUI System by  doxygen 1.4.5