diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-03-20 07:39:32 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-03-20 08:15:29 +0400 |
commit | c6252d6e608a0dff72a8d5fde404fa6bd2c7ca7b (patch) | |
tree | 56367146d49417839143c93852298fcdebfc6648 /source/blender/blenlib/intern/math_rotation.c | |
parent | aee30184f3a2f332edf9eaf256a0a23beca26673 (diff) |
Math Lib: add angle_qt functions
Diffstat (limited to 'source/blender/blenlib/intern/math_rotation.c')
-rw-r--r-- | source/blender/blenlib/intern/math_rotation.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index d1753a77f7f..d7daa23c087 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -440,6 +440,44 @@ void rotation_between_quats_to_quat(float q[4], const float q1[4], const float q mul_qt_qtqt(q, tquat, q2); } + +float angle_normalized_qt(const float q[4]) +{ + BLI_ASSERT_UNIT_QUAT(q); + return 2.0f * saacos(q[0]); +} + +float angle_qt(const float q[4]) +{ + float tquat[4]; + + normalize_qt_qt(tquat, q); + + return angle_normalized_qt(tquat); +} + +float angle_normalized_qtqt(const float q1[4], const float q2[4]) +{ + float qdelta[4]; + + BLI_ASSERT_UNIT_QUAT(q1); + BLI_ASSERT_UNIT_QUAT(q2); + + rotation_between_quats_to_quat(qdelta, q1, q2); + + return angle_normalized_qt(qdelta); +} + +float angle_qtqt(const float q1[4], const float q2[4]) +{ + float quat1[4], quat2[4]; + + normalize_qt_qt(quat1, q1); + normalize_qt_qt(quat2, q2); + + return angle_normalized_qtqt(quat1, quat2); +} + void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag) { float nor[3], tvec[3]; |