diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-12-09 16:28:58 +0100 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-12-09 16:28:58 +0100 |
commit | 8705ce3d468c3cd22159bc0fedf727e8250861ca (patch) | |
tree | f94debc4b7f52badac6052f016e9ab2f9232b095 /Vector.h | |
parent | 3035d4c9e76d6f28579d0b5a024e1c1b2a538919 (diff) | |
parent | 3b534c013dd072d0296ebaac434e8c943ab88c14 (diff) | |
download | c3d-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.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) { |