Crazy Eddies GUI System 0.7.6
|
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 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00010 * 00011 * Permission is hereby granted, free of charge, to any person obtaining 00012 * a copy of this software and associated documentation files (the 00013 * "Software"), to deal in the Software without restriction, including 00014 * without limitation the rights to use, copy, modify, merge, publish, 00015 * distribute, sublicense, and/or sell copies of the Software, and to 00016 * permit persons to whom the Software is furnished to do so, subject to 00017 * the following conditions: 00018 * 00019 * The above copyright notice and this permission notice shall be 00020 * included in all copies or substantial portions of the Software. 00021 * 00022 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00023 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00024 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00025 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00026 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00027 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00028 * OTHER DEALINGS IN THE SOFTWARE. 00029 ***************************************************************************/ 00030 #ifndef _CEGUIVector_h_ 00031 #define _CEGUIVector_h_ 00032 00033 #include "CEGUIBase.h" 00034 #include "CEGUISize.h" 00035 00036 00037 // Start of CEGUI namespace section 00038 namespace CEGUI 00039 { 00040 00045 class CEGUIEXPORT Vector2 00046 { 00047 public: 00048 Vector2(void) {} 00049 Vector2(float x, float y) : d_x(x), d_y(y) {} 00050 Vector2(const Vector2& v) : d_x(v.d_x), d_y(v.d_y) {} 00051 00052 Vector2& operator*=(const Vector2& vec) 00053 { 00054 d_x *= vec.d_x; 00055 d_y *= vec.d_y; 00056 00057 return *this; 00058 } 00059 00060 Vector2& operator/=(const Vector2& vec) 00061 { 00062 d_x /= vec.d_x; 00063 d_y /= vec.d_y; 00064 00065 return *this; 00066 } 00067 00068 Vector2& operator+=(const Vector2& vec) 00069 { 00070 d_x += vec.d_x; 00071 d_y += vec.d_y; 00072 00073 return *this; 00074 } 00075 00076 Vector2& operator-=(const Vector2& vec) 00077 { 00078 d_x -= vec.d_x; 00079 d_y -= vec.d_y; 00080 00081 return *this; 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 Vector2 operator*(const Vector2& vec) const 00095 { 00096 return Vector2(d_x * vec.d_x, d_y * vec.d_y); 00097 } 00098 00099 Vector2 operator*(float c) const 00100 { 00101 return Vector2(d_x * c, d_y * c); 00102 } 00103 00104 bool operator==(const Vector2& vec) const 00105 { 00106 return ((d_x == vec.d_x) && (d_y == vec.d_y)); 00107 } 00108 00109 bool operator!=(const Vector2& vec) const 00110 { 00111 return !(operator==(vec)); 00112 } 00113 00114 Size asSize() const { return Size(d_x, d_y); } 00115 00116 float d_x, d_y; 00117 }; 00118 00123 typedef Vector2 Point; 00124 00125 00130 class CEGUIEXPORT Vector3 00131 { 00132 public: 00133 Vector3(void) {} 00134 Vector3(float x, float y, float z) : d_x(x), d_y(y), d_z(z) {} 00135 Vector3(const Vector3& v) : d_x(v.d_x), d_y(v.d_y), d_z(v.d_z) {} 00136 00137 bool operator==(const Vector3& vec) const 00138 { 00139 return ((d_x == vec.d_x) && (d_y == vec.d_y) && (d_z == vec.d_z)); 00140 } 00141 00142 bool operator!=(const Vector3& vec) const 00143 { 00144 return !(operator==(vec)); 00145 } 00146 00147 Vector3 operator*(float c) const 00148 { 00149 return Vector3(d_x * c, d_y * c, d_z * c); 00150 } 00151 00152 Vector3 operator+(const Vector3& v) const 00153 { 00154 return Vector3(d_x + v.d_x, d_y + v.d_y, d_z + v.d_z); 00155 } 00156 00157 float d_x, d_y, d_z; 00158 }; 00159 00160 } // End of CEGUI namespace section 00161 00162 00163 #endif // end of guard _CEGUIVector_h_ 00164