diff options
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) */ |