summaryrefslogtreecommitdiffstats
path: root/Vector.h
diff options
context:
space:
mode:
authorConstantin Riß <constantin.riss@dre.de>2009-12-09 15:59:14 +0100
committerConstantin Riß <constantin.riss@dre.de>2009-12-09 15:59:14 +0100
commit3b534c013dd072d0296ebaac434e8c943ab88c14 (patch)
tree13e3d7315ccc816a2b9d07a58e98655618177b03 /Vector.h
parent482852aceacb54879c08e6fffc909a2cc160d483 (diff)
downloadc3d-3b534c013dd072d0296ebaac434e8c943ab88c14.tar
c3d-3b534c013dd072d0296ebaac434e8c943ab88c14.zip
Beleuchtung hinzugefügt
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 f884c49..cb55637 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:
@@ -33,6 +34,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) {