diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-04-15 19:16:11 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-04-15 19:16:11 +0400 |
commit | 59ca83c3a9a94efa1e7415c83f0fe2033fcfcd28 (patch) | |
tree | 131a1add9b80df39fed212a1484b51048756b747 /source/blender/blenlib/intern/math_rotation.c | |
parent | 03d631986234d476d4d763b0fded289b482257b6 (diff) |
rename axis_angle_to_mat3_no_norm() --> axis_angle_normalized_to_mat3().
this matches closer to convention from existing functions - angle_v3v3() angle_normalized_v3v3().
also added assert to ensure argument given to axis_angle_normalized_to_mat3() is in fact normalized.
Diffstat (limited to 'source/blender/blenlib/intern/math_rotation.c')
-rw-r--r-- | source/blender/blenlib/intern/math_rotation.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 2d044a13841..93954499d53 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -750,10 +750,12 @@ void eulO_to_axis_angle(float axis[3], float *angle, const float eul[3], const s } /* axis angle to 3x3 matrix - note: requires that axis is normalized */ -void axis_angle_to_mat3_no_norm(float mat[3][3], const float nor[3], const float angle) +void axis_angle_normalized_to_mat3(float mat[3][3], const float nor[3], const float angle) { float nsi[3], co, si, ico; + BLI_ASSERT_UNIT_V3(nor); + /* now convert this to a 3x3 matrix */ co = cosf(angle); si = sinf(angle); @@ -778,7 +780,7 @@ void axis_angle_to_mat3_no_norm(float mat[3][3], const float nor[3], const float /* axis angle to 3x3 matrix - safer version (normalization of axis performed) */ void axis_angle_to_mat3(float mat[3][3], const float axis[3], const float angle) { - float nor[3], nsi[3], co, si, ico; + float nor[3]; /* normalize the axis first (to remove unwanted scaling) */ if (normalize_v3_v3(nor, axis) == 0.0f) { @@ -786,24 +788,7 @@ void axis_angle_to_mat3(float mat[3][3], const float axis[3], const float angle) return; } - /* now convert this to a 3x3 matrix */ - co = cosf(angle); - si = sinf(angle); - - ico = (1.0f - co); - nsi[0] = nor[0] * si; - 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; + axis_angle_normalized_to_mat3(mat, nor, angle); } /* axis angle to 4x4 matrix - safer version (normalization of axis performed) */ |