summaryrefslogtreecommitdiffstats
path: root/Vector.h
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-12-09 16:28:58 +0100
committerMatthias Schiffer <matthias@gamezock.de>2009-12-09 16:28:58 +0100
commit8705ce3d468c3cd22159bc0fedf727e8250861ca (patch)
treef94debc4b7f52badac6052f016e9ab2f9232b095 /Vector.h
parent3035d4c9e76d6f28579d0b5a024e1c1b2a538919 (diff)
parent3b534c013dd072d0296ebaac434e8c943ab88c14 (diff)
downloadc3d-8705ce3d468c3cd22159bc0fedf727e8250861ca.tar
c3d-8705ce3d468c3cd22159bc0fedf727e8250861ca.zip
Merge branch 'master' of git://git.gamezock.de/c3d
Conflicts: DisplayClass.cpp
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) {