Vector2.hpp
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#ifndef SFML_VECTOR2_HPP
26#define SFML_VECTOR2_HPP
27
28
29namespace sf
30{
31////////////////////////////////////////////////////////////
32/// Vector2 is an utility class for manipulating 2 dimensional
33/// vectors. Template parameter defines the type of coordinates
34/// (integer, float, ...)
35////////////////////////////////////////////////////////////
36template <typename T>
38{
39public :
40
43 ///
44 ////////////////////////////////////////////////////////////
46
49
54 Vector2(T X, T Y);
55
57 // Member data
59 T x;
60 T y;
61};
62
71template <typename T>
72Vector2<T> operator -(const Vector2<T>& V);
73
83template <typename T>
84Vector2<T>& operator +=(Vector2<T>& V1, const Vector2<T>& V2);
85
95template <typename T>
96Vector2<T>& operator -=(Vector2<T>& V1, const Vector2<T>& V2);
97
107template <typename T>
108Vector2<T> operator +(const Vector2<T>& V1, const Vector2<T>& V2);
109
119template <typename T>
120Vector2<T> operator -(const Vector2<T>& V1, const Vector2<T>& V2);
121
131template <typename T>
132Vector2<T> operator *(const Vector2<T>& V, T X);
133
143template <typename T>
144Vector2<T> operator *(T X, const Vector2<T>& V);
145
155template <typename T>
156Vector2<T>& operator *=(Vector2<T>& V, T X);
157
167template <typename T>
168Vector2<T> operator /(const Vector2<T>& V, T X);
169
179template <typename T>
180Vector2<T>& operator /=(Vector2<T>& V, T X);
181
191template <typename T>
192bool operator ==(const Vector2<T>& V1, const Vector2<T>& V2);
193
203template <typename T>
204bool operator !=(const Vector2<T>& V1, const Vector2<T>& V2);
205
206#include <SFML/System/Vector2.inl>
207
208// Define the most common types
209typedef Vector2<int> Vector2i;
210typedef Vector2<float> Vector2f;
211
212} // namespace sf
213
214
215#endif // SFML_VECTOR2_HPP
Vector2 is an utility class for manipulating 2 dimensional vectors.
Definition Vector2.hpp:38
Vector2()
Default constructor.
Definition Vector2.hpp:31
Vector2(T X, T Y)
Construct the vector from its coordinates.
Definition Vector2.hpp:43