Warning, /include/SFML/System/Vector2.inl is written in an unsupported language. File is not indexed.
0001 ////////////////////////////////////////////////////////////
0002 //
0003 // SFML - Simple and Fast Multimedia Library
0004 // Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org)
0005 //
0006 // This software is provided 'as-is', without any express or implied warranty.
0007 // In no event will the authors be held liable for any damages arising from the use of this software.
0008 //
0009 // Permission is granted to anyone to use this software for any purpose,
0010 // including commercial applications, and to alter it and redistribute it freely,
0011 // subject to the following restrictions:
0012 //
0013 // 1. The origin of this software must not be misrepresented;
0014 // you must not claim that you wrote the original software.
0015 // If you use this software in a product, an acknowledgment
0016 // in the product documentation would be appreciated but is not required.
0017 //
0018 // 2. Altered source versions must be plainly marked as such,
0019 // and must not be misrepresented as being the original software.
0020 //
0021 // 3. This notice may not be removed or altered from any source distribution.
0022 //
0023 ////////////////////////////////////////////////////////////
0024
0025
0026 ////////////////////////////////////////////////////////////
0027 template <typename T>
0028 inline Vector2<T>::Vector2() :
0029 x(0),
0030 y(0)
0031 {
0032
0033 }
0034
0035
0036 ////////////////////////////////////////////////////////////
0037 template <typename T>
0038 inline Vector2<T>::Vector2(T X, T Y) :
0039 x(X),
0040 y(Y)
0041 {
0042
0043 }
0044
0045
0046 ////////////////////////////////////////////////////////////
0047 template <typename T>
0048 template <typename U>
0049 inline Vector2<T>::Vector2(const Vector2<U>& vector) :
0050 x(static_cast<T>(vector.x)),
0051 y(static_cast<T>(vector.y))
0052 {
0053 }
0054
0055
0056 ////////////////////////////////////////////////////////////
0057 template <typename T>
0058 inline Vector2<T> operator -(const Vector2<T>& right)
0059 {
0060 return Vector2<T>(-right.x, -right.y);
0061 }
0062
0063
0064 ////////////////////////////////////////////////////////////
0065 template <typename T>
0066 inline Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right)
0067 {
0068 left.x += right.x;
0069 left.y += right.y;
0070
0071 return left;
0072 }
0073
0074
0075 ////////////////////////////////////////////////////////////
0076 template <typename T>
0077 inline Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right)
0078 {
0079 left.x -= right.x;
0080 left.y -= right.y;
0081
0082 return left;
0083 }
0084
0085
0086 ////////////////////////////////////////////////////////////
0087 template <typename T>
0088 inline Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right)
0089 {
0090 return Vector2<T>(left.x + right.x, left.y + right.y);
0091 }
0092
0093
0094 ////////////////////////////////////////////////////////////
0095 template <typename T>
0096 inline Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right)
0097 {
0098 return Vector2<T>(left.x - right.x, left.y - right.y);
0099 }
0100
0101
0102 ////////////////////////////////////////////////////////////
0103 template <typename T>
0104 inline Vector2<T> operator *(const Vector2<T>& left, T right)
0105 {
0106 return Vector2<T>(left.x * right, left.y * right);
0107 }
0108
0109
0110 ////////////////////////////////////////////////////////////
0111 template <typename T>
0112 inline Vector2<T> operator *(T left, const Vector2<T>& right)
0113 {
0114 return Vector2<T>(right.x * left, right.y * left);
0115 }
0116
0117
0118 ////////////////////////////////////////////////////////////
0119 template <typename T>
0120 inline Vector2<T>& operator *=(Vector2<T>& left, T right)
0121 {
0122 left.x *= right;
0123 left.y *= right;
0124
0125 return left;
0126 }
0127
0128
0129 ////////////////////////////////////////////////////////////
0130 template <typename T>
0131 inline Vector2<T> operator /(const Vector2<T>& left, T right)
0132 {
0133 return Vector2<T>(left.x / right, left.y / right);
0134 }
0135
0136
0137 ////////////////////////////////////////////////////////////
0138 template <typename T>
0139 inline Vector2<T>& operator /=(Vector2<T>& left, T right)
0140 {
0141 left.x /= right;
0142 left.y /= right;
0143
0144 return left;
0145 }
0146
0147
0148 ////////////////////////////////////////////////////////////
0149 template <typename T>
0150 inline bool operator ==(const Vector2<T>& left, const Vector2<T>& right)
0151 {
0152 return (left.x == right.x) && (left.y == right.y);
0153 }
0154
0155
0156 ////////////////////////////////////////////////////////////
0157 template <typename T>
0158 inline bool operator !=(const Vector2<T>& left, const Vector2<T>& right)
0159 {
0160 return (left.x != right.x) || (left.y != right.y);
0161 }