Skip to content

Commit

Permalink
Vector3f: add some numeric operations
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker committed Dec 28, 2015
1 parent 2ee9a08 commit e69b235
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Vector3f.h
Expand Up @@ -9,6 +9,32 @@ class Vector3f {
return vals[offset];
};

float operator [](size_t offset) const {
return vals[offset];
};

Vector3f operator +=(const Vector3f other) {
vals[0] += other[0];
vals[1] += other[1];
vals[2] += other[2];
return *this;
};

Vector3f operator /=(const uint64_t divisor) {
vals[0] /= (float)divisor;
vals[1] /= (float)divisor;
vals[2] /= (float)divisor;
return *this;
};

Vector3f operator -(const Vector3f other) {
Vector3f ret;
ret[0] = vals[0] - other[0];
ret[1] = vals[1] - other[1];
ret[2] = vals[2] - other[2];
return ret;
};

double len() const {
return sqrt(vals[0]*vals[0] + vals[1]*vals[1] + vals[2]*vals[2]);
}
Expand Down

0 comments on commit e69b235

Please sign in to comment.