summaryrefslogtreecommitdiff
path: root/src/common/vector_math.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/common/vector_math.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/common/vector_math.h b/src/common/vector_math.h
index a57d86d88..7ca8e15f5 100644
--- a/src/common/vector_math.h
+++ b/src/common/vector_math.h
@@ -186,6 +186,18 @@ Vec2<T> operator*(const V& f, const Vec2<T>& vec) {
186 186
187typedef Vec2<float> Vec2f; 187typedef Vec2<float> Vec2f;
188 188
189template <>
190inline float Vec2<float>::Length() const {
191 return std::sqrt(x * x + y * y);
192}
193
194template <>
195inline float Vec2<float>::Normalize() {
196 float length = Length();
197 *this /= length;
198 return length;
199}
200
189template <typename T> 201template <typename T>
190class Vec3 { 202class Vec3 {
191public: 203public:
@@ -388,6 +400,13 @@ inline Vec3<float> Vec3<float>::Normalized() const {
388 return *this / Length(); 400 return *this / Length();
389} 401}
390 402
403template <>
404inline float Vec3<float>::Normalize() {
405 float length = Length();
406 *this /= length;
407 return length;
408}
409
391typedef Vec3<float> Vec3f; 410typedef Vec3<float> Vec3f;
392 411
393template <typename T> 412template <typename T>