From fc9c790563a55108bc4ebfaf6a576841fafa2117 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 19 Apr 2014 14:09:55 +1000 Subject: Math Lib: minor optimization for axis_angle_normalized_to_mat3 --- source/blender/blenlib/intern/math_rotation.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 9fc5909c20d..46f508b12bc 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; } -- cgit v1.2.3