Onsens  1.0
This is C++ game about bitwise logic.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Vector2.inl
Go to the documentation of this file.
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
27template <typename T>
29x(0),
30y(0)
31{
32
33}
34
35
37template <typename T>
38inline Vector2<T>::Vector2(T X, T Y) :
39x(X),
40y(Y)
41{
42
43}
44
45
47template <typename T>
48template <typename U>
49inline Vector2<T>::Vector2(const Vector2<U>& vector) :
50x(static_cast<T>(vector.x)),
51y(static_cast<T>(vector.y))
52{
53}
54
55
57template <typename T>
58inline Vector2<T> operator -(const Vector2<T>& right)
59{
60 return Vector2<T>(-right.x, -right.y);
61}
62
63
65template <typename T>
66inline Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right)
67{
68 left.x += right.x;
69 left.y += right.y;
70
71 return left;
72}
73
74
76template <typename T>
77inline Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right)
78{
79 left.x -= right.x;
80 left.y -= right.y;
81
82 return left;
83}
84
85
87template <typename T>
88inline Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right)
89{
90 return Vector2<T>(left.x + right.x, left.y + right.y);
91}
92
93
95template <typename T>
96inline Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right)
97{
98 return Vector2<T>(left.x - right.x, left.y - right.y);
99}
100
101
103template <typename T>
104inline Vector2<T> operator *(const Vector2<T>& left, T right)
105{
106 return Vector2<T>(left.x * right, left.y * right);
107}
108
109
111template <typename T>
112inline Vector2<T> operator *(T left, const Vector2<T>& right)
113{
114 return Vector2<T>(right.x * left, right.y * left);
115}
116
117
119template <typename T>
120inline Vector2<T>& operator *=(Vector2<T>& left, T right)
121{
122 left.x *= right;
123 left.y *= right;
124
125 return left;
126}
127
128
130template <typename T>
131inline Vector2<T> operator /(const Vector2<T>& left, T right)
132{
133 return Vector2<T>(left.x / right, left.y / right);
134}
135
136
138template <typename T>
139inline Vector2<T>& operator /=(Vector2<T>& left, T right)
140{
141 left.x /= right;
142 left.y /= right;
143
144 return left;
145}
146
147
149template <typename T>
150inline bool operator ==(const Vector2<T>& left, const Vector2<T>& right)
151{
152 return (left.x == right.x) && (left.y == right.y);
153}
154
155
157template <typename T>
158inline bool operator !=(const Vector2<T>& left, const Vector2<T>& right)
159{
160 return (left.x != right.x) || (left.y != right.y);
161}
Vector2< T > & operator-=(Vector2< T > &left, const Vector2< T > &right)
Definition: Vector2.inl:77
Vector2< T > operator-(const Vector2< T > &right)
Definition: Vector2.inl:58
Vector2< T > operator*(const Vector2< T > &left, T right)
Definition: Vector2.inl:104
Vector2< T > operator+(const Vector2< T > &left, const Vector2< T > &right)
Definition: Vector2.inl:88
Vector2< T > operator/(const Vector2< T > &left, T right)
Definition: Vector2.inl:131
Vector2< T > & operator*=(Vector2< T > &left, T right)
Definition: Vector2.inl:120
Vector2< T > & operator/=(Vector2< T > &left, T right)
Definition: Vector2.inl:139
Vector2< T > & operator+=(Vector2< T > &left, const Vector2< T > &right)
Definition: Vector2.inl:66
Utility template class for manipulating 2-dimensional vectors.
Definition: Vector2.hpp:38
Vector2()
Default constructor.
SFML_NETWORK_API bool operator==(const IpAddress &left, const IpAddress &right)
Overload of == operator to compare two IP addresses.
SFML_NETWORK_API bool operator!=(const IpAddress &left, const IpAddress &right)
Overload of != operator to compare two IP addresses.