diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-04-19 08:09:55 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-04-19 08:10:22 +0400 |
commit | fc9c790563a55108bc4ebfaf6a576841fafa2117 (patch) | |
tree | 8b6b713e7584db392231a8654bf9ad91bd87081f | |
parent | 36defb7e66b181b5a54e021aca52955efbfd84ef (diff) |
Math Lib: minor optimization for axis_angle_normalized_to_mat3
-rw-r--r-- | source/blender/blenlib/intern/math_rotation.c | 26 |
1 files changed, 17 insertions, 9 deletions
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; } |