diff options
Diffstat (limited to 'source/blender/blenlib/intern/math_rotation.c')
-rw-r--r-- | source/blender/blenlib/intern/math_rotation.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 6b5bf7743ef..a8cacb60f05 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -36,7 +36,7 @@ void unit_qt(float *q) q[1]= q[2]= q[3]= 0.0f; } -void copy_qt_qt(float *q1, float *q2) +void copy_qt_qt(float *q1, const float *q2) { q1[0]= q2[0]; q1[1]= q2[1]; @@ -49,7 +49,7 @@ int is_zero_qt(float *q) return (q[0] == 0 && q[1] == 0 && q[2] == 0 && q[3] == 0); } -void mul_qt_qtqt(float *q, float *q1, float *q2) +void mul_qt_qtqt(float *q, const float *q1, const float *q2) { float t0,t1,t2; @@ -104,6 +104,12 @@ void invert_qt(float *q) mul_qt_fl(q, 1.0f/f); } +void invert_qt_qt(float *q1, const float *q2) +{ + copy_qt_qt(q1, q2); + invert_qt(q1); +} + /* simple mult */ void mul_qt_fl(float *q, float f) { @@ -336,6 +342,23 @@ void rotation_between_vecs_to_quat(float *q, const float v1[3], const float v2[3 axis_angle_to_quat(q, axis, angle); } +void rotation_between_quats_to_quat(float *q, const float q1[4], const float q2[4]) +{ + float tquat[4]; + double dot = 0.0f; + int x; + + copy_qt_qt(tquat, q1); + conjugate_qt(tquat); + dot = 1.0f / dot_qtqt(tquat, tquat); + + for(x = 0; x < 4; x++) + tquat[x] *= dot; + + mul_qt_qtqt(q, tquat, q2); +} + + void vec_to_quat(float *q,float *vec, short axis, short upflag) { float q2[4], nor[3], *fp, mat[3][3], angle, si, co, x2, y2, z2, len1; |