SFML logo
  • Main Page
  • Namespaces
  • Classes
  • Files
  • File List

Vector2.inl

00001 
00002 //
00003 // SFML - Simple and Fast Multimedia Library
00004 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
00005 //
00006 // This software is provided 'as-is', without any express or implied warranty.
00007 // In no event will the authors be held liable for any damages arising from the use of this software.
00008 //
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it freely,
00011 // subject to the following restrictions:
00012 //
00013 // 1. The origin of this software must not be misrepresented;
00014 //    you must not claim that you wrote the original software.
00015 //    If you use this software in a product, an acknowledgment
00016 //    in the product documentation would be appreciated but is not required.
00017 //
00018 // 2. Altered source versions must be plainly marked as such,
00019 //    and must not be misrepresented as being the original software.
00020 //
00021 // 3. This notice may not be removed or altered from any source distribution.
00022 //
00024 
00025 
00027 template <typename T>
00028 inline Vector2<T>::Vector2() :
00029 x(0),
00030 y(0)
00031 {
00032 
00033 }
00034 
00035 
00037 template <typename T>
00038 inline Vector2<T>::Vector2(T X, T Y) :
00039 x(X),
00040 y(Y)
00041 {
00042 
00043 }
00044 
00045 
00047 template <typename T>
00048 inline Vector2<T> operator -(const Vector2<T>& right)
00049 {
00050     return Vector2<T>(-right.x, -right.y);
00051 }
00052 
00053 
00055 template <typename T>
00056 inline Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right)
00057 {
00058     left.x += right.x;
00059     left.y += right.y;
00060 
00061     return left;
00062 }
00063 
00064 
00066 template <typename T>
00067 inline Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right)
00068 {
00069     left.x -= right.x;
00070     left.y -= right.y;
00071 
00072     return left;
00073 }
00074 
00075 
00077 template <typename T>
00078 inline Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right)
00079 {
00080     return Vector2<T>(left.x + right.x, left.y + right.y);
00081 }
00082 
00083 
00085 template <typename T>
00086 inline Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right)
00087 {
00088     return Vector2<T>(left.x - right.x, left.y - right.y);
00089 }
00090 
00091 
00093 template <typename T>
00094 inline Vector2<T> operator *(const Vector2<T>& left, T right)
00095 {
00096     return Vector2<T>(left.x * right, left.y * right);
00097 }
00098 
00099 
00101 template <typename T>
00102 inline Vector2<T> operator *(T left, const Vector2<T>& right)
00103 {
00104     return Vector2<T>(right.x * left, right.y * left);
00105 }
00106 
00107 
00109 template <typename T>
00110 inline Vector2<T>& operator *=(Vector2<T>& left, T right)
00111 {
00112     left.x *= right;
00113     left.y *= right;
00114 
00115     return left;
00116 }
00117 
00118 
00120 template <typename T>
00121 inline Vector2<T> operator /(const Vector2<T>& left, T right)
00122 {
00123     return Vector2<T>(left.x / right, left.y / right);
00124 }
00125 
00126 
00128 template <typename T>
00129 inline Vector2<T>& operator /=(Vector2<T>& left, T right)
00130 {
00131     left.x /= right;
00132     left.y /= right;
00133 
00134     return left;
00135 }
00136 
00137 
00139 template <typename T>
00140 inline bool operator ==(const Vector2<T>& left, const Vector2<T>& right)
00141 {
00142     return (left.x == right.x) && (left.y == right.y);
00143 }
00144 
00145 
00147 template <typename T>
00148 inline bool operator !=(const Vector2<T>& left, const Vector2<T>& right)
00149 {
00150     return (left.x != right.x) || (left.y != right.y);
00151 }

 ::  Copyright © 2007-2008 Laurent Gomila, all rights reserved  ::  Documentation generated by doxygen 1.5.2  ::