1 /****************************************************************************
2 ** $Id: rs_math.h 2392 2005-05-17 13:52:38Z andrew $
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
6 ** This file is part of the qcadlib Library project.
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.
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.
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.
20 ** See http://www.ribbonsoft.com for further details.
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
25 **********************************************************************/
30 // no idea why, but doesn't link without that under win32 / bcc55:
31 //who cares if it doesn't
46 #define ARAD 57.29577951308232
47 #define RS_TOLERANCE 1.0e-10
48 #define RS_TOLERANCE_ANGLE 1.0e-8
50 //typedef unsigned int uint;
58 static int round(double v);
59 static double pow(double x, double y);
61 //static double abs(double v);
62 //static int abs(int v);
63 static double rad2deg(double a);
64 static double deg2rad(double a);
65 static double rad2gra(double a);
66 static int findGCD(int a, int b);
67 static bool isAngleBetween(double a, double a1, double a2, bool reversed);
68 static double correctAngle(double a);
69 static double getAngleDifference(double a1, double a2);
70 static double makeAngleReadable(double angle, bool readable = true, bool * corrected = NULL);
71 static bool isAngleReadable(double angle);
72 static bool isSameDirection(double dir1, double dir2, double tol);
73 static double eval(const QString & expr, double def = 0.0);
74 static bool cmpDouble(double v1, double v2, double tol = 0.001);
76 // Keep that in the header file for dynamic inclusion/exclusion.
77 // (JLH: What kind of boneheaded crappy justification is that??!!??!!?)
78 static double eval(const QString & expr, bool * ok);
80 static QString doubleToString(double value, double prec);
81 static QString doubleToString(double value, int prec);