Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanne Karhu <jhkarh@gmail.com>2010-10-30 21:42:08 +0400
committerJanne Karhu <jhkarh@gmail.com>2010-10-30 21:42:08 +0400
commit082e9b329d154ed2b3aa6ba6d71064261f8204b7 (patch)
treead8d34ccd33fa93aaedb8ed37cb4f6263e2ef0c3 /source/blender/blenlib/intern/math_rotation.c
parent001259ccb6a8dbe0c70e4eb0f47a82b9b574d3b4 (diff)
Fix for [#24458] Problem with Axis Angle rotation
* Added checks to handle zero axis vector.
Diffstat (limited to 'source/blender/blenlib/intern/math_rotation.c')
-rw-r--r--source/blender/blenlib/intern/math_rotation.c12
1 files changed, 9 insertions, 3 deletions
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);