From 4e3084e4e5479e8cc6f9c37e0f015bac46dadc96 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann <christoph.lehmann@ufz.de> Date: Tue, 19 Jul 2016 12:18:58 +0200 Subject: [PATCH] [GL] less duplicated code --- GeoLib/AnalyticalGeometry-impl.h | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/GeoLib/AnalyticalGeometry-impl.h b/GeoLib/AnalyticalGeometry-impl.h index a1df7be610b..758faef0607 100644 --- a/GeoLib/AnalyticalGeometry-impl.h +++ b/GeoLib/AnalyticalGeometry-impl.h @@ -119,30 +119,25 @@ void computeRotationMatrixToXY(MathLib::Vector3 const& n, { // check if normal points already in the right direction if (n[0] == 0 && n[1] == 0) { + rot_mat(0,1) = 0.0; + rot_mat(0,2) = 0.0; + rot_mat(1,0) = 0.0; + rot_mat(1,1) = 1.0; + rot_mat(1,2) = 0.0; + rot_mat(2,0) = 0.0; + rot_mat(2,1) = 0.0; + if (n[2] > 0) { + // identity matrix rot_mat(0,0) = 1.0; - rot_mat(0,1) = 0.0; - rot_mat(0,2) = 0.0; - rot_mat(1,0) = 0.0; - rot_mat(1,1) = 1.0; - rot_mat(1,2) = 0.0; - rot_mat(2,0) = 0.0; - rot_mat(2,1) = 0.0; rot_mat(2,2) = 1.0; - return; } else { // rotate by pi about the y-axis rot_mat(0,0) = -1.0; - rot_mat(0,1) = 0.0; - rot_mat(0,2) = 0.0; - rot_mat(1,0) = 0.0; - rot_mat(1,1) = 1.0; - rot_mat(1,2) = 0.0; - rot_mat(2,0) = 0.0; - rot_mat(2,1) = 0.0; rot_mat(2,2) = -1.0; - return; } + + return; } // sqrt (n_1^2 + n_3^2) -- GitLab