MikeRohsoft

Untitled

May 15th, 2017
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.75 KB | None | 0 0
  1. class Vector3
  2. {
  3. public:
  4.     float x;
  5.     float padding_0;
  6.     float y;
  7.     float padding_1;
  8.     float z;
  9.     float padding_2;
  10.     Vector3()
  11.     {
  12.  
  13.     }
  14.     Vector3(float x, float y, float z)
  15.     {
  16.         Vector3::x = x;
  17.         Vector3::y = y;
  18.         Vector3::z = z;
  19.     }
  20.     Vector3 operator+(const Vector3& v)
  21.     {
  22.         Vector3 vec;
  23.         vec.x = this->x + v.x;
  24.         vec.y = this->y + v.y;
  25.         vec.z = this->z + v.z;
  26.         return vec;
  27.     }
  28.     Vector3 operator+(const float& v)
  29.     {
  30.         Vector3 vec;
  31.         vec.x = this->x + v;
  32.         vec.y = this->y + v;
  33.         vec.z = this->z + v;
  34.         return vec;
  35.     }
  36.     Vector3& operator+=(const float v)
  37.     {
  38.         this->x += v;
  39.         this->y += v;
  40.         this->z += v;
  41.         return *this;
  42.     }
  43.     Vector3 operator+=(const Vector3& v)
  44.     {
  45.         this->x += v.x;
  46.         this->y += v.y;
  47.         this->z += v.z;
  48.         return *this;
  49.     }
  50.     Vector3 operator-(const Vector3& v)
  51.     {
  52.         Vector3 vec;
  53.         vec.x = this->x - v.x;
  54.         vec.y = this->y - v.y;
  55.         vec.z = this->z - v.z;
  56.         return vec;
  57.     }
  58.     Vector3 operator-(const float& v)
  59.     {
  60.         Vector3 vec;
  61.         vec.x = this->x - v;
  62.         vec.y = this->y - v;
  63.         vec.z = this->z - v;
  64.         return vec;
  65.     }
  66.     Vector3& operator-=(const float v)
  67.     {
  68.         this->x -= v;
  69.         this->y -= v;
  70.         this->z -= v;
  71.         return *this;
  72.     }
  73.     Vector3 operator-=(const Vector3& v)
  74.     {
  75.         this->x -= v.x;
  76.         this->y -= v.y;
  77.         this->z -= v.z;
  78.         return *this;
  79.     }
  80.     Vector3 operator*(const Vector3& v)
  81.     {
  82.         Vector3 vec;
  83.         vec.x = this->x * v.x;
  84.         vec.y = this->y * v.y;
  85.         vec.z = this->z * v.z;
  86.         return vec;
  87.     }
  88.     Vector3 operator*(const float& v)
  89.     {
  90.         Vector3 vec;
  91.         vec.x = this->x * v;
  92.         vec.y = this->y * v;
  93.         vec.z = this->z * v;
  94.         return vec;
  95.     }
  96.     Vector3& operator*=(const float v)
  97.     {
  98.         this->x *= v;
  99.         this->y *= v;
  100.         this->z *= v;
  101.         return *this;
  102.     }
  103.     Vector3 operator*=(const Vector3& v)
  104.     {
  105.         this->x *= v.x;
  106.         this->y *= v.y;
  107.         this->z *= v.z;
  108.         return *this;
  109.     }
  110.     Vector3 operator/(const Vector3& v)
  111.     {
  112.         Vector3 vec;
  113.         vec.x = this->x / v.x;
  114.         vec.y = this->y / v.y;
  115.         vec.z = this->z / v.z;
  116.         return vec;
  117.     }
  118.     Vector3 operator/(const float& v)
  119.     {
  120.         Vector3 vec;
  121.         vec.x = this->x / v;
  122.         vec.y = this->y / v;
  123.         vec.z = this->z / v;
  124.         return vec;
  125.     }
  126.     Vector3& operator/=(const float v)
  127.     {
  128.         this->x /= v;
  129.         this->y /= v;
  130.         this->z /= v;
  131.         return *this;
  132.     }
  133.     Vector3 operator/=(const Vector3& v)
  134.     {
  135.         this->x /= v.x;
  136.         this->y /= v.y;
  137.         this->z /= v.z;
  138.         return *this;
  139.     }
  140.     int size(const Vector3& v)
  141.     {
  142.         double x = (double)v.x;
  143.         double y = (double)v.y;
  144.         double z = (double)v.z;
  145.         return (int)sqrt(x*x + y*y + z*z);
  146.     }
  147. };
  148.  
  149. class CVector3
  150. {
  151. public:
  152.     float x, y, z;
  153.     CVector3()
  154.     {
  155.  
  156.     }
  157.     CVector3(float x, float y, float z)
  158.     {
  159.         CVector3::x = x;
  160.         CVector3::y = y;
  161.         CVector3::z = z;
  162.     }
  163.     explicit operator Vector3() const
  164.     {
  165.         return Vector3(this->x, this->y, this->z);
  166.     }
  167. };
Advertisement
Add Comment
Please, Sign In to add comment