diff options
author | Weiyi Wang <wwylele@gmail.com> | 2017-08-09 18:54:29 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-09 18:54:29 +0300 |
commit | 792dee47a7b520cb2a8d7cf43cc184c17394708f (patch) | |
tree | 35b14f184d95834bed51d3fda5c9662355e8b7f7 /src/common/quaternion.h | |
parent | 93ab46e500584d7b56e430f4552516a0e72cb398 (diff) | |
parent | 2252a63f8036cdf2612243271ce29e6104f82825 (diff) |
Merge pull request #2822 from wwylele/sw_lighting-2
Implement fragment lighting in the sw renderer (take 2)
Diffstat (limited to 'src/common/quaternion.h')
-rw-r--r-- | src/common/quaternion.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/common/quaternion.h b/src/common/quaternion.h index 84ac82ed3..77f626bcb 100644 --- a/src/common/quaternion.h +++ b/src/common/quaternion.h @@ -30,6 +30,11 @@ public: return {xyz * other.w + other.xyz * w + Cross(xyz, other.xyz), w * other.w - Dot(xyz, other.xyz)}; } + + Quaternion<T> Normalized() const { + T length = std::sqrt(xyz.Length2() + w * w); + return {xyz / length, w / length}; + } }; template <typename T> |