diff options
Diffstat (limited to 'Vector.h')
-rw-r--r-- | Vector.h | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -2,6 +2,7 @@ #define _VECTOR_H_ #include "Vertex.h" +#include <math.h> class Vector : public Vertex { public: @@ -41,6 +42,14 @@ class Vector : public Vertex { float dot(const Vector &v) const { return x*v.x + y*v.y + z*v.z; } + + float length() const { + return sqrtf(x*x+y*y+z*z); + } + + Vector normalize() const { + return *this/length(); + } }; static inline Vector operator-(const Vertex &v1, const Vertex &v2) { |