From 082e9b329d154ed2b3aa6ba6d71064261f8204b7 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 30 Oct 2010 17:42:08 +0000 Subject: Fix for [#24458] Problem with Axis Angle rotation * Added checks to handle zero axis vector. --- source/blender/blenlib/intern/math_rotation.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to '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 7debdcdb015..b31e26dfc16 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -592,8 +592,11 @@ void axis_angle_to_quat(float q[4], const float axis[3], float angle) float nor[3]; float si; - normalize_v3_v3(nor, axis); - + if(normalize_v3_v3(nor, axis) == 0.0f) { + unit_qt(q); + return; + } + angle /= 2; si = (float)sin(angle); q[0] = (float)cos(angle); @@ -649,7 +652,10 @@ void axis_angle_to_mat3(float mat[3][3], const float axis[3], const float angle) float nor[3], nsi[3], co, si, ico; /* normalise the axis first (to remove unwanted scaling) */ - normalize_v3_v3(nor, axis); + if(normalize_v3_v3(nor, axis) == 0.0f) { + unit_m3(mat); + return; + } /* now convert this to a 3x3 matrix */ co= (float)cos(angle); -- cgit v1.2.3