diff options
| author | 2017-01-07 12:39:20 -0500 | |
|---|---|---|
| committer | 2017-01-07 12:39:20 -0500 | |
| 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.gz yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.xz yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.zip | |
Merge pull request #1951 from wwylele/motion-sensor
Emulate motion sensor in frontend
Diffstat (limited to '')
| -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) { | |||
| 186 | 186 | ||
| 187 | typedef Vec2<float> Vec2f; | 187 | typedef Vec2<float> Vec2f; |
| 188 | 188 | ||
| 189 | template <> | ||
| 190 | inline float Vec2<float>::Length() const { | ||
| 191 | return std::sqrt(x * x + y * y); | ||
| 192 | } | ||
| 193 | |||
| 194 | template <> | ||
| 195 | inline float Vec2<float>::Normalize() { | ||
| 196 | float length = Length(); | ||
| 197 | *this /= length; | ||
| 198 | return length; | ||
| 199 | } | ||
| 200 | |||
| 189 | template <typename T> | 201 | template <typename T> |
| 190 | class Vec3 { | 202 | class Vec3 { |
| 191 | public: | 203 | public: |
| @@ -388,6 +400,13 @@ inline Vec3<float> Vec3<float>::Normalized() const { | |||
| 388 | return *this / Length(); | 400 | return *this / Length(); |
| 389 | } | 401 | } |
| 390 | 402 | ||
| 403 | template <> | ||
| 404 | inline float Vec3<float>::Normalize() { | ||
| 405 | float length = Length(); | ||
| 406 | *this /= length; | ||
| 407 | return length; | ||
| 408 | } | ||
| 409 | |||
| 391 | typedef Vec3<float> Vec3f; | 410 | typedef Vec3<float> Vec3f; |
| 392 | 411 | ||
| 393 | template <typename T> | 412 | template <typename T> |