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-10-08 11:36:33 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-10-08 11:36:33 +0400
commitc79e054538074d5149296994214397641124d76e (patch)
tree0369ce36a7a326e9e127ef71ff66cd4670bbb748 /source/blender/blenlib/intern
parent65b0893df0c82b04701f5f39c725df983c19f0c7 (diff)
quat_apply_track had incomplete comments
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r--source/blender/blenlib/intern/math_rotation.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index c4f12a5efc1..3b58fe88bf5 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1539,21 +1539,24 @@ void quat_apply_track(float quat[4], short axis, short upflag)
{0.70710676908493, 0.0, 0.0, 0.70710676908493}, /* pos-z90 */
{0.70710676908493, 0.0, 0.70710676908493, 0.0}, /* neg-y90 */
{0.5, -0.5, -0.5, 0.5}, /* Quaternion((1,0,0), radians(-90)) * Quaternion((0,1,0), radians(-90)) */
- {1, 0, 0, 0}};/* no rotation */
+ {-3.0908619663705394e-08, 0.70710676908493, 0.70710676908493, 3.0908619663705394e-08}}; /* no rotation */
mul_qt_qtqt(quat, quat, quat_track[axis]);
if(axis>2)
axis= axis-3;
- /* 90d rotation when the second */
- if(upflag != (2-axis)>>1) { // [0->1, 1->0, 2->0]
- float q[4]= {0.70710676908493, 0, 0, 0};
+ /* there are 2 possible up-axis for each axis used, the 'quat_track' applies so the first
+ * up axis is used X->Y, Y->X, Z->X, if this first up axis isn used then rotate 90d
+ * the strange bit shift below just find the low axis {X:Y, Y:X, Z:X} */
+ if(upflag != (2-axis)>>1) {
+ float q[4]= {0.70710676908493, 0.0, 0.0, 0.0}; /* assign 90d rotation axis */
q[axis+1] = ((axis==1)) ? 0.70710676908493 : -0.70710676908493; /* flip non Y axis */
mul_qt_qtqt(quat, quat, q);
}
}
+
void vec_apply_track(float vec[3], short axis)
{
float tvec[3];
@@ -1572,14 +1575,14 @@ void vec_apply_track(float vec[3], short axis)
/* vec[2]= tvec[2]; */
break;
case 2: /* pos-z */
- vec[0]= tvec[1];
- vec[1]= -tvec[0];
+ /* vec[0]= tvec[0]; */
+ /* vec[1]= tvec[1]; */
// vec[2]= 0.0; */
break;
case 3: /* neg-x */
/* vec[0]= 0.0; */
- vec[1]= -tvec[1];
- vec[2]= -tvec[2];
+ vec[1]= tvec[2];
+ vec[2]= -tvec[1];
break;
case 4: /* neg-y */
vec[0]= -tvec[2];