summaryrefslogtreecommitdiffstats
path: root/Vector.h
diff options
context:
space:
mode:
Diffstat (limited to 'Vector.h')
-rw-r--r--Vector.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/Vector.h b/Vector.h
index ece1230..f03c4b4 100644
--- a/Vector.h
+++ b/Vector.h
@@ -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) {