summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwwylele <wwylele@gmail.com>2016-12-11 22:28:55 +0100
committerwwylele <wwylele@gmail.com>2016-12-26 09:41:26 +0100
commit2e6d8e1321c81e29a85f46c0ff3c0280e3f95b9f (patch)
tree7402e977c2d1ea1f01f26ad08a21cdaf3e333bd6
parentMathUtil: add PI constant (diff)
downloadyuzu-2e6d8e1321c81e29a85f46c0ff3c0280e3f95b9f.tar
yuzu-2e6d8e1321c81e29a85f46c0ff3c0280e3f95b9f.tar.gz
yuzu-2e6d8e1321c81e29a85f46c0ff3c0280e3f95b9f.tar.bz2
yuzu-2e6d8e1321c81e29a85f46c0ff3c0280e3f95b9f.tar.lz
yuzu-2e6d8e1321c81e29a85f46c0ff3c0280e3f95b9f.tar.xz
yuzu-2e6d8e1321c81e29a85f46c0ff3c0280e3f95b9f.tar.zst
yuzu-2e6d8e1321c81e29a85f46c0ff3c0280e3f95b9f.zip
-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) {
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>