xmath.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <gsl/gsl_math.h>
4 
5 namespace nmx {
9 struct Math {
10  //3.14159265358979323846
11  inline static constexpr double PI = M_PI;
12  // 2.71828182845904523536
13  inline static constexpr double E = M_E;
14  // rad -> deg
15  inline static double to_radians(double x) { return PI / 180 * x; }
16  // deg -> rad
17  inline static double to_degrees(double x) { return 180 / PI * x; }
18 
19  //**ist eine Zahl 0?
20  inline static bool is_zero(double x, double epsilon) { //
21  return abs(x) < epsilon;
22  }
23  //Vergleich von zwei Zahlen mit gewünschter Genauigkeit
24  inline static int cmp(double x, double y, double epsilon) { //
25  return gsl_fcmp(x, y, epsilon);
26  }
27  //Vorzeichen einer Zahl
28  inline static int sign(double x) { return GSL_SIGN(x); }
29 }; //Math
30 } // namespace nmx
static double to_degrees(double x)
Definition: xmath.h:17
static constexpr double E
Definition: xmath.h:13
static int sign(double x)
Definition: xmath.h:28
The Math struct Mathematische Hilfsfunktionen.
Definition: xmath.h:9
static double to_radians(double x)
Definition: xmath.h:15
static bool is_zero(double x, double epsilon)
Definition: xmath.h:20
static constexpr double PI
Definition: xmath.h:11
static int cmp(double x, double y, double epsilon)
Definition: xmath.h:24