SFML logo
  • Main Page
  • Modules
  • 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 template <typename U>
00049 inline Vector2<T>::Vector2(const Vector2<U>& vector) :
00050 x(static_cast<T>(vector.x)),
00051 y(static_cast<T>(vector.y))
00052 {
00053 }
00054 
00055 
00057 template <typename T>
00058 inline Vector2<T> operator -(const Vector2<T>& right)
00059 {
00060     return Vector2<T>(-right.x, -right.y);
00061 }
00062 
00063 
00065 template <typename T>
00066 inline Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right)
00067 {
00068     left.x += right.x;
00069     left.y += right.y;
00070 
00071     return left;
00072 }
00073 
00074 
00076 template <typename T>
00077 inline Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right)
00078 {
00079     left.x -= right.x;
00080     left.y -= right.y;
00081 
00082     return left;
00083 }
00084 
00085 
00087 template <typename T>
00088 inline Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right)
00089 {
00090     return Vector2<T>(left.x + right.x, left.y + right.y);
00091 }
00092 
00093 
00095 template <typename T>
00096 inline Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right)
00097 {
00098     return Vector2<T>(left.x - right.x, left.y - right.y);
00099 }
00100 
00101 
00103 template <typename T>
00104 inline Vector2<T> operator *(const Vector2<T>& left, T right)
00105 {
00106     return Vector2<T>(left.x * right, left.y * right);
00107 }
00108 
00109 
00111 template <typename T>
00112 inline Vector2<T> operator *(T left, const Vector2<T>& right)
00113 {
00114     return Vector2<T>(right.x * left, right.y * left);
00115 }
00116 
00117 
00119 template <typename T>
00120 inline Vector2<T>& operator *=(Vector2<T>& left, T right)
00121 {
00122     left.x *= right;
00123     left.y *= right;
00124 
00125     return left;
00126 }
00127 
00128 
00130 template <typename T>
00131 inline Vector2<T> operator /(const Vector2<T>& left, T right)
00132 {
00133     return Vector2<T>(left.x / right, left.y / right);
00134 }
00135 
00136 
00138 template <typename T>
00139 inline Vector2<T>& operator /=(Vector2<T>& left, T right)
00140 {
00141     left.x /= right;
00142     left.y /= right;
00143 
00144     return left;
00145 }
00146 
00147 
00149 template <typename T>
00150 inline bool operator ==(const Vector2<T>& left, const Vector2<T>& right)
00151 {
00152     return (left.x == right.x) && (left.y == right.y);
00153 }
00154 
00155 
00157 template <typename T>
00158 inline bool operator !=(const Vector2<T>& left, const Vector2<T>& right)
00159 {
00160     return (left.x != right.x) || (left.y != right.y);
00161 }

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