CARMA C++
slamac.h
1 #ifndef SLAMACHDEF
2 #define SLAMACHDEF
3 
4 /*
5 ** - - - - - - - - -
6 ** s l a m a c . h
7 ** - - - - - - - - -
8 **
9 ** Macros used by slalib library.
10 **
11 ** Last revision: 5 June 1996
12 **
13 ** Copyright P.T.Wallace. All rights reserved.
14 */
15 
16 /* max(A,B) - larger (most +ve) of two numbers (generic) */
17 #define gmax(A,B) ((A)>(B)?(A):(B))
18 
19 /* min(A,B) - smaller (least +ve) of two numbers (generic) */
20 #define gmin(A,B) ((A)<(B)?(A):(B))
21 
22 /* dint(A) - truncate to nearest whole number towards zero (double) */
23 #define dint(A) ((A)<0.0?ceil(A):floor(A))
24 
25 /* aint(A) - truncate to nearest whole number towards zero (float) */
26 #define aint(A) ((A)<0.0f?(float)ceil((double)(A)):(float)floor((double)(A)))
27 
28 /* dnint(A) - round to nearest whole number (double) */
29 #define dnint(A) ((A)<0.0?ceil((A)-0.5):floor((A)+0.5))
30 
31 /* anint(A) - round to nearest whole number (float) */
32 #define anint(A) ((float)dnint((double)(A)))
33 
34 /* dsign(A,B) - magnitude of A with sign of B (double) */
35 #define dsign(A,B) ((B)<0.0?-(A):(A))
36 
37 /* dmod(A,B) - A modulo B (double) */
38 #define dmod(A,B) ((B)!=0.0?((A)*(B)>0.0?(A)-(B)*floor((A)/(B))\
39  :(A)+(B)*floor(-(A)/(B))):(A))
40 
41 /* logicals */
42 #if !defined(FALSE) || ((FALSE)!=0)
43 #define FALSE 0
44 #endif
45 #if !defined(TRUE) || ((TRUE)!=1)
46 #define TRUE 1
47 #endif
48 
49 /* pi */
50 #define DPI 3.1415926535897932384626433832795028841971693993751
51 
52 /* 2pi */
53 #define D2PI 6.2831853071795864769252867665590057683943387987502
54 
55 /* 1/(2pi) */
56 #define D1B2PI 0.15915494309189533576888376337251436203445964574046
57 
58 /* 4pi */
59 #define D4PI 12.566370614359172953850573533118011536788677597500
60 
61 /* 1/(4pi) */
62 #define D1B4PI 0.079577471545947667884441881686257181017229822870228
63 
64 /* pi^2 */
65 #define DPISQ 9.8696044010893586188344909998761511353136994072408
66 
67 /* sqrt(pi) */
68 #define DSQRPI 1.7724538509055160272981674833411451827975494561224
69 
70 /* pi/2: 90 degrees in radians */
71 #define DPIBY2 1.5707963267948966192313216916397514420985846996876
72 
73 /* pi/180: degrees to radians */
74 #define DD2R 0.017453292519943295769236907684886127134428718885417
75 
76 /* 180/pi: radians to degrees */
77 #define DR2D 57.295779513082320876798154814105170332405472466564
78 
79 /* pi/(180*3600): arcseconds to radians */
80 #define DAS2R 4.8481368110953599358991410235794797595635330237270e-6
81 
82 /* 180*3600/pi : radians to arcseconds */
83 #define DR2AS 2.0626480624709635515647335733077861319665970087963e5
84 
85 /* pi/12: hours to radians */
86 #define DH2R 0.26179938779914943653855361527329190701643078328126
87 
88 /* 12/pi: radians to hours */
89 #define DR2H 3.8197186342054880584532103209403446888270314977709
90 
91 /* pi/(12*3600): seconds of time to radians */
92 #define DS2R 7.2722052166430399038487115353692196393452995355905e-5
93 
94 /* 12*3600/pi: radians to seconds of time */
95 #define DR2S 1.3750987083139757010431557155385240879777313391975e4
96 
97 /* 15/(2pi): hours to degrees x radians to turns */
98 #define D15B2P 2.3873241463784300365332564505877154305168946861068
99 
100 #endif