karbon

vglobal.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2001, The Karbon Developers
00003    Copyright (C) 2002, The Karbon Developers
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef __VGLOBAL_H__
00022 #define __VGLOBAL_H__
00023 
00024 #include <kglobal.h>
00025 
00026 // define some often used mathematical constants et al:
00027 
00028 // TODO: optimize those values.
00029 
00030 namespace VGlobal
00031 {
00032     const double pi         =  3.14159265358979323846;  // pi
00033     const double twopi      =  6.28318530717958647692;  // 2pi
00034     const double pi_2       =  1.57079632679489661923;  // pi/2
00035     const double pi_180     =  0.01745329251994329576;  // pi/180
00036     const double one_pi_180 = 57.29577951308232087684;  // 180/pi
00037     const double sqrt2      =  1.41421356237309504880;  // sqrt(2)
00038     const double one_3      =  0.33333333333333333333;  // 1/3
00039     const double two_3      =  0.66666666666666666667;  // 2/3
00040     const double one_6      =  0.16666666666666666667;  // 1/6
00041     const double one_7      =  0.14285714285714285714;  // 1/7
00042 
00047     const double veryBigNumber = 1.0e8;
00048     const double verySmallNumber = 1.0e-8;
00049 
00053     const double flatnessTolerance = 0.01;
00054 
00060     const double lengthTolerance = 0.005;
00061 
00068     const double paramLengthTolerance = 0.001;
00069 
00074     const double isNearRange = 0.001;
00075 
00080     const double parallelTolerance = 0.99;
00081 
00085     inline int sign( double a )
00086     {
00087         return a < 0.0
00088                ? -1
00089                : 1;
00090     }
00091 
00095     int binomialCoeff( unsigned n, unsigned k );
00096 
00100     double factorialLn( unsigned n );
00101 
00105     double gammaLn( double x );
00106 }
00107 
00108 #endif
00109 
KDE Home | KDE Accessibility Home | Description of Access Keys