From 973999a4d3c6d4d85bf0153230974fd9571f7846 Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Mon, 23 Sep 2019 08:54:41 +0200 Subject: [PATCH] Fix some template type conversions and style --- matrix/AxisAngle.hpp | 2 +- matrix/Euler.hpp | 4 ++-- matrix/Matrix.hpp | 2 +- matrix/Quaternion.hpp | 26 +++++++++++++------------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/matrix/AxisAngle.hpp b/matrix/AxisAngle.hpp index c2aec911e1..b86a57930f 100644 --- a/matrix/AxisAngle.hpp +++ b/matrix/AxisAngle.hpp @@ -69,7 +69,7 @@ public: AxisAngle(const Quaternion &q) { AxisAngle &v = *this; - Type ang = Type(2.0f)*acos(q(0)); + Type ang = Type(2) * acos(q(0)); Type mag = sin(ang/2.0f); if (fabs(mag) > 0) { v(0) = ang*q(1)/mag; diff --git a/matrix/Euler.hpp b/matrix/Euler.hpp index ec82cf1314..a0b8226cbd 100644 --- a/matrix/Euler.hpp +++ b/matrix/Euler.hpp @@ -97,11 +97,11 @@ public: Type pi = Type(M_PI); if (Type(fabs(theta_val - pi / Type(2))) < Type(1.0e-3)) { - phi_val = Type(0.0); + phi_val = Type(0); psi_val = Type(atan2(dcm(1, 2), dcm(0, 2))); } else if (Type(fabs(theta_val + pi / Type(2))) < Type(1.0e-3)) { - phi_val = Type(0.0); + phi_val = Type(0); psi_val = Type(atan2(-dcm(1, 2), -dcm(0, 2))); } diff --git a/matrix/Matrix.hpp b/matrix/Matrix.hpp index 3849f66ac3..15d042e969 100644 --- a/matrix/Matrix.hpp +++ b/matrix/Matrix.hpp @@ -278,7 +278,7 @@ public: void operator/=(Type scalar) { Matrix &self = *this; - self = self * (Type(1.0f) / scalar); + self = self * (Type(1) / scalar); } inline void operator+=(Type scalar) diff --git a/matrix/Quaternion.hpp b/matrix/Quaternion.hpp index 2110ded9e3..ffa00b602b 100644 --- a/matrix/Quaternion.hpp +++ b/matrix/Quaternion.hpp @@ -143,12 +143,12 @@ public: Quaternion(const Euler &euler) { Quaternion &q = *this; - Type cosPhi_2 = Type(cos(euler.phi() / Type(2.0))); - Type cosTheta_2 = Type(cos(euler.theta() / Type(2.0))); - Type cosPsi_2 = Type(cos(euler.psi() / Type(2.0))); - Type sinPhi_2 = Type(sin(euler.phi() / Type(2.0))); - Type sinTheta_2 = Type(sin(euler.theta() / Type(2.0))); - Type sinPsi_2 = Type(sin(euler.psi() / Type(2.0))); + Type cosPhi_2 = Type(cos(euler.phi() / Type(2))); + Type cosTheta_2 = Type(cos(euler.theta() / Type(2))); + Type cosPsi_2 = Type(cos(euler.psi() / Type(2))); + Type sinPhi_2 = Type(sin(euler.phi() / Type(2))); + Type sinTheta_2 = Type(sin(euler.theta() / Type(2))); + Type sinPsi_2 = Type(sin(euler.psi() / Type(2))); q(0) = cosPhi_2 * cosTheta_2 * cosPsi_2 + sinPhi_2 * sinTheta_2 * sinPsi_2; q(1) = sinPhi_2 * cosTheta_2 * cosPsi_2 - @@ -170,10 +170,10 @@ public: Type angle = aa.norm(); Vector axis = aa.unit(); if (angle < Type(1e-10)) { - q(0) = Type(1.0); + q(0) = Type(1); q(1) = q(2) = q(3) = 0; } else { - Type magnitude = sin(angle / 2.0f); + Type magnitude = sin(angle / Type(2)); q(0) = cos(angle / 2.0f); q(1) = axis(0) * magnitude; q(2) = axis(1) * magnitude; @@ -368,7 +368,7 @@ public: Quaternion canonical() const { const Quaternion &q = *this; - if(q(0)= Type(1e-10)) { vec = vec / axis_magnitude; - vec = vec * wrap_pi(Type(2.0) * atan2(axis_magnitude, q(0))); + vec = vec * wrap_pi(Type(2) * atan2(axis_magnitude, q(0))); } return vec;