Skip to content
This repository
Browse code

added some vector operators

  • Loading branch information...
commit 7d2df3a38671f6e4b254576ced18d397828b8179 1 parent 7c300cc
oy oy authored

Showing 1 changed file with 15 additions and 0 deletions. Show diff stats Hide diff stats

  1. +15 0 src/base/vmath.h
15 src/base/vmath.h
@@ -25,12 +25,18 @@ class vector2_base
25 25 vector2_base operator -(const vector2_base &v) const { return vector2_base(x-v.x, y-v.y); }
26 26 vector2_base operator +(const vector2_base &v) const { return vector2_base(x+v.x, y+v.y); }
27 27 vector2_base operator *(const T v) const { return vector2_base(x*v, y*v); }
  28 + vector2_base operator *(const vector2_base &v) const { return vector2_base(x*v.x, y*v.y); }
  29 + vector2_base operator /(const T v) const { return vector3_base(x/v, y/v); }
  30 + vector2_base operator /(const vector2_base &v) const { return vector2_base(x/v.x, y/v.y); }
28 31
29 32 const vector2_base &operator =(const vector2_base &v) { x = v.x; y = v.y; return *this; }
30 33
31 34 const vector2_base &operator +=(const vector2_base &v) { x += v.x; y += v.y; return *this; }
32 35 const vector2_base &operator -=(const vector2_base &v) { x -= v.x; y -= v.y; return *this; }
33 36 const vector2_base &operator *=(const T v) { x *= v; y *= v; return *this; }
  37 + const vector2_base &operator *=(const vector2_base &v) { x *= v.x; y *= v.y; return *this; }
  38 + const vector2_base &operator /=(const T v) { x /= v; y /= v; return *this; }
  39 + const vector2_base &operator /=(const vector2_base &v) { x /= v.x; y /= v.y; return *this; }
34 40
35 41 bool operator ==(const vector2_base &v) const { return x == v.x && y == v.y; } //TODO: do this with an eps instead
36 42
@@ -107,10 +113,14 @@ class vector3_base
107 113 vector3_base operator *(const T v) const { return vector3_base(x*v, y*v, z*v); }
108 114 vector3_base operator *(const vector3_base &v) const { return vector3_base(x*v.x, y*v.y, z*v.z); }
109 115 vector3_base operator /(const T v) const { return vector3_base(x/v, y/v, z/v); }
  116 + vector3_base operator /(const vector3_base &v) const { return vector3_base(x/v.x, y/v.y, z/v.z); }
110 117
111 118 const vector3_base &operator +=(const vector3_base &v) { x += v.x; y += v.y; z += v.z; return *this; }
112 119 const vector3_base &operator -=(const vector3_base &v) { x -= v.x; y -= v.y; z -= v.z; return *this; }
113 120 const vector3_base &operator *=(const T v) { x *= v; y *= v; z *= v; return *this; }
  121 + const vector3_base &operator *=(const vector3_base &v) { x *= v.x; y *= v.y; z *= v.z; return *this; }
  122 + const vector3_base &operator /=(const T v) { x /= v; y /= v; z /= v; return *this; }
  123 + const vector3_base &operator /=(const vector3_base &v) { x /= v.x; y /= v.y; z /= v.z; return *this; }
114 124
115 125 bool operator ==(const vector3_base &v) const { return x == v.x && y == v.y && z == v.z; } //TODO: do this with an eps instead
116 126
@@ -180,12 +190,17 @@ class vector4_base
180 190 vector4_base operator -() const { return vector4_base(-x, -y, -z, -w); }
181 191 vector4_base operator *(const vector4_base &v) const { return vector4_base(x*v.x, y*v.y, z*v.z, w*v.w); }
182 192 vector4_base operator *(const T v) const { return vector4_base(x*v, y*v, z*v, w*v); }
  193 + vector4_base operator /(const vector4_base &v) const { return vector4_base(x/v.x, y/v.y, z/v.z, w/v.w); }
  194 + vector4_base operator /(const T v) const { return vector4_base(x/v, y/v, z/v, w/v); }
183 195
184 196 const vector4_base &operator =(const vector4_base &v) { x = v.x; y = v.y; z = v.z; w = v.w; return *this; }
185 197
186 198 const vector4_base &operator +=(const vector4_base &v) { x += v.x; y += v.y; z += v.z; w += v.w; return *this; }
187 199 const vector4_base &operator -=(const vector4_base &v) { x -= v.x; y -= v.y; z -= v.z; w -= v.w; return *this; }
188 200 const vector4_base &operator *=(const T v) { x *= v; y *= v; z *= v; w *= v; return *this; }
  201 + const vector4_base &operator *=(const vector4_base &v) { x *= v.x; y *= v.y; z *= v.z; w *= v.w; return *this; }
  202 + const vector4_base &operator /=(const T v) { x /= v; y /= v; z /= v; w /= v; return *this; }
  203 + const vector4_base &operator /=(const vector4_base &v) { x /= v.x; y /= v.y; z /= v.z; w /= v.w; return *this; }
189 204
190 205 bool operator ==(const vector4_base &v) const { return x == v.x && y == v.y && z == v.z && w == v.w; } //TODO: do this with an eps instead
191 206

0 comments on commit 7d2df3a

Please sign in to comment.
Something went wrong with that request. Please try again.