From 341da31d07040db9084c564037045f8600789261 Mon Sep 17 00:00:00 2001
From: Norihiro Watanabe <norihiro.watanabe@ufz.de>
Date: Fri, 23 Sep 2016 14:23:11 +0200
Subject: [PATCH] add sgn(), to_radians() in MathTools.h

---
 MathLib/MathTools.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/MathLib/MathTools.h b/MathLib/MathTools.h
index 81f1fad0116..ad82f58fcc9 100644
--- a/MathLib/MathTools.h
+++ b/MathLib/MathTools.h
@@ -11,6 +11,7 @@
 #ifndef MATHTOOLS_H_
 #define MATHTOOLS_H_
 
+#include <cmath>
 #include <cstddef>
 
 #ifdef _OPENMP
@@ -111,6 +112,16 @@ double sqrDist(const double* p0, const double* p1)
  */
 double getAngle (const double p0[3], const double p1[3], const double p2[3]);
 
+/// sign function
+template <typename T> int sgn(T val) {
+    return (T(0) < val) - (val < T(0));
+}
+
+/// converts the given degrees to radians
+inline double to_radians(double degrees) {
+    return degrees*M_PI/180.;
+}
+
 } // namespace
 
 #endif /* MATHTOOLS_H_ */
-- 
GitLab