]> git.sesse.net Git - casparcg/blob - SFML-1.6/include/SFML/System/Vector2.hpp
Removed GLEE from dependencies.
[casparcg] / SFML-1.6 / include / SFML / System / Vector2.hpp
1 ////////////////////////////////////////////////////////////\r
2 //\r
3 // SFML - Simple and Fast Multimedia Library\r
4 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)\r
5 //\r
6 // This software is provided 'as-is', without any express or implied warranty.\r
7 // In no event will the authors be held liable for any damages arising from the use of this software.\r
8 //\r
9 // Permission is granted to anyone to use this software for any purpose,\r
10 // including commercial applications, and to alter it and redistribute it freely,\r
11 // subject to the following restrictions:\r
12 //\r
13 // 1. The origin of this software must not be misrepresented;\r
14 //    you must not claim that you wrote the original software.\r
15 //    If you use this software in a product, an acknowledgment\r
16 //    in the product documentation would be appreciated but is not required.\r
17 //\r
18 // 2. Altered source versions must be plainly marked as such,\r
19 //    and must not be misrepresented as being the original software.\r
20 //\r
21 // 3. This notice may not be removed or altered from any source distribution.\r
22 //\r
23 ////////////////////////////////////////////////////////////\r
24 \r
25 #ifndef SFML_VECTOR2_HPP\r
26 #define SFML_VECTOR2_HPP\r
27 \r
28 \r
29 namespace sf\r
30 {\r
31 ////////////////////////////////////////////////////////////\r
32 /// Vector2 is an utility class for manipulating 2 dimensional\r
33 /// vectors. Template parameter defines the type of coordinates\r
34 /// (integer, float, ...)\r
35 ////////////////////////////////////////////////////////////\r
36 template <typename T>\r
37 class Vector2\r
38 {\r
39 public :\r
40 \r
41     ////////////////////////////////////////////////////////////\r
42     /// Default constructor\r
43     ///\r
44     ////////////////////////////////////////////////////////////\r
45     Vector2();\r
46 \r
47     ////////////////////////////////////////////////////////////\r
48     /// Construct the vector from its coordinates\r
49     ///\r
50     /// \param X : X coordinate\r
51     /// \param Y : Y coordinate\r
52     ///\r
53     ////////////////////////////////////////////////////////////\r
54     Vector2(T X, T Y);\r
55 \r
56     ////////////////////////////////////////////////////////////\r
57     // Member data\r
58     ////////////////////////////////////////////////////////////\r
59     T x; ///< X coordinate of the vector\r
60     T y; ///< Y coordinate of the vector\r
61 };\r
62 \r
63 ////////////////////////////////////////////////////////////\r
64 /// Operator - overload ; returns the opposite of a vector\r
65 ///\r
66 /// \param V : Vector to negate\r
67 ///\r
68 /// \return -V\r
69 ///\r
70 ////////////////////////////////////////////////////////////\r
71 template <typename T>\r
72 Vector2<T> operator -(const Vector2<T>& V);\r
73 \r
74 ////////////////////////////////////////////////////////////\r
75 /// Operator += overload ; add two vectors and assign to the first op\r
76 ///\r
77 /// \param V1 : First vector\r
78 /// \param V2 : Second vector\r
79 ///\r
80 /// \return V1 + V2\r
81 ///\r
82 ////////////////////////////////////////////////////////////\r
83 template <typename T>\r
84 Vector2<T>& operator +=(Vector2<T>& V1, const Vector2<T>& V2);\r
85 \r
86 ////////////////////////////////////////////////////////////\r
87 /// Operator -= overload ; subtract two vectors and assign to the first op\r
88 ///\r
89 /// \param V1 : First vector\r
90 /// \param V2 : Second vector\r
91 ///\r
92 /// \return V1 - V2\r
93 ///\r
94 ////////////////////////////////////////////////////////////\r
95 template <typename T>\r
96 Vector2<T>& operator -=(Vector2<T>& V1, const Vector2<T>& V2);\r
97 \r
98 ////////////////////////////////////////////////////////////\r
99 /// Operator + overload ; adds two vectors\r
100 ///\r
101 /// \param V1 : First vector\r
102 /// \param V2 : Second vector\r
103 ///\r
104 /// \return V1 + V2\r
105 ///\r
106 ////////////////////////////////////////////////////////////\r
107 template <typename T>\r
108 Vector2<T> operator +(const Vector2<T>& V1, const Vector2<T>& V2);\r
109 \r
110 ////////////////////////////////////////////////////////////\r
111 /// Operator - overload ; subtracts two vectors\r
112 ///\r
113 /// \param V1 : First vector\r
114 /// \param V2 : Second vector\r
115 ///\r
116 /// \return V1 - V2\r
117 ///\r
118 ////////////////////////////////////////////////////////////\r
119 template <typename T>\r
120 Vector2<T> operator -(const Vector2<T>& V1, const Vector2<T>& V2);\r
121 \r
122 ////////////////////////////////////////////////////////////\r
123 /// Operator * overload ; multiply a vector by a scalar value\r
124 ///\r
125 /// \param V : Vector\r
126 /// \param X : Scalar value\r
127 ///\r
128 /// \return V * X\r
129 ///\r
130 ////////////////////////////////////////////////////////////\r
131 template <typename T>\r
132 Vector2<T> operator *(const Vector2<T>& V, T X);\r
133 \r
134 ////////////////////////////////////////////////////////////\r
135 /// Operator * overload ; multiply a scalar value by a vector\r
136 ///\r
137 /// \param X : Scalar value\r
138 /// \param V : Vector\r
139 ///\r
140 /// \return X * V\r
141 ///\r
142 ////////////////////////////////////////////////////////////\r
143 template <typename T>\r
144 Vector2<T> operator *(T X, const Vector2<T>& V);\r
145 \r
146 ////////////////////////////////////////////////////////////\r
147 /// Operator *= overload ; multiply-assign a vector by a scalar value\r
148 ///\r
149 /// \param V : Vector\r
150 /// \param X : Scalar value\r
151 ///\r
152 /// \return V * X\r
153 ///\r
154 ////////////////////////////////////////////////////////////\r
155 template <typename T>\r
156 Vector2<T>& operator *=(Vector2<T>& V, T X);\r
157 \r
158 ////////////////////////////////////////////////////////////\r
159 /// Operator / overload ; divide a vector by a scalar value\r
160 ///\r
161 /// \param V : Vector\r
162 /// \param X : Scalar value\r
163 ///\r
164 /// \return V / X\r
165 ///\r
166 ////////////////////////////////////////////////////////////\r
167 template <typename T>\r
168 Vector2<T> operator /(const Vector2<T>& V, T X);\r
169 \r
170 ////////////////////////////////////////////////////////////\r
171 /// Operator /= overload ; divide-assign a vector by a scalar value\r
172 ///\r
173 /// \param V : Vector\r
174 /// \param X : Scalar value\r
175 ///\r
176 /// \return V / X\r
177 ///\r
178 ////////////////////////////////////////////////////////////\r
179 template <typename T>\r
180 Vector2<T>& operator /=(Vector2<T>& V, T X);\r
181 \r
182 ////////////////////////////////////////////////////////////\r
183 /// Operator == overload ; compares the equality of two vectors\r
184 ///\r
185 /// \param V1 : First vector\r
186 /// \param V2 : Second vector\r
187 ///\r
188 /// \return True if V1 is equal to V2\r
189 ///\r
190 ////////////////////////////////////////////////////////////\r
191 template <typename T>\r
192 bool operator ==(const Vector2<T>& V1, const Vector2<T>& V2);\r
193 \r
194 ////////////////////////////////////////////////////////////\r
195 /// Operator != overload ; compares the difference of two vectors\r
196 ///\r
197 /// \param V1 : First vector\r
198 /// \param V2 : Second vector\r
199 ///\r
200 /// \return True if V1 is different than V2\r
201 ///\r
202 ////////////////////////////////////////////////////////////\r
203 template <typename T>\r
204 bool operator !=(const Vector2<T>& V1, const Vector2<T>& V2);\r
205 \r
206 #include <SFML/System/Vector2.inl>\r
207 \r
208 // Define the most common types\r
209 typedef Vector2<int>   Vector2i;\r
210 typedef Vector2<float> Vector2f;\r
211 \r
212 } // namespace sf\r
213 \r
214 \r
215 #endif // SFML_VECTOR2_HPP\r