Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1.  
  2. // TESTED
  3. inline TVector2<T>& operator= (const TVector2<T>& other) { x = other.x; y = other.y; return *this; }
  4. // TESTED
  5. inline TVector2<T>& operator+= (const TVector2<T>& other) { x += other.x; y += other.y; return *this; }
  6. // TESTED
  7. inline TVector2<T>& operator-= (const TVector2<T>& other) { x -= other.x; y -= other.y; return *this; }
  8. // TESTED
  9. inline TVector2<T>& operator*= (const TVector2<T>& other) { x *= other.x; y *= other.y; return *this; }
  10. inline TVector2<T>& operator/= (const TVector2<T>& other) { x /= other.x; y /= other.y; return *this; }
  11. inline TVector2<T>& operator*= (const float& other) { x *= other; y *= other; return *this; }
  12. inline TVector2<T>& operator/= (const float& other) { x /= other; y /= other; return *this; }
  13.  
  14. // Unary operators
  15. inline TVector2<T> operator+ () const { return *this; }
  16. inline TVector2<T> operator- () const { return TVector2<T>(-x, -y); }
  17.  
  18. // Binary operators
  19. inline TVector2<T> operator+ (const TVector2<T>& other) const { return TVector2<T>(x + other.x, y + other.y); }
  20. inline TVector2<T> operator- (const TVector2<T>& other) const { return TVector2<T>(x - other.x, y - other.y); }
  21. inline TVector2<T> operator* (const TVector2<T>& other) const { return TVector2<T>(x * other.x, y * other.y); }
  22. inline TVector2<T> operator/ (const TVector2<T>& other) const { return TVector2<T>(x / other.x, y / other.y); }
  23. inline TVector2<T> operator+ (const float& other) const { return TVector2<T>(x + other, y + other); }
  24. inline TVector2<T> operator- (const float& other) const { return TVector2<T>(x - other, y - other); }
  25. inline TVector2<T> operator* (const float& other) const { return TVector2<T>(x * other, y * other); }
  26. inline TVector2<T> operator/ (const float& other) const { return TVector2<T>(x / other, y / other); }
  27.  
  28. // Boolean operators
  29. inline bool operator== (const TVector2<T>& other) const { return x == other.x && y == other.y; }
  30. inline bool operator!= (const TVector2<T>& other) const { return x != other.x && y != other.y; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement