diff options
author | bunnei <bunneidev@gmail.com> | 2017-01-07 18:39:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-07 18:39:20 +0100 |
commit | 7cfe3ef0463ace034b1e5786c9581cfa5f2e810c (patch) | |
tree | 6b06cb03d276b29070ca29599fc4c5fcf77edb39 /src/common/vector_math.h | |
parent | Merge pull request #2410 from Subv/sleepthread (diff) | |
parent | Frontend: make motion sensor interfaced thread-safe (diff) | |
download | yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.gz yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.bz2 yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.lz yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.xz yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.zst yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.zip |
Diffstat (limited to 'src/common/vector_math.h')
-rw-r--r-- | src/common/vector_math.h | 19 |
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) { typedef Vec2<float> Vec2f; +template <> +inline float Vec2<float>::Length() const { + return std::sqrt(x * x + y * y); +} + +template <> +inline float Vec2<float>::Normalize() { + float length = Length(); + *this /= length; + return length; +} + template <typename T> class Vec3 { public: @@ -388,6 +400,13 @@ inline Vec3<float> Vec3<float>::Normalized() const { return *this / Length(); } +template <> +inline float Vec3<float>::Normalize() { + float length = Length(); + *this /= length; + return length; +} + typedef Vec3<float> Vec3f; template <typename T> |