From 94becf120bf0fe6b779fe952b68e73f1e62c90f1 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 4 Jan 2019 14:53:01 +0100 Subject: [PATCH] Fixed euler angles calculation for the singular case --- src/libslic3r/Geometry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/Geometry.cpp b/src/libslic3r/Geometry.cpp index 317ca4f65..ba9c7b00e 100644 --- a/src/libslic3r/Geometry.cpp +++ b/src/libslic3r/Geometry.cpp @@ -1194,9 +1194,9 @@ Vec3d extract_euler_angles(const Eigen::Matrix& } else { - angles(0) = ::atan2(-rotation_matrix(1, 2), rotation_matrix(1, 1)); + angles(1) = 0.0; angles(1) = ::atan2(-rotation_matrix(2, 0), sy); - angles(2) = 0.0; + angles(2) = (angles(1) >-0.0) ? ::atan2(rotation_matrix(1, 2), rotation_matrix(1, 1)) : ::atan2(-rotation_matrix(1, 2), rotation_matrix(1, 1)); } return angles;