]> Shamusworld >> Repos - architektonas/blob - src/base/rs_math.h.bak
1daeb92d68b131f34df0c31c6ff0b4211c146df3
[architektonas] / src / base / rs_math.h.bak
1 /****************************************************************************
2 ** $Id: rs_math.h 2392 2005-05-17 13:52:38Z andrew $
3 **
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5 **
6 ** This file is part of the qcadlib Library project.
7 **
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
12 **
13 ** Licensees holding valid qcadlib Professional Edition licenses may use
14 ** this file in accordance with the qcadlib Commercial License
15 ** Agreement provided with the Software.
16 **
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 **
20 ** See http://www.ribbonsoft.com for further details.
21 **
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
23 ** not clear to you.
24 **
25 **********************************************************************/
26
27 #ifndef RS_MATH_H
28 #define RS_MATH_H
29
30 // no idea why, but doesn't link without that under win32 / bcc55:
31 //who cares if it doesn't
32 //#ifndef _MT
33 //#define _MT
34 //#endif
35
36 #include <math.h>
37 #include <errno.h>
38 #include <QtCore>
39
40 #ifndef RS_NO_FPARSER
41 #include "fparser.h"
42 #endif
43
44 #include "rs.h"
45 //#include "rs_string.h"
46 #include "rs_regexp.h"
47 //#include "rs_vector.h"
48
49 #define ARAD 57.29577951308232
50 #define RS_TOLERANCE 1.0e-10
51 #define RS_TOLERANCE_ANGLE 1.0e-8
52
53 typedef unsigned int uint;
54
55 /**
56  * Math functions.
57  */
58 class RS_Math
59 {
60 public:
61         static int round(double v);
62         static double pow(double x, double y);
63
64         //static double abs(double v);
65         //static int abs(int v);
66         static double rad2deg(double a);
67         static double deg2rad(double a);
68         static double rad2gra(double a);
69         static int findGCD(int a, int b);
70         static bool isAngleBetween(double a, double a1, double a2, bool reversed);
71         static double correctAngle(double a);
72         static double getAngleDifference(double a1, double a2);
73         static double makeAngleReadable(double angle, bool readable = true, bool * corrected = NULL);
74         static bool isAngleReadable(double angle);
75         static bool isSameDirection(double dir1, double dir2, double tol);
76         static double eval(const QString & expr, double def = 0.0);
77         static bool cmpDouble(double v1, double v2, double tol = 0.001);
78
79         // Keep that in the header file for dynamic inclusion/exclusion.
80         // (JLH: What kind of boneheaded crappy justification is that??!!??!!?)
81         static double eval(const QString & expr, bool * ok);
82
83         static QString doubleToString(double value, double prec);
84         static QString doubleToString(double value, int prec);
85
86         static void test();
87 };
88
89 #endif