diff options
Diffstat (limited to 'core/math/quaternion.h')
-rw-r--r-- | core/math/quaternion.h | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/core/math/quaternion.h b/core/math/quaternion.h index 2575d7d229..9801746659 100644 --- a/core/math/quaternion.h +++ b/core/math/quaternion.h @@ -36,8 +36,7 @@ #include "core/math/vector3.h" #include "core/string/ustring.h" -class _NO_DISCARD_ Quaternion { -public: +struct _NO_DISCARD_ Quaternion { union { struct { real_t x; @@ -61,6 +60,8 @@ public: Quaternion normalized() const; bool is_normalized() const; Quaternion inverse() const; + Quaternion log() const; + Quaternion exp() const; _FORCE_INLINE_ real_t dot(const Quaternion &p_q) const; real_t angle_to(const Quaternion &p_to) const; @@ -146,19 +147,19 @@ public: Vector3 c = v0.cross(v1); real_t d = v0.dot(v1); - if (d < -1.0 + CMP_EPSILON) { + if (d < -1.0f + (real_t)CMP_EPSILON) { x = 0; y = 1; z = 0; w = 0; } else { - real_t s = Math::sqrt((1.0 + d) * 2.0); - real_t rs = 1.0 / s; + real_t s = Math::sqrt((1.0f + d) * 2.0f); + real_t rs = 1.0f / s; x = c.x * rs; y = c.y * rs; z = c.z * rs; - w = s * 0.5; + w = s * 0.5f; } } }; @@ -193,7 +194,7 @@ void Quaternion::operator*=(const real_t &s) { } void Quaternion::operator/=(const real_t &s) { - *this *= 1.0 / s; + *this *= 1.0f / s; } Quaternion Quaternion::operator+(const Quaternion &q2) const { @@ -216,7 +217,7 @@ Quaternion Quaternion::operator*(const real_t &s) const { } Quaternion Quaternion::operator/(const real_t &s) const { - return *this * (1.0 / s); + return *this * (1.0f / s); } bool Quaternion::operator==(const Quaternion &p_quaternion) const { |