Metric conversion constants not doubled in each port code.
[wxWidgets.git] / include / wx / math.h
1 /**
2 * Name: math.h
3 * Purpose: Declarations/definitions of common math functions
4 * Author: John Labenski and others
5 * Modified by:
6 * Created: 02/02/03
7 * RCS-ID:
8 * Copyright: (c)
9 * Licence: wxWindows licence
10 */
11
12 /* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
13
14 #ifndef _WX_MATH_H_
15 #define _WX_MATH_H_
16
17 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
18 #pragma interface "math.h"
19 #endif
20
21 #include "wx/defs.h"
22
23 #include <math.h>
24
25 #ifndef M_PI
26 #define M_PI 3.1415926535897932384626433832795
27 #endif
28
29 // Scaling factors for various unit conversions
30 #ifndef METRIC_CONVERSION_CONSTANT
31 #define METRIC_CONVERSION_CONSTANT 0.0393700787
32 #endif
33
34 #ifndef mm2inches
35 #define mm2inches (METRIC_CONVERSION_CONSTANT)
36 #endif
37
38 #ifndef inches2mm
39 #define inches2mm (1/(mm2inches))
40 #endif
41
42 #ifndef mm2twips
43 #define mm2twips (METRIC_CONVERSION_CONSTANT*1440)
44 #endif
45
46 #ifndef twips2mm
47 #define twips2mm (1/(mm2twips))
48 #endif
49
50 #ifndef mm2pt
51 #define mm2pt (METRIC_CONVERSION_CONSTANT*72)
52 #endif
53
54 #ifndef pt2mm
55 #define pt2mm (1/(mm2pt))
56 #endif
57
58
59 /* unknown __VISAGECC__, __SYMANTECCC__ */
60
61 #if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__)
62 #include <float.h>
63 #define wxFinite(x) _finite(x)
64 #elif defined(__GNUG__)||defined(__GNUWIN32__)||defined(__DJGPP__)|| \
65 defined(__SGI_CC__)||defined(__SUNCC__)||defined(__XLC__)|| \
66 defined(__HPUX__)||defined(__MWERKS__)
67 #define wxFinite(x) finite(x)
68 #else
69 #define wxFinite(x) ((x) == (x))
70 #endif
71
72
73 #if defined(__VISUALC__)||defined(__BORLAND__)
74 #define wxIsNaN(x) _isnan(x)
75 #elif defined(__GNUG__)||defined(__GNUWIN32__)||defined(__DJGPP__)|| \
76 defined(__SGI_CC__)||defined(__SUNCC__)||defined(__XLC__)|| \
77 defined(__HPUX__)||defined(__MWERKS__)
78 #define wxIsNaN(x) isnan(x)
79 #else
80 #define wxIsNaN(x) ((x) != (x))
81 #endif
82
83
84 #endif
85 /* _WX_MATH_H_ */