Guest User

Vector2.h

a guest
Dec 2nd, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include "Util.h"
  4.  
  5. #include <iostream>
  6.  
  7. /*
  8. Basic Vector class to avoid depndency on glm. This class
  9. is a exception on it's styling, since normally the codebase uses
  10. getters and setters instead of public variables. Also the m_
  11. prefix on class variables is not used on the Vector class.
  12. */
  13. class TVector2
  14. {
  15. public:
  16.     TVector2();
  17.     TVector2(int x, int y);
  18.     TVector2(float x, float y);
  19.     ~TVector2();
  20.  
  21.     TVector2 operator+(const TVector2& other);
  22.     TVector2 operator+=(const TVector2& other);
  23.     TVector2 operator+(float other);
  24.     TVector2 operator-(const TVector2& other);
  25.     TVector2 operator-(float other);
  26.     TVector2 operator-();
  27.     TVector2 operator*(const TVector2& other);
  28.     TVector2 operator*(float other);
  29.     TVector2 operator/(float other);
  30.     bool operator==(const TVector2& other);
  31.     friend std::ostream &operator<<(std::ostream &out, TVector2 vector)
  32.     {
  33.         out << "X:" << vector.X << " Y:" << vector.Y;
  34.         return out;
  35.     }
  36.  
  37.     float X;
  38.     float Y;
  39.  
  40.     void Abs();
  41.  
  42.     void Clamp(TVector2 minValue, TVector2 maxValue);
  43.  
  44.     static TVector2 Lerp(TVector2 vector1, TVector2 vector2, float amount);
  45.     static TVector2 Random(int minValue, int maxValue);
  46.     static TVector2 Random(TVector2 minValue, TVector2 maxValue);
  47.  
  48.     int GetLenght();
  49. protected:
  50. private:
  51. };
Advertisement
Add Comment
Please, Sign In to add comment