Crazy Eddies GUI System  0.6.0
CEGUIVector.h
1 /***********************************************************************
2  filename: CEGUIVector.h
3  created: 14/3/2004
4  author: Paul D Turner
5 
6  purpose: Defines interfaces for Vector classes
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIVector_h_
31 #define _CEGUIVector_h_
32 
33 #include "CEGUIBase.h"
34 #include "CEGUISize.h"
35 
36 
37 // Start of CEGUI namespace section
38 namespace CEGUI
39 {
40 
45 class CEGUIEXPORT Vector2
46 {
47 public:
48  Vector2(void) {}
49  Vector2(float x, float y) : d_x(x), d_y(y) {}
50 
51  Vector2& operator*=(const Vector2& vec)
52  {
53  d_x *= vec.d_x;
54  d_y *= vec.d_y;
55 
56  return *this;
57  }
58 
59  Vector2& operator/=(const Vector2& vec)
60  {
61  d_x /= vec.d_x;
62  d_y /= vec.d_y;
63 
64  return *this;
65  }
66 
67  Vector2& operator+=(const Vector2& vec)
68  {
69  d_x += vec.d_x;
70  d_y += vec.d_y;
71 
72  return *this;
73  }
74 
75  Vector2& operator-=(const Vector2& vec)
76  {
77  d_x -= vec.d_x;
78  d_y -= vec.d_y;
79 
80  return *this;
81  }
82 
83  Vector2 operator+(const Vector2& vec) const
84  {
85  return Vector2(d_x + vec.d_x, d_y + vec.d_y);
86  }
87 
88  Vector2 operator-(const Vector2& vec) const
89  {
90  return Vector2(d_x - vec.d_x, d_y - vec.d_y);
91  }
92 
93  Vector2 operator*(const Vector2& vec) const
94  {
95  return Vector2(d_x * vec.d_x, d_y * vec.d_y);
96  }
97 
98  bool operator==(const Vector2& vec) const
99  {
100  return ((d_x == vec.d_x) && (d_y == vec.d_y));
101  }
102 
103  bool operator!=(const Vector2& vec) const
104  {
105  return !(operator==(vec));
106  }
107 
108  Size asSize() const { return Size(d_x, d_y); }
109 
110  float d_x, d_y;
111 };
112 
117 typedef Vector2 Point;
118 
119 
124 class CEGUIEXPORT Vector3
125 {
126 public:
127  Vector3(void) {}
128  Vector3(float x, float y, float z) : d_x(x), d_y(y), d_z(z) {}
129 
130  float d_x, d_y, d_z;
131 };
132 
133 } // End of CEGUI namespace section
134 
135 
136 #endif // end of guard _CEGUIVector_h_