Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-07-26 04:11:14 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-07-26 04:11:14 +0400
commite4a7087982b827edfa6652091a4bc7e2a32b6778 (patch)
tree480ecf6ff88e40f09a4ad9b0f5a965d13a726fec /source/blender/blenlib
parentcc061d075f4368f7a8d380becb0688bbea14832a (diff)
bugfix [#22836] Alt+MMB view alignment don't respect all axes directions
also moved rotation_between_quats_to_quat into BLI_math from python mathutils.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_math_rotation.h6
-rw-r--r--source/blender/blenlib/intern/math_rotation.c27
2 files changed, 29 insertions, 4 deletions
diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h
index 388a9176d53..f3da20f91c2 100644
--- a/source/blender/blenlib/BLI_math_rotation.h
+++ b/source/blender/blenlib/BLI_math_rotation.h
@@ -40,10 +40,10 @@ extern "C" {
/* init */
void unit_qt(float q[4]);
-void copy_qt_qt(float q[4], float a[4]);
+void copy_qt_qt(float q[4], const float a[4]);
/* arithmetic */
-void mul_qt_qtqt(float q[4], float a[4], float b[4]);
+void mul_qt_qtqt(float q[4], const float a[4], const float b[4]);
void mul_qt_v3(float q[4], float r[3]);
void mul_qt_fl(float q[4], float f);
void mul_fac_qt_fl(float q[4], float f);
@@ -51,6 +51,7 @@ void mul_fac_qt_fl(float q[4], float f);
void sub_qt_qtqt(float q[4], float a[4], float b[4]);
void invert_qt(float q[4]);
+void invert_qt_qt(float *q1, const float *q2);
void conjugate_qt(float q[4]);
float dot_qtqt(float a[4], float b[4]);
void normalize_qt(float q[4]);
@@ -72,6 +73,7 @@ void tri_to_quat(float q[4], float a[3], float b[3], float c[3]);
void vec_to_quat(float q[4], float vec[3], short axis, short upflag);
/* note: v1 and v2 must be normalized */
void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2[3]);
+void rotation_between_quats_to_quat(float q[4], const float q1[4], const float q2[4]);
/* TODO: don't what this is, but it's not the same as mat3_to_quat */
void mat3_to_quat_is_ok(float q[4], float mat[3][3]);
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;