diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-06-18 12:35:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-18 12:35:58 +0200 |
commit | 7aebb8f81c44f5f33c4387d32824a76e46266732 (patch) | |
tree | b09b30950ae57cb6d7a543678e65aeefbfd52b70 /core/math/quaternion.cpp | |
parent | 3fc39954ec3473cc022af615c5eb8b1ba271e008 (diff) | |
parent | 93b494d4ae136f43193a5a2da7a355938517767e (diff) |
Merge pull request #44156 from aaronfranke/quat-angle-to
Add Quaternion angle_to method
Diffstat (limited to 'core/math/quaternion.cpp')
-rw-r--r-- | core/math/quaternion.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/core/math/quaternion.cpp b/core/math/quaternion.cpp index 7037db7112..3f1d2c58e5 100644 --- a/core/math/quaternion.cpp +++ b/core/math/quaternion.cpp @@ -33,6 +33,11 @@ #include "core/math/basis.h" #include "core/string/print_string.h" +real_t Quaternion::angle_to(const Quaternion &p_to) const { + real_t d = dot(p_to); + return Math::acos(CLAMP(d * d * 2 - 1, -1, 1)); +} + // get_euler_xyz returns a vector containing the Euler angles in the format // (ax,ay,az), where ax is the angle of rotation around x axis, // and similar for other axes. |