SFML - Simple and Fast Multimedia Library

SFML 2.5.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

Vector2.hpp
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
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{
36template <typename T>
37 class Vector2
38{
39public:
40
47 Vector2();
48
56 Vector2(T X, T Y);
57
69 template <typename U>
70 explicit Vector2(const Vector2<U>& vector);
71
73 // Member data
75 T x;
76 T y;
77};
78
88template <typename T>
89 Vector2<T> operator -(const Vector2<T>& right);
90
104template <typename T>
105 Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right);
106
120template <typename T>
121 Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right);
122
133template <typename T>
134 Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right);
135
146template <typename T>
147 Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right);
148
159template <typename T>
160 Vector2<T> operator *(const Vector2<T>& left, T right);
161
172template <typename T>
173 Vector2<T> operator *(T left, const Vector2<T>& right);
174
188template <typename T>
189 Vector2<T>& operator *=(Vector2<T>& left, T right);
190
201template <typename T>
202 Vector2<T> operator /(const Vector2<T>& left, T right);
203
217template <typename T>
218 Vector2<T>& operator /=(Vector2<T>& left, T right);
219
232template <typename T>
233 bool operator ==(const Vector2<T>& left, const Vector2<T>& right);
234
247template <typename T>
248 bool operator !=(const Vector2<T>& left, const Vector2<T>& right);
249
250#include <SFML/System/Vector2.inl>
251
252// Define the most common types
253typedef Vector2<int> Vector2i;
254typedef Vector2<unsigned int> Vector2u;
255typedef Vector2<float> Vector2f;
256
257} // namespace sf
258
259
260#endif // SFML_VECTOR2_HPP
261
262
sf::Vector2
Utility template class for manipulating 2-dimensional vectors.
Definition: Vector2.hpp:38
sf::Vector2::x
T x
X coordinate of the vector.
Definition: Vector2.hpp:75
sf::Vector2::Vector2
Vector2(const Vector2< U > &vector)
Construct the vector from another type of vector.
sf::Vector2::y
T y
Y coordinate of the vector.
Definition: Vector2.hpp:76
sf::Vector2::Vector2
Vector2()
Default constructor.
sf::Vector2::Vector2
Vector2(T X, T Y)
Construct the vector from its coordinates.