[Bf-blender-cvs] [fc9c790] master: Math Lib: minor optimization for axis_angle_normalized_to_mat3

Campbell Barton noreply at git.blender.org
Sat Apr 19 06:12:40 CEST 2014


Commit: fc9c790563a55108bc4ebfaf6a576841fafa2117
Author: Campbell Barton
Date:   Sat Apr 19 14:09:55 2014 +1000
https://developer.blender.org/rBfc9c790563a55108bc4ebfaf6a576841fafa2117

Math Lib: minor optimization for axis_angle_normalized_to_mat3

===================================================================

M	source/blender/blenlib/intern/math_rotation.c

===================================================================

diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 9fc5909..46f508b 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -834,6 +834,7 @@ void eulO_to_axis_angle(float axis[3], float *angle, const float eul[3], const s
 void axis_angle_normalized_to_mat3(float mat[3][3], const float nor[3], const float angle)
 {
 	float nsi[3], co, si, ico;
+	float n_00, n_01, n_11, n_02, n_12, n_22;
 
 	BLI_ASSERT_UNIT_V3(nor);
 
@@ -846,15 +847,22 @@ void axis_angle_normalized_to_mat3(float mat[3][3], const float nor[3], const fl
 	nsi[1] = nor[1] * si;
 	nsi[2] = nor[2] * si;
 
-	mat[0][0] = ((nor[0] * nor[0]) * ico) + co;
-	mat[0][1] = ((nor[0] * nor[1]) * ico) + nsi[2];
-	mat[0][2] = ((nor[0] * nor[2]) * ico) - nsi[1];
-	mat[1][0] = ((nor[0] * nor[1]) * ico) - nsi[2];
-	mat[1][1] = ((nor[1] * nor[1]) * ico) + co;
-	mat[1][2] = ((nor[1] * nor[2]) * ico) + nsi[0];
-	mat[2][0] = ((nor[0] * nor[2]) * ico) + nsi[1];
-	mat[2][1] = ((nor[1] * nor[2]) * ico) - nsi[0];
-	mat[2][2] = ((nor[2] * nor[2]) * ico) + co;
+	n_00 = (nor[0] * nor[0]) * ico;
+	n_01 = (nor[0] * nor[1]) * ico;
+	n_11 = (nor[1] * nor[1]) * ico;
+	n_02 = (nor[0] * nor[2]) * ico;
+	n_12 = (nor[1] * nor[2]) * ico;
+	n_22 = (nor[2] * nor[2]) * ico;
+
+	mat[0][0] = n_00 + co;
+	mat[0][1] = n_01 + nsi[2];
+	mat[0][2] = n_02 - nsi[1];
+	mat[1][0] = n_01 - nsi[2];
+	mat[1][1] = n_11 + co;
+	mat[1][2] = n_12 + nsi[0];
+	mat[2][0] = n_02 + nsi[1];
+	mat[2][1] = n_12 - nsi[0];
+	mat[2][2] = n_22 + co;
 }




More information about the Bf-blender-cvs mailing list