[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32373] trunk/blender/source/blender/ blenlib/intern/math_rotation.c: quat_apply_track had incomplete comments

Campbell Barton ideasman42 at gmail.com
Fri Oct 8 09:36:33 CEST 2010


Revision: 32373
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32373
Author:   campbellbarton
Date:     2010-10-08 09:36:33 +0200 (Fri, 08 Oct 2010)

Log Message:
-----------
quat_apply_track had incomplete comments

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/math_rotation.c

Modified: trunk/blender/source/blender/blenlib/intern/math_rotation.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_rotation.c	2010-10-08 07:29:08 UTC (rev 32372)
+++ trunk/blender/source/blender/blenlib/intern/math_rotation.c	2010-10-08 07:36:33 UTC (rev 32373)
@@ -1539,21 +1539,24 @@
 	                              {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 */ 
+	                              {1.0, 0.0, 0.0, 0.0}}; /* 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];





More information about the Bf-blender-cvs mailing list