diff options
Diffstat (limited to 'Vector.h')
-rw-r--r-- | Vector.h | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -1,14 +1,16 @@ #ifndef _VECTOR_H_ #define _VECTOR_H_ -#include "Vertex.h" -#include <math.h> +#include <cmath> -class Vector : public Vertex { +class Vector { public: - Vector(float x0 = 0, float y0 = 0, float z0 = 0) : Vertex(x0, y0, z0) {} - Vector(const Vertex &v) : Vertex(v) {} + Vector(float x0 = 0, float y0 = 0, float z0 = 0) : x(x0), y(y0), z(z0) {} + float getX() const {return x;} + float getY() const {return y;} + float getZ() const {return z;} + Vector operator+(const Vector &v) const { return Vector(x+v.x, y+v.y, z+v.z); } @@ -50,11 +52,10 @@ class Vector : public Vertex { Vector normalize() const { return *this/length(); } -}; -static inline Vector operator-(const Vertex &v1, const Vertex &v2) { - return Vector(v1.getX()-v2.getX(), v1.getY()-v2.getY(), v1.getZ()-v2.getZ()); -} + protected: + float x, y, z; +}; #endif /*_VECTOR_H_*/ |