home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume42 / astrolog / part02 / placalc.h < prev   
C/C++ Source or Header  |  1994-03-25  |  27KB  |  803 lines

  1. /*
  2. ** Astrolog (Version 4.10) File: placalc.h
  3. **
  4. ** IMPORTANT NOTICE: the graphics database and chart display routines
  5. ** used in this program are Copyright (C) 1991-1994 by Walter D. Pullen
  6. ** (cruiser1@stein.u.washington.edu). Permission is granted to freely
  7. ** use and distribute these routines provided one doesn't sell,
  8. ** restrict, or profit from them in any way. Modification is allowed
  9. ** provided these notices remain with any altered or edited versions of
  10. ** the program.
  11. **
  12. ** The main planetary calculation routines used in this program have
  13. ** been Copyrighted and the core of this program is basically a
  14. ** conversion to C of the routines created by James Neely as listed in
  15. ** Michael Erlewine's 'Manual of Computer Programming for Astrologers',
  16. ** available from Matrix Software. The copyright gives us permission to
  17. ** use the routines for personal use but not to sell them or profit from
  18. ** them in any way.
  19. **
  20. ** The PostScript code within the core graphics routines are programmed
  21. ** and Copyright (C) 1992-1993 by Brian D. Willoughby
  22. ** (brianw@sounds.wa.com). Conditions are identical to those above.
  23. **
  24. ** The extended accurate ephemeris databases and formulas are from the
  25. ** calculation routines in the program "Placalc" and are programmed and
  26. ** Copyright (C) 1989,1991,1993 by Astrodienst AG and Alois Treindl
  27. ** (alois@azur.ch). The use of that source code is subject to
  28. ** regulations made by Astrodienst Zurich, and the code is not in the
  29. ** public domain. This copyright notice must not be changed or removed
  30. ** by any user of this program.
  31. **
  32. ** Initial programming 8/28,30, 9/10,13,16,20,23, 10/3,6,7, 11/7,10,21/1991.
  33. ** X Window graphics initially programmed 10/23-29/1991.
  34. ** PostScript graphics initially programmed 11/29-30/1992.
  35. ** Last code change made 3/19/1994.
  36. */
  37.  
  38. #include "astrolog.h"
  39.  
  40. #ifdef ASTROLOG
  41. #define EPHE_PATH EPHE_DIR
  42. #define HUGE8 1.7E+308     /* biggest value for REAL8 */
  43.  
  44. extern int lrz_file_posit();
  45. extern int chi_file_posit();
  46. extern int outer_hel();
  47. extern void longreorder();
  48. extern int inpolq();
  49. #endif
  50. #ifdef PLACALC
  51. #ifdef ASTROLOG
  52. /* Begin contents of astrolib.h */
  53. #endif
  54. /************************************************************
  55.    $Header: placalc.h,v 1.4 93/03/22 10:08:39 alois Exp $
  56.    definitions and constants for planetary routines
  57.  
  58.    ATTENTION: PLACALC USERS ON MSDOS:
  59.    See the note close to the end of this file regarding EPHE_PATH.
  60.  
  61.   ---------------------------------------------------------------
  62.   | Copyright Astrodienst AG and Alois Treindl, 1991, 1993.    |
  63.   | The use of this source code is subject to regulations made    |
  64.   | by Astrodienst Zurich. The code is NOT in the public domain.|
  65.   |                                |
  66.   | This copyright notice must not be changed or removed    |
  67.   | by any user of this program.                |
  68.   ---------------------------------------------------------------
  69.  
  70. ************************************************************/
  71. # ifndef _PLACALC_INCLUDED
  72. # define _PLACALC_INCLUDED
  73.  
  74. #ifndef ASTROLOG
  75. #include "ourdef.h"    /* this is the basic include files which
  76.             contains many definitions used throughout
  77.             Astrodienst's programs.
  78.             */
  79. #else /* ASTROLOG */
  80. #ifdef ASTROLOG
  81. /* Begin contents of ourdef.h */
  82. #endif
  83. /************************************************************
  84.    $Header: ourdef.h,v 1.2 91/11/16 16:21:37 alois Exp $
  85.    definitions and constants for all Astrodienst C programs
  86.    contains only declarations and #defines, no global variables.
  87.    auto-dectection of MSDOS (TURBO_C or MS_C) or HPUNIX
  88.    
  89. ************************************************************/
  90.  
  91. #ifndef _OURDEF_INCLUDED /* allow multiple #includes of ourdef.h */
  92. #define _OURDEF_INCLUDED
  93.  
  94. # define MY_TRUE 1    /* for use in other defines, before TRUE is defined */
  95. # define MY_FALSE 0    /* for use in other defines, before TRUE is defined */
  96.  
  97. #ifdef MSDOS    /* already defined by some DOS compilers */
  98. # undef MSDOS
  99. # define MSDOS MY_TRUE
  100. #endif
  101.  
  102. #ifdef __TURBOC__    /* defined by  turboc */
  103. # ifndef MSDOS
  104. #   define MSDOS MY_TRUE
  105. # endif
  106. # define TURBO_C
  107. #endif
  108.  
  109. #if MSDOS
  110. #  define HPUNIX MY_FALSE
  111. #  ifndef TURBO_C
  112. #    define MS_C    /* assume Microsoft C compiler */
  113. #  endif
  114. #else
  115. #  define MSDOS MY_FALSE
  116. #  define HPUNIX MY_TRUE
  117. #  ifndef _HPUX_SOURCE
  118. #    define _HPUX_SOURCE
  119. #  endif
  120. #endif
  121.  
  122. #include <math.h>
  123. #ifndef FILE
  124. #include <stdio.h>
  125. #endif
  126.  
  127. #include <stdlib.h>
  128. # if HPUNIX
  129. #include <unistd.h>
  130. # endif
  131.  
  132. #ifndef TRUE 
  133. #define TRUE 1
  134. #define FALSE 0
  135. #endif
  136.  
  137. #ifndef OK 
  138. #define OK (0)
  139. #define ERR (-1)
  140. #endif
  141.  
  142.  
  143. # define UCHP    (unsigned char*)    /* used for casting *char  */
  144. # define UCP    (unsigned char*)    /* used for casting *char  */
  145. # define SCP    (char*)            /* used for casting *unsigned char */
  146. # define UCHAR    unsigned char
  147.  
  148. #if HPUNIX
  149. #include <malloc.h>
  150.   typedef double  REAL8;  /* real with at least 64 bit precision */
  151.   typedef float   REAL4;  /* real with at least 32 bit precision */
  152.   typedef long     INT4;   /* signed integer with at least 32 bit precision */
  153.   typedef unsigned long UINT4; 
  154.             /* unsigned integer with at least 32 bit precision */
  155.   typedef int     INT2;   /* signed integer with at least 16 bit precision */
  156.   typedef int     INT1;   /* signed integer with at least 8  bit precision */
  157. # ifndef dbd_VERSION    /* db_vista defines boolean in vista.h already */
  158.             /* vista.h must be included before ourdef.h */
  159.   typedef int     BOOLEAN;
  160. # endif
  161.   typedef unsigned short UINT2;    /* unsigned 16 bits */
  162. # define ABS4    abs        /* abs function for long */
  163. # define CHARSET_HP TRUE    /* used by ctype256 */
  164. # define START_OF_EXTRA_CHAR 161
  165. # define DEGREE_CHAR 179    /* HP degree character */
  166. # endif
  167.  
  168. #if MSDOS 
  169. #ifdef TURBO_C
  170. #  include <alloc.h>        /* MSC needs malloc ! */
  171. #else
  172. #  include <malloc.h>
  173. #endif
  174. #include <stdlib.h>
  175. #ifndef ASTROLOG
  176. #define HUGE 1.7E+308     /* biggest value for REAL8 */
  177. #undef M_PI
  178. #define M_PI 3.14159265358979323846
  179. #endif
  180.   typedef double  REAL8;  /* real with at least 64 bit precision */
  181.   typedef float   REAL4;  /* real with at least 32 bit precision */
  182.   typedef long    INT4;   /* signed integer with at least 32 bit precision */
  183.   typedef unsigned long UINT4;
  184.                           /* unsigned integer with at least 32 bit precision */
  185.   typedef int     INT2;   /* signed integer with at least 16 bit precision */
  186.   typedef int     INT1; /* signed integer with at least 8  bit precision */
  187.   typedef int     BOOLEAN;
  188.   typedef unsigned int UINT2;    /* unsigned 16 bits */
  189. # define ABS4    labs        /* abs function for long */ 
  190. # define START_OF_EXTRA_CHAR 128
  191. # define DEGREE_CHAR 248    /* MSDOS degree character */
  192. # define CHARSET_IBM TRUE    /* remains undefined if not msdos */
  193. #endif
  194.  
  195. #define forward extern
  196.  
  197. #define MINUTE_CHAR  39    /* minute character */
  198. #define SECOND_CHAR  34    /* second character */
  199. #define MAXCHAR 256     /* used for string declarations, allowing 255 char+\0 */
  200. #define COMMA ','
  201.  
  202. #define COS8 cos
  203. #define SIN8 sin
  204. #define ASIN8 asin
  205. #define TAN8 tan
  206. #define ATAN8 atan
  207. #define ATAN28 atan2
  208. #define EXP10(x) pow(10.0,(x))
  209. #define ABS8(x) fabs(x)
  210.  
  211. #define TANERRLIMIT 1.0E-10     /* used to check for arguments close to pi */
  212. #define NEAR_ZERO   1.0E-16     /* used to compare for divisors close to 0 */
  213. #define BIGREAL  1.0E+38
  214.  
  215. #define DEGTORAD 0.0174532925199433
  216. #define RADTODEG 57.2957795130823
  217.  
  218. typedef INT4    centisec;       /* centiseconds used for angles and times */
  219. #define CS    (centisec)    /* use for casting */
  220. #define CSEC    centisec    /* use for typing */
  221.     
  222.  
  223. #define DEG     360000L  /* degree expressed in centiseconds */
  224. #define DEG7_30 (2700000L)    /* 7.5 degrees */
  225. #define DEG15   (15 * DEG)
  226. #define DEG24   (24 * DEG)
  227. #define DEG30   (30 * DEG)
  228. #define DEG60   (60 * DEG)
  229. #define DEG90   (90 * DEG)
  230. #define DEG120  (120 * DEG)
  231. #define DEG150  (150 * DEG)
  232. #define DEG180  (180 * DEG)
  233. #define DEG270  (270 * DEG)
  234. #define DEG360  (360 * DEG)
  235.  
  236. #define CSTORAD  4.84813681109536E-08 /* centisec to rad: pi / 180 /3600/100 */
  237. #define RADTOCS  2.06264806247096E+07 /* rad to centisec 180*3600*100/pi */
  238.  
  239. #define DEG2MSEC 3600000.0    /* degree to milliseconds */
  240. #define DEG2CSEC 360000.0    /* degree to centiseconds */
  241.  
  242. #define SEC2CSEC    100    /* seconds to centiseconds */
  243.  
  244. #define CS2DEG    (1.0/360000.0)    /* centisec to degree */
  245. #define CS2CIRCLE (CS2DEG/360.0)    /* centisec to circle */
  246. #define AU2INT     1e7        /* factor for long storage of A.U. */
  247.  
  248. #define CSMIN    6000L
  249. #define CSSEC    100L
  250.  
  251. # define SINDEG(x)    sin(DEGTORAD * (x))
  252. # define COSDEG(x)    cos(DEGTORAD * (x))
  253. # define TANDEG(x)    tan(DEGTORAD * (x))
  254. # define SINCS(x)    sin((double)(CSTORAD * (x)))
  255. # define COSCS(x)    cos((double)(CSTORAD * (x)))
  256. # define TANCS(x)    tan((double)(CSTORAD * (x)))
  257.  
  258. typedef long CMM;        /* plotmod unit 0.01 mm */
  259. # define CMM2PT       0.028346457    /* factor for CMM to points */
  260.  
  261. typedef double *vector;
  262.  
  263. #endif /* _OURDEF_INCLUDED */
  264. #ifdef ASTROLOG
  265. /* End contents of ourdef.h */
  266. #endif
  267. #endif /* ASTROLOG */
  268.  
  269. /*************************************************************
  270.  Exported functions:
  271.  
  272.  In all functions the variable jd_ad indicates the use of
  273.  Astrodienst relative julian days, and jd the use of absolute
  274.  julian days.
  275. *************************************************************/
  276. #ifndef ASTROLOG
  277. extern int nacalc(REAL8 jd_ad, centisec *plon, centisec *pspe);
  278. extern int calcserv(int id, REAL8 t, int flag, int plalist, char *so);
  279. extern void helup(REAL8 jd_ad);
  280. extern void togeo(REAL8 le, REAL8 re, REAL8 l, REAL8 r, REAL8 z, REAL8 *alg, REAL8 *arg);
  281. extern int  calc(int p,
  282.          REAL8 jd_ad,
  283.          int flag, 
  284.          REAL8 *alng,
  285.          REAL8 *arad,
  286.          REAL8 *alat,
  287.          REAL8 *alngspeed);
  288. extern int rel_geo(int planet, double rau);
  289. extern int hel( int    planet,    /* planet index as defined by placalc.h */
  290.         REAL8    jd_ad,    /* relative juliand date, ephemeris time */
  291.                 /* Now come 6 pointers to return values. */
  292.         REAL8    *al,    /* longitude in degrees */
  293.         REAL8   *ar,    /* radius in AU */
  294.         REAL8   *az,    /* distance from ecliptic in AU */
  295.         REAL8   *alp,     /* speed in longitude, degrees per day */
  296.         REAL8   *arp,    /* speed in radius, AU per day */
  297.         REAL8   *azp);   /* speed in z, AU per day */
  298. extern int  moon(REAL8 *al, REAL8 *ar, REAL8 *az);
  299. extern REAL8 fraction(REAL8 t);
  300. extern REAL8 sidtime(REAL8 jd_ad, REAL8 ecl, REAL8 nuta);
  301. extern REAL8 smod8360(REAL8 x);
  302. extern REAL8 mod8360(REAL8 x);
  303. extern REAL8 diff8360(REAL8 x, REAL8 y);
  304. extern REAL8 test_near_zero(REAL8 x);
  305. extern REAL8 deltat(REAL8 jd_ad);
  306. extern void to_mean_ekl (double jd, double xyz[], double lrz[]);
  307.  
  308. /*
  309.  * get the planet index for an AFL letter
  310.  * returns -1 if the letter does not correspond to a planet.
  311.  */
  312. extern int afl2planet(int apl);
  313. #else /* ASTROLOG */
  314. extern int nacalc();
  315. extern int calcserv();
  316. extern void helup();
  317. extern void togeo();
  318. extern int calc();
  319. extern int rel_geo();
  320. extern int hel();
  321. extern int moon();
  322. extern REAL8 fraction();
  323. extern REAL8 sidtime();
  324. extern REAL8 smod8360();
  325. extern REAL8 mod8360();
  326. extern REAL8 diff8360();
  327. extern REAL8 test_near_zero();
  328. extern REAL8 deltat();
  329. extern void to_mean_ekl();
  330. extern int afl2planet();
  331. #endif /* ASTROLOG */
  332.  
  333. /*************************************************************
  334.     exported variables
  335. *************************************************************/
  336. extern REAL8 meanekl;
  337. extern REAL8 ekl;
  338. extern REAL8 nut;
  339.  
  340. extern struct elements { /* actual elements at time thelup */
  341.   REAL8 tj,     /* centuries from epoch */
  342.         lg,     /* mean longitude in degrees of arc*/
  343.         pe,     /* longitude of the perihelion in degrees of arc*/
  344.         ex,     /* excentricity in degrees of arc*/
  345.         kn,     /* longitude of node in degrees of arc*/
  346.         in,     /* inclination of the orbit in degrees of arc*/
  347.         ma;     /* mean anomaly in degrees of arc*/
  348.    } el [];
  349.  
  350. extern char *ephe_path;
  351. extern char *placalc_err_text;
  352.   
  353. /*************************************************************
  354.     definitions
  355. *************************************************************/
  356.  
  357. /*
  358.  * planet index numbers, used to identify a planet in calc() and
  359.  * other related functions.
  360.  */
  361. #define CALC_ONLY_ECL_NUT -1    /* pseudo planet index for calls to calc */
  362. #define SUN    0        /* used synonymously for earth too */
  363. #define EARTH    0
  364. #define MOON    1
  365. #define MERCURY 2
  366. #define VENUS    3
  367. #define MARS    4
  368. #define JUPITER    5
  369. #define SATURN    6
  370. #define URANUS    7
  371. #define NEPTUNE 8
  372. #define PLUTO    9
  373. #define LASTPLANET PLUTO
  374. #define MEAN_NODE  10
  375. #define TRUE_NODE  11
  376. #define CHIRON       12
  377. #define CALC_N       13    /* number of planets in placalc module */
  378. #define LILITH       13    /* Lilith is separate, not included in standard set
  379.                of placalc planets. This is required because
  380.                otherwise some string server calls would
  381.                suddenly return a higher number of fields.
  382.                */
  383.  
  384. /*
  385.  * houses and axes get also a 'planet' index number, but they
  386.  * are not used by placalc itself
  387.  * between chiron and AC we leave 6 places unused for some other celestial
  388.  * bodies or chart factors.
  389.  * Axes and houses cannot be computed with calls to calc(); they must
  390.  * be computed with the housasp module functions.
  391.  */
  392. # define AC       19
  393. # define MC       20
  394. # define CALC_N_MC  21    /* number of normal natal factors */
  395.  
  396. # define FIRST_HSNR 21
  397. # define LAST_HSNR 32
  398. # define NO_OF_HOUSES 12
  399. #define MAX_PL_INDEX 32
  400. /*
  401.  * in a bitlist flag each planet is represented by a bit;
  402.  * all 13 defined planets can be called at once with
  403.  * LILITH is not automatically included
  404.  */
  405. #define CALC_ALL_PLANET_BITS  ((1 << 13) - 1)    /* bits 0..12 set */
  406.  
  407. /*
  408.  * AFL: Astrological factor letters for use in selections strings.
  409.  * Each factor (planet, house cusp etc) has a typical letter which
  410.  * can be combined in a selctions string for specifying a certain
  411.  * sequence of factors for a table or other kind of display.
  412.  * The function apl2planet() can be used to translate the AFL letters
  413.  * into planet indices.
  414.  */
  415.  
  416. # define AFL_SUN    '0'
  417. # define AFL_MON    '1'
  418. # define AFL_MER    '2'
  419. # define AFL_VEN    '3'
  420. # define AFL_MAR    '4'
  421. # define AFL_JUP    '5'
  422. # define AFL_SAT    '6'
  423. # define AFL_URA    '7'
  424. # define AFL_NEP    '8'
  425. # define AFL_PLU    '9'
  426. # define AFL_CHI    'c'
  427. # define AFL_LIL    'i'    /* mean Lilith: direction of lunar aphel */
  428. # define AFL_AC        'A'
  429. # define AFL_MC        'M'
  430. # define AFL_TNODE    'N'    /* TRUE_NODE */
  431. # define AFL_MNODE    'n'    /* MEAN_NODE */
  432.  
  433. /*
  434.  * other AFL definitions not recognized by afl2planet()
  435.  */
  436. # define AFL_SIDT    's'    /* sidereal time */
  437. # define AFL_WDAY    'd'    /* day of week column */
  438.  
  439. # define apl2planet    afl2planet    /* change of original name */
  440.  
  441.  
  442. # define J2000    2451545.0    /* Epoch of JPL ephemeris DE200, absolute */
  443. # define J1950  2433282.423    /* Epoch of JPL ephemeris DE102 */
  444. #define JUL_OFFSET 2433282.0    /* offset of Astrodienst relative Julian date */
  445. #define EPOCH1850 -36524.0    /* jupiter,saturn 0 jan 1850, 12:00 */
  446. #define EPOCH1900 -18262.0    /* inner planets  0 jan 1900, 12:00 */
  447. #define EPOCH1950  0.0        /* pluto       0 jan 1950, 12:00 */
  448.                                 /* this is the origin of the Astrodienst
  449.                                    relative julian calendar system */
  450. #define EPOCH1960  3653.0    /* uranus,neptune 1 jan 1960, 12:00 */
  451.  
  452. #define ENDMARK  99        /* used to mark the end of disturbation terms */
  453.  
  454. #define NODE_INTERVAL    0.005    /* days, = 7m20s */
  455. #define MOON_SPEED_INTERVAL  0.0001 /* 8.64 seconds later */
  456.  
  457. /*
  458.  * flag bits used in calc and calcserv
  459.  */
  460. # define CALC_BIT_HELIO    1    /* geo/helio */
  461. # define CALC_BIT_NOAPP    2    /* apparent/true positions */
  462. # define CALC_BIT_NONUT    4    /* true eq. of date/ mean equ. of date */
  463. # define CALC_BIT_EPHE    8    /* universal/ephemeris time */
  464. # define CALC_BIT_SPEED    16    /* without/with speed */
  465. # define CALC_BIT_BETA    32    /* without/with latitude */
  466. # define CALC_BIT_RGEO    64    /* without/with relative rgeo */
  467. # define CALC_BIT_RAU    128    /* without/with real radius */
  468. # define CALC_BIT_MUST_USE_EPHE    256    /* epheserv may not use calc */
  469. # define CALC_BIT_MAY_USE_EPHE    512    /* calcserv may use ephread */
  470.  
  471. # if HPUNIX
  472. #   define XYZ_FILE  "/users/ephe/xyz1950"    /* for creating */
  473. #   define LRZ_FILE "/users/ephe/LRZ5_"    /* for creating */
  474. #   define OPEN_EPHE "r"    
  475. #ifndef ASTROLOG
  476. #   define EPHE_PATH "/users/ephe"    /* for  LRZ and CHI */
  477. #endif
  478. # else
  479.  
  480. /* ephemeris file path for MSDOS */
  481.  
  482. /*****************************************************************************
  483. ******************************************************************************
  484.   ATTENTION: PLACALC USERS ON MSDOS:
  485.  
  486.   EPHE_PATH indicates where the ephemeris files LRZ_nnn and CHI_nnn
  487.   are found in you system.
  488.   EPHE_PATH is only used once at the beginning of placalc.c to initialize
  489.   the global variable ephe_path.
  490.  
  491.   If you do not have the ephemeris files in \PAIR\EPHE, you must do one of
  492.   two things:
  493.   - change the #define statement below to point to your ephemeris directory
  494.   - OR change the global char *ephe_path before  you call any placalc
  495.   function.
  496.   Take care, that ephe_path ends NOT with the directory character ('\' in DOS).
  497. ******************************************************************************
  498. *****************************************************************************/
  499. #ifndef ASTROLOG
  500. #   define EPHE_PATH "\\pair\\ephe"    
  501. #endif
  502.  
  503. #   define OPEN_EPHE "rb"        /* read binary */
  504. # endif
  505.  
  506. # define EPHE_STEP    80        /* days step in LRZ ephe */
  507. # define EPHE_DAYS_PER_FILE 100000    /* days per ephe file */
  508. # define EPHE_OUTER "LRZ5_"        /* file name prefix */
  509. # define EPHE_OUTER_BSIZE    60    /* blocksize  */
  510. # define EPHE_CHIRON "CHI_"        /* file name prefix */
  511. # define EPHE_CHIRON_BSIZE    12    /* blocksize  */
  512.  
  513. /********************************************
  514.   About the format of the ephemeris files
  515.   ----------------------------------------
  516.   We use currently ephemeris files with steps of 80 days.
  517.   There are 1250 "records" in each file, so that one file
  518.   spans 100000 days.
  519.   We have two types of ephemeris files:
  520.   LRZ5_nn     for the outer planets Jupiter ... Pluto
  521.   CHI_nn    for Chiron.
  522.   nn is an expression derived from the first julian daynumber on the
  523.   file. Jd 2100'000 to 2199'920 is on file LRZ5_21 and CHI_21;
  524.   for negative Jd we use the filenames LRZ5_Mxx  with M indicating the minus.
  525.  
  526.   Given the jd for which you want the ephemeris, it is simple to build
  527.   the filename and use fseek() within the file to go where the data is.
  528.   This is done by the functions lrz_file_posit() and chi_file_posit().
  529.  
  530.   The stored coordinates are for each date and planet:
  531.   L = ecliptic longitude relative to mean exquinox of date,
  532.       in units of milliseconds of acr (1/3600000 degree) as type long;
  533.   R = radius vector, units of 10-7 AU, as type long.
  534.   Z = disctance of ecliptic; Z = R * sin(latitude); in units of 10-7 AU,
  535.       as type long.
  536.   The data is stored in the byte ordering of the Astrodienst HPUX machines,
  537.   which is most significant byte first. It is not the same byte ordering
  538.   as on Intel processors; the function longreorder() converts between
  539.   the disk file format and the internal format of MSDOS machines.
  540.  
  541.   For LRZ5- files, we have 60-byte records LRZ(Jupiter),LRZ(Saturn),
  542.   LRZ(Uranus), LRZ(Neptune), LRZ(Pluto). 
  543.   For CHI-files we have 12-byte records LRZ.
  544.  
  545. ************************************************/
  546.  
  547. # endif /* _PLACALC_INCLUDED */
  548. #ifdef ASTROLOG
  549. #ifdef ASTROLOG
  550. /* Begin contents of astrolib.h */
  551. #endif
  552. /*******************************************
  553. $Header: astrolib.h,v 1.2 91/11/16 16:21:02 alois Exp $
  554. astrolib.h
  555.  
  556. NOTE for users of the PLACALC package:
  557. This include files declares many function which
  558. are NOT part of the PLACALC package. It is only
  559. included because it also declares some items contained
  560. in PLACALC.
  561.  
  562. ourdef.h should be included before this!
  563.  
  564. *******************************************/
  565. # ifndef _ASTROLIB_INCLUDED
  566. # define _ASTROLIB_INCLUDED
  567.  
  568. /* define days of the week for day_of_week() results */
  569. # define DOW_MONDAY    0
  570. # define DOW_SUNDAY    6
  571.  
  572. # define ORD_DIV    10000        /* for kdv and clients */
  573.  
  574. /* makros for bit operations */
  575. # define clear_bit(v,bit_nr)     ((v) & ~(1L << (bit_nr)))
  576. # define set_bit(v,bit_nr)     ((v) | (1L << (bit_nr)))
  577. # define bit(bit_nr)        (1L << (bit_nr))
  578. # define check_bit(v,bit_nr)    ((v) & (1L << (bit_nr)))
  579.  
  580. # define SPLIT_CS_ROUND_SEC    1
  581. # define SPLIT_CS_ROUND_MIN    2
  582. # define SPLIT_CS_ROUND_DEG    4
  583. # define SPLIT_CS_ROUND_ASTRO  8
  584. # define SPLIT_CS_MOD_360      16
  585. # define SPLIT_CS_MOD_24       32
  586.  
  587. /*******************************************
  588. type definitions
  589. ********************************************/
  590. struct adate {    /* date structure used by revjuls and juldays */
  591.        int day, month, year;
  592.        centisec csec;
  593.        };
  594.  
  595. struct spl_cs {
  596.   centisec cs;
  597.   int sign;
  598.   int degree;
  599.   int min;
  600.   int sec;
  601. };
  602.  
  603. #ifndef ASTROLOG
  604. extern UCHAR *atl_collaps (UCHAR *isp, UCHAR *osp);    /* atlclps.c */
  605. extern UCHAR *atl_uncollaps (UCHAR *isp, UCHAR *osp);
  606.  
  607. extern isalpha256(int);                /* ctype256.c    */
  608. extern isalnum256(int);
  609. extern isupper256(int);
  610. extern toupper256(int);
  611. extern tolower256(int);
  612. extern isspace256(int);
  613.  
  614. /* functions exported by gettext.c */
  615.   extern open_text( char *filename, int max);    /* returns OK or ERR */
  616.   extern void close_text();    
  617.   extern char *get_text(int nr);
  618.   extern char get_textc(int nr);
  619.   extern get_text_array(char *array[], int nr, int arraysie);
  620.     /* returns OK or ERR */
  621.  
  622. # define isdigit256(x) (isascii(x) && isdigit(x))
  623.  
  624. /****************************************
  625.   converts astrodienst daynumber to string
  626. ****************************************/
  627. extern char *adate_to_asc(char *cp, int adate);
  628.  
  629. extern double adate_to_julday(int adate);
  630.  
  631. extern int cut_string(char *s, char *cpos[], int nmax);        /* cutstr.c */
  632. extern char *remove_nl(char *s);    
  633. extern int comma_count(char *s);
  634.  
  635. extern int cut_string_any(char *s, char *cutlist, char *cpos[], int nmax);
  636.         /* cutstr2.c    */
  637.  
  638. extern long d2l(double x);                /* d2l.c    */
  639.  
  640. extern int date_conversion                 /* dateconv.c */
  641.         (int d,
  642.          int m,
  643.          int y,        /* day, month, year */
  644.          centisec gmtime,     /* greenwich time in centiseconds */
  645.          char c,     /* calendar g[regorian]|j[ulian]|a[stro = greg] */
  646.          REAL8 *tgmt    /* julian date relative 0.Jan.1950 12:00 gmt */
  647.                 /* shift is 2433282 from absolute Julian date */
  648.         );            /* return OK or ERR */
  649.  
  650. extern int degstr_conversion (char *s, centisec *t);        /* degstr.c */
  651.  
  652. extern int day_of_week(double jd);            /* julday.c */
  653.     /* monday = 0, ... sunday = 6 */
  654.  
  655. extern double dtime(void);                /* ourtime.c */
  656.     /* returns seconds since 1970, with fraction
  657.        and a resolution of microseconds */
  658.  
  659. extern void ecl_to_equ(double al, double ab, double obl, double *ra, double *d);
  660.                             /* ecl2equ.c */
  661.  
  662. /****************************************
  663.  * gets astrodienst daynumber from system time
  664. ****************************************/
  665. extern int get_adate(void);
  666.  
  667. /* get a long consisting of hhmmss of current time */
  668. extern long get_hms(void);                /* ourtime.c */
  669.  
  670. extern int get_lpb(char *pname);            /* get_lpb.c */
  671.  
  672. extern int hp2ibm(int c);                /* hp2ibm.c    */
  673.  
  674. extern int ibm2hp(int c);                /* ibm2hp.c    */
  675.  
  676. /*
  677.  * interpolation of third order with Newton and Stirling formulas for
  678.  * vectors of double or long.
  679.  * One needs n+1 input values for n output values.
  680.  * u is the normalized x-value to which we interpolate.
  681.  * u is legal within -0.5 .. + 1.0
  682.  * The same array can be used for output and input; the last value will
  683.  * then be unchanged after the call.
  684.  * Attention, the function values must be steady; they cannot have jumps
  685.  * like typical planetary longitudes have when they cross zero degree.
  686.  * You must use make_steady() before calling interpol() otherwise,
  687.  * and later  use norm_range() to normalize again into your range.
  688.  */
  689. extern int interpod(double in[], double out[], double u, int n); /*interpod.c */
  690. extern void make_steady_d(double x[], int n, double range);
  691. extern double norm_range_d(double x, double range);
  692.  
  693. extern int interpol(long in[], long out[], double u, int n); /* interpol.c */
  694. extern void make_steady_l(long x[], int n, long range);
  695. extern long norm_range_l(long x, long range);
  696.  
  697.  
  698. extern double julday(int month, int day, int year, double hour, int gregflag);
  699.                             /* julday.c    */
  700. extern double juldays(int gregflag, struct adate *adp); /* juldays.c    */
  701.  
  702. extern char *kdv_collaps (char *osp, char *isp);    /* kdvclps.c */
  703. extern char *kdv_collaps_w (char *osp, char *isp, char *w);
  704. extern char *string_to_lower(char *c);
  705.  
  706. extern void log_report(FILE *fp, char *s1, char *s2);    /* writelog.c */
  707.  
  708. extern char *get_file_name(char *file_path );
  709. extern char *makepath(char *d, char *s);    /* makepath.c     */
  710.  
  711. extern char *out_ll(char *s, centisec l, char ch_dflt, char ch_opps);
  712.                         /* outll.c    */
  713. extern char *out_merid(char *s, centisec l);    /* outmerid.c    */
  714.  
  715. extern char *nord_to_date(char *cp, long nord);    /* outnord.c */
  716. extern char *out_nord (char *s, long nord);    /* outnord.c */
  717. extern char *out_nords (long nord);        /* outnord.c */
  718. extern char *out_nordhs (long nord, int nhor);/* outnord.c */
  719.  
  720. extern char *out_time(char *s, centisec l);    /* outtime.c    */
  721.  
  722. extern char *print_date_time(char *s);
  723. /*
  724.  * output current date and time in Format: 20-Jul-89 23:20
  725.  */
  726.  
  727. extern char *print_date_time_sec(char *s);
  728. /*
  729.  * output current date and time with 1/100th of second precision
  730.  */
  731.  
  732. extern char *print_timestamp(char *s, long ntst);
  733. /*
  734.  * output ntst date and time in format: 20-Jul-89 23:20
  735.  */
  736.  
  737. extern void revjul (double u,            /* revjul.c */
  738.           int gregflag,
  739.           int *jmon, int *jday, int *jyear,
  740.           double *jut);
  741.  
  742. extern void revjuls(double u, int gregflag, struct adate *adp); /* revjuls.c */
  743.  
  744. extern char *rm_nonprint( char *);            /* rmuscore.c    */
  745. extern char *rm_uscore( char *);            /* rmuscore.c    */
  746.  
  747. extern void split_cs(struct spl_cs *psplit, int roundflag); /* splitcs.c */
  748.  
  749. extern char *stristr(char *si, char *pi);        /* stristr.c    */
  750. /* extern char *strstr(char *si, char *pi);         stristr.c    */
  751.  
  752. extern char *sread(char *s, char *r, int max);        /* sread.c    */
  753.  
  754. extern centisec simple_degstr_conversion(char *s);    /* sdegstr.c    */
  755.  
  756. extern int timestr_conversion(char *s, centisec *t);    /* timestr.c    */
  757.  
  758. extern char *upcase_first_letters( char *s);        /* upcase1.c    */
  759.  
  760. extern char *TimeString (CSEC t, int sep, BOOLEAN suppressZero); /* outdeg.c */
  761. extern char *LonLatString (CSEC t, char pchar, char mchar);    /* outdeg.c */
  762. extern char *DegreeString (CSEC t);                /* outdeg.c */
  763.  
  764. /********************************************************
  765. functions from csec.c
  766. ********************************************************/
  767.  
  768. /*
  769.  * round the arguments to full seconds, takes care with zodiac sign changes:
  770.  * does not round 29_29'59.6" to 0_ of next sign but to 29_29'59"
  771.  */
  772. extern centisec roundsec(centisec x);
  773.  
  774. /* normalizes p into 0..DEG360 by doing a kind of modulo */
  775. extern centisec csnorm(centisec p);
  776. /* the same for degree instead of centisec */
  777. extern double degnorm(double x);
  778.  
  779. /* normalized circle distance p1 - p2, result in [0..360[ */
  780. extern centisec difcsn(centisec p1, centisec p2);    
  781. extern double  difdegn(double x1, double x2);
  782.  
  783. /* normalized circle distance p1 - p2, result in [-180..180[ */
  784. extern centisec difcs2n(centisec p1, centisec p2);    
  785. extern double  difdeg2n(double x1, double x2);
  786.  
  787. extern double dcos(centisec x);            /* trigo. functions for CSEC */
  788. extern double dsin(centisec x);
  789. extern double dtan(centisec x);
  790. extern centisec datan(double x);
  791. extern centisec dasin(double x);
  792. #endif /* ASTROLOG */
  793.  
  794. # endif /* _ASTROLIB_INCLUDED */
  795. #ifdef ASTROLOG
  796. /* End contents of astrolib.h */
  797. #endif
  798. #endif /* ASTROLOG */
  799. #endif /* PLACALC */
  800. #ifdef ASTROLOG
  801. /* End contents of placalc.h */
  802. #endif
  803.