]> Shamusworld >> Repos - architektonas/blob - src/base/rs_math.h
Fixed thumbnail rendering in LibraryWidget and DXF detection.
[architektonas] / src / base / rs_math.h
1 #ifndef RS_MATH_H
2 #define RS_MATH_H
3
4 // no idea why, but doesn't link without that under win32 / bcc55:
5 //who cares if it doesn't
6 //#ifndef _MT
7 //#define _MT
8 //#endif
9
10 #include <QtCore>
11
12 #define ARAD                            57.29577951308232
13 #define RS_TOLERANCE            1.0e-10
14 #define RS_TOLERANCE_ANGLE      1.0e-8
15
16 /**
17  * Math functions.
18  */
19 class RS_Math
20 {
21 public:
22         static int round(double v);
23         static double pow(double x, double y);
24         static double rad2deg(double a);
25         static double deg2rad(double a);
26         static double rad2gra(double a);
27         static int findGCD(int a, int b);
28         static bool isAngleBetween(double a, double a1, double a2, bool reversed);
29         static double correctAngle(double a);
30         static double getAngleDifference(double a1, double a2);
31         static double makeAngleReadable(double angle, bool readable = true, bool * corrected = NULL);
32         static bool isAngleReadable(double angle);
33         static bool isSameDirection(double dir1, double dir2, double tol);
34         static double eval(const QString & expr, double def = 0.0);
35         static bool cmpDouble(double v1, double v2, double tol = 0.001);
36         static double eval(const QString & expr, bool * ok);
37         static QString doubleToString(double value, double prec);
38         static QString doubleToString(double value, int prec);
39
40         static void test();
41 };
42
43 #endif