diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-10-23 19:51:00 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-10-23 19:51:00 +0300 |
commit | 9d8a01dba195880c4b3bc8a5fb2914881b3abeca (patch) | |
tree | f1c048fb934bad730c4f577862de659dc5490072 /source/blender/blenlib | |
parent | d5fb0e517ca998ce39c3c3e46274b91f6d7e5124 (diff) |
BLI_math: add invert_qt_normalized
When the quat is known to be unit length, so we can avoid scaling
(just conjugate_qt which asserts on non unit quats).
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_math_rotation.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_rotation.c | 18 |
2 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h index ac9295c9035..4c4e305c965 100644 --- a/source/blender/blenlib/BLI_math_rotation.h +++ b/source/blender/blenlib/BLI_math_rotation.h @@ -59,6 +59,8 @@ void sub_qt_qtqt(float q[4], const float a[4], const float b[4]); void invert_qt(float q[4]); void invert_qt_qt(float q1[4], const float q2[4]); +void invert_qt_normalized(float q[4]); +void invert_qt_qt_normalized(float q1[4], const float q2[4]); void conjugate_qt(float q[4]); void conjugate_qt_qt(float q1[4], const float q2[4]); float dot_qtqt(const float a[4], const float b[4]); diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 949473a8d86..0ef3f046202 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -154,6 +154,24 @@ void invert_qt_qt(float q1[4], const float q2[4]) invert_qt(q1); } +/** + * This is just conjugate_qt for cases we know \a q is unit-length. + * we could use #conjugate_qt directly, but use this function to show intent, + * and assert if its ever becomes non-unit-length. + */ +void invert_qt_normalized(float q[4]) +{ + BLI_ASSERT_UNIT_QUAT(q); + conjugate_qt(q); + +} + +void invert_qt_qt_normalized(float q1[4], const float q2[4]) +{ + copy_qt_qt(q1, q2); + invert_qt_normalized(q1); +} + /* simple mult */ void mul_qt_fl(float q[4], const float f) { |