From b1b99e0302955b0d3e308b863516cee246ca84fa Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 12 Aug 2013 17:14:09 +0200 Subject: [PATCH] Reindented Swiss Ephemeris source files for better reabability --- swe/src/swecl.c | 8129 +++++++++++++------------- swe/src/swedate.c | 670 +-- swe/src/swedate.h | 31 +- swe/src/swedll.h | 975 ++-- swe/src/swehel.c | 5860 +++++++++++-------- swe/src/swehouse.c | 2965 +++++----- swe/src/swehouse.h | 22 +- swe/src/swejpl.c | 1301 +++-- swe/src/swejpl.h | 13 +- swe/src/swemmoon.c | 2944 +++++----- swe/src/swemplan.c | 1571 ++--- swe/src/swemptab.c | 12593 ++++++++++++++++++++-------------------- swe/src/swenut2000a.h | 5466 ++++++++--------- swe/src/sweodef.h | 294 +- swe/src/swepcalc.c | 1109 ++-- swe/src/swepcalc.h | 361 +- swe/src/swepdate.c | 87 +- swe/src/sweph.c | 10965 +++++++++++++++++----------------- swe/src/sweph.h | 546 +- swe/src/swephexp.h | 645 +- swe/src/swephlib.c | 4031 +++++++------ swe/src/swephlib.h | 66 +- 22 files changed, 31520 insertions(+), 29124 deletions(-) diff --git a/swe/src/swecl.c b/swe/src/swecl.c index bbe9c18..e76bb96 100644 --- a/swe/src/swecl.c +++ b/swe/src/swecl.c @@ -1,3 +1,4 @@ + /* SWISSEPH $Header: /home/dieter/sweph/RCS/swecl.c,v 1.75 2008/08/26 07:23:27 dieter Exp $ @@ -5,6 +6,7 @@ Author: Dieter Koch ************************************************************/ + /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -65,415 +67,423 @@ #include "swephlib.h" #define SEFLG_EPHMASK (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH) -static int find_maximum(double y00, double y11, double y2, double dx, - double *dxret, double *yret); -static int find_zero(double y00, double y11, double y2, double dx, - double *dxret, double *dxret2); -static double calc_dip(double geoalt, double atpress, double attemp, double lapse_rate); -static double calc_astronomical_refr(double geoalt,double atpress, double attemp); -static double const_lapse_rate = SE_LAPSE_RATE; /* for refraction */ +static int find_maximum(double y00, double y11, double y2, double dx, + double *dxret, double *yret); +static int find_zero(double y00, double y11, double y2, double dx, + double *dxret, double *dxret2); +static double calc_dip(double geoalt, double atpress, double attemp, + double lapse_rate); +static double calc_astronomical_refr(double geoalt, double atpress, + double attemp); +static double const_lapse_rate = SE_LAPSE_RATE; /* for refraction */ #if 0 -#define DSUN (1391978489.9 / AUNIT) /* this value is consistent with - * 959.63 arcsec at AU distance (Astr. Alm.) */ +#define DSUN (1391978489.9 / AUNIT) /* this value is consistent with + * 959.63 arcsec at AU distance (Astr. Alm.) */ #else #define DSUN (1392000000.0 / AUNIT) #endif -#define DMOON (3476300.0 / AUNIT) +#define DMOON (3476300.0 / AUNIT) #define DEARTH (6378140.0 * 2 / AUNIT) #define RSUN (DSUN / 2) #define RMOON (DMOON / 2) #define REARTH (DEARTH / 2) -/*#define SEI_OCC_FAST (16 * 1024L)*/ -static int32 eclipse_where( double tjd_ut, int32 ipl, char *starname, int32 ifl, double *geopos, - double *dcore, char *serr); -static int32 eclipse_how( double tjd_ut, int32 ipl, char *starname, int32 ifl, - double geolon, double geolat, double geohgt, - double *attr, char *serr); -static int32 eclipse_when_loc(double tjd_start, int32 ifl, double *geopos, - double *tret, double *attr, AS_BOOL backward, char *serr); -static int32 occult_when_loc(double tjd_start, int32 ipl, char *starname, int32 ifl, - double *geopos, double *tret, double *attr, AS_BOOL backward, char *serr); -static int32 lun_eclipse_how(double tjd_ut, int32 ifl, double *attr, - double *dcore, char *serr); -static int32 calc_mer_trans( - double tjd_ut, int32 ipl, int32 epheflag, int32 rsmi, - double *geopos, - char *starname, - double *tret, - char *serr); -static int32 calc_planet_star(double tjd_et, int32 ipl, char *starname, int32 iflag, double *x, char *serr); -struct saros_data {int series_no; double tstart;}; +/*#define SEI_OCC_FAST (16 * 1024L)*/ +static int32 eclipse_where(double tjd_ut, int32 ipl, char *starname, + int32 ifl, double *geopos, double *dcore, + char *serr); +static int32 eclipse_how(double tjd_ut, int32 ipl, char *starname, int32 ifl, + double geolon, double geolat, double geohgt, + double *attr, char *serr); +static int32 eclipse_when_loc(double tjd_start, int32 ifl, double *geopos, + double *tret, double *attr, AS_BOOL backward, + char *serr); +static int32 occult_when_loc(double tjd_start, int32 ipl, char *starname, + int32 ifl, double *geopos, double *tret, + double *attr, AS_BOOL backward, char *serr); +static int32 lun_eclipse_how(double tjd_ut, int32 ifl, double *attr, + double *dcore, char *serr); +static int32 calc_mer_trans(double tjd_ut, int32 ipl, int32 epheflag, + int32 rsmi, double *geopos, char *starname, + double *tret, char *serr); +static int32 calc_planet_star(double tjd_et, int32 ipl, char *starname, + int32 iflag, double *x, char *serr); + +struct saros_data +{ + int series_no; + double tstart; +}; #define SAROS_CYCLE 6585.3213 #define NSAROS_SOLAR 181 struct saros_data saros_data_solar[NSAROS_SOLAR] = { -{0, 641886.5}, /* 23 May -2955 */ -{1, 672214.5}, /* 04 Jun -2872 */ -{2, 676200.5}, /* 04 May -2861 */ -{3, 693357.5}, /* 24 Apr -2814 */ -{4, 723685.5}, /* 06 May -2731 */ -{5, 727671.5}, /* 04 Apr -2720 */ -{6, 744829.5}, /* 27 Mar -2673 */ -{7, 775157.5}, /* 08 Apr -2590 */ -{8, 779143.5}, /* 07 Mar -2579 */ -{9, 783131.5}, /* 06 Feb -2568 */ -{10, 820044.5}, /* 28 Feb -2467 */ -{11, 810859.5}, /* 06 Jan -2492 */ -{12, 748993.5}, /* 20 Aug -2662 */ -{13, 792492.5}, /* 23 Sep -2543 */ -{14, 789892.5}, /* 11 Aug -2550 */ -{15, 787294.5}, /* 01 Jul -2557 */ -{16, 824207.5}, /* 23 Jul -2456 */ -{17, 834779.5}, /* 03 Jul -2427 */ -{18, 838766.5}, /* 02 Jun -2416 */ -{19, 869094.5}, /* 15 Jun -2333 */ -{20, 886251.5}, /* 05 Jun -2286 */ -{21, 890238.5}, /* 05 May -2275 */ -{22, 927151.5}, /* 28 May -2174 */ -{23, 937722.5}, /* 07 May -2145 */ -{24, 941709.5}, /* 06 Apr -2134 */ -{25, 978623.5}, /* 30 Apr -2033 */ -{26, 989194.5}, /* 08 Apr -2004 */ -{27, 993181.5}, /* 09 Mar -1993 */ -{28, 1023510.5}, /* 22 Mar -1910 */ -{29, 1034081.5}, /* 01 Mar -1881 */ -{30, 972214.5}, /* 12 Oct -2051 */ -{31, 1061811.5}, /* 31 Jan -1805 */ -{32, 1006529.5}, /* 24 Sep -1957 */ -{33, 997345.5}, /* 02 Aug -1982 */ -{34, 1021088.5}, /* 04 Aug -1917 */ -{35, 1038245.5}, /* 25 Jul -1870 */ -{36, 1042231.5}, /* 23 Jun -1859 */ -{37, 1065974.5}, /* 25 Jun -1794 */ -{38, 1089716.5}, /* 26 Jun -1729 */ -{39, 1093703.5}, /* 26 May -1718 */ -{40, 1117446.5}, /* 28 May -1653 */ -{41, 1141188.5}, /* 28 May -1588 */ -{42, 1145175.5}, /* 28 Apr -1577 */ -{43, 1168918.5}, /* 29 Apr -1512 */ -{44, 1192660.5}, /* 30 Apr -1447 */ -{45, 1196647.5}, /* 30 Mar -1436 */ -{46, 1220390.5}, /* 01 Apr -1371 */ -{47, 1244132.5}, /* 02 Apr -1306 */ -{48, 1234948.5}, /* 08 Feb -1331 */ -{49, 1265277.5}, /* 22 Feb -1248 */ -{50, 1282433.5}, /* 11 Feb -1201 */ -{51, 1207395.5}, /* 02 Sep -1407 */ -{52, 1217968.5}, /* 14 Aug -1378 */ -{53, 1254881.5}, /* 06 Sep -1277 */ -{54, 1252282.5}, /* 25 Jul -1284 */ -{55, 1262855.5}, /* 06 Jul -1255 */ -{56, 1293182.5}, /* 17 Jul -1172 */ -{57, 1297169.5}, /* 17 Jun -1161 */ -{58, 1314326.5}, /* 07 Jun -1114 */ -{59, 1344654.5}, /* 19 Jun -1031 */ -{60, 1348640.5}, /* 18 May -1020 */ -{61, 1365798.5}, /* 10 May -0973 */ -{62, 1396126.5}, /* 22 May -0890 */ -{63, 1400112.5}, /* 20 Apr -0879 */ -{64, 1417270.5}, /* 11 Apr -0832 */ -{65, 1447598.5}, /* 24 Apr -0749 */ -{66, 1444999.5}, /* 12 Mar -0756 */ -{67, 1462157.5}, /* 04 Mar -0709 */ -{68, 1492485.5}, /* 16 Mar -0626 */ -{69, 1456959.5}, /* 09 Dec -0724 */ -{70, 1421434.5}, /* 05 Sep -0821 */ -{71, 1471518.5}, /* 19 Oct -0684 */ -{72, 1455748.5}, /* 16 Aug -0727 */ -{73, 1466320.5}, /* 27 Jul -0698 */ -{74, 1496648.5}, /* 08 Aug -0615 */ -{75, 1500634.5}, /* 07 Jul -0604 */ -{76, 1511207.5}, /* 18 Jun -0575 */ -{77, 1548120.5}, /* 11 Jul -0474 */ -{78, 1552106.5}, /* 09 Jun -0463 */ -{79, 1562679.5}, /* 21 May -0434 */ -{80, 1599592.5}, /* 13 Jun -0333 */ -{81, 1603578.5}, /* 12 May -0322 */ -{82, 1614150.5}, /* 22 Apr -0293 */ -{83, 1644479.5}, /* 05 May -0210 */ -{84, 1655050.5}, /* 14 Apr -0181 */ -{85, 1659037.5}, /* 14 Mar -0170 */ -{86, 1695950.5}, /* 06 Apr -0069 */ -{87, 1693351.5}, /* 23 Feb -0076 */ -{88, 1631484.5}, /* 06 Oct -0246 */ -{89, 1727666.5}, /* 04 Feb 0018 */ -{90, 1672384.5}, /* 28 Sep -0134 */ -{91, 1663200.5}, /* 06 Aug -0159 */ -{92, 1693529.5}, /* 19 Aug -0076 */ -{93, 1710685.5}, /* 09 Aug -0029 */ -{94, 1714672.5}, /* 09 Jul -0018 */ -{95, 1738415.5}, /* 11 Jul 0047 */ -{96, 1755572.5}, /* 01 Jul 0094 */ -{97, 1766144.5}, /* 11 Jun 0123 */ -{98, 1789887.5}, /* 12 Jun 0188 */ -{99, 1807044.5}, /* 03 Jun 0235 */ -{100, 1817616.5}, /* 13 May 0264 */ -{101, 1841359.5}, /* 15 May 0329 */ -{102, 1858516.5}, /* 05 May 0376 */ -{103, 1862502.5}, /* 04 Apr 0387 */ -{104, 1892831.5}, /* 17 Apr 0470 */ -{105, 1903402.5}, /* 27 Mar 0499 */ -{106, 1887633.5}, /* 23 Jan 0456 */ -{107, 1924547.5}, /* 15 Feb 0557 */ -{108, 1921948.5}, /* 04 Jan 0550 */ -{109, 1873251.5}, /* 07 Sep 0416 */ -{110, 1890409.5}, /* 30 Aug 0463 */ -{111, 1914151.5}, /* 30 Aug 0528 */ -{112, 1918138.5}, /* 31 Jul 0539 */ -{113, 1935296.5}, /* 22 Jul 0586 */ -{114, 1959038.5}, /* 23 Jul 0651 */ -{115, 1963024.5}, /* 21 Jun 0662 */ -{116, 1986767.5}, /* 23 Jun 0727 */ -{117, 2010510.5}, /* 24 Jun 0792 */ -{118, 2014496.5}, /* 24 May 0803 */ -{119, 2031654.5}, /* 15 May 0850 */ -{120, 2061982.5}, /* 27 May 0933 */ -{121, 2065968.5}, /* 25 Apr 0944 */ -{122, 2083126.5}, /* 17 Apr 0991 */ -{123, 2113454.5}, /* 29 Apr 1074 */ -{124, 2104269.5}, /* 06 Mar 1049 */ -{125, 2108256.5}, /* 04 Feb 1060 */ -{126, 2151755.5}, /* 10 Mar 1179 */ -{127, 2083302.5}, /* 10 Oct 0991 */ -{128, 2080704.5}, /* 29 Aug 0984 */ -{129, 2124203.5}, /* 03 Oct 1103 */ -{130, 2121603.5}, /* 20 Aug 1096 */ -{131, 2132176.5}, /* 01 Aug 1125 */ -{132, 2162504.5}, /* 13 Aug 1208 */ -{133, 2166490.5}, /* 13 Jul 1219 */ -{134, 2177062.5}, /* 22 Jun 1248 */ -{135, 2207390.5}, /* 05 Jul 1331 */ -{136, 2217962.5}, /* 14 Jun 1360 */ -{137, 2228534.5}, /* 25 May 1389 */ -{138, 2258862.5}, /* 06 Jun 1472 */ -{139, 2269434.5}, /* 17 May 1501 */ -{140, 2273421.5}, /* 16 Apr 1512 */ -{141, 2310334.5}, /* 19 May 1613 */ -{142, 2314320.5}, /* 17 Apr 1624 */ -{143, 2311722.5}, /* 07 Mar 1617 */ -{144, 2355221.5}, /* 11 Apr 1736 */ -{145, 2319695.5}, /* 04 Jan 1639 */ -{146, 2284169.5}, /* 19 Sep 1541 */ -{147, 2314498.5}, /* 12 Oct 1624 */ -{148, 2325069.5}, /* 21 Sep 1653 */ -{149, 2329056.5}, /* 21 Aug 1664 */ -{150, 2352799.5}, /* 24 Aug 1729 */ -{151, 2369956.5}, /* 14 Aug 1776 */ -{152, 2380528.5}, /* 26 Jul 1805 */ -{153, 2404271.5}, /* 28 Jul 1870 */ -{154, 2421428.5}, /* 19 Jul 1917 */ -{155, 2425414.5}, /* 17 Jun 1928 */ -{156, 2455743.5}, /* 01 Jul 2011 */ -{157, 2472900.5}, /* 21 Jun 2058 */ -{158, 2476886.5}, /* 20 May 2069 */ -{159, 2500629.5}, /* 23 May 2134 */ -{160, 2517786.5}, /* 13 May 2181 */ -{161, 2515187.5}, /* 01 Apr 2174 */ -{162, 2545516.5}, /* 15 Apr 2257 */ -{163, 2556087.5}, /* 25 Mar 2286 */ -{164, 2487635.5}, /* 24 Oct 2098 */ -{165, 2504793.5}, /* 16 Oct 2145 */ -{166, 2535121.5}, /* 29 Oct 2228 */ -{167, 2525936.5}, /* 06 Sep 2203 */ -{168, 2543094.5}, /* 28 Aug 2250 */ -{169, 2573422.5}, /* 10 Sep 2333 */ -{170, 2577408.5}, /* 09 Aug 2344 */ -{171, 2594566.5}, /* 01 Aug 2391 */ -{172, 2624894.5}, /* 13 Aug 2474 */ -{173, 2628880.5}, /* 12 Jul 2485 */ -{174, 2646038.5}, /* 04 Jul 2532 */ -{175, 2669780.5}, /* 05 Jul 2597 */ -{176, 2673766.5}, /* 04 Jun 2608 */ -{177, 2690924.5}, /* 27 May 2655 */ -{178, 2721252.5}, /* 09 Jun 2738 */ -{179, 2718653.5}, /* 28 Apr 2731 */ -{180, 2729226.5}, /* 08 Apr 2760 */ + {0, 641886.5}, /* 23 May -2955 */ + {1, 672214.5}, /* 04 Jun -2872 */ + {2, 676200.5}, /* 04 May -2861 */ + {3, 693357.5}, /* 24 Apr -2814 */ + {4, 723685.5}, /* 06 May -2731 */ + {5, 727671.5}, /* 04 Apr -2720 */ + {6, 744829.5}, /* 27 Mar -2673 */ + {7, 775157.5}, /* 08 Apr -2590 */ + {8, 779143.5}, /* 07 Mar -2579 */ + {9, 783131.5}, /* 06 Feb -2568 */ + {10, 820044.5}, /* 28 Feb -2467 */ + {11, 810859.5}, /* 06 Jan -2492 */ + {12, 748993.5}, /* 20 Aug -2662 */ + {13, 792492.5}, /* 23 Sep -2543 */ + {14, 789892.5}, /* 11 Aug -2550 */ + {15, 787294.5}, /* 01 Jul -2557 */ + {16, 824207.5}, /* 23 Jul -2456 */ + {17, 834779.5}, /* 03 Jul -2427 */ + {18, 838766.5}, /* 02 Jun -2416 */ + {19, 869094.5}, /* 15 Jun -2333 */ + {20, 886251.5}, /* 05 Jun -2286 */ + {21, 890238.5}, /* 05 May -2275 */ + {22, 927151.5}, /* 28 May -2174 */ + {23, 937722.5}, /* 07 May -2145 */ + {24, 941709.5}, /* 06 Apr -2134 */ + {25, 978623.5}, /* 30 Apr -2033 */ + {26, 989194.5}, /* 08 Apr -2004 */ + {27, 993181.5}, /* 09 Mar -1993 */ + {28, 1023510.5}, /* 22 Mar -1910 */ + {29, 1034081.5}, /* 01 Mar -1881 */ + {30, 972214.5}, /* 12 Oct -2051 */ + {31, 1061811.5}, /* 31 Jan -1805 */ + {32, 1006529.5}, /* 24 Sep -1957 */ + {33, 997345.5}, /* 02 Aug -1982 */ + {34, 1021088.5}, /* 04 Aug -1917 */ + {35, 1038245.5}, /* 25 Jul -1870 */ + {36, 1042231.5}, /* 23 Jun -1859 */ + {37, 1065974.5}, /* 25 Jun -1794 */ + {38, 1089716.5}, /* 26 Jun -1729 */ + {39, 1093703.5}, /* 26 May -1718 */ + {40, 1117446.5}, /* 28 May -1653 */ + {41, 1141188.5}, /* 28 May -1588 */ + {42, 1145175.5}, /* 28 Apr -1577 */ + {43, 1168918.5}, /* 29 Apr -1512 */ + {44, 1192660.5}, /* 30 Apr -1447 */ + {45, 1196647.5}, /* 30 Mar -1436 */ + {46, 1220390.5}, /* 01 Apr -1371 */ + {47, 1244132.5}, /* 02 Apr -1306 */ + {48, 1234948.5}, /* 08 Feb -1331 */ + {49, 1265277.5}, /* 22 Feb -1248 */ + {50, 1282433.5}, /* 11 Feb -1201 */ + {51, 1207395.5}, /* 02 Sep -1407 */ + {52, 1217968.5}, /* 14 Aug -1378 */ + {53, 1254881.5}, /* 06 Sep -1277 */ + {54, 1252282.5}, /* 25 Jul -1284 */ + {55, 1262855.5}, /* 06 Jul -1255 */ + {56, 1293182.5}, /* 17 Jul -1172 */ + {57, 1297169.5}, /* 17 Jun -1161 */ + {58, 1314326.5}, /* 07 Jun -1114 */ + {59, 1344654.5}, /* 19 Jun -1031 */ + {60, 1348640.5}, /* 18 May -1020 */ + {61, 1365798.5}, /* 10 May -0973 */ + {62, 1396126.5}, /* 22 May -0890 */ + {63, 1400112.5}, /* 20 Apr -0879 */ + {64, 1417270.5}, /* 11 Apr -0832 */ + {65, 1447598.5}, /* 24 Apr -0749 */ + {66, 1444999.5}, /* 12 Mar -0756 */ + {67, 1462157.5}, /* 04 Mar -0709 */ + {68, 1492485.5}, /* 16 Mar -0626 */ + {69, 1456959.5}, /* 09 Dec -0724 */ + {70, 1421434.5}, /* 05 Sep -0821 */ + {71, 1471518.5}, /* 19 Oct -0684 */ + {72, 1455748.5}, /* 16 Aug -0727 */ + {73, 1466320.5}, /* 27 Jul -0698 */ + {74, 1496648.5}, /* 08 Aug -0615 */ + {75, 1500634.5}, /* 07 Jul -0604 */ + {76, 1511207.5}, /* 18 Jun -0575 */ + {77, 1548120.5}, /* 11 Jul -0474 */ + {78, 1552106.5}, /* 09 Jun -0463 */ + {79, 1562679.5}, /* 21 May -0434 */ + {80, 1599592.5}, /* 13 Jun -0333 */ + {81, 1603578.5}, /* 12 May -0322 */ + {82, 1614150.5}, /* 22 Apr -0293 */ + {83, 1644479.5}, /* 05 May -0210 */ + {84, 1655050.5}, /* 14 Apr -0181 */ + {85, 1659037.5}, /* 14 Mar -0170 */ + {86, 1695950.5}, /* 06 Apr -0069 */ + {87, 1693351.5}, /* 23 Feb -0076 */ + {88, 1631484.5}, /* 06 Oct -0246 */ + {89, 1727666.5}, /* 04 Feb 0018 */ + {90, 1672384.5}, /* 28 Sep -0134 */ + {91, 1663200.5}, /* 06 Aug -0159 */ + {92, 1693529.5}, /* 19 Aug -0076 */ + {93, 1710685.5}, /* 09 Aug -0029 */ + {94, 1714672.5}, /* 09 Jul -0018 */ + {95, 1738415.5}, /* 11 Jul 0047 */ + {96, 1755572.5}, /* 01 Jul 0094 */ + {97, 1766144.5}, /* 11 Jun 0123 */ + {98, 1789887.5}, /* 12 Jun 0188 */ + {99, 1807044.5}, /* 03 Jun 0235 */ + {100, 1817616.5}, /* 13 May 0264 */ + {101, 1841359.5}, /* 15 May 0329 */ + {102, 1858516.5}, /* 05 May 0376 */ + {103, 1862502.5}, /* 04 Apr 0387 */ + {104, 1892831.5}, /* 17 Apr 0470 */ + {105, 1903402.5}, /* 27 Mar 0499 */ + {106, 1887633.5}, /* 23 Jan 0456 */ + {107, 1924547.5}, /* 15 Feb 0557 */ + {108, 1921948.5}, /* 04 Jan 0550 */ + {109, 1873251.5}, /* 07 Sep 0416 */ + {110, 1890409.5}, /* 30 Aug 0463 */ + {111, 1914151.5}, /* 30 Aug 0528 */ + {112, 1918138.5}, /* 31 Jul 0539 */ + {113, 1935296.5}, /* 22 Jul 0586 */ + {114, 1959038.5}, /* 23 Jul 0651 */ + {115, 1963024.5}, /* 21 Jun 0662 */ + {116, 1986767.5}, /* 23 Jun 0727 */ + {117, 2010510.5}, /* 24 Jun 0792 */ + {118, 2014496.5}, /* 24 May 0803 */ + {119, 2031654.5}, /* 15 May 0850 */ + {120, 2061982.5}, /* 27 May 0933 */ + {121, 2065968.5}, /* 25 Apr 0944 */ + {122, 2083126.5}, /* 17 Apr 0991 */ + {123, 2113454.5}, /* 29 Apr 1074 */ + {124, 2104269.5}, /* 06 Mar 1049 */ + {125, 2108256.5}, /* 04 Feb 1060 */ + {126, 2151755.5}, /* 10 Mar 1179 */ + {127, 2083302.5}, /* 10 Oct 0991 */ + {128, 2080704.5}, /* 29 Aug 0984 */ + {129, 2124203.5}, /* 03 Oct 1103 */ + {130, 2121603.5}, /* 20 Aug 1096 */ + {131, 2132176.5}, /* 01 Aug 1125 */ + {132, 2162504.5}, /* 13 Aug 1208 */ + {133, 2166490.5}, /* 13 Jul 1219 */ + {134, 2177062.5}, /* 22 Jun 1248 */ + {135, 2207390.5}, /* 05 Jul 1331 */ + {136, 2217962.5}, /* 14 Jun 1360 */ + {137, 2228534.5}, /* 25 May 1389 */ + {138, 2258862.5}, /* 06 Jun 1472 */ + {139, 2269434.5}, /* 17 May 1501 */ + {140, 2273421.5}, /* 16 Apr 1512 */ + {141, 2310334.5}, /* 19 May 1613 */ + {142, 2314320.5}, /* 17 Apr 1624 */ + {143, 2311722.5}, /* 07 Mar 1617 */ + {144, 2355221.5}, /* 11 Apr 1736 */ + {145, 2319695.5}, /* 04 Jan 1639 */ + {146, 2284169.5}, /* 19 Sep 1541 */ + {147, 2314498.5}, /* 12 Oct 1624 */ + {148, 2325069.5}, /* 21 Sep 1653 */ + {149, 2329056.5}, /* 21 Aug 1664 */ + {150, 2352799.5}, /* 24 Aug 1729 */ + {151, 2369956.5}, /* 14 Aug 1776 */ + {152, 2380528.5}, /* 26 Jul 1805 */ + {153, 2404271.5}, /* 28 Jul 1870 */ + {154, 2421428.5}, /* 19 Jul 1917 */ + {155, 2425414.5}, /* 17 Jun 1928 */ + {156, 2455743.5}, /* 01 Jul 2011 */ + {157, 2472900.5}, /* 21 Jun 2058 */ + {158, 2476886.5}, /* 20 May 2069 */ + {159, 2500629.5}, /* 23 May 2134 */ + {160, 2517786.5}, /* 13 May 2181 */ + {161, 2515187.5}, /* 01 Apr 2174 */ + {162, 2545516.5}, /* 15 Apr 2257 */ + {163, 2556087.5}, /* 25 Mar 2286 */ + {164, 2487635.5}, /* 24 Oct 2098 */ + {165, 2504793.5}, /* 16 Oct 2145 */ + {166, 2535121.5}, /* 29 Oct 2228 */ + {167, 2525936.5}, /* 06 Sep 2203 */ + {168, 2543094.5}, /* 28 Aug 2250 */ + {169, 2573422.5}, /* 10 Sep 2333 */ + {170, 2577408.5}, /* 09 Aug 2344 */ + {171, 2594566.5}, /* 01 Aug 2391 */ + {172, 2624894.5}, /* 13 Aug 2474 */ + {173, 2628880.5}, /* 12 Jul 2485 */ + {174, 2646038.5}, /* 04 Jul 2532 */ + {175, 2669780.5}, /* 05 Jul 2597 */ + {176, 2673766.5}, /* 04 Jun 2608 */ + {177, 2690924.5}, /* 27 May 2655 */ + {178, 2721252.5}, /* 09 Jun 2738 */ + {179, 2718653.5}, /* 28 Apr 2731 */ + {180, 2729226.5}, /* 08 Apr 2760 */ }; #define NSAROS_LUNAR 180 struct saros_data saros_data_lunar[NSAROS_LUNAR] = { -{1, 782437.5}, /* 14 Mar -2570 */ -{2, 799593.5}, /* 03 Mar -2523 */ -{3, 783824.5}, /* 30 Dec -2567 */ -{4, 754884.5}, /* 06 Oct -2646 */ -{5, 824724.5}, /* 22 Dec -2455 */ -{6, 762857.5}, /* 04 Aug -2624 */ -{7, 773430.5}, /* 16 Jul -2595 */ -{8, 810343.5}, /* 08 Aug -2494 */ -{9, 807743.5}, /* 26 Jun -2501 */ -{10, 824901.5}, /* 17 Jun -2454 */ -{11, 855229.5}, /* 29 Jun -2371 */ -{12, 859215.5}, /* 28 May -2360 */ -{13, 876373.5}, /* 20 May -2313 */ -{14, 906701.5}, /* 01 Jun -2230 */ -{15, 910687.5}, /* 30 Apr -2219 */ -{16, 927845.5}, /* 21 Apr -2172 */ -{17, 958173.5}, /* 04 May -2089 */ -{18, 962159.5}, /* 02 Apr -2078 */ -{19, 979317.5}, /* 24 Mar -2031 */ -{20, 1009645.5}, /* 05 Apr -1948 */ -{21, 1007046.5}, /* 22 Feb -1955 */ -{22, 1017618.5}, /* 02 Feb -1926 */ -{23, 1054531.5}, /* 25 Feb -1825 */ -{24, 979493.5}, /* 16 Sep -2031 */ -{25, 976895.5}, /* 06 Aug -2038 */ -{26, 1020394.5}, /* 09 Sep -1919 */ -{27, 1017794.5}, /* 28 Jul -1926 */ -{28, 1028367.5}, /* 09 Jul -1897 */ -{29, 1058695.5}, /* 21 Jul -1814 */ -{30, 1062681.5}, /* 19 Jun -1803 */ -{31, 1073253.5}, /* 30 May -1774 */ -{32, 1110167.5}, /* 23 Jun -1673 */ -{33, 1114153.5}, /* 22 May -1662 */ -{34, 1131311.5}, /* 13 May -1615 */ -{35, 1161639.5}, /* 25 May -1532 */ -{36, 1165625.5}, /* 24 Apr -1521 */ -{37, 1176197.5}, /* 03 Apr -1492 */ -{38, 1213111.5}, /* 27 Apr -1391 */ -{39, 1217097.5}, /* 26 Mar -1380 */ -{40, 1221084.5}, /* 24 Feb -1369 */ -{41, 1257997.5}, /* 18 Mar -1268 */ -{42, 1255398.5}, /* 04 Feb -1275 */ -{43, 1186946.5}, /* 07 Sep -1463 */ -{44, 1283128.5}, /* 06 Jan -1199 */ -{45, 1227845.5}, /* 29 Aug -1351 */ -{46, 1225247.5}, /* 19 Jul -1358 */ -{47, 1255575.5}, /* 31 Jul -1275 */ -{48, 1272732.5}, /* 21 Jul -1228 */ -{49, 1276719.5}, /* 21 Jun -1217 */ -{50, 1307047.5}, /* 03 Jul -1134 */ -{51, 1317619.5}, /* 13 Jun -1105 */ -{52, 1328191.5}, /* 23 May -1076 */ -{53, 1358519.5}, /* 05 Jun -0993 */ -{54, 1375676.5}, /* 26 May -0946 */ -{55, 1379663.5}, /* 25 Apr -0935 */ -{56, 1409991.5}, /* 07 May -0852 */ -{57, 1420562.5}, /* 16 Apr -0823 */ -{58, 1424549.5}, /* 16 Mar -0812 */ -{59, 1461463.5}, /* 09 Apr -0711 */ -{60, 1465449.5}, /* 08 Mar -0700 */ -{61, 1436509.5}, /* 13 Dec -0780 */ -{62, 1493179.5}, /* 08 Feb -0624 */ -{63, 1457653.5}, /* 03 Nov -0722 */ -{64, 1435298.5}, /* 20 Aug -0783 */ -{65, 1452456.5}, /* 11 Aug -0736 */ -{66, 1476198.5}, /* 12 Aug -0671 */ -{67, 1480184.5}, /* 11 Jul -0660 */ -{68, 1503928.5}, /* 14 Jul -0595 */ -{69, 1527670.5}, /* 15 Jul -0530 */ -{70, 1531656.5}, /* 13 Jun -0519 */ -{71, 1548814.5}, /* 04 Jun -0472 */ -{72, 1579142.5}, /* 17 Jun -0389 */ -{73, 1583128.5}, /* 16 May -0378 */ -{74, 1600286.5}, /* 07 May -0331 */ -{75, 1624028.5}, /* 08 May -0266 */ -{76, 1628015.5}, /* 07 Apr -0255 */ -{77, 1651758.5}, /* 09 Apr -0190 */ -{78, 1675500.5}, /* 10 Apr -0125 */ -{79, 1672901.5}, /* 27 Feb -0132 */ -{80, 1683474.5}, /* 07 Feb -0103 */ -{81, 1713801.5}, /* 19 Feb -0020 */ -{82, 1645349.5}, /* 21 Sep -0208 */ -{83, 1649336.5}, /* 22 Aug -0197 */ -{84, 1686249.5}, /* 13 Sep -0096 */ -{85, 1683650.5}, /* 02 Aug -0103 */ -{86, 1694222.5}, /* 13 Jul -0074 */ -{87, 1731136.5}, /* 06 Aug 0027 */ -{88, 1735122.5}, /* 05 Jul 0038 */ -{89, 1745694.5}, /* 15 Jun 0067 */ -{90, 1776022.5}, /* 27 Jun 0150 */ -{91, 1786594.5}, /* 07 Jun 0179 */ -{92, 1797166.5}, /* 17 May 0208 */ -{93, 1827494.5}, /* 30 May 0291 */ -{94, 1838066.5}, /* 09 May 0320 */ -{95, 1848638.5}, /* 19 Apr 0349 */ -{96, 1878966.5}, /* 01 May 0432 */ -{97, 1882952.5}, /* 31 Mar 0443 */ -{98, 1880354.5}, /* 18 Feb 0436 */ -{99, 1923853.5}, /* 24 Mar 0555 */ -{100, 1881741.5}, /* 06 Dec 0439 */ -{101, 1852801.5}, /* 11 Sep 0360 */ -{102, 1889715.5}, /* 05 Oct 0461 */ -{103, 1893701.5}, /* 03 Sep 0472 */ -{104, 1897688.5}, /* 04 Aug 0483 */ -{105, 1928016.5}, /* 16 Aug 0566 */ -{106, 1938588.5}, /* 27 Jul 0595 */ -{107, 1942575.5}, /* 26 Jun 0606 */ -{108, 1972903.5}, /* 08 Jul 0689 */ -{109, 1990059.5}, /* 27 Jun 0736 */ -{110, 1994046.5}, /* 28 May 0747 */ -{111, 2024375.5}, /* 10 Jun 0830 */ -{112, 2034946.5}, /* 20 May 0859 */ -{113, 2045518.5}, /* 29 Apr 0888 */ -{114, 2075847.5}, /* 13 May 0971 */ -{115, 2086418.5}, /* 21 Apr 1000 */ -{116, 2083820.5}, /* 11 Mar 0993 */ -{117, 2120733.5}, /* 03 Apr 1094 */ -{118, 2124719.5}, /* 02 Mar 1105 */ -{119, 2062852.5}, /* 14 Oct 0935 */ -{120, 2086596.5}, /* 16 Oct 1000 */ -{121, 2103752.5}, /* 06 Oct 1047 */ -{122, 2094568.5}, /* 14 Aug 1022 */ -{123, 2118311.5}, /* 16 Aug 1087 */ -{124, 2142054.5}, /* 17 Aug 1152 */ -{125, 2146040.5}, /* 17 Jul 1163 */ -{126, 2169783.5}, /* 18 Jul 1228 */ -{127, 2186940.5}, /* 09 Jul 1275 */ -{128, 2197512.5}, /* 18 Jun 1304 */ -{129, 2214670.5}, /* 10 Jun 1351 */ -{130, 2238412.5}, /* 10 Jun 1416 */ -{131, 2242398.5}, /* 10 May 1427 */ -{132, 2266142.5}, /* 12 May 1492 */ -{133, 2289884.5}, /* 13 May 1557 */ -{134, 2287285.5}, /* 01 Apr 1550 */ -{135, 2311028.5}, /* 13 Apr 1615 */ -{136, 2334770.5}, /* 13 Apr 1680 */ -{137, 2292659.5}, /* 17 Dec 1564 */ -{138, 2276890.5}, /* 15 Oct 1521 */ -{139, 2326974.5}, /* 09 Dec 1658 */ -{140, 2304619.5}, /* 25 Sep 1597 */ -{141, 2308606.5}, /* 25 Aug 1608 */ -{142, 2345520.5}, /* 19 Sep 1709 */ -{143, 2349506.5}, /* 18 Aug 1720 */ -{144, 2360078.5}, /* 29 Jul 1749 */ -{145, 2390406.5}, /* 11 Aug 1832 */ -{146, 2394392.5}, /* 11 Jul 1843 */ -{147, 2411550.5}, /* 02 Jul 1890 */ -{148, 2441878.5}, /* 15 Jul 1973 */ -{149, 2445864.5}, /* 13 Jun 1984 */ -{150, 2456437.5}, /* 25 May 2013 */ -{151, 2486765.5}, /* 06 Jun 2096 */ -{152, 2490751.5}, /* 07 May 2107 */ -{153, 2501323.5}, /* 16 Apr 2136 */ -{154, 2538236.5}, /* 10 May 2237 */ -{155, 2529052.5}, /* 18 Mar 2212 */ -{156, 2473771.5}, /* 08 Nov 2060 */ -{157, 2563367.5}, /* 01 Mar 2306 */ -{158, 2508085.5}, /* 21 Oct 2154 */ -{159, 2505486.5}, /* 09 Sep 2147 */ -{160, 2542400.5}, /* 03 Oct 2248 */ -{161, 2546386.5}, /* 02 Sep 2259 */ -{162, 2556958.5}, /* 12 Aug 2288 */ -{163, 2587287.5}, /* 27 Aug 2371 */ -{164, 2597858.5}, /* 05 Aug 2400 */ -{165, 2601845.5}, /* 06 Jul 2411 */ -{166, 2632173.5}, /* 18 Jul 2494 */ -{167, 2649330.5}, /* 09 Jul 2541 */ -{168, 2653317.5}, /* 08 Jun 2552 */ -{169, 2683645.5}, /* 22 Jun 2635 */ -{170, 2694217.5}, /* 01 Jun 2664 */ -{171, 2698203.5}, /* 01 May 2675 */ -{172, 2728532.5}, /* 15 May 2758 */ -{173, 2739103.5}, /* 24 Apr 2787 */ -{174, 2683822.5}, /* 16 Dec 2635 */ -{175, 2740492.5}, /* 11 Feb 2791 */ -{176, 2724722.5}, /* 09 Dec 2747 */ -{177, 2708952.5}, /* 05 Oct 2704 */ -{178, 2732695.5}, /* 07 Oct 2769 */ -{179, 2749852.5}, /* 27 Sep 2816 */ -{180, 2753839.5}, /* 28 Aug 2827 */ + {1, 782437.5}, /* 14 Mar -2570 */ + {2, 799593.5}, /* 03 Mar -2523 */ + {3, 783824.5}, /* 30 Dec -2567 */ + {4, 754884.5}, /* 06 Oct -2646 */ + {5, 824724.5}, /* 22 Dec -2455 */ + {6, 762857.5}, /* 04 Aug -2624 */ + {7, 773430.5}, /* 16 Jul -2595 */ + {8, 810343.5}, /* 08 Aug -2494 */ + {9, 807743.5}, /* 26 Jun -2501 */ + {10, 824901.5}, /* 17 Jun -2454 */ + {11, 855229.5}, /* 29 Jun -2371 */ + {12, 859215.5}, /* 28 May -2360 */ + {13, 876373.5}, /* 20 May -2313 */ + {14, 906701.5}, /* 01 Jun -2230 */ + {15, 910687.5}, /* 30 Apr -2219 */ + {16, 927845.5}, /* 21 Apr -2172 */ + {17, 958173.5}, /* 04 May -2089 */ + {18, 962159.5}, /* 02 Apr -2078 */ + {19, 979317.5}, /* 24 Mar -2031 */ + {20, 1009645.5}, /* 05 Apr -1948 */ + {21, 1007046.5}, /* 22 Feb -1955 */ + {22, 1017618.5}, /* 02 Feb -1926 */ + {23, 1054531.5}, /* 25 Feb -1825 */ + {24, 979493.5}, /* 16 Sep -2031 */ + {25, 976895.5}, /* 06 Aug -2038 */ + {26, 1020394.5}, /* 09 Sep -1919 */ + {27, 1017794.5}, /* 28 Jul -1926 */ + {28, 1028367.5}, /* 09 Jul -1897 */ + {29, 1058695.5}, /* 21 Jul -1814 */ + {30, 1062681.5}, /* 19 Jun -1803 */ + {31, 1073253.5}, /* 30 May -1774 */ + {32, 1110167.5}, /* 23 Jun -1673 */ + {33, 1114153.5}, /* 22 May -1662 */ + {34, 1131311.5}, /* 13 May -1615 */ + {35, 1161639.5}, /* 25 May -1532 */ + {36, 1165625.5}, /* 24 Apr -1521 */ + {37, 1176197.5}, /* 03 Apr -1492 */ + {38, 1213111.5}, /* 27 Apr -1391 */ + {39, 1217097.5}, /* 26 Mar -1380 */ + {40, 1221084.5}, /* 24 Feb -1369 */ + {41, 1257997.5}, /* 18 Mar -1268 */ + {42, 1255398.5}, /* 04 Feb -1275 */ + {43, 1186946.5}, /* 07 Sep -1463 */ + {44, 1283128.5}, /* 06 Jan -1199 */ + {45, 1227845.5}, /* 29 Aug -1351 */ + {46, 1225247.5}, /* 19 Jul -1358 */ + {47, 1255575.5}, /* 31 Jul -1275 */ + {48, 1272732.5}, /* 21 Jul -1228 */ + {49, 1276719.5}, /* 21 Jun -1217 */ + {50, 1307047.5}, /* 03 Jul -1134 */ + {51, 1317619.5}, /* 13 Jun -1105 */ + {52, 1328191.5}, /* 23 May -1076 */ + {53, 1358519.5}, /* 05 Jun -0993 */ + {54, 1375676.5}, /* 26 May -0946 */ + {55, 1379663.5}, /* 25 Apr -0935 */ + {56, 1409991.5}, /* 07 May -0852 */ + {57, 1420562.5}, /* 16 Apr -0823 */ + {58, 1424549.5}, /* 16 Mar -0812 */ + {59, 1461463.5}, /* 09 Apr -0711 */ + {60, 1465449.5}, /* 08 Mar -0700 */ + {61, 1436509.5}, /* 13 Dec -0780 */ + {62, 1493179.5}, /* 08 Feb -0624 */ + {63, 1457653.5}, /* 03 Nov -0722 */ + {64, 1435298.5}, /* 20 Aug -0783 */ + {65, 1452456.5}, /* 11 Aug -0736 */ + {66, 1476198.5}, /* 12 Aug -0671 */ + {67, 1480184.5}, /* 11 Jul -0660 */ + {68, 1503928.5}, /* 14 Jul -0595 */ + {69, 1527670.5}, /* 15 Jul -0530 */ + {70, 1531656.5}, /* 13 Jun -0519 */ + {71, 1548814.5}, /* 04 Jun -0472 */ + {72, 1579142.5}, /* 17 Jun -0389 */ + {73, 1583128.5}, /* 16 May -0378 */ + {74, 1600286.5}, /* 07 May -0331 */ + {75, 1624028.5}, /* 08 May -0266 */ + {76, 1628015.5}, /* 07 Apr -0255 */ + {77, 1651758.5}, /* 09 Apr -0190 */ + {78, 1675500.5}, /* 10 Apr -0125 */ + {79, 1672901.5}, /* 27 Feb -0132 */ + {80, 1683474.5}, /* 07 Feb -0103 */ + {81, 1713801.5}, /* 19 Feb -0020 */ + {82, 1645349.5}, /* 21 Sep -0208 */ + {83, 1649336.5}, /* 22 Aug -0197 */ + {84, 1686249.5}, /* 13 Sep -0096 */ + {85, 1683650.5}, /* 02 Aug -0103 */ + {86, 1694222.5}, /* 13 Jul -0074 */ + {87, 1731136.5}, /* 06 Aug 0027 */ + {88, 1735122.5}, /* 05 Jul 0038 */ + {89, 1745694.5}, /* 15 Jun 0067 */ + {90, 1776022.5}, /* 27 Jun 0150 */ + {91, 1786594.5}, /* 07 Jun 0179 */ + {92, 1797166.5}, /* 17 May 0208 */ + {93, 1827494.5}, /* 30 May 0291 */ + {94, 1838066.5}, /* 09 May 0320 */ + {95, 1848638.5}, /* 19 Apr 0349 */ + {96, 1878966.5}, /* 01 May 0432 */ + {97, 1882952.5}, /* 31 Mar 0443 */ + {98, 1880354.5}, /* 18 Feb 0436 */ + {99, 1923853.5}, /* 24 Mar 0555 */ + {100, 1881741.5}, /* 06 Dec 0439 */ + {101, 1852801.5}, /* 11 Sep 0360 */ + {102, 1889715.5}, /* 05 Oct 0461 */ + {103, 1893701.5}, /* 03 Sep 0472 */ + {104, 1897688.5}, /* 04 Aug 0483 */ + {105, 1928016.5}, /* 16 Aug 0566 */ + {106, 1938588.5}, /* 27 Jul 0595 */ + {107, 1942575.5}, /* 26 Jun 0606 */ + {108, 1972903.5}, /* 08 Jul 0689 */ + {109, 1990059.5}, /* 27 Jun 0736 */ + {110, 1994046.5}, /* 28 May 0747 */ + {111, 2024375.5}, /* 10 Jun 0830 */ + {112, 2034946.5}, /* 20 May 0859 */ + {113, 2045518.5}, /* 29 Apr 0888 */ + {114, 2075847.5}, /* 13 May 0971 */ + {115, 2086418.5}, /* 21 Apr 1000 */ + {116, 2083820.5}, /* 11 Mar 0993 */ + {117, 2120733.5}, /* 03 Apr 1094 */ + {118, 2124719.5}, /* 02 Mar 1105 */ + {119, 2062852.5}, /* 14 Oct 0935 */ + {120, 2086596.5}, /* 16 Oct 1000 */ + {121, 2103752.5}, /* 06 Oct 1047 */ + {122, 2094568.5}, /* 14 Aug 1022 */ + {123, 2118311.5}, /* 16 Aug 1087 */ + {124, 2142054.5}, /* 17 Aug 1152 */ + {125, 2146040.5}, /* 17 Jul 1163 */ + {126, 2169783.5}, /* 18 Jul 1228 */ + {127, 2186940.5}, /* 09 Jul 1275 */ + {128, 2197512.5}, /* 18 Jun 1304 */ + {129, 2214670.5}, /* 10 Jun 1351 */ + {130, 2238412.5}, /* 10 Jun 1416 */ + {131, 2242398.5}, /* 10 May 1427 */ + {132, 2266142.5}, /* 12 May 1492 */ + {133, 2289884.5}, /* 13 May 1557 */ + {134, 2287285.5}, /* 01 Apr 1550 */ + {135, 2311028.5}, /* 13 Apr 1615 */ + {136, 2334770.5}, /* 13 Apr 1680 */ + {137, 2292659.5}, /* 17 Dec 1564 */ + {138, 2276890.5}, /* 15 Oct 1521 */ + {139, 2326974.5}, /* 09 Dec 1658 */ + {140, 2304619.5}, /* 25 Sep 1597 */ + {141, 2308606.5}, /* 25 Aug 1608 */ + {142, 2345520.5}, /* 19 Sep 1709 */ + {143, 2349506.5}, /* 18 Aug 1720 */ + {144, 2360078.5}, /* 29 Jul 1749 */ + {145, 2390406.5}, /* 11 Aug 1832 */ + {146, 2394392.5}, /* 11 Jul 1843 */ + {147, 2411550.5}, /* 02 Jul 1890 */ + {148, 2441878.5}, /* 15 Jul 1973 */ + {149, 2445864.5}, /* 13 Jun 1984 */ + {150, 2456437.5}, /* 25 May 2013 */ + {151, 2486765.5}, /* 06 Jun 2096 */ + {152, 2490751.5}, /* 07 May 2107 */ + {153, 2501323.5}, /* 16 Apr 2136 */ + {154, 2538236.5}, /* 10 May 2237 */ + {155, 2529052.5}, /* 18 Mar 2212 */ + {156, 2473771.5}, /* 08 Nov 2060 */ + {157, 2563367.5}, /* 01 Mar 2306 */ + {158, 2508085.5}, /* 21 Oct 2154 */ + {159, 2505486.5}, /* 09 Sep 2147 */ + {160, 2542400.5}, /* 03 Oct 2248 */ + {161, 2546386.5}, /* 02 Sep 2259 */ + {162, 2556958.5}, /* 12 Aug 2288 */ + {163, 2587287.5}, /* 27 Aug 2371 */ + {164, 2597858.5}, /* 05 Aug 2400 */ + {165, 2601845.5}, /* 06 Jul 2411 */ + {166, 2632173.5}, /* 18 Jul 2494 */ + {167, 2649330.5}, /* 09 Jul 2541 */ + {168, 2653317.5}, /* 08 Jun 2552 */ + {169, 2683645.5}, /* 22 Jun 2635 */ + {170, 2694217.5}, /* 01 Jun 2664 */ + {171, 2698203.5}, /* 01 May 2675 */ + {172, 2728532.5}, /* 15 May 2758 */ + {173, 2739103.5}, /* 24 Apr 2787 */ + {174, 2683822.5}, /* 16 Dec 2635 */ + {175, 2740492.5}, /* 11 Feb 2791 */ + {176, 2724722.5}, /* 09 Dec 2747 */ + {177, 2708952.5}, /* 05 Oct 2704 */ + {178, 2732695.5}, /* 07 Oct 2769 */ + {179, 2749852.5}, /* 27 Sep 2816 */ + {180, 2753839.5}, /* 28 Aug 2827 */ }; /* Computes geographic location and type of solar eclipse @@ -548,46 +558,44 @@ struct saros_data saros_data_lunar[NSAROS_LUNAR] = { * attr[7] angular distance of moon from sun in degrees * declare as attr[20] at least ! */ -int32 FAR PASCAL_CONV swe_sol_eclipse_where( - double tjd_ut, - int32 ifl, - double *geopos, - double *attr, - char *serr) +int32 FAR PASCAL_CONV +swe_sol_eclipse_where(double tjd_ut, int32 ifl, double *geopos, double *attr, + char *serr) { - int32 retflag, retflag2; - double dcore[10]; - ifl &= SEFLG_EPHMASK; - if ((retflag = eclipse_where(tjd_ut, SE_SUN, NULL, ifl, geopos, dcore, serr)) < 0) + int32 retflag, retflag2; + double dcore[10]; + ifl &= SEFLG_EPHMASK; + if ((retflag = + eclipse_where(tjd_ut, SE_SUN, NULL, ifl, geopos, dcore, serr)) < 0) + return retflag; + if ((retflag2 = + eclipse_how(tjd_ut, SE_SUN, NULL, ifl, geopos[0], geopos[1], 0, attr, + serr)) == ERR) + return retflag2; + attr[3] = dcore[0]; return retflag; - if ((retflag2 = eclipse_how(tjd_ut, SE_SUN, NULL, ifl, geopos[0], geopos[1], 0, attr, serr)) == ERR) - return retflag2; - attr[3] = dcore[0]; - return retflag; } -int32 FAR PASCAL_CONV swe_lun_occult_where( - double tjd_ut, - int32 ipl, - char *starname, - int32 ifl, - double *geopos, - double *attr, - char *serr) +int32 FAR PASCAL_CONV +swe_lun_occult_where(double tjd_ut, int32 ipl, char *starname, int32 ifl, + double *geopos, double *attr, char *serr) { - int32 retflag, retflag2; - double dcore[10]; - ifl &= SEFLG_EPHMASK; - /* function calls for Pluto with asteroid number 134340 - * are treated as calls for Pluto as main body SE_PLUTO */ - if (ipl == SE_AST_OFFSET + 134340) - ipl = SE_PLUTO; - if ((retflag = eclipse_where(tjd_ut, ipl, starname, ifl, geopos, dcore, serr)) < 0) + int32 retflag, retflag2; + double dcore[10]; + ifl &= SEFLG_EPHMASK; + /* function calls for Pluto with asteroid number 134340 + * are treated as calls for Pluto as main body SE_PLUTO */ + if (ipl == SE_AST_OFFSET + 134340) + ipl = SE_PLUTO; + if ((retflag = + eclipse_where(tjd_ut, ipl, starname, ifl, geopos, dcore, serr)) < 0) + return retflag; + if ((retflag2 = + eclipse_how(tjd_ut, ipl, starname, ifl, geopos[0], geopos[1], 0, + attr, serr)) == ERR) + return retflag2; + attr[3] = dcore[0]; return retflag; - if ((retflag2 = eclipse_how(tjd_ut, ipl, starname, ifl, geopos[0], geopos[1], 0, attr, serr)) == ERR) - return retflag2; - attr[3] = dcore[0]; - return retflag; } /* Used by several swe_sol_eclipse_ functions. @@ -598,275 +606,288 @@ int32 FAR PASCAL_CONV swe_lun_occult_where( * dcore[3]: diameter of core shadow on fundamental plane d0 * dcore[4]: diameter of half-shadow on fundamental plane D0 */ -static int32 eclipse_where( double tjd_ut, int32 ipl, char *starname, int32 ifl, double *geopos, double *dcore, - char *serr) +static int32 +eclipse_where(double tjd_ut, int32 ipl, char *starname, int32 ifl, + double *geopos, double *dcore, char *serr) { - int i; - int32 retc = 0, niter = 0; - double e[6], et[6], rm[6], rs[6], rmt[6], rst[6], xs[6], xst[6]; + int i; + int32 retc = 0, niter = 0; + double e[6], et[6], rm[6], rs[6], rmt[6], rst[6], xs[6], xst[6]; #if 0 - double erm[6]; + double erm[6]; #endif - double x[6]; - double lm[6], ls[6], lx[6]; - double dsm, dsmt, d0, D0, s0, r0, d, s, dm; - double de = 6378140.0 / AUNIT; - double earthobl = 1 - EARTH_OBLATENESS; - double deltat, tjd, sidt; - double drad; - double sinf1, sinf2, cosf1, cosf2; - double rmoon = RMOON; - double dmoon = 2 * rmoon; - int32 iflag, iflag2; - /* double ecce = sqrt(2 * EARTH_OBLATENESS - EARTH_OBLATENESS * EARTH_OBLATENESS); */ - AS_BOOL no_eclipse = FALSE; - struct epsilon *oe = &swed.oec; - for (i = 0; i < 10; i++) - dcore[i] = 0; - /* nutation need not be in lunar and solar positions, - * if mean sidereal time will be used */ - iflag = SEFLG_SPEED | SEFLG_EQUATORIAL | ifl; - iflag2 = iflag | SEFLG_RADIANS; - iflag = iflag | SEFLG_XYZ; - deltat = swe_deltat(tjd_ut); - tjd = tjd_ut + deltat; - /* moon in cartesian coordinates */ - if ((retc = swe_calc(tjd, SE_MOON, iflag, rm, serr)) == ERR) - return retc; - /* moon in polar coordinates */ - if ((retc = swe_calc(tjd, SE_MOON, iflag2, lm, serr)) == ERR) - return retc; - /* sun in cartesian coordinates */ - if ((retc = calc_planet_star(tjd, ipl, starname, iflag, rs, serr)) == ERR) - return retc; - /* sun in polar coordinates */ - if ((retc = calc_planet_star(tjd, ipl, starname, iflag2, ls, serr)) == ERR) - return retc; - /* save sun position */ - for (i = 0; i <= 2; i++) - rst[i] = rs[i]; - /* save moon position */ - for (i = 0; i <= 2; i++) - rmt[i] = rm[i]; - if (iflag & SEFLG_NONUT) - sidt = swe_sidtime0(tjd_ut, oe->eps * RADTODEG, 0) * 15 * DEGTORAD; - else - sidt = swe_sidtime(tjd_ut) * 15 * DEGTORAD; - /* - * radius of planet disk in AU - */ - if (starname != NULL && *starname != '\0') - drad = 0; - else if (ipl < NDIAM) - drad = pla_diam[ipl] / 2 / AUNIT; - else if (ipl > SE_AST_OFFSET) - drad = swed.ast_diam / 2 * 1000 / AUNIT; /* km -> m -> AU */ - else - drad = 0; + double x[6]; + double lm[6], ls[6], lx[6]; + double dsm, dsmt, d0, D0, s0, r0, d, s, dm; + double de = 6378140.0 / AUNIT; + double earthobl = 1 - EARTH_OBLATENESS; + double deltat, tjd, sidt; + double drad; + double sinf1, sinf2, cosf1, cosf2; + double rmoon = RMOON; + double dmoon = 2 * rmoon; + int32 iflag, iflag2; + /* double ecce = sqrt(2 * EARTH_OBLATENESS - EARTH_OBLATENESS * EARTH_OBLATENESS); */ + AS_BOOL no_eclipse = FALSE; + struct epsilon *oe = &swed.oec; + for (i = 0; i < 10; i++) + dcore[i] = 0; + /* nutation need not be in lunar and solar positions, + * if mean sidereal time will be used */ + iflag = SEFLG_SPEED | SEFLG_EQUATORIAL | ifl; + iflag2 = iflag | SEFLG_RADIANS; + iflag = iflag | SEFLG_XYZ; + deltat = swe_deltat(tjd_ut); + tjd = tjd_ut + deltat; + /* moon in cartesian coordinates */ + if ((retc = swe_calc(tjd, SE_MOON, iflag, rm, serr)) == ERR) + return retc; + /* moon in polar coordinates */ + if ((retc = swe_calc(tjd, SE_MOON, iflag2, lm, serr)) == ERR) + return retc; + /* sun in cartesian coordinates */ + if ((retc = calc_planet_star(tjd, ipl, starname, iflag, rs, serr)) == ERR) + return retc; + /* sun in polar coordinates */ + if ((retc = + calc_planet_star(tjd, ipl, starname, iflag2, ls, serr)) == ERR) + return retc; + /* save sun position */ + for (i = 0; i <= 2; i++) + rst[i] = rs[i]; + /* save moon position */ + for (i = 0; i <= 2; i++) + rmt[i] = rm[i]; + if (iflag & SEFLG_NONUT) + sidt = swe_sidtime0(tjd_ut, oe->eps * RADTODEG, 0) * 15 * DEGTORAD; + else + sidt = swe_sidtime(tjd_ut) * 15 * DEGTORAD; + /* + * radius of planet disk in AU + */ + if (starname != NULL && *starname != '\0') + drad = 0; + else if (ipl < NDIAM) + drad = pla_diam[ipl] / 2 / AUNIT; + else if (ipl > SE_AST_OFFSET) + drad = swed.ast_diam / 2 * 1000 / AUNIT; /* km -> m -> AU */ + else + drad = 0; iter_where: - for (i = 0; i <= 2; i++) { - rs[i] = rst[i]; - rm[i] = rmt[i]; - } - /* Account for oblateness of earth: - * Instead of flattening the earth, we apply the - * correction to the z coordinate of the moon and - * the sun. This makes the calculation easier. - */ - for (i = 0; i <= 2; i++) - lx[i] = lm[i]; - swi_polcart(lx, rm); - rm[2] /= earthobl; - /* distance of moon from geocenter */ - dm = sqrt(square_sum(rm)); - /* Account for oblateness of earth */ - for (i = 0; i <= 2; i++) - lx[i] = ls[i]; - swi_polcart(lx, rs); - rs[2] /= earthobl; - /* sun - moon vector */ - for (i = 0; i <= 2; i++) { - e[i] = (rm[i] - rs[i]); - et[i] = (rmt[i] - rst[i]); - } - /* distance sun - moon */ - dsm = sqrt(square_sum(e)); - dsmt = sqrt(square_sum(et)); - /* sun - moon unit vector */ - for (i = 0; i <= 2; i++) { - e[i] /= dsm; - et[i] /= dsmt; + for (i = 0; i <= 2; i++) { + rs[i] = rst[i]; + rm[i] = rmt[i]; + } + /* Account for oblateness of earth: + * Instead of flattening the earth, we apply the + * correction to the z coordinate of the moon and + * the sun. This makes the calculation easier. + */ + for (i = 0; i <= 2; i++) + lx[i] = lm[i]; + swi_polcart(lx, rm); + rm[2] /= earthobl; + /* distance of moon from geocenter */ + dm = sqrt(square_sum(rm)); + /* Account for oblateness of earth */ + for (i = 0; i <= 2; i++) + lx[i] = ls[i]; + swi_polcart(lx, rs); + rs[2] /= earthobl; + /* sun - moon vector */ + for (i = 0; i <= 2; i++) { + e[i] = (rm[i] - rs[i]); + et[i] = (rmt[i] - rst[i]); + } + /* distance sun - moon */ + dsm = sqrt(square_sum(e)); + dsmt = sqrt(square_sum(et)); + /* sun - moon unit vector */ + for (i = 0; i <= 2; i++) { + e[i] /= dsm; + et[i] /= dsmt; #if 0 - erm[i] = rm[i] / dm; + erm[i] = rm[i] / dm; #endif - } - sinf1 = ((drad - rmoon) / dsm); - cosf1 = sqrt(1 - sinf1 * sinf1); - sinf2 = ((drad + rmoon) / dsm); - cosf2 = sqrt(1 - sinf2 * sinf2); - /* distance of moon from fundamental plane */ - s0 = -dot_prod(rm, e); - /* distance of shadow axis from geocenter */ - r0 = sqrt(dm * dm - s0 * s0); - /* diameter of core shadow on fundamental plane */ - d0 = (s0 / dsm * (drad * 2 - dmoon) - dmoon) / cosf1; - /* diameter of half-shadow on fundamental plane */ - D0 = (s0 / dsm * (drad * 2 + dmoon) + dmoon) / cosf2; - dcore[2] = r0; - dcore[3] = d0; - dcore[4] = D0; - dcore[5] = cosf1; - dcore[6] = cosf2; - for (i = 2; i < 5; i++) - dcore[i] *= AUNIT / 1000.0; + } + sinf1 = ((drad - rmoon) / dsm); + cosf1 = sqrt(1 - sinf1 * sinf1); + sinf2 = ((drad + rmoon) / dsm); + cosf2 = sqrt(1 - sinf2 * sinf2); + /* distance of moon from fundamental plane */ + s0 = -dot_prod(rm, e); + /* distance of shadow axis from geocenter */ + r0 = sqrt(dm * dm - s0 * s0); + /* diameter of core shadow on fundamental plane */ + d0 = (s0 / dsm * (drad * 2 - dmoon) - dmoon) / cosf1; + /* diameter of half-shadow on fundamental plane */ + D0 = (s0 / dsm * (drad * 2 + dmoon) + dmoon) / cosf2; + dcore[2] = r0; + dcore[3] = d0; + dcore[4] = D0; + dcore[5] = cosf1; + dcore[6] = cosf2; + for (i = 2; i < 5; i++) + dcore[i] *= AUNIT / 1000.0; + /************************** * central (total or annular) phase **************************/ - retc = 0; - if (de * cosf1 >= r0) { - retc |= SE_ECL_CENTRAL; - } else if (r0 <= de * cosf1 + fabs(d0) / 2) { - retc |= SE_ECL_NONCENTRAL; - } else if (r0 <= de * cosf2 + D0 / 2) { - retc |= (SE_ECL_PARTIAL | SE_ECL_NONCENTRAL); - } else { - if (serr != NULL) - sprintf(serr, "no solar eclipse at tjd = %f", tjd); - for (i = 0; i < 10; i++) - geopos[i] = 0; - *dcore = 0; retc = 0; - d = 0; - no_eclipse = TRUE; - /*return retc;*/ - } - /* distance of shadow point from fundamental plane */ - d = s0 * s0 + de * de - dm * dm; - if (d > 0) - d = sqrt(d); - else - d = 0; - /* distance of moon from shadow point on earth */ - s = s0 - d; - /* next: geographic position of eclipse center. - * if shadow axis does not touch the earth, - * place on earth with maximum occultation is computed. - */ -#if 0 /* the following stuff is meaningless for observations */ - /* - * account for refraction at horizon - */ - if (d == 0) { - double ds, a, b; - /* distance of sun from geocenter */ - ds = sqrt(square_sum(rs)); - a = PI - acos(swi_dot_prod_unit(e, erm)); - /* refraction at horizon + sun radius = about 0.83 degrees */ - b = 34.4556 / 60.0 * DEGTORAD + asin(drad / ds); -# if 0 - /* at edge of umbra and penumbra - * light rays are not parallel to shadow axis. - * for a short time close to contact of umbra and - * penumbra, an angle < 0.27 degrees would have - * to be subtracted from b; - */ - if (retc & SE_ECL_PARTIAL) { - d = d0; - sinf = sinf1; - } else { - d = D0; - sinf = sinf2; + if (de * cosf1 >= r0) { + retc |= SE_ECL_CENTRAL; } - c = (r0 - de) / d * 2 * sinf; - if (c > sinf1) { - b -= .....; + else if (r0 <= de * cosf1 + fabs(d0) / 2) { + retc |= SE_ECL_NONCENTRAL; } - printf("%f %f %f", a * RADTODEG, b * RADTODEG, s); - printf(" %f\n", s); -# else - if (retc & SE_ECL_PARTIAL) - b -= asin(sinf2); /* maximum! */ + else if (r0 <= de * cosf2 + D0 / 2) { + retc |= (SE_ECL_PARTIAL | SE_ECL_NONCENTRAL); + } + else { + if (serr != NULL) + sprintf(serr, "no solar eclipse at tjd = %f", tjd); + for (i = 0; i < 10; i++) + geopos[i] = 0; + *dcore = 0; + retc = 0; + d = 0; + no_eclipse = TRUE; + /*return retc; */ + } + /* distance of shadow point from fundamental plane */ + d = s0 * s0 + de * de - dm * dm; + if (d > 0) + d = sqrt(d); else - b -= asin(sinf1); -# endif - s += tan(b) * cos(PI / 2 - a) * dm; - } + d = 0; + /* distance of moon from shadow point on earth */ + s = s0 - d; + /* next: geographic position of eclipse center. + * if shadow axis does not touch the earth, + * place on earth with maximum occultation is computed. + */ +#if 0 /* the following stuff is meaningless for observations */ + /* + * account for refraction at horizon + */ + if (d == 0) { + double ds, a, b; + /* distance of sun from geocenter */ + ds = sqrt(square_sum(rs)); + a = PI - acos(swi_dot_prod_unit(e, erm)); + /* refraction at horizon + sun radius = about 0.83 degrees */ + b = 34.4556 / 60.0 * DEGTORAD + asin(drad / ds); +#if 0 + /* at edge of umbra and penumbra + * light rays are not parallel to shadow axis. + * for a short time close to contact of umbra and + * penumbra, an angle < 0.27 degrees would have + * to be subtracted from b; + */ + if (retc & SE_ECL_PARTIAL) { + d = d0; + sinf = sinf1; + } + else { + d = D0; + sinf = sinf2; + } + c = (r0 - de) / d * 2 * sinf; + if (c > sinf1) { + b -= .....; + } + printf("%f %f %f", a * RADTODEG, b * RADTODEG, s); + printf(" %f\n", s); +#else + if (retc & SE_ECL_PARTIAL) + b -= asin(sinf2); /* maximum! */ + else + b -= asin(sinf1); #endif - /* geographic position of eclipse center (maximum) */ - for (i = 0; i <= 2; i++) - xs[i] = rm[i] + s * e[i]; - /* we need geographic position with correct z, as well */ - for (i = 0; i <= 2; i++) - xst[i] = xs[i]; - xst[2] *= earthobl; - swi_cartpol(xst, xst); - if (niter <= 0) { - double cosfi = cos(xst[1]); - double sinfi = sin(xst[1]); - double eobl = EARTH_OBLATENESS; - double cc= 1 / sqrt(cosfi * cosfi + (1-eobl) * (1-eobl) * sinfi * sinfi); - double ss= (1-eobl) * (1-eobl) * cc; - earthobl = ss; - niter++; - goto iter_where; - } - swi_polcart(xst, xst); - /* to longitude and latitude */ - swi_cartpol(xs, xs); - /* measure from sidereal time at greenwich */ - xs[0] -= sidt; - xs[0] *= RADTODEG; - xs[1] *= RADTODEG; - xs[0] = swe_degnorm(xs[0]); - /* west is negative */ - if (xs[0] > 180) - xs[0] -= 360; - geopos[0] = xs[0]; - geopos[1] = xs[1]; - /* diameter of core shadow: - * first, distance moon - place of eclipse on earth */ - for (i = 0; i <= 2; i++) - x[i] = rmt[i] - xst[i]; - s = sqrt(square_sum(x)); - /* diameter of core shadow at place of maximum eclipse */ - *dcore = (s / dsmt * ( drad * 2 - dmoon) - dmoon) * cosf1; - *dcore *= AUNIT / 1000.0; - /* diameter of penumbra at place of maximum eclipse */ - dcore[1] = (s / dsmt * ( drad * 2 + dmoon) + dmoon) * cosf2; - dcore[1] *= AUNIT / 1000.0; - if (!(retc & SE_ECL_PARTIAL) && !no_eclipse) { - if (*dcore > 0) { - /*printf("annular\n");*/ - retc |= SE_ECL_ANNULAR; - } else { - /*printf("total\n");*/ - retc |= SE_ECL_TOTAL; + s += tan(b) * cos(PI / 2 - a) * dm; } - } - return retc; +#endif + /* geographic position of eclipse center (maximum) */ + for (i = 0; i <= 2; i++) + xs[i] = rm[i] + s * e[i]; + /* we need geographic position with correct z, as well */ + for (i = 0; i <= 2; i++) + xst[i] = xs[i]; + xst[2] *= earthobl; + swi_cartpol(xst, xst); + if (niter <= 0) { + double cosfi = cos(xst[1]); + double sinfi = sin(xst[1]); + double eobl = EARTH_OBLATENESS; + double cc = + 1 / sqrt(cosfi * cosfi + (1 - eobl) * (1 - eobl) * sinfi * sinfi); + double ss = (1 - eobl) * (1 - eobl) * cc; + earthobl = ss; + niter++; + goto iter_where; + } + swi_polcart(xst, xst); + /* to longitude and latitude */ + swi_cartpol(xs, xs); + /* measure from sidereal time at greenwich */ + xs[0] -= sidt; + xs[0] *= RADTODEG; + xs[1] *= RADTODEG; + xs[0] = swe_degnorm(xs[0]); + /* west is negative */ + if (xs[0] > 180) + xs[0] -= 360; + geopos[0] = xs[0]; + geopos[1] = xs[1]; + /* diameter of core shadow: + * first, distance moon - place of eclipse on earth */ + for (i = 0; i <= 2; i++) + x[i] = rmt[i] - xst[i]; + s = sqrt(square_sum(x)); + /* diameter of core shadow at place of maximum eclipse */ + *dcore = (s / dsmt * (drad * 2 - dmoon) - dmoon) * cosf1; + *dcore *= AUNIT / 1000.0; + /* diameter of penumbra at place of maximum eclipse */ + dcore[1] = (s / dsmt * (drad * 2 + dmoon) + dmoon) * cosf2; + dcore[1] *= AUNIT / 1000.0; + if (!(retc & SE_ECL_PARTIAL) && !no_eclipse) { + if (*dcore > 0) { + /*printf("annular\n"); */ + retc |= SE_ECL_ANNULAR; + } + else { + /*printf("total\n"); */ + retc |= SE_ECL_TOTAL; + } + } + return retc; } -static int32 calc_planet_star(double tjd_et, int32 ipl, char *starname, int32 iflag, double *x, char *serr) +static int32 +calc_planet_star(double tjd_et, int32 ipl, char *starname, int32 iflag, + double *x, char *serr) { - int i; - int retc = OK; - if (starname == NULL || *starname == '\0') { - retc = swe_calc(tjd_et, ipl, iflag, x, serr); - } else { - if ((retc = swe_fixstar(starname, tjd_et, iflag, x, serr)) == OK) { - /* fixstars have the standard distance 1. - * in the occultation routines, this might lead to errors - * if interpreted as AU distance. To avoid this, we make it very high. - */ - if (iflag & SEFLG_XYZ) { - for (i = 0; i < 3; i++) - x[i] *= 100000000; - } else { - x[2] *= 100000000; - } + int i; + int retc = OK; + if (starname == NULL || *starname == '\0') { + retc = swe_calc(tjd_et, ipl, iflag, x, serr); } - } - return retc; + else { + if ((retc = swe_fixstar(starname, tjd_et, iflag, x, serr)) == OK) { + /* fixstars have the standard distance 1. + * in the occultation routines, this might lead to errors + * if interpreted as AU distance. To avoid this, we make it very high. + */ + if (iflag & SEFLG_XYZ) { + for (i = 0; i < 3; i++) + x[i] *= 100000000; + } + else { + x[2] *= 100000000; + } + } + } + return retc; } /* Computes attributes of a solar eclipse for given tjd, geo. longitude, @@ -892,219 +913,232 @@ static int32 calc_planet_star(double tjd_et, int32 ipl, char *starname, int32 if * declare as attr[20] at least ! * */ -int32 FAR PASCAL_CONV swe_sol_eclipse_how( - double tjd_ut, - int32 ifl, - double *geopos, - double *attr, - char *serr) +int32 FAR PASCAL_CONV +swe_sol_eclipse_how(double tjd_ut, int32 ifl, double *geopos, double *attr, + char *serr) { - int32 retflag, retflag2; - double dcore[10], ls[6], xaz[6]; - double geopos2[20]; - ifl &= SEFLG_EPHMASK; - if ((retflag = eclipse_how(tjd_ut, SE_SUN, NULL, ifl, geopos[0], geopos[1], geopos[2], attr, serr)) == ERR) + int32 retflag, retflag2; + double dcore[10], ls[6], xaz[6]; + double geopos2[20]; + ifl &= SEFLG_EPHMASK; + if ((retflag = + eclipse_how(tjd_ut, SE_SUN, NULL, ifl, geopos[0], geopos[1], + geopos[2], attr, serr)) == ERR) + return retflag; + if ((retflag2 = + eclipse_where(tjd_ut, SE_SUN, NULL, ifl, geopos2, dcore, + serr)) == ERR) + return retflag2; + if (retflag) + retflag |= (retflag2 & (SE_ECL_CENTRAL | SE_ECL_NONCENTRAL)); + attr[3] = dcore[0]; + swe_set_topo(geopos[0], geopos[1], geopos[2]); + if (swe_calc_ut + (tjd_ut, SE_SUN, ifl | SEFLG_TOPOCTR | SEFLG_EQUATORIAL, ls, + serr) == ERR) + return ERR; + swe_azalt(tjd_ut, SE_EQU2HOR, geopos, 0, 10, ls, xaz); + attr[4] = xaz[0]; + attr[5] = xaz[1]; + attr[6] = xaz[2]; + if (xaz[2] <= 0) + retflag = 0; return retflag; - if ((retflag2 = eclipse_where(tjd_ut, SE_SUN, NULL, ifl, geopos2, dcore, serr)) == ERR) - return retflag2; - if (retflag) - retflag |= (retflag2 & (SE_ECL_CENTRAL | SE_ECL_NONCENTRAL)); - attr[3] = dcore[0]; - swe_set_topo(geopos[0], geopos[1], geopos[2]); - if (swe_calc_ut(tjd_ut, SE_SUN, ifl | SEFLG_TOPOCTR | SEFLG_EQUATORIAL, ls, serr) == ERR) - return ERR; - swe_azalt(tjd_ut, SE_EQU2HOR, geopos, 0, 10, ls, xaz); - attr[4] = xaz[0]; - attr[5] = xaz[1]; - attr[6] = xaz[2]; - if (xaz[2] <= 0) - retflag = 0; - return retflag; } #define USE_AZ_NAV 0 -static int32 eclipse_how( double tjd_ut, int32 ipl, char *starname, int32 ifl, - double geolon, double geolat, double geohgt, - double *attr, char *serr) +static int32 +eclipse_how(double tjd_ut, int32 ipl, char *starname, int32 ifl, + double geolon, double geolat, double geohgt, double *attr, + char *serr) { - int i, j, k; - int32 retc = 0; - double te, d; - double xs[6], xm[6], ls[6], lm[6], x1[6], x2[6]; - double rmoon, rsun, rsplusrm, rsminusrm; - double dctr; - double drad; - int32 iflag = SEFLG_EQUATORIAL | SEFLG_TOPOCTR | ifl; - int32 iflagcart = iflag | SEFLG_XYZ; + int i, j, k; + int32 retc = 0; + double te, d; + double xs[6], xm[6], ls[6], lm[6], x1[6], x2[6]; + double rmoon, rsun, rsplusrm, rsminusrm; + double dctr; + double drad; + int32 iflag = SEFLG_EQUATORIAL | SEFLG_TOPOCTR | ifl; + int32 iflagcart = iflag | SEFLG_XYZ; #if USE_AZ_NAV - double mdd, eps, sidt, armc; + double mdd, eps, sidt, armc; #endif - double xh[6], hmin_appr; - double lsun, lmoon, lctr, lsunleft, a, b, sc1, sc2; - double geopos[3]; - for (i = 0; i < 10; i++) - attr[i] = 0; - geopos[0] = geolon; - geopos[1] = geolat; - geopos[2] = geohgt; - te = tjd_ut + swe_deltat(tjd_ut); - swe_set_topo(geolon, geolat, geohgt); - if (calc_planet_star(te, ipl, starname, iflag, ls, serr) == ERR) - return ERR; - if (swe_calc(te, SE_MOON, iflag, lm, serr) == ERR) - return ERR; - if (calc_planet_star(te, ipl, starname, iflagcart, xs, serr) == ERR) - return ERR; - if (swe_calc(te, SE_MOON, iflagcart, xm, serr) == ERR) - return ERR; - /* - * radius of planet disk in AU - */ - if (starname != NULL && *starname != '\0') - drad = 0; - else if (ipl < NDIAM) - drad = pla_diam[ipl] / 2 / AUNIT; - else if (ipl > SE_AST_OFFSET) - drad = swed.ast_diam / 2 * 1000 / AUNIT; /* km -> m -> AU */ - else - drad = 0; - /* - * azimuth and altitude of sun or planet - */ -#if USE_AZ_NAV /* old */ - eps = swi_epsiln(te); - if (iflag & SEFLG_NONUT) - sidt = swe_sidtime0(tjd_ut, eps * RADTODEG, 0) * 15; - else - sidt = swe_sidtime(tjd_ut) * 15; - armc = sidt + geolon; - mdd = swe_degnorm(ls[0] - armc); - xh[0] = swe_degnorm(mdd - 90); - xh[1] = ls[1]; - xh[2] = ls[2]; - swe_cotrans(xh, xh, 90 - geolat); /* azimuth from east, counterclock, via north */ + double xh[6], hmin_appr; + double lsun, lmoon, lctr, lsunleft, a, b, sc1, sc2; + double geopos[3]; + for (i = 0; i < 10; i++) + attr[i] = 0; + geopos[0] = geolon; + geopos[1] = geolat; + geopos[2] = geohgt; + te = tjd_ut + swe_deltat(tjd_ut); + swe_set_topo(geolon, geolat, geohgt); + if (calc_planet_star(te, ipl, starname, iflag, ls, serr) == ERR) + return ERR; + if (swe_calc(te, SE_MOON, iflag, lm, serr) == ERR) + return ERR; + if (calc_planet_star(te, ipl, starname, iflagcart, xs, serr) == ERR) + return ERR; + if (swe_calc(te, SE_MOON, iflagcart, xm, serr) == ERR) + return ERR; + /* + * radius of planet disk in AU + */ + if (starname != NULL && *starname != '\0') + drad = 0; + else if (ipl < NDIAM) + drad = pla_diam[ipl] / 2 / AUNIT; + else if (ipl > SE_AST_OFFSET) + drad = swed.ast_diam / 2 * 1000 / AUNIT; /* km -> m -> AU */ + else + drad = 0; + /* + * azimuth and altitude of sun or planet + */ +#if USE_AZ_NAV /* old */ + eps = swi_epsiln(te); + if (iflag & SEFLG_NONUT) + sidt = swe_sidtime0(tjd_ut, eps * RADTODEG, 0) * 15; + else + sidt = swe_sidtime(tjd_ut) * 15; + armc = sidt + geolon; + mdd = swe_degnorm(ls[0] - armc); + xh[0] = swe_degnorm(mdd - 90); + xh[1] = ls[1]; + xh[2] = ls[2]; + swe_cotrans(xh, xh, 90 - geolat); /* azimuth from east, counterclock, via north */ #else - swe_azalt(tjd_ut, SE_EQU2HOR, geopos, 0, 10, ls, xh); /* azimuth from south, clockwise, via west */ + swe_azalt(tjd_ut, SE_EQU2HOR, geopos, 0, 10, ls, xh); /* azimuth from south, clockwise, via west */ #endif - /* eclipse description */ - rmoon = asin(RMOON / lm[2]) * RADTODEG; - rsun = asin(drad / ls[2]) * RADTODEG; - rsplusrm = rsun + rmoon; - rsminusrm = rsun - rmoon; - for (i = 0; i < 3; i++) { - x1[i] = xs[i] / ls[2]; - x2[i] = xm[i] / lm[2]; - } - dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; - /* - * phase - */ - if (dctr < rsminusrm) - retc = SE_ECL_ANNULAR; - else if (dctr < fabs(rsminusrm)) - retc = SE_ECL_TOTAL; - else if (dctr < rsplusrm) - retc = SE_ECL_PARTIAL; - else { - retc = 0; - if (serr != NULL) - sprintf(serr, "no solar eclipse at tjd = %f", tjd_ut); - } - /* - * ratio of diameter of moon to that of sun - */ - if (rsun > 0) - attr[1] = rmoon / rsun; - else - attr[1] = 0; - /* - * eclipse magnitude: - * fraction of solar diameter covered by moon - */ - lsun = asin(rsun / 2 * DEGTORAD) * 2; - lsunleft = (-dctr + rsun + rmoon); - if (lsun > 0) { - attr[0] = lsunleft / rsun / 2; - } else { - attr[0] = 100; - } - /*if (retc == SE_ECL_ANNULAR || retc == SE_ECL_TOTAL) - attr[0] = attr[1];*/ - /* - * obscuration: - * fraction of solar disc obscured by moon - */ - lsun = rsun; - lmoon = rmoon; - lctr = dctr; - if (retc == 0 || lsun == 0) { - attr[2] = 100; - } else if (retc == SE_ECL_TOTAL || retc == SE_ECL_ANNULAR) { - attr[2] = lmoon * lmoon / lsun / lsun; - } else { - a = 2 * lctr * lmoon; - b = 2 * lctr * lsun; - if (a < 1e-9) { - attr[2] = lmoon * lmoon / lsun / lsun; - } else { - a = (lctr * lctr + lmoon * lmoon - lsun * lsun) / a; - if (a > 1) a = 1; - if (a < -1) a = -1; - b = (lctr * lctr + lsun * lsun - lmoon * lmoon) / b; - if (b > 1) b = 1; - if (b < -1) b = -1; - a = acos(a); - b = acos(b); - sc1 = a * lmoon * lmoon / 2; - sc2 = b * lsun * lsun / 2; - sc1 -= (cos(a) * sin(a)) * lmoon * lmoon / 2; - sc2 -= (cos(b) * sin(b)) * lsun * lsun / 2; - attr[2] = (sc1 + sc2) * 2 / PI / lsun / lsun; + /* eclipse description */ + rmoon = asin(RMOON / lm[2]) * RADTODEG; + rsun = asin(drad / ls[2]) * RADTODEG; + rsplusrm = rsun + rmoon; + rsminusrm = rsun - rmoon; + for (i = 0; i < 3; i++) { + x1[i] = xs[i] / ls[2]; + x2[i] = xm[i] / lm[2]; } - } - attr[7] = dctr; - /* approximate minimum height for visibility, considering - * refraction and dip - * 34.4556': refraction at horizon, from Bennets formulae - * 1.75' / sqrt(geohgt): dip of horizon - * 0.37' / sqrt(geohgt): refraction between horizon and observer */ - hmin_appr = -(34.4556 + (1.75 + 0.37) * sqrt(geohgt)) / 60; - if (xh[1] + rsun + fabs(hmin_appr) >= 0 && retc) - retc |= SE_ECL_VISIBLE; /* eclipse visible */ -#if USE_AZ_NAV /* old */ - attr[4] = swe_degnorm(90 - xh[0]); /* azimuth, from north, clockwise, via east */ + dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; + /* + * phase + */ + if (dctr < rsminusrm) + retc = SE_ECL_ANNULAR; + else if (dctr < fabs(rsminusrm)) + retc = SE_ECL_TOTAL; + else if (dctr < rsplusrm) + retc = SE_ECL_PARTIAL; + else { + retc = 0; + if (serr != NULL) + sprintf(serr, "no solar eclipse at tjd = %f", tjd_ut); + } + /* + * ratio of diameter of moon to that of sun + */ + if (rsun > 0) + attr[1] = rmoon / rsun; + else + attr[1] = 0; + /* + * eclipse magnitude: + * fraction of solar diameter covered by moon + */ + lsun = asin(rsun / 2 * DEGTORAD) * 2; + lsunleft = (-dctr + rsun + rmoon); + if (lsun > 0) { + attr[0] = lsunleft / rsun / 2; + } + else { + attr[0] = 100; + } + /*if (retc == SE_ECL_ANNULAR || retc == SE_ECL_TOTAL) + * attr[0] = attr[1]; */ + /* + * obscuration: + * fraction of solar disc obscured by moon + */ + lsun = rsun; + lmoon = rmoon; + lctr = dctr; + if (retc == 0 || lsun == 0) { + attr[2] = 100; + } + else if (retc == SE_ECL_TOTAL || retc == SE_ECL_ANNULAR) { + attr[2] = lmoon * lmoon / lsun / lsun; + } + else { + a = 2 * lctr * lmoon; + b = 2 * lctr * lsun; + if (a < 1e-9) { + attr[2] = lmoon * lmoon / lsun / lsun; + } + else { + a = (lctr * lctr + lmoon * lmoon - lsun * lsun) / a; + if (a > 1) + a = 1; + if (a < -1) + a = -1; + b = (lctr * lctr + lsun * lsun - lmoon * lmoon) / b; + if (b > 1) + b = 1; + if (b < -1) + b = -1; + a = acos(a); + b = acos(b); + sc1 = a * lmoon * lmoon / 2; + sc2 = b * lsun * lsun / 2; + sc1 -= (cos(a) * sin(a)) * lmoon * lmoon / 2; + sc2 -= (cos(b) * sin(b)) * lsun * lsun / 2; + attr[2] = (sc1 + sc2) * 2 / PI / lsun / lsun; + } + } + attr[7] = dctr; + /* approximate minimum height for visibility, considering + * refraction and dip + * 34.4556': refraction at horizon, from Bennets formulae + * 1.75' / sqrt(geohgt): dip of horizon + * 0.37' / sqrt(geohgt): refraction between horizon and observer */ + hmin_appr = -(34.4556 + (1.75 + 0.37) * sqrt(geohgt)) / 60; + if (xh[1] + rsun + fabs(hmin_appr) >= 0 && retc) + retc |= SE_ECL_VISIBLE; /* eclipse visible */ +#if USE_AZ_NAV /* old */ + attr[4] = swe_degnorm(90 - xh[0]); /* azimuth, from north, clockwise, via east */ #else - attr[4] = xh[0]; /* azimuth, from south, clockwise, via west */ + attr[4] = xh[0]; /* azimuth, from south, clockwise, via west */ #endif - attr[5] = xh[1]; /* height */ - attr[6] = xh[2]; /* height */ - if (ipl == SE_SUN && (starname == NULL || *starname == '\0')) { - /* magnitude of solar eclipse according to NASA */ - attr[8] = attr[0]; /* fraction of diameter occulted */ - if (retc & (SE_ECL_TOTAL | SE_ECL_ANNULAR)) - attr[8] = attr[1]; /* ratio between diameters of sun and moon */ - /* saros series and member */ - for (i = 0; i < NSAROS_SOLAR; i++) { - d = (tjd_ut - saros_data_solar[i].tstart) / SAROS_CYCLE; - if (d < 0) continue; - j = (int) d; - if ((d - j) * SAROS_CYCLE < 2) { - attr[9] = (double) saros_data_solar[i].series_no; - attr[10] = (double) j + 1; - break; - } - k = j + 1; - if ((k - d) * SAROS_CYCLE < 2) { - attr[9] = (double) saros_data_solar[i].series_no; - attr[10] = (double) k + 1; - break; - } + attr[5] = xh[1]; /* height */ + attr[6] = xh[2]; /* height */ + if (ipl == SE_SUN && (starname == NULL || *starname == '\0')) { + /* magnitude of solar eclipse according to NASA */ + attr[8] = attr[0]; /* fraction of diameter occulted */ + if (retc & (SE_ECL_TOTAL | SE_ECL_ANNULAR)) + attr[8] = attr[1]; /* ratio between diameters of sun and moon */ + /* saros series and member */ + for (i = 0; i < NSAROS_SOLAR; i++) { + d = (tjd_ut - saros_data_solar[i].tstart) / SAROS_CYCLE; + if (d < 0) + continue; + j = (int)d; + if ((d - j) * SAROS_CYCLE < 2) { + attr[9] = (double)saros_data_solar[i].series_no; + attr[10] = (double)j + 1; + break; + } + k = j + 1; + if ((k - d) * SAROS_CYCLE < 2) { + attr[9] = (double)saros_data_solar[i].series_no; + attr[10] = (double)k + 1; + break; + } + } + if (i == NSAROS_SOLAR) { + attr[9] = attr[10] = -99999999; + } } - if (i == NSAROS_SOLAR) { - attr[9] = attr[10] = -99999999; - } - } - return retc; + return retc; } /* When is the next solar eclipse anywhere on earth? @@ -1138,324 +1172,338 @@ static int32 eclipse_how( double tjd_ut, int32 ipl, char *starname, int32 ifl, * declare as tret[10] at least! * */ -int32 FAR PASCAL_CONV swe_sol_eclipse_when_glob(double tjd_start, int32 ifl, int32 ifltype, - double *tret, int32 backward, char *serr) +int32 FAR PASCAL_CONV +swe_sol_eclipse_when_glob(double tjd_start, int32 ifl, int32 ifltype, + double *tret, int32 backward, char *serr) { - int i, j, k, m, n, o, i1 = 0, i2 = 0; - int32 retflag = 0, retflag2 = 0; - double de = 6378.140, a; - double t, tt, tjd, tjds, dt, dtint, dta, dtb; - double T, T2, T3, T4, K, M, Mm; - double E, Ff; - double xs[6], xm[6], ls[6], lm[6]; - double rmoon, rsun, dcore[10]; - double dc[3], dctr; - double twohr = 2.0 / 24.0; - double tenmin = 10.0 / 24.0 / 60.0; - double dt1, dt2; - double geopos[20], attr[20]; - double dtstart, dtdiv; - double xa[6], xb[6]; - int direction = 1; - AS_BOOL dont_times = FALSE; - int32 iflag, iflagcart; - ifl &= SEFLG_EPHMASK; - iflag = SEFLG_EQUATORIAL | ifl; - iflagcart = iflag | SEFLG_XYZ; - if (ifltype == (SE_ECL_PARTIAL | SE_ECL_CENTRAL)) { - if (serr != NULL) - strcpy(serr, "central partial eclipses do not exist"); - return ERR; - } - if (ifltype == 0) - ifltype = SE_ECL_TOTAL | SE_ECL_ANNULAR | SE_ECL_PARTIAL - | SE_ECL_ANNULAR_TOTAL | SE_ECL_NONCENTRAL | SE_ECL_CENTRAL; - if (backward) - direction = -1; - K = (int) ((tjd_start - J2000) / 365.2425 * 12.3685); - K -= direction; -next_try: - retflag = 0; - dont_times = FALSE; - for (i = 0; i <= 9; i++) - tret[i] = 0; - T = K / 1236.85; - T2 = T * T; T3 = T2 * T; T4 = T3 * T; - Ff = swe_degnorm(160.7108 + 390.67050274 * K - - 0.0016341 * T2 - - 0.00000227 * T3 - + 0.000000011 * T4); - if (Ff > 180) - Ff -= 180; - if (Ff > 21 && Ff < 159) { /* no eclipse possible */ - K += direction; - goto next_try; - } - /* approximate time of geocentric maximum eclipse - * formula from Meeus, German, p. 381 */ - tjd = 2451550.09765 + 29.530588853 * K - + 0.0001337 * T2 - - 0.000000150 * T3 - + 0.00000000073 * T4; - M = swe_degnorm(2.5534 + 29.10535669 * K - - 0.0000218 * T2 - - 0.00000011 * T3); - Mm = swe_degnorm(201.5643 + 385.81693528 * K - + 0.1017438 * T2 - + 0.00001239 * T3 - + 0.000000058 * T4); - E = 1 - 0.002516 * T - 0.0000074 * T2; - M *= DEGTORAD; - Mm *= DEGTORAD; - tjd = tjd - 0.4075 * sin(Mm) - + 0.1721 * E * sin(M); - /* - * time of maximum eclipse (if eclipse) = - * minimum geocentric angle between sun and moon edges. - * After this time has been determined, check - * whether or not an eclipse is taking place with - * the functions eclipse_where() and _how(). - */ - dtstart = 1; - if (tjd < 2000000) - dtstart = 5; - dtdiv = 4; - for (dt = dtstart; - dt > 0.0001; - dt /= dtdiv) { - for (i = 0, t = tjd - dt; i <= 2; i++, t += dt) { - if (swe_calc(t, SE_SUN, iflag, ls, serr) == ERR) + int i, j, k, m, n, o, i1 = 0, i2 = 0; + int32 retflag = 0, retflag2 = 0; + double de = 6378.140, a; + double t, tt, tjd, tjds, dt, dtint, dta, dtb; + double T, T2, T3, T4, K, M, Mm; + double E, Ff; + double xs[6], xm[6], ls[6], lm[6]; + double rmoon, rsun, dcore[10]; + double dc[3], dctr; + double twohr = 2.0 / 24.0; + double tenmin = 10.0 / 24.0 / 60.0; + double dt1, dt2; + double geopos[20], attr[20]; + double dtstart, dtdiv; + double xa[6], xb[6]; + int direction = 1; + AS_BOOL dont_times = FALSE; + int32 iflag, iflagcart; + ifl &= SEFLG_EPHMASK; + iflag = SEFLG_EQUATORIAL | ifl; + iflagcart = iflag | SEFLG_XYZ; + if (ifltype == (SE_ECL_PARTIAL | SE_ECL_CENTRAL)) { + if (serr != NULL) + strcpy(serr, "central partial eclipses do not exist"); return ERR; - if (swe_calc(t, SE_MOON, iflag, lm, serr) == ERR) - return ERR; - if (swe_calc(t, SE_SUN, iflagcart, xs, serr) == ERR) - return ERR; - if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) - return ERR; - for (m = 0; m < 3; m++) { - xa[m] = xs[m] / ls[2]; - xb[m] = xm[m] / lm[2]; - } - dc[i] = acos(swi_dot_prod_unit(xa, xb)) * RADTODEG; - rmoon = asin(RMOON / lm[2]) * RADTODEG; - rsun = asin(RSUN / ls[2]) * RADTODEG; - dc[i] -= (rmoon + rsun); } - find_maximum(dc[0], dc[1], dc[2], dt, &dtint, &dctr); - tjd += dtint + dt; - } - tjds = tjd = tjd - swe_deltat(tjd); - if ((retflag = eclipse_where(tjd, SE_SUN, NULL, ifl, geopos, dcore, serr)) == ERR) - return retflag; - retflag2 = retflag; + if (ifltype == 0) + ifltype = + SE_ECL_TOTAL | SE_ECL_ANNULAR | SE_ECL_PARTIAL | + SE_ECL_ANNULAR_TOTAL | SE_ECL_NONCENTRAL | SE_ECL_CENTRAL; + if (backward) + direction = -1; + K = (int)((tjd_start - J2000) / 365.2425 * 12.3685); + K -= direction; +next_try: + retflag = 0; + dont_times = FALSE; + for (i = 0; i <= 9; i++) + tret[i] = 0; + T = K / 1236.85; + T2 = T * T; + T3 = T2 * T; + T4 = T3 * T; + Ff = swe_degnorm(160.7108 + 390.67050274 * K - 0.0016341 * T2 - + 0.00000227 * T3 + 0.000000011 * T4); + if (Ff > 180) + Ff -= 180; + if (Ff > 21 && Ff < 159) { /* no eclipse possible */ + K += direction; + goto next_try; + } + /* approximate time of geocentric maximum eclipse + * formula from Meeus, German, p. 381 */ + tjd = + 2451550.09765 + 29.530588853 * K + 0.0001337 * T2 - 0.000000150 * T3 + + 0.00000000073 * T4; + M = swe_degnorm(2.5534 + 29.10535669 * K - 0.0000218 * T2 - + 0.00000011 * T3); + Mm = swe_degnorm(201.5643 + 385.81693528 * K + 0.1017438 * T2 + + 0.00001239 * T3 + 0.000000058 * T4); + E = 1 - 0.002516 * T - 0.0000074 * T2; + M *= DEGTORAD; + Mm *= DEGTORAD; + tjd = tjd - 0.4075 * sin(Mm) + + 0.1721 * E * sin(M); + /* + * time of maximum eclipse (if eclipse) = + * minimum geocentric angle between sun and moon edges. + * After this time has been determined, check + * whether or not an eclipse is taking place with + * the functions eclipse_where() and _how(). + */ + dtstart = 1; + if (tjd < 2000000) + dtstart = 5; + dtdiv = 4; + for (dt = dtstart; dt > 0.0001; dt /= dtdiv) { + for (i = 0, t = tjd - dt; i <= 2; i++, t += dt) { + if (swe_calc(t, SE_SUN, iflag, ls, serr) == ERR) + return ERR; + if (swe_calc(t, SE_MOON, iflag, lm, serr) == ERR) + return ERR; + if (swe_calc(t, SE_SUN, iflagcart, xs, serr) == ERR) + return ERR; + if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) + return ERR; + for (m = 0; m < 3; m++) { + xa[m] = xs[m] / ls[2]; + xb[m] = xm[m] / lm[2]; + } + dc[i] = acos(swi_dot_prod_unit(xa, xb)) * RADTODEG; + rmoon = asin(RMOON / lm[2]) * RADTODEG; + rsun = asin(RSUN / ls[2]) * RADTODEG; + dc[i] -= (rmoon + rsun); + } + find_maximum(dc[0], dc[1], dc[2], dt, &dtint, &dctr); + tjd += dtint + dt; + } + tjds = tjd = tjd - swe_deltat(tjd); + if ((retflag = + eclipse_where(tjd, SE_SUN, NULL, ifl, geopos, dcore, serr)) == ERR) + return retflag; + retflag2 = retflag; /* in extreme cases _where() returns no eclipse, where there is * actually a very small one, therefore call _how() with the * coordinates returned by _where(): */ - if ((retflag2 = eclipse_how(tjd, SE_SUN, NULL, ifl, geopos[0], geopos[1], 0, attr, serr)) == ERR) - return retflag2; - if (retflag2 == 0) { - K += direction; - goto next_try; - } - tret[0] = tjd; - if ((backward && tret[0] >= tjd_start - 0.0001) - || (!backward && tret[0] <= tjd_start + 0.0001)) { - K += direction; - goto next_try; - } - /* - * eclipse type, SE_ECL_TOTAL, _ANNULAR, etc. - * SE_ECL_ANNULAR_TOTAL will be discovered later - */ - if ((retflag = eclipse_where(tjd, SE_SUN, NULL, ifl, geopos, dcore, serr)) == ERR) - return retflag; - if (retflag == 0) { /* can happen with extremely small percentage */ - retflag = SE_ECL_PARTIAL | SE_ECL_NONCENTRAL; - tret[4] = tret[5] = tjd; /* fix this ???? */ - dont_times = TRUE; - } - /* - * check whether or not eclipse type found is wanted - */ - /* non central eclipse is wanted: */ - if (!(ifltype & SE_ECL_NONCENTRAL) && (retflag & SE_ECL_NONCENTRAL)) { - K += direction; - goto next_try; - } - /* central eclipse is wanted: */ - if (!(ifltype & SE_ECL_CENTRAL) && (retflag & SE_ECL_CENTRAL)) { - K += direction; - goto next_try; - } - /* non annular eclipse is wanted: */ - if (!(ifltype & SE_ECL_ANNULAR) && (retflag & SE_ECL_ANNULAR)) { - K += direction; - goto next_try; - } - /* non partial eclipse is wanted: */ - if (!(ifltype & SE_ECL_PARTIAL) && (retflag & SE_ECL_PARTIAL)) { - K += direction; - goto next_try; - } - /* annular-total eclipse will be discovered later */ - if (!(ifltype & (SE_ECL_TOTAL | SE_ECL_ANNULAR_TOTAL)) && (retflag & SE_ECL_TOTAL)) { - K += direction; - goto next_try; - } - if (dont_times) - goto end_search_global; - /* - * n = 0: times of eclipse begin and end - * n = 1: times of totality begin and end - * n = 2: times of center line begin and end - */ - if (retflag & SE_ECL_PARTIAL) - o = 0; - else if (retflag & SE_ECL_NONCENTRAL) - o = 1; - else - o = 2; - dta = twohr; - dtb = tenmin / 3.0; - for (n = 0; n <= o; n++) { - if (n == 0) { - /*dc[1] = dcore[3] / 2 + de - dcore[1];*/ - i1 = 2; i2 = 3; - } else if (n == 1) { - if (retflag & SE_ECL_PARTIAL) - continue; - i1 = 4; i2 = 5; - } else if (n == 2) { - if (retflag & SE_ECL_NONCENTRAL) - continue; - i1 = 6; i2 = 7; - } - for (i = 0, t = tjd - dta; i <= 2; i += 1, t += dta) { - if ((retflag2 = eclipse_where(t, SE_SUN, NULL, ifl, geopos, dcore, serr)) == ERR) + if ((retflag2 = + eclipse_how(tjd, SE_SUN, NULL, ifl, geopos[0], geopos[1], 0, attr, + serr)) == ERR) return retflag2; - if (n == 0) - dc[i] = dcore[4] / 2 + de / dcore[5] - dcore[2]; - else if (n == 1) - dc[i] = fabs(dcore[3]) / 2 + de / dcore[6] - dcore[2]; - else if (n == 2) - dc[i] = de / dcore[6] - dcore[2]; + if (retflag2 == 0) { + K += direction; + goto next_try; } - find_zero(dc[0], dc[1], dc[2], dta, &dt1, &dt2); - tret[i1] = tjd + dt1 + dta; - tret[i2] = tjd + dt2 + dta; - for (m = 0, dt = dtb; m < 3; m++, dt /= 3) { - for (j = i1; j <= i2; j += (i2 - i1)) { - for (i = 0, t = tret[j] - dt; i < 2; i++, t += dt) { - if ((retflag2 = eclipse_where(t, SE_SUN, NULL, ifl, geopos, dcore, serr)) == ERR) - return retflag2; - if (n == 0) - dc[i] = dcore[4] / 2 + de / dcore[5] - dcore[2]; - else if (n == 1) - dc[i] = fabs(dcore[3]) / 2 + de / dcore[6] - dcore[2]; - else if (n == 2) - dc[i] = de / dcore[6] - dcore[2]; - } - dt1 = dc[1] / ((dc[1] - dc[0]) / dt); - tret[j] -= dt1; - } + tret[0] = tjd; + if ((backward && tret[0] >= tjd_start - 0.0001) + || (!backward && tret[0] <= tjd_start + 0.0001)) { + K += direction; + goto next_try; } - } - /* - * annular-total eclipses - */ - if (retflag & SE_ECL_TOTAL) { - if ((retflag2 = eclipse_where(tret[0], SE_SUN, NULL, ifl, geopos, dcore, serr)) == ERR) - return retflag2; - dc[0] = *dcore; - if ((retflag2 = eclipse_where(tret[4], SE_SUN, NULL, ifl, geopos, dcore, serr)) == ERR) - return retflag2; - dc[1] = *dcore; - if ((retflag2 = eclipse_where(tret[5], SE_SUN, NULL, ifl, geopos, dcore, serr)) == ERR) - return retflag2; - dc[2] = *dcore; - /* the maximum is always total, and there is either one or - * to times before and after, when the core shadow becomes - * zero and totality changes into annularity or vice versa. + /* + * eclipse type, SE_ECL_TOTAL, _ANNULAR, etc. + * SE_ECL_ANNULAR_TOTAL will be discovered later */ - if (dc[0] * dc[1] < 0 || dc[0] * dc[2] < 0) { - retflag |= SE_ECL_ANNULAR_TOTAL; - retflag &= ~SE_ECL_TOTAL; - } - } - /* if eclipse is given but not wanted: */ - if (!(ifltype & SE_ECL_TOTAL) && (retflag & SE_ECL_TOTAL)) { - K += direction; - goto next_try; - } - /* if annular_total eclipse is given but not wanted: */ - if (!(ifltype & SE_ECL_ANNULAR_TOTAL) && (retflag & SE_ECL_ANNULAR_TOTAL)) { - K += direction; - goto next_try; - } - /* - * time of maximum eclipse at local apparent noon - */ - /* first, find out, if there is a solar transit - * between begin and end of eclipse */ - k = 2; - for (i = 0; i < 2; i++) { - j = i + k; - tt = tret[j] + swe_deltat(tret[j]); - if (swe_calc(tt, SE_SUN, iflag, ls, serr) == ERR) - return ERR; - if (swe_calc(tt, SE_MOON, iflag, lm, serr) == ERR) - return ERR; - dc[i] = swe_degnorm(ls[0] - lm[0]); - if (dc[i] > 180) - dc[i] -= 360; - } - if (dc[0] * dc[1] >= 0) /* no transit */ - tret[1] = 0; - else { - tjd = tjds; - dt = 0.1; - dt1 = (tret[3] - tret[2]) / 2.0; - if (dt1 < dt) - dt = dt1 / 2.0; - for (j = 0; - dt > 0.01; - j++, dt /= 3) { - for (i = 0, t = tjd; i <= 1; i++, t -= dt) { - tt = t + swe_deltat(t); + if ((retflag = + eclipse_where(tjd, SE_SUN, NULL, ifl, geopos, dcore, serr)) == ERR) + return retflag; + if (retflag == 0) { /* can happen with extremely small percentage */ + retflag = SE_ECL_PARTIAL | SE_ECL_NONCENTRAL; + tret[4] = tret[5] = tjd; /* fix this ???? */ + dont_times = TRUE; + } + /* + * check whether or not eclipse type found is wanted + */ + /* non central eclipse is wanted: */ + if (!(ifltype & SE_ECL_NONCENTRAL) && (retflag & SE_ECL_NONCENTRAL)) { + K += direction; + goto next_try; + } + /* central eclipse is wanted: */ + if (!(ifltype & SE_ECL_CENTRAL) && (retflag & SE_ECL_CENTRAL)) { + K += direction; + goto next_try; + } + /* non annular eclipse is wanted: */ + if (!(ifltype & SE_ECL_ANNULAR) && (retflag & SE_ECL_ANNULAR)) { + K += direction; + goto next_try; + } + /* non partial eclipse is wanted: */ + if (!(ifltype & SE_ECL_PARTIAL) && (retflag & SE_ECL_PARTIAL)) { + K += direction; + goto next_try; + } + /* annular-total eclipse will be discovered later */ + if (!(ifltype & (SE_ECL_TOTAL | SE_ECL_ANNULAR_TOTAL)) + && (retflag & SE_ECL_TOTAL)) { + K += direction; + goto next_try; + } + if (dont_times) + goto end_search_global; + /* + * n = 0: times of eclipse begin and end + * n = 1: times of totality begin and end + * n = 2: times of center line begin and end + */ + if (retflag & SE_ECL_PARTIAL) + o = 0; + else if (retflag & SE_ECL_NONCENTRAL) + o = 1; + else + o = 2; + dta = twohr; + dtb = tenmin / 3.0; + for (n = 0; n <= o; n++) { + if (n == 0) { + /*dc[1] = dcore[3] / 2 + de - dcore[1]; */ + i1 = 2; + i2 = 3; + } + else if (n == 1) { + if (retflag & SE_ECL_PARTIAL) + continue; + i1 = 4; + i2 = 5; + } + else if (n == 2) { + if (retflag & SE_ECL_NONCENTRAL) + continue; + i1 = 6; + i2 = 7; + } + for (i = 0, t = tjd - dta; i <= 2; i += 1, t += dta) { + if ((retflag2 = + eclipse_where(t, SE_SUN, NULL, ifl, geopos, dcore, + serr)) == ERR) + return retflag2; + if (n == 0) + dc[i] = dcore[4] / 2 + de / dcore[5] - dcore[2]; + else if (n == 1) + dc[i] = fabs(dcore[3]) / 2 + de / dcore[6] - dcore[2]; + else if (n == 2) + dc[i] = de / dcore[6] - dcore[2]; + } + find_zero(dc[0], dc[1], dc[2], dta, &dt1, &dt2); + tret[i1] = tjd + dt1 + dta; + tret[i2] = tjd + dt2 + dta; + for (m = 0, dt = dtb; m < 3; m++, dt /= 3) { + for (j = i1; j <= i2; j += (i2 - i1)) { + for (i = 0, t = tret[j] - dt; i < 2; i++, t += dt) { + if ((retflag2 = + eclipse_where(t, SE_SUN, NULL, ifl, geopos, dcore, + serr)) == ERR) + return retflag2; + if (n == 0) + dc[i] = dcore[4] / 2 + de / dcore[5] - dcore[2]; + else if (n == 1) + dc[i] = fabs(dcore[3]) / 2 + de / dcore[6] - dcore[2]; + else if (n == 2) + dc[i] = de / dcore[6] - dcore[2]; + } + dt1 = dc[1] / ((dc[1] - dc[0]) / dt); + tret[j] -= dt1; + } + } + } + /* + * annular-total eclipses + */ + if (retflag & SE_ECL_TOTAL) { + if ((retflag2 = + eclipse_where(tret[0], SE_SUN, NULL, ifl, geopos, dcore, + serr)) == ERR) + return retflag2; + dc[0] = *dcore; + if ((retflag2 = + eclipse_where(tret[4], SE_SUN, NULL, ifl, geopos, dcore, + serr)) == ERR) + return retflag2; + dc[1] = *dcore; + if ((retflag2 = + eclipse_where(tret[5], SE_SUN, NULL, ifl, geopos, dcore, + serr)) == ERR) + return retflag2; + dc[2] = *dcore; + /* the maximum is always total, and there is either one or + * to times before and after, when the core shadow becomes + * zero and totality changes into annularity or vice versa. + */ + if (dc[0] * dc[1] < 0 || dc[0] * dc[2] < 0) { + retflag |= SE_ECL_ANNULAR_TOTAL; + retflag &= ~SE_ECL_TOTAL; + } + } + /* if eclipse is given but not wanted: */ + if (!(ifltype & SE_ECL_TOTAL) && (retflag & SE_ECL_TOTAL)) { + K += direction; + goto next_try; + } + /* if annular_total eclipse is given but not wanted: */ + if (!(ifltype & SE_ECL_ANNULAR_TOTAL) && (retflag & SE_ECL_ANNULAR_TOTAL)) { + K += direction; + goto next_try; + } + /* + * time of maximum eclipse at local apparent noon + */ + /* first, find out, if there is a solar transit + * between begin and end of eclipse */ + k = 2; + for (i = 0; i < 2; i++) { + j = i + k; + tt = tret[j] + swe_deltat(tret[j]); if (swe_calc(tt, SE_SUN, iflag, ls, serr) == ERR) - return ERR; + return ERR; if (swe_calc(tt, SE_MOON, iflag, lm, serr) == ERR) - return ERR; + return ERR; dc[i] = swe_degnorm(ls[0] - lm[0]); if (dc[i] > 180) - dc[i] -= 360; - if (dc[i] > 180) - dc[i] -= 360; - } - a = (dc[1] - dc[0]) / dt; - if (a < 1e-10) - break; - dt1 = dc[0] / a; - tjd += dt1; + dc[i] -= 360; + } + if (dc[0] * dc[1] >= 0) /* no transit */ + tret[1] = 0; + else { + tjd = tjds; + dt = 0.1; + dt1 = (tret[3] - tret[2]) / 2.0; + if (dt1 < dt) + dt = dt1 / 2.0; + for (j = 0; dt > 0.01; j++, dt /= 3) { + for (i = 0, t = tjd; i <= 1; i++, t -= dt) { + tt = t + swe_deltat(t); + if (swe_calc(tt, SE_SUN, iflag, ls, serr) == ERR) + return ERR; + if (swe_calc(tt, SE_MOON, iflag, lm, serr) == ERR) + return ERR; + dc[i] = swe_degnorm(ls[0] - lm[0]); + if (dc[i] > 180) + dc[i] -= 360; + if (dc[i] > 180) + dc[i] -= 360; + } + a = (dc[1] - dc[0]) / dt; + if (a < 1e-10) + break; + dt1 = dc[0] / a; + tjd += dt1; + } + tret[1] = tjd; } - tret[1] = tjd; - } end_search_global: - return retflag; - /* - * the time of maximum occultation is practically identical - * with the time of maximum core shadow diameter. - * - * the time, when duration of totality is maximal, - * is not an interesting computation either. Near the maximum - * occulation, the time of totality can be the same by - * a second for hundreds of kilometers (for 10 minutes - * or more). - * - * for annular eclipses the maximum duration is close to the - * beginning and the end of the center lines, where is also - * the minimum of core shadow diameter. - */ + return retflag; + /* + * the time of maximum occultation is practically identical + * with the time of maximum core shadow diameter. + * + * the time, when duration of totality is maximal, + * is not an interesting computation either. Near the maximum + * occulation, the time of totality can be the same by + * a second for hundreds of kilometers (for 10 minutes + * or more). + * + * for annular eclipses the maximum duration is close to the + * beginning and the end of the center lines, where is also + * the minimum of core shadow diameter. + */ } /* When is the next lunar occultation anywhere on earth? @@ -1513,337 +1561,359 @@ end_search_global: * declare as tret[10] at least! * */ -int32 FAR PASCAL_CONV swe_lun_occult_when_glob( - double tjd_start, int32 ipl, char *starname, int32 ifl, int32 ifltype, - double *tret, int32 backward, char *serr) +int32 FAR PASCAL_CONV +swe_lun_occult_when_glob(double tjd_start, int32 ipl, char *starname, + int32 ifl, int32 ifltype, double *tret, + int32 backward, char *serr) { - int i, j, k, m, n, o, i1, i2; - int32 retflag = 0, retflag2 = 0; - double de = 6378.140, a; - double t, tt, tjd = 0, tjds, dt, dtint, dta, dtb; - double drad; - double xs[6], xm[6], ls[6], lm[6]; - double rmoon, rsun, dcore[10]; - double dc[20], dctr; - double twohr = 2.0 / 24.0; - double tenmin = 10.0 / 24.0 / 60.0; - double dt1, dt2, dadd = 10, dadd2 = 6; - int nstartpos = 10; - double geopos[20]; - double dtstart, dtdiv; - int direction = 1; - char s[AS_MAXCH]; - int32 iflag, iflagcart; - AS_BOOL dont_times = FALSE; - int32 one_try = backward & SE_ECL_ONE_TRY; + int i, j, k, m, n, o, i1, i2; + int32 retflag = 0, retflag2 = 0; + double de = 6378.140, a; + double t, tt, tjd = 0, tjds, dt, dtint, dta, dtb; + double drad; + double xs[6], xm[6], ls[6], lm[6]; + double rmoon, rsun, dcore[10]; + double dc[20], dctr; + double twohr = 2.0 / 24.0; + double tenmin = 10.0 / 24.0 / 60.0; + double dt1, dt2, dadd = 10, dadd2 = 6; + int nstartpos = 10; + double geopos[20]; + double dtstart, dtdiv; + int direction = 1; + char s[AS_MAXCH]; + int32 iflag, iflagcart; + AS_BOOL dont_times = FALSE; + int32 one_try = backward & SE_ECL_ONE_TRY; + /*if (backward & SEI_OCC_FAST) dont_times = TRUE; */ - /* function calls for Pluto with asteroid number 134340 - * are treated as calls for Pluto as main body SE_PLUTO */ - if (ipl == SE_AST_OFFSET + 134340) - ipl = SE_PLUTO; - ifl &= SEFLG_EPHMASK; - iflag = SEFLG_EQUATORIAL | ifl; - iflagcart = iflag | SEFLG_XYZ; - backward &= 1L; - /* - * initializations - */ - if (ifltype == (SE_ECL_PARTIAL | SE_ECL_CENTRAL)) { - if (serr != NULL) - strcpy(serr, "central partial eclipses do not exist"); - return ERR; - } - if (ifltype == 0) - ifltype = SE_ECL_TOTAL | SE_ECL_ANNULAR | SE_ECL_PARTIAL - | SE_ECL_ANNULAR_TOTAL | SE_ECL_NONCENTRAL | SE_ECL_CENTRAL; - retflag = 0; - for (i = 0; i <= 9; i++) - tret[i] = 0; - if (backward) - direction = -1; - t = tjd_start - direction * 0.001; + /* function calls for Pluto with asteroid number 134340 + * are treated as calls for Pluto as main body SE_PLUTO */ + if (ipl == SE_AST_OFFSET + 134340) + ipl = SE_PLUTO; + ifl &= SEFLG_EPHMASK; + iflag = SEFLG_EQUATORIAL | ifl; + iflagcart = iflag | SEFLG_XYZ; + backward &= 1L; + /* + * initializations + */ + if (ifltype == (SE_ECL_PARTIAL | SE_ECL_CENTRAL)) { + if (serr != NULL) + strcpy(serr, "central partial eclipses do not exist"); + return ERR; + } + if (ifltype == 0) + ifltype = + SE_ECL_TOTAL | SE_ECL_ANNULAR | SE_ECL_PARTIAL | + SE_ECL_ANNULAR_TOTAL | SE_ECL_NONCENTRAL | SE_ECL_CENTRAL; + retflag = 0; + for (i = 0; i <= 9; i++) + tret[i] = 0; + if (backward) + direction = -1; + t = tjd_start - direction * 0.001; next_try: - for (i = 0; i < nstartpos; i++, t += direction * dadd2) { - if (calc_planet_star(t, ipl, starname, iflagcart, xs, serr) == ERR) - return ERR; - if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) - return ERR; - dc[i] = acos(swi_dot_prod_unit(xs, xm)) * RADTODEG; - if (i > 1 && dc[i] > dc[i-1] && dc[i-2] > dc[i-1]) { - tjd = t - direction * dadd2; - break; - } else if (i == nstartpos-1) { - /*for (j = 0; j < nstartpos; j++) - printf("%f ", dc[j]);*/ - if (serr != NULL) { - if (starname != NULL && *starname != '\0') - strcpy(s, starname); - else - swe_get_planet_name(ipl , s); - sprintf(serr, "error in swe_lun_occult_when_glob(): conjunction of moon with planet %s not found\n", s); - } - return ERR; + for (i = 0; i < nstartpos; i++, t += direction * dadd2) { + if (calc_planet_star(t, ipl, starname, iflagcart, xs, serr) == ERR) + return ERR; + if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) + return ERR; + dc[i] = acos(swi_dot_prod_unit(xs, xm)) * RADTODEG; + if (i > 1 && dc[i] > dc[i - 1] && dc[i - 2] > dc[i - 1]) { + tjd = t - direction * dadd2; + break; + } + else if (i == nstartpos - 1) { + /*for (j = 0; j < nstartpos; j++) + * printf("%f ", dc[j]); */ + if (serr != NULL) { + if (starname != NULL && *starname != '\0') + strcpy(s, starname); + else + swe_get_planet_name(ipl, s); + sprintf(serr, + "error in swe_lun_occult_when_glob(): conjunction of moon with planet %s not found\n", + s); + } + return ERR; + } } - } - /* - * radius of planet disk in AU - */ - if (starname != NULL && *starname != '\0') - drad = 0; - else if (ipl < NDIAM) - drad = pla_diam[ipl] / 2 / AUNIT; - else if (ipl > SE_AST_OFFSET) - drad = swed.ast_diam / 2 * 1000 / AUNIT; /* km -> m -> AU */ - else - drad = 0; - /* - * time of maximum eclipse (if eclipse) = - * minimum geocentric angle between sun and moon edges. - * After this time has been determined, check - * whether or not an eclipse is taking place with - * the functions eclipse_where() and _how(). - */ - dtstart = dadd2; /* originally 1 */ - dtdiv = 3; - for (dt = dtstart; - dt > 0.0001; - dt /= dtdiv) { - for (i = 0, t = tjd - dt; i <= 2; i++, t += dt) { - if (calc_planet_star(t, ipl, starname, iflag, ls, serr) == ERR) - return ERR; - if (swe_calc(t, SE_MOON, iflag, lm, serr) == ERR) - return ERR; - if (calc_planet_star(t, ipl, starname, iflagcart, xs, serr) == ERR) - return ERR; - if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) - return ERR; - dc[i] = acos(swi_dot_prod_unit(xs, xm)) * RADTODEG; - rmoon = asin(RMOON / lm[2]) * RADTODEG; - rsun = asin(drad / ls[2]) * RADTODEG; - dc[i] -= (rmoon + rsun); + /* + * radius of planet disk in AU + */ + if (starname != NULL && *starname != '\0') + drad = 0; + else if (ipl < NDIAM) + drad = pla_diam[ipl] / 2 / AUNIT; + else if (ipl > SE_AST_OFFSET) + drad = swed.ast_diam / 2 * 1000 / AUNIT; /* km -> m -> AU */ + else + drad = 0; + /* + * time of maximum eclipse (if eclipse) = + * minimum geocentric angle between sun and moon edges. + * After this time has been determined, check + * whether or not an eclipse is taking place with + * the functions eclipse_where() and _how(). + */ + dtstart = dadd2; /* originally 1 */ + dtdiv = 3; + for (dt = dtstart; dt > 0.0001; dt /= dtdiv) { + for (i = 0, t = tjd - dt; i <= 2; i++, t += dt) { + if (calc_planet_star(t, ipl, starname, iflag, ls, serr) == ERR) + return ERR; + if (swe_calc(t, SE_MOON, iflag, lm, serr) == ERR) + return ERR; + if (calc_planet_star(t, ipl, starname, iflagcart, xs, serr) == + ERR) + return ERR; + if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) + return ERR; + dc[i] = acos(swi_dot_prod_unit(xs, xm)) * RADTODEG; + rmoon = asin(RMOON / lm[2]) * RADTODEG; + rsun = asin(drad / ls[2]) * RADTODEG; + dc[i] -= (rmoon + rsun); + } + find_maximum(dc[0], dc[1], dc[2], dt, &dtint, &dctr); + tjd += dtint + dt; } - find_maximum(dc[0], dc[1], dc[2], dt, &dtint, &dctr); - tjd += dtint + dt; - } - tjd -= swe_deltat(tjd); - tjds = tjd; - if ((retflag = eclipse_where(tjd, ipl, starname, ifl, geopos, dcore, serr)) == ERR) - return retflag; - retflag2 = retflag; + tjd -= swe_deltat(tjd); + tjds = tjd; + if ((retflag = + eclipse_where(tjd, ipl, starname, ifl, geopos, dcore, serr)) == ERR) + return retflag; + retflag2 = retflag; /* in extreme cases _where() returns no eclipse, where there is * actually a very small one, therefore call _how() with the * coordinates returned by _where(): */ - /* if ((retflag2 = eclipse_how(tjd, ipl, starname, ifl, geopos[0], geopos[1], 0, attr, serr)) == ERR) - return retflag2; */ - if (retflag2 == 0) { - /* only one try! */ - if (one_try) { - tret[0] = tjd; - return 0; - } - t= tjd + direction * dadd; - goto next_try; - } - tret[0] = tjd; - if ((backward && tret[0] >= tjd_start - 0.0001) - || (!backward && tret[0] <= tjd_start + 0.0001)) { - t= tjd + direction * dadd; - goto next_try; - } - /* - * eclipse type, SE_ECL_TOTAL, _ANNULAR, etc. - * SE_ECL_ANNULAR_TOTAL will be discovered later - */ - if ((retflag = eclipse_where(tjd, ipl, starname, ifl, geopos, dcore, serr)) == ERR) - return retflag; - if (retflag == 0) { /* can happen with extremely small percentage */ - retflag = SE_ECL_PARTIAL | SE_ECL_NONCENTRAL; - tret[4] = tret[5] = tjd; /* fix this ???? */ - dont_times = TRUE; - } - /* - * check whether or not eclipse type found is wanted - */ - /* non central eclipse is wanted: */ - if (!(ifltype & SE_ECL_NONCENTRAL) && (retflag & SE_ECL_NONCENTRAL)) { - t= tjd + direction * dadd; - goto next_try; - } - /* central eclipse is wanted: */ - if (!(ifltype & SE_ECL_CENTRAL) && (retflag & SE_ECL_CENTRAL)) { - t= tjd + direction * dadd; - goto next_try; - } - /* non annular eclipse is wanted: */ - if (!(ifltype & SE_ECL_ANNULAR) && (retflag & SE_ECL_ANNULAR)) { - t= tjd + direction * dadd; - goto next_try; - } - /* non partial eclipse is wanted: */ - if (!(ifltype & SE_ECL_PARTIAL) && (retflag & SE_ECL_PARTIAL)) { - t= tjd + direction * dadd; - goto next_try; - } - /* annular-total eclipse will be discovered later */ - if (!(ifltype & (SE_ECL_TOTAL | SE_ECL_ANNULAR_TOTAL)) && (retflag & SE_ECL_TOTAL)) { - t= tjd + direction * dadd; - goto next_try; - } - if (dont_times) - goto end_search_global; - /* - * n = 0: times of eclipse begin and end - * n = 1: times of totality begin and end - * n = 2: times of center line begin and end - */ - if (retflag & SE_ECL_PARTIAL) - o = 0; - else if (retflag & SE_ECL_NONCENTRAL) - o = 1; - else - o = 2; - dta = twohr; - dtb = tenmin; - for (n = 0; n <= o; n++) { - if (n == 0) { - /*dc[1] = dcore[3] / 2 + de - dcore[1];*/ - i1 = 2; i2 = 3; - } else if (n == 1) { - if (retflag & SE_ECL_PARTIAL) - continue; - i1 = 4; i2 = 5; - } else if (n == 2) { - if (retflag & SE_ECL_NONCENTRAL) - continue; - i1 = 6; i2 = 7; - } - for (i = 0, t = tjd - dta; i <= 2; i += 1, t += dta) { - if ((retflag2 = eclipse_where(t, ipl, starname, ifl, geopos, dcore, serr)) == ERR) - return retflag2; - if (n == 0) - dc[i] = dcore[4] / 2 + de / dcore[5] - dcore[2]; - else if (n == 1) - dc[i] = fabs(dcore[3]) / 2 + de / dcore[6] - dcore[2]; - else if (n == 2) - dc[i] = de / dcore[6] - dcore[2]; - } - find_zero(dc[0], dc[1], dc[2], dta, &dt1, &dt2); - tret[i1] = tjd + dt1 + dta; - tret[i2] = tjd + dt2 + dta; - for (m = 0, dt = dtb; m < 3; m++, dt /= 3) { - for (j = i1; j <= i2; j += (i2 - i1)) { - for (i = 0, t = tret[j] - dt; i < 2; i++, t += dt) { - if ((retflag2 = eclipse_where(t, ipl, starname, ifl, geopos, dcore, serr)) == ERR) - return retflag2; - if (n == 0) - dc[i] = dcore[4] / 2 + de / dcore[5] - dcore[2]; - else if (n == 1) - dc[i] = fabs(dcore[3]) / 2 + de / dcore[6] - dcore[2]; - else if (n == 2) - dc[i] = de / dcore[6] - dcore[2]; + /* if ((retflag2 = eclipse_how(tjd, ipl, starname, ifl, geopos[0], geopos[1], 0, attr, serr)) == ERR) + * return retflag2; */ + if (retflag2 == 0) { + /* only one try! */ + if (one_try) { + tret[0] = tjd; + return 0; } - dt1 = dc[1] / ((dc[1] - dc[0]) / dt); - tret[j] -= dt1; - } + t = tjd + direction * dadd; + goto next_try; } - } - /* - * annular-total eclipses - */ - if (retflag & SE_ECL_TOTAL) { - if ((retflag2 = eclipse_where(tret[0], ipl, starname, ifl, geopos, dcore, serr)) == ERR) - return retflag2; - dc[0] = *dcore; - if ((retflag2 = eclipse_where(tret[4], ipl, starname, ifl, geopos, dcore, serr)) == ERR) - return retflag2; - dc[1] = *dcore; - if ((retflag2 = eclipse_where(tret[5], ipl, starname, ifl, geopos, dcore, serr)) == ERR) - return retflag2; - dc[2] = *dcore; - /* the maximum is always total, and there is either one or - * to times before and after, when the core shadow becomes - * zero and totality changes into annularity or vice versa. + tret[0] = tjd; + if ((backward && tret[0] >= tjd_start - 0.0001) + || (!backward && tret[0] <= tjd_start + 0.0001)) { + t = tjd + direction * dadd; + goto next_try; + } + /* + * eclipse type, SE_ECL_TOTAL, _ANNULAR, etc. + * SE_ECL_ANNULAR_TOTAL will be discovered later */ - if (dc[0] * dc[1] < 0 || dc[0] * dc[2] < 0) { - retflag |= SE_ECL_ANNULAR_TOTAL; - retflag &= ~SE_ECL_TOTAL; - } - } - /* if eclipse is given but not wanted: */ - if (!(ifltype & SE_ECL_TOTAL) && (retflag & SE_ECL_TOTAL)) { - t= tjd + direction * dadd; - goto next_try; - } - /* if annular_total eclipse is given but not wanted: */ - if (!(ifltype & SE_ECL_ANNULAR_TOTAL) && (retflag & SE_ECL_ANNULAR_TOTAL)) { - t= tjd + direction * dadd; - goto next_try; - } - /* - * time of maximum eclipse at local apparent noon - */ - /* first, find out, if there is a solar transit - * between begin and end of eclipse */ - k = 2; - for (i = 0; i < 2; i++) { - j = i + k; - tt = tret[j] + swe_deltat(tret[j]); - if (calc_planet_star(tt, ipl, starname, iflag, ls, serr) == ERR) - return ERR; - if (swe_calc(tt, SE_MOON, iflag, lm, serr) == ERR) - return ERR; - dc[i] = swe_degnorm(ls[0] - lm[0]); - if (dc[i] > 180) - dc[i] -= 360; - } - if (dc[0] * dc[1] >= 0) /* no transit */ - tret[1] = 0; - else { - tjd = tjds; - dt = 0.1; - dt1 = (tret[3] - tret[2]) / 2.0; - if (dt1 < dt) - dt = dt1 / 2.0; - for (j = 0; - dt > 0.01; - j++, dt /= 3) { - for (i = 0, t = tjd; i <= 1; i++, t -= dt) { - tt = t + swe_deltat(t); + if ((retflag = + eclipse_where(tjd, ipl, starname, ifl, geopos, dcore, serr)) == ERR) + return retflag; + if (retflag == 0) { /* can happen with extremely small percentage */ + retflag = SE_ECL_PARTIAL | SE_ECL_NONCENTRAL; + tret[4] = tret[5] = tjd; /* fix this ???? */ + dont_times = TRUE; + } + /* + * check whether or not eclipse type found is wanted + */ + /* non central eclipse is wanted: */ + if (!(ifltype & SE_ECL_NONCENTRAL) && (retflag & SE_ECL_NONCENTRAL)) { + t = tjd + direction * dadd; + goto next_try; + } + /* central eclipse is wanted: */ + if (!(ifltype & SE_ECL_CENTRAL) && (retflag & SE_ECL_CENTRAL)) { + t = tjd + direction * dadd; + goto next_try; + } + /* non annular eclipse is wanted: */ + if (!(ifltype & SE_ECL_ANNULAR) && (retflag & SE_ECL_ANNULAR)) { + t = tjd + direction * dadd; + goto next_try; + } + /* non partial eclipse is wanted: */ + if (!(ifltype & SE_ECL_PARTIAL) && (retflag & SE_ECL_PARTIAL)) { + t = tjd + direction * dadd; + goto next_try; + } + /* annular-total eclipse will be discovered later */ + if (!(ifltype & (SE_ECL_TOTAL | SE_ECL_ANNULAR_TOTAL)) + && (retflag & SE_ECL_TOTAL)) { + t = tjd + direction * dadd; + goto next_try; + } + if (dont_times) + goto end_search_global; + /* + * n = 0: times of eclipse begin and end + * n = 1: times of totality begin and end + * n = 2: times of center line begin and end + */ + if (retflag & SE_ECL_PARTIAL) + o = 0; + else if (retflag & SE_ECL_NONCENTRAL) + o = 1; + else + o = 2; + dta = twohr; + dtb = tenmin; + for (n = 0; n <= o; n++) { + if (n == 0) { + /*dc[1] = dcore[3] / 2 + de - dcore[1]; */ + i1 = 2; + i2 = 3; + } + else if (n == 1) { + if (retflag & SE_ECL_PARTIAL) + continue; + i1 = 4; + i2 = 5; + } + else if (n == 2) { + if (retflag & SE_ECL_NONCENTRAL) + continue; + i1 = 6; + i2 = 7; + } + for (i = 0, t = tjd - dta; i <= 2; i += 1, t += dta) { + if ((retflag2 = + eclipse_where(t, ipl, starname, ifl, geopos, dcore, + serr)) == ERR) + return retflag2; + if (n == 0) + dc[i] = dcore[4] / 2 + de / dcore[5] - dcore[2]; + else if (n == 1) + dc[i] = fabs(dcore[3]) / 2 + de / dcore[6] - dcore[2]; + else if (n == 2) + dc[i] = de / dcore[6] - dcore[2]; + } + find_zero(dc[0], dc[1], dc[2], dta, &dt1, &dt2); + tret[i1] = tjd + dt1 + dta; + tret[i2] = tjd + dt2 + dta; + for (m = 0, dt = dtb; m < 3; m++, dt /= 3) { + for (j = i1; j <= i2; j += (i2 - i1)) { + for (i = 0, t = tret[j] - dt; i < 2; i++, t += dt) { + if ((retflag2 = + eclipse_where(t, ipl, starname, ifl, geopos, dcore, + serr)) == ERR) + return retflag2; + if (n == 0) + dc[i] = dcore[4] / 2 + de / dcore[5] - dcore[2]; + else if (n == 1) + dc[i] = fabs(dcore[3]) / 2 + de / dcore[6] - dcore[2]; + else if (n == 2) + dc[i] = de / dcore[6] - dcore[2]; + } + dt1 = dc[1] / ((dc[1] - dc[0]) / dt); + tret[j] -= dt1; + } + } + } + /* + * annular-total eclipses + */ + if (retflag & SE_ECL_TOTAL) { + if ((retflag2 = + eclipse_where(tret[0], ipl, starname, ifl, geopos, dcore, + serr)) == ERR) + return retflag2; + dc[0] = *dcore; + if ((retflag2 = + eclipse_where(tret[4], ipl, starname, ifl, geopos, dcore, + serr)) == ERR) + return retflag2; + dc[1] = *dcore; + if ((retflag2 = + eclipse_where(tret[5], ipl, starname, ifl, geopos, dcore, + serr)) == ERR) + return retflag2; + dc[2] = *dcore; + /* the maximum is always total, and there is either one or + * to times before and after, when the core shadow becomes + * zero and totality changes into annularity or vice versa. + */ + if (dc[0] * dc[1] < 0 || dc[0] * dc[2] < 0) { + retflag |= SE_ECL_ANNULAR_TOTAL; + retflag &= ~SE_ECL_TOTAL; + } + } + /* if eclipse is given but not wanted: */ + if (!(ifltype & SE_ECL_TOTAL) && (retflag & SE_ECL_TOTAL)) { + t = tjd + direction * dadd; + goto next_try; + } + /* if annular_total eclipse is given but not wanted: */ + if (!(ifltype & SE_ECL_ANNULAR_TOTAL) && (retflag & SE_ECL_ANNULAR_TOTAL)) { + t = tjd + direction * dadd; + goto next_try; + } + /* + * time of maximum eclipse at local apparent noon + */ + /* first, find out, if there is a solar transit + * between begin and end of eclipse */ + k = 2; + for (i = 0; i < 2; i++) { + j = i + k; + tt = tret[j] + swe_deltat(tret[j]); if (calc_planet_star(tt, ipl, starname, iflag, ls, serr) == ERR) - return ERR; + return ERR; if (swe_calc(tt, SE_MOON, iflag, lm, serr) == ERR) - return ERR; + return ERR; dc[i] = swe_degnorm(ls[0] - lm[0]); if (dc[i] > 180) - dc[i] -= 360; - if (dc[i] > 180) - dc[i] -= 360; - } - a = (dc[1] - dc[0]) / dt; - if (a < 1e-10) - break; - dt1 = dc[0] / a; - tjd += dt1; + dc[i] -= 360; + } + if (dc[0] * dc[1] >= 0) /* no transit */ + tret[1] = 0; + else { + tjd = tjds; + dt = 0.1; + dt1 = (tret[3] - tret[2]) / 2.0; + if (dt1 < dt) + dt = dt1 / 2.0; + for (j = 0; dt > 0.01; j++, dt /= 3) { + for (i = 0, t = tjd; i <= 1; i++, t -= dt) { + tt = t + swe_deltat(t); + if (calc_planet_star(tt, ipl, starname, iflag, ls, serr) == + ERR) + return ERR; + if (swe_calc(tt, SE_MOON, iflag, lm, serr) == ERR) + return ERR; + dc[i] = swe_degnorm(ls[0] - lm[0]); + if (dc[i] > 180) + dc[i] -= 360; + if (dc[i] > 180) + dc[i] -= 360; + } + a = (dc[1] - dc[0]) / dt; + if (a < 1e-10) + break; + dt1 = dc[0] / a; + tjd += dt1; + } + tret[1] = tjd; } - tret[1] = tjd; - } end_search_global: - return retflag; - /* - * the time of maximum occultation is practically identical - * with the time of maximum core shadow diameter. - * - * the time, when duration of totality is maximal, - * is not an interesting computation either. Near the maximum - * occulation, the time of totality can be the same by - * a second for hundreds of kilometers (for 10 minutes - * or more). - * - * for annular eclipses the maximum duration is close to the - * beginning and the end of the center lines, where is also - * the minimum of core shadow diameter. - */ + return retflag; + /* + * the time of maximum occultation is practically identical + * with the time of maximum core shadow diameter. + * + * the time, when duration of totality is maximal, + * is not an interesting computation either. Near the maximum + * occulation, the time of totality can be the same by + * a second for hundreds of kilometers (for 10 minutes + * or more). + * + * for annular eclipses the maximum duration is close to the + * beginning and the end of the center lines, where is also + * the minimum of core shadow diameter. + */ } /* When is the next solar eclipse at a given geographical position? @@ -1879,22 +1949,28 @@ end_search_global: * attr[10] saros series member number * declare as attr[20] at least ! */ -int32 FAR PASCAL_CONV swe_sol_eclipse_when_loc(double tjd_start, int32 ifl, - double *geopos, double *tret, double *attr, int32 backward, char *serr) +int32 FAR PASCAL_CONV +swe_sol_eclipse_when_loc(double tjd_start, int32 ifl, double *geopos, + double *tret, double *attr, int32 backward, + char *serr) { - int32 retflag = 0, retflag2 = 0; - double geopos2[20], dcore[10]; - ifl &= SEFLG_EPHMASK; - if ((retflag = eclipse_when_loc(tjd_start, ifl, geopos, tret, attr, backward, serr)) <= 0) + int32 retflag = 0, retflag2 = 0; + double geopos2[20], dcore[10]; + ifl &= SEFLG_EPHMASK; + if ((retflag = + eclipse_when_loc(tjd_start, ifl, geopos, tret, attr, backward, + serr)) <= 0) + return retflag; + /* + * diameter of core shadow + */ + if ((retflag2 = + eclipse_where(tret[0], SE_SUN, NULL, ifl, geopos2, dcore, + serr)) == ERR) + return retflag2; + retflag |= (retflag2 & SE_ECL_NONCENTRAL); + attr[3] = dcore[0]; return retflag; - /* - * diameter of core shadow - */ - if ((retflag2 = eclipse_where(tret[0], SE_SUN, NULL, ifl, geopos2, dcore, serr)) == ERR) - return retflag2; - retflag |= (retflag2 & SE_ECL_NONCENTRAL); - attr[3] = dcore[0]; - return retflag; } /* Same declaration as swe_sol_eclipse_when_loc(). @@ -1911,616 +1987,671 @@ int32 FAR PASCAL_CONV swe_sol_eclipse_when_loc(double tjd_start, int32 ifl, * the function may search unsuccessfully until it reaches * the end of the ephemeris. */ -int32 FAR PASCAL_CONV swe_lun_occult_when_loc(double tjd_start, int32 ipl, char *starname, int32 ifl, - double *geopos, double *tret, double *attr, int32 backward, char *serr) +int32 FAR PASCAL_CONV +swe_lun_occult_when_loc(double tjd_start, int32 ipl, char *starname, + int32 ifl, double *geopos, double *tret, double *attr, + int32 backward, char *serr) { - int32 retflag = 0, retflag2 = 0; - double geopos2[20], dcore[10]; - /* function calls for Pluto with asteroid number 134340 - * are treated as calls for Pluto as main body SE_PLUTO */ - if (ipl == SE_AST_OFFSET + 134340) - ipl = SE_PLUTO; - ifl &= SEFLG_EPHMASK; - if ((retflag = occult_when_loc(tjd_start, ipl, starname, ifl, geopos, tret, attr, backward, serr)) <= 0) + int32 retflag = 0, retflag2 = 0; + double geopos2[20], dcore[10]; + /* function calls for Pluto with asteroid number 134340 + * are treated as calls for Pluto as main body SE_PLUTO */ + if (ipl == SE_AST_OFFSET + 134340) + ipl = SE_PLUTO; + ifl &= SEFLG_EPHMASK; + if ((retflag = + occult_when_loc(tjd_start, ipl, starname, ifl, geopos, tret, attr, + backward, serr)) <= 0) + return retflag; + /* + * diameter of core shadow + */ + if ((retflag2 = + eclipse_where(tret[0], ipl, starname, ifl, geopos2, dcore, + serr)) == ERR) + return retflag2; + retflag |= (retflag2 & SE_ECL_NONCENTRAL); + attr[3] = dcore[0]; return retflag; - /* - * diameter of core shadow - */ - if ((retflag2 = eclipse_where(tret[0], ipl, starname, ifl, geopos2, dcore, serr)) == ERR) - return retflag2; - retflag |= (retflag2 & SE_ECL_NONCENTRAL); - attr[3] = dcore[0]; - return retflag; } -static int32 eclipse_when_loc(double tjd_start, int32 ifl, double *geopos, double *tret, double *attr, int32 backward, char *serr) +static int32 +eclipse_when_loc(double tjd_start, int32 ifl, double *geopos, double *tret, + double *attr, int32 backward, char *serr) { - int i, j, k, m; - int32 retflag = 0, retc; - double t, tjd, dt, dtint, K, T, T2, T3, T4, F, M, Mm; - double tjdr, tjds; - double E, Ff, A1, Om; - double xs[6], xm[6], ls[6], lm[6], x1[6], x2[6], dm, ds; - double rmoon, rsun, rsplusrm, rsminusrm; - double dc[3], dctr, dctrmin; - double twomin = 2.0 / 24.0 / 60.0; - double tensec = 10.0 / 24.0 / 60.0 / 60.0; - double twohr = 2.0 / 24.0; - double tenmin = 10.0 / 24.0 / 60.0; - double dt1, dt2, dtdiv, dtstart; - int32 iflag = SEFLG_EQUATORIAL | SEFLG_TOPOCTR | ifl; - int32 iflagcart = iflag | SEFLG_XYZ; - swe_set_topo(geopos[0], geopos[1], geopos[2]); - K = (int) ((tjd_start - J2000) / 365.2425 * 12.3685); - if (backward) - K++; - else - K--; + int i, j, k, m; + int32 retflag = 0, retc; + double t, tjd, dt, dtint, K, T, T2, T3, T4, F, M, Mm; + double tjdr, tjds; + double E, Ff, A1, Om; + double xs[6], xm[6], ls[6], lm[6], x1[6], x2[6], dm, ds; + double rmoon, rsun, rsplusrm, rsminusrm; + double dc[3], dctr, dctrmin; + double twomin = 2.0 / 24.0 / 60.0; + double tensec = 10.0 / 24.0 / 60.0 / 60.0; + double twohr = 2.0 / 24.0; + double tenmin = 10.0 / 24.0 / 60.0; + double dt1, dt2, dtdiv, dtstart; + int32 iflag = SEFLG_EQUATORIAL | SEFLG_TOPOCTR | ifl; + int32 iflagcart = iflag | SEFLG_XYZ; + swe_set_topo(geopos[0], geopos[1], geopos[2]); + K = (int)((tjd_start - J2000) / 365.2425 * 12.3685); + if (backward) + K++; + else + K--; next_try: - T = K / 1236.85; - T2 = T * T; T3 = T2 * T; T4 = T3 * T; - Ff = F = swe_degnorm(160.7108 + 390.67050274 * K - - 0.0016341 * T2 - - 0.00000227 * T3 - + 0.000000011 * T4); - if (Ff > 180) - Ff -= 180; - if (Ff > 21 && Ff < 159) { /* no eclipse possible */ - if (backward) - K--; - else - K++; - goto next_try; - } - /* approximate time of geocentric maximum eclipse. - * formula from Meeus, German, p. 381 */ - tjd = 2451550.09765 + 29.530588853 * K - + 0.0001337 * T2 - - 0.000000150 * T3 - + 0.00000000073 * T4; - M = swe_degnorm(2.5534 + 29.10535669 * K - - 0.0000218 * T2 - - 0.00000011 * T3); - Mm = swe_degnorm(201.5643 + 385.81693528 * K - + 0.1017438 * T2 - + 0.00001239 * T3 - + 0.000000058 * T4); - Om = swe_degnorm(124.7746 - 1.56375580 * K - + 0.0020691 * T2 - + 0.00000215 * T3); - E = 1 - 0.002516 * T - 0.0000074 * T2; - A1 = swe_degnorm(299.77 + 0.107408 * K - 0.009173 * T2); - M *= DEGTORAD; - Mm *= DEGTORAD; - F *= DEGTORAD; - Om *= DEGTORAD; - A1 *= DEGTORAD; - tjd = tjd - 0.4075 * sin(Mm) - + 0.1721 * E * sin(M); - swe_set_topo(geopos[0], geopos[1], geopos[2]); - dtdiv = 2; - dtstart = 0.5; - if (tjd < 1900000) /* because above formula is not good (delta t?) */ - dtstart = 2; - for (dt = dtstart; - dt > 0.00001; - dt /= dtdiv) { - if (dt < 0.1) - dtdiv = 3; - for (i = 0, t = tjd - dt; i <= 2; i++, t += dt) { - /* this takes some time, but is necessary to avoid - * missing an eclipse */ - if (swe_calc(t, SE_SUN, iflagcart, xs, serr) == ERR) - return ERR; - if (swe_calc(t, SE_SUN, iflag, ls, serr) == ERR) - return ERR; - if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) - return ERR; - if (swe_calc(t, SE_MOON, iflag, lm, serr) == ERR) - return ERR; - dm = sqrt(square_sum(xm)); - ds = sqrt(square_sum(xs)); - for (k = 0; k < 3; k++) { - x1[k] = xs[k] / ds /*ls[2]*/; - x2[k] = xm[k] / dm /*lm[2]*/; - } - dc[i] = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; + T = K / 1236.85; + T2 = T * T; + T3 = T2 * T; + T4 = T3 * T; + Ff = F = + swe_degnorm(160.7108 + 390.67050274 * K - 0.0016341 * T2 - + 0.00000227 * T3 + 0.000000011 * T4); + if (Ff > 180) + Ff -= 180; + if (Ff > 21 && Ff < 159) { /* no eclipse possible */ + if (backward) + K--; + else + K++; + goto next_try; } - find_maximum(dc[0], dc[1], dc[2], dt, &dtint, &dctr); - tjd += dtint + dt; - } - if (swe_calc(tjd, SE_SUN, iflagcart, xs, serr) == ERR) - return ERR; - if (swe_calc(tjd, SE_SUN, iflag, ls, serr) == ERR) - return ERR; - if (swe_calc(tjd, SE_MOON, iflagcart, xm, serr) == ERR) - return ERR; - if (swe_calc(tjd, SE_MOON, iflag, lm, serr) == ERR) - return ERR; - dctr = acos(swi_dot_prod_unit(xs, xm)) * RADTODEG; - rmoon = asin(RMOON / lm[2]) * RADTODEG; - rsun = asin(RSUN / ls[2]) * RADTODEG; - rsplusrm = rsun + rmoon; - rsminusrm = rsun - rmoon; - if (dctr > rsplusrm) { - if (backward) - K--; - else - K++; - goto next_try; - } - tret[0] = tjd - swe_deltat(tjd); - if ((backward && tret[0] >= tjd_start - 0.0001) - || (!backward && tret[0] <= tjd_start + 0.0001)) { - if (backward) - K--; - else - K++; - goto next_try; - } - if (dctr < rsminusrm) - retflag = SE_ECL_ANNULAR; - else if (dctr < fabs(rsminusrm)) - retflag = SE_ECL_TOTAL; - else if (dctr <= rsplusrm) - retflag = SE_ECL_PARTIAL; - dctrmin = dctr; - /* contacts 2 and 3 */ - if (dctr > fabs(rsminusrm)) /* partial, no 2nd and 3rd contact */ - tret[2] = tret[3] = 0; - else { - dc[1] = fabs(rsminusrm) - dctrmin; - for (i = 0, t = tjd - twomin; i <= 2; i += 2, t = tjd + twomin) { - if (swe_calc(t, SE_SUN, iflagcart, xs, serr) == ERR) - return ERR; - if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) - return ERR; - dm = sqrt(square_sum(xm)); - ds = sqrt(square_sum(xs)); - rmoon = asin(RMOON / dm) * RADTODEG; - rmoon *= 0.99916; /* gives better accuracy for 2nd/3rd contacts */ - rsun = asin(RSUN / ds) * RADTODEG; - rsminusrm = rsun - rmoon; - for (k = 0; k < 3; k++) { - x1[k] = xs[k] / ds /*ls[2]*/; - x2[k] = xm[k] / dm /*lm[2]*/; - } - dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; - dc[i] = fabs(rsminusrm) - dctr; - } - find_zero(dc[0], dc[1], dc[2], twomin, &dt1, &dt2); - tret[2] = tjd + dt1 + twomin; - tret[3] = tjd + dt2 + twomin; - for (m = 0, dt = tensec; m < 2; m++, dt /= 10) { - for (j = 2; j <= 3; j++) { - if (swe_calc(tret[j], SE_SUN, iflagcart | SEFLG_SPEED, xs, serr) == ERR) - return ERR; - if (swe_calc(tret[j], SE_MOON, iflagcart | SEFLG_SPEED, xm, serr) == ERR) - return ERR; - for (i = 0; i < 2; i++) { - if (i == 1) { - for(k = 0; k < 3; k++) { - xs[k] -= xs[k+3] * dt; - xm[k] -= xm[k+3] * dt; + /* approximate time of geocentric maximum eclipse. + * formula from Meeus, German, p. 381 */ + tjd = + 2451550.09765 + 29.530588853 * K + 0.0001337 * T2 - 0.000000150 * T3 + + 0.00000000073 * T4; + M = swe_degnorm(2.5534 + 29.10535669 * K - 0.0000218 * T2 - + 0.00000011 * T3); + Mm = swe_degnorm(201.5643 + 385.81693528 * K + 0.1017438 * T2 + + 0.00001239 * T3 + 0.000000058 * T4); + Om = swe_degnorm(124.7746 - 1.56375580 * K + 0.0020691 * T2 + + 0.00000215 * T3); + E = 1 - 0.002516 * T - 0.0000074 * T2; + A1 = swe_degnorm(299.77 + 0.107408 * K - 0.009173 * T2); + M *= DEGTORAD; + Mm *= DEGTORAD; + F *= DEGTORAD; + Om *= DEGTORAD; + A1 *= DEGTORAD; + tjd = tjd - 0.4075 * sin(Mm) + + 0.1721 * E * sin(M); + swe_set_topo(geopos[0], geopos[1], geopos[2]); + dtdiv = 2; + dtstart = 0.5; + if (tjd < 1900000) /* because above formula is not good (delta t?) */ + dtstart = 2; + for (dt = dtstart; dt > 0.00001; dt /= dtdiv) { + if (dt < 0.1) + dtdiv = 3; + for (i = 0, t = tjd - dt; i <= 2; i++, t += dt) { + /* this takes some time, but is necessary to avoid + * missing an eclipse */ + if (swe_calc(t, SE_SUN, iflagcart, xs, serr) == ERR) + return ERR; + if (swe_calc(t, SE_SUN, iflag, ls, serr) == ERR) + return ERR; + if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) + return ERR; + if (swe_calc(t, SE_MOON, iflag, lm, serr) == ERR) + return ERR; + dm = sqrt(square_sum(xm)); + ds = sqrt(square_sum(xs)); + for (k = 0; k < 3; k++) { + x1[k] = xs[k] / ds /*ls[2] */ ; + x2[k] = xm[k] / dm /*lm[2] */ ; } - } - dm = sqrt(square_sum(xm)); - ds = sqrt(square_sum(xs)); - rmoon = asin(RMOON / dm) * RADTODEG; - rmoon *= 0.99916; /* gives better accuracy for 2nd/3rd contacts */ - rsun = asin(RSUN / ds) * RADTODEG; - rsminusrm = rsun - rmoon; - for (k = 0; k < 3; k++) { - x1[k] = xs[k] / ds /*ls[2]*/; - x2[k] = xm[k] / dm /*lm[2]*/; - } - dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; - dc[i] = fabs(rsminusrm) - dctr; + dc[i] = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; } - dt1 = -dc[0] / ((dc[0] - dc[1]) / dt); - tret[j] += dt1; - } + find_maximum(dc[0], dc[1], dc[2], dt, &dtint, &dctr); + tjd += dtint + dt; } - tret[2] -= swe_deltat(tret[2]); - tret[3] -= swe_deltat(tret[3]); - } - /* contacts 1 and 4 */ - dc[1] = rsplusrm - dctrmin; - for (i = 0, t = tjd - twohr; i <= 2; i += 2, t = tjd + twohr) { - if (swe_calc(t, SE_SUN, iflagcart, xs, serr) == ERR) - return ERR; - if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) - return ERR; - dm = sqrt(square_sum(xm)); - ds = sqrt(square_sum(xs)); - rmoon = asin(RMOON / dm) * RADTODEG; - rsun = asin(RSUN / ds) * RADTODEG; + if (swe_calc(tjd, SE_SUN, iflagcart, xs, serr) == ERR) + return ERR; + if (swe_calc(tjd, SE_SUN, iflag, ls, serr) == ERR) + return ERR; + if (swe_calc(tjd, SE_MOON, iflagcart, xm, serr) == ERR) + return ERR; + if (swe_calc(tjd, SE_MOON, iflag, lm, serr) == ERR) + return ERR; + dctr = acos(swi_dot_prod_unit(xs, xm)) * RADTODEG; + rmoon = asin(RMOON / lm[2]) * RADTODEG; + rsun = asin(RSUN / ls[2]) * RADTODEG; rsplusrm = rsun + rmoon; - for (k = 0; k < 3; k++) { - x1[k] = xs[k] / ds /*ls[2]*/; - x2[k] = xm[k] / dm /*lm[2]*/; + rsminusrm = rsun - rmoon; + if (dctr > rsplusrm) { + if (backward) + K--; + else + K++; + goto next_try; } - dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; - dc[i] = rsplusrm - dctr; - } - find_zero(dc[0], dc[1], dc[2], twohr, &dt1, &dt2); - tret[1] = tjd + dt1 + twohr; - tret[4] = tjd + dt2 + twohr; - for (m = 0, dt = tenmin; m < 3; m++, dt /= 10) { - for (j = 1; j <= 4; j += 3) { - if (swe_calc(tret[j], SE_SUN, iflagcart | SEFLG_SPEED, xs, serr) == ERR) - return ERR; - if (swe_calc(tret[j], SE_MOON, iflagcart | SEFLG_SPEED, xm, serr) == ERR) - return ERR; - for (i = 0; i < 2; i++) { - if (i == 1) { - for(k = 0; k < 3; k++) { - xs[k] -= xs[k+3] * dt; - xm[k] -= xm[k+3] * dt; - } + tret[0] = tjd - swe_deltat(tjd); + if ((backward && tret[0] >= tjd_start - 0.0001) + || (!backward && tret[0] <= tjd_start + 0.0001)) { + if (backward) + K--; + else + K++; + goto next_try; + } + if (dctr < rsminusrm) + retflag = SE_ECL_ANNULAR; + else if (dctr < fabs(rsminusrm)) + retflag = SE_ECL_TOTAL; + else if (dctr <= rsplusrm) + retflag = SE_ECL_PARTIAL; + dctrmin = dctr; + /* contacts 2 and 3 */ + if (dctr > fabs(rsminusrm)) /* partial, no 2nd and 3rd contact */ + tret[2] = tret[3] = 0; + else { + dc[1] = fabs(rsminusrm) - dctrmin; + for (i = 0, t = tjd - twomin; i <= 2; i += 2, t = tjd + twomin) { + if (swe_calc(t, SE_SUN, iflagcart, xs, serr) == ERR) + return ERR; + if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) + return ERR; + dm = sqrt(square_sum(xm)); + ds = sqrt(square_sum(xs)); + rmoon = asin(RMOON / dm) * RADTODEG; + rmoon *= 0.99916; /* gives better accuracy for 2nd/3rd contacts */ + rsun = asin(RSUN / ds) * RADTODEG; + rsminusrm = rsun - rmoon; + for (k = 0; k < 3; k++) { + x1[k] = xs[k] / ds /*ls[2] */ ; + x2[k] = xm[k] / dm /*lm[2] */ ; + } + dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; + dc[i] = fabs(rsminusrm) - dctr; } + find_zero(dc[0], dc[1], dc[2], twomin, &dt1, &dt2); + tret[2] = tjd + dt1 + twomin; + tret[3] = tjd + dt2 + twomin; + for (m = 0, dt = tensec; m < 2; m++, dt /= 10) { + for (j = 2; j <= 3; j++) { + if (swe_calc + (tret[j], SE_SUN, iflagcart | SEFLG_SPEED, xs, + serr) == ERR) + return ERR; + if (swe_calc + (tret[j], SE_MOON, iflagcart | SEFLG_SPEED, xm, + serr) == ERR) + return ERR; + for (i = 0; i < 2; i++) { + if (i == 1) { + for (k = 0; k < 3; k++) { + xs[k] -= xs[k + 3] * dt; + xm[k] -= xm[k + 3] * dt; + } + } + dm = sqrt(square_sum(xm)); + ds = sqrt(square_sum(xs)); + rmoon = asin(RMOON / dm) * RADTODEG; + rmoon *= 0.99916; /* gives better accuracy for 2nd/3rd contacts */ + rsun = asin(RSUN / ds) * RADTODEG; + rsminusrm = rsun - rmoon; + for (k = 0; k < 3; k++) { + x1[k] = xs[k] / ds /*ls[2] */ ; + x2[k] = xm[k] / dm /*lm[2] */ ; + } + dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; + dc[i] = fabs(rsminusrm) - dctr; + } + dt1 = -dc[0] / ((dc[0] - dc[1]) / dt); + tret[j] += dt1; + } + } + tret[2] -= swe_deltat(tret[2]); + tret[3] -= swe_deltat(tret[3]); + } + /* contacts 1 and 4 */ + dc[1] = rsplusrm - dctrmin; + for (i = 0, t = tjd - twohr; i <= 2; i += 2, t = tjd + twohr) { + if (swe_calc(t, SE_SUN, iflagcart, xs, serr) == ERR) + return ERR; + if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) + return ERR; dm = sqrt(square_sum(xm)); ds = sqrt(square_sum(xs)); rmoon = asin(RMOON / dm) * RADTODEG; rsun = asin(RSUN / ds) * RADTODEG; rsplusrm = rsun + rmoon; for (k = 0; k < 3; k++) { - x1[k] = xs[k] / ds /*ls[2]*/; - x2[k] = xm[k] / dm /*lm[2]*/; + x1[k] = xs[k] / ds /*ls[2] */ ; + x2[k] = xm[k] / dm /*lm[2] */ ; } dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; - dc[i] = fabs(rsplusrm) - dctr; - } - dt1 = -dc[0] / ((dc[0] - dc[1]) / dt); - tret[j] += dt1; + dc[i] = rsplusrm - dctr; } - } - tret[1] -= swe_deltat(tret[1]); - tret[4] -= swe_deltat(tret[4]); - /* - * visibility of eclipse phases - */ - for (i = 4; i >= 0; i--) { /* attr for i = 0 must be kept !!! */ - if (tret[i] == 0) - continue; - if (eclipse_how(tret[i], SE_SUN, NULL, ifl, geopos[0], geopos[1], geopos[2], - attr, serr) == ERR) - return ERR; - /*if (retflag2 & SE_ECL_VISIBLE) { could be wrong for 1st/4th contact */ - if (attr[6] > 0) { /* this is save, sun above horizon, using app. alt. */ - retflag |= SE_ECL_VISIBLE; - switch(i) { - case 0: retflag |= SE_ECL_MAX_VISIBLE; break; - case 1: retflag |= SE_ECL_1ST_VISIBLE; break; - case 2: retflag |= SE_ECL_2ND_VISIBLE; break; - case 3: retflag |= SE_ECL_3RD_VISIBLE; break; - case 4: retflag |= SE_ECL_4TH_VISIBLE; break; - default: break; - } + find_zero(dc[0], dc[1], dc[2], twohr, &dt1, &dt2); + tret[1] = tjd + dt1 + twohr; + tret[4] = tjd + dt2 + twohr; + for (m = 0, dt = tenmin; m < 3; m++, dt /= 10) { + for (j = 1; j <= 4; j += 3) { + if (swe_calc(tret[j], SE_SUN, iflagcart | SEFLG_SPEED, xs, serr) + == ERR) + return ERR; + if (swe_calc(tret[j], SE_MOON, iflagcart | SEFLG_SPEED, xm, serr) + == ERR) + return ERR; + for (i = 0; i < 2; i++) { + if (i == 1) { + for (k = 0; k < 3; k++) { + xs[k] -= xs[k + 3] * dt; + xm[k] -= xm[k + 3] * dt; + } + } + dm = sqrt(square_sum(xm)); + ds = sqrt(square_sum(xs)); + rmoon = asin(RMOON / dm) * RADTODEG; + rsun = asin(RSUN / ds) * RADTODEG; + rsplusrm = rsun + rmoon; + for (k = 0; k < 3; k++) { + x1[k] = xs[k] / ds /*ls[2] */ ; + x2[k] = xm[k] / dm /*lm[2] */ ; + } + dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; + dc[i] = fabs(rsplusrm) - dctr; + } + dt1 = -dc[0] / ((dc[0] - dc[1]) / dt); + tret[j] += dt1; + } + } + tret[1] -= swe_deltat(tret[1]); + tret[4] -= swe_deltat(tret[4]); + /* + * visibility of eclipse phases + */ + for (i = 4; i >= 0; i--) { /* attr for i = 0 must be kept !!! */ + if (tret[i] == 0) + continue; + if (eclipse_how + (tret[i], SE_SUN, NULL, ifl, geopos[0], geopos[1], geopos[2], + attr, serr) == ERR) + return ERR; + /*if (retflag2 & SE_ECL_VISIBLE) { could be wrong for 1st/4th contact */ + if (attr[6] > 0) { /* this is save, sun above horizon, using app. alt. */ + retflag |= SE_ECL_VISIBLE; + switch (i) { + case 0: + retflag |= SE_ECL_MAX_VISIBLE; + break; + case 1: + retflag |= SE_ECL_1ST_VISIBLE; + break; + case 2: + retflag |= SE_ECL_2ND_VISIBLE; + break; + case 3: + retflag |= SE_ECL_3RD_VISIBLE; + break; + case 4: + retflag |= SE_ECL_4TH_VISIBLE; + break; + default: + break; + } + } } - } #if 1 - if (!(retflag & SE_ECL_VISIBLE)) { - if (backward) - K--; - else - K++; - goto next_try; - } + if (!(retflag & SE_ECL_VISIBLE)) { + if (backward) + K--; + else + K++; + goto next_try; + } #endif - if (swe_rise_trans(tret[1] - 0.1, SE_SUN, NULL, iflag, SE_CALC_RISE|SE_BIT_DISC_BOTTOM, geopos, 0, 0, &tjdr, serr) == ERR) - return ERR; - if (swe_rise_trans(tret[1] - 0.1, SE_SUN, NULL, iflag, SE_CALC_SET|SE_BIT_DISC_BOTTOM, geopos, 0, 0, &tjds, serr) == ERR) - return ERR; - if (tjdr > tret[1] && tjdr < tret[4]) { - tret[5] = tjdr; - if (!(retflag & SE_ECL_MAX_VISIBLE)) { - tret[0] = tjdr; - if ((retc = eclipse_how(tret[5], SE_SUN, NULL, ifl, geopos[0], geopos[1], geopos[2], attr, serr)) == ERR) - return ERR; - retflag &= ~(SE_ECL_TOTAL|SE_ECL_ANNULAR|SE_ECL_PARTIAL); - retflag |= (retc & (SE_ECL_TOTAL|SE_ECL_ANNULAR|SE_ECL_PARTIAL)); + if (swe_rise_trans + (tret[1] - 0.1, SE_SUN, NULL, iflag, + SE_CALC_RISE | SE_BIT_DISC_BOTTOM, geopos, 0, 0, &tjdr, serr) == ERR) + return ERR; + if (swe_rise_trans + (tret[1] - 0.1, SE_SUN, NULL, iflag, SE_CALC_SET | SE_BIT_DISC_BOTTOM, + geopos, 0, 0, &tjds, serr) == ERR) + return ERR; + if (tjdr > tret[1] && tjdr < tret[4]) { + tret[5] = tjdr; + if (!(retflag & SE_ECL_MAX_VISIBLE)) { + tret[0] = tjdr; + if ((retc = + eclipse_how(tret[5], SE_SUN, NULL, ifl, geopos[0], geopos[1], + geopos[2], attr, serr)) == ERR) + return ERR; + retflag &= ~(SE_ECL_TOTAL | SE_ECL_ANNULAR | SE_ECL_PARTIAL); + retflag |= + (retc & (SE_ECL_TOTAL | SE_ECL_ANNULAR | SE_ECL_PARTIAL)); + } } - } - if (tjds > tret[1] && tjds < tret[4]) { - tret[6] = tjds; - if (!(retflag & SE_ECL_MAX_VISIBLE)) { - tret[0] = tjds; - if ((retc = eclipse_how(tret[6], SE_SUN, NULL, ifl, geopos[0], geopos[1], geopos[2], attr, serr)) == ERR) - return ERR; - retflag &= ~(SE_ECL_TOTAL|SE_ECL_ANNULAR|SE_ECL_PARTIAL); - retflag |= (retc & (SE_ECL_TOTAL|SE_ECL_ANNULAR|SE_ECL_PARTIAL)); + if (tjds > tret[1] && tjds < tret[4]) { + tret[6] = tjds; + if (!(retflag & SE_ECL_MAX_VISIBLE)) { + tret[0] = tjds; + if ((retc = + eclipse_how(tret[6], SE_SUN, NULL, ifl, geopos[0], geopos[1], + geopos[2], attr, serr)) == ERR) + return ERR; + retflag &= ~(SE_ECL_TOTAL | SE_ECL_ANNULAR | SE_ECL_PARTIAL); + retflag |= + (retc & (SE_ECL_TOTAL | SE_ECL_ANNULAR | SE_ECL_PARTIAL)); + } } - } - return retflag; + return retflag; } -static int32 occult_when_loc( - double tjd_start, int32 ipl, char *starname, - int32 ifl, double *geopos, double *tret, double *attr, - int32 backward, char *serr) +static int32 +occult_when_loc(double tjd_start, int32 ipl, char *starname, int32 ifl, + double *geopos, double *tret, double *attr, int32 backward, + char *serr) { - int i, j, k, m; - int32 retflag = 0; - double t, tjd, dt, dtint; - double tjdr, tjds; - double xs[6], xm[6], ls[6], lm[6], x1[6], x2[6], dm, ds; - double rmoon, rsun, rsplusrm, rsminusrm; - double dc[20], dctr, dctrmin; - double twomin = 2.0 / 24.0 / 60.0; - double tensec = 10.0 / 24.0 / 60.0 / 60.0; - double twohr = 2.0 / 24.0; - double tenmin = 10.0 / 24.0 / 60.0; - double dt1, dt2, dtdiv, dtstart; - double dadd2 = 6; - int nstartpos = 10; - double drad; - int32 iflag = SEFLG_TOPOCTR | ifl; - int32 iflaggeo = iflag & ~SEFLG_TOPOCTR; - int32 iflagcart = iflag | SEFLG_XYZ; - int32 iflagcartgeo = iflaggeo | SEFLG_XYZ; - int direction = 1; - int32 one_try = backward & SE_ECL_ONE_TRY; - AS_BOOL stop_after_this = FALSE; - backward &= 1L; - retflag = 0; - swe_set_topo(geopos[0], geopos[1], geopos[2]); - for (i = 0; i <= 9; i++) - tret[i] = 0; - if (backward) - direction = -1; - t = tjd_start - direction * 0.1; - tjd = tjd_start; + int i, j, k, m; + int32 retflag = 0; + double t, tjd, dt, dtint; + double tjdr, tjds; + double xs[6], xm[6], ls[6], lm[6], x1[6], x2[6], dm, ds; + double rmoon, rsun, rsplusrm, rsminusrm; + double dc[20], dctr, dctrmin; + double twomin = 2.0 / 24.0 / 60.0; + double tensec = 10.0 / 24.0 / 60.0 / 60.0; + double twohr = 2.0 / 24.0; + double tenmin = 10.0 / 24.0 / 60.0; + double dt1, dt2, dtdiv, dtstart; + double dadd2 = 6; + int nstartpos = 10; + double drad; + int32 iflag = SEFLG_TOPOCTR | ifl; + int32 iflaggeo = iflag & ~SEFLG_TOPOCTR; + int32 iflagcart = iflag | SEFLG_XYZ; + int32 iflagcartgeo = iflaggeo | SEFLG_XYZ; + int direction = 1; + int32 one_try = backward & SE_ECL_ONE_TRY; + AS_BOOL stop_after_this = FALSE; + backward &= 1L; + retflag = 0; + swe_set_topo(geopos[0], geopos[1], geopos[2]); + for (i = 0; i <= 9; i++) + tret[i] = 0; + if (backward) + direction = -1; + t = tjd_start - direction * 0.1; + tjd = tjd_start; next_try: - for (i = 0; i < nstartpos; i++, t += direction * dadd2) { - if (calc_planet_star(t, ipl, starname, iflagcartgeo, xs, serr) == ERR) - return ERR; - if (swe_calc(t, SE_MOON, iflagcartgeo, xm, serr) == ERR) - return ERR; - dc[i] = acos(swi_dot_prod_unit(xs, xm)) * RADTODEG; - if (i > 1 && dc[i] > dc[i-1] && dc[i-2] > dc[i-1]) { - tjd = t - direction*dadd2; - break; - } else if (i == nstartpos-1) { - for (j = 0; j < nstartpos; j++) - printf("%f ", dc[j]); - printf("swe_lun_occult_when_loc(): problem planet\n"); - return ERR; - } - } - /* - * radius of planet disk in AU - */ - if (starname != NULL && *starname != '\0') - drad = 0; - else if (ipl < NDIAM) - drad = pla_diam[ipl] / 2 / AUNIT; - else if (ipl > SE_AST_OFFSET) - drad = swed.ast_diam / 2 * 1000 / AUNIT; /* km -> m -> AU */ - else - drad = 0; - /* now find out, if there is an occultation at our geogr. location */ - dtdiv = 3; - dtstart = dadd2; /* formerly 0.2 */ - for (dt = dtstart; - dt > 0.00001; - dt /= dtdiv) { - if (dt < 0.01) - dtdiv = 3; - for (i = 0, t = tjd - dt; i <= 2; i++, t += dt) { - /* this takes some time, but is necessary to avoid - * missing an eclipse */ - if (calc_planet_star(t, ipl, starname, iflagcart, xs, serr) == ERR) - return ERR; - if (calc_planet_star(t, ipl, starname, iflag, ls, serr) == ERR) - return ERR; - if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) - return ERR; - if (swe_calc(t, SE_MOON, iflag, lm, serr) == ERR) - return ERR; - if (dt < 1 && fabs(ls[1] - lm[1]) > 2) { - if (one_try) { - stop_after_this = TRUE; - } else { - t = tjd + direction * 2; - goto next_try; + for (i = 0; i < nstartpos; i++, t += direction * dadd2) { + if (calc_planet_star(t, ipl, starname, iflagcartgeo, xs, serr) == ERR) + return ERR; + if (swe_calc(t, SE_MOON, iflagcartgeo, xm, serr) == ERR) + return ERR; + dc[i] = acos(swi_dot_prod_unit(xs, xm)) * RADTODEG; + if (i > 1 && dc[i] > dc[i - 1] && dc[i - 2] > dc[i - 1]) { + tjd = t - direction * dadd2; + break; + } + else if (i == nstartpos - 1) { + for (j = 0; j < nstartpos; j++) + printf("%f ", dc[j]); + printf("swe_lun_occult_when_loc(): problem planet\n"); + return ERR; } - } - dc[i] = acos(swi_dot_prod_unit(xs, xm)) * RADTODEG; - rmoon = asin(RMOON / lm[2]) * RADTODEG; - rsun = asin(drad / ls[2]) * RADTODEG; - dc[i] -= (rmoon + rsun); } - find_maximum(dc[0], dc[1], dc[2], dt, &dtint, &dctr); - tjd += dtint + dt; - } - if (stop_after_this) { /* has one_try = TRUE */ - tret[0] = tjd; - return 0; - } - if (calc_planet_star(tjd, ipl, starname, iflagcart, xs, serr) == ERR) - return ERR; - if (calc_planet_star(tjd, ipl, starname, iflag, ls, serr) == ERR) - return ERR; - if (swe_calc(tjd, SE_MOON, iflagcart, xm, serr) == ERR) - return ERR; - if (swe_calc(tjd, SE_MOON, iflag, lm, serr) == ERR) - return ERR; - dctr = acos(swi_dot_prod_unit(xs, xm)) * RADTODEG; - rmoon = asin(RMOON / lm[2]) * RADTODEG; - rsun = asin(drad / ls[2]) * RADTODEG; - rsplusrm = rsun + rmoon; - rsminusrm = rsun - rmoon; - if (dctr > rsplusrm) { - if (one_try) { - tret[0] = tjd; - return 0; - } - t = tjd + direction; - goto next_try; - } - tret[0] = tjd - swe_deltat(tjd); - if ((backward && tret[0] >= tjd_start - 0.0001) - || (!backward && tret[0] <= tjd_start + 0.0001)) { - t = tjd + direction; - goto next_try; - } - if (dctr < rsminusrm) - retflag = SE_ECL_ANNULAR; - else if (dctr < fabs(rsminusrm)) - retflag = SE_ECL_TOTAL; - else if (dctr <= rsplusrm) - retflag = SE_ECL_PARTIAL; - dctrmin = dctr; - /* contacts 2 and 3 */ - if (dctr > fabs(rsminusrm)) /* partial, no 2nd and 3rd contact */ - tret[2] = tret[3] = 0; - else { - dc[1] = fabs(rsminusrm) - dctrmin; - for (i = 0, t = tjd - twomin; i <= 2; i += 2, t = tjd + twomin) { - if (calc_planet_star(t, ipl, starname, iflagcart, xs, serr) == ERR) - return ERR; - if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) - return ERR; - dm = sqrt(square_sum(xm)); - ds = sqrt(square_sum(xs)); - rmoon = asin(RMOON / dm) * RADTODEG; - rmoon *= 0.99916; /* gives better accuracy for 2nd/3rd contacts */ - rsun = asin(drad / ds) * RADTODEG; - rsminusrm = rsun - rmoon; - for (k = 0; k < 3; k++) { - x1[k] = xs[k] / ds /*ls[2]*/; - x2[k] = xm[k] / dm /*lm[2]*/; - } - dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; - dc[i] = fabs(rsminusrm) - dctr; - } - find_zero(dc[0], dc[1], dc[2], twomin, &dt1, &dt2); - tret[2] = tjd + dt1 + twomin; - tret[3] = tjd + dt2 + twomin; - for (m = 0, dt = tensec; m < 2; m++, dt /= 10) { - for (j = 2; j <= 3; j++) { - if (calc_planet_star(tret[j], ipl, starname, iflagcart | SEFLG_SPEED, xs, serr) == ERR) - return ERR; - if (swe_calc(tret[j], SE_MOON, iflagcart | SEFLG_SPEED, xm, serr) == ERR) - return ERR; - for (i = 0; i < 2; i++) { - if (i == 1) { - for(k = 0; k < 3; k++) { - xs[k] -= xs[k+3] * dt; - xm[k] -= xm[k+3] * dt; + /* + * radius of planet disk in AU + */ + if (starname != NULL && *starname != '\0') + drad = 0; + else if (ipl < NDIAM) + drad = pla_diam[ipl] / 2 / AUNIT; + else if (ipl > SE_AST_OFFSET) + drad = swed.ast_diam / 2 * 1000 / AUNIT; /* km -> m -> AU */ + else + drad = 0; + /* now find out, if there is an occultation at our geogr. location */ + dtdiv = 3; + dtstart = dadd2; /* formerly 0.2 */ + for (dt = dtstart; dt > 0.00001; dt /= dtdiv) { + if (dt < 0.01) + dtdiv = 3; + for (i = 0, t = tjd - dt; i <= 2; i++, t += dt) { + /* this takes some time, but is necessary to avoid + * missing an eclipse */ + if (calc_planet_star(t, ipl, starname, iflagcart, xs, serr) == + ERR) + return ERR; + if (calc_planet_star(t, ipl, starname, iflag, ls, serr) == ERR) + return ERR; + if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) + return ERR; + if (swe_calc(t, SE_MOON, iflag, lm, serr) == ERR) + return ERR; + if (dt < 1 && fabs(ls[1] - lm[1]) > 2) { + if (one_try) { + stop_after_this = TRUE; + } + else { + t = tjd + direction * 2; + goto next_try; + } } - } - dm = sqrt(square_sum(xm)); - ds = sqrt(square_sum(xs)); - rmoon = asin(RMOON / dm) * RADTODEG; - rmoon *= 0.99916; /* gives better accuracy for 2nd/3rd contacts */ - rsun = asin(drad / ds) * RADTODEG; - rsminusrm = rsun - rmoon; - for (k = 0; k < 3; k++) { - x1[k] = xs[k] / ds /*ls[2]*/; - x2[k] = xm[k] / dm /*lm[2]*/; - } - dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; - dc[i] = fabs(rsminusrm) - dctr; + dc[i] = acos(swi_dot_prod_unit(xs, xm)) * RADTODEG; + rmoon = asin(RMOON / lm[2]) * RADTODEG; + rsun = asin(drad / ls[2]) * RADTODEG; + dc[i] -= (rmoon + rsun); } - dt1 = -dc[0] / ((dc[0] - dc[1]) / dt); - tret[j] += dt1; - } + find_maximum(dc[0], dc[1], dc[2], dt, &dtint, &dctr); + tjd += dtint + dt; } - tret[2] -= swe_deltat(tret[2]); - tret[3] -= swe_deltat(tret[3]); - } - /* contacts 1 and 4 */ - dc[1] = rsplusrm - dctrmin; - for (i = 0, t = tjd - twohr; i <= 2; i += 2, t = tjd + twohr) { - if (calc_planet_star(t, ipl, starname, iflagcart, xs, serr) == ERR) - return ERR; - if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) - return ERR; - dm = sqrt(square_sum(xm)); - ds = sqrt(square_sum(xs)); - rmoon = asin(RMOON / dm) * RADTODEG; - rsun = asin(drad / ds) * RADTODEG; + if (stop_after_this) { /* has one_try = TRUE */ + tret[0] = tjd; + return 0; + } + if (calc_planet_star(tjd, ipl, starname, iflagcart, xs, serr) == ERR) + return ERR; + if (calc_planet_star(tjd, ipl, starname, iflag, ls, serr) == ERR) + return ERR; + if (swe_calc(tjd, SE_MOON, iflagcart, xm, serr) == ERR) + return ERR; + if (swe_calc(tjd, SE_MOON, iflag, lm, serr) == ERR) + return ERR; + dctr = acos(swi_dot_prod_unit(xs, xm)) * RADTODEG; + rmoon = asin(RMOON / lm[2]) * RADTODEG; + rsun = asin(drad / ls[2]) * RADTODEG; rsplusrm = rsun + rmoon; - for (k = 0; k < 3; k++) { - x1[k] = xs[k] / ds /*ls[2]*/; - x2[k] = xm[k] / dm /*lm[2]*/; - } - dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; - dc[i] = rsplusrm - dctr; - } - find_zero(dc[0], dc[1], dc[2], twohr, &dt1, &dt2); - tret[1] = tjd + dt1 + twohr; - tret[4] = tjd + dt2 + twohr; - for (m = 0, dt = tenmin; m < 3; m++, dt /= 10) { - for (j = 1; j <= 4; j += 3) { - if (calc_planet_star(tret[j], ipl, starname, iflagcart | SEFLG_SPEED, xs, serr) == ERR) - return ERR; - if (swe_calc(tret[j], SE_MOON, iflagcart | SEFLG_SPEED, xm, serr) == ERR) - return ERR; - for (i = 0; i < 2; i++) { - if (i == 1) { - for(k = 0; k < 3; k++) { - xs[k] -= xs[k+3] * dt; - xm[k] -= xm[k+3] * dt; - } + rsminusrm = rsun - rmoon; + if (dctr > rsplusrm) { + if (one_try) { + tret[0] = tjd; + return 0; } + t = tjd + direction; + goto next_try; + } + tret[0] = tjd - swe_deltat(tjd); + if ((backward && tret[0] >= tjd_start - 0.0001) + || (!backward && tret[0] <= tjd_start + 0.0001)) { + t = tjd + direction; + goto next_try; + } + if (dctr < rsminusrm) + retflag = SE_ECL_ANNULAR; + else if (dctr < fabs(rsminusrm)) + retflag = SE_ECL_TOTAL; + else if (dctr <= rsplusrm) + retflag = SE_ECL_PARTIAL; + dctrmin = dctr; + /* contacts 2 and 3 */ + if (dctr > fabs(rsminusrm)) /* partial, no 2nd and 3rd contact */ + tret[2] = tret[3] = 0; + else { + dc[1] = fabs(rsminusrm) - dctrmin; + for (i = 0, t = tjd - twomin; i <= 2; i += 2, t = tjd + twomin) { + if (calc_planet_star(t, ipl, starname, iflagcart, xs, serr) == + ERR) + return ERR; + if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) + return ERR; + dm = sqrt(square_sum(xm)); + ds = sqrt(square_sum(xs)); + rmoon = asin(RMOON / dm) * RADTODEG; + rmoon *= 0.99916; /* gives better accuracy for 2nd/3rd contacts */ + rsun = asin(drad / ds) * RADTODEG; + rsminusrm = rsun - rmoon; + for (k = 0; k < 3; k++) { + x1[k] = xs[k] / ds /*ls[2] */ ; + x2[k] = xm[k] / dm /*lm[2] */ ; + } + dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; + dc[i] = fabs(rsminusrm) - dctr; + } + find_zero(dc[0], dc[1], dc[2], twomin, &dt1, &dt2); + tret[2] = tjd + dt1 + twomin; + tret[3] = tjd + dt2 + twomin; + for (m = 0, dt = tensec; m < 2; m++, dt /= 10) { + for (j = 2; j <= 3; j++) { + if (calc_planet_star + (tret[j], ipl, starname, iflagcart | SEFLG_SPEED, xs, + serr) == ERR) + return ERR; + if (swe_calc + (tret[j], SE_MOON, iflagcart | SEFLG_SPEED, xm, + serr) == ERR) + return ERR; + for (i = 0; i < 2; i++) { + if (i == 1) { + for (k = 0; k < 3; k++) { + xs[k] -= xs[k + 3] * dt; + xm[k] -= xm[k + 3] * dt; + } + } + dm = sqrt(square_sum(xm)); + ds = sqrt(square_sum(xs)); + rmoon = asin(RMOON / dm) * RADTODEG; + rmoon *= 0.99916; /* gives better accuracy for 2nd/3rd contacts */ + rsun = asin(drad / ds) * RADTODEG; + rsminusrm = rsun - rmoon; + for (k = 0; k < 3; k++) { + x1[k] = xs[k] / ds /*ls[2] */ ; + x2[k] = xm[k] / dm /*lm[2] */ ; + } + dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; + dc[i] = fabs(rsminusrm) - dctr; + } + dt1 = -dc[0] / ((dc[0] - dc[1]) / dt); + tret[j] += dt1; + } + } + tret[2] -= swe_deltat(tret[2]); + tret[3] -= swe_deltat(tret[3]); + } + /* contacts 1 and 4 */ + dc[1] = rsplusrm - dctrmin; + for (i = 0, t = tjd - twohr; i <= 2; i += 2, t = tjd + twohr) { + if (calc_planet_star(t, ipl, starname, iflagcart, xs, serr) == ERR) + return ERR; + if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) + return ERR; dm = sqrt(square_sum(xm)); ds = sqrt(square_sum(xs)); rmoon = asin(RMOON / dm) * RADTODEG; rsun = asin(drad / ds) * RADTODEG; rsplusrm = rsun + rmoon; for (k = 0; k < 3; k++) { - x1[k] = xs[k] / ds /*ls[2]*/; - x2[k] = xm[k] / dm /*lm[2]*/; + x1[k] = xs[k] / ds /*ls[2] */ ; + x2[k] = xm[k] / dm /*lm[2] */ ; } dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; - dc[i] = fabs(rsplusrm) - dctr; - } - dt1 = -dc[0] / ((dc[0] - dc[1]) / dt); - tret[j] += dt1; + dc[i] = rsplusrm - dctr; } - } - tret[1] -= swe_deltat(tret[1]); - tret[4] -= swe_deltat(tret[4]); - /* - * visibility of eclipse phases - */ - for (i = 4; i >= 0; i--) { /* attr for i = 0 must be kept !!! */ - if (tret[i] == 0) - continue; - if (eclipse_how(tret[i], ipl, starname, ifl, geopos[0], geopos[1], geopos[2], - attr, serr) == ERR) - return ERR; - /*if (retflag2 & SE_ECL_VISIBLE) { could be wrong for 1st/4th contact */ - if (attr[6] > 0) { /* this is save, sun above horizon (using app. alt.) */ - retflag |= SE_ECL_VISIBLE; - switch(i) { - case 0: retflag |= SE_ECL_MAX_VISIBLE; break; - case 1: retflag |= SE_ECL_1ST_VISIBLE; break; - case 2: retflag |= SE_ECL_2ND_VISIBLE; break; - case 3: retflag |= SE_ECL_3RD_VISIBLE; break; - case 4: retflag |= SE_ECL_4TH_VISIBLE; break; - default: break; - } + find_zero(dc[0], dc[1], dc[2], twohr, &dt1, &dt2); + tret[1] = tjd + dt1 + twohr; + tret[4] = tjd + dt2 + twohr; + for (m = 0, dt = tenmin; m < 3; m++, dt /= 10) { + for (j = 1; j <= 4; j += 3) { + if (calc_planet_star + (tret[j], ipl, starname, iflagcart | SEFLG_SPEED, xs, + serr) == ERR) + return ERR; + if (swe_calc(tret[j], SE_MOON, iflagcart | SEFLG_SPEED, xm, serr) + == ERR) + return ERR; + for (i = 0; i < 2; i++) { + if (i == 1) { + for (k = 0; k < 3; k++) { + xs[k] -= xs[k + 3] * dt; + xm[k] -= xm[k + 3] * dt; + } + } + dm = sqrt(square_sum(xm)); + ds = sqrt(square_sum(xs)); + rmoon = asin(RMOON / dm) * RADTODEG; + rsun = asin(drad / ds) * RADTODEG; + rsplusrm = rsun + rmoon; + for (k = 0; k < 3; k++) { + x1[k] = xs[k] / ds /*ls[2] */ ; + x2[k] = xm[k] / dm /*lm[2] */ ; + } + dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; + dc[i] = fabs(rsplusrm) - dctr; + } + dt1 = -dc[0] / ((dc[0] - dc[1]) / dt); + tret[j] += dt1; + } + } + tret[1] -= swe_deltat(tret[1]); + tret[4] -= swe_deltat(tret[4]); + /* + * visibility of eclipse phases + */ + for (i = 4; i >= 0; i--) { /* attr for i = 0 must be kept !!! */ + if (tret[i] == 0) + continue; + if (eclipse_how + (tret[i], ipl, starname, ifl, geopos[0], geopos[1], geopos[2], + attr, serr) == ERR) + return ERR; + /*if (retflag2 & SE_ECL_VISIBLE) { could be wrong for 1st/4th contact */ + if (attr[6] > 0) { /* this is save, sun above horizon (using app. alt.) */ + retflag |= SE_ECL_VISIBLE; + switch (i) { + case 0: + retflag |= SE_ECL_MAX_VISIBLE; + break; + case 1: + retflag |= SE_ECL_1ST_VISIBLE; + break; + case 2: + retflag |= SE_ECL_2ND_VISIBLE; + break; + case 3: + retflag |= SE_ECL_3RD_VISIBLE; + break; + case 4: + retflag |= SE_ECL_4TH_VISIBLE; + break; + default: + break; + } + } } - } #if 1 - if (!(retflag & SE_ECL_VISIBLE)) { - t = tjd + direction; - goto next_try; - } + if (!(retflag & SE_ECL_VISIBLE)) { + t = tjd + direction; + goto next_try; + } #endif - if (swe_rise_trans(tret[1] - 0.1, ipl, starname, iflag, SE_CALC_RISE|SE_BIT_DISC_BOTTOM, geopos, 0, 0, &tjdr, serr) == ERR) - return ERR; - if (swe_rise_trans(tret[1] - 0.1, ipl, starname, iflag, SE_CALC_SET|SE_BIT_DISC_BOTTOM, geopos, 0, 0, &tjds, serr) == ERR) - return ERR; - if (tjdr > tret[1] && tjdr < tret[4]) - tret[5] = tjdr; - if (tjds > tret[1] && tjds < tret[4]) - tret[6] = tjds; - return retflag; + if (swe_rise_trans + (tret[1] - 0.1, ipl, starname, iflag, + SE_CALC_RISE | SE_BIT_DISC_BOTTOM, geopos, 0, 0, &tjdr, serr) == ERR) + return ERR; + if (swe_rise_trans + (tret[1] - 0.1, ipl, starname, iflag, + SE_CALC_SET | SE_BIT_DISC_BOTTOM, geopos, 0, 0, &tjds, serr) == ERR) + return ERR; + if (tjdr > tret[1] && tjdr < tret[4]) + tret[5] = tjdr; + if (tjds > tret[1] && tjds < tret[4]) + tret[6] = tjds; + return retflag; } /* @@ -2545,44 +2676,41 @@ next_try: * if a non-zero height above sea is given, atpress is estimated. * geohgt height of observer above sea (optional) */ -void FAR PASCAL_CONV swe_azalt( - double tjd_ut, - int32 calc_flag, - double *geopos, - double atpress, - double attemp, - double *xin, - double *xaz) +void FAR PASCAL_CONV +swe_azalt(double tjd_ut, int32 calc_flag, double *geopos, double atpress, + double attemp, double *xin, double *xaz) { - int i; - double x[6], xra[3]; - double armc = swe_degnorm(swe_sidtime(tjd_ut) * 15 + geopos[0]); - double mdd, eps_true, tjd_et; - for (i = 0; i < 2; i++) - xra[i] = xin[i]; - xra[2] = 1; - if (calc_flag == SE_ECL2HOR) { - tjd_et = tjd_ut + swe_deltat(tjd_ut); - swe_calc(tjd_et, SE_ECL_NUT, 0, x, NULL); - eps_true = x[0]; - swe_cotrans(xra, xra, -eps_true); - } - mdd = swe_degnorm(xra[0] - armc); - x[0] = swe_degnorm(mdd - 90); - x[1] = xra[1]; - x[2] = 1; - /* azimuth from east, counterclock */ - swe_cotrans(x, x, 90 - geopos[1]); - /* azimuth from south to west */ - x[0] = swe_degnorm(x[0] + 90); - xaz[0] = 360 - x[0]; - xaz[1] = x[1]; /* true height */ - if (atpress == 0) { - /* estimate atmospheric pressure */ - atpress = 1013.25 * pow(1 - 0.0065 * geopos[2] / 288, 5.255); - } - xaz[2] = swe_refrac_extended(x[1], geopos[2], atpress, attemp, const_lapse_rate, SE_TRUE_TO_APP, NULL); - /* xaz[2] = swe_refrac_extended(xaz[2], geopos[2], atpress, attemp, const_lapse_rate, SE_APP_TO_TRUE, NULL);*/ + int i; + double x[6], xra[3]; + double armc = swe_degnorm(swe_sidtime(tjd_ut) * 15 + geopos[0]); + double mdd, eps_true, tjd_et; + for (i = 0; i < 2; i++) + xra[i] = xin[i]; + xra[2] = 1; + if (calc_flag == SE_ECL2HOR) { + tjd_et = tjd_ut + swe_deltat(tjd_ut); + swe_calc(tjd_et, SE_ECL_NUT, 0, x, NULL); + eps_true = x[0]; + swe_cotrans(xra, xra, -eps_true); + } + mdd = swe_degnorm(xra[0] - armc); + x[0] = swe_degnorm(mdd - 90); + x[1] = xra[1]; + x[2] = 1; + /* azimuth from east, counterclock */ + swe_cotrans(x, x, 90 - geopos[1]); + /* azimuth from south to west */ + x[0] = swe_degnorm(x[0] + 90); + xaz[0] = 360 - x[0]; + xaz[1] = x[1]; /* true height */ + if (atpress == 0) { + /* estimate atmospheric pressure */ + atpress = 1013.25 * pow(1 - 0.0065 * geopos[2] / 288, 5.255); + } + xaz[2] = + swe_refrac_extended(x[1], geopos[2], atpress, attemp, + const_lapse_rate, SE_TRUE_TO_APP, NULL); + /* xaz[2] = swe_refrac_extended(xaz[2], geopos[2], atpress, attemp, const_lapse_rate, SE_APP_TO_TRUE, NULL); */ } /* @@ -2597,41 +2725,38 @@ void FAR PASCAL_CONV swe_azalt( * iflag either SE_HOR2ECL or SE_HOR2EQU * xin[2] azimut and true altitude, in degrees */ -void FAR PASCAL_CONV swe_azalt_rev( - double tjd_ut, - int32 calc_flag, - double *geopos, - double *xin, - double *xout) +void FAR PASCAL_CONV +swe_azalt_rev(double tjd_ut, int32 calc_flag, double *geopos, double *xin, + double *xout) { - int i; - double x[6], xaz[3]; - double geolon = geopos[0]; - double geolat = geopos[1]; - double armc = swe_degnorm(swe_sidtime(tjd_ut) * 15 + geolon); - double eps_true, tjd_et, dang; - for (i = 0; i < 2; i++) - xaz[i] = xin[i]; - xaz[2] = 1; - /* azimuth is from south, clockwise. - * we need it from east, counterclock */ - xaz[0] = 360 - xaz[0]; - xaz[0] = swe_degnorm(xaz[0] - 90); - /* equatorial positions */ - dang = geolat - 90; - swe_cotrans(xaz, xaz, dang); - xaz[0] = swe_degnorm(xaz[0] + armc + 90); - xout[0] = xaz[0]; - xout[1] = xaz[1]; - /* ecliptic positions */ - if (calc_flag == SE_HOR2ECL) { - tjd_et = tjd_ut + swe_deltat(tjd_ut); - swe_calc(tjd_et, SE_ECL_NUT, 0, x, NULL); - eps_true = x[0]; - swe_cotrans(xaz, x, eps_true); - xout[0] = x[0]; - xout[1] = x[1]; - } + int i; + double x[6], xaz[3]; + double geolon = geopos[0]; + double geolat = geopos[1]; + double armc = swe_degnorm(swe_sidtime(tjd_ut) * 15 + geolon); + double eps_true, tjd_et, dang; + for (i = 0; i < 2; i++) + xaz[i] = xin[i]; + xaz[2] = 1; + /* azimuth is from south, clockwise. + * we need it from east, counterclock */ + xaz[0] = 360 - xaz[0]; + xaz[0] = swe_degnorm(xaz[0] - 90); + /* equatorial positions */ + dang = geolat - 90; + swe_cotrans(xaz, xaz, dang); + xaz[0] = swe_degnorm(xaz[0] + armc + 90); + xout[0] = xaz[0]; + xout[1] = xaz[1]; + /* ecliptic positions */ + if (calc_flag == SE_HOR2ECL) { + tjd_et = tjd_ut + swe_deltat(tjd_ut); + swe_calc(tjd_et, SE_ECL_NUT, 0, x, NULL); + eps_true = x[0]; + swe_cotrans(xaz, x, eps_true); + xout[0] = x[0]; + xout[1] = x[1]; + } } /* swe_refrac() @@ -2646,108 +2771,115 @@ void FAR PASCAL_CONV swe_azalt_rev( * int32 calc_flag; * either SE_CALC_APP_TO_TRUE or * * SE_CALC_TRUE_TO_APP */ -double FAR PASCAL_CONV swe_refrac(double inalt, double atpress, double attemp, int32 calc_flag) +double FAR PASCAL_CONV +swe_refrac(double inalt, double atpress, double attemp, int32 calc_flag) { - double a, refr; - double pt_factor = atpress / 1010.0 * 283.0 / (273.0 + attemp); - double trualt, appalt; + double a, refr; + double pt_factor = atpress / 1010.0 * 283.0 / (273.0 + attemp); + double trualt, appalt; #if 0 - /* - * -- S. L. Moshier */ - double y, yy0, D0, N, D, P, Q; - int i; - if (calc_flag == SE_TRUE_TO_APP) { - trualt = inalt; - if( (trualt < -2.0) || (trualt >= 90.0) ) - return(trualt); - /* For high altitude angle, AA page B61 - * Accuracy "usually about 0.1' ". - */ - if( trualt > 15.0 ) { - D = 0.00452*atpress/((273.0+attemp)*tan( DEGTORAD*trualt )); - return(trualt + D); - } - /* Formula for low altitude is from the Almanac for Computers. - * It gives the correction for observed altitude, so has - * to be inverted numerically to get the observed from the true. - * Accuracy about 0.2' for -20C < T < +40C and 970mb < P < 1050mb. - */ - /* Start iteration assuming correction = 0 - */ - y = trualt; - D = 0.0; - /* Invert Almanac for Computers formula numerically - */ - P = (atpress - 80.0)/930.0; - Q = 4.8e-3 * (attemp - 10.0); - yy0 = y; - D0 = D; - for( i=0; i<4; i++ ) { - N = y + (7.31/(y+4.4)); - N = 1.0/tan(DEGTORAD*N); - D = N*P/(60.0 + Q * (N + 39.0)); - N = y - yy0; - yy0 = D - D0 - N; /* denominator of derivative */ - if( (N != 0.0) && (yy0 != 0.0) ) - /* Newton iteration with numerically estimated derivative */ - N = y - N*(trualt + D - y)/yy0; - else - /* Can't do it on first pass */ - N = trualt + D; - yy0 = y; - D0 = D; - y = N; - } - return( trualt + D ); - } else { -#else - /* another algorithm, from Meeus, German, p. 114ff. - */ - if (calc_flag == SE_TRUE_TO_APP) { - trualt = inalt; - if (trualt > 15) { - a = tan((90 - trualt) * DEGTORAD); - refr = (58.276 * a - 0.0824 * a * a * a); - refr *= pt_factor / 3600.0; - } else if (trualt > -5) { - /* the following tan is not defined for a value - * of trualt near -5.00158 and 89.89158 */ - a = trualt + 10.3 / (trualt + 5.11); - if (a + 1e-10 >= 90) - refr = 0; - else - refr = 1.02 / tan(a * DEGTORAD); - refr *= pt_factor / 60.0; - } else - refr = 0; - appalt = trualt; - if (appalt + refr > 0) - appalt += refr; - return appalt; - } else { -#endif - /* apparent to true */ - appalt = inalt; - /* the following tan is not defined for a value - * of inalt near -4.3285 and 89.9225 */ - a = appalt + 7.31 / (appalt + 4.4); - if (a + 1e-10 >= 90) - refr = 0; - else { - refr = 1.00 / tan(a * DEGTORAD); - refr -= 0.06 * sin(14.7 * refr + 13); + /* + * -- S. L. Moshier */ + double y, yy0, D0, N, D, P, Q; + int i; + if (calc_flag == SE_TRUE_TO_APP) { + trualt = inalt; + if ((trualt < -2.0) || (trualt >= 90.0)) + return (trualt); + /* For high altitude angle, AA page B61 + * Accuracy "usually about 0.1' ". + */ + if (trualt > 15.0) { + D = 0.00452 * atpress / ((273.0 + attemp) * + tan(DEGTORAD * trualt)); + return (trualt + D); + } + /* Formula for low altitude is from the Almanac for Computers. + * It gives the correction for observed altitude, so has + * to be inverted numerically to get the observed from the true. + * Accuracy about 0.2' for -20C < T < +40C and 970mb < P < 1050mb. + */ + /* Start iteration assuming correction = 0 + */ + y = trualt; + D = 0.0; + /* Invert Almanac for Computers formula numerically + */ + P = (atpress - 80.0) / 930.0; + Q = 4.8e-3 * (attemp - 10.0); + yy0 = y; + D0 = D; + for (i = 0; i < 4; i++) { + N = y + (7.31 / (y + 4.4)); + N = 1.0 / tan(DEGTORAD * N); + D = N * P / (60.0 + Q * (N + 39.0)); + N = y - yy0; + yy0 = D - D0 - N; /* denominator of derivative */ + if ((N != 0.0) && (yy0 != 0.0)) + /* Newton iteration with numerically estimated derivative */ + N = y - N * (trualt + D - y) / yy0; + else + /* Can't do it on first pass */ + N = trualt + D; + yy0 = y; + D0 = D; + y = N; + } + return (trualt + D); + } + else { +#else + /* another algorithm, from Meeus, German, p. 114ff. + */ + if (calc_flag == SE_TRUE_TO_APP) { + trualt = inalt; + if (trualt > 15) { + a = tan((90 - trualt) * DEGTORAD); + refr = (58.276 * a - 0.0824 * a * a * a); + refr *= pt_factor / 3600.0; + } + else if (trualt > -5) { + /* the following tan is not defined for a value + * of trualt near -5.00158 and 89.89158 */ + a = trualt + 10.3 / (trualt + 5.11); + if (a + 1e-10 >= 90) + refr = 0; + else + refr = 1.02 / tan(a * DEGTORAD); + refr *= pt_factor / 60.0; + } + else + refr = 0; + appalt = trualt; + if (appalt + refr > 0) + appalt += refr; + return appalt; + } + else { +#endif + /* apparent to true */ + appalt = inalt; + /* the following tan is not defined for a value + * of inalt near -4.3285 and 89.9225 */ + a = appalt + 7.31 / (appalt + 4.4); + if (a + 1e-10 >= 90) + refr = 0; + else { + refr = 1.00 / tan(a * DEGTORAD); + refr -= 0.06 * sin(14.7 * refr + 13); + } + refr *= pt_factor / 60.0; + trualt = appalt; + if (appalt - refr > 0) + trualt = appalt - refr; + return trualt; } - refr *= pt_factor / 60.0; - trualt = appalt; - if (appalt - refr > 0) - trualt = appalt - refr; - return trualt; - } } -void FAR PASCAL_CONV swe_set_lapse_rate(double lapse_rate) +void FAR PASCAL_CONV +swe_set_lapse_rate(double lapse_rate) { - const_lapse_rate = lapse_rate; + const_lapse_rate = lapse_rate; } /* swe_refrac_extended() @@ -2792,81 +2924,86 @@ void FAR PASCAL_CONV swe_set_lapse_rate(double lapse_rate) * * The body is above the horizon if the dret[0] != dret[1] */ -double FAR PASCAL_CONV swe_refrac_extended(double inalt, double geoalt, double atpress, double attemp, double lapse_rate, int32 calc_flag, double *dret) +double FAR PASCAL_CONV +swe_refrac_extended(double inalt, double geoalt, double atpress, + double attemp, double lapse_rate, int32 calc_flag, + double *dret) { - double refr; - double trualt; - double dip = calc_dip(geoalt, atpress, attemp, lapse_rate); - double D, D0, N, y, yy0; - int i; - /* make sure that inalt <=90 */ - if( (inalt>90) ) - inalt=180-inalt; - if (calc_flag == SE_TRUE_TO_APP) { - if (inalt < -10) { - if (dret != NULL) { - dret[0]=inalt; - dret[1]=inalt; - dret[2]=0; - dret[3]=dip; - } - return inalt; + double refr; + double trualt; + double dip = calc_dip(geoalt, atpress, attemp, lapse_rate); + double D, D0, N, y, yy0; + int i; + /* make sure that inalt <=90 */ + if ((inalt > 90)) + inalt = 180 - inalt; + if (calc_flag == SE_TRUE_TO_APP) { + if (inalt < -10) { + if (dret != NULL) { + dret[0] = inalt; + dret[1] = inalt; + dret[2] = 0; + dret[3] = dip; + } + return inalt; + } + /* by iteration */ + y = inalt; + D = 0.0; + yy0 = 0; + D0 = D; + for (i = 0; i < 5; i++) { + D = calc_astronomical_refr(y, atpress, attemp); + N = y - yy0; + yy0 = D - D0 - N; /* denominator of derivative */ + if (N != 0.0 && yy0 != 0.0) /* sic !!! code by Moshier */ + N = y - N * (inalt + D - y) / yy0; /* Newton iteration with numerically estimated derivative */ + else /* Can't do it on first pass */ + N = inalt + D; + yy0 = y; + D0 = D; + y = N; + } + refr = D; + if ((inalt + refr < dip)) { + if (dret != NULL) { + dret[0] = inalt; + dret[1] = inalt; + dret[2] = 0; + dret[3] = dip; + } + return inalt; + } + if (dret != NULL) { + dret[0] = inalt; + dret[1] = inalt + refr; + dret[2] = refr; + dret[3] = dip; + } + return inalt + refr; } - /* by iteration */ - y = inalt; - D = 0.0; - yy0 = 0; - D0 = D; - for(i=0; i<5; i++) { - D = calc_astronomical_refr(y,atpress,attemp); - N = y - yy0; - yy0 = D - D0 - N; /* denominator of derivative */ - if (N != 0.0 && yy0 != 0.0) /* sic !!! code by Moshier */ - N = y - N*(inalt + D - y)/yy0; /* Newton iteration with numerically estimated derivative */ - else /* Can't do it on first pass */ - N = inalt + D; - yy0 = y; - D0 = D; - y = N; + else { + refr = calc_astronomical_refr(inalt, atpress, attemp); + trualt = inalt - refr; + if (dret != NULL) { + if (inalt > dip) { + dret[0] = trualt; + dret[1] = inalt; + dret[2] = refr; + dret[3] = dip; + } + else { + dret[0] = inalt; + dret[1] = inalt; + dret[2] = 0; + dret[3] = dip; + } + } + if (trualt > dip) + return trualt; + else + return inalt; } - refr = D; - if( (inalt + refr < dip) ) { - if (dret != NULL) { - dret[0]=inalt; - dret[1]=inalt; - dret[2]=0; - dret[3]=dip; - } - return inalt; - } - if (dret != NULL) { - dret[0]=inalt; - dret[1]=inalt+refr; - dret[2]=refr; - dret[3]=dip; - } - return inalt+refr; - } else { - refr = calc_astronomical_refr(inalt,atpress,attemp); - trualt=inalt-refr; - if (dret != NULL) { - if (inalt > dip) { - dret[0]=trualt; - dret[1]=inalt; - dret[2]=refr; - dret[3]=dip; - } else { - dret[0]=inalt; - dret[1]=inalt; - dret[2]=0; - dret[3]=dip; - } - } - if (trualt > dip) - return trualt; - else - return inalt; - } } /* calculate the astronomical refraction @@ -2876,29 +3013,39 @@ double FAR PASCAL_CONV swe_refrac_extended(double inalt, double geoalt, double a * double attemp * atmospheric temperature degrees C * * returns double r in degrees */ -static double calc_astronomical_refr(double inalt,double atpress, double attemp) +static double +calc_astronomical_refr(double inalt, double atpress, double attemp) { #if 0 - /* formula based on G.G. Bennett, The calculation of astronomical refraction in marine navigation, - * Journal of Inst. Navigation, No. 35, page 255-259, 1982, - * page 257 for refraction formula: formula H - * and page 259 for atmospheric compensation - */ - double refractaccent = 1/tan(DEGTORAD*(inalt + 7.31/(inalt+4.4))); - double r = (refractaccent - 0.06 * sin(DEGTORAD*(14.7*refractaccent +13))); - r = ((atpress - 80) / 930 / (1 + 0.00008 * (r + 39) * (attemp - 10)) * r)/60; - return r; + /* formula based on G.G. Bennett, The calculation of astronomical refraction in marine navigation, + * Journal of Inst. Navigation, No. 35, page 255-259, 1982, + * page 257 for refraction formula: formula H + * and page 259 for atmospheric compensation + */ + double refractaccent = 1 / tan(DEGTORAD * (inalt + 7.31 / (inalt + 4.4))); + double r = + (refractaccent - 0.06 * sin(DEGTORAD * (14.7 * refractaccent + 13))); + r = ((atpress - 80) / 930 / (1 + + 0.00008 * (r + 39) * (attemp - + 10)) * r) / 60; + return r; #else - /* Formula by Sinclair, see article mentioned above, p. 256. Better for - * apparent altitudes < 0; */ - double r; - if (inalt > 17.904104638432) { /* for continuous function, instead of '>15' */ - r = 0.97 / tan(inalt * DEGTORAD); - } else { - r = (34.46 + 4.23 * inalt + 0.004 * inalt * inalt) / (1 + 0.505 * inalt + 0.0845 * inalt * inalt); - } - r = ((atpress - 80) / 930 / (1 + 0.00008 * (r + 39) * (attemp - 10)) * r) / 60.0; - return r; + /* Formula by Sinclair, see article mentioned above, p. 256. Better for + * apparent altitudes < 0; */ + double r; + if (inalt > 17.904104638432) { /* for continuous function, instead of '>15' */ + r = 0.97 / tan(inalt * DEGTORAD); + } + else { + r = (34.46 + 4.23 * inalt + 0.004 * inalt * inalt) / (1 + + 0.505 * inalt + + 0.0845 * inalt * + inalt); + } + r = ((atpress - 80) / 930 / (1 + + 0.00008 * (r + 39) * (attemp - + 10)) * r) / 60.0; + return r; #endif } @@ -2910,17 +3057,19 @@ static double calc_astronomical_refr(double inalt,double atpress, double attemp) * double lapse_rate * (dT/dh) [deg K/m] * returns dip in degrees */ -static double calc_dip(double geoalt, double atpress, double attemp, double lapse_rate) +static double +calc_dip(double geoalt, double atpress, double attemp, double lapse_rate) { - /* below formula is based on A. Thom, Megalithic lunar observations, 1973 (page 32). - * conversion to metric has been done by - * V. Reijs, 2000, http://www.iol.ie/~geniet/eng/refract.htm - */ - double krefr = (0.0342 + lapse_rate) / (0.154 * 0.0238); - double d = 1-1.8480*krefr*atpress/(273.16+attemp)/(273.16+attemp); - /* return -0.03203*sqrt(geoalt)*sqrt(d); */ - /* double a = acos(1/(1+geoalt/EARTH_RADIUS));*/ - return -180.0/PI * acos(1 / (1 + geoalt / EARTH_RADIUS)) * sqrt(d); + /* below formula is based on A. Thom, Megalithic lunar observations, 1973 (page 32). + * conversion to metric has been done by + * V. Reijs, 2000, http://www.iol.ie/~geniet/eng/refract.htm + */ + double krefr = (0.0342 + lapse_rate) / (0.154 * 0.0238); + double d = + 1 - 1.8480 * krefr * atpress / (273.16 + attemp) / (273.16 + attemp); + /* return -0.03203*sqrt(geoalt)*sqrt(d); */ + /* double a = acos(1/(1+geoalt/EARTH_RADIUS)); */ + return -180.0 / PI * acos(1 / (1 + geoalt / EARTH_RADIUS)) * sqrt(d); } @@ -2942,36 +3091,35 @@ static double calc_dip(double geoalt, double atpress, double attemp, double laps * declare as attr[20] at least ! * */ -int32 FAR PASCAL_CONV swe_lun_eclipse_how( - double tjd_ut, - int32 ifl, - double *geopos, - double *attr, - char *serr) +int32 FAR PASCAL_CONV +swe_lun_eclipse_how(double tjd_ut, int32 ifl, double *geopos, double *attr, + char *serr) { - double dcore[10]; - double lm[6], xaz[6]; - int32 retc; - /* attention: geopos[] is not used so far; may be NULL */ - if (geopos != NULL) - geopos[0] = geopos[0]; /* to shut up mint */ - ifl = ifl & ~SEFLG_TOPOCTR; - retc = lun_eclipse_how(tjd_ut, ifl, attr, dcore, serr); - if (geopos == NULL) + double dcore[10]; + double lm[6], xaz[6]; + int32 retc; + /* attention: geopos[] is not used so far; may be NULL */ + if (geopos != NULL) + geopos[0] = geopos[0]; /* to shut up mint */ + ifl = ifl & ~SEFLG_TOPOCTR; + retc = lun_eclipse_how(tjd_ut, ifl, attr, dcore, serr); + if (geopos == NULL) + return retc; + /* + * azimuth and altitude of moon + */ + swe_set_topo(geopos[0], geopos[1], geopos[2]); + if (swe_calc_ut + (tjd_ut, SE_MOON, ifl | SEFLG_TOPOCTR | SEFLG_EQUATORIAL, lm, + serr) == ERR) + return ERR; + swe_azalt(tjd_ut, SE_EQU2HOR, geopos, 0, 10, lm, xaz); + attr[4] = xaz[0]; + attr[5] = xaz[1]; + attr[6] = xaz[2]; + if (xaz[2] <= 0) + retc = 0; return retc; - /* - * azimuth and altitude of moon - */ - swe_set_topo(geopos[0], geopos[1], geopos[2]); - if (swe_calc_ut(tjd_ut, SE_MOON, ifl | SEFLG_TOPOCTR | SEFLG_EQUATORIAL, lm, serr) == ERR) - return ERR; - swe_azalt(tjd_ut, SE_EQU2HOR, geopos, 0, 10, lm, xaz); - attr[4] = xaz[0]; - attr[5] = xaz[1]; - attr[6] = xaz[2]; - if (xaz[2] <= 0) - retc = 0; - return retc; } /* @@ -2981,131 +3129,134 @@ int32 FAR PASCAL_CONV swe_lun_eclipse_how( * dcore[1]: diameter of core shadow on fundamental plane d0 * dcore[2]: diameter of half-shadow on fundamental plane D0 */ -static int32 lun_eclipse_how( - double tjd_ut, - int32 ifl, - double *attr, - double *dcore, - char *serr) +static int32 +lun_eclipse_how(double tjd_ut, int32 ifl, double *attr, double *dcore, + char *serr) { - int i, j, k; - int32 retc = 0; - double e[6], rm[6], rs[6]; - double dsm, d0, D0, s0, r0, ds, dm; - double dctr, x1[6], x2[6]; - double f1, f2; - double deltat, tjd, d; - double cosf1, cosf2; - double rmoon = RMOON; - double dmoon = 2 * rmoon; - int32 iflag; - for (i = 0; i < 10; i++) - dcore[i] = 0; - for (i = 0; i < 20; i++) - attr[i] = 0; - /* nutation need not be in lunar and solar positions, - * if mean sidereal time will be used */ - iflag = SEFLG_SPEED | SEFLG_EQUATORIAL | ifl; - iflag = iflag | SEFLG_XYZ; - deltat = swe_deltat(tjd_ut); - tjd = tjd_ut + deltat; - /* moon in cartesian coordinates */ - if (swe_calc(tjd, SE_MOON, iflag, rm, serr) == ERR) - return ERR; - /* distance of moon from geocenter */ - dm = sqrt(square_sum(rm)); - /* sun in cartesian coordinates */ - if (swe_calc(tjd, SE_SUN, iflag, rs, serr) == ERR) - return ERR; - /* distance of sun from geocenter */ - ds = sqrt(square_sum(rs)); - for (i = 0; i < 3; i++) { - x1[i] = rs[i] / ds; - x2[i] = rm[i] / dm; - } - dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; - /* selenocentric sun */ - for (i = 0; i <= 2; i++) - rs[i] -= rm[i]; - /* selenocentric earth */ - for (i = 0; i <= 2; i++) - rm[i] = -rm[i]; - /* sun - earth vector */ - for (i = 0; i <= 2; i++) - e[i] = (rm[i] - rs[i]); - /* distance sun - earth */ - dsm = sqrt(square_sum(e)); - /* sun - earth unit vector */ - for (i = 0; i <= 2; i++) - e[i] /= dsm; - f1 = ((RSUN - REARTH) / dsm); - cosf1 = sqrt(1 - f1 * f1); - f2 = ((RSUN + REARTH) / dsm); - cosf2 = sqrt(1 - f2 * f2); - /* distance of earth from fundamental plane */ - s0 = -dot_prod(rm, e); - /* distance of shadow axis from selenocenter */ - r0 = sqrt(dm * dm - s0 * s0); - /* diameter of core shadow on fundamental plane */ - /* one 50th is added for effect of atmosphere, AA98, L4 */ - d0 = fabs(s0 / dsm * (DSUN - DEARTH) - DEARTH) * (1 + 1.0 / 50.0) / cosf1; - /* diameter of half-shadow on fundamental plane */ - D0 = (s0 / dsm * (DSUN + DEARTH) + DEARTH) * (1 + 1.0 / 50.0) / cosf2; - d0 /= cosf1; - D0 /= cosf2; - /* for better agreement with NASA: */ - d0 *= 0.99405; - D0 *= 0.98813; - dcore[0] = r0; - dcore[1] = d0; - dcore[2] = D0; - dcore[3] = cosf1; - dcore[4] = cosf2; + int i, j, k; + int32 retc = 0; + double e[6], rm[6], rs[6]; + double dsm, d0, D0, s0, r0, ds, dm; + double dctr, x1[6], x2[6]; + double f1, f2; + double deltat, tjd, d; + double cosf1, cosf2; + double rmoon = RMOON; + double dmoon = 2 * rmoon; + int32 iflag; + for (i = 0; i < 10; i++) + dcore[i] = 0; + for (i = 0; i < 20; i++) + attr[i] = 0; + /* nutation need not be in lunar and solar positions, + * if mean sidereal time will be used */ + iflag = SEFLG_SPEED | SEFLG_EQUATORIAL | ifl; + iflag = iflag | SEFLG_XYZ; + deltat = swe_deltat(tjd_ut); + tjd = tjd_ut + deltat; + /* moon in cartesian coordinates */ + if (swe_calc(tjd, SE_MOON, iflag, rm, serr) == ERR) + return ERR; + /* distance of moon from geocenter */ + dm = sqrt(square_sum(rm)); + /* sun in cartesian coordinates */ + if (swe_calc(tjd, SE_SUN, iflag, rs, serr) == ERR) + return ERR; + /* distance of sun from geocenter */ + ds = sqrt(square_sum(rs)); + for (i = 0; i < 3; i++) { + x1[i] = rs[i] / ds; + x2[i] = rm[i] / dm; + } + dctr = acos(swi_dot_prod_unit(x1, x2)) * RADTODEG; + /* selenocentric sun */ + for (i = 0; i <= 2; i++) + rs[i] -= rm[i]; + /* selenocentric earth */ + for (i = 0; i <= 2; i++) + rm[i] = -rm[i]; + /* sun - earth vector */ + for (i = 0; i <= 2; i++) + e[i] = (rm[i] - rs[i]); + /* distance sun - earth */ + dsm = sqrt(square_sum(e)); + /* sun - earth unit vector */ + for (i = 0; i <= 2; i++) + e[i] /= dsm; + f1 = ((RSUN - REARTH) / dsm); + cosf1 = sqrt(1 - f1 * f1); + f2 = ((RSUN + REARTH) / dsm); + cosf2 = sqrt(1 - f2 * f2); + /* distance of earth from fundamental plane */ + s0 = -dot_prod(rm, e); + /* distance of shadow axis from selenocenter */ + r0 = sqrt(dm * dm - s0 * s0); + /* diameter of core shadow on fundamental plane */ + /* one 50th is added for effect of atmosphere, AA98, L4 */ + d0 = fabs(s0 / dsm * (DSUN - DEARTH) - DEARTH) * (1 + 1.0 / 50.0) / cosf1; + /* diameter of half-shadow on fundamental plane */ + D0 = (s0 / dsm * (DSUN + DEARTH) + DEARTH) * (1 + 1.0 / 50.0) / cosf2; + d0 /= cosf1; + D0 /= cosf2; + /* for better agreement with NASA: */ + d0 *= 0.99405; + D0 *= 0.98813; + dcore[0] = r0; + dcore[1] = d0; + dcore[2] = D0; + dcore[3] = cosf1; + dcore[4] = cosf2; + /************************** * phase and umbral magnitude **************************/ - retc = 0; - if (d0 / 2 >= r0 + rmoon / cosf1) { - retc = SE_ECL_TOTAL; - attr[0] = (d0 / 2 - r0 + rmoon) / dmoon; - } else if (d0 / 2 >= r0 - rmoon / cosf1) { - retc = SE_ECL_PARTIAL; - attr[0] = (d0 / 2 - r0 + rmoon) / dmoon; - } else if (D0 / 2 >= r0 - rmoon / cosf2) { - retc = SE_ECL_PENUMBRAL; - attr[0] = 0; - } else { - if (serr != NULL) - sprintf(serr, "no lunar eclipse at tjd = %f", tjd); - } - attr[8] = attr[0]; + retc = 0; + if (d0 / 2 >= r0 + rmoon / cosf1) { + retc = SE_ECL_TOTAL; + attr[0] = (d0 / 2 - r0 + rmoon) / dmoon; + } + else if (d0 / 2 >= r0 - rmoon / cosf1) { + retc = SE_ECL_PARTIAL; + attr[0] = (d0 / 2 - r0 + rmoon) / dmoon; + } + else if (D0 / 2 >= r0 - rmoon / cosf2) { + retc = SE_ECL_PENUMBRAL; + attr[0] = 0; + } + else { + if (serr != NULL) + sprintf(serr, "no lunar eclipse at tjd = %f", tjd); + } + attr[8] = attr[0]; + /************************** * penumbral magnitude **************************/ - attr[1] = (D0 / 2 - r0 + rmoon) / dmoon; - if (retc != 0) - attr[7] = 180 - fabs(dctr); - /* saros series and member */ - for (i = 0; i < NSAROS_LUNAR; i++) { - d = (tjd_ut - saros_data_lunar[i].tstart) / SAROS_CYCLE; - if (d < 0) continue; - j = (int) d; - if ((d - j) * SAROS_CYCLE < 2) { - attr[9] = (double) saros_data_lunar[i].series_no; - attr[10] = (double) j + 1; - break; + attr[1] = (D0 / 2 - r0 + rmoon) / dmoon; + if (retc != 0) + attr[7] = 180 - fabs(dctr); + /* saros series and member */ + for (i = 0; i < NSAROS_LUNAR; i++) { + d = (tjd_ut - saros_data_lunar[i].tstart) / SAROS_CYCLE; + if (d < 0) + continue; + j = (int)d; + if ((d - j) * SAROS_CYCLE < 2) { + attr[9] = (double)saros_data_lunar[i].series_no; + attr[10] = (double)j + 1; + break; + } + k = j + 1; + if ((k - d) * SAROS_CYCLE < 2) { + attr[9] = (double)saros_data_lunar[i].series_no; + attr[10] = (double)k + 1; + break; + } } - k = j + 1; - if ((k - d) * SAROS_CYCLE < 2) { - attr[9] = (double) saros_data_lunar[i].series_no; - attr[10] = (double) k + 1; - break; + if (i == NSAROS_LUNAR) { + attr[9] = attr[10] = -99999999; } - } - if (i == NSAROS_LUNAR) { - attr[9] = attr[10] = -99999999; - } - return retc; + return retc; } /* When is the next lunar eclipse? @@ -3121,220 +3272,222 @@ static int32 lun_eclipse_how( * tret[6] time of penumbral phase begin * tret[7] time of penumbral phase end */ -int32 FAR PASCAL_CONV swe_lun_eclipse_when(double tjd_start, int32 ifl, int32 ifltype, - double *tret, int32 backward, char *serr) +int32 FAR PASCAL_CONV +swe_lun_eclipse_when(double tjd_start, int32 ifl, int32 ifltype, double *tret, + int32 backward, char *serr) { - int i, j, m, n, o, i1 = 0, i2 = 0; - int32 retflag = 0, retflag2 = 0; - double t, tjd, dt, dtint, dta, dtb; - double T, T2, T3, T4, K, F, M, Mm; - double E, Ff, F1, A1, Om; - double xs[6], xm[6], dm, ds; - double rsun, rearth, dcore[10]; - double dc[3], dctr; - double twohr = 2.0 / 24.0; - double tenmin = 10.0 / 24.0 / 60.0; - double dt1, dt2; - double kk; - double attr[20]; - double dtstart, dtdiv; - double xa[6], xb[6]; - int direction = 1; - int32 iflag; - int32 iflagcart; - ifl &= SEFLG_EPHMASK; - iflag = SEFLG_EQUATORIAL | ifl; - iflagcart = iflag | SEFLG_XYZ; - if (ifltype == 0) - ifltype = SE_ECL_TOTAL | SE_ECL_PENUMBRAL | SE_ECL_PARTIAL; - if (backward) - direction = -1; - K = (int) ((tjd_start - J2000) / 365.2425 * 12.3685); - K -= direction; + int i, j, m, n, o, i1 = 0, i2 = 0; + int32 retflag = 0, retflag2 = 0; + double t, tjd, dt, dtint, dta, dtb; + double T, T2, T3, T4, K, F, M, Mm; + double E, Ff, F1, A1, Om; + double xs[6], xm[6], dm, ds; + double rsun, rearth, dcore[10]; + double dc[3], dctr; + double twohr = 2.0 / 24.0; + double tenmin = 10.0 / 24.0 / 60.0; + double dt1, dt2; + double kk; + double attr[20]; + double dtstart, dtdiv; + double xa[6], xb[6]; + int direction = 1; + int32 iflag; + int32 iflagcart; + ifl &= SEFLG_EPHMASK; + iflag = SEFLG_EQUATORIAL | ifl; + iflagcart = iflag | SEFLG_XYZ; + if (ifltype == 0) + ifltype = SE_ECL_TOTAL | SE_ECL_PENUMBRAL | SE_ECL_PARTIAL; + if (backward) + direction = -1; + K = (int)((tjd_start - J2000) / 365.2425 * 12.3685); + K -= direction; next_try: - retflag = 0; - for (i = 0; i <= 9; i++) - tret[i] = 0; - kk = K + 0.5; - T = kk / 1236.85; - T2 = T * T; T3 = T2 * T; T4 = T3 * T; - Ff = F = swe_degnorm(160.7108 + 390.67050274 * kk - - 0.0016341 * T2 - - 0.00000227 * T3 - + 0.000000011 * T4); - if (Ff > 180) - Ff -= 180; - if (Ff > 21 && Ff < 159) { /* no eclipse possible */ - K += direction; - goto next_try; - } - /* approximate time of geocentric maximum eclipse - * formula from Meeus, German, p. 381 */ - tjd = 2451550.09765 + 29.530588853 * kk - + 0.0001337 * T2 - - 0.000000150 * T3 - + 0.00000000073 * T4; - M = swe_degnorm(2.5534 + 29.10535669 * kk - - 0.0000218 * T2 - - 0.00000011 * T3); - Mm = swe_degnorm(201.5643 + 385.81693528 * kk - + 0.1017438 * T2 - + 0.00001239 * T3 - + 0.000000058 * T4); - Om = swe_degnorm(124.7746 - 1.56375580 * kk - + 0.0020691 * T2 - + 0.00000215 * T3); - E = 1 - 0.002516 * T - 0.0000074 * T2; - A1 = swe_degnorm(299.77 + 0.107408 * kk - 0.009173 * T2); - M *= DEGTORAD; - Mm *= DEGTORAD; - F *= DEGTORAD; - Om *= DEGTORAD; - F1 = F - 0.02665 * sin(Om) * DEGTORAD; - A1 *= DEGTORAD; - tjd = tjd - 0.4075 * sin(Mm) - + 0.1721 * E * sin(M) - + 0.0161 * sin(2 * Mm) - - 0.0097 * sin(2 * F1) - + 0.0073 * E * sin(Mm - M) - - 0.0050 * E * sin(Mm + M) - - 0.0023 * sin(Mm - 2 * F1) - + 0.0021 * E * sin(2 * M) - + 0.0012 * sin(Mm + 2 * F1) - + 0.0006 * E * sin(2 * Mm + M) - - 0.0004 * sin(3 * Mm) - - 0.0003 * E * sin(M + 2 * F1) - + 0.0003 * sin(A1) - - 0.0002 * E * sin(M - 2 * F1) - - 0.0002 * E * sin(2 * Mm - M) - - 0.0002 * sin(Om); - /* - * precise computation: - * time of maximum eclipse (if eclipse) = - * minimum selenocentric angle between sun and earth edges. - * After this time has been determined, check - * whether or not an eclipse is taking place with - * the function lun_eclipse_how(). - */ - dtstart = 0.1; - if (tjd < 2000000) - dtstart = 5; - dtdiv = 4; - for (j = 0, dt = dtstart; - dt > 0.001; - j++, dt /= dtdiv) { - for (i = 0, t = tjd - dt; i <= 2; i++, t += dt) { - if (swe_calc(t, SE_SUN, iflagcart, xs, serr) == ERR) - return ERR; - if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) - return ERR; - for (m = 0; m < 3; m++) { - xs[m] -= xm[m]; /* selenocentric sun */ - xm[m] = -xm[m]; /* selenocentric earth */ - } - ds = sqrt(square_sum(xs)); - dm = sqrt(square_sum(xm)); - for (m = 0; m < 3; m++) { - xa[m] = xs[m] / ds; - xb[m] = xm[m] / dm; - } - dc[i] = acos(swi_dot_prod_unit(xa, xb)) * RADTODEG; - rearth = asin(REARTH / dm) * RADTODEG; - rsun = asin(RSUN / ds) * RADTODEG; - dc[i] -= (rearth + rsun); + retflag = 0; + for (i = 0; i <= 9; i++) + tret[i] = 0; + kk = K + 0.5; + T = kk / 1236.85; + T2 = T * T; + T3 = T2 * T; + T4 = T3 * T; + Ff = F = + swe_degnorm(160.7108 + 390.67050274 * kk - 0.0016341 * T2 - + 0.00000227 * T3 + 0.000000011 * T4); + if (Ff > 180) + Ff -= 180; + if (Ff > 21 && Ff < 159) { /* no eclipse possible */ + K += direction; + goto next_try; } - find_maximum(dc[0], dc[1], dc[2], dt, &dtint, &dctr); - tjd += dtint + dt; - } - tjd = tjd - swe_deltat(tjd); - if ((retflag = swe_lun_eclipse_how(tjd, ifl, NULL, attr, serr)) == ERR) - return retflag; - if (retflag == 0) { - K += direction; - goto next_try; - } - tret[0] = tjd; - if ((backward && tret[0] >= tjd_start - 0.0001) - || (!backward && tret[0] <= tjd_start + 0.0001)) { - K += direction; - goto next_try; - } - /* - * check whether or not eclipse type found is wanted - */ - /* non penumbral eclipse is wanted: */ - if (!(ifltype & SE_ECL_PENUMBRAL) && (retflag & SE_ECL_PENUMBRAL)) { - K += direction; - goto next_try; - } - /* non partial eclipse is wanted: */ - if (!(ifltype & SE_ECL_PARTIAL) && (retflag & SE_ECL_PARTIAL)) { - K += direction; - goto next_try; - } - /* annular-total eclipse will be discovered later */ - if (!(ifltype & (SE_ECL_TOTAL)) && (retflag & SE_ECL_TOTAL)) { - K += direction; - goto next_try; - } - /* - * n = 0: times of eclipse begin and end - * n = 1: times of totality begin and end - * n = 2: times of center line begin and end - */ - if (retflag & SE_ECL_PENUMBRAL) - o = 0; - else if (retflag & SE_ECL_PARTIAL) - o = 1; - else - o = 2; - dta = twohr; - dtb = tenmin; - for (n = 0; n <= o; n++) { - if (n == 0) { - i1 = 6; i2 = 7; - } else if (n == 1) { - i1 = 2; i2 = 3; - } else if (n == 2) { - i1 = 4; i2 = 5; - } -#if 1 - for (i = 0, t = tjd - dta; i <= 2; i += 1, t += dta) { - if ((retflag2 = lun_eclipse_how(t, ifl, attr, dcore, serr)) == ERR) - return retflag2; - if (n == 0) - dc[i] = dcore[2] / 2 + RMOON / dcore[4] - dcore[0]; - else if (n == 1) - dc[i] = dcore[1] / 2 + RMOON / dcore[3] - dcore[0]; - else if (n == 2) - dc[i] = dcore[1] / 2 - RMOON / dcore[3] - dcore[0]; - } - find_zero(dc[0], dc[1], dc[2], dta, &dt1, &dt2); - dtb = (dt1 + dta) / 2; - tret[i1] = tjd + dt1 + dta; - tret[i2] = tjd + dt2 + dta; -#else - tret[i1] = tjd - dtb; - tret[i2] = tjd + dtb; -#endif - for (m = 0, dt = dtb / 2; m < 3; m++, dt /= 2) { - for (j = i1; j <= i2; j += (i2 - i1)) { - for (i = 0, t = tret[j] - dt; i < 2; i++, t += dt) { - if ((retflag2 = lun_eclipse_how(t, ifl, attr, dcore, serr)) == ERR) - return retflag2; - if (n == 0) - dc[i] = dcore[2] / 2 + RMOON / dcore[4] - dcore[0]; - else if (n == 1) - dc[i] = dcore[1] / 2 + RMOON / dcore[3] - dcore[0]; - else if (n == 2) - dc[i] = dcore[1] / 2 - RMOON / dcore[3] - dcore[0]; + /* approximate time of geocentric maximum eclipse + * formula from Meeus, German, p. 381 */ + tjd = + 2451550.09765 + 29.530588853 * kk + 0.0001337 * T2 - + 0.000000150 * T3 + 0.00000000073 * T4; + M = swe_degnorm(2.5534 + 29.10535669 * kk - 0.0000218 * T2 - + 0.00000011 * T3); + Mm = swe_degnorm(201.5643 + 385.81693528 * kk + 0.1017438 * T2 + + 0.00001239 * T3 + 0.000000058 * T4); + Om = swe_degnorm(124.7746 - 1.56375580 * kk + 0.0020691 * T2 + + 0.00000215 * T3); + E = 1 - 0.002516 * T - 0.0000074 * T2; + A1 = swe_degnorm(299.77 + 0.107408 * kk - 0.009173 * T2); + M *= DEGTORAD; + Mm *= DEGTORAD; + F *= DEGTORAD; + Om *= DEGTORAD; + F1 = F - 0.02665 * sin(Om) * DEGTORAD; + A1 *= DEGTORAD; + tjd = tjd - 0.4075 * sin(Mm) + + 0.1721 * E * sin(M) + + 0.0161 * sin(2 * Mm) + - 0.0097 * sin(2 * F1) + + 0.0073 * E * sin(Mm - M) + - 0.0050 * E * sin(Mm + M) + - 0.0023 * sin(Mm - 2 * F1) + + 0.0021 * E * sin(2 * M) + + 0.0012 * sin(Mm + 2 * F1) + + 0.0006 * E * sin(2 * Mm + M) + - 0.0004 * sin(3 * Mm) + - 0.0003 * E * sin(M + 2 * F1) + + 0.0003 * sin(A1) + - 0.0002 * E * sin(M - 2 * F1) + - 0.0002 * E * sin(2 * Mm - M) + - 0.0002 * sin(Om); + /* + * precise computation: + * time of maximum eclipse (if eclipse) = + * minimum selenocentric angle between sun and earth edges. + * After this time has been determined, check + * whether or not an eclipse is taking place with + * the function lun_eclipse_how(). + */ + dtstart = 0.1; + if (tjd < 2000000) + dtstart = 5; + dtdiv = 4; + for (j = 0, dt = dtstart; dt > 0.001; j++, dt /= dtdiv) { + for (i = 0, t = tjd - dt; i <= 2; i++, t += dt) { + if (swe_calc(t, SE_SUN, iflagcart, xs, serr) == ERR) + return ERR; + if (swe_calc(t, SE_MOON, iflagcart, xm, serr) == ERR) + return ERR; + for (m = 0; m < 3; m++) { + xs[m] -= xm[m]; /* selenocentric sun */ + xm[m] = -xm[m]; /* selenocentric earth */ + } + ds = sqrt(square_sum(xs)); + dm = sqrt(square_sum(xm)); + for (m = 0; m < 3; m++) { + xa[m] = xs[m] / ds; + xb[m] = xm[m] / dm; + } + dc[i] = acos(swi_dot_prod_unit(xa, xb)) * RADTODEG; + rearth = asin(REARTH / dm) * RADTODEG; + rsun = asin(RSUN / ds) * RADTODEG; + dc[i] -= (rearth + rsun); } - dt1 = dc[1] / ((dc[1] - dc[0]) / dt); - tret[j] -= dt1; - } + find_maximum(dc[0], dc[1], dc[2], dt, &dtint, &dctr); + tjd += dtint + dt; } - } - return retflag; + tjd = tjd - swe_deltat(tjd); + if ((retflag = swe_lun_eclipse_how(tjd, ifl, NULL, attr, serr)) == ERR) + return retflag; + if (retflag == 0) { + K += direction; + goto next_try; + } + tret[0] = tjd; + if ((backward && tret[0] >= tjd_start - 0.0001) + || (!backward && tret[0] <= tjd_start + 0.0001)) { + K += direction; + goto next_try; + } + /* + * check whether or not eclipse type found is wanted + */ + /* non penumbral eclipse is wanted: */ + if (!(ifltype & SE_ECL_PENUMBRAL) && (retflag & SE_ECL_PENUMBRAL)) { + K += direction; + goto next_try; + } + /* non partial eclipse is wanted: */ + if (!(ifltype & SE_ECL_PARTIAL) && (retflag & SE_ECL_PARTIAL)) { + K += direction; + goto next_try; + } + /* annular-total eclipse will be discovered later */ + if (!(ifltype & (SE_ECL_TOTAL)) && (retflag & SE_ECL_TOTAL)) { + K += direction; + goto next_try; + } + /* + * n = 0: times of eclipse begin and end + * n = 1: times of totality begin and end + * n = 2: times of center line begin and end + */ + if (retflag & SE_ECL_PENUMBRAL) + o = 0; + else if (retflag & SE_ECL_PARTIAL) + o = 1; + else + o = 2; + dta = twohr; + dtb = tenmin; + for (n = 0; n <= o; n++) { + if (n == 0) { + i1 = 6; + i2 = 7; + } + else if (n == 1) { + i1 = 2; + i2 = 3; + } + else if (n == 2) { + i1 = 4; + i2 = 5; + } +#if 1 + for (i = 0, t = tjd - dta; i <= 2; i += 1, t += dta) { + if ((retflag2 = + lun_eclipse_how(t, ifl, attr, dcore, serr)) == ERR) + return retflag2; + if (n == 0) + dc[i] = dcore[2] / 2 + RMOON / dcore[4] - dcore[0]; + else if (n == 1) + dc[i] = dcore[1] / 2 + RMOON / dcore[3] - dcore[0]; + else if (n == 2) + dc[i] = dcore[1] / 2 - RMOON / dcore[3] - dcore[0]; + } + find_zero(dc[0], dc[1], dc[2], dta, &dt1, &dt2); + dtb = (dt1 + dta) / 2; + tret[i1] = tjd + dt1 + dta; + tret[i2] = tjd + dt2 + dta; +#else + tret[i1] = tjd - dtb; + tret[i2] = tjd + dtb; +#endif + for (m = 0, dt = dtb / 2; m < 3; m++, dt /= 2) { + for (j = i1; j <= i2; j += (i2 - i1)) { + for (i = 0, t = tret[j] - dt; i < 2; i++, t += dt) { + if ((retflag2 = + lun_eclipse_how(t, ifl, attr, dcore, serr)) == ERR) + return retflag2; + if (n == 0) + dc[i] = dcore[2] / 2 + RMOON / dcore[4] - dcore[0]; + else if (n == 1) + dc[i] = dcore[1] / 2 + RMOON / dcore[3] - dcore[0]; + else if (n == 2) + dc[i] = dcore[1] / 2 - RMOON / dcore[3] - dcore[0]; + } + dt1 = dc[1] / ((dc[1] - dc[0]) / dt); + tret[j] -= dt1; + } + } + } + return retflag; } /* @@ -3357,291 +3510,314 @@ next_try: #define EULER 2.718281828459 #define NMAG_ELEM (SE_VESTA + 1) static double mag_elem[NMAG_ELEM][4] = { - /* DTV-Atlas Astronomie, p. 32 */ - {-26.86, 0, 0, 0}, - {-12.55, 0, 0, 0}, - /* IAU 1986 */ - {-0.42, 3.80, -2.73, 2.00}, - {-4.40, 0.09, 2.39, -0.65}, - {- 1.52, 1.60, 0, 0}, /* Mars */ - {- 9.40, 0.5, 0, 0}, /* Jupiter */ - {- 8.88, -2.60, 1.25, 0.044}, /* Saturn */ - {- 7.19, 0.0, 0, 0}, /* Uranus */ - {- 6.87, 0.0, 0, 0}, /* Neptune */ - {- 1.00, 0.0, 0, 0}, /* Pluto */ - {99, 0, 0, 0}, /* nodes and apogees */ - {99, 0, 0, 0}, - {99, 0, 0, 0}, - {99, 0, 0, 0}, - {99, 0, 0, 0}, /* Earth */ - /* from Bowell data base */ - {6.5, 0.15, 0, 0}, /* Chiron */ - {7.0, 0.15, 0, 0}, /* Pholus */ - {3.34, 0.12, 0, 0}, /* Ceres */ - {4.13, 0.11, 0, 0}, /* Pallas */ - {5.33, 0.32, 0, 0}, /* Juno */ - {3.20, 0.32, 0, 0}, /* Vesta */ - }; -int32 FAR PASCAL_CONV swe_pheno(double tjd, int32 ipl, int32 iflag, double *attr, char *serr) + /* DTV-Atlas Astronomie, p. 32 */ + {-26.86, 0, 0, 0}, + {-12.55, 0, 0, 0}, + /* IAU 1986 */ + {-0.42, 3.80, -2.73, 2.00}, + {-4.40, 0.09, 2.39, -0.65}, + {-1.52, 1.60, 0, 0}, /* Mars */ + {-9.40, 0.5, 0, 0}, /* Jupiter */ + {-8.88, -2.60, 1.25, 0.044}, /* Saturn */ + {-7.19, 0.0, 0, 0}, /* Uranus */ + {-6.87, 0.0, 0, 0}, /* Neptune */ + {-1.00, 0.0, 0, 0}, /* Pluto */ + {99, 0, 0, 0}, /* nodes and apogees */ + {99, 0, 0, 0}, + {99, 0, 0, 0}, + {99, 0, 0, 0}, + {99, 0, 0, 0}, /* Earth */ + /* from Bowell data base */ + {6.5, 0.15, 0, 0}, /* Chiron */ + {7.0, 0.15, 0, 0}, /* Pholus */ + {3.34, 0.12, 0, 0}, /* Ceres */ + {4.13, 0.11, 0, 0}, /* Pallas */ + {5.33, 0.32, 0, 0}, /* Juno */ + {3.20, 0.32, 0, 0}, /* Vesta */ +}; + +int32 FAR PASCAL_CONV +swe_pheno(double tjd, int32 ipl, int32 iflag, double *attr, char *serr) { - int i; - double xx[6], xx2[6], xxs[6], lbr[6], lbr2[6], dt = 0, dd; - double fac; - double T, in, om, sinB, u1, u2, du; - double ph1, ph2, me[2]; - int32 iflagp, epheflag; - /* function calls for Pluto with asteroid number 134340 - * are treated as calls for Pluto as main body SE_PLUTO */ - if (ipl == SE_AST_OFFSET + 134340) - ipl = SE_PLUTO; - for (i = 0; i < 20; i++) - attr[i] = 0; - /* Ceres - Vesta must be SE_CERES etc., not 10001 etc. */ - if (ipl > SE_AST_OFFSET && ipl <= SE_AST_OFFSET + 4) + int i; + double xx[6], xx2[6], xxs[6], lbr[6], lbr2[6], dt = 0, dd; + double fac; + double T, in, om, sinB, u1, u2, du; + double ph1, ph2, me[2]; + int32 iflagp, epheflag; + /* function calls for Pluto with asteroid number 134340 + * are treated as calls for Pluto as main body SE_PLUTO */ + if (ipl == SE_AST_OFFSET + 134340) + ipl = SE_PLUTO; + for (i = 0; i < 20; i++) + attr[i] = 0; + /* Ceres - Vesta must be SE_CERES etc., not 10001 etc. */ + if (ipl > SE_AST_OFFSET && ipl <= SE_AST_OFFSET + 4) ipl = ipl - SE_AST_OFFSET - 1 + SE_CERES; - iflag = iflag & (SEFLG_EPHMASK | - SEFLG_TRUEPOS | - SEFLG_J2000 | - SEFLG_NONUT | - SEFLG_NOGDEFL | - SEFLG_NOABERR | - SEFLG_TOPOCTR); - iflagp = iflag & (SEFLG_EPHMASK | - SEFLG_TRUEPOS | - SEFLG_J2000 | - SEFLG_NONUT | - SEFLG_NOABERR); - iflagp |= SEFLG_HELCTR; - epheflag = iflag & SEFLG_EPHMASK; - /* - * geocentric planet - */ - if (swe_calc(tjd, (int) ipl, iflag | SEFLG_XYZ, xx, serr) == ERR) - /* int cast can be removed when swe_calc() gets int32 ipl definition */ - return ERR; - if (swe_calc(tjd, (int) ipl, iflag, lbr, serr) == ERR) - /* int cast can be removed when swe_calc() gets int32 ipl definition */ - return ERR; - /* if moon, we need sun as well, for magnitude */ - if (ipl == SE_MOON) - if (swe_calc(tjd, SE_SUN, iflag | SEFLG_XYZ, xxs, serr) == ERR) - return ERR; - if (ipl != SE_SUN && ipl != SE_EARTH && - ipl != SE_MEAN_NODE && ipl != SE_TRUE_NODE && - ipl != SE_MEAN_APOG && ipl != SE_OSCU_APOG) { - /* - * light time planet - earth + iflag = + iflag & (SEFLG_EPHMASK | SEFLG_TRUEPOS | SEFLG_J2000 | SEFLG_NONUT | + SEFLG_NOGDEFL | SEFLG_NOABERR | SEFLG_TOPOCTR); + iflagp = + iflag & (SEFLG_EPHMASK | SEFLG_TRUEPOS | SEFLG_J2000 | SEFLG_NONUT | + SEFLG_NOABERR); + iflagp |= SEFLG_HELCTR; + epheflag = iflag & SEFLG_EPHMASK; + /* + * geocentric planet */ - dt = lbr[2] * AUNIT / CLIGHT / 86400.0; + if (swe_calc(tjd, (int)ipl, iflag | SEFLG_XYZ, xx, serr) == ERR) + /* int cast can be removed when swe_calc() gets int32 ipl definition */ + return ERR; + if (swe_calc(tjd, (int)ipl, iflag, lbr, serr) == ERR) + /* int cast can be removed when swe_calc() gets int32 ipl definition */ + return ERR; + /* if moon, we need sun as well, for magnitude */ + if (ipl == SE_MOON) + if (swe_calc(tjd, SE_SUN, iflag | SEFLG_XYZ, xxs, serr) == ERR) + return ERR; + if (ipl != SE_SUN && ipl != SE_EARTH && ipl != SE_MEAN_NODE + && ipl != SE_TRUE_NODE && ipl != SE_MEAN_APOG + && ipl != SE_OSCU_APOG) { + /* + * light time planet - earth + */ + dt = lbr[2] * AUNIT / CLIGHT / 86400.0; if (iflag & SEFLG_TRUEPOS) - dt = 0; + dt = 0; + /* + * heliocentric planet at tjd - dt + */ + if (swe_calc(tjd - dt, (int)ipl, iflagp | SEFLG_XYZ, xx2, serr) == + ERR) + /* int cast can be removed when swe_calc() gets int32 ipl definition */ + return ERR; + if (swe_calc(tjd - dt, (int)ipl, iflagp, lbr2, serr) == ERR) + /* int cast can be removed when swe_calc() gets int32 ipl definition */ + return ERR; + /* + * phase angle + */ + attr[0] = acos(swi_dot_prod_unit(xx, xx2)) * RADTODEG; + /* + * phase + */ + attr[1] = (1 + cos(attr[0] * DEGTORAD)) / 2; + } + /* + * apparent diameter of disk + */ + if (ipl < NDIAM) + dd = pla_diam[ipl]; + else if (ipl > SE_AST_OFFSET) + dd = swed.ast_diam * 1000; /* km -> m */ + else + dd = 0; + if (lbr[2] < dd / 2 / AUNIT) + attr[3] = 180; /* assume position on surface of earth */ + else + attr[3] = asin(dd / 2 / AUNIT / lbr[2]) * 2 * RADTODEG; /* - * heliocentric planet at tjd - dt + * apparent magnitude */ - if (swe_calc(tjd - dt, (int) ipl, iflagp | SEFLG_XYZ, xx2, serr) == ERR) - /* int cast can be removed when swe_calc() gets int32 ipl definition */ - return ERR; - if (swe_calc(tjd - dt, (int) ipl, iflagp, lbr2, serr) == ERR) - /* int cast can be removed when swe_calc() gets int32 ipl definition */ - return ERR; - /* - * phase angle - */ - attr[0] = acos(swi_dot_prod_unit(xx, xx2)) * RADTODEG; - /* - * phase - */ - attr[1] = (1 + cos(attr[0] * DEGTORAD)) / 2; - } - /* - * apparent diameter of disk - */ - if (ipl < NDIAM) - dd = pla_diam[ipl]; - else if (ipl > SE_AST_OFFSET) - dd = swed.ast_diam * 1000; /* km -> m */ - else - dd = 0; - if (lbr[2] < dd / 2 / AUNIT) - attr[3] = 180; /* assume position on surface of earth */ - else - attr[3] = asin(dd / 2 / AUNIT / lbr[2]) * 2 * RADTODEG; - /* - * apparent magnitude - */ - if (ipl > SE_AST_OFFSET || (ipl < NMAG_ELEM && mag_elem[ipl][0] < 99)) { - if (ipl == SE_SUN) { - /* ratio apparent diameter : average diameter */ - fac = attr[3] / (asin(pla_diam[SE_SUN] / 2.0 / AUNIT) * 2 * RADTODEG); - fac *= fac; - attr[4] = mag_elem[ipl][0] - 2.5 * log10(fac); - } else if (ipl == SE_MOON) { - /* formula according to Allen, C.W., 1976, Astrophysical Quantities */ - /*attr[4] = -21.62 + 5 * log10(384410497.8 / EARTH_RADIUS) / log10(10) + 0.026 * fabs(attr[0]) + 0.000000004 * pow(attr[0], 4);*/ - attr[4] = -21.62 + 5 * log10(lbr[2] * AUNIT / EARTH_RADIUS) / log10(10) + 0.026 * fabs(attr[0]) + 0.000000004 * pow(attr[0], 4); + if (ipl > SE_AST_OFFSET || (ipl < NMAG_ELEM && mag_elem[ipl][0] < 99)) { + if (ipl == SE_SUN) { + /* ratio apparent diameter : average diameter */ + fac = + attr[3] / (asin(pla_diam[SE_SUN] / 2.0 / AUNIT) * 2 * + RADTODEG); + fac *= fac; + attr[4] = mag_elem[ipl][0] - 2.5 * log10(fac); + } + else if (ipl == SE_MOON) { + /* formula according to Allen, C.W., 1976, Astrophysical Quantities */ + /*attr[4] = -21.62 + 5 * log10(384410497.8 / EARTH_RADIUS) / log10(10) + 0.026 * fabs(attr[0]) + 0.000000004 * pow(attr[0], 4); */ + attr[4] = + -21.62 + + 5 * log10(lbr[2] * AUNIT / EARTH_RADIUS) / log10(10) + + 0.026 * fabs(attr[0]) + 0.000000004 * pow(attr[0], 4); #if 0 - /* ratio apparent diameter : average diameter */ - fac = attr[3] / (asin(pla_diam[SE_MOON] / 2.0 / 384400000.0) * 2 * RADTODEG); - /* distance sun - moon */ - for (i = 0; i < 3; i++) - xxs[i] -= xx[i]; - dsm = sqrt(square_sum(xxs)); - /* account for phase and distance of moon: */ - fac *= fac * attr[1]; - /* account for distance of sun from moon: */ - fac *= dsm * dsm; - attr[4] = mag_elem[ipl][0] - 2.5 * log10(fac); + /* ratio apparent diameter : average diameter */ + fac = + attr[3] / (asin(pla_diam[SE_MOON] / 2.0 / 384400000.0) * 2 * + RADTODEG); + /* distance sun - moon */ + for (i = 0; i < 3; i++) + xxs[i] -= xx[i]; + dsm = sqrt(square_sum(xxs)); + /* account for phase and distance of moon: */ + fac *= fac * attr[1]; + /* account for distance of sun from moon: */ + fac *= dsm * dsm; + attr[4] = mag_elem[ipl][0] - 2.5 * log10(fac); #endif - /*printf("1 = %f, 2 = %f\n", mag, mag2);*/ - } else if (ipl == SE_SATURN) { - /* rings are considered according to Meeus, German, p. 329ff. */ - T = (tjd - dt - J2000) / 36525.0; - in = (28.075216 - 0.012998 * T + 0.000004 * T * T) * DEGTORAD; - om = (169.508470 + 1.394681 * T + 0.000412 * T * T) * DEGTORAD; - sinB = fabs(sin(in) * cos(lbr[1] * DEGTORAD) - * sin(lbr[0] * DEGTORAD - om) - - cos(in) * sin(lbr[1] * DEGTORAD)); - u1 = atan2(sin(in) * tan(lbr2[1] * DEGTORAD) - + cos(in) * sin(lbr2[0] * DEGTORAD - om), - cos(lbr2[0] * DEGTORAD - om)) * RADTODEG; - u2 = atan2(sin(in) * tan(lbr[1] * DEGTORAD) - + cos(in) * sin(lbr[0] * DEGTORAD - om), - cos(lbr[0] * DEGTORAD - om)) * RADTODEG; - du = swe_degnorm(u1 - u2); - if (du > 10) - du = 360 - du; - attr[4] = 5 * log10(lbr2[2] * lbr[2]) - + mag_elem[ipl][1] * sinB - + mag_elem[ipl][2] * sinB * sinB - + mag_elem[ipl][3] * du - + mag_elem[ipl][0]; - } else if (ipl < SE_CHIRON) { - attr[4] = 5 * log10(lbr2[2] * lbr[2]) - + mag_elem[ipl][1] * attr[0] /100.0 - + mag_elem[ipl][2] * attr[0] * attr[0] / 10000.0 - + mag_elem[ipl][3] * attr[0] * attr[0] * attr[0] / 1000000.0 - + mag_elem[ipl][0]; - } else if (ipl < NMAG_ELEM || ipl > SE_AST_OFFSET) { /* asteroids */ - ph1 = pow(EULER, -3.33 * pow(tan(attr[0] * DEGTORAD / 2), 0.63)); - ph2 = pow(EULER, -1.87 * pow(tan(attr[0] * DEGTORAD / 2), 1.22)); - if (ipl < NMAG_ELEM) { /* main asteroids */ - me[0] = mag_elem[ipl][0]; - me[1] = mag_elem[ipl][1]; - } else if (ipl == SE_AST_OFFSET + 1566) { - /* Icarus has elements from JPL database */ + /*printf("1 = %f, 2 = %f\n", mag, mag2); */ + } + else if (ipl == SE_SATURN) { + /* rings are considered according to Meeus, German, p. 329ff. */ + T = (tjd - dt - J2000) / 36525.0; + in = (28.075216 - 0.012998 * T + 0.000004 * T * T) * DEGTORAD; + om = (169.508470 + 1.394681 * T + 0.000412 * T * T) * DEGTORAD; + sinB = fabs(sin(in) * cos(lbr[1] * DEGTORAD) + * sin(lbr[0] * DEGTORAD - om) + - cos(in) * sin(lbr[1] * DEGTORAD)); + u1 = atan2(sin(in) * tan(lbr2[1] * DEGTORAD) + + cos(in) * sin(lbr2[0] * DEGTORAD - om), + cos(lbr2[0] * DEGTORAD - om)) * RADTODEG; + u2 = atan2(sin(in) * tan(lbr[1] * DEGTORAD) + + cos(in) * sin(lbr[0] * DEGTORAD - om), + cos(lbr[0] * DEGTORAD - om)) * RADTODEG; + du = swe_degnorm(u1 - u2); + if (du > 10) + du = 360 - du; + attr[4] = 5 * log10(lbr2[2] * lbr[2]) + + mag_elem[ipl][1] * sinB + mag_elem[ipl][2] * sinB * sinB + + mag_elem[ipl][3] * du + mag_elem[ipl][0]; + } + else if (ipl < SE_CHIRON) { + attr[4] = 5 * log10(lbr2[2] * lbr[2]) + + mag_elem[ipl][1] * attr[0] / 100.0 + + mag_elem[ipl][2] * attr[0] * attr[0] / 10000.0 + + mag_elem[ipl][3] * attr[0] * attr[0] * attr[0] / 1000000.0 + + mag_elem[ipl][0]; + } + else if (ipl < NMAG_ELEM || ipl > SE_AST_OFFSET) { /* asteroids */ + ph1 = pow(EULER, -3.33 * pow(tan(attr[0] * DEGTORAD / 2), 0.63)); + ph2 = pow(EULER, -1.87 * pow(tan(attr[0] * DEGTORAD / 2), 1.22)); + if (ipl < NMAG_ELEM) { /* main asteroids */ + me[0] = mag_elem[ipl][0]; + me[1] = mag_elem[ipl][1]; + } + else if (ipl == SE_AST_OFFSET + 1566) { + /* Icarus has elements from JPL database */ me[0] = 16.9; me[1] = 0.15; - } else { /* other asteroids */ - me[0] = swed.ast_H; - me[1] = swed.ast_G; - } - attr[4] = 5 * log10(lbr2[2] * lbr[2]) - + me[0] - - 2.5 * log10((1 - me[1]) * ph1 + me[1] * ph2); - } else { /* ficticious bodies */ - attr[4] = 0; + } + else { /* other asteroids */ + me[0] = swed.ast_H; + me[1] = swed.ast_G; + } + attr[4] = 5 * log10(lbr2[2] * lbr[2]) + + me[0] + - 2.5 * log10((1 - me[1]) * ph1 + me[1] * ph2); + } + else { /* ficticious bodies */ + attr[4] = 0; + } } - } - if (ipl != SE_SUN && ipl != SE_EARTH) { - /* - * elongation of planet - */ - if (swe_calc(tjd, SE_SUN, iflag | SEFLG_XYZ, xx2, serr) == ERR) - return ERR; - if (swe_calc(tjd, SE_SUN, iflag, lbr2, serr) == ERR) - return ERR; - attr[2] = acos(swi_dot_prod_unit(xx, xx2)) * RADTODEG; - } - /* horizontal parallax */ - if (ipl == SE_MOON) { - double sinhp, xm[6]; - /* geocentric horizontal parallax */ - /* Expl.Suppl. to the AA 1984, p.400 */ - if (swe_calc(tjd, (int) ipl, epheflag|SEFLG_TRUEPOS|SEFLG_EQUATORIAL|SEFLG_RADIANS, xm, serr) == ERR) - /* int cast can be removed when swe_calc() gets int32 ipl definition */ - return ERR; - sinhp = EARTH_RADIUS / xm[2] / AUNIT; - attr[5] = asin(sinhp) / DEGTORAD; - /* topocentric horizontal parallax */ - if (iflag & SEFLG_TOPOCTR) { - if (swe_calc(tjd, (int) ipl, epheflag|SEFLG_XYZ|SEFLG_TOPOCTR, xm, serr) == ERR) - return ERR; - if (swe_calc(tjd, (int) ipl, epheflag|SEFLG_XYZ, xx, serr) == ERR) - return ERR; - attr[5] = acos(swi_dot_prod_unit(xm, xx)) / DEGTORAD; + if (ipl != SE_SUN && ipl != SE_EARTH) { + /* + * elongation of planet + */ + if (swe_calc(tjd, SE_SUN, iflag | SEFLG_XYZ, xx2, serr) == ERR) + return ERR; + if (swe_calc(tjd, SE_SUN, iflag, lbr2, serr) == ERR) + return ERR; + attr[2] = acos(swi_dot_prod_unit(xx, xx2)) * RADTODEG; + } + /* horizontal parallax */ + if (ipl == SE_MOON) { + double sinhp, xm[6]; + /* geocentric horizontal parallax */ + /* Expl.Suppl. to the AA 1984, p.400 */ + if (swe_calc + (tjd, (int)ipl, + epheflag | SEFLG_TRUEPOS | SEFLG_EQUATORIAL | SEFLG_RADIANS, xm, + serr) == ERR) + /* int cast can be removed when swe_calc() gets int32 ipl definition */ + return ERR; + sinhp = EARTH_RADIUS / xm[2] / AUNIT; + attr[5] = asin(sinhp) / DEGTORAD; + /* topocentric horizontal parallax */ + if (iflag & SEFLG_TOPOCTR) { + if (swe_calc + (tjd, (int)ipl, epheflag | SEFLG_XYZ | SEFLG_TOPOCTR, xm, + serr) == ERR) + return ERR; + if (swe_calc(tjd, (int)ipl, epheflag | SEFLG_XYZ, xx, serr) == + ERR) + return ERR; + attr[5] = acos(swi_dot_prod_unit(xm, xx)) / DEGTORAD; #if 0 - { - /* Expl. Suppl. to the Astronomical Almanac 1984, p. 400; - * Does not take into account - * - the topocentric distance of the moon - * - the distance of the observer from the geocenter - */ - double tsid, h, e, f = EARTH_OBLATENESS; - double cosz, sinz, phi; - /* local apparent sidereal time */ - tsid = swe_sidtime(tjd - swe_deltat(tjd)) * 15 + swed.topd.geolon; - /* local hour angle of the moon */ - h = swe_degnorm(tsid - xm[0] / DEGTORAD); - /* geocentric latitude of the observer */ - e = sqrt(f * (2 - f)); - phi = atan((1 - e * e) * tan(swed.topd.geolat * DEGTORAD)); - /* sine of geocentric zenith angle of moon */ - cosz = sin(xm[1]) * sin(phi) + cos(xm[1]) * cos(phi) * cos(h * DEGTORAD); - sinz = sqrt(1 - cosz * cosz); - attr[5] = asin(sinz * sinhp / (1 - sinz * sinhp)) / DEGTORAD; - } + { + /* Expl. Suppl. to the Astronomical Almanac 1984, p. 400; + * Does not take into account + * - the topocentric distance of the moon + * - the distance of the observer from the geocenter + */ + double tsid, h, e, f = EARTH_OBLATENESS; + double cosz, sinz, phi; + /* local apparent sidereal time */ + tsid = + swe_sidtime(tjd - swe_deltat(tjd)) * 15 + + swed.topd.geolon; + /* local hour angle of the moon */ + h = swe_degnorm(tsid - xm[0] / DEGTORAD); + /* geocentric latitude of the observer */ + e = sqrt(f * (2 - f)); + phi = atan((1 - e * e) * tan(swed.topd.geolat * DEGTORAD)); + /* sine of geocentric zenith angle of moon */ + cosz = + sin(xm[1]) * sin(phi) + + cos(xm[1]) * cos(phi) * cos(h * DEGTORAD); + sinz = sqrt(1 - cosz * cosz); + attr[5] = asin(sinz * sinhp / (1 - sinz * sinhp)) / DEGTORAD; + } #endif + } } - } - return OK; + return OK; } -int32 FAR PASCAL_CONV swe_pheno_ut(double tjd_ut, int32 ipl, int32 iflag, double *attr, char *serr) +int32 FAR PASCAL_CONV +swe_pheno_ut(double tjd_ut, int32 ipl, int32 iflag, double *attr, char *serr) { - return swe_pheno(tjd_ut + swe_deltat(tjd_ut), ipl, iflag, attr, serr); + return swe_pheno(tjd_ut + swe_deltat(tjd_ut), ipl, iflag, attr, serr); } -static int find_maximum(double y00, double y11, double y2, double dx, - double *dxret, double *yret) +static int +find_maximum(double y00, double y11, double y2, double dx, double *dxret, + double *yret) { - double a, b, c, x, y; - c = y11; - b = (y2 - y00) / 2.0; - a = (y2 + y00) / 2.0 - c; - x = -b / 2 / a; - y = (4 * a * c - b * b) / 4 / a; - *dxret = (x - 1) * dx; - if (yret != NULL) - *yret = y; - return OK; + double a, b, c, x, y; + c = y11; + b = (y2 - y00) / 2.0; + a = (y2 + y00) / 2.0 - c; + x = -b / 2 / a; + y = (4 * a * c - b * b) / 4 / a; + *dxret = (x - 1) * dx; + if (yret != NULL) + *yret = y; + return OK; } -static int find_zero(double y00, double y11, double y2, double dx, - double *dxret, double *dxret2) +static int +find_zero(double y00, double y11, double y2, double dx, double *dxret, + double *dxret2) { - double a, b, c, x1, x2; - c = y11; - b = (y2 - y00) / 2.0; - a = (y2 + y00) / 2.0 - c; - if (b * b - 4 * a * c < 0) - return ERR; - x1 = (-b + sqrt(b * b - 4 * a * c)) / 2 / a; - x2 = (-b - sqrt(b * b - 4 * a * c)) / 2 / a; + double a, b, c, x1, x2; + c = y11; + b = (y2 - y00) / 2.0; + a = (y2 + y00) / 2.0 - c; + if (b * b - 4 * a * c < 0) + return ERR; + x1 = (-b + sqrt(b * b - 4 * a * c)) / 2 / a; + x2 = (-b - sqrt(b * b - 4 * a * c)) / 2 / a; *dxret = (x1 - 1) * dx; *dxret2 = (x2 - 1) * dx; - return OK; + return OK; } -double rdi_twilight(int32 rsmi) +double +rdi_twilight(int32 rsmi) { - double rdi = 0; - if (rsmi & SE_BIT_CIVIL_TWILIGHT) - rdi = 6; - if (rsmi & SE_BIT_NAUTIC_TWILIGHT) - rdi = 12; - if (rsmi & SE_BIT_ASTRO_TWILIGHT) - rdi = 18; - return rdi; + double rdi = 0; + if (rsmi & SE_BIT_CIVIL_TWILIGHT) + rdi = 6; + if (rsmi & SE_BIT_NAUTIC_TWILIGHT) + rdi = 12; + if (rsmi & SE_BIT_ASTRO_TWILIGHT) + rdi = 18; + return rdi; } /* rise, set, and meridian transits of sun, moon, planets, and stars @@ -3665,335 +3841,343 @@ double rdi_twilight(int32 rsmi) * serr[256] error string * function return value -2 means that the body does not rise or set */ #define SEFLG_EPHMASK (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH) -int32 FAR PASCAL_CONV swe_rise_trans( - double tjd_ut, int32 ipl, char *starname, - int32 epheflag, int32 rsmi, - double *geopos, - double atpress, double attemp, - double *tret, - char *serr) +int32 FAR PASCAL_CONV +swe_rise_trans(double tjd_ut, int32 ipl, char *starname, int32 epheflag, + int32 rsmi, double *geopos, double atpress, double attemp, + double *tret, char *serr) { - return swe_rise_trans_true_hor(tjd_ut, ipl, starname, epheflag, rsmi, geopos, atpress, attemp, 0, tret, serr); + return swe_rise_trans_true_hor(tjd_ut, ipl, starname, epheflag, rsmi, + geopos, atpress, attemp, 0, tret, serr); } /* same as swe_rise_trans(), but allows to define the height of the horizon * at the point of the rising or setting (horhgt) */ -int32 FAR PASCAL_CONV swe_rise_trans_true_hor( - double tjd_ut, int32 ipl, char *starname, - int32 epheflag, int32 rsmi, - double *geopos, - double atpress, double attemp, - double horhgt, - double *tret, - char *serr) +int32 FAR PASCAL_CONV +swe_rise_trans_true_hor(double tjd_ut, int32 ipl, char *starname, + int32 epheflag, int32 rsmi, double *geopos, + double atpress, double attemp, double horhgt, + double *tret, char *serr) { - int i, j, k, ii, calc_culm, nculm = -1; - double tjd_et = tjd_ut + swe_deltat(tjd_ut); - double xc[6], xh[20][6], ah[6], aha; - double tculm[4], tcu, tc[20], h[20], t2[6], dc[6], dtint, dx, rdi, dd = 0; - int32 iflag = epheflag; - int jmax = 14; - double t, te, tt, dt, twohrs = 1.0 / 12.0; - double curdist; - AS_BOOL do_fixstar = (starname != NULL && *starname != '\0'); - /* function calls for Pluto with asteroid number 134340 - * are treated as calls for Pluto as main body SE_PLUTO */ - if (ipl == SE_AST_OFFSET + 134340) - ipl = SE_PLUTO; - xh[0][0] = 0; /* to shut up mint */ - /* allowing SEFLG_NONUT and SEFLG_TRUEPOS speeds it up */ - iflag &= (SEFLG_EPHMASK | SEFLG_NONUT | SEFLG_TRUEPOS); - *tret = 0; - iflag |= (SEFLG_EQUATORIAL | SEFLG_TOPOCTR); - swe_set_topo(geopos[0], geopos[1], geopos[2]); - if (rsmi & (SE_CALC_MTRANSIT | SE_CALC_ITRANSIT)) - return calc_mer_trans(tjd_ut, ipl, epheflag, rsmi, - geopos, starname, tret, serr); - if (!(rsmi & (SE_CALC_RISE | SE_CALC_SET))) - rsmi |= SE_CALC_RISE; - /* twilight calculation */ - if (ipl == SE_SUN && (rsmi & (SE_BIT_CIVIL_TWILIGHT|SE_BIT_NAUTIC_TWILIGHT|SE_BIT_ASTRO_TWILIGHT))) { - rsmi |= (SE_BIT_NO_REFRACTION | SE_BIT_DISC_CENTER); - horhgt = -rdi_twilight(rsmi); - /* note: twilight is not dependent on height of horizon, so we can - * use this parameter and define a fictitious height of horizon */ - } - /* find culmination points within 28 hours from t0 - twohrs. - * culminations are required in case there are maxima or minima - * in height slightly above or below the horizon. - * we do not use meridian transits, because in polar regions - * the culmination points may considerably deviate from - * transits. also, there are cases where the moon rises in the - * western half of the sky for a short time. - */ - if (do_fixstar) { - if (swe_fixstar(starname, tjd_et, iflag, xc, serr) == ERR) - return ERR; - } - for (ii = 0, t = tjd_ut - twohrs; ii <= jmax; ii++, t += twohrs) { - tc[ii] = t; - if (!do_fixstar) { - te = t + swe_deltat(t); - if (swe_calc(te, ipl, iflag, xc, serr) == ERR) - return ERR; + int i, j, k, ii, calc_culm, nculm = -1; + double tjd_et = tjd_ut + swe_deltat(tjd_ut); + double xc[6], xh[20][6], ah[6], aha; + double tculm[4], tcu, tc[20], h[20], t2[6], dc[6], dtint, dx, rdi, dd = 0; + int32 iflag = epheflag; + int jmax = 14; + double t, te, tt, dt, twohrs = 1.0 / 12.0; + double curdist; + AS_BOOL do_fixstar = (starname != NULL && *starname != '\0'); + /* function calls for Pluto with asteroid number 134340 + * are treated as calls for Pluto as main body SE_PLUTO */ + if (ipl == SE_AST_OFFSET + 134340) + ipl = SE_PLUTO; + xh[0][0] = 0; /* to shut up mint */ + /* allowing SEFLG_NONUT and SEFLG_TRUEPOS speeds it up */ + iflag &= (SEFLG_EPHMASK | SEFLG_NONUT | SEFLG_TRUEPOS); + *tret = 0; + iflag |= (SEFLG_EQUATORIAL | SEFLG_TOPOCTR); + swe_set_topo(geopos[0], geopos[1], geopos[2]); + if (rsmi & (SE_CALC_MTRANSIT | SE_CALC_ITRANSIT)) + return calc_mer_trans(tjd_ut, ipl, epheflag, rsmi, geopos, starname, + tret, serr); + if (!(rsmi & (SE_CALC_RISE | SE_CALC_SET))) + rsmi |= SE_CALC_RISE; + /* twilight calculation */ + if (ipl == SE_SUN + && (rsmi & + (SE_BIT_CIVIL_TWILIGHT | SE_BIT_NAUTIC_TWILIGHT | + SE_BIT_ASTRO_TWILIGHT))) { + rsmi |= (SE_BIT_NO_REFRACTION | SE_BIT_DISC_CENTER); + horhgt = -rdi_twilight(rsmi); + /* note: twilight is not dependent on height of horizon, so we can + * use this parameter and define a fictitious height of horizon */ } - /* diameter of object in km */ - if (ii == 0) { - if (do_fixstar) - dd = 0; - else if (rsmi & SE_BIT_DISC_CENTER) - dd = 0; - else if (ipl < NDIAM) - dd = pla_diam[ipl]; - else if (ipl > SE_AST_OFFSET) - dd = swed.ast_diam * 1000; /* km -> m */ - else - dd = 0; - } - curdist = xc[2]; - if (rsmi & SE_BIT_FIXED_DISC_SIZE) { - if (ipl == SE_SUN) { - curdist = 1.0; - } else if (ipl == SE_MOON) { - curdist = 0.00257; - } - } - /* apparent radius of disc */ - rdi = asin( dd / 2 / AUNIT / curdist ) * RADTODEG; - /* true height of center of body */ - swe_azalt(t, SE_EQU2HOR, geopos, atpress, attemp, xc, xh[ii]); - if (rsmi & SE_BIT_DISC_BOTTOM) { - /* true height of bottom point of body */ - xh[ii][1] -= rdi; - } else { - /* true height of uppermost point of body */ - xh[ii][1] += rdi; - } - /* apparent height of uppermost point of body */ - if (rsmi & SE_BIT_NO_REFRACTION) { - xh[ii][1] -= horhgt; - h[ii] = xh[ii][1]; - } else { - swe_azalt_rev(t, SE_HOR2EQU, geopos, xh[ii], xc); - swe_azalt(t, SE_EQU2HOR, geopos, atpress, attemp, xc, xh[ii]); - xh[ii][1] -= horhgt; - xh[ii][2] -= horhgt; - h[ii] = xh[ii][2]; - } - calc_culm = 0; - if (ii > 1) { - dc[0] = xh[ii-2][1]; - dc[1] = xh[ii-1][1]; - dc[2] = xh[ii][1]; - if (dc[1] > dc[0] && dc[1] > dc[2]) - calc_culm = 1; - if (dc[1] < dc[0] && dc[1] < dc[2]) - calc_culm = 2; - } - if (calc_culm) { - dt = twohrs; - tcu = t - dt; - find_maximum(dc[0], dc[1], dc[2], dt, &dtint, &dx); - tcu += dtint + dt; - dt /= 3; - for (; dt > 0.0001; dt /= 3) { - for (i = 0, tt = tcu - dt; i < 3; tt += dt, i++) { - te = tt + swe_deltat(tt); - if (!do_fixstar) - if (swe_calc(te, ipl, iflag, xc, serr) == ERR) - return ERR; - swe_azalt(tt, SE_EQU2HOR, geopos, atpress, attemp, xc, ah); - ah[1] -= horhgt; - dc[i] = ah[1]; - } - find_maximum(dc[0], dc[1], dc[2], dt, &dtint, &dx); - tcu += dtint + dt; - } - nculm++; - tculm[nculm] = tcu; - } - } - /* note: there can be a rise or set on the poles, even if - * there is no culmination. So, we must not leave here - * in any case. */ - /* insert culminations into array of heights */ - for (i = 0; i <= nculm; i++) { - for (j = 1; j <= jmax; j++) { - if (tculm[i] < tc[j]) { - for (k = jmax; k >= j; k--) { - tc[k+1] = tc[k]; - h[k+1] = h[k]; - } - tc[j] = tculm[i]; - if (!do_fixstar) { - te = tc[j] + swe_deltat(tc[j]); - if (swe_calc(te, ipl, iflag, xc, serr) == ERR) + /* find culmination points within 28 hours from t0 - twohrs. + * culminations are required in case there are maxima or minima + * in height slightly above or below the horizon. + * we do not use meridian transits, because in polar regions + * the culmination points may considerably deviate from + * transits. also, there are cases where the moon rises in the + * western half of the sky for a short time. + */ + if (do_fixstar) { + if (swe_fixstar(starname, tjd_et, iflag, xc, serr) == ERR) return ERR; + } + for (ii = 0, t = tjd_ut - twohrs; ii <= jmax; ii++, t += twohrs) { + tc[ii] = t; + if (!do_fixstar) { + te = t + swe_deltat(t); + if (swe_calc(te, ipl, iflag, xc, serr) == ERR) + return ERR; + } + /* diameter of object in km */ + if (ii == 0) { + if (do_fixstar) + dd = 0; + else if (rsmi & SE_BIT_DISC_CENTER) + dd = 0; + else if (ipl < NDIAM) + dd = pla_diam[ipl]; + else if (ipl > SE_AST_OFFSET) + dd = swed.ast_diam * 1000; /* km -> m */ + else + dd = 0; } curdist = xc[2]; if (rsmi & SE_BIT_FIXED_DISC_SIZE) { - if ( ipl == SE_SUN ) { - curdist = 1.0; - } else if (ipl == SE_MOON) { - curdist = 0.00257; - } + if (ipl == SE_SUN) { + curdist = 1.0; + } + else if (ipl == SE_MOON) { + curdist = 0.00257; + } } /* apparent radius of disc */ - rdi = asin( dd / 2 / AUNIT / curdist ) * RADTODEG; + rdi = asin(dd / 2 / AUNIT / curdist) * RADTODEG; /* true height of center of body */ - swe_azalt(tc[j], SE_EQU2HOR, geopos, atpress, attemp, xc, ah); + swe_azalt(t, SE_EQU2HOR, geopos, atpress, attemp, xc, xh[ii]); if (rsmi & SE_BIT_DISC_BOTTOM) { - /* true height of bottom point of body */ - ah[1] -= rdi; - } else { - /* true height of uppermost point of body */ - ah[1] += rdi; + /* true height of bottom point of body */ + xh[ii][1] -= rdi; + } + else { + /* true height of uppermost point of body */ + xh[ii][1] += rdi; } /* apparent height of uppermost point of body */ - if (rsmi & SE_BIT_NO_REFRACTION) { - ah[1] -= horhgt; - h[j] = ah[1]; - } else { - swe_azalt_rev(tc[j], SE_HOR2EQU, geopos, ah, xc); - swe_azalt(tc[j], SE_EQU2HOR, geopos, atpress, attemp, xc, ah); - ah[1] -= horhgt; - ah[2] -= horhgt; - h[j] = ah[2]; - } - jmax++; - break; - } - } - } - *tret = 0; - /* find points with zero height. - * binary search */ - for (ii = 1; ii <= jmax; ii++) { - if (h[ii-1] * h[ii] >= 0) - continue; - if (h[ii-1] < h[ii] && !(rsmi & SE_CALC_RISE)) - continue; - if (h[ii-1] > h[ii] && !(rsmi & SE_CALC_SET)) - continue; - dc[0] = h[ii-1]; - dc[1] = h[ii]; - t2[0] = tc[ii-1]; - t2[1] = tc[ii]; - for (i = 0; i < 20; i++) { - t = (t2[0] + t2[1]) / 2; - if (!do_fixstar) { - te = t + swe_deltat(t); - if (swe_calc(te, ipl, iflag, xc, serr) == ERR) - return ERR; - } - curdist = xc[2]; - if (rsmi & SE_BIT_FIXED_DISC_SIZE) { - if (ipl == SE_SUN) { - curdist = 1.0; - } else if (ipl == SE_MOON) { - curdist = 0.00257; + if (rsmi & SE_BIT_NO_REFRACTION) { + xh[ii][1] -= horhgt; + h[ii] = xh[ii][1]; + } + else { + swe_azalt_rev(t, SE_HOR2EQU, geopos, xh[ii], xc); + swe_azalt(t, SE_EQU2HOR, geopos, atpress, attemp, xc, xh[ii]); + xh[ii][1] -= horhgt; + xh[ii][2] -= horhgt; + h[ii] = xh[ii][2]; + } + calc_culm = 0; + if (ii > 1) { + dc[0] = xh[ii - 2][1]; + dc[1] = xh[ii - 1][1]; + dc[2] = xh[ii][1]; + if (dc[1] > dc[0] && dc[1] > dc[2]) + calc_culm = 1; + if (dc[1] < dc[0] && dc[1] < dc[2]) + calc_culm = 2; + } + if (calc_culm) { + dt = twohrs; + tcu = t - dt; + find_maximum(dc[0], dc[1], dc[2], dt, &dtint, &dx); + tcu += dtint + dt; + dt /= 3; + for (; dt > 0.0001; dt /= 3) { + for (i = 0, tt = tcu - dt; i < 3; tt += dt, i++) { + te = tt + swe_deltat(tt); + if (!do_fixstar) + if (swe_calc(te, ipl, iflag, xc, serr) == ERR) + return ERR; + swe_azalt(tt, SE_EQU2HOR, geopos, atpress, attemp, xc, + ah); + ah[1] -= horhgt; + dc[i] = ah[1]; + } + find_maximum(dc[0], dc[1], dc[2], dt, &dtint, &dx); + tcu += dtint + dt; + } + nculm++; + tculm[nculm] = tcu; } - } - /* apparent radius of disc */ - rdi = asin( dd / 2 / AUNIT / curdist ) * RADTODEG; - /* true height of center of body */ - swe_azalt(t, SE_EQU2HOR, geopos, atpress, attemp, xc, ah); - if (rsmi & SE_BIT_DISC_BOTTOM) { - /* true height of bottom point of body */ - ah[1] -= rdi; - } else { - /* true height of uppermost point of body */ - ah[1] += rdi; - } - /* apparent height of uppermost point of body */ - if (rsmi & SE_BIT_NO_REFRACTION) { - ah[1] -= horhgt; - aha = ah[1]; - } else { - swe_azalt_rev(t, SE_HOR2EQU, geopos, ah, xc); - swe_azalt(t, SE_EQU2HOR, geopos, atpress, attemp, xc, ah); - ah[1] -= horhgt; - ah[2] -= horhgt; - aha = ah[2]; - } - if (aha * dc[0] <= 0) { - dc[1] = aha; - t2[1] = t; - } else { - dc[0] = aha; - t2[0] = t; - } } - if (t > tjd_ut) { - *tret = t; - return OK; + /* note: there can be a rise or set on the poles, even if + * there is no culmination. So, we must not leave here + * in any case. */ + /* insert culminations into array of heights */ + for (i = 0; i <= nculm; i++) { + for (j = 1; j <= jmax; j++) { + if (tculm[i] < tc[j]) { + for (k = jmax; k >= j; k--) { + tc[k + 1] = tc[k]; + h[k + 1] = h[k]; + } + tc[j] = tculm[i]; + if (!do_fixstar) { + te = tc[j] + swe_deltat(tc[j]); + if (swe_calc(te, ipl, iflag, xc, serr) == ERR) + return ERR; + } + curdist = xc[2]; + if (rsmi & SE_BIT_FIXED_DISC_SIZE) { + if (ipl == SE_SUN) { + curdist = 1.0; + } + else if (ipl == SE_MOON) { + curdist = 0.00257; + } + } + /* apparent radius of disc */ + rdi = asin(dd / 2 / AUNIT / curdist) * RADTODEG; + /* true height of center of body */ + swe_azalt(tc[j], SE_EQU2HOR, geopos, atpress, attemp, xc, ah); + if (rsmi & SE_BIT_DISC_BOTTOM) { + /* true height of bottom point of body */ + ah[1] -= rdi; + } + else { + /* true height of uppermost point of body */ + ah[1] += rdi; + } + /* apparent height of uppermost point of body */ + if (rsmi & SE_BIT_NO_REFRACTION) { + ah[1] -= horhgt; + h[j] = ah[1]; + } + else { + swe_azalt_rev(tc[j], SE_HOR2EQU, geopos, ah, xc); + swe_azalt(tc[j], SE_EQU2HOR, geopos, atpress, attemp, xc, + ah); + ah[1] -= horhgt; + ah[2] -= horhgt; + h[j] = ah[2]; + } + jmax++; + break; + } + } } - } - if (serr) - sprintf(serr, "rise or set not found for planet %d", ipl); - return -2; /* no t of rise or set found */ + *tret = 0; + /* find points with zero height. + * binary search */ + for (ii = 1; ii <= jmax; ii++) { + if (h[ii - 1] * h[ii] >= 0) + continue; + if (h[ii - 1] < h[ii] && !(rsmi & SE_CALC_RISE)) + continue; + if (h[ii - 1] > h[ii] && !(rsmi & SE_CALC_SET)) + continue; + dc[0] = h[ii - 1]; + dc[1] = h[ii]; + t2[0] = tc[ii - 1]; + t2[1] = tc[ii]; + for (i = 0; i < 20; i++) { + t = (t2[0] + t2[1]) / 2; + if (!do_fixstar) { + te = t + swe_deltat(t); + if (swe_calc(te, ipl, iflag, xc, serr) == ERR) + return ERR; + } + curdist = xc[2]; + if (rsmi & SE_BIT_FIXED_DISC_SIZE) { + if (ipl == SE_SUN) { + curdist = 1.0; + } + else if (ipl == SE_MOON) { + curdist = 0.00257; + } + } + /* apparent radius of disc */ + rdi = asin(dd / 2 / AUNIT / curdist) * RADTODEG; + /* true height of center of body */ + swe_azalt(t, SE_EQU2HOR, geopos, atpress, attemp, xc, ah); + if (rsmi & SE_BIT_DISC_BOTTOM) { + /* true height of bottom point of body */ + ah[1] -= rdi; + } + else { + /* true height of uppermost point of body */ + ah[1] += rdi; + } + /* apparent height of uppermost point of body */ + if (rsmi & SE_BIT_NO_REFRACTION) { + ah[1] -= horhgt; + aha = ah[1]; + } + else { + swe_azalt_rev(t, SE_HOR2EQU, geopos, ah, xc); + swe_azalt(t, SE_EQU2HOR, geopos, atpress, attemp, xc, ah); + ah[1] -= horhgt; + ah[2] -= horhgt; + aha = ah[2]; + } + if (aha * dc[0] <= 0) { + dc[1] = aha; + t2[1] = t; + } + else { + dc[0] = aha; + t2[0] = t; + } + } + if (t > tjd_ut) { + *tret = t; + return OK; + } + } + if (serr) + sprintf(serr, "rise or set not found for planet %d", ipl); + return -2; /* no t of rise or set found */ } -static int32 calc_mer_trans( - double tjd_ut, int32 ipl, int32 epheflag, int32 rsmi, - double *geopos, - char *starname, - double *tret, - char *serr) +static int32 +calc_mer_trans(double tjd_ut, int32 ipl, int32 epheflag, int32 rsmi, + double *geopos, char *starname, double *tret, char *serr) { - int i; - double tjd_et = tjd_ut + swe_deltat(tjd_ut); - double armc, armc0, arxc, x0[6], x[6], t, te; - double mdd; - int32 iflag = epheflag; - AS_BOOL do_fixstar = (starname != NULL && *starname != '\0'); - iflag &= SEFLG_EPHMASK; - *tret = 0; - iflag |= (SEFLG_EQUATORIAL | SEFLG_TOPOCTR); - armc0 = swe_sidtime(tjd_ut) + geopos[0] / 15; - if (armc0 >= 24) - armc0 -= 24; - if (armc0 < 0) - armc0 += 24; - armc0 *= 15; - if (do_fixstar) { - if (swe_fixstar(starname, tjd_et, iflag, x0, serr) == ERR) - return ERR; - } else { - if (swe_calc(tjd_et, ipl, iflag, x0, serr) == ERR) - return ERR; - } - /* - * meridian transits - */ + int i; + double tjd_et = tjd_ut + swe_deltat(tjd_ut); + double armc, armc0, arxc, x0[6], x[6], t, te; + double mdd; + int32 iflag = epheflag; + AS_BOOL do_fixstar = (starname != NULL && *starname != '\0'); + iflag &= SEFLG_EPHMASK; + *tret = 0; + iflag |= (SEFLG_EQUATORIAL | SEFLG_TOPOCTR); + armc0 = swe_sidtime(tjd_ut) + geopos[0] / 15; + if (armc0 >= 24) + armc0 -= 24; + if (armc0 < 0) + armc0 += 24; + armc0 *= 15; + if (do_fixstar) { + if (swe_fixstar(starname, tjd_et, iflag, x0, serr) == ERR) + return ERR; + } + else { + if (swe_calc(tjd_et, ipl, iflag, x0, serr) == ERR) + return ERR; + } + /* + * meridian transits + */ x[0] = x0[0]; x[1] = x0[1]; t = tjd_ut; arxc = armc0; if (rsmi & SE_CALC_ITRANSIT) - arxc = swe_degnorm(arxc + 180); - for (i = 0; i < 4; i++) { - mdd = swe_degnorm(x[0] - arxc); - if (i > 0 && mdd > 180) - mdd -= 360; - t += mdd / 361; - armc = swe_sidtime(t) + geopos[0] / 15; - if (armc >= 24) - armc -= 24; - if (armc < 0) - armc += 24; - armc *= 15; - arxc = armc; - if (rsmi & SE_CALC_ITRANSIT) arxc = swe_degnorm(arxc + 180); - if (!do_fixstar) { - te = t + swe_deltat(t); - if (swe_calc(te, ipl, iflag, x, serr) == ERR) - return ERR; - } + for (i = 0; i < 4; i++) { + mdd = swe_degnorm(x[0] - arxc); + if (i > 0 && mdd > 180) + mdd -= 360; + t += mdd / 361; + armc = swe_sidtime(t) + geopos[0] / 15; + if (armc >= 24) + armc -= 24; + if (armc < 0) + armc += 24; + armc *= 15; + arxc = armc; + if (rsmi & SE_CALC_ITRANSIT) + arxc = swe_degnorm(arxc + 180); + if (!do_fixstar) { + te = t + swe_deltat(t); + if (swe_calc(te, ipl, iflag, x, serr) == ERR) + return ERR; + } } - *tret = t; - return OK; + *tret = t; + return OK; } /* @@ -4246,652 +4430,720 @@ barycentric position. * bits. The second focal points of the ellipses will * be returned instead of the aphelia. */ + /* mean elements for Mercury - Neptune from VSOP87 (mean equinox of date) */ -static double el_node[8][4] = - {{ 48.330893, 1.1861890, 0.00017587, 0.000000211,}, /* Mercury */ - { 76.679920, 0.9011190, 0.00040665, -0.000000080,}, /* Venus */ - { 0 , 0 , 0 , 0 ,}, /* Earth */ - { 49.558093, 0.7720923, 0.00001605, 0.000002325,}, /* Mars */ - {100.464441, 1.0209550, 0.00040117, 0.000000569,}, /* Jupiter */ - {113.665524, 0.8770970, -0.00012067, -0.000002380,}, /* Saturn */ - { 74.005947, 0.5211258, 0.00133982, 0.000018516,}, /* Uranus */ - {131.784057, 1.1022057, 0.00026006, -0.000000636,}, /* Neptune */ - }; -static double el_peri[8][4] = - {{ 77.456119, 1.5564775, 0.00029589, 0.000000056,}, /* Mercury */ - {131.563707, 1.4022188, -0.00107337, -0.000005315,}, /* Venus */ - {102.937348, 1.7195269, 0.00045962, 0.000000499,}, /* Earth */ - {336.060234, 1.8410331, 0.00013515, 0.000000318,}, /* Mars */ - { 14.331309, 1.6126668, 0.00103127, -0.000004569,}, /* Jupiter */ - { 93.056787, 1.9637694, 0.00083757, 0.000004899,}, /* Saturn */ - {173.005159, 1.4863784, 0.00021450, 0.000000433,}, /* Uranus */ - { 48.123691, 1.4262677, 0.00037918, -0.000000003,}, /* Neptune */ - }; -static double el_incl[8][4] = - {{ 7.004986, 0.0018215, -0.00001809, 0.000000053,}, /* Mercury */ - { 3.394662, 0.0010037, -0.00000088, -0.000000007,}, /* Venus */ - { 0, 0, 0, 0 ,}, /* Earth */ - { 1.849726, -0.0006010, 0.00001276, -0.000000006,}, /* Mars */ - { 1.303270, -0.0054966, 0.00000465, -0.000000004,}, /* Jupiter */ - { 2.488878, -0.0037363, -0.00001516, 0.000000089,}, /* Saturn */ - { 0.773196, 0.0007744, 0.00003749, -0.000000092,}, /* Uranus */ - { 1.769952, -0.0093082, -0.00000708, 0.000000028,}, /* Neptune */ - }; -static double el_ecce[8][4] = - {{ 0.20563175, 0.000020406, -0.0000000284, -0.00000000017,}, /* Mercury */ - { 0.00677188, -0.000047766, 0.0000000975, 0.00000000044,}, /* Venus */ - { 0.01670862, -0.000042037, -0.0000001236, 0.00000000004,}, /* Earth */ - { 0.09340062, 0.000090483, -0.0000000806, -0.00000000035,}, /* Mars */ - { 0.04849485, 0.000163244, -0.0000004719, -0.00000000197,}, /* Jupiter */ - { 0.05550862, -0.000346818, -0.0000006456, 0.00000000338,}, /* Saturn */ - { 0.04629590, -0.000027337, 0.0000000790, 0.00000000025,}, /* Uranus */ - { 0.00898809, 0.000006408, -0.0000000008, -0.00000000005,}, /* Neptune */ - }; -static double el_sema[8][4] = - {{ 0.387098310, 0.0, 0.0, 0.0,}, /* Mercury */ - { 0.723329820, 0.0, 0.0, 0.0,}, /* Venus */ - { 1.000001018, 0.0, 0.0, 0.0,}, /* Earth */ - { 1.523679342, 0.0, 0.0, 0.0,}, /* Mars */ - { 5.202603191, 0.0000001913, 0.0, 0.0,}, /* Jupiter */ - { 9.554909596, 0.0000021389, 0.0, 0.0,}, /* Saturn */ - { 19.218446062, -0.0000000372, 0.00000000098, 0.0,}, /* Uranus */ - { 30.110386869, -0.0000001663, 0.00000000069, 0.0,}, /* Neptune */ - }; +static double el_node[8][4] = { {48.330893, 1.1861890, 0.00017587, 0.000000211,}, /* Mercury */ +{76.679920, 0.9011190, 0.00040665, -0.000000080,}, /* Venus */ +{0, 0, 0, 0,}, /* Earth */ +{49.558093, 0.7720923, 0.00001605, 0.000002325,}, /* Mars */ +{100.464441, 1.0209550, 0.00040117, 0.000000569,}, /* Jupiter */ +{113.665524, 0.8770970, -0.00012067, -0.000002380,}, /* Saturn */ +{74.005947, 0.5211258, 0.00133982, 0.000018516,}, /* Uranus */ +{131.784057, 1.1022057, 0.00026006, -0.000000636,}, /* Neptune */ +}; +static double el_peri[8][4] = { {77.456119, 1.5564775, 0.00029589, 0.000000056,}, /* Mercury */ +{131.563707, 1.4022188, -0.00107337, -0.000005315,}, /* Venus */ +{102.937348, 1.7195269, 0.00045962, 0.000000499,}, /* Earth */ +{336.060234, 1.8410331, 0.00013515, 0.000000318,}, /* Mars */ +{14.331309, 1.6126668, 0.00103127, -0.000004569,}, /* Jupiter */ +{93.056787, 1.9637694, 0.00083757, 0.000004899,}, /* Saturn */ +{173.005159, 1.4863784, 0.00021450, 0.000000433,}, /* Uranus */ +{48.123691, 1.4262677, 0.00037918, -0.000000003,}, /* Neptune */ +}; +static double el_incl[8][4] = { {7.004986, 0.0018215, -0.00001809, 0.000000053,}, /* Mercury */ +{3.394662, 0.0010037, -0.00000088, -0.000000007,}, /* Venus */ +{0, 0, 0, 0,}, /* Earth */ +{1.849726, -0.0006010, 0.00001276, -0.000000006,}, /* Mars */ +{1.303270, -0.0054966, 0.00000465, -0.000000004,}, /* Jupiter */ +{2.488878, -0.0037363, -0.00001516, 0.000000089,}, /* Saturn */ +{0.773196, 0.0007744, 0.00003749, -0.000000092,}, /* Uranus */ +{1.769952, -0.0093082, -0.00000708, 0.000000028,}, /* Neptune */ +}; +static double el_ecce[8][4] = { {0.20563175, 0.000020406, -0.0000000284, -0.00000000017,}, /* Mercury */ +{0.00677188, -0.000047766, 0.0000000975, 0.00000000044,}, /* Venus */ +{0.01670862, -0.000042037, -0.0000001236, 0.00000000004,}, /* Earth */ +{0.09340062, 0.000090483, -0.0000000806, -0.00000000035,}, /* Mars */ +{0.04849485, 0.000163244, -0.0000004719, -0.00000000197,}, /* Jupiter */ +{0.05550862, -0.000346818, -0.0000006456, 0.00000000338,}, /* Saturn */ +{0.04629590, -0.000027337, 0.0000000790, 0.00000000025,}, /* Uranus */ +{0.00898809, 0.000006408, -0.0000000008, -0.00000000005,}, /* Neptune */ +}; +static double el_sema[8][4] = { {0.387098310, 0.0, 0.0, 0.0,}, /* Mercury */ +{0.723329820, 0.0, 0.0, 0.0,}, /* Venus */ +{1.000001018, 0.0, 0.0, 0.0,}, /* Earth */ +{1.523679342, 0.0, 0.0, 0.0,}, /* Mars */ +{5.202603191, 0.0000001913, 0.0, 0.0,}, /* Jupiter */ +{9.554909596, 0.0000021389, 0.0, 0.0,}, /* Saturn */ +{19.218446062, -0.0000000372, 0.00000000098, 0.0,}, /* Uranus */ +{30.110386869, -0.0000001663, 0.00000000069, 0.0,}, /* Neptune */ +}; + /* Ratios of mass of Sun to masses of the planets */ static double plmass[9] = { - 6023600, /* Mercury */ - 408523.5, /* Venus */ - 328900.5, /* Earth and Moon */ - 3098710, /* Mars */ - 1047.350, /* Jupiter */ - 3498.0, /* Saturn */ - 22960, /* Uranus */ - 19314, /* Neptune */ - 130000000, /* Pluto */ + 6023600, /* Mercury */ + 408523.5, /* Venus */ + 328900.5, /* Earth and Moon */ + 3098710, /* Mars */ + 1047.350, /* Jupiter */ + 3498.0, /* Saturn */ + 22960, /* Uranus */ + 19314, /* Neptune */ + 130000000, /* Pluto */ }; -static int ipl_to_elem[15] = {2, 0, 0, 1, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 2,}; -int32 FAR PASCAL_CONV swe_nod_aps(double tjd_et, int32 ipl, int32 iflag, - int32 method, - double *xnasc, double *xndsc, - double *xperi, double *xaphe, - char *serr) +static int ipl_to_elem[15] = { 2, 0, 0, 1, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 2, }; + +int32 FAR PASCAL_CONV +swe_nod_aps(double tjd_et, int32 ipl, int32 iflag, int32 method, + double *xnasc, double *xndsc, double *xperi, double *xaphe, + char *serr) { - int ij, i, j; - int32 iplx; - int32 ipli; - int istart, iend; - int32 iflJ2000; - double plm; - double t = (tjd_et - J2000) / 36525, dt; - double x[6], xx[24], *xp, xobs[6], x2000[6]; - double xpos[3][6], xnorm[6]; - double xposm[6]; - double xn[3][6], xs[3][6]; - double xq[3][6], xa[3][6]; - double xobs2[6], x2[6]; - double *xna, *xnd, *xpe, *xap; - double incl, sema, ecce, parg, ea, vincl, vsema, vecce, pargx, eax; - struct plan_data *pedp = &swed.pldat[SEI_EARTH]; - struct plan_data *psbdp = &swed.pldat[SEI_SUNBARY]; - struct plan_data pldat; - double *xsun = psbdp->x; - double *xear = pedp->x; - double *ep; - double Gmsm, dzmin; - double rxy, rxyz, fac, sgn; - double sinnode, cosnode, sinincl, cosincl, sinu, cosu, sinE, cosE, cosE2; - double uu, ny, ny2, c2, v2, pp, ro, ro2, rn, rn2; - struct epsilon *oe; - AS_BOOL is_true_nodaps = FALSE; - AS_BOOL do_aberr = !(iflag & (SEFLG_TRUEPOS | SEFLG_NOABERR)); - AS_BOOL do_defl = !(iflag & SEFLG_TRUEPOS) && !(iflag & SEFLG_NOGDEFL); - AS_BOOL do_focal_point = method & SE_NODBIT_FOPOINT; - AS_BOOL ellipse_is_bary = FALSE; - int32 iflg0; - /* function calls for Pluto with asteroid number 134340 - * are treated as calls for Pluto as main body SE_PLUTO */ - if (ipl == SE_AST_OFFSET + 134340) - ipl = SE_PLUTO; - xna = xx; - xnd = xx+6; - xpe = xx+12; - xap = xx+18; - xpos[0][0] = 0; /* to shut up mint */ - /* to get control over the save area: */ - swi_force_app_pos_etc(); - method %= SE_NODBIT_FOPOINT; - ipli = ipl; - if (ipl == SE_SUN) - ipli = SE_EARTH; - if (ipl == SE_MOON) { - do_defl = FALSE; - if (!(iflag & SEFLG_HELCTR)) - do_aberr = FALSE; - } - iflg0 = (iflag & (SEFLG_EPHMASK|SEFLG_NONUT)) | SEFLG_SPEED | SEFLG_TRUEPOS; - if (ipli != SE_MOON) - iflg0 |= SEFLG_HELCTR; - if (ipl == SE_MEAN_NODE || ipl == SE_TRUE_NODE || - ipl == SE_MEAN_APOG || ipl == SE_OSCU_APOG || - ipl < 0 || - (ipl >= SE_NPLANETS && ipl <= SE_AST_OFFSET)) { - /*(ipl >= SE_FICT_OFFSET && ipl - SE_FICT_OFFSET < SE_NFICT_ELEM)) */ - if (serr != NULL) - sprintf(serr, "nodes/apsides for planet %5.0f are not implemented", (double) ipl); - if (xnasc != NULL) - for (i = 0; i <= 5; i++) - xnasc[i] = 0; - if (xndsc != NULL) - for (i = 0; i <= 5; i++) - xndsc[i] = 0; - if (xaphe != NULL) - for (i = 0; i <= 5; i++) - xaphe[i] = 0; - if (xperi != NULL) - for (i = 0; i <= 5; i++) - xperi[i] = 0; - return ERR; - } - for (i = 0; i < 24; i++) - xx[i] = 0; + int ij, i, j; + int32 iplx; + int32 ipli; + int istart, iend; + int32 iflJ2000; + double plm; + double t = (tjd_et - J2000) / 36525, dt; + double x[6], xx[24], *xp, xobs[6], x2000[6]; + double xpos[3][6], xnorm[6]; + double xposm[6]; + double xn[3][6], xs[3][6]; + double xq[3][6], xa[3][6]; + double xobs2[6], x2[6]; + double *xna, *xnd, *xpe, *xap; + double incl, sema, ecce, parg, ea, vincl, vsema, vecce, pargx, eax; + struct plan_data *pedp = &swed.pldat[SEI_EARTH]; + struct plan_data *psbdp = &swed.pldat[SEI_SUNBARY]; + struct plan_data pldat; + double *xsun = psbdp->x; + double *xear = pedp->x; + double *ep; + double Gmsm, dzmin; + double rxy, rxyz, fac, sgn; + double sinnode, cosnode, sinincl, cosincl, sinu, cosu, sinE, cosE, cosE2; + double uu, ny, ny2, c2, v2, pp, ro, ro2, rn, rn2; + struct epsilon *oe; + AS_BOOL is_true_nodaps = FALSE; + AS_BOOL do_aberr = !(iflag & (SEFLG_TRUEPOS | SEFLG_NOABERR)); + AS_BOOL do_defl = !(iflag & SEFLG_TRUEPOS) && !(iflag & SEFLG_NOGDEFL); + AS_BOOL do_focal_point = method & SE_NODBIT_FOPOINT; + AS_BOOL ellipse_is_bary = FALSE; + int32 iflg0; + /* function calls for Pluto with asteroid number 134340 + * are treated as calls for Pluto as main body SE_PLUTO */ + if (ipl == SE_AST_OFFSET + 134340) + ipl = SE_PLUTO; + xna = xx; + xnd = xx + 6; + xpe = xx + 12; + xap = xx + 18; + xpos[0][0] = 0; /* to shut up mint */ + /* to get control over the save area: */ + swi_force_app_pos_etc(); + method %= SE_NODBIT_FOPOINT; + ipli = ipl; + if (ipl == SE_SUN) + ipli = SE_EARTH; + if (ipl == SE_MOON) { + do_defl = FALSE; + if (!(iflag & SEFLG_HELCTR)) + do_aberr = FALSE; + } + iflg0 = + (iflag & (SEFLG_EPHMASK | SEFLG_NONUT)) | SEFLG_SPEED | SEFLG_TRUEPOS; + if (ipli != SE_MOON) + iflg0 |= SEFLG_HELCTR; + if (ipl == SE_MEAN_NODE || ipl == SE_TRUE_NODE || ipl == SE_MEAN_APOG + || ipl == SE_OSCU_APOG || ipl < 0 || (ipl >= SE_NPLANETS + && ipl <= SE_AST_OFFSET)) { + /*(ipl >= SE_FICT_OFFSET && ipl - SE_FICT_OFFSET < SE_NFICT_ELEM)) */ + if (serr != NULL) + sprintf(serr, + "nodes/apsides for planet %5.0f are not implemented", + (double)ipl); + if (xnasc != NULL) + for (i = 0; i <= 5; i++) + xnasc[i] = 0; + if (xndsc != NULL) + for (i = 0; i <= 5; i++) + xndsc[i] = 0; + if (xaphe != NULL) + for (i = 0; i <= 5; i++) + xaphe[i] = 0; + if (xperi != NULL) + for (i = 0; i <= 5; i++) + xperi[i] = 0; + return ERR; + } + for (i = 0; i < 24; i++) + xx[i] = 0; + /*************************************** * mean nodes and apsides ***************************************/ - /* mean points only for Sun - Neptune */ - if ((method == 0 || (method & SE_NODBIT_MEAN)) && - ((ipl >= SE_SUN && ipl <= SE_NEPTUNE) || ipl == SE_EARTH)) { - if (ipl == SE_MOON) { - swi_mean_lunar_elements(tjd_et, &xna[0], &xna[3], &xpe[0], &xpe[3]); - incl = MOON_MEAN_INCL; - vincl = 0; - ecce = MOON_MEAN_ECC; - vecce = 0; - sema = MOON_MEAN_DIST / AUNIT; - vsema = 0; - } else { - iplx = ipl_to_elem[ipl]; - ep = el_incl[iplx]; - incl = ep[0] + ep[1] * t + ep[2] * t * t + ep[3] * t * t * t; - vincl = ep[1] / 36525; - ep = el_sema[iplx]; - sema = ep[0] + ep[1] * t + ep[2] * t * t + ep[3] * t * t * t; - vsema = ep[1] / 36525; - ep = el_ecce[iplx]; - ecce = ep[0] + ep[1] * t + ep[2] * t * t + ep[3] * t * t * t; - vecce = ep[1] / 36525; - ep = el_node[iplx]; - /* ascending node */ - xna[0] = ep[0] + ep[1] * t + ep[2] * t * t + ep[3] * t * t * t; - xna[3] = ep[1] / 36525; - /* perihelion */ - ep = el_peri[iplx]; - xpe[0] = ep[0] + ep[1] * t + ep[2] * t * t + ep[3] * t * t * t; - xpe[3] = ep[1] / 36525; - } - /* descending node */ - xnd[0] = swe_degnorm(xna[0] + 180); - xnd[3] = xna[3]; - /* angular distance of perihelion from node */ - parg = xpe[0] = swe_degnorm(xpe[0] - xna[0]); - pargx = xpe[3] = swe_degnorm(xpe[0] + xpe[3] - xna[3]); - /* transform from orbital plane to mean ecliptic of date */ - swe_cotrans(xpe, xpe, -incl); - /* xpe+3 is aux. position, not speed!!! */ - swe_cotrans(xpe+3, xpe+3, -incl-vincl); - /* add node again */ - xpe[0] = swe_degnorm(xpe[0] + xna[0]); - /* xpe+3 is aux. position, not speed!!! */ - xpe[3] = swe_degnorm(xpe[3] + xna[0] + xna[3]); - /* speed */ - xpe[3] = swe_degnorm(xpe[3] - xpe[0]); - /* heliocentric distance of perihelion and aphelion */ - xpe[2] = sema * (1 - ecce); - xpe[5] = (sema + vsema) * (1 - ecce - vecce) - xpe[2]; - /* aphelion */ - xap[0] = swe_degnorm(xpe[0] + 180); - xap[1] = -xpe[1]; - xap[3] = xpe[3]; - xap[4] = -xpe[4]; - if (do_focal_point) { - xap[2] = sema * ecce * 2; - xap[5] = (sema + vsema) * (ecce + vecce) * 2 - xap[2]; - } else { - xap[2] = sema * (1 + ecce); - xap[5] = (sema + vsema) * (1 + ecce + vecce) - xap[2]; - } - /* heliocentric distance of nodes */ - ea = atan(tan(-parg * DEGTORAD / 2) * sqrt((1-ecce)/(1+ecce))) * 2; - eax = atan(tan(-pargx * DEGTORAD / 2) * sqrt((1-ecce-vecce)/(1+ecce+vecce))) * 2; - xna[2] = sema * (cos(ea) - ecce) / cos(parg * DEGTORAD); - xna[5] = (sema+vsema) * (cos(eax) - ecce - vecce) / cos(pargx * DEGTORAD); - xna[5] -= xna[2]; - ea = atan(tan((180 - parg) * DEGTORAD / 2) * sqrt((1-ecce)/(1+ecce))) * 2; - eax = atan(tan((180 - pargx) * DEGTORAD / 2) * sqrt((1-ecce-vecce)/(1+ecce+vecce))) * 2; - xnd[2] = sema * (cos(ea) - ecce) / cos((180 - parg) * DEGTORAD); - xnd[5] = (sema+vsema) * (cos(eax) - ecce - vecce) / cos((180 - pargx) * DEGTORAD); - xnd[5] -= xnd[2]; - /* no light-time correction because speed is extremely small */ - for (i = 0, xp = xx; i < 4; i++, xp += 6) { - /* to cartesian coordinates */ - xp[0] *= DEGTORAD; - xp[1] *= DEGTORAD; - xp[3] *= DEGTORAD; - xp[4] *= DEGTORAD; - swi_polcart_sp(xp, xp); - } + /* mean points only for Sun - Neptune */ + if ((method == 0 || (method & SE_NODBIT_MEAN)) + && ((ipl >= SE_SUN && ipl <= SE_NEPTUNE) || ipl == SE_EARTH)) { + if (ipl == SE_MOON) { + swi_mean_lunar_elements(tjd_et, &xna[0], &xna[3], &xpe[0], + &xpe[3]); + incl = MOON_MEAN_INCL; + vincl = 0; + ecce = MOON_MEAN_ECC; + vecce = 0; + sema = MOON_MEAN_DIST / AUNIT; + vsema = 0; + } + else { + iplx = ipl_to_elem[ipl]; + ep = el_incl[iplx]; + incl = ep[0] + ep[1] * t + ep[2] * t * t + ep[3] * t * t * t; + vincl = ep[1] / 36525; + ep = el_sema[iplx]; + sema = ep[0] + ep[1] * t + ep[2] * t * t + ep[3] * t * t * t; + vsema = ep[1] / 36525; + ep = el_ecce[iplx]; + ecce = ep[0] + ep[1] * t + ep[2] * t * t + ep[3] * t * t * t; + vecce = ep[1] / 36525; + ep = el_node[iplx]; + /* ascending node */ + xna[0] = ep[0] + ep[1] * t + ep[2] * t * t + ep[3] * t * t * t; + xna[3] = ep[1] / 36525; + /* perihelion */ + ep = el_peri[iplx]; + xpe[0] = ep[0] + ep[1] * t + ep[2] * t * t + ep[3] * t * t * t; + xpe[3] = ep[1] / 36525; + } + /* descending node */ + xnd[0] = swe_degnorm(xna[0] + 180); + xnd[3] = xna[3]; + /* angular distance of perihelion from node */ + parg = xpe[0] = swe_degnorm(xpe[0] - xna[0]); + pargx = xpe[3] = swe_degnorm(xpe[0] + xpe[3] - xna[3]); + /* transform from orbital plane to mean ecliptic of date */ + swe_cotrans(xpe, xpe, -incl); + /* xpe+3 is aux. position, not speed!!! */ + swe_cotrans(xpe + 3, xpe + 3, -incl - vincl); + /* add node again */ + xpe[0] = swe_degnorm(xpe[0] + xna[0]); + /* xpe+3 is aux. position, not speed!!! */ + xpe[3] = swe_degnorm(xpe[3] + xna[0] + xna[3]); + /* speed */ + xpe[3] = swe_degnorm(xpe[3] - xpe[0]); + /* heliocentric distance of perihelion and aphelion */ + xpe[2] = sema * (1 - ecce); + xpe[5] = (sema + vsema) * (1 - ecce - vecce) - xpe[2]; + /* aphelion */ + xap[0] = swe_degnorm(xpe[0] + 180); + xap[1] = -xpe[1]; + xap[3] = xpe[3]; + xap[4] = -xpe[4]; + if (do_focal_point) { + xap[2] = sema * ecce * 2; + xap[5] = (sema + vsema) * (ecce + vecce) * 2 - xap[2]; + } + else { + xap[2] = sema * (1 + ecce); + xap[5] = (sema + vsema) * (1 + ecce + vecce) - xap[2]; + } + /* heliocentric distance of nodes */ + ea = atan(tan(-parg * DEGTORAD / 2) * sqrt((1 - ecce) / (1 + ecce))) * + 2; + eax = + atan(tan(-pargx * DEGTORAD / 2) * + sqrt((1 - ecce - vecce) / (1 + ecce + vecce))) * 2; + xna[2] = sema * (cos(ea) - ecce) / cos(parg * DEGTORAD); + xna[5] = + (sema + vsema) * (cos(eax) - ecce - + vecce) / cos(pargx * DEGTORAD); + xna[5] -= xna[2]; + ea = atan(tan((180 - parg) * DEGTORAD / 2) * + sqrt((1 - ecce) / (1 + ecce))) * 2; + eax = + atan(tan((180 - pargx) * DEGTORAD / 2) * + sqrt((1 - ecce - vecce) / (1 + ecce + vecce))) * 2; + xnd[2] = sema * (cos(ea) - ecce) / cos((180 - parg) * DEGTORAD); + xnd[5] = + (sema + vsema) * (cos(eax) - ecce - + vecce) / cos((180 - pargx) * DEGTORAD); + xnd[5] -= xnd[2]; + /* no light-time correction because speed is extremely small */ + for (i = 0, xp = xx; i < 4; i++, xp += 6) { + /* to cartesian coordinates */ + xp[0] *= DEGTORAD; + xp[1] *= DEGTORAD; + xp[3] *= DEGTORAD; + xp[4] *= DEGTORAD; + swi_polcart_sp(xp, xp); + } + /*************************************** * "true" or osculating nodes and apsides ***************************************/ - } else { - /* first, we need a heliocentric distance of the planet */ - if (swe_calc(tjd_et, ipli, iflg0, x, serr) == ERR) - return ERR; - iflJ2000 = (iflag & SEFLG_EPHMASK)|SEFLG_J2000|SEFLG_EQUATORIAL|SEFLG_XYZ|SEFLG_TRUEPOS|SEFLG_NONUT|SEFLG_SPEED; - ellipse_is_bary = FALSE; - if (ipli != SE_MOON) { - if ((method & SE_NODBIT_OSCU_BAR) && x[2] > 6) { - iflJ2000 |= SEFLG_BARYCTR; /* only planets beyond Jupiter */ - ellipse_is_bary = TRUE; - } else { - iflJ2000 |= SEFLG_HELCTR; - } } - /* we need three positions and three speeds - * for three nodes/apsides. from the three node positions, - * the speed of the node will be computed. */ - if (ipli == SE_MOON) { - dt = NODE_CALC_INTV; - dzmin = 1e-15; - Gmsm = GEOGCONST * (1 + 1 / EARTH_MOON_MRAT) /AUNIT/AUNIT/AUNIT*86400.0*86400.0; - } else { - if ((ipli >= SE_MERCURY && ipli <= SE_PLUTO) || ipli == SE_EARTH) - plm = 1 / plmass[ipl_to_elem[ipl]]; - else - plm = 0; - dt = NODE_CALC_INTV * 10 * x[2]; - dzmin = 1e-15 * dt / NODE_CALC_INTV; - Gmsm = HELGRAVCONST * (1 + plm) /AUNIT/AUNIT/AUNIT*86400.0*86400.0; + else { + /* first, we need a heliocentric distance of the planet */ + if (swe_calc(tjd_et, ipli, iflg0, x, serr) == ERR) + return ERR; + iflJ2000 = + (iflag & SEFLG_EPHMASK) | SEFLG_J2000 | SEFLG_EQUATORIAL | + SEFLG_XYZ | SEFLG_TRUEPOS | SEFLG_NONUT | SEFLG_SPEED; + ellipse_is_bary = FALSE; + if (ipli != SE_MOON) { + if ((method & SE_NODBIT_OSCU_BAR) && x[2] > 6) { + iflJ2000 |= SEFLG_BARYCTR; /* only planets beyond Jupiter */ + ellipse_is_bary = TRUE; + } + else { + iflJ2000 |= SEFLG_HELCTR; + } + } + /* we need three positions and three speeds + * for three nodes/apsides. from the three node positions, + * the speed of the node will be computed. */ + if (ipli == SE_MOON) { + dt = NODE_CALC_INTV; + dzmin = 1e-15; + Gmsm = + GEOGCONST * (1 + + 1 / EARTH_MOON_MRAT) / AUNIT / AUNIT / AUNIT * + 86400.0 * 86400.0; + } + else { + if ((ipli >= SE_MERCURY && ipli <= SE_PLUTO) || ipli == SE_EARTH) + plm = 1 / plmass[ipl_to_elem[ipl]]; + else + plm = 0; + dt = NODE_CALC_INTV * 10 * x[2]; + dzmin = 1e-15 * dt / NODE_CALC_INTV; + Gmsm = + HELGRAVCONST * (1 + + plm) / AUNIT / AUNIT / AUNIT * 86400.0 * + 86400.0; + } + if (iflag & SEFLG_SPEED) { + istart = 0; + iend = 2; + } + else { + istart = iend = 0; + dt = 0; + } + for (i = istart, t = tjd_et - dt; i <= iend; i++, t += dt) { + if (istart == iend) + t = tjd_et; + if (swe_calc(t, ipli, iflJ2000, xpos[i], serr) == ERR) + return ERR; + /* the EMB is used instead of the earth */ + if (ipli == SE_EARTH) { + if (swe_calc + (t, SE_MOON, iflJ2000 & ~(SEFLG_BARYCTR | SEFLG_HELCTR), + xposm, serr) == ERR) + return ERR; + for (j = 0; j <= 2; j++) + xpos[i][j] += xposm[j] / (EARTH_MOON_MRAT + 1.0); + } + swi_plan_for_osc_elem(iflg0, t, xpos[i]); + } + for (i = istart; i <= iend; i++) { + if (fabs(xpos[i][5]) < dzmin) + xpos[i][5] = dzmin; + fac = xpos[i][2] / xpos[i][5]; + sgn = xpos[i][5] / fabs(xpos[i][5]); + for (j = 0; j <= 2; j++) { + xn[i][j] = (xpos[i][j] - fac * xpos[i][j + 3]) * sgn; + xs[i][j] = -xn[i][j]; + } + } + for (i = istart; i <= iend; i++) { + /* node */ + rxy = sqrt(xn[i][0] * xn[i][0] + xn[i][1] * xn[i][1]); + cosnode = xn[i][0] / rxy; + sinnode = xn[i][1] / rxy; + /* inclination */ + swi_cross_prod(xpos[i], xpos[i] + 3, xnorm); + rxy = xnorm[0] * xnorm[0] + xnorm[1] * xnorm[1]; + c2 = (rxy + xnorm[2] * xnorm[2]); + rxyz = sqrt(c2); + rxy = sqrt(rxy); + sinincl = rxy / rxyz; + cosincl = sqrt(1 - sinincl * sinincl); + if (xnorm[2] < 0) + cosincl = -cosincl; /* retrograde asteroid, e.g. 20461 Dioretsa */ + /* argument of latitude */ + cosu = xpos[i][0] * cosnode + xpos[i][1] * sinnode; + sinu = xpos[i][2] / sinincl; + uu = atan2(sinu, cosu); + /* semi-axis */ + rxyz = sqrt(square_sum(xpos[i])); + v2 = square_sum((xpos[i] + 3)); + sema = 1 / (2 / rxyz - v2 / Gmsm); + /* eccentricity */ + pp = c2 / Gmsm; + ecce = sqrt(1 - pp / sema); + /* eccentric anomaly */ + cosE = 1 / ecce * (1 - rxyz / sema); + sinE = + 1 / ecce / sqrt(sema * Gmsm) * dot_prod(xpos[i], + (xpos[i] + 3)); + /* true anomaly */ + ny = 2 * atan(sqrt((1 + ecce) / (1 - ecce)) * sinE / (1 + cosE)); + /* distance of perihelion from ascending node */ + xq[i][0] = swi_mod2PI(uu - ny); + xq[i][1] = 0; /* latitude */ + xq[i][2] = sema * (1 - ecce); /* distance of perihelion */ + /* transformation to ecliptic coordinates */ + swi_polcart(xq[i], xq[i]); + swi_coortrf2(xq[i], xq[i], -sinincl, cosincl); + swi_cartpol(xq[i], xq[i]); + /* adding node, we get perihelion in ecl. coord. */ + xq[i][0] += atan2(sinnode, cosnode); + xa[i][0] = swi_mod2PI(xq[i][0] + PI); + xa[i][1] = -xq[i][1]; + if (do_focal_point) { + xa[i][2] = sema * ecce * 2; /* distance of aphelion */ + } + else { + xa[i][2] = sema * (1 + ecce); /* distance of aphelion */ + } + swi_polcart(xq[i], xq[i]); + swi_polcart(xa[i], xa[i]); + /* new distance of node from orbital ellipse: + * true anomaly of node: */ + ny = swi_mod2PI(ny - uu); + ny2 = swi_mod2PI(ny + PI); + /* eccentric anomaly */ + cosE = cos(2 * atan(tan(ny / 2) / sqrt((1 + ecce) / (1 - ecce)))); + cosE2 = + cos(2 * atan(tan(ny2 / 2) / sqrt((1 + ecce) / (1 - ecce)))); + /* new distance */ + rn = sema * (1 - ecce * cosE); + rn2 = sema * (1 - ecce * cosE2); + /* old node distance */ + ro = sqrt(square_sum(xn[i])); + ro2 = sqrt(square_sum(xs[i])); + /* correct length of position vector */ + for (j = 0; j <= 2; j++) { + xn[i][j] *= rn / ro; + xs[i][j] *= rn2 / ro2; + } + } + for (i = 0; i <= 2; i++) { + if (iflag & SEFLG_SPEED) { + xpe[i] = xq[1][i]; + xpe[i + 3] = (xq[2][i] - xq[0][i]) / dt / 2; + xap[i] = xa[1][i]; + xap[i + 3] = (xa[2][i] - xa[0][i]) / dt / 2; + xna[i] = xn[1][i]; + xna[i + 3] = (xn[2][i] - xn[0][i]) / dt / 2; + xnd[i] = xs[1][i]; + xnd[i + 3] = (xs[2][i] - xs[0][i]) / dt / 2; + } + else { + xpe[i] = xq[0][i]; + xpe[i + 3] = 0; + xap[i] = xa[0][i]; + xap[i + 3] = 0; + xna[i] = xn[0][i]; + xna[i + 3] = 0; + xnd[i] = xs[0][i]; + xnd[i + 3] = 0; + } + } + is_true_nodaps = TRUE; } - if (iflag & SEFLG_SPEED) { - istart = 0; - iend = 2; - } else { - istart = iend = 0; - dt = 0; + /* to set the variables required in the save area, + * i.e. ecliptic, nutation, barycentric sun, earth + * we compute the planet */ + if (ipli == SE_MOON && (iflag & (SEFLG_HELCTR | SEFLG_BARYCTR))) { + swi_force_app_pos_etc(); + if (swe_calc(tjd_et, SE_SUN, iflg0, x, serr) == ERR) + return ERR; } - for (i = istart, t = tjd_et - dt; i <= iend; i++, t += dt) { - if (istart == iend) - t = tjd_et; - if (swe_calc(t, ipli, iflJ2000, xpos[i], serr) == ERR) - return ERR; - /* the EMB is used instead of the earth */ - if (ipli == SE_EARTH) { - if (swe_calc(t, SE_MOON, iflJ2000 & ~(SEFLG_BARYCTR|SEFLG_HELCTR), xposm, serr) == ERR) - return ERR; - for (j = 0; j <= 2; j++) - xpos[i][j] += xposm[j] / (EARTH_MOON_MRAT + 1.0); - } - swi_plan_for_osc_elem(iflg0, t, xpos[i]); + else { + if (swe_calc(tjd_et, ipli, iflg0 | (iflag & SEFLG_TOPOCTR), x, serr) + == ERR) + return ERR; } - for (i = istart; i <= iend; i++) { - if (fabs(xpos[i][5]) < dzmin) - xpos[i][5] = dzmin; - fac = xpos[i][2] / xpos[i][5]; - sgn = xpos[i][5] / fabs(xpos[i][5]); - for (j = 0; j <= 2; j++) { - xn[i][j] = (xpos[i][j] - fac * xpos[i][j+3]) * sgn; - xs[i][j] = -xn[i][j]; - } - } - for (i = istart; i <= iend; i++) { - /* node */ - rxy = sqrt(xn[i][0] * xn[i][0] + xn[i][1] * xn[i][1]); - cosnode = xn[i][0] / rxy; - sinnode = xn[i][1] / rxy; - /* inclination */ - swi_cross_prod(xpos[i], xpos[i]+3, xnorm); - rxy = xnorm[0] * xnorm[0] + xnorm[1] * xnorm[1]; - c2 = (rxy + xnorm[2] * xnorm[2]); - rxyz = sqrt(c2); - rxy = sqrt(rxy); - sinincl = rxy / rxyz; - cosincl = sqrt(1 - sinincl * sinincl); - if (xnorm[2] < 0) cosincl = -cosincl; /* retrograde asteroid, e.g. 20461 Dioretsa */ - /* argument of latitude */ - cosu = xpos[i][0] * cosnode + xpos[i][1] * sinnode; - sinu = xpos[i][2] / sinincl; - uu = atan2(sinu, cosu); - /* semi-axis */ - rxyz = sqrt(square_sum(xpos[i])); - v2 = square_sum((xpos[i]+3)); - sema = 1 / (2 / rxyz - v2 / Gmsm); - /* eccentricity */ - pp = c2 / Gmsm; - ecce = sqrt(1 - pp / sema); - /* eccentric anomaly */ - cosE = 1 / ecce * (1 - rxyz / sema); - sinE = 1 / ecce / sqrt(sema * Gmsm) * dot_prod(xpos[i], (xpos[i]+3)); - /* true anomaly */ - ny = 2 * atan(sqrt((1+ecce)/(1-ecce)) * sinE / (1 + cosE)); - /* distance of perihelion from ascending node */ - xq[i][0] = swi_mod2PI(uu - ny); - xq[i][1] = 0; /* latitude */ - xq[i][2] = sema * (1 - ecce); /* distance of perihelion */ - /* transformation to ecliptic coordinates */ - swi_polcart(xq[i], xq[i]); - swi_coortrf2(xq[i], xq[i], -sinincl, cosincl); - swi_cartpol(xq[i], xq[i]); - /* adding node, we get perihelion in ecl. coord. */ - xq[i][0] += atan2(sinnode, cosnode); - xa[i][0] = swi_mod2PI(xq[i][0] + PI); - xa[i][1] = -xq[i][1]; - if (do_focal_point) { - xa[i][2] = sema * ecce * 2; /* distance of aphelion */ - } else { - xa[i][2] = sema * (1 + ecce); /* distance of aphelion */ - } - swi_polcart(xq[i], xq[i]); - swi_polcart(xa[i], xa[i]); - /* new distance of node from orbital ellipse: - * true anomaly of node: */ - ny = swi_mod2PI(ny - uu); - ny2 = swi_mod2PI(ny + PI); - /* eccentric anomaly */ - cosE = cos(2 * atan(tan(ny / 2) / sqrt((1+ecce) / (1-ecce)))); - cosE2 = cos(2 * atan(tan(ny2 / 2) / sqrt((1+ecce) / (1-ecce)))); - /* new distance */ - rn = sema * (1 - ecce * cosE); - rn2 = sema * (1 - ecce * cosE2); - /* old node distance */ - ro = sqrt(square_sum(xn[i])); - ro2 = sqrt(square_sum(xs[i])); - /* correct length of position vector */ - for (j = 0; j <= 2; j++) { - xn[i][j] *= rn / ro; - xs[i][j] *= rn2 / ro2; - } - } - for (i = 0; i <= 2; i++) { - if (iflag & SEFLG_SPEED) { - xpe[i] = xq[1][i]; - xpe[i+3] = (xq[2][i] - xq[0][i]) / dt / 2; - xap[i] = xa[1][i]; - xap[i+3] = (xa[2][i] - xa[0][i]) / dt / 2; - xna[i] = xn[1][i]; - xna[i+3] = (xn[2][i] - xn[0][i]) / dt / 2; - xnd[i] = xs[1][i]; - xnd[i+3] = (xs[2][i] - xs[0][i]) / dt / 2; - } else { - xpe[i] = xq[0][i]; - xpe[i+3] = 0; - xap[i] = xa[0][i]; - xap[i+3] = 0; - xna[i] = xn[0][i]; - xna[i+3] = 0; - xnd[i] = xs[0][i]; - xnd[i+3] = 0; - } - } - is_true_nodaps = TRUE; - } - /* to set the variables required in the save area, - * i.e. ecliptic, nutation, barycentric sun, earth - * we compute the planet */ - if (ipli == SE_MOON && (iflag & (SEFLG_HELCTR | SEFLG_BARYCTR))) { - swi_force_app_pos_etc(); - if (swe_calc(tjd_et, SE_SUN, iflg0, x, serr) == ERR) - return ERR; - } else { - if (swe_calc(tjd_et, ipli, iflg0 | (iflag & SEFLG_TOPOCTR), x, serr) == ERR) - return ERR; - } + /*********************** * position of observer ***********************/ - if (iflag & SEFLG_TOPOCTR) { - /* geocentric position of observer */ - if (swi_get_observer(tjd_et, iflag, FALSE, xobs, serr) != OK) - return ERR; - /*for (i = 0; i <= 5; i++) - xobs[i] = swed.topd.xobs[i];*/ - } else { - for (i = 0; i <= 5; i++) - xobs[i] = 0; - } - if (iflag & (SEFLG_HELCTR | SEFLG_BARYCTR)) { - if ((iflag & SEFLG_HELCTR) && !(iflag & SEFLG_MOSEPH)) - for (i = 0; i <= 5; i++) - xobs[i] = xsun[i]; - } else if (ipl == SE_SUN && !(iflag & SEFLG_MOSEPH)) { - for (i = 0; i <= 5; i++) - xobs[i] = xsun[i]; - } else { - /* barycentric position of observer */ - for (i = 0; i <= 5; i++) - xobs[i] += xear[i]; - } - /* ecliptic obliqity */ - if (iflag & SEFLG_J2000) - oe = &swed.oec2000; - else - oe = &swed.oec; + if (iflag & SEFLG_TOPOCTR) { + /* geocentric position of observer */ + if (swi_get_observer(tjd_et, iflag, FALSE, xobs, serr) != OK) + return ERR; + /*for (i = 0; i <= 5; i++) + * xobs[i] = swed.topd.xobs[i]; */ + } + else { + for (i = 0; i <= 5; i++) + xobs[i] = 0; + } + if (iflag & (SEFLG_HELCTR | SEFLG_BARYCTR)) { + if ((iflag & SEFLG_HELCTR) && !(iflag & SEFLG_MOSEPH)) + for (i = 0; i <= 5; i++) + xobs[i] = xsun[i]; + } + else if (ipl == SE_SUN && !(iflag & SEFLG_MOSEPH)) { + for (i = 0; i <= 5; i++) + xobs[i] = xsun[i]; + } + else { + /* barycentric position of observer */ + for (i = 0; i <= 5; i++) + xobs[i] += xear[i]; + } + /* ecliptic obliqity */ + if (iflag & SEFLG_J2000) + oe = &swed.oec2000; + else + oe = &swed.oec; + /************************************************* * conversions shared by mean and osculating points *************************************************/ - for (ij = 0, xp = xx; ij < 4; ij++, xp += 6) { - /* no nodes for earth */ - if (ipli == SE_EARTH && ij <= 1) { - for (i = 0; i <= 5; i++) - xp[i] = 0; - continue; - } + for (ij = 0, xp = xx; ij < 4; ij++, xp += 6) { + /* no nodes for earth */ + if (ipli == SE_EARTH && ij <= 1) { + for (i = 0; i <= 5; i++) + xp[i] = 0; + continue; + } + /********************* * to equator *********************/ - if (is_true_nodaps && !(iflag & SEFLG_NONUT)) { - swi_coortrf2(xp, xp, -swed.nut.snut, swed.nut.cnut); - if (iflag & SEFLG_SPEED) - swi_coortrf2(xp+3, xp+3, -swed.nut.snut, swed.nut.cnut); - } - swi_coortrf2(xp, xp, -oe->seps, oe->ceps); - swi_coortrf2(xp+3, xp+3, -oe->seps, oe->ceps); - if (is_true_nodaps) { + if (is_true_nodaps && !(iflag & SEFLG_NONUT)) { + swi_coortrf2(xp, xp, -swed.nut.snut, swed.nut.cnut); + if (iflag & SEFLG_SPEED) + swi_coortrf2(xp + 3, xp + 3, -swed.nut.snut, swed.nut.cnut); + } + swi_coortrf2(xp, xp, -oe->seps, oe->ceps); + swi_coortrf2(xp + 3, xp + 3, -oe->seps, oe->ceps); + if (is_true_nodaps) { + /**************************** * to mean ecliptic of date ****************************/ - if (!(iflag & SEFLG_NONUT)) - swi_nutate(xp, iflag, TRUE); - } + if (!(iflag & SEFLG_NONUT)) + swi_nutate(xp, iflag, TRUE); + } + /********************* * to J2000 *********************/ - swi_precess(xp, tjd_et, J_TO_J2000); - if (iflag & SEFLG_SPEED) - swi_precess_speed(xp, tjd_et, J_TO_J2000); + swi_precess(xp, tjd_et, J_TO_J2000); + if (iflag & SEFLG_SPEED) + swi_precess_speed(xp, tjd_et, J_TO_J2000); + /********************* * to barycenter *********************/ - if (ipli == SE_MOON) { - for (i = 0; i <= 5; i++) - xp[i] += xear[i]; - } else { - if (!(iflag & SEFLG_MOSEPH) && !ellipse_is_bary) - for (j = 0; j <= 5; j++) - xp[j] += xsun[j]; - } + if (ipli == SE_MOON) { + for (i = 0; i <= 5; i++) + xp[i] += xear[i]; + } + else { + if (!(iflag & SEFLG_MOSEPH) && !ellipse_is_bary) + for (j = 0; j <= 5; j++) + xp[j] += xsun[j]; + } + /********************* * to correct center *********************/ - for (j = 0; j <= 5; j++) - xp[j] -= xobs[j]; + for (j = 0; j <= 5; j++) + xp[j] -= xobs[j]; /* geocentric perigee/apogee of sun */ - if (ipl == SE_SUN && !(iflag & (SEFLG_HELCTR | SEFLG_BARYCTR))) - for (j = 0; j <= 5; j++) - xp[j] = -xp[j]; + if (ipl == SE_SUN && !(iflag & (SEFLG_HELCTR | SEFLG_BARYCTR))) + for (j = 0; j <= 5; j++) + xp[j] = -xp[j]; + /********************* * light deflection *********************/ - dt = sqrt(square_sum(xp)) * AUNIT / CLIGHT / 86400.0; - if (do_defl) - swi_deflect_light(xp, dt, iflag); + dt = sqrt(square_sum(xp)) * AUNIT / CLIGHT / 86400.0; + if (do_defl) + swi_deflect_light(xp, dt, iflag); + /********************* * aberration *********************/ - if (do_aberr) { - swi_aberr_light(xp, xobs, iflag); - /* - * Apparent speed is also influenced by - * the difference of speed of the earth between t and t-dt. - * Neglecting this would result in an error of several 0.1" - */ - if (iflag & SEFLG_SPEED) { - /* get barycentric sun and earth for t-dt into save area */ - if (swe_calc(tjd_et - dt, ipli, iflg0 | (iflag & SEFLG_TOPOCTR), x2, serr) == ERR) - return ERR; - if (iflag & SEFLG_TOPOCTR) { - /* geocentric position of observer */ - /* if (swi_get_observer(tjd_et - dt, iflag, FALSE, xobs, serr) != OK) - return ERR;*/ - for (i = 0; i <= 5; i++) - xobs2[i] = swed.topd.xobs[i]; - } else { - for (i = 0; i <= 5; i++) - xobs2[i] = 0; + if (do_aberr) { + swi_aberr_light(xp, xobs, iflag); + /* + * Apparent speed is also influenced by + * the difference of speed of the earth between t and t-dt. + * Neglecting this would result in an error of several 0.1" + */ + if (iflag & SEFLG_SPEED) { + /* get barycentric sun and earth for t-dt into save area */ + if (swe_calc + (tjd_et - dt, ipli, iflg0 | (iflag & SEFLG_TOPOCTR), x2, + serr) == ERR) + return ERR; + if (iflag & SEFLG_TOPOCTR) { + /* geocentric position of observer */ + /* if (swi_get_observer(tjd_et - dt, iflag, FALSE, xobs, serr) != OK) + * return ERR; */ + for (i = 0; i <= 5; i++) + xobs2[i] = swed.topd.xobs[i]; + } + else { + for (i = 0; i <= 5; i++) + xobs2[i] = 0; + } + if (iflag & (SEFLG_HELCTR | SEFLG_BARYCTR)) { + if ((iflag & SEFLG_HELCTR) && !(iflag & SEFLG_MOSEPH)) + for (i = 0; i <= 5; i++) + xobs2[i] = xsun[i]; + } + else if (ipl == SE_SUN && !(iflag & SEFLG_MOSEPH)) { + for (i = 0; i <= 5; i++) + xobs2[i] = xsun[i]; + } + else { + /* barycentric position of observer */ + for (i = 0; i <= 5; i++) + xobs2[i] += xear[i]; + } + for (i = 3; i <= 5; i++) + xp[i] += xobs[i] - xobs2[i]; + /* The above call of swe_calc() has destroyed the + * parts of the save area + * (i.e. bary sun, earth nutation matrix!). + * to restore it: + */ + if (swe_calc + (tjd_et, SE_SUN, iflg0 | (iflag & SEFLG_TOPOCTR), x2, + serr) == ERR) + return ERR; + } } - if (iflag & (SEFLG_HELCTR | SEFLG_BARYCTR)) { - if ((iflag & SEFLG_HELCTR) && !(iflag & SEFLG_MOSEPH)) - for (i = 0; i <= 5; i++) - xobs2[i] = xsun[i]; - } else if (ipl == SE_SUN && !(iflag & SEFLG_MOSEPH)) { - for (i = 0; i <= 5; i++) - xobs2[i] = xsun[i]; - } else { - /* barycentric position of observer */ - for (i = 0; i <= 5; i++) - xobs2[i] += xear[i]; - } - for (i = 3; i <= 5; i++) - xp[i] += xobs[i] - xobs2[i]; - /* The above call of swe_calc() has destroyed the - * parts of the save area - * (i.e. bary sun, earth nutation matrix!). - * to restore it: - */ - if (swe_calc(tjd_et, SE_SUN, iflg0 | (iflag & SEFLG_TOPOCTR), x2, serr) == ERR) - return ERR; - } - } + /********************* * precession *********************/ - /* save J2000 coordinates; required for sidereal positions */ - for (j = 0; j <= 5; j++) - x2000[j] = xp[j]; - if (!(iflag & SEFLG_J2000)) { - swi_precess(xp, tjd_et, J2000_TO_J); - if (iflag & SEFLG_SPEED) - swi_precess_speed(xp, tjd_et, J2000_TO_J); - } + /* save J2000 coordinates; required for sidereal positions */ + for (j = 0; j <= 5; j++) + x2000[j] = xp[j]; + if (!(iflag & SEFLG_J2000)) { + swi_precess(xp, tjd_et, J2000_TO_J); + if (iflag & SEFLG_SPEED) + swi_precess_speed(xp, tjd_et, J2000_TO_J); + } + /********************* * nutation *********************/ - if (!(iflag & SEFLG_NONUT)) - swi_nutate(xp, iflag, FALSE); - /* now we have equatorial cartesian coordinates; keep them */ - for (j = 0; j <= 5; j++) - pldat.xreturn[18+j] = xp[j]; + if (!(iflag & SEFLG_NONUT)) + swi_nutate(xp, iflag, FALSE); + /* now we have equatorial cartesian coordinates; keep them */ + for (j = 0; j <= 5; j++) + pldat.xreturn[18 + j] = xp[j]; + /************************************************ * transformation to ecliptic. * * with sidereal calc. this will be overwritten * * afterwards. * ************************************************/ - swi_coortrf2(xp, xp, oe->seps, oe->ceps); - if (iflag & SEFLG_SPEED) - swi_coortrf2(xp+3, xp+3, oe->seps, oe->ceps); - if (!(iflag & SEFLG_NONUT)) { - swi_coortrf2(xp, xp, swed.nut.snut, swed.nut.cnut); - if (iflag & SEFLG_SPEED) - swi_coortrf2(xp+3, xp+3, swed.nut.snut, swed.nut.cnut); - } - /* now we have ecliptic cartesian coordinates */ - for (j = 0; j <= 5; j++) - pldat.xreturn[6+j] = xp[j]; + swi_coortrf2(xp, xp, oe->seps, oe->ceps); + if (iflag & SEFLG_SPEED) + swi_coortrf2(xp + 3, xp + 3, oe->seps, oe->ceps); + if (!(iflag & SEFLG_NONUT)) { + swi_coortrf2(xp, xp, swed.nut.snut, swed.nut.cnut); + if (iflag & SEFLG_SPEED) + swi_coortrf2(xp + 3, xp + 3, swed.nut.snut, swed.nut.cnut); + } + /* now we have ecliptic cartesian coordinates */ + for (j = 0; j <= 5; j++) + pldat.xreturn[6 + j] = xp[j]; + /************************************ * sidereal positions * ************************************/ - if (iflag & SEFLG_SIDEREAL) { - /* project onto ecliptic t0 */ - if (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) { - if (swi_trop_ra2sid_lon(x2000, pldat.xreturn+6, pldat.xreturn+18, iflag, serr) != OK) - return ERR; - /* project onto solar system equator */ - } else if (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE) { - if (swi_trop_ra2sid_lon_sosy(x2000, pldat.xreturn+6, pldat.xreturn+18, iflag, serr) != OK) - return ERR; - } else { - /* traditional algorithm */ - swi_cartpol_sp(pldat.xreturn+6, pldat.xreturn); - pldat.xreturn[0] -= swe_get_ayanamsa(tjd_et) * DEGTORAD; - swi_polcart_sp(pldat.xreturn, pldat.xreturn+6); - } - } - if ((iflag & SEFLG_XYZ) && (iflag & SEFLG_EQUATORIAL)) { - for (j = 0; j <= 5; j++) - xp[j] = pldat.xreturn[18+j]; - continue; - } - if (iflag & SEFLG_XYZ) { - for (j = 0; j <= 5; j++) - xp[j] = pldat.xreturn[6+j]; - continue; - } + if (iflag & SEFLG_SIDEREAL) { + /* project onto ecliptic t0 */ + if (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) { + if (swi_trop_ra2sid_lon + (x2000, pldat.xreturn + 6, pldat.xreturn + 18, iflag, + serr) != OK) + return ERR; + /* project onto solar system equator */ + } + else if (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE) { + if (swi_trop_ra2sid_lon_sosy + (x2000, pldat.xreturn + 6, pldat.xreturn + 18, iflag, + serr) != OK) + return ERR; + } + else { + /* traditional algorithm */ + swi_cartpol_sp(pldat.xreturn + 6, pldat.xreturn); + pldat.xreturn[0] -= swe_get_ayanamsa(tjd_et) * DEGTORAD; + swi_polcart_sp(pldat.xreturn, pldat.xreturn + 6); + } + } + if ((iflag & SEFLG_XYZ) && (iflag & SEFLG_EQUATORIAL)) { + for (j = 0; j <= 5; j++) + xp[j] = pldat.xreturn[18 + j]; + continue; + } + if (iflag & SEFLG_XYZ) { + for (j = 0; j <= 5; j++) + xp[j] = pldat.xreturn[6 + j]; + continue; + } + /************************************************ * transformation to polar coordinates * ************************************************/ - swi_cartpol_sp(pldat.xreturn+18, pldat.xreturn+12); - swi_cartpol_sp(pldat.xreturn+6, pldat.xreturn); + swi_cartpol_sp(pldat.xreturn + 18, pldat.xreturn + 12); + swi_cartpol_sp(pldat.xreturn + 6, pldat.xreturn); + /********************** * radians to degrees * **********************/ - for (j = 0; j < 2; j++) { - pldat.xreturn[j] *= RADTODEG; /* ecliptic */ - pldat.xreturn[j+3] *= RADTODEG; - pldat.xreturn[j+12] *= RADTODEG; /* equator */ - pldat.xreturn[j+15] *= RADTODEG; + for (j = 0; j < 2; j++) { + pldat.xreturn[j] *= RADTODEG; /* ecliptic */ + pldat.xreturn[j + 3] *= RADTODEG; + pldat.xreturn[j + 12] *= RADTODEG; /* equator */ + pldat.xreturn[j + 15] *= RADTODEG; + } + if (iflag & SEFLG_EQUATORIAL) { + for (j = 0; j <= 5; j++) + xp[j] = pldat.xreturn[12 + j]; + continue; + } + else { + for (j = 0; j <= 5; j++) + xp[j] = pldat.xreturn[j]; + continue; + } } - if (iflag & SEFLG_EQUATORIAL) { - for (j = 0; j <= 5; j++) - xp[j] = pldat.xreturn[12+j]; - continue; - } else { - for (j = 0; j <= 5; j++) - xp[j] = pldat.xreturn[j]; - continue; + for (i = 0; i <= 5; i++) { + if (i > 2 && !(iflag & SEFLG_SPEED)) + xna[i] = xnd[i] = xpe[i] = xap[i] = 0; + if (xnasc != NULL) + xnasc[i] = xna[i]; + if (xndsc != NULL) + xndsc[i] = xnd[i]; + if (xperi != NULL) + xperi[i] = xpe[i]; + if (xaphe != NULL) + xaphe[i] = xap[i]; } - } - for (i = 0; i <= 5; i++) { - if (i > 2 && !(iflag & SEFLG_SPEED)) - xna[i] = xnd[i] = xpe[i] = xap[i] = 0; - if (xnasc != NULL) - xnasc[i] = xna[i]; - if (xndsc != NULL) - xndsc[i] = xnd[i]; - if (xperi != NULL) - xperi[i] = xpe[i]; - if (xaphe != NULL) - xaphe[i] = xap[i]; - } - return OK; + return OK; } -int32 FAR PASCAL_CONV swe_nod_aps_ut(double tjd_ut, int32 ipl, int32 iflag, - int32 method, - double *xnasc, double *xndsc, - double *xperi, double *xaphe, - char *serr) { - return swe_nod_aps(tjd_ut + swe_deltat(tjd_ut), - ipl, iflag, method, xnasc, xndsc, xperi, xaphe, - serr); +int32 FAR PASCAL_CONV +swe_nod_aps_ut(double tjd_ut, int32 ipl, int32 iflag, int32 method, + double *xnasc, double *xndsc, double *xperi, double *xaphe, + char *serr) +{ + return swe_nod_aps(tjd_ut + swe_deltat(tjd_ut), ipl, iflag, method, xnasc, + xndsc, xperi, xaphe, serr); } /* function finds the gauquelin sector position of a planet or fixed star @@ -4913,119 +5165,144 @@ int32 FAR PASCAL_CONV swe_nod_aps_ut(double tjd_ut, int32 ipl, int32 iflag, * dgsect is return area (pointer to a double) * serr is pointer to error string, may be NULL */ -int32 FAR PASCAL_CONV swe_gauquelin_sector(double t_ut, int32 ipl, char *starname, int32 iflag, int32 imeth, double *geopos, double atpress, double attemp, double *dgsect, char *serr) +int32 FAR PASCAL_CONV +swe_gauquelin_sector(double t_ut, int32 ipl, char *starname, int32 iflag, + int32 imeth, double *geopos, double atpress, + double attemp, double *dgsect, char *serr) { - AS_BOOL rise_found = TRUE; - AS_BOOL set_found = TRUE; - int32 retval; - double tret[3]; - double t_et, t; - double x0[6]; - double eps, nutlo[2], armc; - int32 epheflag = iflag & SEFLG_EPHMASK; - AS_BOOL do_fixstar = (starname != NULL && *starname != '\0'); - int32 risemeth = 0; - AS_BOOL above_horizon = FALSE; - if (imeth < 0 || imeth > 5) { - if (serr) - sprintf(serr, "invalid method: %d", imeth); - return ERR; - } - /* function calls for Pluto with asteroid number 134340 - * are treated as calls for Pluto as main body SE_PLUTO */ - if (ipl == SE_AST_OFFSET + 134340) - ipl = SE_PLUTO; - /* - * geometrically from ecl. longitude and latitude - */ - if (imeth == 0 || imeth == 1) { - t_et = t_ut + swe_deltat(t_ut); - eps = swi_epsiln(t_et) * RADTODEG; - swi_nutation(t_et, nutlo); - nutlo[0] *= RADTODEG; - nutlo[1] *= RADTODEG; - armc = swe_degnorm(swe_sidtime0(t_ut, eps + nutlo[1], nutlo[0]) * 15 + geopos[0]); - if (do_fixstar) { - if (swe_fixstar(starname, t_et, iflag, x0, serr) == ERR) - return ERR; - } else { - if (swe_calc(t_et, ipl, iflag, x0, serr) == ERR) - return ERR; + AS_BOOL rise_found = TRUE; + AS_BOOL set_found = TRUE; + int32 retval; + double tret[3]; + double t_et, t; + double x0[6]; + double eps, nutlo[2], armc; + int32 epheflag = iflag & SEFLG_EPHMASK; + AS_BOOL do_fixstar = (starname != NULL && *starname != '\0'); + int32 risemeth = 0; + AS_BOOL above_horizon = FALSE; + if (imeth < 0 || imeth > 5) { + if (serr) + sprintf(serr, "invalid method: %d", imeth); + return ERR; } - if (imeth == 1) - x0[1] = 0; - *dgsect = swe_house_pos(armc, geopos[1], eps + nutlo[1], 'G', x0, NULL); - return OK; - } - /* - * from rise and set times - */ - if (imeth == 2 || imeth == 4) - risemeth |= SE_BIT_NO_REFRACTION; - if (imeth == 2 || imeth == 3) - risemeth |= SE_BIT_DISC_CENTER; - /* find the next rising time of the planet or star */ - retval = swe_rise_trans(t_ut, ipl, starname, epheflag, SE_CALC_RISE|risemeth, geopos, atpress, attemp, &(tret[0]), serr); - if (retval == ERR) { - return ERR; - } else if (retval == -2) { - /* actually, we could return ERR here. However, we - * keep this variable, in case we implement an algorithm - * for Gauquelin sector positions of circumpolar bodies. - * As with the Ludwig Otto procedure with Placidus, one - * could replace missing rises or sets by meridian transits, - * although there are cases where even this is not possible. - * Sometimes a body both appears and disappears on the western - * part of the horizon. Using true culminations rather than meridan - * transits would not help in any case either, because there are - * cases where a body does not have a culmination within days, - * e.g. the sun near the poles. + /* function calls for Pluto with asteroid number 134340 + * are treated as calls for Pluto as main body SE_PLUTO */ + if (ipl == SE_AST_OFFSET + 134340) + ipl = SE_PLUTO; + /* + * geometrically from ecl. longitude and latitude */ - rise_found = FALSE; - } - /* find the next setting time of the planet or star */ - retval = swe_rise_trans(t_ut, ipl, starname, epheflag, SE_CALC_SET|risemeth, geopos, atpress, attemp, &(tret[1]), serr); - if (retval == ERR) { - return ERR; - } else if (retval == -2) { - set_found = FALSE; - } - if (tret[0] < tret[1] && rise_found == TRUE) { - above_horizon = FALSE; - /* find last set */ - t = t_ut - 1.2; - if (set_found) t = tret[1] - 1.2; - set_found = TRUE; - retval = swe_rise_trans(t, ipl, starname, epheflag, SE_CALC_SET|risemeth, geopos, atpress, attemp, &(tret[1]), serr); + if (imeth == 0 || imeth == 1) { + t_et = t_ut + swe_deltat(t_ut); + eps = swi_epsiln(t_et) * RADTODEG; + swi_nutation(t_et, nutlo); + nutlo[0] *= RADTODEG; + nutlo[1] *= RADTODEG; + armc = + swe_degnorm(swe_sidtime0(t_ut, eps + nutlo[1], nutlo[0]) * 15 + + geopos[0]); + if (do_fixstar) { + if (swe_fixstar(starname, t_et, iflag, x0, serr) == ERR) + return ERR; + } + else { + if (swe_calc(t_et, ipl, iflag, x0, serr) == ERR) + return ERR; + } + if (imeth == 1) + x0[1] = 0; + *dgsect = + swe_house_pos(armc, geopos[1], eps + nutlo[1], 'G', x0, NULL); + return OK; + } + /* + * from rise and set times + */ + if (imeth == 2 || imeth == 4) + risemeth |= SE_BIT_NO_REFRACTION; + if (imeth == 2 || imeth == 3) + risemeth |= SE_BIT_DISC_CENTER; + /* find the next rising time of the planet or star */ + retval = + swe_rise_trans(t_ut, ipl, starname, epheflag, SE_CALC_RISE | risemeth, + geopos, atpress, attemp, &(tret[0]), serr); if (retval == ERR) { - return ERR; - } else if (retval == -2) { - set_found = FALSE; + return ERR; } - } else if (tret[0] >= tret[1] && set_found == TRUE) { - above_horizon = TRUE; - /* find last rise */ - t = t_ut - 1.2; - if (rise_found) t = tret[0] - 1.2; - rise_found = TRUE; - retval = swe_rise_trans(t, ipl, starname, epheflag, SE_CALC_RISE|risemeth, geopos, atpress, attemp, &(tret[0]), serr); + else if (retval == -2) { + /* actually, we could return ERR here. However, we + * keep this variable, in case we implement an algorithm + * for Gauquelin sector positions of circumpolar bodies. + * As with the Ludwig Otto procedure with Placidus, one + * could replace missing rises or sets by meridian transits, + * although there are cases where even this is not possible. + * Sometimes a body both appears and disappears on the western + * part of the horizon. Using true culminations rather than meridan + * transits would not help in any case either, because there are + * cases where a body does not have a culmination within days, + * e.g. the sun near the poles. + */ + rise_found = FALSE; + } + /* find the next setting time of the planet or star */ + retval = + swe_rise_trans(t_ut, ipl, starname, epheflag, SE_CALC_SET | risemeth, + geopos, atpress, attemp, &(tret[1]), serr); if (retval == ERR) { - return ERR; - } else if (retval == -2) { - rise_found = FALSE; + return ERR; } - } - if (rise_found && set_found) { - if (above_horizon) { - *dgsect = (t_ut - tret[0]) / (tret[1] - tret[0]) * 18 + 1; - } else { - *dgsect = (t_ut - tret[1]) / (tret[0] - tret[1]) * 18 + 19; + else if (retval == -2) { + set_found = FALSE; + } + if (tret[0] < tret[1] && rise_found == TRUE) { + above_horizon = FALSE; + /* find last set */ + t = t_ut - 1.2; + if (set_found) + t = tret[1] - 1.2; + set_found = TRUE; + retval = + swe_rise_trans(t, ipl, starname, epheflag, SE_CALC_SET | risemeth, + geopos, atpress, attemp, &(tret[1]), serr); + if (retval == ERR) { + return ERR; + } + else if (retval == -2) { + set_found = FALSE; + } + } + else if (tret[0] >= tret[1] && set_found == TRUE) { + above_horizon = TRUE; + /* find last rise */ + t = t_ut - 1.2; + if (rise_found) + t = tret[0] - 1.2; + rise_found = TRUE; + retval = + swe_rise_trans(t, ipl, starname, epheflag, + SE_CALC_RISE | risemeth, geopos, atpress, attemp, + &(tret[0]), serr); + if (retval == ERR) { + return ERR; + } + else if (retval == -2) { + rise_found = FALSE; + } + } + if (rise_found && set_found) { + if (above_horizon) { + *dgsect = (t_ut - tret[0]) / (tret[1] - tret[0]) * 18 + 1; + } + else { + *dgsect = (t_ut - tret[1]) / (tret[0] - tret[1]) * 18 + 19; + } + return OK; + } + else { + *dgsect = 0; + if (serr) + sprintf(serr, "rise or set not found for planet %d", ipl); + return ERR; } - return OK; - } else { - *dgsect = 0; - if (serr) - sprintf(serr, "rise or set not found for planet %d", ipl); - return ERR; - } } diff --git a/swe/src/swedate.c b/swe/src/swedate.c index cf2c83a..f6edf95 100644 --- a/swe/src/swedate.c +++ b/swe/src/swedate.c @@ -1,3 +1,4 @@ + /********************************************************* $Header: /home/dieter/sweph/RCS/swedate.c,v 1.75 2009/04/08 07:17:29 dieter Exp $ version 15-feb-89 16:30 @@ -7,6 +8,7 @@ swe_julday() ************************************************************/ + /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -83,34 +85,34 @@ Return: OK or ERR (for illegal date) *********************************************************/ -# include "swephexp.h" -# include "sweph.h" +#include "swephexp.h" +#include "sweph.h" static AS_BOOL init_leapseconds_done = FALSE; -int FAR PASCAL_CONV swe_date_conversion(int y, - int m, - int d, /* day, month, year */ - double uttime, /* UT in hours (decimal) */ - char c, /* calendar g[regorian]|j[ulian] */ - double *tjd) +int FAR PASCAL_CONV +swe_date_conversion(int y, int m, int d, /* day, month, year */ + double uttime, /* UT in hours (decimal) */ + char c, /* calendar g[regorian]|j[ulian] */ + double *tjd) { - int rday, rmon, ryear; - double rut, jd; - int gregflag = SE_JUL_CAL; - if (c == 'g') - gregflag = SE_GREG_CAL; - rut = uttime; /* hours UT */ - jd = swe_julday(y, m, d, rut, gregflag); - swe_revjul(jd, gregflag, &ryear, &rmon, &rday, &rut); - *tjd = jd; - if (rmon == m && rday == d && ryear == y) { - return OK; - } else { - return ERR; - } -} /* end date_conversion */ + int rday, rmon, ryear; + double rut, jd; + int gregflag = SE_JUL_CAL; + if (c == 'g') + gregflag = SE_GREG_CAL; + rut = uttime; /* hours UT */ + jd = swe_julday(y, m, d, rut, gregflag); + swe_revjul(jd, gregflag, &ryear, &rmon, &rday, &rut); + *tjd = jd; + if (rmon == m && rday == d && ryear == y) { + return OK; + } + else { + return ERR; + } +} /* end date_conversion */ /*************** swe_julday ******************************************** * This function returns the absolute Julian day number (JD) @@ -161,26 +163,31 @@ int FAR PASCAL_CONV swe_date_conversion(int y, and notifies errors like 32 January. ****************************************************************/ -double FAR PASCAL_CONV swe_julday(int year, int month, int day, double hour, int gregflag) +double FAR PASCAL_CONV +swe_julday(int year, int month, int day, double hour, int gregflag) { - double jd; - double u,u0,u1,u2; - u = year; - if (month < 3) u -=1; - u0 = u + 4712.0; - u1 = month + 1.0; - if (u1 < 4) u1 += 12.0; - jd = floor(u0*365.25) - + floor(30.6*u1+0.000001) - + day + hour/24.0 - 63.5; - if (gregflag == SE_GREG_CAL) { - u2 = floor(fabs(u) / 100) - floor(fabs(u) / 400); - if (u < 0.0) u2 = -u2; - jd = jd - u2 + 2; - if ((u < 0.0) && (u/100 == floor(u/100)) && (u/400 != floor(u/400))) - jd -=1; - } - return jd; + double jd; + double u, u0, u1, u2; + u = year; + if (month < 3) + u -= 1; + u0 = u + 4712.0; + u1 = month + 1.0; + if (u1 < 4) + u1 += 12.0; + jd = floor(u0 * 365.25) + + floor(30.6 * u1 + 0.000001) + + day + hour / 24.0 - 63.5; + if (gregflag == SE_GREG_CAL) { + u2 = floor(fabs(u) / 100) - floor(fabs(u) / 400); + if (u < 0.0) + u2 = -u2; + jd = jd - u2 + 2; + if ((u < 0.0) && (u / 100 == floor(u / 100)) + && (u / 400 != floor(u / 400))) + jd -= 1; + } + return jd; } /*** swe_revjul ****************************************************** @@ -202,24 +209,27 @@ double FAR PASCAL_CONV swe_julday(int year, int month, int day, double hour, int Original author Mark Pottenger, Los Angeles. with bug fix for year < -4711 16-aug-88 Alois Treindl *************************************************************************/ -void FAR PASCAL_CONV swe_revjul (double jd, int gregflag, - int *jyear, int *jmon, int *jday, double *jut) +void FAR PASCAL_CONV +swe_revjul(double jd, int gregflag, int *jyear, int *jmon, int *jday, + double *jut) { - double u0,u1,u2,u3,u4; - u0 = jd + 32082.5; - if (gregflag == SE_GREG_CAL) { - u1 = u0 + floor (u0/36525.0) - floor (u0/146100.0) - 38.0; - if (jd >= 1830691.5) u1 +=1; - u0 = u0 + floor (u1/36525.0) - floor (u1/146100.0) - 38.0; - } - u2 = floor (u0 + 123.0); - u3 = floor ( (u2 - 122.2) / 365.25); - u4 = floor ( (u2 - floor (365.25 * u3) ) / 30.6001); - *jmon = (int) (u4 - 1.0); - if (*jmon > 12) *jmon -= 12; - *jday = (int) (u2 - floor (365.25 * u3) - floor (30.6001 * u4)); - *jyear = (int) (u3 + floor ( (u4 - 2.0) / 12.0) - 4800); - *jut = (jd - floor (jd + 0.5) + 0.5) * 24.0; + double u0, u1, u2, u3, u4; + u0 = jd + 32082.5; + if (gregflag == SE_GREG_CAL) { + u1 = u0 + floor(u0 / 36525.0) - floor(u0 / 146100.0) - 38.0; + if (jd >= 1830691.5) + u1 += 1; + u0 = u0 + floor(u1 / 36525.0) - floor(u1 / 146100.0) - 38.0; + } + u2 = floor(u0 + 123.0); + u3 = floor((u2 - 122.2) / 365.25); + u4 = floor((u2 - floor(365.25 * u3)) / 30.6001); + *jmon = (int)(u4 - 1.0); + if (*jmon > 12) + *jmon -= 12; + *jday = (int)(u2 - floor(365.25 * u3) - floor(30.6001 * u4)); + *jyear = (int)(u3 + floor((u4 - 2.0) / 12.0) - 4800); + *jut = (jd - floor(jd + 0.5) + 0.5) * 24.0; } /* transform local time to UTC or UTC to local time @@ -236,39 +246,37 @@ void FAR PASCAL_CONV swe_revjul (double jd, int gregflag, * For conversion from local time to utc, use +d_timezone. * For conversion from utc to local time, use -d_timezone. */ -void FAR PASCAL_CONV swe_utc_time_zone( - int32 iyear, int32 imonth, int32 iday, - int32 ihour, int32 imin, double dsec, - double d_timezone, - int32 *iyear_out, int32 *imonth_out, int32 *iday_out, - int32 *ihour_out, int32 *imin_out, double *dsec_out - ) +void FAR PASCAL_CONV +swe_utc_time_zone(int32 iyear, int32 imonth, int32 iday, int32 ihour, + int32 imin, double dsec, double d_timezone, + int32 * iyear_out, int32 * imonth_out, int32 * iday_out, + int32 * ihour_out, int32 * imin_out, double *dsec_out) { - double tjd, d; - AS_BOOL have_leapsec = FALSE; - double dhour; - if (dsec >= 60.0) { - have_leapsec = TRUE; - dsec -= 1.0; - } - dhour = ((double) ihour) + ((double) imin) / 60.0 + dsec / 3600.0; - tjd = swe_julday(iyear, imonth, iday, 0, SE_GREG_CAL); - dhour -= d_timezone; - if (dhour < 0.0) { - tjd -= 1.0; - dhour += 24.0; - } - if (dhour >= 24.0) { - tjd += 1.0; - dhour -= 24.0; - } - swe_revjul(tjd + 0.001, SE_GREG_CAL, iyear_out, imonth_out, iday_out, &d); - *ihour_out = (int) dhour; - d = (dhour - (double) *ihour_out) * 60; - *imin_out = (int) d; - *dsec_out = (d - (double) *imin_out) * 60; - if (have_leapsec) - *dsec_out += 1.0; + double tjd, d; + AS_BOOL have_leapsec = FALSE; + double dhour; + if (dsec >= 60.0) { + have_leapsec = TRUE; + dsec -= 1.0; + } + dhour = ((double)ihour) + ((double)imin) / 60.0 + dsec / 3600.0; + tjd = swe_julday(iyear, imonth, iday, 0, SE_GREG_CAL); + dhour -= d_timezone; + if (dhour < 0.0) { + tjd -= 1.0; + dhour += 24.0; + } + if (dhour >= 24.0) { + tjd += 1.0; + dhour -= 24.0; + } + swe_revjul(tjd + 0.001, SE_GREG_CAL, iyear_out, imonth_out, iday_out, &d); + *ihour_out = (int)dhour; + d = (dhour - (double)*ihour_out) * 60; + *imin_out = (int)d; + *dsec_out = (d - (double)*imin_out) * 60; + if (have_leapsec) + *dsec_out += 1.0; } /* @@ -279,80 +287,85 @@ void FAR PASCAL_CONV swe_utc_time_zone( #define NLEAP_SECONDS 24 #define NLEAP_SECONDS_SPACE 100 static int leap_seconds[NLEAP_SECONDS_SPACE] = { -19720630, -19721231, -19731231, -19741231, -19751231, -19761231, -19771231, -19781231, -19791231, -19810630, -19820630, -19830630, -19850630, -19871231, -19891231, -19901231, -19920630, -19930630, -19940630, -19951231, -19970630, -19981231, -20051231, -20081231, -0 /* keep this 0 as end mark */ + 19720630, + 19721231, + 19731231, + 19741231, + 19751231, + 19761231, + 19771231, + 19781231, + 19791231, + 19810630, + 19820630, + 19830630, + 19850630, + 19871231, + 19891231, + 19901231, + 19920630, + 19930630, + 19940630, + 19951231, + 19970630, + 19981231, + 20051231, + 20081231, + 0 /* keep this 0 as end mark */ }; + #define J1972 2441317.5 #define NLEAP_INIT 10 /* Read additional leap second dates from external file, if given. */ -static int init_leapsec(void) +static int +init_leapsec(void) { - FILE *fp; - int ndat, ndat_last; - int tabsiz = 0; - int i; - char s[AS_MAXCH]; - char *sp; - if (!init_leapseconds_done) { - init_leapseconds_done = TRUE; - tabsiz = NLEAP_SECONDS; - ndat_last = leap_seconds[NLEAP_SECONDS - 1]; - /* no error message if file is missing */ - if ((fp = swi_fopen(-1, "seleapsec.txt", swed.ephepath, NULL)) == NULL) - return NLEAP_SECONDS; - while(fgets(s, AS_MAXCH, fp) != NULL) { - sp = s; - while (*sp == ' ' || *sp == '\t') sp++; - sp++; - if (*sp == '#' || *sp == '\n') - continue; - ndat = atoi(s); - if (ndat <= ndat_last) - continue; - /* table space is limited. no error msg, if exceeded */ - if (tabsiz >= NLEAP_SECONDS_SPACE) + FILE *fp; + int ndat, ndat_last; + int tabsiz = 0; + int i; + char s[AS_MAXCH]; + char *sp; + if (!init_leapseconds_done) { + init_leapseconds_done = TRUE; + tabsiz = NLEAP_SECONDS; + ndat_last = leap_seconds[NLEAP_SECONDS - 1]; + /* no error message if file is missing */ + if ((fp = + swi_fopen(-1, "seleapsec.txt", swed.ephepath, NULL)) == NULL) + return NLEAP_SECONDS; + while (fgets(s, AS_MAXCH, fp) != NULL) { + sp = s; + while (*sp == ' ' || *sp == '\t') + sp++; + sp++; + if (*sp == '#' || *sp == '\n') + continue; + ndat = atoi(s); + if (ndat <= ndat_last) + continue; + /* table space is limited. no error msg, if exceeded */ + if (tabsiz >= NLEAP_SECONDS_SPACE) + return tabsiz; + leap_seconds[tabsiz] = ndat; + tabsiz++; + } + if (tabsiz > NLEAP_SECONDS) + leap_seconds[tabsiz] = 0; /* end mark */ + fclose(fp); return tabsiz; - leap_seconds[tabsiz] = ndat; - tabsiz++; } - if (tabsiz > NLEAP_SECONDS) leap_seconds[tabsiz] = 0; /* end mark */ - fclose(fp); + /* find table size */ + tabsiz = 0; + for (i = 0; i < NLEAP_SECONDS_SPACE; i++) { + if (leap_seconds[i] == 0) + break; + else + tabsiz++; + } return tabsiz; - } - /* find table size */ - tabsiz = 0; - for (i = 0; i < NLEAP_SECONDS_SPACE; i++) { - if (leap_seconds[i] == 0) - break; - else - tabsiz++; - } - return tabsiz; } /* @@ -374,100 +387,103 @@ static int init_leapsec(void) * the leap seconds table (or the Swiss Ephemeris version) is not updated * for a long time. */ -int32 FAR PASCAL_CONV swe_utc_to_jd(int32 iyear, int32 imonth, int32 iday, int32 ihour, int32 imin, double dsec, int32 gregflag, double *dret, char *serr) +int32 FAR PASCAL_CONV +swe_utc_to_jd(int32 iyear, int32 imonth, int32 iday, int32 ihour, int32 imin, + double dsec, int32 gregflag, double *dret, char *serr) { - double tjd_ut1, tjd_et, tjd_et_1972, dhour, d; - int iyear2, imonth2, iday2; - int i, j, ndat, nleap, tabsiz_nleap; - /* - * error handling: invalid iyear etc. - */ - tjd_ut1 = swe_julday(iyear, imonth, iday, 0, gregflag); - swe_revjul(tjd_ut1, gregflag, &iyear2, &imonth2, &iday2, &d); - if (iyear != iyear2 || imonth != imonth2 || iday != iday2) { - if (serr != NULL) - sprintf(serr, "invalid date: year = %d, month = %d, day = %d", iyear, imonth, iday); - return ERR; - } - if (ihour < 0 || ihour > 23 - || imin < 0 || imin > 59 - || dsec < 0 || dsec >= 61 - || (dsec >= 60 && (imin < 59 || ihour < 23 || tjd_ut1 < J1972))) { - if (serr != NULL) - sprintf(serr, "invalid time: %d:%d:%.2f", ihour, imin, dsec); - return ERR; - } - dhour = (double) ihour + ((double) imin) / 60.0 + dsec / 3600.0; - /* - * before 1972, we treat input date as UT1 - */ - if (tjd_ut1 < J1972) { - dret[1] = swe_julday(iyear, imonth, iday, dhour, gregflag); - dret[0] = dret[1] + swe_deltat(dret[1]); - return OK; - } - /* - * if gregflag = Julian calendar, convert to gregorian calendar - */ - if (gregflag == SE_JUL_CAL) { - gregflag = SE_GREG_CAL; - swe_revjul(tjd_ut1, gregflag, &iyear, &imonth, &iday, &d); - } - /* - * number of leap seconds since 1972: - */ - tabsiz_nleap = init_leapsec(); - nleap = NLEAP_INIT; /* initial difference between UTC and TAI in 1972 */ - ndat = iyear * 10000 + imonth * 100 + iday; - for (i = 0; i < tabsiz_nleap; i++) { - if (ndat <= leap_seconds[i]) - break; - nleap++; - } - /* - * For input dates > today: - * If leap seconds table is not up to date, we'd better interpret the - * input time as UT1, not as UTC. How do we find out? - * Check, if delta_t - nleap - 32.184 > 0.9 - */ - d = swe_deltat(tjd_ut1) * 86400.0; - if (d - (double) nleap - 32.184 >= 1.0) { - dret[1] = tjd_ut1 + dhour / 24.0; - dret[0] = dret[1] + swe_deltat(dret[1]); - return OK; - } - /* - * if input second is 60: is it a valid leap second ? - */ - if (dsec >= 60) { - j = 0; + double tjd_ut1, tjd_et, tjd_et_1972, dhour, d; + int iyear2, imonth2, iday2; + int i, j, ndat, nleap, tabsiz_nleap; + /* + * error handling: invalid iyear etc. + */ + tjd_ut1 = swe_julday(iyear, imonth, iday, 0, gregflag); + swe_revjul(tjd_ut1, gregflag, &iyear2, &imonth2, &iday2, &d); + if (iyear != iyear2 || imonth != imonth2 || iday != iday2) { + if (serr != NULL) + sprintf(serr, "invalid date: year = %d, month = %d, day = %d", + iyear, imonth, iday); + return ERR; + } + if (ihour < 0 || ihour > 23 || imin < 0 || imin > 59 || dsec < 0 + || dsec >= 61 || (dsec >= 60 + && (imin < 59 || ihour < 23 || tjd_ut1 < J1972))) { + if (serr != NULL) + sprintf(serr, "invalid time: %d:%d:%.2f", ihour, imin, dsec); + return ERR; + } + dhour = (double)ihour + ((double)imin) / 60.0 + dsec / 3600.0; + /* + * before 1972, we treat input date as UT1 + */ + if (tjd_ut1 < J1972) { + dret[1] = swe_julday(iyear, imonth, iday, dhour, gregflag); + dret[0] = dret[1] + swe_deltat(dret[1]); + return OK; + } + /* + * if gregflag = Julian calendar, convert to gregorian calendar + */ + if (gregflag == SE_JUL_CAL) { + gregflag = SE_GREG_CAL; + swe_revjul(tjd_ut1, gregflag, &iyear, &imonth, &iday, &d); + } + /* + * number of leap seconds since 1972: + */ + tabsiz_nleap = init_leapsec(); + nleap = NLEAP_INIT; /* initial difference between UTC and TAI in 1972 */ + ndat = iyear * 10000 + imonth * 100 + iday; for (i = 0; i < tabsiz_nleap; i++) { - if (ndat == leap_seconds[i]) { - j = 1; - break; - } + if (ndat <= leap_seconds[i]) + break; + nleap++; } - if (j != 1) { - if (serr != NULL) - sprintf(serr, "invalid time (no leap second!): %d:%d:%.2f", ihour, imin, dsec); - return ERR; + /* + * For input dates > today: + * If leap seconds table is not up to date, we'd better interpret the + * input time as UT1, not as UTC. How do we find out? + * Check, if delta_t - nleap - 32.184 > 0.9 + */ + d = swe_deltat(tjd_ut1) * 86400.0; + if (d - (double)nleap - 32.184 >= 1.0) { + dret[1] = tjd_ut1 + dhour / 24.0; + dret[0] = dret[1] + swe_deltat(dret[1]); + return OK; } - } - /* - * convert UTC to ET and UT1 - */ - /* the number of days between input date and 1 jan 1972: */ - d = tjd_ut1 - J1972; - /* SI time since 1972, ignoring leap seconds: */ - d += (double) ihour / 24.0 + (double) imin / 1440.0 + dsec / 86400.0; - /* ET (TT) */ - tjd_et_1972 = J1972 + (32.184 + NLEAP_INIT) / 86400.0; - tjd_et = tjd_et_1972 + d + ((double) (nleap - NLEAP_INIT)) / 86400.0; - d = swe_deltat(tjd_et); - tjd_ut1 = tjd_et - swe_deltat(tjd_et - d); - dret[0] = tjd_et; - dret[1] = tjd_ut1; - return OK; + /* + * if input second is 60: is it a valid leap second ? + */ + if (dsec >= 60) { + j = 0; + for (i = 0; i < tabsiz_nleap; i++) { + if (ndat == leap_seconds[i]) { + j = 1; + break; + } + } + if (j != 1) { + if (serr != NULL) + sprintf(serr, "invalid time (no leap second!): %d:%d:%.2f", + ihour, imin, dsec); + return ERR; + } + } + /* + * convert UTC to ET and UT1 + */ + /* the number of days between input date and 1 jan 1972: */ + d = tjd_ut1 - J1972; + /* SI time since 1972, ignoring leap seconds: */ + d += (double)ihour / 24.0 + (double)imin / 1440.0 + dsec / 86400.0; + /* ET (TT) */ + tjd_et_1972 = J1972 + (32.184 + NLEAP_INIT) / 86400.0; + tjd_et = tjd_et_1972 + d + ((double)(nleap - NLEAP_INIT)) / 86400.0; + d = swe_deltat(tjd_et); + tjd_ut1 = tjd_et - swe_deltat(tjd_et - d); + dret[0] = tjd_et; + dret[1] = tjd_ut1; + return OK; } /* @@ -484,86 +500,92 @@ int32 FAR PASCAL_CONV swe_utc_to_jd(int32 iyear, int32 imonth, int32 iday, int32 * the leap seconds table (or the Swiss Ephemeris version) has not been * updated for a long time. */ -void FAR PASCAL_CONV swe_jdet_to_utc(double tjd_et, int32 gregflag, int32 *iyear, int32 *imonth, int32 *iday, int32 *ihour, int32 *imin, double *dsec) +void FAR PASCAL_CONV +swe_jdet_to_utc(double tjd_et, int32 gregflag, int32 * iyear, int32 * imonth, + int32 * iday, int32 * ihour, int32 * imin, double *dsec) { - int i; - int second_60 = 0; - int iyear2, imonth2, iday2, nleap, ndat, tabsiz_nleap; - double d, tjd, tjd_et_1972, tjd_ut, dret[10]; - /* - * if tjd_et is before 1 jan 1972 UTC, return UT1 - */ - tjd_et_1972 = J1972 + (32.184 + NLEAP_INIT) / 86400.0; - d = swe_deltat(tjd_et); - tjd_ut = tjd_et - swe_deltat(tjd_et - d); - if (tjd_et < tjd_et_1972) { - swe_revjul(tjd_ut, gregflag, iyear, imonth, iday, &d); - *ihour = (int32) d; - d -= (double) *ihour; - d *= 60; - *imin = (int32) d; - *dsec = (d - (double) *imin) * 60.0; - return; - } - /* - * minimum number of leap seconds since 1972; we may be missing one leap - * second - */ - tabsiz_nleap = init_leapsec(); - swe_revjul(tjd_ut-1, SE_GREG_CAL, &iyear2, &imonth2, &iday2, &d); - ndat = iyear2 * 10000 + imonth2 * 100 + iday2; - nleap = 0; - for (i = 0; i < tabsiz_nleap; i++) { - if (ndat <= leap_seconds[i]) - break; - nleap++; - } - /* date of potentially missing leapsecond */ - if (nleap < tabsiz_nleap) { - i = leap_seconds[nleap]; - iyear2 = i / 10000; - imonth2 = (i % 10000) / 100;; - iday2 = i % 100; - tjd = swe_julday(iyear2, imonth2, iday2, 0, SE_GREG_CAL); - swe_revjul(tjd+1, SE_GREG_CAL, &iyear2, &imonth2, &iday2, &d); - swe_utc_to_jd(iyear2,imonth2,iday2, 0, 0, 0, SE_GREG_CAL, dret, NULL); - d = tjd_et - dret[0]; - if (d >= 0) { - nleap++; - } else if (d < 0 && d > -1.0/86400.0) { - second_60 = 1; + int i; + int second_60 = 0; + int iyear2, imonth2, iday2, nleap, ndat, tabsiz_nleap; + double d, tjd, tjd_et_1972, tjd_ut, dret[10]; + /* + * if tjd_et is before 1 jan 1972 UTC, return UT1 + */ + tjd_et_1972 = J1972 + (32.184 + NLEAP_INIT) / 86400.0; + d = swe_deltat(tjd_et); + tjd_ut = tjd_et - swe_deltat(tjd_et - d); + if (tjd_et < tjd_et_1972) { + swe_revjul(tjd_ut, gregflag, iyear, imonth, iday, &d); + *ihour = (int32) d; + d -= (double)*ihour; + d *= 60; + *imin = (int32) d; + *dsec = (d - (double)*imin) * 60.0; + return; } - } - /* - * UTC, still unsure about one leap second - */ - tjd = J1972 + (tjd_et - tjd_et_1972) - ((double) nleap + second_60) / 86400.0; - swe_revjul(tjd, SE_GREG_CAL, iyear, imonth, iday, &d); - *ihour = (int32) d; - d -= (double) *ihour; - d *= 60; - *imin = (int32) d; - *dsec = (d - (double) *imin) * 60.0 + second_60; - /* - * For input dates > today: - * If leap seconds table is not up to date, we'd better interpret the - * input time as UT1, not as UTC. How do we find out? - * Check, if delta_t - nleap - 32.184 > 0.9 - */ - d = swe_deltat(tjd_et); - d = swe_deltat(tjd_et - d); - if (d * 86400.0 - (double) (nleap + NLEAP_INIT) - 32.184 >= 1.0) { - swe_revjul(tjd_et - d, SE_GREG_CAL, iyear, imonth, iday, &d); + /* + * minimum number of leap seconds since 1972; we may be missing one leap + * second + */ + tabsiz_nleap = init_leapsec(); + swe_revjul(tjd_ut - 1, SE_GREG_CAL, &iyear2, &imonth2, &iday2, &d); + ndat = iyear2 * 10000 + imonth2 * 100 + iday2; + nleap = 0; + for (i = 0; i < tabsiz_nleap; i++) { + if (ndat <= leap_seconds[i]) + break; + nleap++; + } + /* date of potentially missing leapsecond */ + if (nleap < tabsiz_nleap) { + i = leap_seconds[nleap]; + iyear2 = i / 10000; + imonth2 = (i % 10000) / 100;; + iday2 = i % 100; + tjd = swe_julday(iyear2, imonth2, iday2, 0, SE_GREG_CAL); + swe_revjul(tjd + 1, SE_GREG_CAL, &iyear2, &imonth2, &iday2, &d); + swe_utc_to_jd(iyear2, imonth2, iday2, 0, 0, 0, SE_GREG_CAL, dret, + NULL); + d = tjd_et - dret[0]; + if (d >= 0) { + nleap++; + } + else if (d < 0 && d > -1.0 / 86400.0) { + second_60 = 1; + } + } + /* + * UTC, still unsure about one leap second + */ + tjd = + J1972 + (tjd_et - tjd_et_1972) - ((double)nleap + + second_60) / 86400.0; + swe_revjul(tjd, SE_GREG_CAL, iyear, imonth, iday, &d); *ihour = (int32) d; - d -= (double) *ihour; + d -= (double)*ihour; d *= 60; *imin = (int32) d; - *dsec = (d - (double) *imin) * 60.0; - } - if (gregflag == SE_JUL_CAL) { - tjd = swe_julday(*iyear, *imonth, *iday, 0, SE_GREG_CAL); - swe_revjul(tjd, gregflag, iyear, imonth, iday, &d); - } + *dsec = (d - (double)*imin) * 60.0 + second_60; + /* + * For input dates > today: + * If leap seconds table is not up to date, we'd better interpret the + * input time as UT1, not as UTC. How do we find out? + * Check, if delta_t - nleap - 32.184 > 0.9 + */ + d = swe_deltat(tjd_et); + d = swe_deltat(tjd_et - d); + if (d * 86400.0 - (double)(nleap + NLEAP_INIT) - 32.184 >= 1.0) { + swe_revjul(tjd_et - d, SE_GREG_CAL, iyear, imonth, iday, &d); + *ihour = (int32) d; + d -= (double)*ihour; + d *= 60; + *imin = (int32) d; + *dsec = (d - (double)*imin) * 60.0; + } + if (gregflag == SE_JUL_CAL) { + tjd = swe_julday(*iyear, *imonth, *iday, 0, SE_GREG_CAL); + swe_revjul(tjd, gregflag, iyear, imonth, iday, &d); + } } /* @@ -580,8 +602,10 @@ void FAR PASCAL_CONV swe_jdet_to_utc(double tjd_et, int32 gregflag, int32 *iyear * the leap seconds table (or the Swiss Ephemeris version) has not been * updated for a long time. */ -void FAR PASCAL_CONV swe_jdut1_to_utc(double tjd_ut, int32 gregflag, int32 *iyear, int32 *imonth, int32 *iday, int32 *ihour, int32 *imin, double *dsec) +void FAR PASCAL_CONV +swe_jdut1_to_utc(double tjd_ut, int32 gregflag, int32 * iyear, int32 * imonth, + int32 * iday, int32 * ihour, int32 * imin, double *dsec) { - double tjd_et = tjd_ut + swe_deltat(tjd_ut); - swe_jdet_to_utc(tjd_et, gregflag, iyear, imonth, iday, ihour, imin, dsec); + double tjd_et = tjd_ut + swe_deltat(tjd_ut); + swe_jdet_to_utc(tjd_et, gregflag, iyear, imonth, iday, ihour, imin, dsec); } diff --git a/swe/src/swedate.h b/swe/src/swedate.h index a03e3e1..1000957 100644 --- a/swe/src/swedate.h +++ b/swe/src/swedate.h @@ -1,3 +1,4 @@ + /********************************************************* $Header: /home/dieter/sweph/RCS/swedate.h,v 1.74 2008/06/16 10:07:20 dieter Exp $ version 15-feb-89 16:30 @@ -58,25 +59,27 @@ */ #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif #ifndef _SWEDLL_H -extern EXP32 int FAR PASCAL_CONV EXP16 swe_date_conversion ( - int y , int m , int d , /* year, month, day */ - double utime, /* universal time in hours (decimal) */ - char c, /* calendar g[regorian]|j[ulian]|a[stro = greg] */ - double *tgmt); + extern EXP32 int FAR PASCAL_CONV EXP16 swe_date_conversion(int y, int m, int d, /* year, month, day */ + double utime, /* universal time in hours (decimal) */ + char c, /* calendar g[regorian]|j[ulian]|a[stro = greg] */ + double *tgmt); -extern EXP32 double *FAR PASCAL_CONV EXP16 swe_julday( - int year, int month, int day, double hour, - int gregflag); + extern EXP32 double *FAR PASCAL_CONV EXP16 swe_julday(int year, int month, + int day, + double hour, + int gregflag); -extern EXP32 void FAR PASCAL_CONV EXP16 swe_revjul ( - double jd, - int gregflag, - int *jyear, int *jmon, int *jday, double *jut); + extern EXP32 void FAR PASCAL_CONV EXP16 swe_revjul(double jd, + int gregflag, + int *jyear, int *jmon, + int *jday, + double *jut); #endif #ifdef __cplusplus -} /* extern C */ +} /* extern C */ #endif diff --git a/swe/src/swedll.h b/swe/src/swedll.h index c5e6665..8683a14 100644 --- a/swe/src/swedll.h +++ b/swe/src/swedll.h @@ -1,10 +1,12 @@ + /* SWISSEPH * $Header: /home/dieter/sweph/RCS/swedll.h,v 1.75 2009/04/08 07:19:08 dieter Exp $ * * Windows DLL interface imports for the Astrodienst SWISSEPH package * -**************************************************************/ +**************************************************************/ + /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -57,469 +59,560 @@ The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used for promoting such software, products or services. -*/ - -/* $Id: swedll.h,v 1.75 2009/04/08 07:19:08 dieter Exp $ */ - +*/ + + +/* $Id: swedll.h,v 1.75 2009/04/08 07:19:08 dieter Exp $ */ + #ifdef __cplusplus -extern "C" { -#endif +extern "C" +{ + +#endif /* */ #ifndef _SWEDLL_H #define _SWEDLL_H - + #ifndef _SWEPHEXP_INCLUDED #include "swephexp.h" -#endif - +#endif /* */ + #ifdef USE_DLL16 /* 16bit DLL */ #define DllImport extern -#else -# ifdef __cplusplus +#else /* */ +#ifdef __cplusplus #define DllImport extern "C" __declspec( dllimport ) -# else +#else /* */ #define DllImport __declspec( dllimport ) -# endif -#endif - -DllImport int32 FAR PASCAL swe_heliacal_ut(double JDNDaysUTStart, double *geopos, double *datm, double *dobs, char *ObjectName, int32 TypeEvent, int32 iflag, double *dret, char *serr); -DllImport int32 FAR PASCAL swe_heliacal_pheno_ut(double JDNDaysUT, double *geopos, double *datm, double *dobs, char *ObjectName, int32 TypeEvent, int32 helflag, double *darr, char *serr); -DllImport int32 FAR PASCAL swe_vis_limit_mag(double tjdut, double *geopos, double *datm, double *dobs, char *ObjectName, int32 helflag, double *dret, char *serr); -/* the following are secret, for Victor Reijs' */ -DllImport int32 FAR PASCAL swe_heliacal_angle(double tjdut, double *dgeo, double *datm, double *dobs, int32 helflag, double mag, double azi_obj, double azi_sun, double azi_moon, double alt_moon, double *dret, char *serr); -DllImport int32 FAR PASCAL swe_topo_arcus_visionis(double tjdut, double *dgeo, double *datm, double *dobs, int32 helflag, double mag, double azi_obj, double alt_obj, double azi_sun, double azi_moon, double alt_moon, double *dret, char *serr); - -DllImport double FAR PASCAL swe_degnorm(double deg); - -DllImport char * FAR PASCAL swe_version(char *); - -DllImport int32 FAR PASCAL swe_calc( - double tjd, int ipl, int32 iflag, - double *xx, - char *serr); - -DllImport int32 FAR PASCAL swe_calc_ut( - double tjd_ut, int32 ipl, int32 iflag, - double *xx, - char *serr); - -DllImport int32 FAR PASCAL swe_fixstar( - char *star, double tjd, int32 iflag, - double *xx, - char *serr); - -DllImport int32 FAR PASCAL swe_fixstar_ut( - char *star, double tjd_ut, int32 iflag, - double *xx, - char *serr); - -DllImport int32 FAR PASCAL swe_fixstar_mag( - char *star, double *xx, char *serr); - -DllImport double FAR PASCAL swe_sidtime0(double tjd_ut, double ecl, double nut); -DllImport double FAR PASCAL swe_sidtime(double tjd_ut); - -DllImport double FAR PASCAL swe_deltat(double tjd); - -DllImport int FAR PASCAL swe_houses( - double tjd_ut, double geolat, double geolon, int hsys, - double *hcusps, double *ascmc); - -DllImport int FAR PASCAL swe_houses_ex( - double tjd_ut, int32 iflag, double geolat, double geolon, int hsys, - double *hcusps, double *ascmc); - -DllImport int FAR PASCAL swe_houses_armc( - double armc, double geolat, double eps, int hsys, - double *hcusps, double *ascmc); - -DllImport double FAR PASCAL swe_house_pos( - double armc, double geolon, double eps, int hsys, double *xpin, char *serr); - -DllImport int32 FAR PASCAL swe_gauquelin_sector( - double t_ut, int32 ipl, char *starname, int32 iflag, int32 imeth, double *geopos, double atpress, double attemp, double *dgsect, char *serr); - -DllImport void FAR PASCAL swe_set_sid_mode( - int32 sid_mode, double t0, double ayan_t0); - -DllImport double FAR PASCAL swe_get_ayanamsa(double tjd_et); - -DllImport double FAR PASCAL swe_get_ayanamsa_ut(double tjd_ut); - -DllImport char *FAR PASCAL swe_get_ayanamsa_name(int32 isidmode); - -DllImport int FAR PASCAL swe_date_conversion( - int y , int m , int d , /* year, month, day */ - double utime, /* universal time in hours (decimal) */ - char c, /* calendar g[regorian]|j[ulian]|a[stro = greg] */ - double *tjd); - -DllImport double FAR PASCAL swe_julday( - int year, int mon, int mday, - double hour, - int gregflag); - -DllImport void FAR PASCAL swe_revjul( - double jd, int gregflag, - int *year, int *mon, int *mday, - double *hour); - -DllImport void FAR PASCAL swe_utc_time_zone( - int32 iyear, int32 imonth, int32 iday, - int32 ihour, int32 imin, double dsec, - double d_timezone, - int32 *iyear_out, int32 *imonth_out, int32 *iday_out, - int32 *ihour_out, int32 *imin_out, double *dsec_out); - -DllImport int32 FAR PASCAL swe_utc_to_jd( - int32 iyear, int32 imonth, int32 iday, - int32 ihour, int32 imin, double dsec, - int32 gregflag, double *dret, char *serr); - -DllImport void FAR PASCAL swe_jdet_to_utc( - double tjd_et, int32 gregflag, - int32 *iyear, int32 *imonth, int32 *iday, - int32 *ihour, int32 *imin, double *dsec); - -DllImport void FAR PASCAL swe_jdut1_to_utc( - double tjd_ut, int32 gregflag, - int32 *iyear, int32 *imonth, int32 *iday, - int32 *ihour, int32 *imin, double *dsec); - -DllImport int FAR PASCAL swe_time_equ( - double tjd, double *e, char *serr); - -DllImport double FAR PASCAL swe_get_tid_acc(void); -DllImport void FAR PASCAL swe_set_tid_acc(double tidacc); -DllImport void FAR PASCAL swe_set_ephe_path(char *path); -DllImport void FAR PASCAL swe_set_jpl_file(char *fname); -DllImport void FAR PASCAL swe_close(void); -DllImport char *FAR PASCAL swe_get_planet_name(int ipl, char *spname); -DllImport void FAR PASCAL swe_cotrans(double *xpo, double *xpn, double eps); -DllImport void FAR PASCAL swe_cotrans_sp(double *xpo, double *xpn, double eps); - -DllImport void FAR PASCAL swe_set_topo(double geolon, double geolat, double height); - +#endif /* */ +#endif /* */ + DllImport int32 FAR PASCAL swe_heliacal_ut(double JDNDaysUTStart, + double *geopos, double *datm, + double *dobs, + char *ObjectName, + int32 TypeEvent, int32 iflag, + double *dret, char *serr); + DllImport int32 FAR PASCAL swe_heliacal_pheno_ut(double JDNDaysUT, + double *geopos, + double *datm, + double *dobs, + char *ObjectName, + int32 TypeEvent, + int32 helflag, + double *darr, + char *serr); + DllImport int32 FAR PASCAL swe_vis_limit_mag(double tjdut, + double *geopos, + double *datm, double *dobs, + char *ObjectName, + int32 helflag, + double *dret, char *serr); + + +/* the following are secret, for Victor Reijs' */ + DllImport int32 FAR PASCAL swe_heliacal_angle(double tjdut, + double *dgeo, + double *datm, + double *dobs, + int32 helflag, double mag, + double azi_obj, + double azi_sun, + double azi_moon, + double alt_moon, + double *dret, char *serr); + DllImport int32 FAR PASCAL swe_topo_arcus_visionis(double tjdut, + double *dgeo, + double *datm, + double *dobs, + int32 helflag, + double mag, + double azi_obj, + double alt_obj, + double azi_sun, + double azi_moon, + double alt_moon, + double *dret, + char *serr); + DllImport double FAR PASCAL swe_degnorm(double deg); + DllImport char *FAR PASCAL swe_version(char *); + DllImport int32 FAR PASCAL swe_calc( double tjd, int ipl, int32 iflag, + double *xx, char *serr); + DllImport int32 FAR PASCAL swe_calc_ut( double tjd_ut, int32 ipl, + int32 iflag, double *xx, + char *serr); + DllImport int32 FAR PASCAL swe_fixstar( char *star, double tjd, + int32 iflag, double *xx, + char *serr); + DllImport int32 FAR PASCAL swe_fixstar_ut( char *star, double tjd_ut, + int32 iflag, double *xx, + char *serr); + DllImport int32 FAR PASCAL swe_fixstar_mag( char *star, double *xx, + char *serr); + DllImport double FAR PASCAL swe_sidtime0(double tjd_ut, double ecl, + double nut); + DllImport double FAR PASCAL swe_sidtime(double tjd_ut); + DllImport double FAR PASCAL swe_deltat(double tjd); + DllImport int FAR PASCAL swe_houses( double tjd_ut, double geolat, + double geolon, int hsys, + double *hcusps, double *ascmc); + DllImport int FAR PASCAL swe_houses_ex( double tjd_ut, int32 iflag, + double geolat, double geolon, + int hsys, double *hcusps, + double *ascmc); + DllImport int FAR PASCAL swe_houses_armc( double armc, double geolat, + double eps, int hsys, + double *hcusps, + double *ascmc); + DllImport double FAR PASCAL swe_house_pos( double armc, double geolon, + double eps, int hsys, + double *xpin, char *serr); + DllImport int32 FAR PASCAL swe_gauquelin_sector( double t_ut, int32 ipl, + char *starname, + int32 iflag, + int32 imeth, + double *geopos, + double atpress, + double attemp, + double *dgsect, + char *serr); + DllImport void FAR PASCAL swe_set_sid_mode( int32 sid_mode, double t0, + double ayan_t0); + DllImport double FAR PASCAL swe_get_ayanamsa(double tjd_et); + DllImport double FAR PASCAL swe_get_ayanamsa_ut(double tjd_ut); + DllImport char *FAR PASCAL swe_get_ayanamsa_name(int32 isidmode); + DllImport int FAR PASCAL swe_date_conversion( int y, int m, int d, /* year, month, day */ + double utime, /* universal time in hours (decimal) */ + char c, /* calendar g[regorian]|j[ulian]|a[stro = greg] */ + double *tjd); + DllImport double FAR PASCAL swe_julday( int year, int mon, int mday, + double hour, int gregflag); + DllImport void FAR PASCAL swe_revjul( double jd, int gregflag, + int *year, int *mon, int *mday, + double *hour); + DllImport void FAR PASCAL swe_utc_time_zone( int32 iyear, int32 imonth, + int32 iday, int32 ihour, + int32 imin, double dsec, + double d_timezone, + int32 * iyear_out, + int32 * imonth_out, + int32 * iday_out, + int32 * ihour_out, + int32 * imin_out, + double *dsec_out); + DllImport int32 FAR PASCAL swe_utc_to_jd( int32 iyear, int32 imonth, + int32 iday, int32 ihour, + int32 imin, double dsec, + int32 gregflag, double *dret, + char *serr); + DllImport void FAR PASCAL swe_jdet_to_utc( double tjd_et, + int32 gregflag, + int32 * iyear, + int32 * imonth, int32 * iday, + int32 * ihour, int32 * imin, + double *dsec); + DllImport void FAR PASCAL swe_jdut1_to_utc( double tjd_ut, + int32 gregflag, + int32 * iyear, + int32 * imonth, int32 * iday, + int32 * ihour, int32 * imin, + double *dsec); + DllImport int FAR PASCAL swe_time_equ( double tjd, double *e, + char *serr); + DllImport double FAR PASCAL swe_get_tid_acc(void); + DllImport void FAR PASCAL swe_set_tid_acc(double tidacc); + DllImport void FAR PASCAL swe_set_ephe_path(char *path); + DllImport void FAR PASCAL swe_set_jpl_file(char *fname); + DllImport void FAR PASCAL swe_close(void); + DllImport char *FAR PASCAL swe_get_planet_name(int ipl, char *spname); + DllImport void FAR PASCAL swe_cotrans(double *xpo, double *xpn, + double eps); + DllImport void FAR PASCAL swe_cotrans_sp(double *xpo, double *xpn, + double eps); + DllImport void FAR PASCAL swe_set_topo(double geolon, double geolat, + double height); + + /**************************** * from swecl.c - ****************************/ - + ****************************/ + + /* computes geographic location and attributes of solar - * eclipse at a given tjd */ -DllImport int32 FAR PASCAL swe_sol_eclipse_where(double tjd, int32 ifl, double *geopos, double *attr, char *serr); - -DllImport int32 FAR PASCAL swe_lun_occult_where(double tjd, int32 ipl, char *starname, int32 ifl, double *geopos, double *attr, char *serr); - -/* computes attributes of a solar eclipse for given tjd, geolon, geolat */ -DllImport int32 FAR PASCAL swe_sol_eclipse_how(double tjd, int32 ifl, double *geopos, double *attr, char *serr); - -/* finds time of next local eclipse */ -DllImport int32 FAR PASCAL swe_sol_eclipse_when_loc(double tjd_start, int32 ifl, double *geopos, double *tret, double *attr, int32 backward, char *serr); - -DllImport int32 FAR PASCAL swe_lun_occult_when_loc(double tjd_start, int32 ipl, char *starname, int32 ifl, double *geopos, double *tret, double *attr, int32 backward, char *serr); - -/* finds time of next eclipse globally */ -DllImport int32 FAR PASCAL swe_sol_eclipse_when_glob(double tjd_start, int32 ifl, int32 ifltype, double *tret, int32 backward, char *serr); - -/* finds time of next occultation globally */ -DllImport int32 FAR PASCAL swe_lun_occult_when_glob(double tjd_start, int32 ipl, char *starname, int32 ifl, int32 ifltype, double *tret, int32 backward, char *serr); - -/* computes attributes of a lunar eclipse for given tjd */ -DllImport int32 FAR PASCAL swe_lun_eclipse_how( - double tjd_ut, - int32 ifl, - double *geopos, - double *attr, - char *serr); -DllImport int32 FAR PASCAL swe_lun_eclipse_when(double tjd_start, int32 ifl, int32 ifltype, double *tret, int32 backward, char *serr); - -/* planetary phenomena */ -DllImport int32 FAR PASCAL swe_pheno(double tjd, int32 ipl, int32 iflag, - double *attr, char *serr); - -DllImport int32 FAR PASCAL swe_pheno_ut(double tjd_ut, int32 ipl, int32 iflag, double *attr, char *serr); - -DllImport double FAR PASCAL swe_refrac(double inalt, double atpress, double attemp, int32 calc_flag); -DllImport double FAR PASCAL swe_refrac_extended(double inalt, double geoalt, double atpress, double attemp, double lapse_rate, int32 calc_flag, double *dret); -DllImport void FAR PASCAL swe_set_lapse_rate(double lapse_rate); - -DllImport void FAR PASCAL swe_azalt( - double tjd_ut, - int32 calc_flag, - double *geopos, - double atpress, - double attemp, - double *xin, - double *xaz); - -DllImport void FAR PASCAL swe_azalt_rev( - double tjd_ut, - int32 calc_flag, - double *geopos, - double *xin, - double *xout); - -DllImport int32 FAR PASCAL swe_rise_trans( - double tjd_ut, int32 ipl, char *starname, - int32 epheflag, int32 rsmi, - double *geopos, - double atpress, double attemp, - double *tret, - char *serr); - -DllImport int32 FAR PASCAL swe_rise_trans_true_hor( - double tjd_ut, int32 ipl, char *starname, - int32 epheflag, int32 rsmi, - double *geopos, - double atpress, double attemp, - double horhgt, - double *tret, - char *serr); - -DllImport int32 FAR PASCAL swe_nod_aps(double tjd_et, int32 ipl, int32 iflag, - int32 method, - double *xnasc, double *xndsc, - double *xperi, double *xaphe, - char *serr); - -DllImport int32 FAR PASCAL swe_nod_aps_ut(double tjd_ut, int32 ipl, int32 iflag, - int32 method, - double *xnasc, double *xndsc, - double *xperi, double *xaphe, - char *serr); - + * eclipse at a given tjd */ + DllImport int32 FAR PASCAL swe_sol_eclipse_where(double tjd, int32 ifl, + double *geopos, + double *attr, + char *serr); + DllImport int32 FAR PASCAL swe_lun_occult_where(double tjd, int32 ipl, + char *starname, + int32 ifl, + double *geopos, + double *attr, + char *serr); + + +/* computes attributes of a solar eclipse for given tjd, geolon, geolat */ + DllImport int32 FAR PASCAL swe_sol_eclipse_how(double tjd, int32 ifl, + double *geopos, + double *attr, + char *serr); + + +/* finds time of next local eclipse */ + DllImport int32 FAR PASCAL swe_sol_eclipse_when_loc(double tjd_start, + int32 ifl, + double *geopos, + double *tret, + double *attr, + int32 backward, + char *serr); + DllImport int32 FAR PASCAL swe_lun_occult_when_loc(double tjd_start, + int32 ipl, + char *starname, + int32 ifl, + double *geopos, + double *tret, + double *attr, + int32 backward, + char *serr); + + +/* finds time of next eclipse globally */ + DllImport int32 FAR PASCAL swe_sol_eclipse_when_glob(double tjd_start, + int32 ifl, + int32 ifltype, + double *tret, + int32 backward, + char *serr); + + +/* finds time of next occultation globally */ + DllImport int32 FAR PASCAL swe_lun_occult_when_glob(double tjd_start, + int32 ipl, + char *starname, + int32 ifl, + int32 ifltype, + double *tret, + int32 backward, + char *serr); + + +/* computes attributes of a lunar eclipse for given tjd */ + DllImport int32 FAR PASCAL swe_lun_eclipse_how( double tjd_ut, + int32 ifl, + double *geopos, + double *attr, + char *serr); + DllImport int32 FAR PASCAL swe_lun_eclipse_when(double tjd_start, + int32 ifl, + int32 ifltype, + double *tret, + int32 backward, + char *serr); + + +/* planetary phenomena */ + DllImport int32 FAR PASCAL swe_pheno(double tjd, int32 ipl, int32 iflag, + double *attr, char *serr); + DllImport int32 FAR PASCAL swe_pheno_ut(double tjd_ut, int32 ipl, + int32 iflag, double *attr, + char *serr); + DllImport double FAR PASCAL swe_refrac(double inalt, double atpress, + double attemp, int32 calc_flag); + DllImport double FAR PASCAL swe_refrac_extended(double inalt, + double geoalt, + double atpress, + double attemp, + double lapse_rate, + int32 calc_flag, + double *dret); + DllImport void FAR PASCAL swe_set_lapse_rate(double lapse_rate); + DllImport void FAR PASCAL swe_azalt( double tjd_ut, int32 calc_flag, + double *geopos, double atpress, + double attemp, double *xin, + double *xaz); + DllImport void FAR PASCAL swe_azalt_rev( double tjd_ut, + int32 calc_flag, + double *geopos, double *xin, + double *xout); + DllImport int32 FAR PASCAL swe_rise_trans( double tjd_ut, int32 ipl, + char *starname, + int32 epheflag, int32 rsmi, + double *geopos, + double atpress, + double attemp, double *tret, + char *serr); + DllImport int32 FAR PASCAL swe_rise_trans_true_hor( double tjd_ut, + int32 ipl, + char *starname, + int32 epheflag, + int32 rsmi, + double *geopos, + double atpress, + double attemp, + double horhgt, + double *tret, + char *serr); + DllImport int32 FAR PASCAL swe_nod_aps(double tjd_et, int32 ipl, + int32 iflag, int32 method, + double *xnasc, double *xndsc, + double *xperi, double *xaphe, + char *serr); + DllImport int32 FAR PASCAL swe_nod_aps_ut(double tjd_ut, int32 ipl, + int32 iflag, int32 method, + double *xnasc, double *xndsc, + double *xperi, double *xaphe, + char *serr); + + /*DllImport int32 FAR PASCAL HeliacalAngle(double Magn, double Age, int SN, double AziO, double AltM, double AziM, double JDNDaysUT, double AziS, double Lat, double HeightEye, double Temperature, double Pressure, double RH, double VR, double *dangret, char *serr); -DllImport int32 FAR PASCAL HeliacalJDut(double JDNDaysUTStart, double Age, int SN, double Lat, double Longitude, double HeightEye, double Temperature, double Pressure, double RH, double VR, char *ObjectName, int TypeEvent, char *AVkind, double *dret, char *serr);*/ - +DllImport int32 FAR PASCAL HeliacalJDut(double JDNDaysUTStart, double Age, int SN, double Lat, double Longitude, double HeightEye, double Temperature, double Pressure, double RH, double VR, char *ObjectName, int TypeEvent, char *AVkind, double *dret, char *serr);*/ + + /******************************************************* * other functions from swephlib.c; * they are not needed for Swiss Ephemeris, * but may be useful to former Placalc users. - ********************************************************/ - -/* normalize argument into interval [0..DEG360] */ -DllImport centisec FAR PASCAL swe_csnorm(centisec p); - -/* distance in centisecs p1 - p2 normalized to [0..360[ */ -DllImport centisec FAR PASCAL swe_difcsn (centisec p1, centisec p2); - -DllImport double FAR PASCAL swe_difdegn (double p1, double p2); - -/* distance in centisecs p1 - p2 normalized to [-180..180[ */ -DllImport centisec FAR PASCAL swe_difcs2n(centisec p1, centisec p2); - -DllImport double FAR PASCAL swe_difdeg2n(double p1, double p2); - -DllImport double FAR PASCAL swe_difdeg2n(double p1, double p2); -DllImport double FAR PASCAL swe_difrad2n(double p1, double p2); -DllImport double FAR PASCAL swe_rad_midp(double x1, double x0); -DllImport double FAR PASCAL swe_deg_midp(double x1, double x0); - -/* round second, but at 29.5959 always down */ -DllImport centisec FAR PASCAL swe_csroundsec(centisec x); - -/* double to int32 with rounding, no overflow check */ -DllImport int32 FAR PASCAL swe_d2l(double x); - -DllImport void FAR PASCAL swe_split_deg(double ddeg, int32 roundflag, int32 *ideg, int32 *imin, int32 *isec, double *dsecfr, int32 *isgn); - -/* monday = 0, ... sunday = 6 */ -DllImport int FAR PASCAL swe_day_of_week(double jd); - -DllImport char *FAR PASCAL swe_cs2timestr(CSEC t, int sep, AS_BOOL suppressZero, char *a); - -DllImport char *FAR PASCAL swe_cs2lonlatstr(CSEC t, char pchar, char mchar, char *s); - -DllImport char *FAR PASCAL swe_cs2degstr(CSEC t, char *a); - - + ********************************************************/ + + +/* normalize argument into interval [0..DEG360] */ + DllImport centisec FAR PASCAL swe_csnorm(centisec p); + + +/* distance in centisecs p1 - p2 normalized to [0..360[ */ + DllImport centisec FAR PASCAL swe_difcsn(centisec p1, centisec p2); + DllImport double FAR PASCAL swe_difdegn(double p1, double p2); + + +/* distance in centisecs p1 - p2 normalized to [-180..180[ */ + DllImport centisec FAR PASCAL swe_difcs2n(centisec p1, centisec p2); + DllImport double FAR PASCAL swe_difdeg2n(double p1, double p2); + DllImport double FAR PASCAL swe_difdeg2n(double p1, double p2); + DllImport double FAR PASCAL swe_difrad2n(double p1, double p2); + DllImport double FAR PASCAL swe_rad_midp(double x1, double x0); + DllImport double FAR PASCAL swe_deg_midp(double x1, double x0); + + +/* round second, but at 29.5959 always down */ + DllImport centisec FAR PASCAL swe_csroundsec(centisec x); + + +/* double to int32 with rounding, no overflow check */ + DllImport int32 FAR PASCAL swe_d2l(double x); + DllImport void FAR PASCAL swe_split_deg(double ddeg, int32 roundflag, + int32 * ideg, int32 * imin, + int32 * isec, double *dsecfr, + int32 * isgn); + + +/* monday = 0, ... sunday = 6 */ + DllImport int FAR PASCAL swe_day_of_week(double jd); + DllImport char *FAR PASCAL swe_cs2timestr(CSEC t, int sep, + AS_BOOL suppressZero, + char *a); + DllImport char *FAR PASCAL swe_cs2lonlatstr(CSEC t, char pchar, + char mchar, char *s); + DllImport char *FAR PASCAL swe_cs2degstr(CSEC t, char *a); + + /* additional functions for antiquated GFA basic DLL interface. * double -> double * * char -> char * * void -> int - */ - -DllImport int32 FAR PASCAL swe_calc_d( - double *tjd, int ipl, int32 iflag, - double *x, - char *serr); - -DllImport int32 FAR PASCAL swe_calc_ut_d( - double *tjd, int16 ipl, int32 iflag, - double *x, - char *serr); - -DllImport int32 FAR PASCAL swe_fixstar_d( - char *star, double *tjd, int32 iflag, - double *x, - char *serr); - -DllImport int32 FAR PASCAL swe_fixstar_ut_d( - char *star, double *tjd, int32 iflag, - double *x, - char *serr); - -DllImport int FAR PASCAL swe_close_d(int ivoid); - -DllImport int FAR PASCAL swe_set_ephe_path_d(char *path); - -DllImport int FAR PASCAL swe_set_jpl_file_d(char *fname); - -DllImport char *FAR PASCAL swe_get_planet_name_d(int ipl, char *spname); - -DllImport int FAR PASCAL swe_deltat_d(double *tjd, double *deltat); - -DllImport int FAR PASCAL swe_sidtime0_d(double *tjd_ut, double *eps, -double *nut, double *sidt); -DllImport int FAR PASCAL swe_sidtime_d(double *tjd_ut, double *sidt); - -DllImport int FAR PASCAL swe_set_sid_mode_d( - int32 sid_mode, double *t0, double *ayan_t0); - -DllImport int FAR PASCAL swe_get_ayanamsa_d(double *tjd_et, double *ayan); -DllImport int FAR PASCAL swe_get_ayanamsa_ut_d(double *tjd_et, double *ayan); - -DllImport int FAR PASCAL swe_cotrans_d(double *xpo, double *xpn, double *eps); -DllImport int FAR PASCAL swe_cotrans_sp_d(double *xpo, double *xpn, double *eps); - -DllImport int FAR PASCAL swe_set_topo_d(double *geolon, double *geolat, double *height); - -DllImport int FAR PASCAL swe_get_tid_acc_d(double *t_acc); -DllImport int FAR PASCAL swe_set_tid_acc_d(double *t_acc); - -DllImport int FAR PASCAL swe_degnorm_d(double *x); - -DllImport int FAR PASCAL swe_date_conversion_d( - int y , int m , int d , /* year, month, day */ - double *utime, /* universal time in hours (decimal) */ - char *c, /* calendar g[regorian]|j[ulian]|a[stro = greg] */ - double *tjd); - -DllImport int FAR PASCAL swe_julday_d( - int year, int month, int day, double *hour, - int gregflag, double *tjd); - -DllImport int FAR PASCAL swe_revjul_d( - double *tjd, - int gregflag, - int *jyear, int *jmon, int *jday, double *jut); - -DllImport int FAR PASCAL swe_houses_d( - double *tjd, double *geolat, double *geolon, int hsys, - double *hcusps, double *ascmc); - -DllImport int FAR PASCAL swe_houses_ex_d( - double *tjd_ut, int32 iflag, double *geolat, double *geolon, int hsys, - double *hcusps, double *ascmc); - -DllImport int FAR PASCAL swe_houses_armc_d( - double *armc, double *geolat, double *eps, int hsys, - double *hcusps, double *ascmc); - -DllImport int FAR PASCAL swe_house_pos_d( - double *armc, double *geolon, double *eps, int hsys, double *xpin, double *hpos, char *serr); - -/* normalize argument into interval [0..DEG360] */ -DllImport centisec FAR PASCAL swe_csnorm_d(centisec p); - -/* distance in centisecs p1 - p2 normalized to [0..360[ */ -DllImport centisec FAR PASCAL swe_difcsn_d(centisec p1, centisec p2); - -DllImport int FAR PASCAL swe_difdegn_d(double *p1, double *p2, double *diff); - -/* distance in centisecs p1 - p2 normalized to [-180..180[ */ -DllImport centisec FAR PASCAL swe_difcs2n_d(centisec p1, centisec p2); - -DllImport int FAR PASCAL swe_difdeg2n_d(double *p1, double *p2, double *diff); - -/* round second, but at 29.5959 always down */ -DllImport centisec FAR PASCAL swe_csroundsec_d(centisec x); - -/* double to int32 with rounding, no overflow check */ -DllImport int32 FAR PASCAL swe_d2l_d(double *x); - -DllImport int FAR PASCAL swe_split_deg_d(double *ddeg, int32 roundflag, int32 *ideg, int32 *imin, int32 *isec, double *dsecfr, int32 *isgn); - -/* monday = 0, ... sunday = 6 */ -DllImport int FAR PASCAL swe_day_of_week_d(double *jd); - -DllImport char *FAR PASCAL swe_cs2timestr_d(CSEC t, int sep, AS_BOOL suppressZero, char *a); - -DllImport char *FAR PASCAL swe_cs2lonlatstr_d(CSEC t, char *pchar, char *mchar, char *s); - -DllImport char *FAR PASCAL swe_cs2degstr_d(CSEC t, char *a); - + */ + DllImport int32 FAR PASCAL swe_calc_d( double *tjd, int ipl, + int32 iflag, double *x, + char *serr); + DllImport int32 FAR PASCAL swe_calc_ut_d( double *tjd, int16 ipl, + int32 iflag, double *x, + char *serr); + DllImport int32 FAR PASCAL swe_fixstar_d( char *star, double *tjd, + int32 iflag, double *x, + char *serr); + DllImport int32 FAR PASCAL swe_fixstar_ut_d( char *star, double *tjd, + int32 iflag, double *x, + char *serr); + DllImport int FAR PASCAL swe_close_d(int ivoid); + DllImport int FAR PASCAL swe_set_ephe_path_d(char *path); + DllImport int FAR PASCAL swe_set_jpl_file_d(char *fname); + DllImport char *FAR PASCAL swe_get_planet_name_d(int ipl, char *spname); + DllImport int FAR PASCAL swe_deltat_d(double *tjd, double *deltat); + DllImport int FAR PASCAL swe_sidtime0_d(double *tjd_ut, double *eps, + double *nut, double *sidt); + DllImport int FAR PASCAL swe_sidtime_d(double *tjd_ut, double *sidt); + DllImport int FAR PASCAL swe_set_sid_mode_d( int32 sid_mode, double *t0, + double *ayan_t0); + DllImport int FAR PASCAL swe_get_ayanamsa_d(double *tjd_et, + double *ayan); + DllImport int FAR PASCAL swe_get_ayanamsa_ut_d(double *tjd_et, + double *ayan); + DllImport int FAR PASCAL swe_cotrans_d(double *xpo, double *xpn, + double *eps); + DllImport int FAR PASCAL swe_cotrans_sp_d(double *xpo, double *xpn, + double *eps); + DllImport int FAR PASCAL swe_set_topo_d(double *geolon, double *geolat, + double *height); + DllImport int FAR PASCAL swe_get_tid_acc_d(double *t_acc); + DllImport int FAR PASCAL swe_set_tid_acc_d(double *t_acc); + DllImport int FAR PASCAL swe_degnorm_d(double *x); + DllImport int FAR PASCAL swe_date_conversion_d( int y, int m, int d, /* year, month, day */ + double *utime, /* universal time in hours (decimal) */ + char *c, /* calendar g[regorian]|j[ulian]|a[stro = greg] */ + double *tjd); + DllImport int FAR PASCAL swe_julday_d( int year, int month, int day, + double *hour, int gregflag, + double *tjd); + DllImport int FAR PASCAL swe_revjul_d( double *tjd, int gregflag, + int *jyear, int *jmon, int *jday, + double *jut); + DllImport int FAR PASCAL swe_houses_d( double *tjd, double *geolat, + double *geolon, int hsys, + double *hcusps, double *ascmc); + DllImport int FAR PASCAL swe_houses_ex_d( double *tjd_ut, int32 iflag, + double *geolat, double *geolon, + int hsys, double *hcusps, + double *ascmc); + DllImport int FAR PASCAL swe_houses_armc_d( double *armc, + double *geolat, double *eps, + int hsys, double *hcusps, + double *ascmc); + DllImport int FAR PASCAL swe_house_pos_d( double *armc, double *geolon, + double *eps, int hsys, + double *xpin, double *hpos, + char *serr); + + +/* normalize argument into interval [0..DEG360] */ + DllImport centisec FAR PASCAL swe_csnorm_d(centisec p); + + +/* distance in centisecs p1 - p2 normalized to [0..360[ */ + DllImport centisec FAR PASCAL swe_difcsn_d(centisec p1, centisec p2); + DllImport int FAR PASCAL swe_difdegn_d(double *p1, double *p2, + double *diff); + + +/* distance in centisecs p1 - p2 normalized to [-180..180[ */ + DllImport centisec FAR PASCAL swe_difcs2n_d(centisec p1, centisec p2); + DllImport int FAR PASCAL swe_difdeg2n_d(double *p1, double *p2, + double *diff); + + +/* round second, but at 29.5959 always down */ + DllImport centisec FAR PASCAL swe_csroundsec_d(centisec x); + + +/* double to int32 with rounding, no overflow check */ + DllImport int32 FAR PASCAL swe_d2l_d(double *x); + DllImport int FAR PASCAL swe_split_deg_d(double *ddeg, int32 roundflag, + int32 * ideg, int32 * imin, + int32 * isec, double *dsecfr, + int32 * isgn); + + +/* monday = 0, ... sunday = 6 */ + DllImport int FAR PASCAL swe_day_of_week_d(double *jd); + DllImport char *FAR PASCAL swe_cs2timestr_d(CSEC t, int sep, + AS_BOOL suppressZero, + char *a); + DllImport char *FAR PASCAL swe_cs2lonlatstr_d(CSEC t, char *pchar, + char *mchar, char *s); + DllImport char *FAR PASCAL swe_cs2degstr_d(CSEC t, char *a); + + /**************************** * from swecl.c - ****************************/ - + ****************************/ + + /* computes geographic location and attributes of solar - * eclipse at a given tjd */ -DllImport int32 FAR PASCAL swe_sol_eclipse_where_d(double *tjd_ut, int32 ifl, double *geopos, double *attr, char *serr); - -/* computes attributes of a solar eclipse for given tjd, geolon, geolat */ -DllImport int32 FAR PASCAL swe_sol_eclipse_how_d(double *tjd_ut, int32 ifl, double geolon, double geolat, double geohgt, double *attr, char *serr); - -/* finds time of next local eclipse */ -DllImport int32 FAR PASCAL swe_sol_eclipse_when_loc_d(double *tjd_start, int32 ifl, double *geopos, double *tret, double *attr, AS_BOOL backward, char *serr); - -/* finds time of next eclipse globally */ -DllImport int32 FAR PASCAL swe_sol_eclipse_when_glob_d(double *tjd_start, int32 ifl, int32 ifltype, - double *tret, AS_BOOL backward, char *serr); - -/* computes attributes of a lunar eclipse for given tjd */ -DllImport int32 FAR PASCAL swe_lun_eclipse_how_d( - double *tjd_ut, - int32 ifl, - double *attr, - char *serr); -DllImport int32 FAR PASCAL swe_lun_eclipse_when_d(double *tjd_start, int32 ifl, int32 ifltype, - double *tret, AS_BOOL backward, char *serr); - -DllImport int32 FAR PASCAL swe_pheno_d(double *tjd, int32 ipl, int32 iflag, - double *attr, char *serr); - -DllImport int32 FAR PASCAL swe_pheno_ut_d(double *tjd_ut, int32 ipl, int32 iflag, double *attr, char *serr); - -DllImport int FAR PASCAL swe_refrac_d(double *inalt, double *atpress, double *attemp, int32 calc_flag, double *retalt); - -DllImport int FAR PASCAL swe_azalt_d( - double *tjd_ut, - int32 calc_flag, - double *geopos, - double *atpress, - double *attemp, - double *xin, - double *xaz); - -DllImport int FAR PASCAL swe_azalt_rev_d( - double *tjd_ut, - int32 calc_flag, - double *geopos, - double *xin, - double *xout); - -DllImport int32 FAR PASCAL swe_rise_trans_d( - double *tjd_ut, int32 ipl, char *starname, - int32 epheflag, int32 rsmi, - double *geopos, - double *atpress, double *attemp, - double *tret, - char *serr); - -DllImport int32 FAR PASCAL swe_nod_aps_d(double *tjd_et, int32 ipl, int32 iflag, - int32 method, - double *xnasc, double *xndsc, - double *xperi, double *xaphe, - char *serr); - -DllImport int32 FAR PASCAL swe_nod_aps_ut_d(double *tjd_ut, int32 ipl, int32 iflag, - int32 method, - double *xnasc, double *xndsc, - double *xperi, double *xaphe, - char *serr); - -#endif /* !_SWEDLL_H */ + * eclipse at a given tjd */ + DllImport int32 FAR PASCAL swe_sol_eclipse_where_d(double *tjd_ut, + int32 ifl, + double *geopos, + double *attr, + char *serr); + + +/* computes attributes of a solar eclipse for given tjd, geolon, geolat */ + DllImport int32 FAR PASCAL swe_sol_eclipse_how_d(double *tjd_ut, + int32 ifl, + double geolon, + double geolat, + double geohgt, + double *attr, + char *serr); + + +/* finds time of next local eclipse */ + DllImport int32 FAR PASCAL swe_sol_eclipse_when_loc_d(double *tjd_start, + int32 ifl, + double *geopos, + double *tret, + double *attr, + AS_BOOL backward, + char *serr); + + +/* finds time of next eclipse globally */ + DllImport int32 FAR PASCAL swe_sol_eclipse_when_glob_d(double + *tjd_start, + int32 ifl, + int32 ifltype, + double *tret, + AS_BOOL backward, + char *serr); + + +/* computes attributes of a lunar eclipse for given tjd */ + DllImport int32 FAR PASCAL swe_lun_eclipse_how_d( double *tjd_ut, + int32 ifl, + double *attr, + char *serr); + DllImport int32 FAR PASCAL swe_lun_eclipse_when_d(double *tjd_start, + int32 ifl, + int32 ifltype, + double *tret, + AS_BOOL backward, + char *serr); + DllImport int32 FAR PASCAL swe_pheno_d(double *tjd, int32 ipl, + int32 iflag, double *attr, + char *serr); + DllImport int32 FAR PASCAL swe_pheno_ut_d(double *tjd_ut, int32 ipl, + int32 iflag, double *attr, + char *serr); + DllImport int FAR PASCAL swe_refrac_d(double *inalt, double *atpress, + double *attemp, int32 calc_flag, + double *retalt); + DllImport int FAR PASCAL swe_azalt_d( double *tjd_ut, int32 calc_flag, + double *geopos, double *atpress, + double *attemp, double *xin, + double *xaz); + DllImport int FAR PASCAL swe_azalt_rev_d( double *tjd_ut, + int32 calc_flag, + double *geopos, double *xin, + double *xout); + DllImport int32 FAR PASCAL swe_rise_trans_d( double *tjd_ut, int32 ipl, + char *starname, + int32 epheflag, int32 rsmi, + double *geopos, + double *atpress, + double *attemp, + double *tret, char *serr); + DllImport int32 FAR PASCAL swe_nod_aps_d(double *tjd_et, int32 ipl, + int32 iflag, int32 method, + double *xnasc, double *xndsc, + double *xperi, double *xaphe, + char *serr); + DllImport int32 FAR PASCAL swe_nod_aps_ut_d(double *tjd_ut, int32 ipl, + int32 iflag, int32 method, + double *xnasc, + double *xndsc, + double *xperi, + double *xaphe, char *serr); + +#endif /* !_SWEDLL_H */ #ifdef __cplusplus -} /* extern C */ -#endif +} /* extern C */ +#endif /* */ diff --git a/swe/src/swehel.c b/swe/src/swehel.c index 9709bab..3c9d461 100644 --- a/swe/src/swehel.c +++ b/swe/src/swehel.c @@ -1,3 +1,4 @@ + /* SWISSEPH $Header: /home/dieter/sweph/RCS/swehel.c,v 1.1 2009/04/21 06:05:59 dieter Exp dieter $ @@ -70,104 +71,108 @@ #include "swephlib.h" #include -#define PLSV 0 /*if Planet, Lunar and Stellar Visibility formula is needed PLSV=1*/ -#define criticalangle 0.0 /*[deg]*/ -#define BNIGHT 1479.0 /*[nL]*/ +#define PLSV 0 /*if Planet, Lunar and Stellar Visibility formula is needed PLSV=1 */ +#define criticalangle 0.0 /*[deg] */ +#define BNIGHT 1479.0 /*[nL] */ #define BNIGHT_FACTOR 1.0 #define PI M_PI #define Min2Deg (1.0 / 60.0) #define DEBUG 0 #define DONE 1 -#define MaxTryHours 4 +#define MaxTryHours 4 #define TimeStepDefault 1 #define LocalMinStep 8 /* time constants */ -#define Y2D 365.25 /*[Day]*/ -#define D2Y (1 / Y2D) /*[Year]*/ -#define D2H 24.0 /*[Hour]*/ -#define H2S 3600.0 /*[sec]*/ -#define D2S (D2H * H2S) /*[sec]*/ -#define S2H (1.0 / H2S) /*[Hour]*/ -#define JC2D 36525.0 /*[Day]*/ -#define M2S 60.0 /*[sec]*/ +#define Y2D 365.25 /*[Day] */ +#define D2Y (1 / Y2D) /*[Year] */ +#define D2H 24.0 /*[Hour] */ +#define H2S 3600.0 /*[sec] */ +#define D2S (D2H * H2S) /*[sec] */ +#define S2H (1.0 / H2S) /*[Hour] */ +#define JC2D 36525.0 /*[Day] */ +#define M2S 60.0 /*[sec] */ /* Determines which algorimths are used*/ #define USE_DELTA_T_VR 0 #define REFR_SINCLAIR 0 #define REFR_BENNETTH 1 -#define FormAstroRefrac REFR_SINCLAIR /*for Astronomical refraction can be "bennetth" or "sinclair"*/ -#define GravitySource 2 /*0=RGO, 1=Wikipedia,2=Exp. Suppl. 1992,3=van der Werf*/ -#define REarthSource 1 /*0=RGO (constant), 1=WGS84 method*/ +#define FormAstroRefrac REFR_SINCLAIR /*for Astronomical refraction can be "bennetth" or "sinclair" */ +#define GravitySource 2 /*0=RGO, 1=Wikipedia,2=Exp. Suppl. 1992,3=van der Werf */ +#define REarthSource 1 /*0=RGO (constant), 1=WGS84 method */ -#define StartYear 1820 /*[year]*/ -#define Average 1.80546834626888 /*[msec/cy]*/ -#define Periodicy 1443.67123144531 /*[year]*/ -#define Amplitude 3.75606495492684 /*[msec]*/ -#define phase 0 /*[deg]*/ -#define MAX_COUNT_SYNPER 5 /* search within 10 synodic periods */ -#define MAX_COUNT_SYNPER_MAX 1000000 /* high, so there is not max count */ -#define AvgRadiusMoon (15.541 / 60) /* '[Deg] at 2007 CE or BCE*/ +#define StartYear 1820 /*[year] */ +#define Average 1.80546834626888 /*[msec/cy] */ +#define Periodicy 1443.67123144531 /*[year] */ +#define Amplitude 3.75606495492684 /*[msec] */ +#define phase 0 /*[deg] */ +#define MAX_COUNT_SYNPER 5 /* search within 10 synodic periods */ +#define MAX_COUNT_SYNPER_MAX 1000000 /* high, so there is not max count */ +#define AvgRadiusMoon (15.541 / 60) /* '[Deg] at 2007 CE or BCE */ /* WGS84 ellipsoid constants * http://w3sli.wcape.gov.za/Surveys/Mapping/wgs84.htm*/ -#define Ra 6378136.6 /*'[m]*/ -#define Rb 6356752.314 /*'[m]*/ +#define Ra 6378136.6 /*'[m] */ +#define Rb 6356752.314 /*'[m] */ /* choices in Schaefer's model */ #define nL2erg (1.02E-15) -#define erg2nL (1 / nL2erg) /*erg2nL to nLambert*/ -#define MoonDistance 384410.4978 /*[km]*/ -#define scaleHwater 3000.0 /*[m] Ricchiazzi [1997] 8200 Schaefer [2000]*/ -#define scaleHrayleigh 8515.0 /*[m] Su [2003] 8200 Schaefer [2000]*/ -#define scaleHaerosol 3745.0 /*m Su [2003] 1500 Schaefer [2000]*/ -#define scaleHozone 20000.0 /*[m] Schaefer [2000]*/ -#define astr2tau 0.921034037197618 /*LN(10 ^ 0.4)*/ +#define erg2nL (1 / nL2erg) /*erg2nL to nLambert */ +#define MoonDistance 384410.4978 /*[km] */ +#define scaleHwater 3000.0 /*[m] Ricchiazzi [1997] 8200 Schaefer [2000] */ +#define scaleHrayleigh 8515.0 /*[m] Su [2003] 8200 Schaefer [2000] */ +#define scaleHaerosol 3745.0 /*m Su [2003] 1500 Schaefer [2000] */ +#define scaleHozone 20000.0 /*[m] Schaefer [2000] */ +#define astr2tau 0.921034037197618 /*LN(10 ^ 0.4) */ #define tau2astr 1 / astr2tau /* meteorological constants*/ -#define C2K 273.15 /*[K]*/ +#define C2K 273.15 /*[K] */ #define DELTA 18.36 #define TempNulDiff 0.000001 -#define PressRef 1000 /*[mbar]*/ -#define MD 28.964 /*[kg] Mol weight of dry air van der Werf*/ -#define MW 18.016 /*[kg] Mol weight of water vapor*/ -#define GCR 8314.472 /*[L/kmol/K] van der Werf*/ -#define LapseSA 0.0065 /*[K/m] standard atmosphere*/ -#define LapseDA 0.0098 /*[K/m] dry adiabatic*/ +#define PressRef 1000 /*[mbar] */ +#define MD 28.964 /*[kg] Mol weight of dry air van der Werf */ +#define MW 18.016 /*[kg] Mol weight of water vapor */ +#define GCR 8314.472 /*[L/kmol/K] van der Werf */ +#define LapseSA 0.0065 /*[K/m] standard atmosphere */ +#define LapseDA 0.0098 /*[K/m] dry adiabatic */ /* lowest apparent altitude to provide*/ -#define LowestAppAlt -3.5 /*[Deg]*/ +#define LowestAppAlt -3.5 /*[Deg] */ /*optimization delta*/ #define epsilon 0.001 + /* for Airmass usage*/ -#define staticAirmass 0 /* use staticAirmass=1 instead depending on difference k's*/ +#define staticAirmass 0 /* use staticAirmass=1 instead depending on difference k's */ /* optic stuff */ -#define GOpticMag 1 /*telescope magnification*/ -#define GOpticTrans 0.8 /*telescope transmission*/ -#define GBinocular 1 /*1-binocular 0=monocular*/ -#define GOpticDia 50 /*telescope diameter [mm]*/ +#define GOpticMag 1 /*telescope magnification */ +#define GOpticTrans 0.8 /*telescope transmission */ +#define GBinocular 1 /*1-binocular 0=monocular */ +#define GOpticDia 50 /*telescope diameter [mm] */ -static double mymin(double a, double b) +static double +mymin(double a, double b) { - if (a <= b) - return a; - return b; + if (a <= b) + return a; + return b; } -static double mymax(double a, double b) +static double +mymax(double a, double b) { - if (a >= b) - return a; - return b; + if (a >= b) + return a; + return b; } /*###################################################################*/ -static double Tanh(double x) +static double +Tanh(double x) { - return (exp(x) - exp(-x)) / (exp(x) + exp(-x)); + return (exp(x) - exp(-x)) / (exp(x) + exp(-x)); } /* @@ -175,13 +180,16 @@ static double Tanh(double x) ' SN [-] ' CVA [deg] */ -static double CVA(double B, double SN) +static double +CVA(double B, double SN) { - /*Schaefer, Astronomy and the limits of vision, Archaeoastronomy, 1993*/ - if (B > BNIGHT) - return (40.0 / SN) * pow(10, (8.28 * pow(B, (-0.29)))) / 60.0 / 60.0; - else - return mymin(900, 380 / SN * pow(10, (0.3 * pow(B, (-0.29))))) / 60.0 / 60.0; + /*Schaefer, Astronomy and the limits of vision, Archaeoastronomy, 1993 */ + if (B > BNIGHT) + return (40.0 / SN) * pow(10, (8.28 * pow(B, (-0.29)))) / 60.0 / 60.0; + else + return mymin(900, + 380 / SN * pow(10, + (0.3 * pow(B, (-0.29))))) / 60.0 / 60.0; } /* @@ -189,10 +197,13 @@ static double CVA(double B, double SN) ' B [nL] ' PupilDia [mm] */ -static double PupilDia(double Age, double B) +static double +PupilDia(double Age, double B) { - /* age dependancy from Garstang [2000]*/ - return (0.534 - 0.00211 * Age - (0.236 - 0.00127 * Age) * Tanh(0.4 * log(B) / log(10) - 2.2)) * 10; + /* age dependancy from Garstang [2000] */ + return (0.534 - 0.00211 * Age - + (0.236 - 0.00127 * Age) * Tanh(0.4 * log(B) / log(10) - + 2.2)) * 10; } /* @@ -211,179 +222,210 @@ static double PupilDia(double Age, double B) 'Output ' OpticFactor [-] */ -static double OpticFactor(double Bback, double kX, double *dobs, double JDNDaysUT, char *ObjectName, int TypeFactor, int helflag) +static double +OpticFactor(double Bback, double kX, double *dobs, double JDNDaysUT, + char *ObjectName, int TypeFactor, int helflag) { - double Pst, CIb, CIi, ObjectSize, Fb, Fe, Fsc, Fci, Fcb, Ft, Fp, Fa, Fr, Fm; - double Age = dobs[0]; - double SN = dobs[1], SNi; - double Binocular = dobs[2]; - double OpticMag = dobs[3]; - double OpticDia = dobs[4]; - double OpticTrans = dobs[5]; - SNi = SN; - if (SNi <= 0.00000001) SNi = 0.00000001; - /* 23 jaar as standard from Garstang*/ - Pst = PupilDia(23, Bback); - if (OpticMag == 1) { /*OpticMagn=1 means using eye*/ - OpticTrans = 1; - OpticDia = Pst; - } -#if 0 /*is done in default_heliacal_parameters()*/ - if (OpticMag == 0) { /*OpticMagn=0 (undefined) using eye*/ - OpticTrans = 1; - OpticDia = Pst; - Binocular = 1; - OpticMag = 1; - } + double Pst, CIb, CIi, ObjectSize, Fb, Fe, Fsc, Fci, Fcb, Ft, Fp, Fa, Fr, + Fm; + double Age = dobs[0]; + double SN = dobs[1], SNi; + double Binocular = dobs[2]; + double OpticMag = dobs[3]; + double OpticDia = dobs[4]; + double OpticTrans = dobs[5]; + SNi = SN; + if (SNi <= 0.00000001) + SNi = 0.00000001; + /* 23 jaar as standard from Garstang */ + Pst = PupilDia(23, Bback); + if (OpticMag == 1) { /*OpticMagn=1 means using eye */ + OpticTrans = 1; + OpticDia = Pst; + } +#if 0 /*is done in default_heliacal_parameters() */ + if (OpticMag == 0) { /*OpticMagn=0 (undefined) using eye */ + OpticTrans = 1; + OpticDia = Pst; + Binocular = 1; + OpticMag = 1; + } #endif - /* Schaefer, Astronomy and the limits of vision, Archaeoastronomy, 1993*/ - CIb = 0.7; /* color of background (from Ben Sugerman)*/ - CIi = 0.5; /* Color index for white (from Ben Sugerman), should be function of ObjectName*/ - ObjectSize = 0; - if (strcmp(ObjectName, "moon") == 0) { - /*ObjectSize and CI needs to be determined (depending on JDNDaysUT)*/ - ; - } - Fb = 1; - if (Binocular == 0) Fb = 1.41; - if (Bback < BNIGHT && !(helflag & SE_HELFLAG_VISLIM_PHOTOPIC)) { - Fe = pow(10, (0.48 * kX)); - Fsc = mymin(1, (1 - pow(Pst / 124.4, 4)) / (1 - pow((OpticDia / OpticMag / 124.4), 4))); - Fci = pow(10, (-0.4 * (1 - CIi / 2.0))); - Fcb = pow(10, (-0.4 * (1 - CIb / 2.0))); - } else { - Fe = pow(10, (0.4 * kX)); - Fsc = mymin(1, pow((OpticDia / OpticMag / Pst), 2) * (1 - exp(-pow((Pst / 6.2), 2))) / (1 - exp(-pow((OpticDia / OpticMag / 6.2), 2)))); - Fci = 1; - Fcb = 1; - } - Ft = 1 / OpticTrans; - Fp = mymax(1, pow((Pst / (OpticMag * PupilDia(Age, Bback))), 2)); - Fa = pow((Pst / OpticDia), 2); - Fr = (1 + 0.03 * pow((OpticMag * ObjectSize / CVA(Bback, SNi)), 2)) / pow(SNi, 2); - Fm = pow(OpticMag, 2); + /* Schaefer, Astronomy and the limits of vision, Archaeoastronomy, 1993 */ + CIb = 0.7; /* color of background (from Ben Sugerman) */ + CIi = 0.5; /* Color index for white (from Ben Sugerman), should be function of ObjectName */ + ObjectSize = 0; + if (strcmp(ObjectName, "moon") == 0) { + /*ObjectSize and CI needs to be determined (depending on JDNDaysUT) */ + ; + } + Fb = 1; + if (Binocular == 0) + Fb = 1.41; + if (Bback < BNIGHT && !(helflag & SE_HELFLAG_VISLIM_PHOTOPIC)) { + Fe = pow(10, (0.48 * kX)); + Fsc = + mymin(1, + (1 - pow(Pst / 124.4, 4)) / (1 - + pow((OpticDia / OpticMag / + 124.4), 4))); + Fci = pow(10, (-0.4 * (1 - CIi / 2.0))); + Fcb = pow(10, (-0.4 * (1 - CIb / 2.0))); + } + else { + Fe = pow(10, (0.4 * kX)); + Fsc = + mymin(1, + pow((OpticDia / OpticMag / Pst), + 2) * (1 - exp(-pow((Pst / 6.2), 2))) / (1 - + exp(-pow + ((OpticDia / + OpticMag / + 6.2), + 2)))); + Fci = 1; + Fcb = 1; + } + Ft = 1 / OpticTrans; + Fp = mymax(1, pow((Pst / (OpticMag * PupilDia(Age, Bback))), 2)); + Fa = pow((Pst / OpticDia), 2); + Fr = (1 + + 0.03 * pow((OpticMag * ObjectSize / CVA(Bback, SNi)), 2)) / pow(SNi, + 2); + Fm = pow(OpticMag, 2); #if DEBUG - fprintf(stderr, "Pst=%f\n", Pst); - fprintf(stderr, "Fb =%f\n", Fb); - fprintf(stderr, "Fe =%f\n", Fe); - fprintf(stderr, "Ft =%f\n", Ft); - fprintf(stderr, "Fp =%f\n", Fp); - fprintf(stderr, "Fa =%f\n", Fa); - fprintf(stderr, "Fm =%f\n", Fm); - fprintf(stderr, "Fsc=%f\n", Fsc); - fprintf(stderr, "Fci=%f\n", Fci); - fprintf(stderr, "Fcb=%f\n", Fcb); - fprintf(stderr, "Fr =%f\n", Fr ); + fprintf(stderr, "Pst=%f\n", Pst); + fprintf(stderr, "Fb =%f\n", Fb); + fprintf(stderr, "Fe =%f\n", Fe); + fprintf(stderr, "Ft =%f\n", Ft); + fprintf(stderr, "Fp =%f\n", Fp); + fprintf(stderr, "Fa =%f\n", Fa); + fprintf(stderr, "Fm =%f\n", Fm); + fprintf(stderr, "Fsc=%f\n", Fsc); + fprintf(stderr, "Fci=%f\n", Fci); + fprintf(stderr, "Fcb=%f\n", Fcb); + fprintf(stderr, "Fr =%f\n", Fr); #endif - if (TypeFactor == 0) - return Fb * Fe * Ft * Fp * Fa * Fr * Fsc * Fci; - else - return Fb * Ft * Fp * Fa * Fm * Fsc * Fcb; + if (TypeFactor == 0) + return Fb * Fe * Ft * Fp * Fa * Fr * Fsc * Fci; + else + return Fb * Ft * Fp * Fa * Fm * Fsc * Fcb; } /*################################################################### */ -static int32 DeterObject(char *ObjectName) +static int32 +DeterObject(char *ObjectName) { - char s[AS_MAXCH]; - char *sp; - int32 ipl; - strcpy(s, ObjectName); - for (sp = s; *sp != '\0'; sp++) - *sp = tolower(*sp); - if (strncmp(s, "sun", 3) == 0) - return SE_SUN; - if (strncmp(s, "venus", 5) == 0) - return SE_VENUS; - if (strncmp(s, "mars", 4) == 0) - return SE_MARS; - if (strncmp(s, "mercur", 6) == 0) - return SE_MERCURY; - if (strncmp(s, "jupiter", 7) == 0) - return SE_JUPITER; - if (strncmp(s, "saturn", 6) == 0) - return SE_SATURN; - if (strncmp(s, "uranus", 6) == 0) - return SE_URANUS; - if (strncmp(s, "neptun", 6) == 0) - return SE_NEPTUNE; - if (strncmp(s, "moon", 4) == 0) - return SE_MOON; - if ((ipl = atoi(s)) > 0) { - ipl += SE_AST_OFFSET; - return ipl; - } - return -1; + char s[AS_MAXCH]; + char *sp; + int32 ipl; + strcpy(s, ObjectName); + for (sp = s; *sp != '\0'; sp++) + *sp = tolower(*sp); + if (strncmp(s, "sun", 3) == 0) + return SE_SUN; + if (strncmp(s, "venus", 5) == 0) + return SE_VENUS; + if (strncmp(s, "mars", 4) == 0) + return SE_MARS; + if (strncmp(s, "mercur", 6) == 0) + return SE_MERCURY; + if (strncmp(s, "jupiter", 7) == 0) + return SE_JUPITER; + if (strncmp(s, "saturn", 6) == 0) + return SE_SATURN; + if (strncmp(s, "uranus", 6) == 0) + return SE_URANUS; + if (strncmp(s, "neptun", 6) == 0) + return SE_NEPTUNE; + if (strncmp(s, "moon", 4) == 0) + return SE_MOON; + if ((ipl = atoi(s)) > 0) { + ipl += SE_AST_OFFSET; + return ipl; + } + return -1; } #if 0 -int32 call_swe_calc(double tjd, int32 ipl, int32 iflag, double *x, char *serr) +int32 +call_swe_calc(double tjd, int32 ipl, int32 iflag, double *x, char *serr) { - int32 retval = OK, ipli, i; - double dtjd; - static double tjdsv[3]; - static double xsv[3][6]; - static int32 iflagsv[3]; - ipli = ipl; - if (ipli > SE_MOON) - ipli = 2; - dtjd = tjd - tjdsv[ipli]; - if (tjdsv[ipli] != 0 && iflag == iflagsv[ipli] && fabs(dtjd) < 5.0 / 1440.0) { - for (i = 0; i < 3; i++) - x[i] = xsv[ipli][i] + dtjd * xsv[ipli][i+3]; - for (i = 3; i < 6; i++) - x[i] = xsv[ipli][i]; - } else { - retval = swe_calc(tjd, ipl, iflag, x, serr); - tjdsv[ipli] = tjd; - iflagsv[ipli] = iflag; - for (i = 0; i < 6; i++) - xsv[ipli][i] = x[i]; - } - return retval; + int32 retval = OK, ipli, i; + double dtjd; + static double tjdsv[3]; + static double xsv[3][6]; + static int32 iflagsv[3]; + ipli = ipl; + if (ipli > SE_MOON) + ipli = 2; + dtjd = tjd - tjdsv[ipli]; + if (tjdsv[ipli] != 0 && iflag == iflagsv[ipli] + && fabs(dtjd) < 5.0 / 1440.0) { + for (i = 0; i < 3; i++) + x[i] = xsv[ipli][i] + dtjd * xsv[ipli][i + 3]; + for (i = 3; i < 6; i++) + x[i] = xsv[ipli][i]; + } + else { + retval = swe_calc(tjd, ipl, iflag, x, serr); + tjdsv[ipli] = tjd; + iflagsv[ipli] = iflag; + for (i = 0; i < 6; i++) + xsv[ipli][i] = x[i]; + } + return retval; } #endif /* avoids problems with star name string that may be overwritten by swe_fixstar() */ -int32 call_swe_fixstar(char *star, double tjd, int32 iflag, double *xx, char *serr) +int32 +call_swe_fixstar(char *star, double tjd, int32 iflag, double *xx, char *serr) { - int32 retval; - char star2[AS_MAXCH]; - strcpy(star2, star); - retval = swe_fixstar(star2, tjd, iflag, xx, serr); - return retval; + int32 retval; + char star2[AS_MAXCH]; + strcpy(star2, star); + retval = swe_fixstar(star2, tjd, iflag, xx, serr); + return retval; } /* avoids problems with star name string that may be overwritten by swe_fixstar_mag() */ -int32 call_swe_fixstar_mag(char *star, double *mag, char *serr) +int32 +call_swe_fixstar_mag(char *star, double *mag, char *serr) { - int32 retval; - char star2[AS_MAXCH]; - static double dmag; - static char star_save[AS_MAXCH]; - if (strcmp(star, star_save) == 0) { + int32 retval; + char star2[AS_MAXCH]; + static double dmag; + static char star_save[AS_MAXCH]; + if (strcmp(star, star_save) == 0) { + *mag = dmag; + return OK; + } + strcpy(star_save, star); + strcpy(star2, star); + retval = swe_fixstar_mag(star2, &dmag, serr); *mag = dmag; - return OK; - } - strcpy(star_save, star); - strcpy(star2, star); - retval = swe_fixstar_mag(star2, &dmag, serr); - *mag = dmag; - return retval; + return retval; } /* avoids problems with star name string that may be overwritten by swe_fixstar() */ -int32 call_swe_rise_trans(double tjd, int32 ipl, char *star, int32 helflag, int32 eventtype, double *dgeo, double atpress, double attemp, double *tret, char *serr) +int32 +call_swe_rise_trans(double tjd, int32 ipl, char *star, int32 helflag, + int32 eventtype, double *dgeo, double atpress, + double attemp, double *tret, char *serr) { - int32 retval; - int32 iflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - char star2[AS_MAXCH]; - strcpy(star2, star); - retval = swe_rise_trans(tjd, ipl, star2, iflag, eventtype, dgeo, atpress, attemp, tret, serr); - return retval; + int32 retval; + int32 iflag = helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + char star2[AS_MAXCH]; + strcpy(star2, star); + retval = + swe_rise_trans(tjd, ipl, star2, iflag, eventtype, dgeo, atpress, + attemp, tret, serr); + return retval; } /* @@ -394,106 +436,137 @@ int32 call_swe_rise_trans(double tjd, int32 ipl, char *star, int32 helflag, int3 * generally use it for geographical latitudes higher than 58N/S. * For fixed stars, swe_rise_trans() is fast enough. */ -static int32 calc_rise_and_set(double tjd_start, int32 ipl, double *dgeo, double *datm, int32 eventflag, int32 helflag, double *trise, char *serr) +static int32 +calc_rise_and_set(double tjd_start, int32 ipl, double *dgeo, double *datm, + int32 eventflag, int32 helflag, double *trise, char *serr) { - int retc = OK, i; - double sda, xs[6], xx[6], xaz[6], xaz2[6], dfac = 1/365.25; - double rdi, rh; - double tjd0 = tjd_start, tjdrise; - double tjdnoon = (int) tjd0 - dgeo[0] / 15.0 / 24.0; - int32 iflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - iflag |= SEFLG_EQUATORIAL; - if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) - iflag |= SEFLG_NONUT|SEFLG_TRUEPOS; - if (swe_calc_ut(tjd0, SE_SUN, iflag, xs, serr) == 0) { - if (serr != NULL) - strcpy(serr, "error in calc_rise_and_set(): calc(sun) failed "); - return ERR; - } - if (swe_calc_ut(tjd0, ipl, iflag, xx, serr) == 0) { - if (serr != NULL) - strcpy(serr, "error in calc_rise_and_set(): calc(sun) failed "); - return ERR; - } - tjdnoon -= swe_degnorm(xs[0] - xx[0])/360.0 + 0; - /* is planet above horizon or below? */ - swe_azalt(tjd0, SE_EQU2HOR, dgeo, datm[0], datm[1], xx, xaz); -if (eventflag & SE_CALC_RISE) { - if (xaz[2] > 0) { - while (tjdnoon - tjd0 < 0.5) {/*printf("e");*/tjdnoon += 1;} - while (tjdnoon - tjd0 > 1.5) {/*printf("f");*/tjdnoon -= 1;} - } else { - while (tjdnoon - tjd0 < 0.0) {/*printf("g");*/tjdnoon += 1;} - while (tjdnoon - tjd0 > 1.0) {/*printf("h");*/tjdnoon -= 1;} - } -} else { - if (xaz[2] > 0) { - while (tjd0 - tjdnoon > 0.5) {/*printf("a");*/ tjdnoon += 1;} - while (tjd0 - tjdnoon < -0.5) {/*printf("b");*/ tjdnoon -= 1;} - } else { - while (tjd0 - tjdnoon > 0.0) {/*printf("c");*/ tjdnoon += 1;} - while (tjd0 - tjdnoon < -1.0) {/*printf("d");*/ tjdnoon -= 1;} - } -} - /* position of planet */ - if (swe_calc_ut(tjdnoon, ipl, iflag, xx, serr) == ERR) { - if (serr != NULL) - strcpy(serr, "error in calc_rise_and_set(): calc(sun) failed "); - return ERR; - } - /* apparent radius of solar disk (ignoring refraction) */ - rdi = asin(696000000.0 / 1.49597870691e+11 / xx[2]) / DEGTORAD; - if (eventflag & SE_BIT_DISC_CENTER) - rdi = 0; - /* true altitude of sun, when it appears at the horizon */ - /* refraction for a body visible at the horizon at 0m above sea, - * atmospheric temperature 10 deg C, atmospheric pressure 1013.25 is 34.5 arcmin*/ - rh = -(34.5 / 60.0 + rdi); - /* semidiurnal arc of sun */ - sda = acos(-tan(dgeo[1] * DEGTORAD) * tan(xx[1] * DEGTORAD)) * RADTODEG; - /* rough rising and setting times */ -if (eventflag & SE_CALC_RISE) - tjdrise = tjdnoon - sda / 360.0; -else - tjdrise = tjdnoon + sda / 360.0; - /*ph->tset = tjd_start + sda / 360.0;*/ - /* now calculate more accurate rising and setting times. - * use vertical speed in order to determine crossing of the horizon - * refraction of 34' and solar disk diameter of 16' = 50' = 0.84 deg */ - iflag = SEFLG_SPEED|SEFLG_EQUATORIAL; - if (ipl == SE_MOON) - iflag |= SEFLG_TOPOCTR; - if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) - iflag |= SEFLG_NONUT|SEFLG_TRUEPOS; - for (i = 0; i < 2; i++) { - if (swe_calc_ut(tjdrise, ipl, iflag, xx, serr) == ERR) - return ERR; - swe_azalt(tjdrise, SE_EQU2HOR, dgeo, datm[0], datm[1], xx, xaz); - xx[0] -= xx[3] * dfac; - xx[1] -= xx[4] * dfac; - swe_azalt(tjdrise - dfac, SE_EQU2HOR, dgeo, datm[0], datm[1], xx, xaz2); - tjdrise -= (xaz[1] - rh) / (xaz[1] - xaz2[1]) * dfac; - /*fprintf(stderr, "%f\n", ph->trise);*/ - } - *trise = tjdrise; - return retc; + int retc = OK, i; + double sda, xs[6], xx[6], xaz[6], xaz2[6], dfac = 1 / 365.25; + double rdi, rh; + double tjd0 = tjd_start, tjdrise; + double tjdnoon = (int)tjd0 - dgeo[0] / 15.0 / 24.0; + int32 iflag = helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + iflag |= SEFLG_EQUATORIAL; + if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) + iflag |= SEFLG_NONUT | SEFLG_TRUEPOS; + if (swe_calc_ut(tjd0, SE_SUN, iflag, xs, serr) == 0) { + if (serr != NULL) + strcpy(serr, "error in calc_rise_and_set(): calc(sun) failed "); + return ERR; + } + if (swe_calc_ut(tjd0, ipl, iflag, xx, serr) == 0) { + if (serr != NULL) + strcpy(serr, "error in calc_rise_and_set(): calc(sun) failed "); + return ERR; + } + tjdnoon -= swe_degnorm(xs[0] - xx[0]) / 360.0 + 0; + /* is planet above horizon or below? */ + swe_azalt(tjd0, SE_EQU2HOR, dgeo, datm[0], datm[1], xx, xaz); + if (eventflag & SE_CALC_RISE) { + if (xaz[2] > 0) { + while (tjdnoon - tjd0 < 0.5) { /*printf("e"); */ + tjdnoon += 1; + } + while (tjdnoon - tjd0 > 1.5) { /*printf("f"); */ + tjdnoon -= 1; + } + } + else { + while (tjdnoon - tjd0 < 0.0) { /*printf("g"); */ + tjdnoon += 1; + } + while (tjdnoon - tjd0 > 1.0) { /*printf("h"); */ + tjdnoon -= 1; + } + } + } + else { + if (xaz[2] > 0) { + while (tjd0 - tjdnoon > 0.5) { /*printf("a"); */ + tjdnoon += 1; + } + while (tjd0 - tjdnoon < -0.5) { /*printf("b"); */ + tjdnoon -= 1; + } + } + else { + while (tjd0 - tjdnoon > 0.0) { /*printf("c"); */ + tjdnoon += 1; + } + while (tjd0 - tjdnoon < -1.0) { /*printf("d"); */ + tjdnoon -= 1; + } + } + } + /* position of planet */ + if (swe_calc_ut(tjdnoon, ipl, iflag, xx, serr) == ERR) { + if (serr != NULL) + strcpy(serr, "error in calc_rise_and_set(): calc(sun) failed "); + return ERR; + } + /* apparent radius of solar disk (ignoring refraction) */ + rdi = asin(696000000.0 / 1.49597870691e+11 / xx[2]) / DEGTORAD; + if (eventflag & SE_BIT_DISC_CENTER) + rdi = 0; + /* true altitude of sun, when it appears at the horizon */ + /* refraction for a body visible at the horizon at 0m above sea, + * atmospheric temperature 10 deg C, atmospheric pressure 1013.25 is 34.5 arcmin*/ + rh = -(34.5 / 60.0 + rdi); + /* semidiurnal arc of sun */ + sda = acos(-tan(dgeo[1] * DEGTORAD) * tan(xx[1] * DEGTORAD)) * RADTODEG; + /* rough rising and setting times */ + if (eventflag & SE_CALC_RISE) + tjdrise = tjdnoon - sda / 360.0; + else + tjdrise = tjdnoon + sda / 360.0; + /*ph->tset = tjd_start + sda / 360.0; */ + /* now calculate more accurate rising and setting times. + * use vertical speed in order to determine crossing of the horizon + * refraction of 34' and solar disk diameter of 16' = 50' = 0.84 deg */ + iflag = SEFLG_SPEED | SEFLG_EQUATORIAL; + if (ipl == SE_MOON) + iflag |= SEFLG_TOPOCTR; + if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) + iflag |= SEFLG_NONUT | SEFLG_TRUEPOS; + for (i = 0; i < 2; i++) { + if (swe_calc_ut(tjdrise, ipl, iflag, xx, serr) == ERR) + return ERR; + swe_azalt(tjdrise, SE_EQU2HOR, dgeo, datm[0], datm[1], xx, xaz); + xx[0] -= xx[3] * dfac; + xx[1] -= xx[4] * dfac; + swe_azalt(tjdrise - dfac, SE_EQU2HOR, dgeo, datm[0], datm[1], xx, + xaz2); + tjdrise -= (xaz[1] - rh) / (xaz[1] - xaz2[1]) * dfac; + /*fprintf(stderr, "%f\n", ph->trise); */ + } + *trise = tjdrise; + return retc; } -static int32 my_rise_trans(double tjd, int32 ipl, char* starname, int32 eventtype, int32 helflag, double *dgeo, double *datm, double *tret, char *serr) +static int32 +my_rise_trans(double tjd, int32 ipl, char *starname, int32 eventtype, + int32 helflag, double *dgeo, double *datm, double *tret, + char *serr) { - int retc = OK; - if (starname != NULL && *starname != '\0') - ipl = DeterObject(starname); - /* for non-circumpolar planets we can use a faster algorithm */ - /*if (!(helflag & SE_HELFLAG_HIGH_PRECISION) && ipl != -1 && fabs(dgeo[1]) < 58) {*/ - if (ipl != -1 && fabs(dgeo[1]) < 63) { - retc = calc_rise_and_set(tjd, ipl, dgeo, datm, eventtype, helflag, tret, serr); - /* for stars and circumpolar planets we use a rigorous algorithm */ - } else { - retc = call_swe_rise_trans(tjd, ipl, starname, helflag, eventtype, dgeo, datm[0], datm[1], tret, serr); - } + int retc = OK; + if (starname != NULL && *starname != '\0') + ipl = DeterObject(starname); + /* for non-circumpolar planets we can use a faster algorithm */ + /*if (!(helflag & SE_HELFLAG_HIGH_PRECISION) && ipl != -1 && fabs(dgeo[1]) < 58) { */ + if (ipl != -1 && fabs(dgeo[1]) < 63) { + retc = + calc_rise_and_set(tjd, ipl, dgeo, datm, eventtype, helflag, tret, + serr); + /* for stars and circumpolar planets we use a rigorous algorithm */ + } + else { + retc = + call_swe_rise_trans(tjd, ipl, starname, helflag, eventtype, dgeo, + datm[0], datm[1], tret, serr); + } + /* printf("%f, %f\n", tjd, *tret);*/ - return retc; + return retc; } /*################################################################### @@ -506,17 +579,23 @@ static int32 my_rise_trans(double tjd, int32 ipl, char* starname, int32 eventtyp ' Rim [0=center,1=top] ' RiseSet [Day] */ -static int32 RiseSet(double JDNDaysUT, double *dgeo, double *datm, char *ObjectName, int32 RSEvent, int32 helflag, int32 Rim, double *tret, char *serr) +static int32 +RiseSet(double JDNDaysUT, double *dgeo, double *datm, char *ObjectName, + int32 RSEvent, int32 helflag, int32 Rim, double *tret, char *serr) { - int32 eventtype = RSEvent, Planet, retval; - if (Rim == 0) - eventtype |= SE_BIT_DISC_CENTER; - Planet = DeterObject(ObjectName); - if (Planet != -1) - retval = my_rise_trans(JDNDaysUT, Planet, "", eventtype, helflag, dgeo, datm, tret, serr); - else - retval = my_rise_trans(JDNDaysUT, -1, ObjectName, eventtype, helflag, dgeo, datm, tret, serr); - return retval; + int32 eventtype = RSEvent, Planet, retval; + if (Rim == 0) + eventtype |= SE_BIT_DISC_CENTER; + Planet = DeterObject(ObjectName); + if (Planet != -1) + retval = + my_rise_trans(JDNDaysUT, Planet, "", eventtype, helflag, dgeo, + datm, tret, serr); + else + retval = + my_rise_trans(JDNDaysUT, -1, ObjectName, eventtype, helflag, dgeo, + datm, tret, serr); + return retval; } /*################################################################### @@ -524,44 +603,47 @@ static int32 RiseSet(double JDNDaysUT, double *dgeo, double *datm, char *ObjectN ' actual [0= approximation, 1=actual] ' SunRA [deg] */ -static double SunRA(double JDNDaysUT, int32 helflag, char *serr) +static double +SunRA(double JDNDaysUT, int32 helflag, char *serr) { - int imon, iday, iyar, calflag = SE_GREG_CAL; - double dut; - static double tjdlast; - static double ralast; - if (JDNDaysUT == tjdlast) - return ralast; + int imon, iday, iyar, calflag = SE_GREG_CAL; + double dut; + static double tjdlast; + static double ralast; + if (JDNDaysUT == tjdlast) + return ralast; #ifndef SIMULATE_VICTORVB - if (1) { /*helflag & SE_HELFLAG_HIGH_PRECISION) {*/ - double tjd_tt; - double x[6]; - int32 epheflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - int32 iflag = epheflag | SEFLG_EQUATORIAL; - iflag |= SEFLG_NONUT | SEFLG_TRUEPOS; - tjd_tt = JDNDaysUT + swe_deltat(JDNDaysUT); - if (swe_calc(tjd_tt, SE_SUN, iflag, x, serr) != ERR) { - ralast = x[0]; - tjdlast = JDNDaysUT; - return ralast; + if (1) { /*helflag & SE_HELFLAG_HIGH_PRECISION) { */ + double tjd_tt; + double x[6]; + int32 epheflag = + helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + int32 iflag = epheflag | SEFLG_EQUATORIAL; + iflag |= SEFLG_NONUT | SEFLG_TRUEPOS; + tjd_tt = JDNDaysUT + swe_deltat(JDNDaysUT); + if (swe_calc(tjd_tt, SE_SUN, iflag, x, serr) != ERR) { + ralast = x[0]; + tjdlast = JDNDaysUT; + return ralast; + } } - } #endif - swe_revjul(JDNDaysUT, calflag, &iyar, &imon, &iday, &dut); /* this seems to be much faster than calling swe_revjul() ! Note: only because SunRA is called 1000s of times */ - tjdlast = JDNDaysUT; - ralast = swe_degnorm((imon + (iday - 1) / 30.4 - 3.69) * 30); - /*ralast = (DatefromJDut(JDNDaysUT, 2) + (DatefromJDut(JDNDaysUT, 3) - 1) / 30.4 - 3.69) * 30;*/ - return ralast; + swe_revjul(JDNDaysUT, calflag, &iyar, &imon, &iday, &dut); /* this seems to be much faster than calling swe_revjul() ! Note: only because SunRA is called 1000s of times */ + tjdlast = JDNDaysUT; + ralast = swe_degnorm((imon + (iday - 1) / 30.4 - 3.69) * 30); + /*ralast = (DatefromJDut(JDNDaysUT, 2) + (DatefromJDut(JDNDaysUT, 3) - 1) / 30.4 - 3.69) * 30; */ + return ralast; } /*################################################################### ' Temp [C] ' Kelvin [K] */ -static double Kelvin(double Temp) +static double +Kelvin(double Temp) { - /*' http://en.wikipedia.org/wiki/Kelvin*/ - return Temp + C2K; + /*' http://en.wikipedia.org/wiki/Kelvin */ + return Temp + C2K; } /*################################################################### @@ -570,21 +652,28 @@ static double Kelvin(double Temp) ' PresE [mbar] ' TopoAltitudefromAppAlt [deg] */ -static double TopoAltfromAppAlt(double AppAlt, double TempE, double PresE) +static double +TopoAltfromAppAlt(double AppAlt, double TempE, double PresE) { - double R = 0; - double retalt = 0; - if (AppAlt >= LowestAppAlt) { - if (AppAlt > 17.904104638432) - R = 0.97 / tan(AppAlt * DEGTORAD); - else - R = (34.46 + 4.23 * AppAlt + 0.004 * AppAlt * AppAlt) / (1 + 0.505 * AppAlt + 0.0845 * AppAlt * AppAlt); - R = (PresE - 80) / 930 / (1 + 0.00008 * (R + 39) * (TempE - 10)) * R; - retalt = AppAlt - R * Min2Deg; - } else { - retalt = AppAlt; - } - return retalt; + double R = 0; + double retalt = 0; + if (AppAlt >= LowestAppAlt) { + if (AppAlt > 17.904104638432) + R = 0.97 / tan(AppAlt * DEGTORAD); + else + R = (34.46 + 4.23 * AppAlt + 0.004 * AppAlt * AppAlt) / (1 + + 0.505 * + AppAlt + + 0.0845 * + AppAlt * + AppAlt); + R = (PresE - 80) / 930 / (1 + 0.00008 * (R + 39) * (TempE - 10)) * R; + retalt = AppAlt - R * Min2Deg; + } + else { + retalt = AppAlt; + } + return retalt; } /*################################################################### @@ -595,34 +684,37 @@ static double TopoAltfromAppAlt(double AppAlt, double TempE, double PresE) ' call this instead of swe_azalt(), because it is faster (lower precision ' is required) */ -static double AppAltfromTopoAlt(double TopoAlt, double TempE, double PresE, int32 helflag) +static double +AppAltfromTopoAlt(double TopoAlt, double TempE, double PresE, int32 helflag) { - /* using methodology of Newtown derivatives (analogue to what Swiss Emphemeris uses)*/ - int i, nloop = 2; - double newAppAlt = TopoAlt; - double newTopoAlt = 0.0; - double oudAppAlt = newAppAlt; - double oudTopoAlt = newTopoAlt; - double verschil, retalt; - if (helflag & SE_HELFLAG_HIGH_PRECISION) - nloop = 5; - for (i = 0; i <= nloop; i++) { - newTopoAlt = newAppAlt - TopoAltfromAppAlt(newAppAlt, TempE, PresE); - /*newTopoAlt = newAppAlt - swe_refrac(newAppAlt, PresE, TempE, SE_CALC_APP_TO_TRUE);*/ - verschil = newAppAlt - oudAppAlt; - oudAppAlt = newTopoAlt - oudTopoAlt - verschil; - if ((verschil != 0) && (oudAppAlt != 0)) - verschil = newAppAlt - verschil * (TopoAlt + newTopoAlt - newAppAlt) / oudAppAlt; - else - verschil = TopoAlt + newTopoAlt; - oudAppAlt = newAppAlt; - oudTopoAlt = newTopoAlt; - newAppAlt = verschil; - } - retalt = TopoAlt + newTopoAlt; - if (retalt < LowestAppAlt) - retalt = TopoAlt; - return retalt; + /* using methodology of Newtown derivatives (analogue to what Swiss Emphemeris uses) */ + int i, nloop = 2; + double newAppAlt = TopoAlt; + double newTopoAlt = 0.0; + double oudAppAlt = newAppAlt; + double oudTopoAlt = newTopoAlt; + double verschil, retalt; + if (helflag & SE_HELFLAG_HIGH_PRECISION) + nloop = 5; + for (i = 0; i <= nloop; i++) { + newTopoAlt = newAppAlt - TopoAltfromAppAlt(newAppAlt, TempE, PresE); + /*newTopoAlt = newAppAlt - swe_refrac(newAppAlt, PresE, TempE, SE_CALC_APP_TO_TRUE); */ + verschil = newAppAlt - oudAppAlt; + oudAppAlt = newTopoAlt - oudTopoAlt - verschil; + if ((verschil != 0) && (oudAppAlt != 0)) + verschil = + newAppAlt - verschil * (TopoAlt + newTopoAlt - + newAppAlt) / oudAppAlt; + else + verschil = TopoAlt + newTopoAlt; + oudAppAlt = newAppAlt; + oudTopoAlt = newTopoAlt; + newAppAlt = verschil; + } + retalt = TopoAlt + newTopoAlt; + if (retalt < LowestAppAlt) + retalt = TopoAlt; + return retalt; } /*################################################################### @@ -631,16 +723,19 @@ static double AppAltfromTopoAlt(double TopoAlt, double TempE, double PresE, int3 ' Lat [deg] ' HourAngle [hour] */ -static double HourAngle(double TopoAlt, double TopoDecl, double Lat) +static double +HourAngle(double TopoAlt, double TopoDecl, double Lat) { - double Alti = TopoAlt * DEGTORAD; - double decli = TopoDecl * DEGTORAD; - double Lati = Lat * DEGTORAD; - double ha = (sin(Alti) - sin(Lati) * sin(decli)) / cos(Lati) / cos(decli); - if (ha < -1) ha = -1; - if (ha > 1) ha = 1; - /* from http://star-www.st-and.ac.uk/~fv/webnotes/chapt12.htm*/ - return acos(ha) / DEGTORAD / 15.0; + double Alti = TopoAlt * DEGTORAD; + double decli = TopoDecl * DEGTORAD; + double Lati = Lat * DEGTORAD; + double ha = (sin(Alti) - sin(Lati) * sin(decli)) / cos(Lati) / cos(decli); + if (ha < -1) + ha = -1; + if (ha > 1) + ha = 1; + /* from http://star-www.st-and.ac.uk/~fv/webnotes/chapt12.htm */ + return acos(ha) / DEGTORAD / 15.0; } /*################################################################### @@ -648,19 +743,22 @@ static double HourAngle(double TopoAlt, double TopoDecl, double Lat) ' COD [msec/cy] ' DeltaTSE [Sec] */ -static double DeltaTSE(double JDNDays, int COD) +static double +DeltaTSE(double JDNDays, int COD) { - double OffSetYear; - int gregflag = SE_GREG_CAL; - if (StartYear < 1583) - gregflag = SE_JUL_CAL; - /* from Swiss Emphemeris */ - if (COD != 0) { - /* Determined by V. Reijs*/ - OffSetYear = (swe_julday((int) StartYear, 1, 1, 0, gregflag) - JDNDays) / 365.25; - return (OffSetYear * OffSetYear / 100.0 / 2.0 * COD * Y2D) / 1000.0; - } - return swe_deltat(JDNDays) * D2S; + double OffSetYear; + int gregflag = SE_GREG_CAL; + if (StartYear < 1583) + gregflag = SE_JUL_CAL; + /* from Swiss Emphemeris */ + if (COD != 0) { + /* Determined by V. Reijs */ + OffSetYear = + (swe_julday((int)StartYear, 1, 1, 0, gregflag) - + JDNDays) / 365.25; + return (OffSetYear * OffSetYear / 100.0 / 2.0 * COD * Y2D) / 1000.0; + } + return swe_deltat(JDNDays) * D2S; } /*################################################################### @@ -668,21 +766,27 @@ static double DeltaTSE(double JDNDays, int COD) ' COD [msec/cy] ' DeltaTVR [Sec] */ -static double DeltaTVR(double JDNDays, int COD) +static double +DeltaTVR(double JDNDays, int COD) { - /* Determined by V. Reijs */ - double DeltaTVR; - int gregflag = SE_GREG_CAL; - double OffSetYear; - if (StartYear < 1583) - gregflag = SE_JUL_CAL; - OffSetYear = (swe_julday((int) StartYear, 1, 1, 0, gregflag) - JDNDays) / 365.25; - if (COD == 0) { - DeltaTVR = (OffSetYear * OffSetYear / 100.0 / 2.0 * Average + Periodicy / 2.0 / PI * Amplitude * (cos((2 * PI * OffSetYear / Periodicy)) - 1)) * Y2D; - } else { - DeltaTVR = OffSetYear * OffSetYear / 100.0 / 2.0 * COD * Y2D; - } - return DeltaTVR / 1000.0; + /* Determined by V. Reijs */ + double DeltaTVR; + int gregflag = SE_GREG_CAL; + double OffSetYear; + if (StartYear < 1583) + gregflag = SE_JUL_CAL; + OffSetYear = + (swe_julday((int)StartYear, 1, 1, 0, gregflag) - JDNDays) / 365.25; + if (COD == 0) { + DeltaTVR = + (OffSetYear * OffSetYear / 100.0 / 2.0 * Average + + Periodicy / 2.0 / PI * Amplitude * + (cos((2 * PI * OffSetYear / Periodicy)) - 1)) * Y2D; + } + else { + DeltaTVR = OffSetYear * OffSetYear / 100.0 / 2.0 * COD * Y2D; + } + return DeltaTVR / 1000.0; } /*################################################################### @@ -690,11 +794,12 @@ static double DeltaTVR(double JDNDays, int COD) ' COD [msec/cy] ' DeltaT [Sec] */ -static double DeltaT(double JDNDays, int COD) +static double +DeltaT(double JDNDays, int COD) { - if (USE_DELTA_T_VR) - return DeltaTVR(JDNDays, COD); - return DeltaTSE(JDNDays, COD); + if (USE_DELTA_T_VR) + return DeltaTVR(JDNDays, COD); + return DeltaTSE(JDNDays, COD); } /*################################################################### @@ -706,49 +811,57 @@ static double DeltaT(double JDNDays, int COD) ' Angle (0 = TopoAlt, 1 = Azi, 2=Topo Declination, 3=Topo Rectascension, 4=AppAlt,5=Geo Declination, 6=Geo Rectascension) ' ObjectLoc [deg] */ -static int32 ObjectLoc(double JDNDaysUT, double *dgeo, double *datm, char *ObjectName, int32 Angle, int32 helflag, double *dret, char *serr) +static int32 +ObjectLoc(double JDNDaysUT, double *dgeo, double *datm, char *ObjectName, + int32 Angle, int32 helflag, double *dret, char *serr) { - double x[6], xin[3], xaz[3], tjd_tt; - int32 Planet; - int32 epheflag; - int32 iflag = SEFLG_EQUATORIAL; - epheflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - iflag |= epheflag; - if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) - iflag |= SEFLG_NONUT | SEFLG_TRUEPOS; - if (Angle < 5) iflag = iflag | SEFLG_TOPOCTR; - if (Angle == 7) Angle = 0; - tjd_tt = JDNDaysUT + DeltaT(JDNDaysUT, 0) / D2S; - Planet = DeterObject(ObjectName); - if (Planet != -1) { - if (swe_calc(tjd_tt, Planet, iflag, x, serr) == ERR) - return ERR; - } else { - if (call_swe_fixstar(ObjectName, tjd_tt, iflag, x, serr) == ERR) - return ERR; - } - if (Angle == 2 || Angle == 5) { - *dret = x[1]; - } else { - if (Angle == 3 || Angle == 6) { - *dret = x[0]; - } else { - xin[0] = x[0]; - xin[1] = x[1]; - swe_azalt(JDNDaysUT, SE_EQU2HOR, dgeo, datm[0], datm[1], xin, xaz); - if (Angle == 0) - *dret = xaz[1]; - if (Angle == 4) - *dret = AppAltfromTopoAlt(xaz[1], datm[0], datm[1], helflag); - if (Angle == 1) { - xaz[0] += 180; - if (xaz[0] >= 360) - xaz[0] -= 360; - *dret = xaz[0]; - } + double x[6], xin[3], xaz[3], tjd_tt; + int32 Planet; + int32 epheflag; + int32 iflag = SEFLG_EQUATORIAL; + epheflag = helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + iflag |= epheflag; + if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) + iflag |= SEFLG_NONUT | SEFLG_TRUEPOS; + if (Angle < 5) + iflag = iflag | SEFLG_TOPOCTR; + if (Angle == 7) + Angle = 0; + tjd_tt = JDNDaysUT + DeltaT(JDNDaysUT, 0) / D2S; + Planet = DeterObject(ObjectName); + if (Planet != -1) { + if (swe_calc(tjd_tt, Planet, iflag, x, serr) == ERR) + return ERR; } - } - return OK; + else { + if (call_swe_fixstar(ObjectName, tjd_tt, iflag, x, serr) == ERR) + return ERR; + } + if (Angle == 2 || Angle == 5) { + *dret = x[1]; + } + else { + if (Angle == 3 || Angle == 6) { + *dret = x[0]; + } + else { + xin[0] = x[0]; + xin[1] = x[1]; + swe_azalt(JDNDaysUT, SE_EQU2HOR, dgeo, datm[0], datm[1], xin, + xaz); + if (Angle == 0) + *dret = xaz[1]; + if (Angle == 4) + *dret = AppAltfromTopoAlt(xaz[1], datm[0], datm[1], helflag); + if (Angle == 1) { + xaz[0] += 180; + if (xaz[0] >= 360) + xaz[0] -= 360; + *dret = xaz[0]; + } + } + } + return OK; } /*################################################################### @@ -760,40 +873,43 @@ static int32 ObjectLoc(double JDNDaysUT, double *dgeo, double *datm, char *Objec ' Angle (0 = TopoAlt, 1 = Azi, 2=Topo Declination, 3=Topo Rectascension, 4=AppAlt,5=Geo Declination, 6=Geo Rectascension) ' ObjectLoc [deg] */ -static int32 azalt_cart(double JDNDaysUT, double *dgeo, double *datm, char *ObjectName, int32 helflag, double *dret, char *serr) +static int32 +azalt_cart(double JDNDaysUT, double *dgeo, double *datm, char *ObjectName, + int32 helflag, double *dret, char *serr) { - double x[6], xin[3], xaz[3], tjd_tt; - int32 Planet; - int32 epheflag; - int32 iflag = SEFLG_EQUATORIAL; - epheflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - iflag |= epheflag; - if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) - iflag |= SEFLG_NONUT | SEFLG_TRUEPOS; - iflag = iflag | SEFLG_TOPOCTR; - tjd_tt = JDNDaysUT + DeltaT(JDNDaysUT, 0) / D2S; - Planet = DeterObject(ObjectName); - if (Planet != -1) { - if (swe_calc(tjd_tt, Planet, iflag, x, serr) == ERR) - return ERR; - } else { - if (call_swe_fixstar(ObjectName, tjd_tt, iflag, x, serr) == ERR) - return ERR; - } - xin[0] = x[0]; - xin[1] = x[1]; - swe_azalt(JDNDaysUT, SE_EQU2HOR, dgeo, datm[0], datm[1], xin, xaz); - dret[0] = xaz[0]; - dret[1] = xaz[1]; /* true altitude */ - dret[2] = xaz[2]; /* apparent altitude */ - /* also return cartesian coordinates, for apparent altitude */ - xaz[1] = xaz[2]; - xaz[2] = 1; - swi_polcart(xaz, xaz); - dret[3] = xaz[0]; - dret[4] = xaz[1]; - dret[5] = xaz[2]; - return OK; + double x[6], xin[3], xaz[3], tjd_tt; + int32 Planet; + int32 epheflag; + int32 iflag = SEFLG_EQUATORIAL; + epheflag = helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + iflag |= epheflag; + if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) + iflag |= SEFLG_NONUT | SEFLG_TRUEPOS; + iflag = iflag | SEFLG_TOPOCTR; + tjd_tt = JDNDaysUT + DeltaT(JDNDaysUT, 0) / D2S; + Planet = DeterObject(ObjectName); + if (Planet != -1) { + if (swe_calc(tjd_tt, Planet, iflag, x, serr) == ERR) + return ERR; + } + else { + if (call_swe_fixstar(ObjectName, tjd_tt, iflag, x, serr) == ERR) + return ERR; + } + xin[0] = x[0]; + xin[1] = x[1]; + swe_azalt(JDNDaysUT, SE_EQU2HOR, dgeo, datm[0], datm[1], xin, xaz); + dret[0] = xaz[0]; + dret[1] = xaz[1]; /* true altitude */ + dret[2] = xaz[2]; /* apparent altitude */ + /* also return cartesian coordinates, for apparent altitude */ + xaz[1] = xaz[2]; + xaz[2] = 1; + swi_polcart(xaz, xaz); + dret[3] = xaz[0]; + dret[4] = xaz[1]; + dret[5] = xaz[2]; + return OK; } /*################################################################### @@ -803,19 +919,22 @@ static int32 azalt_cart(double JDNDaysUT, double *dgeo, double *datm, char *Obje ' LongB [rad] ' DistanceAngle [rad] */ -static double DistanceAngle(double LatA, double LongA, double LatB, double LongB) +static double +DistanceAngle(double LatA, double LongA, double LatB, double LongB) { - double dlon = LongB - LongA; - double dlat = LatB - LatA; - /* Haversine formula - * http://www.movable-type.co.uk/scripts/GIS-FAQ-5.1.html - * R.W. Sinnott, Virtues of the Haversine, Sky and Telescope, vol. 68, no. 2, 1984, p. 159 - */ - double sindlat2 = sin(dlat / 2); - double sindlon2 = sin(dlon / 2); - double corde = sindlat2 * sindlat2 + cos(LatA) * cos(LatB) * sindlon2 *sindlon2; - if (corde > 1) corde = 1; - return 2 * asin(sqrt(corde)); + double dlon = LongB - LongA; + double dlat = LatB - LatA; + /* Haversine formula + * http://www.movable-type.co.uk/scripts/GIS-FAQ-5.1.html + * R.W. Sinnott, Virtues of the Haversine, Sky and Telescope, vol. 68, no. 2, 1984, p. 159 + */ + double sindlat2 = sin(dlat / 2); + double sindlon2 = sin(dlon / 2); + double corde = + sindlat2 * sindlat2 + cos(LatA) * cos(LatB) * sindlon2 * sindlon2; + if (corde > 1) + corde = 1; + return 2 * asin(sqrt(corde)); } /*################################################################### @@ -824,12 +943,15 @@ static double DistanceAngle(double LatA, double LongA, double LatB, double LongB ' RH [%] ' kW [-] */ -static double kW(double HeightEye, double TempS, double RH) +static double +kW(double HeightEye, double TempS, double RH) { - /* From Schaefer , Archaeoastronomy, XV, 2000, page 128*/ - double WT = 0.031; - WT *= 0.94 * (RH / 100.0) * exp(TempS / 15) * exp(-1 * HeightEye / scaleHwater); - return WT; + /* From Schaefer , Archaeoastronomy, XV, 2000, page 128 */ + double WT = 0.031; + WT *= + 0.94 * (RH / 100.0) * exp(TempS / 15) * exp(-1 * HeightEye / + scaleHwater); + return WT; } /*################################################################### @@ -838,22 +960,25 @@ static double kW(double HeightEye, double TempS, double RH) ' lat [deg] ' kOZ [-] */ -static double kOZ(double AltS, double sunra, double Lat) +static double +kOZ(double AltS, double sunra, double Lat) { - double CHANGEKO, OZ, LT, kOZret; - static double koz_last, alts_last, sunra_last; - if (AltS == alts_last && sunra == sunra_last) + double CHANGEKO, OZ, LT, kOZret; + static double koz_last, alts_last, sunra_last; + if (AltS == alts_last && sunra == sunra_last) + return koz_last; + alts_last = AltS; + sunra_last = sunra; + OZ = 0.031; + LT = Lat * DEGTORAD; + /* From Schaefer , Archaeoastronomy, XV, 2000, page 128 */ + kOZret = + OZ * (3.0 + 0.4 * (LT * cos(sunra * DEGTORAD) - cos(3 * LT))) / 3.0; + /* depending on day/night vision (altitude of sun < start astronomical twilight), KO changes from 100% to 30% + * see extinction section of Vistas in Astronomy page 343*/ + CHANGEKO = (100 - 11.6 * mymin(6, mymax(-AltS - 12, 0))) / 100; + koz_last = kOZret * CHANGEKO; return koz_last; - alts_last = AltS; sunra_last = sunra; - OZ = 0.031; - LT = Lat * DEGTORAD; - /* From Schaefer , Archaeoastronomy, XV, 2000, page 128*/ - kOZret = OZ * (3.0 + 0.4 * (LT * cos(sunra * DEGTORAD) - cos(3 * LT))) / 3.0; - /* depending on day/night vision (altitude of sun < start astronomical twilight), KO changes from 100% to 30% - * see extinction section of Vistas in Astronomy page 343*/ - CHANGEKO = (100 - 11.6 * mymin(6, mymax(-AltS - 12, 0))) / 100; - koz_last = kOZret * CHANGEKO; - return koz_last; } /*################################################################### @@ -861,27 +986,32 @@ static double kOZ(double AltS, double sunra, double Lat) ' heighteye [m] ' kR [-] */ -static double kR(double AltS, double HeightEye) +static double +kR(double AltS, double HeightEye) { - /* depending on day/night vision (altitude of sun < start astronomical twilight), - * lambda eye sensibility changes - * see extinction section of Vistas in Astronomy page 343*/ - double CHANGEK, LAMBDA; - double val = -AltS - 12; - if (val < 0) val = 0; - if (val > 6) val = 6; - /*CHANGEK = (1 - 0.166667 * Min(6, Max(-AltS - 12, 0)));*/ - CHANGEK = (1 - 0.166667 * val ); - LAMBDA = 0.55 + (CHANGEK - 1) * 0.04; - /* From Schaefer , Archaeoastronomy, XV, 2000, page 128 */ - return 0.1066 * exp(-1 * HeightEye / scaleHrayleigh) * pow(LAMBDA / 0.55 , -4); + /* depending on day/night vision (altitude of sun < start astronomical twilight), + * lambda eye sensibility changes + * see extinction section of Vistas in Astronomy page 343*/ + double CHANGEK, LAMBDA; + double val = -AltS - 12; + if (val < 0) + val = 0; + if (val > 6) + val = 6; + /*CHANGEK = (1 - 0.166667 * Min(6, Max(-AltS - 12, 0))); */ + CHANGEK = (1 - 0.166667 * val); + LAMBDA = 0.55 + (CHANGEK - 1) * 0.04; + /* From Schaefer , Archaeoastronomy, XV, 2000, page 128 */ + return 0.1066 * exp(-1 * HeightEye / scaleHrayleigh) * pow(LAMBDA / 0.55, + -4); } -static int Sgn(double x) +static int +Sgn(double x) { - if (x < 0) - return -1; - return 1; + if (x < 0) + return -1; + return 1; } /*################################################################### @@ -894,52 +1024,75 @@ static int Sgn(double x) ' VR [km] ' ka [-] */ -static double ka(double AltS, double sunra, double Lat, double HeightEye, double TempS, double RH, double VR, char *serr) +static double +ka(double AltS, double sunra, double Lat, double HeightEye, double TempS, + double RH, double VR, char *serr) { - double CHANGEKA, LAMBDA, BetaVr, Betaa, kaact; - double SL = Sgn(Lat); - /* depending on day/night vision (altitude of sun < start astronomical twilight), - * lambda eye sensibility changes - * see extinction section of Vistas in Astronomy page 343 */ - static double alts_last, sunra_last, ka_last; - if (AltS == alts_last && sunra == sunra_last) - return ka_last; - alts_last = AltS; sunra_last = sunra; - CHANGEKA = (1 - 0.166667 * mymin(6, mymax(-AltS - 12, 0))); - LAMBDA = 0.55 + (CHANGEKA - 1) * 0.04; - if (VR != 0) { - if (VR >= 1) { - /* Visbility range from http://www1.cs.columbia.edu/CAVE/publications/pdfs/Narasimhan_CVPR03.pdf - * http://www.icao.int/anb/SG/AMOSSG/meetings/amossg3/wp/SN11Rev.pdf where MOR=2.995/ke - * factor 1.3 is the relation between "prevailing visibility" and - * meteorological range was derived by Koshmeider in the 1920's */ - BetaVr = 3.912 / VR; - Betaa = BetaVr - (kW(HeightEye, TempS, RH) / scaleHwater + kR(AltS, HeightEye) / scaleHrayleigh) * 1000 * astr2tau; - kaact = Betaa * scaleHaerosol / 1000 * tau2astr; - if (kaact < 0) { - if (serr != NULL) - strcpy(serr, "The provided Meteorological range is too long, when taking into acount other atmospheric parameters"); /* is a warning */ - /* return 0; * return "#HIGHVR"; */ - } - } else { - kaact = VR - kW(HeightEye, TempS, RH) - kR(AltS, HeightEye) - kOZ(AltS, sunra, Lat); - if (kaact < 0) { - if (serr != NULL) - strcpy(serr, "The provided atmosphic coeefficent (ktot) is too low, when taking into acount other atmospheric parameters"); /* is a warning */ - /* return 0; * "#LOWktot"; */ - } + double CHANGEKA, LAMBDA, BetaVr, Betaa, kaact; + double SL = Sgn(Lat); + /* depending on day/night vision (altitude of sun < start astronomical twilight), + * lambda eye sensibility changes + * see extinction section of Vistas in Astronomy page 343 */ + static double alts_last, sunra_last, ka_last; + if (AltS == alts_last && sunra == sunra_last) + return ka_last; + alts_last = AltS; + sunra_last = sunra; + CHANGEKA = (1 - 0.166667 * mymin(6, mymax(-AltS - 12, 0))); + LAMBDA = 0.55 + (CHANGEKA - 1) * 0.04; + if (VR != 0) { + if (VR >= 1) { + /* Visbility range from http://www1.cs.columbia.edu/CAVE/publications/pdfs/Narasimhan_CVPR03.pdf + * http://www.icao.int/anb/SG/AMOSSG/meetings/amossg3/wp/SN11Rev.pdf where MOR=2.995/ke + * factor 1.3 is the relation between "prevailing visibility" and + * meteorological range was derived by Koshmeider in the 1920's */ + BetaVr = 3.912 / VR; + Betaa = + BetaVr - (kW(HeightEye, TempS, RH) / scaleHwater + + kR(AltS, + HeightEye) / scaleHrayleigh) * 1000 * astr2tau; + kaact = Betaa * scaleHaerosol / 1000 * tau2astr; + if (kaact < 0) { + if (serr != NULL) + strcpy(serr, "The provided Meteorological range is too long, when taking into acount other atmospheric parameters"); /* is a warning */ + /* return 0; * return "#HIGHVR"; */ + } + } + else { + kaact = + VR - kW(HeightEye, TempS, RH) - kR(AltS, + HeightEye) - kOZ(AltS, + sunra, + Lat); + if (kaact < 0) { + if (serr != NULL) + strcpy(serr, "The provided atmosphic coeefficent (ktot) is too low, when taking into acount other atmospheric parameters"); /* is a warning */ + /* return 0; * "#LOWktot"; */ + } + } } - } else { - /* From Schaefer , Archaeoastronomy, XV, 2000, page 128 */ + else { + /* From Schaefer , Archaeoastronomy, XV, 2000, page 128 */ #ifdef SIMULATE_VICTORVB - if (RH <= 0.00000001) RH = 0.00000001; - if (RH >= 99.99999999) RH = 99.99999999; + if (RH <= 0.00000001) + RH = 0.00000001; + if (RH >= 99.99999999) + RH = 99.99999999; #endif - kaact = 0.1 * exp(-1 * HeightEye / scaleHaerosol) * pow(1 - 0.32 / log(RH / 100.0), 1.33) * (1 + 0.33 * SL * sin(sunra * DEGTORAD)); - kaact = kaact * pow(LAMBDA / 0.55, -1.3); - } - ka_last = kaact; - return kaact; + kaact = + 0.1 * exp(-1 * HeightEye / scaleHaerosol) * pow(1 - + 0.32 / log(RH / + 100.0), + 1.33) * (1 + + 0.33 * + SL * + sin(sunra + * + DEGTORAD)); + kaact = kaact * pow(LAMBDA / 0.55, -1.3); + } + ka_last = kaact; + return kaact; } /*################################################################### @@ -953,23 +1106,25 @@ static double ka(double AltS, double sunra, double Lat, double HeightEye, double ' ExtType [0=ka,1=kW,2=kR,3=kOZ,4=ktot] ' kt [-] */ -static double kt(double AltS, double sunra, double Lat, double HeightEye, double TempS, double RH, double VR, int32 ExtType, char *serr) +static double +kt(double AltS, double sunra, double Lat, double HeightEye, double TempS, + double RH, double VR, int32 ExtType, char *serr) { - double kRact = 0; - double kWact = 0; - double kOZact = 0; - double kaact = 0; - if (ExtType == 2 || ExtType == 4) - kRact = kR(AltS, HeightEye); - if (ExtType == 1 || ExtType == 4) - kWact = kW(HeightEye, TempS, RH); - if (ExtType == 3 || ExtType == 4) - kOZact = kOZ(AltS, sunra, Lat); - if (ExtType == 0 || ExtType == 4) - kaact = ka(AltS, sunra, Lat, HeightEye, TempS, RH, VR, serr); - if (kaact < 0) - kaact = 0; - return kWact + kRact + kOZact + kaact; + double kRact = 0; + double kWact = 0; + double kOZact = 0; + double kaact = 0; + if (ExtType == 2 || ExtType == 4) + kRact = kR(AltS, HeightEye); + if (ExtType == 1 || ExtType == 4) + kWact = kW(HeightEye, TempS, RH); + if (ExtType == 3 || ExtType == 4) + kOZact = kOZ(AltS, sunra, Lat); + if (ExtType == 0 || ExtType == 4) + kaact = ka(AltS, sunra, Lat, HeightEye, TempS, RH, VR, serr); + if (kaact < 0) + kaact = 0; + return kWact + kRact + kOZact + kaact; } /*################################################################### @@ -977,14 +1132,15 @@ static double kt(double AltS, double sunra, double Lat, double HeightEye, double ' PresS [mbar] ' Airmass [??] */ -static double Airmass(double AppAltO, double Press) +static double +Airmass(double AppAltO, double Press) { - double airm, zend; - zend = (90 - AppAltO) * DEGTORAD; - if (zend > PI / 2) - zend = PI / 2; - airm = 1 / (cos(zend) + 0.025 * exp(-11 * cos(zend))); - return Press / 1013 * airm; + double airm, zend; + zend = (90 - AppAltO) * DEGTORAD; + if (zend > PI / 2) + zend = PI / 2; + airm = 1 / (cos(zend) + 0.025 * exp(-11 * cos(zend))); + return Press / 1013 * airm; } /*################################################################### @@ -993,9 +1149,14 @@ static double Airmass(double AppAltO, double Press) ' PresS [mbar] ' Xext [-] */ -static double Xext(double scaleH, double zend, double Press) +static double +Xext(double scaleH, double zend, double Press) { - return Press / 1013.0 / (cos(zend) + 0.01 * sqrt(scaleH / 1000.0) * exp(-30.0 / sqrt(scaleH / 1000.0) * cos(zend))); + return Press / 1013.0 / (cos(zend) + + 0.01 * sqrt(scaleH / 1000.0) * exp(-30.0 / + sqrt(scaleH / + 1000.0) * + cos(zend))); } /*################################################################### @@ -1004,11 +1165,12 @@ static double Xext(double scaleH, double zend, double Press) ' PresS [mbar] ' Xlay [-] */ -static double Xlay(double scaleH, double zend, double Press) +static double +Xlay(double scaleH, double zend, double Press) { - /*return Press / 1013.0 / sqrt(1.0 - pow(sin(zend) / (1.0 + (scaleH / Ra)), 2));*/ - double a = sin(zend) / (1.0 + (scaleH / Ra)); - return Press / 1013.0 / sqrt(1.0 - a * a); + /*return Press / 1013.0 / sqrt(1.0 - pow(sin(zend) / (1.0 + (scaleH / Ra)), 2)); */ + double a = sin(zend) / (1.0 + (scaleH / Ra)); + return Press / 1013.0 / sqrt(1.0 - a * a); } /*################################################################### @@ -1018,9 +1180,10 @@ static double Xlay(double scaleH, double zend, double Press) ' HeightEye [m] ' TempEfromTempS [C] */ -static double TempEfromTempS(double TempS, double HeightEye, double Lapse) +static double +TempEfromTempS(double TempS, double HeightEye, double Lapse) { - return TempS - Lapse * HeightEye; + return TempS - Lapse * HeightEye; } /*################################################################### @@ -1029,9 +1192,12 @@ static double TempEfromTempS(double TempS, double HeightEye, double Lapse) ' HeightEye [m] ' PresEfromPresS [mbar] */ -static double PresEfromPresS(double TempS, double Press, double HeightEye) +static double +PresEfromPresS(double TempS, double Press, double HeightEye) { - return Press * exp(-9.80665 * 0.0289644 / (Kelvin(TempS) + 3.25 * HeightEye / 1000) / 8.31441 * HeightEye); + return Press * exp(-9.80665 * 0.0289644 / + (Kelvin(TempS) + + 3.25 * HeightEye / 1000) / 8.31441 * HeightEye); } /*################################################################### @@ -1046,32 +1212,44 @@ static double PresEfromPresS(double TempS, double Press, double HeightEye) ' VR [km] ' Deltam [-] */ -static double Deltam(double AltO, double AltS, double sunra, double Lat, double HeightEye, double *datm, int32 helflag, char *serr) +static double +Deltam(double AltO, double AltS, double sunra, double Lat, double HeightEye, + double *datm, int32 helflag, char *serr) { - double zend, xR, XW, Xa, XOZ; - double PresE = PresEfromPresS(datm[1], datm[0], HeightEye); - double TempE = TempEfromTempS(datm[1], HeightEye, LapseSA); - double AppAltO = AppAltfromTopoAlt(AltO, TempE, PresE, helflag); - double deltam; - static double alts_last, alto_last, sunra_last, deltam_last; - if (AltS == alts_last && AltO == alto_last && sunra == sunra_last) - return deltam_last; - alts_last = AltS; alto_last = AltO; sunra_last = sunra; - if (staticAirmass == 0) { - zend = (90 - AppAltO) * DEGTORAD; - if (zend > PI / 2) - zend = PI / 2; - /* From Schaefer , Archaeoastronomy, XV, 2000, page 128*/ - xR = Xext(scaleHrayleigh, zend, datm[0]); - XW = Xext(scaleHwater, zend, datm[0]); - Xa = Xext(scaleHaerosol, zend, datm[0]); - XOZ = Xlay(scaleHozone, zend, datm[0]); - deltam = kR(AltS, HeightEye) * xR + kt(AltS, sunra, Lat, HeightEye, datm[1], datm[2], datm[3], 0, serr) * Xa + kOZ(AltS, sunra, Lat) * XOZ + kW(HeightEye, datm[1], datm[2]) * XW; - } else { - deltam = kt(AltS, sunra, Lat, HeightEye, datm[1], datm[2], datm[3], 4, serr) * Airmass(AppAltO, datm[0]); - } - deltam_last = deltam; - return deltam; + double zend, xR, XW, Xa, XOZ; + double PresE = PresEfromPresS(datm[1], datm[0], HeightEye); + double TempE = TempEfromTempS(datm[1], HeightEye, LapseSA); + double AppAltO = AppAltfromTopoAlt(AltO, TempE, PresE, helflag); + double deltam; + static double alts_last, alto_last, sunra_last, deltam_last; + if (AltS == alts_last && AltO == alto_last && sunra == sunra_last) + return deltam_last; + alts_last = AltS; + alto_last = AltO; + sunra_last = sunra; + if (staticAirmass == 0) { + zend = (90 - AppAltO) * DEGTORAD; + if (zend > PI / 2) + zend = PI / 2; + /* From Schaefer , Archaeoastronomy, XV, 2000, page 128 */ + xR = Xext(scaleHrayleigh, zend, datm[0]); + XW = Xext(scaleHwater, zend, datm[0]); + Xa = Xext(scaleHaerosol, zend, datm[0]); + XOZ = Xlay(scaleHozone, zend, datm[0]); + deltam = + kR(AltS, HeightEye) * xR + kt(AltS, sunra, Lat, HeightEye, + datm[1], datm[2], datm[3], 0, + serr) * Xa + kOZ(AltS, sunra, + Lat) * XOZ + + kW(HeightEye, datm[1], datm[2]) * XW; + } + else { + deltam = + kt(AltS, sunra, Lat, HeightEye, datm[1], datm[2], datm[3], 4, + serr) * Airmass(AppAltO, datm[0]); + } + deltam_last = deltam; + return deltam; } /*################################################################### @@ -1086,29 +1264,40 @@ static double Deltam(double AltO, double AltS, double sunra, double Lat, double ' VR [km] ' Bn [nL] */ -static double Bn(double AltO, double JDNDayUT, double AltS, double sunra, double Lat, double HeightEye, double *datm, int32 helflag, char *serr) +static double +Bn(double AltO, double JDNDayUT, double AltS, double sunra, double Lat, + double HeightEye, double *datm, int32 helflag, char *serr) { - double PresE = PresEfromPresS(datm[1], datm[0], HeightEye); - double TempE = TempEfromTempS(datm[1], HeightEye, LapseSA); - double AppAltO = AppAltfromTopoAlt(AltO, TempE, PresE, helflag); - double zend, YearB, MonthB, DayB, Bna, kX, Bnb; - double B0 = 0.0000000000001, dut; - int iyar, imon, iday; - /* Below altitude of 10 degrees, the Bn stays the same (see page 343 Vistas in Astronomy) */ - if (AppAltO < 10) - AppAltO = 10; - zend = (90 - AppAltO) * DEGTORAD; - /* From Schaefer , Archaeoastronomy, XV, 2000, page 128 and adjusted for sunspot period*/ - /*YearB = DatefromJDut(JDNDayUT, 1); - MonthB = DatefromJDut(JDNDayUT, 2); - DayB = DatefromJDut(JDNDayUT, 3);*/ - swe_revjul(JDNDayUT, SE_GREG_CAL, &iyar, &imon, &iday, &dut); - YearB = iyar; MonthB = imon; DayB = iday; - Bna = B0 * (1 + 0.3 * cos(6.283 * (YearB + ((DayB - 1) / 30.4 + MonthB - 1) / 12 - 1990.33) / 11.1)); - kX = Deltam(AltO, AltS, sunra, Lat, HeightEye, datm, helflag, serr); - /* From Schaefer , Archaeoastronomy, XV, 2000, page 129 */ - Bnb = Bna * (0.4 + 0.6 / sqrt(1 - 0.96 * pow(sin(zend), 2))) * pow(10, -0.4 * kX); - return mymax(Bnb, 0) * erg2nL; + double PresE = PresEfromPresS(datm[1], datm[0], HeightEye); + double TempE = TempEfromTempS(datm[1], HeightEye, LapseSA); + double AppAltO = AppAltfromTopoAlt(AltO, TempE, PresE, helflag); + double zend, YearB, MonthB, DayB, Bna, kX, Bnb; + double B0 = 0.0000000000001, dut; + int iyar, imon, iday; + /* Below altitude of 10 degrees, the Bn stays the same (see page 343 Vistas in Astronomy) */ + if (AppAltO < 10) + AppAltO = 10; + zend = (90 - AppAltO) * DEGTORAD; + /* From Schaefer , Archaeoastronomy, XV, 2000, page 128 and adjusted for sunspot period */ + /*YearB = DatefromJDut(JDNDayUT, 1); + * MonthB = DatefromJDut(JDNDayUT, 2); + * DayB = DatefromJDut(JDNDayUT, 3); */ + swe_revjul(JDNDayUT, SE_GREG_CAL, &iyar, &imon, &iday, &dut); + YearB = iyar; + MonthB = imon; + DayB = iday; + Bna = + B0 * (1 + + 0.3 * cos(6.283 * + (YearB + ((DayB - 1) / 30.4 + MonthB - 1) / 12 - + 1990.33) / 11.1)); + kX = Deltam(AltO, AltS, sunra, Lat, HeightEye, datm, helflag, serr); + /* From Schaefer , Archaeoastronomy, XV, 2000, page 129 */ + Bnb = + Bna * (0.4 + 0.6 / sqrt(1 - 0.96 * pow(sin(zend), 2))) * pow(10, + -0.4 * + kX); + return mymax(Bnb, 0) * erg2nL; } /*################################################################### @@ -1119,51 +1308,59 @@ static double Bn(double AltO, double JDNDayUT, double AltS, double sunra, double ' ObjectName [-] ' Magnitude [-] */ -static int32 Magnitude(double JDNDaysUT, double *dgeo, char *ObjectName, int32 helflag, double *dmag, char *serr) +static int32 +Magnitude(double JDNDaysUT, double *dgeo, char *ObjectName, int32 helflag, + double *dmag, char *serr) { - double x[20]; - int32 Planet, iflag, epheflag; - epheflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - *dmag = -99.0; - Planet = DeterObject(ObjectName); - iflag = SEFLG_TOPOCTR | SEFLG_EQUATORIAL | epheflag; - if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) - iflag |= SEFLG_NONUT|SEFLG_TRUEPOS; - if (Planet != -1) { + double x[20]; + int32 Planet, iflag, epheflag; + epheflag = helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + *dmag = -99.0; + Planet = DeterObject(ObjectName); + iflag = SEFLG_TOPOCTR | SEFLG_EQUATORIAL | epheflag; + if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) + iflag |= SEFLG_NONUT | SEFLG_TRUEPOS; + if (Planet != -1) { + /**dmag = Phenomena(JDNDaysUT, Lat, Longitude, HeightEye, TempE, PresE, ObjectName, 4);*/ - swe_set_topo(dgeo[0], dgeo[1], dgeo[2]); - if (swe_pheno_ut(JDNDaysUT, Planet, iflag, x, serr) == ERR) - return ERR; - *dmag = x[4]; - } else { - if (call_swe_fixstar_mag(ObjectName, dmag, serr) == ERR) - return ERR; - } - return OK; + swe_set_topo(dgeo[0], dgeo[1], dgeo[2]); + if (swe_pheno_ut(JDNDaysUT, Planet, iflag, x, serr) == ERR) + return ERR; + *dmag = x[4]; + } + else { + if (call_swe_fixstar_mag(ObjectName, dmag, serr) == ERR) + return ERR; + } + return OK; } #if 0 -static int32 fast_magnitude(double tjd, double *dgeo, char *ObjectName, int32 helflag, double *dmag, char *serr) +static int32 +fast_magnitude(double tjd, double *dgeo, char *ObjectName, int32 helflag, + double *dmag, char *serr) { - int32 retval = OK, ipl, ipli; - double dtjd; - static double tjdsv[3]; - static double dmagsv[3]; - static int32 helflagsv[3]; - ipl = DeterObject(ObjectName); - ipli = ipl; - if (ipli > SE_MOON) - ipli = 2; - dtjd = tjd - tjdsv[ipli]; - if (tjdsv[ipli] != 0 && helflag == helflagsv[ipli] && fabs(dtjd) < 5.0 / 1440.0) { - *dmag = dmagsv[ipli]; - } else { - retval = Magnitude(tjd, dgeo, ObjectName, helflag, dmag, serr); - tjdsv[ipli] = tjd; - helflagsv[ipli] = helflag; - dmagsv[ipli] = *dmag; - } - return retval; + int32 retval = OK, ipl, ipli; + double dtjd; + static double tjdsv[3]; + static double dmagsv[3]; + static int32 helflagsv[3]; + ipl = DeterObject(ObjectName); + ipli = ipl; + if (ipli > SE_MOON) + ipli = 2; + dtjd = tjd - tjdsv[ipli]; + if (tjdsv[ipli] != 0 && helflag == helflagsv[ipli] + && fabs(dtjd) < 5.0 / 1440.0) { + *dmag = dmagsv[ipli]; + } + else { + retval = Magnitude(tjd, dgeo, ObjectName, helflag, dmag, serr); + tjdsv[ipli] = tjd; + helflagsv[ipli] = helflag; + dmagsv[ipli] = *dmag; + } + return retval; } #endif @@ -1172,11 +1369,13 @@ static int32 fast_magnitude(double tjd, double *dgeo, char *ObjectName, int32 he ' phasemoon [-] ' MoonsBrightness [-] */ -static double MoonsBrightness(double dist, double phasemoon) +static double +MoonsBrightness(double dist, double phasemoon) { - double log10 = 2.302585092994; - /*Moon's brightness changes with distance: http://hem.passagen.se/pausch/comp/ppcomp.html#15 */ - return -21.62 + 5 * log(dist / (Ra / 1000)) / log10 + 0.026 * fabs(phasemoon) + 0.000000004 * pow(phasemoon, 4); + double log10 = 2.302585092994; + /*Moon's brightness changes with distance: http://hem.passagen.se/pausch/comp/ppcomp.html#15 */ + return -21.62 + 5 * log(dist / (Ra / 1000)) / log10 + + 0.026 * fabs(phasemoon) + 0.000000004 * pow(phasemoon, 4); } /*################################################################### @@ -1185,79 +1384,103 @@ static double MoonsBrightness(double dist, double phasemoon) ' AziS [deg] ' MoonPhase [deg] */ -static double MoonPhase(double AltM, double AziM, double AziS) +static double +MoonPhase(double AltM, double AziM, double AziS) { - double AltMi = AltM * DEGTORAD; - double AziMi = AziM * DEGTORAD; - double AziSi = AziS * DEGTORAD; - return 180 - acos(cos(AziSi - AziMi) * cos(AltMi + 0.95 * DEGTORAD)) / DEGTORAD; + double AltMi = AltM * DEGTORAD; + double AziMi = AziM * DEGTORAD; + double AziSi = AziS * DEGTORAD; + return 180 - + acos(cos(AziSi - AziMi) * cos(AltMi + 0.95 * DEGTORAD)) / DEGTORAD; } /*################################################################### ' Pressure [mbar] */ -static double Bm(double AltO, double AziO, double AltM, double AziM, double AltS, double AziS, double sunra, double Lat, double HeightEye, double *datm, int32 helflag, char *serr) +static double +Bm(double AltO, double AziO, double AltM, double AziM, double AltS, + double AziS, double sunra, double Lat, double HeightEye, double *datm, + int32 helflag, char *serr) { - double M0 = -11.05; - double Bm = 0; - double RM, kXM, kX, C3, FM, phasemoon, MM; - if (AltM > -0.26) { - /* moon only adds light when (partly) above horizon - * From Schaefer , Archaeoastronomy, XV, 2000, page 129*/ - RM = DistanceAngle(AltO * DEGTORAD, AziO * DEGTORAD, AltM * DEGTORAD, AziM * DEGTORAD) / DEGTORAD; - kXM = Deltam(AltM, AltS, sunra, Lat, HeightEye, datm, helflag, serr); - kX = Deltam(AltO, AltS, sunra, Lat, HeightEye, datm, helflag, serr); - C3 = pow(10, -0.4 * kXM); - FM = (62000000.0) / RM / RM + pow(10, 6.15 - RM / 40) + pow(10, 5.36) * (1.06 + pow(cos(RM * DEGTORAD), 2)); - Bm = FM * C3 + 440000 * (1 - C3); - phasemoon = MoonPhase(AltM, AziM, AziS); - MM = MoonsBrightness(MoonDistance, phasemoon); - Bm = Bm * pow(10, -0.4 * (MM - M0 + 43.27)); - Bm = Bm * (1 - pow(10, -0.4 * kX)); - } - Bm = mymax(Bm, 0) * erg2nL; - return Bm; + double M0 = -11.05; + double Bm = 0; + double RM, kXM, kX, C3, FM, phasemoon, MM; + if (AltM > -0.26) { + /* moon only adds light when (partly) above horizon + * From Schaefer , Archaeoastronomy, XV, 2000, page 129*/ + RM = DistanceAngle(AltO * DEGTORAD, AziO * DEGTORAD, AltM * DEGTORAD, + AziM * DEGTORAD) / DEGTORAD; + kXM = Deltam(AltM, AltS, sunra, Lat, HeightEye, datm, helflag, serr); + kX = Deltam(AltO, AltS, sunra, Lat, HeightEye, datm, helflag, serr); + C3 = pow(10, -0.4 * kXM); + FM = (62000000.0) / RM / RM + pow(10, 6.15 - RM / 40) + pow(10, + 5.36) * + (1.06 + pow(cos(RM * DEGTORAD), 2)); + Bm = FM * C3 + 440000 * (1 - C3); + phasemoon = MoonPhase(AltM, AziM, AziS); + MM = MoonsBrightness(MoonDistance, phasemoon); + Bm = Bm * pow(10, -0.4 * (MM - M0 + 43.27)); + Bm = Bm * (1 - pow(10, -0.4 * kX)); + } + Bm = mymax(Bm, 0) * erg2nL; + return Bm; } /*################################################################### ' Pressure [mbar] */ -static double Btwi(double AltO, double AziO, double AltS, double AziS, double sunra, double Lat, double HeightEye, double *datm, int32 helflag, char *serr) +static double +Btwi(double AltO, double AziO, double AltS, double AziS, double sunra, + double Lat, double HeightEye, double *datm, int32 helflag, char *serr) { -double M0 = -11.05; -double MS = -26.74; -double PresE = PresEfromPresS(datm[1], datm[0], HeightEye); -double TempE = TempEfromTempS(datm[1], HeightEye, LapseSA); -double AppAltO = AppAltfromTopoAlt(AltO, TempE, PresE, helflag); -double ZendO = 90 - AppAltO; -double RS = DistanceAngle(AltO * DEGTORAD, AziO * DEGTORAD, AltS * DEGTORAD, AziS * DEGTORAD) / DEGTORAD; -double kX = Deltam(AltO, AltS, sunra, Lat, HeightEye, datm, helflag, serr); -double k = kt(AltS, sunra, Lat, HeightEye, datm[1], datm[2], datm[3], 4, serr); + double M0 = -11.05; + double MS = -26.74; + double PresE = PresEfromPresS(datm[1], datm[0], HeightEye); + double TempE = TempEfromTempS(datm[1], HeightEye, LapseSA); + double AppAltO = AppAltfromTopoAlt(AltO, TempE, PresE, helflag); + double ZendO = 90 - AppAltO; + double RS = + DistanceAngle(AltO * DEGTORAD, AziO * DEGTORAD, AltS * DEGTORAD, + AziS * DEGTORAD) / DEGTORAD; + double kX = + Deltam(AltO, AltS, sunra, Lat, HeightEye, datm, helflag, serr); + double k = + kt(AltS, sunra, Lat, HeightEye, datm[1], datm[2], datm[3], 4, serr); + /* From Schaefer , Archaeoastronomy, XV, 2000, page 129*/ -double Btwi = pow(10, -0.4 * (MS - M0 + 32.5 - AltS - (ZendO / (360 * k)))); -Btwi = Btwi * (100 / RS) * (1 - pow(10, -0.4 * kX)); -Btwi = mymax(Btwi, 0) * erg2nL; -return Btwi; + double Btwi = + pow(10, -0.4 * (MS - M0 + 32.5 - AltS - (ZendO / (360 * k)))); + Btwi = Btwi * (100 / RS) * (1 - pow(10, -0.4 * kX)); + Btwi = mymax(Btwi, 0) * erg2nL; + return Btwi; } /*################################################################### ' Pressure [mbar] */ -static double Bday(double AltO, double AziO, double AltS, double AziS, double sunra, double Lat, double HeightEye, double *datm, int32 helflag, char *serr) +static double +Bday(double AltO, double AziO, double AltS, double AziS, double sunra, + double Lat, double HeightEye, double *datm, int32 helflag, char *serr) { - double M0 = -11.05; - double MS = -26.74; - double RS = DistanceAngle(AltO * DEGTORAD, AziO * DEGTORAD, AltS * DEGTORAD, AziS * DEGTORAD) / DEGTORAD; - double kXS = Deltam(AltS, AltS, sunra, Lat, HeightEye, datm, helflag, serr); - double kX = Deltam(AltO, AltS, sunra, Lat, HeightEye, datm, helflag, serr); - /* From Schaefer , Archaeoastronomy, XV, 2000, page 129*/ - double C4 = pow(10, -0.4 * kXS); - double FS = (62000000.0) / RS / RS + pow(10, (6.15 - RS / 40)) + pow(10, 5.36) * (1.06 + pow(cos(RS * DEGTORAD), 2)); - double Bday = FS * C4 + 440000.0 * (1 - C4); - Bday = Bday * pow(10, (-0.4 * (MS - M0 + 43.27))); - Bday = Bday * (1 - pow(10, -0.4 * kX)); - Bday = mymax(Bday, 0) * erg2nL; - return Bday; + double M0 = -11.05; + double MS = -26.74; + double RS = + DistanceAngle(AltO * DEGTORAD, AziO * DEGTORAD, AltS * DEGTORAD, + AziS * DEGTORAD) / DEGTORAD; + double kXS = + Deltam(AltS, AltS, sunra, Lat, HeightEye, datm, helflag, serr); + double kX = + Deltam(AltO, AltS, sunra, Lat, HeightEye, datm, helflag, serr); + /* From Schaefer , Archaeoastronomy, XV, 2000, page 129 */ + double C4 = pow(10, -0.4 * kXS); + double FS = (62000000.0) / RS / RS + pow(10, (6.15 - RS / 40)) + pow(10, + 5.36) + * (1.06 + pow(cos(RS * DEGTORAD), 2)); + double Bday = FS * C4 + 440000.0 * (1 - C4); + Bday = Bday * pow(10, (-0.4 * (MS - M0 + 43.27))); + Bday = Bday * (1 - pow(10, -0.4 * kX)); + Bday = mymax(Bday, 0) * erg2nL; + return Bday; } /*################################################################### @@ -1265,38 +1488,57 @@ static double Bday(double AltO, double AziO, double AltS, double AziS, double su ' PresS [mbar] ' Bcity [nL] */ -static double Bcity(double Value, double Press) +static double +Bcity(double Value, double Press) { - double Bcity = Value; - Bcity = mymax(Bcity, 0); - return Bcity; + double Bcity = Value; + Bcity = mymax(Bcity, 0); + return Bcity; } /*################################################################### ' Pressure [mbar] */ -static double Bsky(double AltO, double AziO, double AltM, double AziM, double JDNDaysUT, double AltS, double AziS, double sunra, double Lat, double HeightEye, double *datm, int32 helflag, char *serr) +static double +Bsky(double AltO, double AziO, double AltM, double AziM, double JDNDaysUT, + double AltS, double AziS, double sunra, double Lat, double HeightEye, + double *datm, int32 helflag, char *serr) { - double Bsky = 0; - if (AltS < -3) { - Bsky += Btwi(AltO, AziO, AltS, AziS, sunra, Lat, HeightEye, datm, helflag, serr); - } else { - if (AltS > 4) { - Bsky += Bday(AltO, AziO, AltS, AziS, sunra, Lat, HeightEye, datm, helflag, serr); - } else { - Bsky += mymin(Bday(AltO, AziO, AltS, AziS, sunra, Lat, HeightEye, datm, helflag, serr), Btwi(AltO, AziO, AltS, AziS, sunra, Lat, HeightEye, datm, helflag, serr)); + double Bsky = 0; + if (AltS < -3) { + Bsky += + Btwi(AltO, AziO, AltS, AziS, sunra, Lat, HeightEye, datm, helflag, + serr); } - } - /* if max. Bm [1E7] <5% of Bsky don't add Bm*/ - if (Bsky < 200000000.0) - Bsky += Bm(AltO, AziO, AltM, AziM, AltS, AziS, sunra, Lat, HeightEye, datm, helflag, serr); - if (AltS <= 0) - Bsky += Bcity(0, datm[0]); - /* if max. Bn [250] <5% of Bsky don't add Bn*/ - if (Bsky < 5000) - Bsky = Bsky + Bn(AltO, JDNDaysUT, AltS, sunra, Lat, HeightEye, datm, helflag, serr); - /* if max. Bm [1E7] <5% of Bsky don't add Bm*/ - return Bsky; + else { + if (AltS > 4) { + Bsky += + Bday(AltO, AziO, AltS, AziS, sunra, Lat, HeightEye, datm, + helflag, serr); + } + else { + Bsky += + mymin(Bday + (AltO, AziO, AltS, AziS, sunra, Lat, HeightEye, datm, + helflag, serr), Btwi(AltO, AziO, AltS, AziS, sunra, + Lat, HeightEye, datm, helflag, + serr)); + } + } + /* if max. Bm [1E7] <5% of Bsky don't add Bm */ + if (Bsky < 200000000.0) + Bsky += + Bm(AltO, AziO, AltM, AziM, AltS, AziS, sunra, Lat, HeightEye, + datm, helflag, serr); + if (AltS <= 0) + Bsky += Bcity(0, datm[0]); + /* if max. Bn [250] <5% of Bsky don't add Bn */ + if (Bsky < 5000) + Bsky = + Bsky + Bn(AltO, JDNDaysUT, AltS, sunra, Lat, HeightEye, datm, + helflag, serr); + /* if max. Bm [1E7] <5% of Bsky don't add Bm */ + return Bsky; } /* default handling: @@ -1314,43 +1556,48 @@ static double Bsky(double AltO, double AziO, double AltM, double AziM, double JD * [0] age (default 36) * [1] Snellen ratio or visual acuity of observer (default 1) */ -static void default_heliacal_parameters(double *datm, double *dgeo, double *dobs, int helflag) +static void +default_heliacal_parameters(double *datm, double *dgeo, double *dobs, + int helflag) { - int i; - if (datm[0] <= 0) { - /* estimate atmospheric pressure, according to the - * International Standard Atmosphere (ISA) */ - datm[0] = 1013.25 * pow(1 - 0.0065 * dgeo[2] / 288, 5.255); - /* temperature */ - if (datm[1] == 0) - datm[1] = 15 - 0.0065 * dgeo[2]; - /* relative humidity, independent of atmospheric pressure and altitude */ - if (datm[2] == 0) - datm[2] = 40; - /* note: datm[3] / VR defaults outside this function */ - } else { + int i; + if (datm[0] <= 0) { + /* estimate atmospheric pressure, according to the + * International Standard Atmosphere (ISA) */ + datm[0] = 1013.25 * pow(1 - 0.0065 * dgeo[2] / 288, 5.255); + /* temperature */ + if (datm[1] == 0) + datm[1] = 15 - 0.0065 * dgeo[2]; + /* relative humidity, independent of atmospheric pressure and altitude */ + if (datm[2] == 0) + datm[2] = 40; + /* note: datm[3] / VR defaults outside this function */ + } + else { #ifndef SIMULATE_VICTORVB - if (datm[2] <= 0.00000001) datm[2] = 0.00000001; - if (datm[2] >= 99.99999999) datm[2] = 99.99999999; + if (datm[2] <= 0.00000001) + datm[2] = 0.00000001; + if (datm[2] >= 99.99999999) + datm[2] = 99.99999999; #endif - } - /* age of observer */ - if (dobs[0] == 0) - dobs[0] = 36; - /* SN Snellen factor of the visual acuity of the observer */ - if (dobs[1] == 0) - dobs[1] = 1; - if (!(helflag & SE_HELFLAG_OPTICAL_PARAMS)) { - for (i = 2; i <= 5; i++) - dobs[i] = 0; - } - /* OpticMagn undefined -> use eye */ - if (dobs[3] == 0) { - dobs[2] = 1; /* Binocular = 1 */ - dobs[3] = 1; /* OpticMagn = 1: use eye */ - /* dobs[4] and dobs[5] (OpticDia and OpticTrans) will be defaulted in - * OpticFactor() */ - } + } + /* age of observer */ + if (dobs[0] == 0) + dobs[0] = 36; + /* SN Snellen factor of the visual acuity of the observer */ + if (dobs[1] == 0) + dobs[1] = 1; + if (!(helflag & SE_HELFLAG_OPTICAL_PARAMS)) { + for (i = 2; i <= 5; i++) + dobs[i] = 0; + } + /* OpticMagn undefined -> use eye */ + if (dobs[3] == 0) { + dobs[2] = 1; /* Binocular = 1 */ + dobs[3] = 1; /* OpticMagn = 1: use eye */ + /* dobs[4] and dobs[5] (OpticDia and OpticTrans) will be defaulted in + * OpticFactor() */ + } } /*################################################################### @@ -1372,52 +1619,60 @@ static void default_heliacal_parameters(double *datm, double *dgeo, double *dobs ' VR [km] ' VisLimMagn [-] */ -static double VisLimMagn(double *dobs, double AltO, double AziO, double AltM, double AziM, double JDNDaysUT, double AltS, double AziS, double sunra, double Lat, double HeightEye, double *datm, int32 helflag, int32 *scotopic_flag, char *serr) +static double +VisLimMagn(double *dobs, double AltO, double AziO, double AltM, double AziM, + double JDNDaysUT, double AltS, double AziS, double sunra, + double Lat, double HeightEye, double *datm, int32 helflag, + int32 * scotopic_flag, char *serr) { - double C1, C2, Th, kX, Bsk, CorrFactor1, CorrFactor2; - double log10 = 2.302585092994; - /*double Age = dobs[0];*/ - /*double SN = dobs[1];*/ - Bsk = Bsky(AltO, AziO, AltM, AziM, JDNDaysUT, AltS, AziS, sunra, Lat, HeightEye, datm, helflag, serr); - /* Schaefer, Astronomy and the limits of vision, Archaeoastronomy, 1993 Verder:*/ - kX = Deltam(AltO, AltS, sunra, Lat, HeightEye, datm, helflag, serr); - /* influence of age*/ - /*Fa = mymax(1, pow(p(23, Bsk) / p(Age, Bsk), 2)); */ - CorrFactor1 = OpticFactor(Bsk, kX, dobs, JDNDaysUT, "", 1, helflag); - CorrFactor2 = OpticFactor(Bsk, kX, dobs, JDNDaysUT, "", 0, helflag); - /* From Schaefer , Archaeoastronomy, XV, 2000, page 129*/ - if (Bsk < BNIGHT && !(helflag & SE_HELFLAG_VISLIM_PHOTOPIC)) { - C1 = 1.5848931924611e-10; /*pow(10, -9.8);*/ /* C1 = 10 ^ (-9.8);*/ - C2 = 0.012589254117942; /*pow(10, -1.9);*/ /* C2 = 10 ^ (-1.9);*/ - if (scotopic_flag != NULL) - *scotopic_flag = 1; - } else { - C1 = 4.4668359215096e-9; /*pow(10, -8.35);*/ /* C1 = 10 ^ (-8.35);*/ - C2 = 1.2589254117942e-6; /*pow(10, -5.9);*/ /* C2 = 10 ^ (-5.9);*/ - if (scotopic_flag != NULL) - *scotopic_flag = 0; - } - if (scotopic_flag != NULL) { - if (BNIGHT * BNIGHT_FACTOR > Bsk && BNIGHT / BNIGHT_FACTOR < Bsk) - *scotopic_flag |= 2; - } - /*Th = C1 * pow(1 + sqrt(C2 * Bsk), 2) * Fa;*/ - Bsk = Bsk / CorrFactor1; - Th = C1 * pow(1 + sqrt(C2 * Bsk), 2) * CorrFactor2; + double C1, C2, Th, kX, Bsk, CorrFactor1, CorrFactor2; + double log10 = 2.302585092994; + /*double Age = dobs[0]; */ + /*double SN = dobs[1]; */ + Bsk = + Bsky(AltO, AziO, AltM, AziM, JDNDaysUT, AltS, AziS, sunra, Lat, + HeightEye, datm, helflag, serr); + /* Schaefer, Astronomy and the limits of vision, Archaeoastronomy, 1993 Verder: */ + kX = Deltam(AltO, AltS, sunra, Lat, HeightEye, datm, helflag, serr); + /* influence of age */ + /*Fa = mymax(1, pow(p(23, Bsk) / p(Age, Bsk), 2)); */ + CorrFactor1 = OpticFactor(Bsk, kX, dobs, JDNDaysUT, "", 1, helflag); + CorrFactor2 = OpticFactor(Bsk, kX, dobs, JDNDaysUT, "", 0, helflag); + /* From Schaefer , Archaeoastronomy, XV, 2000, page 129 */ + if (Bsk < BNIGHT && !(helflag & SE_HELFLAG_VISLIM_PHOTOPIC)) { + C1 = 1.5848931924611e-10; /*pow(10, -9.8); *//* C1 = 10 ^ (-9.8); */ + C2 = 0.012589254117942; /*pow(10, -1.9); *//* C2 = 10 ^ (-1.9); */ + if (scotopic_flag != NULL) + *scotopic_flag = 1; + } + else { + C1 = 4.4668359215096e-9; /*pow(10, -8.35); *//* C1 = 10 ^ (-8.35); */ + C2 = 1.2589254117942e-6; /*pow(10, -5.9); *//* C2 = 10 ^ (-5.9); */ + if (scotopic_flag != NULL) + *scotopic_flag = 0; + } + if (scotopic_flag != NULL) { + if (BNIGHT * BNIGHT_FACTOR > Bsk && BNIGHT / BNIGHT_FACTOR < Bsk) + *scotopic_flag |= 2; + } + /*Th = C1 * pow(1 + sqrt(C2 * Bsk), 2) * Fa; */ + Bsk = Bsk / CorrFactor1; + Th = C1 * pow(1 + sqrt(C2 * Bsk), 2) * CorrFactor2; #if DEBUG - fprintf(stderr, "Bsk=%f\n", Bsk); - fprintf(stderr, "kX =%f\n", kX); - fprintf(stderr, "Th =%f\n", Th); - fprintf(stderr, "CorrFactor1=%f\n", CorrFactor1); - fprintf(stderr, "CorrFactor2=%f\n", CorrFactor2); + fprintf(stderr, "Bsk=%f\n", Bsk); + fprintf(stderr, "kX =%f\n", kX); + fprintf(stderr, "Th =%f\n", Th); + fprintf(stderr, "CorrFactor1=%f\n", CorrFactor1); + fprintf(stderr, "CorrFactor2=%f\n", CorrFactor2); #endif - /* Visual limiting magnitude of point source*/ + /* Visual limiting magnitude of point source */ #if 0 - if (SN <= 0.00000001) - SN = 0.00000001; - return -16.57 - 2.5 * (log(Th) / log10) - kX + 5.0 * (log(SN) / log10);*/ + if (SN <= 0.00000001) + SN = 0.00000001; + return -16.57 - 2.5 * (log(Th) / log10) - kX + 5.0 * (log(SN) / log10); + */ #endif - return -16.57 - 2.5 * (log(Th) / log10); + return -16.57 - 2.5 * (log(Th) / log10); } /* Limiting magnitude in dark skies @@ -1428,73 +1683,86 @@ static double VisLimMagn(double *dobs, double AltO, double AziO, double AltM, do * |1 OK, scotopic vision * |2 OK, near limit photopic/scotopic */ -int32 FAR PASCAL_CONV swe_vis_limit_mag(double tjdut, double *dgeo, double *datm, double *dobs, char *ObjectName, int32 helflag, double *dret, char *serr) +int32 FAR PASCAL_CONV +swe_vis_limit_mag(double tjdut, double *dgeo, double *datm, double *dobs, + char *ObjectName, int32 helflag, double *dret, char *serr) { - int32 retval = OK, i, scotopic_flag = 0; - double AltO, AziO, AltM, AziM, AltS, AziS; - double sunra = SunRA(tjdut, helflag, serr); - default_heliacal_parameters(datm, dgeo, dobs, helflag); - swe_set_topo(dgeo[0], dgeo[1], dgeo[2]); - for (i = 0; i < 7; i++) - dret[i] = 0; - if (ObjectLoc(tjdut, dgeo, datm, ObjectName, 0, helflag, &AltO, serr) == ERR) - return ERR; - if (AltO < 0 && serr != NULL) { - strcpy(serr, "object is below local horizon"); - *dret = -100; - return -2; - } - if (ObjectLoc(tjdut, dgeo, datm, ObjectName, 1, helflag, &AziO, serr) == ERR) - return ERR; - if (helflag & SE_HELFLAG_VISLIM_DARK) { - AltS = -90; - AziS = 0; - } else { - if (ObjectLoc(tjdut, dgeo, datm, "sun", 0, helflag, &AltS, serr) == ERR) - return ERR; - if (ObjectLoc(tjdut, dgeo, datm, "sun", 1, helflag, &AziS, serr) == ERR) - return ERR; - } - if (strncmp(ObjectName, "moon", 4) == 0 || - (helflag & SE_HELFLAG_VISLIM_DARK) || - (helflag & SE_HELFLAG_VISLIM_NOMOON) - ) { - AltM = -90; AziM = 0; - } else { - if (ObjectLoc(tjdut, dgeo, datm, "moon", 0, helflag, &AltM, serr) == ERR) - return ERR; - if (ObjectLoc(tjdut, dgeo, datm, "moon", 1, helflag, &AziM, serr) == ERR) - return ERR; - } + int32 retval = OK, i, scotopic_flag = 0; + double AltO, AziO, AltM, AziM, AltS, AziS; + double sunra = SunRA(tjdut, helflag, serr); + default_heliacal_parameters(datm, dgeo, dobs, helflag); + swe_set_topo(dgeo[0], dgeo[1], dgeo[2]); + for (i = 0; i < 7; i++) + dret[i] = 0; + if (ObjectLoc(tjdut, dgeo, datm, ObjectName, 0, helflag, &AltO, serr) == + ERR) + return ERR; + if (AltO < 0 && serr != NULL) { + strcpy(serr, "object is below local horizon"); + *dret = -100; + return -2; + } + if (ObjectLoc(tjdut, dgeo, datm, ObjectName, 1, helflag, &AziO, serr) == + ERR) + return ERR; + if (helflag & SE_HELFLAG_VISLIM_DARK) { + AltS = -90; + AziS = 0; + } + else { + if (ObjectLoc(tjdut, dgeo, datm, "sun", 0, helflag, &AltS, serr) == + ERR) + return ERR; + if (ObjectLoc(tjdut, dgeo, datm, "sun", 1, helflag, &AziS, serr) == + ERR) + return ERR; + } + if (strncmp(ObjectName, "moon", 4) == 0 + || (helflag & SE_HELFLAG_VISLIM_DARK) + || (helflag & SE_HELFLAG_VISLIM_NOMOON) + ) { + AltM = -90; + AziM = 0; + } + else { + if (ObjectLoc(tjdut, dgeo, datm, "moon", 0, helflag, &AltM, serr) == + ERR) + return ERR; + if (ObjectLoc(tjdut, dgeo, datm, "moon", 1, helflag, &AziM, serr) == + ERR) + return ERR; + } #if DEBUG -{ - int i; - for (i = 0; i < 6;i++) - printf("dobs[%d] = %f\n", i, dobs[i]); - printf("AltO = %.10f, AziO = %.10f\n", AltO, AziO); - printf("AltM = %.10f, AziM = %.10f\n", AltM, AziM); - printf("AltS = %.10f, AziS = %.10f\n", AltS, AziS); - printf("JD = %.10f\n", tjdut); - printf("lat = %f, eyeh = %f\n", dgeo[1], dgeo[2]); - for (i = 0; i < 4;i++) - printf("datm[%d] = %f\n", i, datm[i]); - printf("helflag = %d\n", helflag); -} + { + int i; + for (i = 0; i < 6; i++) + printf("dobs[%d] = %f\n", i, dobs[i]); + printf("AltO = %.10f, AziO = %.10f\n", AltO, AziO); + printf("AltM = %.10f, AziM = %.10f\n", AltM, AziM); + printf("AltS = %.10f, AziS = %.10f\n", AltS, AziS); + printf("JD = %.10f\n", tjdut); + printf("lat = %f, eyeh = %f\n", dgeo[1], dgeo[2]); + for (i = 0; i < 4; i++) + printf("datm[%d] = %f\n", i, datm[i]); + printf("helflag = %d\n", helflag); + } #endif - dret[0] = VisLimMagn(dobs, AltO, AziO, AltM, AziM, tjdut, AltS, AziS, sunra, dgeo[1], dgeo[2], datm, helflag, &scotopic_flag, serr); - dret[1] = AltO; - dret[2] = AziO; - dret[3] = AltS; - dret[4] = AziS; - dret[5] = AltM; - dret[6] = AziM; - if (Magnitude(tjdut, dgeo, ObjectName, helflag, &(dret[7]), serr) == ERR) - return ERR; - retval = scotopic_flag; - /*dret[8] = (double) is_scotopic;*/ - /*if (*serr != '\0') * in VisLimMagn(), serr is only a warning * - retval = ERR; */ - return retval; + dret[0] = + VisLimMagn(dobs, AltO, AziO, AltM, AziM, tjdut, AltS, AziS, sunra, + dgeo[1], dgeo[2], datm, helflag, &scotopic_flag, serr); + dret[1] = AltO; + dret[2] = AziO; + dret[3] = AltS; + dret[4] = AziS; + dret[5] = AltM; + dret[6] = AziM; + if (Magnitude(tjdut, dgeo, ObjectName, helflag, &(dret[7]), serr) == ERR) + return ERR; + retval = scotopic_flag; + /*dret[8] = (double) is_scotopic; */ + /*if (*serr != '\0') * in VisLimMagn(), serr is only a warning * + * retval = ERR; */ + return retval; } /*################################################################### @@ -1516,54 +1784,74 @@ int32 FAR PASCAL_CONV swe_vis_limit_mag(double tjdut, double *dgeo, double *datm ' VR [km] ' TopoArcVisionis [deg] */ -static int32 TopoArcVisionis(double Magn, double *dobs, double AltO, double AziO, double AltM, double AziM, double JDNDaysUT, double AziS, double sunra, double Lat, double HeightEye, double *datm, int32 helflag, double *dret, char *serr) +static int32 +TopoArcVisionis(double Magn, double *dobs, double AltO, double AziO, + double AltM, double AziM, double JDNDaysUT, double AziS, + double sunra, double Lat, double HeightEye, double *datm, + int32 helflag, double *dret, char *serr) { - double Xm, Ym, AltSi, AziSi; - double xR = 0; - double Xl = 45; - double Yl, Yr; - Yl = Magn - VisLimMagn(dobs, AltO, AziO, AltM, AziM, JDNDaysUT, AltO - Xl, AziS, sunra, Lat, HeightEye, datm, helflag, NULL, serr); - /* if (*serr != '\0') return ERR; * serr is only a warning */ - Yr = Magn - VisLimMagn(dobs, AltO, AziO, AltM, AziM, JDNDaysUT, AltO - xR, AziS, sunra, Lat, HeightEye, datm, helflag, NULL, serr); - /* if (*serr != '\0') return ERR; * serr is only a warning */ - /* http://en.wikipedia.org/wiki/Bisection_method*/ - if ((Yl * Yr) <= 0) { - while(fabs(xR - Xl) > epsilon) { - /*Calculate midpoint of domain*/ - Xm = (xR + Xl) / 2.0; - AltSi = AltO - Xm; - AziSi = AziS; - Ym = Magn - VisLimMagn(dobs, AltO, AziO, AltM, AziM, JDNDaysUT, AltSi, AziSi, sunra, Lat, HeightEye, datm, helflag, NULL, serr); - /* if (*serr != '\0') return ERR; * serr is only a warning */ - if ((Yl * Ym) > 0) { - /* Throw away left half*/ - Xl = Xm; - Yl = Ym; - } else { - /* Throw away right half */ - xR = Xm; - Yr = Ym; - } + double Xm, Ym, AltSi, AziSi; + double xR = 0; + double Xl = 45; + double Yl, Yr; + Yl = Magn - VisLimMagn(dobs, AltO, AziO, AltM, AziM, JDNDaysUT, AltO - Xl, + AziS, sunra, Lat, HeightEye, datm, helflag, NULL, + serr); + /* if (*serr != '\0') return ERR; * serr is only a warning */ + Yr = Magn - VisLimMagn(dobs, AltO, AziO, AltM, AziM, JDNDaysUT, AltO - xR, + AziS, sunra, Lat, HeightEye, datm, helflag, NULL, + serr); + /* if (*serr != '\0') return ERR; * serr is only a warning */ + /* http://en.wikipedia.org/wiki/Bisection_method */ + if ((Yl * Yr) <= 0) { + while (fabs(xR - Xl) > epsilon) { + /*Calculate midpoint of domain */ + Xm = (xR + Xl) / 2.0; + AltSi = AltO - Xm; + AziSi = AziS; + Ym = Magn - VisLimMagn(dobs, AltO, AziO, AltM, AziM, JDNDaysUT, + AltSi, AziSi, sunra, Lat, HeightEye, datm, + helflag, NULL, serr); + /* if (*serr != '\0') return ERR; * serr is only a warning */ + if ((Yl * Ym) > 0) { + /* Throw away left half */ + Xl = Xm; + Yl = Ym; + } + else { + /* Throw away right half */ + xR = Xm; + Yr = Ym; + } + } + Xm = (xR + Xl) / 2.0; } - Xm = (xR + Xl) / 2.0; - } else { - Xm = 99; - } - if (Xm < AltO) - Xm = AltO; - *dret = Xm; - return OK; + else { + Xm = 99; + } + if (Xm < AltO) + Xm = AltO; + *dret = Xm; + return OK; } -int32 FAR PASCAL_CONV swe_topo_arcus_visionis(double tjdut, double *dgeo, double *datm, double *dobs, int32 helflag, double mag, double azi_obj, double alt_obj, double azi_sun, double azi_moon, double alt_moon, double *dret, char *serr) +int32 FAR PASCAL_CONV +swe_topo_arcus_visionis(double tjdut, double *dgeo, double *datm, + double *dobs, int32 helflag, double mag, + double azi_obj, double alt_obj, double azi_sun, + double azi_moon, double alt_moon, double *dret, + char *serr) { - double sunra = SunRA(tjdut, helflag, serr); - if (serr != NULL && *serr != '\0') - return ERR; - return TopoArcVisionis(mag, dobs, alt_obj, azi_obj, alt_moon, azi_moon, tjdut, azi_sun, sunra, dgeo[1], dgeo[2], datm, helflag, dret, serr); + double sunra = SunRA(tjdut, helflag, serr); + if (serr != NULL && *serr != '\0') + return ERR; + return TopoArcVisionis(mag, dobs, alt_obj, azi_obj, alt_moon, azi_moon, + tjdut, azi_sun, sunra, dgeo[1], dgeo[2], datm, + helflag, dret, serr); } /*###################################################################*/ + /*' Magn [-] ' age [Year] ' SN Snellen factor of the visual aquity of the observer @@ -1587,68 +1875,86 @@ int32 FAR PASCAL_CONV swe_topo_arcus_visionis(double tjdut, double *dgeo, double ' 2=Sun's altitude] ' HeliacalAngle [deg] */ -static int32 HeliacalAngle(double Magn, double *dobs, double AziO, double AltM, double AziM, double JDNDaysUT, double AziS, double *dgeo, double *datm, int32 helflag, double *dangret, char *serr) +static int32 +HeliacalAngle(double Magn, double *dobs, double AziO, double AltM, + double AziM, double JDNDaysUT, double AziS, double *dgeo, + double *datm, int32 helflag, double *dangret, char *serr) { - double x, minx, maxx, xmin, ymin, Xl, xR, Yr, Yl, Xm, Ym, xmd, ymd; - double Arc, DELTAx; - double sunra = SunRA(JDNDaysUT, helflag, serr); - double Lat = dgeo[1]; - double HeightEye = dgeo[2]; - if (PLSV == 1) { - dangret[0] = criticalangle; - dangret[1] = criticalangle + Magn * 2.492 + 13.447; - dangret[2] = -(Magn * 2.492 + 13.447); /* Magn * 1.1 + 8.9;*/ - return OK; - } - minx = 2; - maxx = 20; - xmin = 0; - ymin = 10000; - for (x = minx; x <= maxx; x++) { - if (TopoArcVisionis(Magn, dobs, x, AziO, AltM, AziM, JDNDaysUT, AziS, sunra, Lat, HeightEye, datm, helflag, &Arc, serr) == ERR) - return ERR; - if (Arc < ymin) { - ymin = Arc; - xmin = x; + double x, minx, maxx, xmin, ymin, Xl, xR, Yr, Yl, Xm, Ym, xmd, ymd; + double Arc, DELTAx; + double sunra = SunRA(JDNDaysUT, helflag, serr); + double Lat = dgeo[1]; + double HeightEye = dgeo[2]; + if (PLSV == 1) { + dangret[0] = criticalangle; + dangret[1] = criticalangle + Magn * 2.492 + 13.447; + dangret[2] = -(Magn * 2.492 + 13.447); /* Magn * 1.1 + 8.9; */ + return OK; + } + minx = 2; + maxx = 20; + xmin = 0; + ymin = 10000; + for (x = minx; x <= maxx; x++) { + if (TopoArcVisionis + (Magn, dobs, x, AziO, AltM, AziM, JDNDaysUT, AziS, sunra, Lat, + HeightEye, datm, helflag, &Arc, serr) == ERR) + return ERR; + if (Arc < ymin) { + ymin = Arc; + xmin = x; + } + } + Xl = xmin - 1; + xR = xmin + 1; + if (TopoArcVisionis + (Magn, dobs, xR, AziO, AltM, AziM, JDNDaysUT, AziS, sunra, Lat, + HeightEye, datm, helflag, &Yr, serr) == ERR) + return ERR; + if (TopoArcVisionis + (Magn, dobs, Xl, AziO, AltM, AziM, JDNDaysUT, AziS, sunra, Lat, + HeightEye, datm, helflag, &Yl, serr) == ERR) + return ERR; + /* http://en.wikipedia.org/wiki/Bisection_method */ + while (fabs(xR - Xl) > 0.1) { + /* Calculate midpoint of domain */ + Xm = (xR + Xl) / 2.0; + DELTAx = 0.025; + xmd = Xm + DELTAx; + if (TopoArcVisionis + (Magn, dobs, Xm, AziO, AltM, AziM, JDNDaysUT, AziS, sunra, Lat, + HeightEye, datm, helflag, &Ym, serr) == ERR) + return ERR; + if (TopoArcVisionis + (Magn, dobs, xmd, AziO, AltM, AziM, JDNDaysUT, AziS, sunra, Lat, + HeightEye, datm, helflag, &ymd, serr) == ERR) + return ERR; + if (Ym >= ymd) { + /* Throw away left half */ + Xl = Xm; + Yl = Ym; + } + else { + /*Throw away right half */ + xR = Xm; + Yr = Ym; + } } - } - Xl = xmin - 1; - xR = xmin + 1; - if (TopoArcVisionis(Magn, dobs, xR, AziO, AltM, AziM, JDNDaysUT, AziS, sunra, Lat, HeightEye, datm, helflag, &Yr, serr) == ERR) - return ERR; - if (TopoArcVisionis(Magn, dobs, Xl, AziO, AltM, AziM, JDNDaysUT, AziS, sunra, Lat, HeightEye, datm, helflag, &Yl, serr) == ERR) - return ERR; - /* http://en.wikipedia.org/wiki/Bisection_method*/ - while(fabs(xR - Xl) > 0.1) { - /* Calculate midpoint of domain */ Xm = (xR + Xl) / 2.0; - DELTAx = 0.025; - xmd = Xm + DELTAx; - if (TopoArcVisionis(Magn, dobs, Xm, AziO, AltM, AziM, JDNDaysUT, AziS, sunra, Lat, HeightEye, datm, helflag, &Ym, serr) == ERR) - return ERR; - if (TopoArcVisionis(Magn, dobs, xmd, AziO, AltM, AziM, JDNDaysUT, AziS, sunra, Lat, HeightEye, datm, helflag, &ymd, serr) == ERR) - return ERR; - if (Ym >= ymd) { - /* Throw away left half */ - Xl = Xm; - Yl = Ym; - } else { - /*Throw away right half */ - xR = Xm; - Yr = Ym; - } - } - Xm = (xR + Xl) / 2.0; - Ym = (Yr + Yl) / 2.0; - dangret[1] = Ym; - dangret[2] = Xm - Ym; - dangret[0] = Xm; - return OK; + Ym = (Yr + Yl) / 2.0; + dangret[1] = Ym; + dangret[2] = Xm - Ym; + dangret[0] = Xm; + return OK; } -int32 FAR PASCAL_CONV swe_heliacal_angle(double tjdut, double *dgeo, double *datm, double *dobs, int32 helflag, double mag, double azi_obj, double azi_sun, double azi_moon, double alt_moon, double *dret, char *serr) +int32 FAR PASCAL_CONV +swe_heliacal_angle(double tjdut, double *dgeo, double *datm, double *dobs, + int32 helflag, double mag, double azi_obj, double azi_sun, + double azi_moon, double alt_moon, double *dret, char *serr) { - return HeliacalAngle(mag, dobs, azi_obj, alt_moon, azi_moon, tjdut, azi_sun, dgeo, datm, helflag, dret, serr); + return HeliacalAngle(mag, dobs, azi_obj, alt_moon, azi_moon, tjdut, + azi_sun, dgeo, datm, helflag, dret, serr); } /*################################################################### @@ -1659,25 +1965,32 @@ int32 FAR PASCAL_CONV swe_heliacal_angle(double tjdut, double *dgeo, double *dat ' parallax [deg] ' WidthMoon [deg] */ -static double WidthMoon(double AltO, double AziO, double AltS, double AziS, double parallax) +static double +WidthMoon(double AltO, double AziO, double AltS, double AziS, double parallax) { - /* Yallop 1998, page 3*/ - double GeoAltO = AltO + parallax; - return 0.27245 * parallax * (1 + sin(GeoAltO * DEGTORAD) * sin(parallax * DEGTORAD)) * (1 - cos((AltS - GeoAltO) * DEGTORAD) * cos((AziS - AziO) * DEGTORAD)); + /* Yallop 1998, page 3 */ + double GeoAltO = AltO + parallax; + return 0.27245 * parallax * (1 + + sin(GeoAltO * DEGTORAD) * sin(parallax * + DEGTORAD)) * + (1 - + cos((AltS - GeoAltO) * DEGTORAD) * cos((AziS - AziO) * DEGTORAD)); } /*################################################################### ' W [deg] ' LengthMoon [deg] */ -static double LengthMoon(double W, double Diamoon) +static double +LengthMoon(double W, double Diamoon) { - double Wi, D; - if (Diamoon == 0) Diamoon = AvgRadiusMoon * 2; - Wi = W * 60; - D = Diamoon * 60; - /* Crescent length according: http://calendar.ut.ac.ir/Fa/Crescent/Data/Sultan2005.pdf*/ - return (D - 0.3 * (D + Wi) / 2.0 / Wi) / 60.0; + double Wi, D; + if (Diamoon == 0) + Diamoon = AvgRadiusMoon * 2; + Wi = W * 60; + D = Diamoon * 60; + /* Crescent length according: http://calendar.ut.ac.ir/Fa/Crescent/Data/Sultan2005.pdf */ + return (D - 0.3 * (D + Wi) / 2.0 / Wi) / 60.0; } /*################################################################### @@ -1685,10 +1998,13 @@ static double LengthMoon(double W, double Diamoon) ' GeoARCVact [deg] ' q [-] */ -static double qYallop(double W, double GeoARCVact) +static double +qYallop(double W, double GeoARCVact) { - double Wi = W * 60; - return (GeoARCVact - (11.8371 - 6.3226 * Wi + 0.7319 * Wi * Wi - 0.1018 * Wi * Wi * Wi)) / 10; + double Wi = W * 60; + return (GeoARCVact - + (11.8371 - 6.3226 * Wi + 0.7319 * Wi * Wi - + 0.1018 * Wi * Wi * Wi)) / 10; } /*################################################################### @@ -1697,36 +2013,47 @@ static double qYallop(double W, double GeoARCVact) 'C (0,r) 'D (1,s) */ -static double crossing(double A, double B, double C, double D) +static double +crossing(double A, double B, double C, double D) { -return (C - A) / ((B - A) - (D - C)); + return (C - A) / ((B - A) - (D - C)); } /*###################################################################*/ -static int32 DeterTAV(double *dobs, double JDNDaysUT, double *dgeo, double *datm, char *ObjectName, int32 helflag, double *dret, char *serr) +static int32 +DeterTAV(double *dobs, double JDNDaysUT, double *dgeo, double *datm, + char *ObjectName, int32 helflag, double *dret, char *serr) { - double Magn, AltO, AziS, AziO, AziM, AltM; - double sunra = SunRA(JDNDaysUT, helflag, serr); - if (Magnitude(JDNDaysUT, dgeo, ObjectName, helflag, &Magn, serr) == ERR) - return ERR; - if (ObjectLoc(JDNDaysUT, dgeo, datm, ObjectName, 0, helflag, &AltO, serr) == ERR) - return ERR; - if (ObjectLoc(JDNDaysUT, dgeo, datm, ObjectName, 1, helflag, &AziO, serr) == ERR) - return ERR; - if (strncmp(ObjectName, "moon", 4) == 0) { - AltM = -90; - AziM = 0; - } else { - if (ObjectLoc(JDNDaysUT, dgeo, datm, "moon", 0, helflag, &AltM, serr) == ERR) - return ERR; - if (ObjectLoc(JDNDaysUT, dgeo, datm, "moon", 1, helflag, &AziM, serr) == ERR) - return ERR; - } - if (ObjectLoc(JDNDaysUT, dgeo, datm, "sun", 1, helflag, &AziS, serr) == ERR) - return ERR; - if (TopoArcVisionis(Magn, dobs, AltO, AziO, AltM, AziM, JDNDaysUT, AziS, sunra, dgeo[1], dgeo[2], datm, helflag, dret, serr) == ERR) - return ERR; - return OK; + double Magn, AltO, AziS, AziO, AziM, AltM; + double sunra = SunRA(JDNDaysUT, helflag, serr); + if (Magnitude(JDNDaysUT, dgeo, ObjectName, helflag, &Magn, serr) == ERR) + return ERR; + if (ObjectLoc(JDNDaysUT, dgeo, datm, ObjectName, 0, helflag, &AltO, serr) + == ERR) + return ERR; + if (ObjectLoc(JDNDaysUT, dgeo, datm, ObjectName, 1, helflag, &AziO, serr) + == ERR) + return ERR; + if (strncmp(ObjectName, "moon", 4) == 0) { + AltM = -90; + AziM = 0; + } + else { + if (ObjectLoc(JDNDaysUT, dgeo, datm, "moon", 0, helflag, &AltM, serr) + == ERR) + return ERR; + if (ObjectLoc(JDNDaysUT, dgeo, datm, "moon", 1, helflag, &AziM, serr) + == ERR) + return ERR; + } + if (ObjectLoc(JDNDaysUT, dgeo, datm, "sun", 1, helflag, &AziS, serr) == + ERR) + return ERR; + if (TopoArcVisionis + (Magn, dobs, AltO, AziO, AltM, AziM, JDNDaysUT, AziS, sunra, dgeo[1], + dgeo[2], datm, helflag, dret, serr) == ERR) + return ERR; + return OK; } /*################################################################### @@ -1735,12 +2062,13 @@ static int32 DeterTAV(double *dobs, double JDNDaysUT, double *dgeo, double *datm ' C y-value at x=-1 ' x2min minimum for the quadratic function */ -static double x2min(double A, double B, double C) +static double +x2min(double A, double B, double C) { - double term = A + C - 2 * B; - if (term == 0) - return 0; - return -(A - C) / 2.0 / term; + double term = A + C - 2 * B; + if (term == 0) + return 0; + return -(A - C) / 2.0 / term; } @@ -1751,22 +2079,26 @@ static double x2min(double A, double B, double C) ' x ' y is y-value of quadratic function */ -static double funct2(double A, double B, double C, double x) +static double +funct2(double A, double B, double C, double x) { - return (A + C - 2 * B) / 2.0 * x * x + (A - C) / 2.0 * x + B; + return (A + C - 2 * B) / 2.0 * x * x + (A - C) / 2.0 * x + B; } -static void strcpy_VBsafe(char *sout, char *sin) -{ - char *sp, *sp2; - int iw = 0; - sp = sin; - sp2 = sout; - while((isalnum(*sp) || *sp == ' ' || *sp == '-') && iw < 30) { - *sp2 = *sp; - sp++; sp2++; iw++; - } - *sp2 = '\0'; +static void +strcpy_VBsafe(char *sout, char *sin) +{ + char *sp, *sp2; + int iw = 0; + sp = sin; + sp2 = sout; + while ((isalnum(*sp) || *sp == ' ' || *sp == '-') && iw < 30) { + *sp2 = *sp; + sp++; + sp2++; + iw++; + } + *sp2 = '\0'; } /*################################################################### @@ -1803,695 +2135,899 @@ static void strcpy_VBsafe(char *sout, char *sin) '28=CVAact [deg] 'new '29=MSk [-] */ -int32 FAR PASCAL_CONV swe_heliacal_pheno_ut(double JDNDaysUT, double *dgeo, double *datm, double *dobs, char *ObjectNameIn, int32 TypeEvent, int32 helflag, double *darr, char *serr) +int32 FAR PASCAL_CONV +swe_heliacal_pheno_ut(double JDNDaysUT, double *dgeo, double *datm, + double *dobs, char *ObjectNameIn, int32 TypeEvent, + int32 helflag, double *darr, char *serr) { - double AziS, AltS, AltS2, AziO, AltO, AltO2, GeoAltO, AppAltO, DAZact, TAVact, ParO, MagnO; - double ARCVact, ARCLact, kact, WMoon, LMoon = 0, qYal, qCrit; - double RiseSetO, RiseSetS, Lag, TbYallop, TfirstVR, TlastVR, TbVR; - double MinTAV = 0, MinTAVact, Ta, Tc, TimeStep, TimePointer, MinTAVoud = 0, DeltaAltoud = 0, DeltaAlt, TvisVR, crosspoint; - double OldestMinTAV, extrax, illum; - double elong, attr[30]; - double TimeCheck, LocalminCheck; - int32 retval = OK, RS, Planet; - AS_BOOL noriseO = FALSE; - char ObjectName[AS_MAXCH]; - double sunra = SunRA(JDNDaysUT, helflag, serr); - int32 iflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - /* note, the fixed stars functions rewrite the star name. The input string - may be too short, so we have to make sure we have enough space */ - strcpy_VBsafe(ObjectName, ObjectNameIn); - default_heliacal_parameters(datm, dgeo, dobs, helflag); - swe_set_topo(dgeo[0], dgeo[1], dgeo[2]); - retval = ObjectLoc(JDNDaysUT, dgeo, datm, "sun", 1, helflag, &AziS, serr); - if (retval == OK) - retval = ObjectLoc(JDNDaysUT, dgeo, datm, "sun", 0, helflag, &AltS, serr); - if (retval == OK) - retval = ObjectLoc(JDNDaysUT, dgeo, datm, ObjectName, 1, helflag, &AziO, serr); - if (retval == OK) - retval = ObjectLoc(JDNDaysUT, dgeo, datm, ObjectName, 0, helflag, &AltO, serr); - if (retval == OK) - retval = ObjectLoc(JDNDaysUT, dgeo, datm, ObjectName, 7, helflag, &GeoAltO, serr); - if (retval == ERR) - return ERR; - AppAltO = AppAltfromTopoAlt(AltO, datm[1], datm[0], helflag); - DAZact = AziS - AziO; - TAVact = AltO - AltS; - /*this parallax seems to be somewhat smaller then in Yallop and SkyMap! Needs to be studied*/ - ParO = GeoAltO - AltO; - if (Magnitude(JDNDaysUT, dgeo, ObjectName, helflag, &MagnO, serr) == ERR) - return ERR; - ARCVact = TAVact + ParO; - ARCLact = acos(cos(ARCVact * DEGTORAD) * cos(DAZact * DEGTORAD)) / DEGTORAD; - Planet = DeterObject(ObjectName); - if (Planet == -1) { - elong = ARCLact; - illum = 100; - } else { - retval = swe_pheno_ut(JDNDaysUT, Planet, iflag|(SEFLG_TOPOCTR|SEFLG_EQUATORIAL), attr, serr); - if (retval == ERR) return ERR; - elong = attr[2]; - illum = attr[1] * 100; - } - kact = kt(AltS, sunra, dgeo[1], dgeo[2], datm[1], datm[2], datm[3], 4, serr); - if (0) { -darr[26] = kR(AltS, dgeo[2]); -darr[27] = kW(dgeo[2], datm[1], datm[2]); -darr[28] = kOZ(AltS, sunra, dgeo[1]); -darr[29] = ka(AltS, sunra, dgeo[1], dgeo[2], datm[1], datm[2], datm[3], serr); -darr[30] = darr[26] + darr[27] + darr[28] + darr[29]; - } - WMoon = 0; - qYal = 0; - qCrit = 0; - LMoon = 0; - if (Planet == SE_MOON) { - WMoon = WidthMoon(AltO, AziO, AltS, AziS, ParO); - LMoon = LengthMoon(WMoon, 0); - qYal = qYallop(WMoon, ARCVact); - if (qYal > 0.216) qCrit = 1; /* A */ - if (qYal < 0.216 && qYal > -0.014) qCrit = 2; /* B */ - if (qYal < -0.014 && qYal > -0.16) qCrit = 3; /* C */ - if (qYal < -0.16 && qYal > -0.232) qCrit = 4; /* D */ - if (qYal < -0.232 && qYal > -0.293) qCrit = 5; /* E */ - if (qYal < -0.293) qCrit = 6; /* F */ - } - /*determine if rise or set event*/ - RS = 2; - if (TypeEvent == 1 || TypeEvent == 4) RS = 1; - retval = RiseSet(JDNDaysUT - 4.0 / 24.0, dgeo, datm, "sun", RS, helflag, 0, &RiseSetS, serr); - if (retval == ERR) - return ERR; - retval = RiseSet(JDNDaysUT - 4.0 / 24.0, dgeo, datm, ObjectName, RS, helflag, 0, &RiseSetO, serr); - if (retval == ERR) - return ERR; - TbYallop = TJD_INVALID; - if (retval == -2) { /* object does not rise or set */ - Lag = 0; - noriseO = TRUE; - } else { - Lag = RiseSetO - RiseSetS; - if (Planet == SE_MOON) - TbYallop = (RiseSetO * 4 + RiseSetS * 5) / 9.0; - } - if ((TypeEvent == 3 || TypeEvent == 4) && (Planet == -1 || Planet >= SE_MARS)) { - TfirstVR = TJD_INVALID; - TbVR = TJD_INVALID; - TlastVR = TJD_INVALID; - TvisVR = 0; - MinTAV = 0; - goto output_heliacal_pheno; - } - /* If HPheno >= 11 And HPheno <= 14 Or HPheno = 24 Then*/ - /*te bepalen m.b.v. walkthrough*/ + double AziS, AltS, AltS2, AziO, AltO, AltO2, GeoAltO, AppAltO, DAZact, + TAVact, ParO, MagnO; + double ARCVact, ARCLact, kact, WMoon, LMoon = 0, qYal, qCrit; + double RiseSetO, RiseSetS, Lag, TbYallop, TfirstVR, TlastVR, TbVR; + double MinTAV = 0, MinTAVact, Ta, Tc, TimeStep, TimePointer, MinTAVoud = + 0, DeltaAltoud = 0, DeltaAlt, TvisVR, crosspoint; + double OldestMinTAV, extrax, illum; + double elong, attr[30]; + double TimeCheck, LocalminCheck; + int32 retval = OK, RS, Planet; + AS_BOOL noriseO = FALSE; + char ObjectName[AS_MAXCH]; + double sunra = SunRA(JDNDaysUT, helflag, serr); + int32 iflag = helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + /* note, the fixed stars functions rewrite the star name. The input string + * may be too short, so we have to make sure we have enough space */ + strcpy_VBsafe(ObjectName, ObjectNameIn); + default_heliacal_parameters(datm, dgeo, dobs, helflag); + swe_set_topo(dgeo[0], dgeo[1], dgeo[2]); + retval = ObjectLoc(JDNDaysUT, dgeo, datm, "sun", 1, helflag, &AziS, serr); + if (retval == OK) + retval = + ObjectLoc(JDNDaysUT, dgeo, datm, "sun", 0, helflag, &AltS, serr); + if (retval == OK) + retval = + ObjectLoc(JDNDaysUT, dgeo, datm, ObjectName, 1, helflag, &AziO, + serr); + if (retval == OK) + retval = + ObjectLoc(JDNDaysUT, dgeo, datm, ObjectName, 0, helflag, &AltO, + serr); + if (retval == OK) + retval = + ObjectLoc(JDNDaysUT, dgeo, datm, ObjectName, 7, helflag, &GeoAltO, + serr); + if (retval == ERR) + return ERR; + AppAltO = AppAltfromTopoAlt(AltO, datm[1], datm[0], helflag); + DAZact = AziS - AziO; + TAVact = AltO - AltS; + /*this parallax seems to be somewhat smaller then in Yallop and SkyMap! Needs to be studied */ + ParO = GeoAltO - AltO; + if (Magnitude(JDNDaysUT, dgeo, ObjectName, helflag, &MagnO, serr) == ERR) + return ERR; + ARCVact = TAVact + ParO; + ARCLact = + acos(cos(ARCVact * DEGTORAD) * cos(DAZact * DEGTORAD)) / DEGTORAD; + Planet = DeterObject(ObjectName); + if (Planet == -1) { + elong = ARCLact; + illum = 100; + } + else { + retval = + swe_pheno_ut(JDNDaysUT, Planet, + iflag | (SEFLG_TOPOCTR | SEFLG_EQUATORIAL), attr, + serr); + if (retval == ERR) + return ERR; + elong = attr[2]; + illum = attr[1] * 100; + } + kact = + kt(AltS, sunra, dgeo[1], dgeo[2], datm[1], datm[2], datm[3], 4, serr); + if (0) { + darr[26] = kR(AltS, dgeo[2]); + darr[27] = kW(dgeo[2], datm[1], datm[2]); + darr[28] = kOZ(AltS, sunra, dgeo[1]); + darr[29] = + ka(AltS, sunra, dgeo[1], dgeo[2], datm[1], datm[2], datm[3], + serr); + darr[30] = darr[26] + darr[27] + darr[28] + darr[29]; + } + WMoon = 0; + qYal = 0; + qCrit = 0; + LMoon = 0; + if (Planet == SE_MOON) { + WMoon = WidthMoon(AltO, AziO, AltS, AziS, ParO); + LMoon = LengthMoon(WMoon, 0); + qYal = qYallop(WMoon, ARCVact); + if (qYal > 0.216) + qCrit = 1; /* A */ + if (qYal < 0.216 && qYal > -0.014) + qCrit = 2; /* B */ + if (qYal < -0.014 && qYal > -0.16) + qCrit = 3; /* C */ + if (qYal < -0.16 && qYal > -0.232) + qCrit = 4; /* D */ + if (qYal < -0.232 && qYal > -0.293) + qCrit = 5; /* E */ + if (qYal < -0.293) + qCrit = 6; /* F */ + } + /*determine if rise or set event */ + RS = 2; + if (TypeEvent == 1 || TypeEvent == 4) + RS = 1; + retval = + RiseSet(JDNDaysUT - 4.0 / 24.0, dgeo, datm, "sun", RS, helflag, 0, + &RiseSetS, serr); + if (retval == ERR) + return ERR; + retval = + RiseSet(JDNDaysUT - 4.0 / 24.0, dgeo, datm, ObjectName, RS, helflag, + 0, &RiseSetO, serr); + if (retval == ERR) + return ERR; + TbYallop = TJD_INVALID; + if (retval == -2) { /* object does not rise or set */ + Lag = 0; + noriseO = TRUE; + } + else { + Lag = RiseSetO - RiseSetS; + if (Planet == SE_MOON) + TbYallop = (RiseSetO * 4 + RiseSetS * 5) / 9.0; + } + if ((TypeEvent == 3 || TypeEvent == 4) + && (Planet == -1 || Planet >= SE_MARS)) { + TfirstVR = TJD_INVALID; + TbVR = TJD_INVALID; + TlastVR = TJD_INVALID; + TvisVR = 0; + MinTAV = 0; + goto output_heliacal_pheno; + } + /* If HPheno >= 11 And HPheno <= 14 Or HPheno = 24 Then */ + /*te bepalen m.b.v. walkthrough */ MinTAVact = 199; - DeltaAlt = 0; + DeltaAlt = 0; OldestMinTAV = 0; Ta = 0; Tc = 0; TbVR = 0; TimeStep = -TimeStepDefault / 24.0 / 60.0; - if (RS == 2) TimeStep = -TimeStep; + if (RS == 2) + TimeStep = -TimeStep; TimePointer = RiseSetS - TimeStep; do { - TimePointer = TimePointer + TimeStep; - OldestMinTAV = MinTAVoud; - MinTAVoud = MinTAVact; - DeltaAltoud = DeltaAlt; - retval = ObjectLoc(TimePointer, dgeo, datm, "sun", 0, helflag, &AltS2, serr); - if (retval == OK) - retval = ObjectLoc(TimePointer, dgeo, datm, ObjectName, 0, helflag, &AltO2, serr); - if (retval != OK) - return ERR; - DeltaAlt = AltO2 - AltS2; - if (DeterTAV(dobs, TimePointer, dgeo, datm, ObjectName, helflag, &MinTAVact, serr) == ERR) - return ERR; - if (MinTAVoud < MinTAVact && TbVR == 0) { - /* determine if this is a local minimum with object still above horizon*/ - TimeCheck = TimePointer + Sgn(TimeStep) * LocalMinStep / 24.0 / 60.0; - if (RiseSetO != 0) { - if (TimeStep > 0) - TimeCheck = mymin(TimeCheck, RiseSetO); - else - TimeCheck = mymax(TimeCheck, RiseSetO); - } - if (DeterTAV(dobs, TimeCheck, dgeo, datm, ObjectName, helflag, &LocalminCheck, serr) == ERR) - return ERR; - if (LocalminCheck > MinTAVact) { - extrax = x2min(MinTAVact, MinTAVoud, OldestMinTAV); - TbVR = TimePointer - (1 - extrax) * TimeStep; - MinTAV = funct2(MinTAVact, MinTAVoud, OldestMinTAV, extrax); - } - } - if (DeltaAlt > MinTAVact && Tc == 0 && TbVR == 0) { - crosspoint = crossing(DeltaAltoud, DeltaAlt, MinTAVoud, MinTAVact); - Tc = TimePointer - TimeStep * (1 - crosspoint); - } - if (DeltaAlt < MinTAVact && Ta == 0 && Tc != 0) { - crosspoint = crossing(DeltaAltoud, DeltaAlt, MinTAVoud, MinTAVact); - Ta = TimePointer - TimeStep * (1 - crosspoint); - } - } while (fabs(TimePointer - RiseSetS) <= MaxTryHours / 24.0 && Ta == 0 && !((TbVR != 0 && (TypeEvent == 3 || TypeEvent == 4) && (strncmp(ObjectName, "moon", 4) != 0 && strncmp(ObjectName, "venus", 5) != 0 && strncmp(ObjectName, "mercury", 7) != 0)))); + TimePointer = TimePointer + TimeStep; + OldestMinTAV = MinTAVoud; + MinTAVoud = MinTAVact; + DeltaAltoud = DeltaAlt; + retval = + ObjectLoc(TimePointer, dgeo, datm, "sun", 0, helflag, &AltS2, + serr); + if (retval == OK) + retval = + ObjectLoc(TimePointer, dgeo, datm, ObjectName, 0, helflag, + &AltO2, serr); + if (retval != OK) + return ERR; + DeltaAlt = AltO2 - AltS2; + if (DeterTAV + (dobs, TimePointer, dgeo, datm, ObjectName, helflag, &MinTAVact, + serr) == ERR) + return ERR; + if (MinTAVoud < MinTAVact && TbVR == 0) { + /* determine if this is a local minimum with object still above horizon */ + TimeCheck = + TimePointer + Sgn(TimeStep) * LocalMinStep / 24.0 / 60.0; + if (RiseSetO != 0) { + if (TimeStep > 0) + TimeCheck = mymin(TimeCheck, RiseSetO); + else + TimeCheck = mymax(TimeCheck, RiseSetO); + } + if (DeterTAV + (dobs, TimeCheck, dgeo, datm, ObjectName, helflag, + &LocalminCheck, serr) == ERR) + return ERR; + if (LocalminCheck > MinTAVact) { + extrax = x2min(MinTAVact, MinTAVoud, OldestMinTAV); + TbVR = TimePointer - (1 - extrax) * TimeStep; + MinTAV = funct2(MinTAVact, MinTAVoud, OldestMinTAV, extrax); + } + } + if (DeltaAlt > MinTAVact && Tc == 0 && TbVR == 0) { + crosspoint = + crossing(DeltaAltoud, DeltaAlt, MinTAVoud, MinTAVact); + Tc = TimePointer - TimeStep * (1 - crosspoint); + } + if (DeltaAlt < MinTAVact && Ta == 0 && Tc != 0) { + crosspoint = + crossing(DeltaAltoud, DeltaAlt, MinTAVoud, MinTAVact); + Ta = TimePointer - TimeStep * (1 - crosspoint); + } + } while (fabs(TimePointer - RiseSetS) <= MaxTryHours / 24.0 && Ta == 0 + && !((TbVR != 0 && (TypeEvent == 3 || TypeEvent == 4) + && (strncmp(ObjectName, "moon", 4) != 0 + && strncmp(ObjectName, "venus", 5) != 0 + && strncmp(ObjectName, "mercury", 7) != 0)))); if (RS == 2) { - TfirstVR = Tc; - TlastVR = Ta; - } else { - TfirstVR = Ta; - TlastVR = Tc; + TfirstVR = Tc; + TlastVR = Ta; + } + else { + TfirstVR = Ta; + TlastVR = Tc; } if (TfirstVR == 0 && TlastVR == 0) { - if (RS == 1) - TfirstVR = TbVR - 0.000001; - else - TlastVR = TbVR + 0.000001; + if (RS == 1) + TfirstVR = TbVR - 0.000001; + else + TlastVR = TbVR + 0.000001; } if (!noriseO) { - if (RS == 1) - TfirstVR = mymax(TfirstVR, RiseSetO); - else - TlastVR = mymin(TlastVR, RiseSetO); + if (RS == 1) + TfirstVR = mymax(TfirstVR, RiseSetO); + else + TlastVR = mymin(TlastVR, RiseSetO); } - TvisVR = TJD_INVALID; /*"#NA!" */ + TvisVR = TJD_INVALID; /*"#NA!" */ if (TlastVR != 0 && TfirstVR != 0) - TvisVR = TlastVR - TfirstVR; - if (TlastVR == 0) TlastVR = TJD_INVALID; /*"#NA!" */ - if (TbVR == 0) TbVR = TJD_INVALID; /*"#NA!" */ - if (TfirstVR == 0) TfirstVR = TJD_INVALID; /*"#NA!" */ + TvisVR = TlastVR - TfirstVR; + if (TlastVR == 0) + TlastVR = TJD_INVALID; /*"#NA!" */ + if (TbVR == 0) + TbVR = TJD_INVALID; /*"#NA!" */ + if (TfirstVR == 0) + TfirstVR = TJD_INVALID; /*"#NA!" */ output_heliacal_pheno: - /*End If*/ - darr[0] = AltO; - darr[1] = AppAltO; - darr[2] = GeoAltO; - darr[3] = AziO; - darr[4] = AltS; - darr[5] = AziS; - darr[6] = TAVact; - darr[7] = ARCVact; - darr[8] = DAZact; - darr[9] = ARCLact; - darr[10] = kact; - darr[11] = MinTAV; - darr[12] = TfirstVR; - darr[13] = TbVR; - darr[14] = TlastVR; - darr[15] = TbYallop; - darr[16] = WMoon; - darr[17] = qYal; - darr[18] = qCrit; - darr[19] = ParO; - darr[20] = MagnO; - darr[21] = RiseSetO; - darr[22] = RiseSetS; - darr[23] = Lag; - darr[24] = TvisVR; - darr[25] = LMoon; - darr[26] = elong; - darr[27] = illum; - return OK; + /*End If */ + darr[0] = AltO; + darr[1] = AppAltO; + darr[2] = GeoAltO; + darr[3] = AziO; + darr[4] = AltS; + darr[5] = AziS; + darr[6] = TAVact; + darr[7] = ARCVact; + darr[8] = DAZact; + darr[9] = ARCLact; + darr[10] = kact; + darr[11] = MinTAV; + darr[12] = TfirstVR; + darr[13] = TbVR; + darr[14] = TlastVR; + darr[15] = TbYallop; + darr[16] = WMoon; + darr[17] = qYal; + darr[18] = qCrit; + darr[19] = ParO; + darr[20] = MagnO; + darr[21] = RiseSetO; + darr[22] = RiseSetS; + darr[23] = Lag; + darr[24] = TvisVR; + darr[25] = LMoon; + darr[26] = elong; + darr[27] = illum; + return OK; } #if 0 -int32 FAR PASCAL_CONV HeliacalJDut(double JDNDaysUTStart, double Age, double SN, double Lat, double Longitude, double HeightEye, double Temperature, double Pressure, double RH, double VR, char *ObjectName, int TypeEvent, char *AVkind, double *dret, char *serr) +int32 FAR PASCAL_CONV +HeliacalJDut(double JDNDaysUTStart, double Age, double SN, double Lat, + double Longitude, double HeightEye, double Temperature, + double Pressure, double RH, double VR, char *ObjectName, + int TypeEvent, char *AVkind, double *dret, char *serr) { - double dgeo[3], datm[4], dobs[6]; - int32 helflag = SE_HELFLAG_HIGH_PRECISION; - helflag |= SE_HELFLAG_AVKIND_VR; - dgeo[0] = Longitude; - dgeo[1] = Lat; - dgeo[2] = HeightEye; - datm[0] = Pressure; - datm[1] = Temperature; - datm[2] = RH; - datm[3] = VR; - dobs[0] = Age; - dobs[1] = SN; - return swe_heliacal_ut(JDNDaysUTStart, dgeo, datm, dobs, ObjectName, TypeEvent, helflag, dret, serr); + double dgeo[3], datm[4], dobs[6]; + int32 helflag = SE_HELFLAG_HIGH_PRECISION; + helflag |= SE_HELFLAG_AVKIND_VR; + dgeo[0] = Longitude; + dgeo[1] = Lat; + dgeo[2] = HeightEye; + datm[0] = Pressure; + datm[1] = Temperature; + datm[2] = RH; + datm[3] = VR; + dobs[0] = Age; + dobs[1] = SN; + return swe_heliacal_ut(JDNDaysUTStart, dgeo, datm, dobs, ObjectName, + TypeEvent, helflag, dret, serr); } #endif -static double get_synodic_period(int Planet) +static double +get_synodic_period(int Planet) { - /* synodic periods from: - * Kelley/Milone/Aveni, "Exploring ancient Skies", p. 43. */ - switch(Planet) { - case SE_MOON: return 29.530588853; - case SE_MERCURY: return 115.8775; - case SE_VENUS: return 583.9214; - case SE_MARS: return 779.9361; - case SE_JUPITER: return 398.8840; - case SE_SATURN: return 378.0919; - case SE_URANUS: return 369.6560; - case SE_NEPTUNE: return 367.4867; - case SE_PLUTO: return 366.7207; - } - return 366; /* for stars and default for far away planets */ + /* synodic periods from: + * Kelley/Milone/Aveni, "Exploring ancient Skies", p. 43. */ + switch (Planet) { + case SE_MOON: + return 29.530588853; + case SE_MERCURY: + return 115.8775; + case SE_VENUS: + return 583.9214; + case SE_MARS: + return 779.9361; + case SE_JUPITER: + return 398.8840; + case SE_SATURN: + return 378.0919; + case SE_URANUS: + return 369.6560; + case SE_NEPTUNE: + return 367.4867; + case SE_PLUTO: + return 366.7207; + } + return 366; /* for stars and default for far away planets */ } /*###################################################################*/ -static int32 moon_event_arc_vis(double JDNDaysUTStart, double *dgeo, double *datm, double *dobs, int32 TypeEvent, int32 helflag, double *dret, char *serr) +static int32 +moon_event_arc_vis(double JDNDaysUTStart, double *dgeo, double *datm, + double *dobs, int32 TypeEvent, int32 helflag, double *dret, + char *serr) { - double x[20], MinTAV, MinTAVoud, OldestMinTAV; - double phase1, phase2, JDNDaysUT, JDNDaysUTi; - double tjd_moonevent, tjd_moonevent_start; - double DeltaAltoud, TimeCheck, LocalminCheck; - double AltS, AltO, DeltaAlt = 90; - char ObjectName[30]; - int32 iflag, Daystep, goingup, Planet, retval; - int32 avkind = helflag & SE_HELFLAG_AVKIND; - int32 epheflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - dret[0] = JDNDaysUTStart; /* will be returned in error case */ - if (avkind == 0) - avkind = SE_HELFLAG_AVKIND_VR; - if (avkind != SE_HELFLAG_AVKIND_VR) { - if (serr != NULL) - strcpy(serr, "error: in valid AV kind for the moon"); - return ERR; - } - if (TypeEvent == 1 || TypeEvent == 2) { - if (serr != NULL) - strcpy(serr, "error: the moon has no morning first or evening last"); - return ERR; - } - strcpy(ObjectName, "moon"); - Planet = SE_MOON; - iflag = SEFLG_TOPOCTR | SEFLG_EQUATORIAL | epheflag; - if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) - iflag |= SEFLG_NONUT|SEFLG_TRUEPOS; - Daystep = 1; - if (TypeEvent == 3) { - /*morning last */ - TypeEvent = 2; - } else { - /*evening first*/ - TypeEvent = 1; - Daystep = -Daystep; - } - /* check Synodic/phase Period */ - JDNDaysUT = JDNDaysUTStart; - /* start 30 days later if TypeEvent=4 (1) */ - if (TypeEvent == 1) JDNDaysUT = JDNDaysUT + 30; - /* determination of new moon date */ - swe_pheno_ut(JDNDaysUT, Planet, iflag, x, serr); - phase2 = x[0]; - goingup = 0; - do { - JDNDaysUT = JDNDaysUT + Daystep; - phase1 = phase2; + double x[20], MinTAV, MinTAVoud, OldestMinTAV; + double phase1, phase2, JDNDaysUT, JDNDaysUTi; + double tjd_moonevent, tjd_moonevent_start; + double DeltaAltoud, TimeCheck, LocalminCheck; + double AltS, AltO, DeltaAlt = 90; + char ObjectName[30]; + int32 iflag, Daystep, goingup, Planet, retval; + int32 avkind = helflag & SE_HELFLAG_AVKIND; + int32 epheflag = helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + dret[0] = JDNDaysUTStart; /* will be returned in error case */ + if (avkind == 0) + avkind = SE_HELFLAG_AVKIND_VR; + if (avkind != SE_HELFLAG_AVKIND_VR) { + if (serr != NULL) + strcpy(serr, "error: in valid AV kind for the moon"); + return ERR; + } + if (TypeEvent == 1 || TypeEvent == 2) { + if (serr != NULL) + strcpy(serr, + "error: the moon has no morning first or evening last"); + return ERR; + } + strcpy(ObjectName, "moon"); + Planet = SE_MOON; + iflag = SEFLG_TOPOCTR | SEFLG_EQUATORIAL | epheflag; + if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) + iflag |= SEFLG_NONUT | SEFLG_TRUEPOS; + Daystep = 1; + if (TypeEvent == 3) { + /*morning last */ + TypeEvent = 2; + } + else { + /*evening first */ + TypeEvent = 1; + Daystep = -Daystep; + } + /* check Synodic/phase Period */ + JDNDaysUT = JDNDaysUTStart; + /* start 30 days later if TypeEvent=4 (1) */ + if (TypeEvent == 1) + JDNDaysUT = JDNDaysUT + 30; + /* determination of new moon date */ swe_pheno_ut(JDNDaysUT, Planet, iflag, x, serr); phase2 = x[0]; - if (phase2 > phase1) - goingup = 1; - } while (goingup == 0 || (goingup == 1 && (phase2 > phase1))); - /* fix the date to get the day with the smallest phase (nwest moon) */ - JDNDaysUT = JDNDaysUT - Daystep; - /* initialize the date to look for set */ - JDNDaysUTi = JDNDaysUT; - JDNDaysUT = JDNDaysUT - Daystep; - MinTAVoud = 199; - do { - JDNDaysUT = JDNDaysUT + Daystep; - if ((retval = RiseSet(JDNDaysUT, dgeo, datm, ObjectName, TypeEvent, helflag, 0, &tjd_moonevent, serr)) != OK) - return retval; - tjd_moonevent_start = tjd_moonevent; - MinTAV = 199; - OldestMinTAV = MinTAV; + goingup = 0; do { - OldestMinTAV = MinTAVoud; - MinTAVoud = MinTAV; - DeltaAltoud = DeltaAlt; - tjd_moonevent = tjd_moonevent - 1.0 / 60.0 / 24.0 * Sgn(Daystep); - if (ObjectLoc(tjd_moonevent, dgeo, datm, "sun", 0, helflag, &AltS, serr) == ERR) - return ERR; - if (ObjectLoc(tjd_moonevent, dgeo, datm, ObjectName, 0, helflag, &AltO, serr) == ERR) - return ERR; - DeltaAlt = AltO - AltS; - if (DeterTAV(dobs, tjd_moonevent, dgeo, datm, ObjectName, helflag, &MinTAV, serr) == ERR) - return ERR; - TimeCheck = tjd_moonevent - LocalMinStep / 60.0 / 24.0 * Sgn(Daystep); - if (DeterTAV(dobs, TimeCheck, dgeo, datm, ObjectName, helflag, &LocalminCheck, serr) == ERR) - return ERR; + JDNDaysUT = JDNDaysUT + Daystep; + phase1 = phase2; + swe_pheno_ut(JDNDaysUT, Planet, iflag, x, serr); + phase2 = x[0]; + if (phase2 > phase1) + goingup = 1; + } while (goingup == 0 || (goingup == 1 && (phase2 > phase1))); + /* fix the date to get the day with the smallest phase (nwest moon) */ + JDNDaysUT = JDNDaysUT - Daystep; + /* initialize the date to look for set */ + JDNDaysUTi = JDNDaysUT; + JDNDaysUT = JDNDaysUT - Daystep; + MinTAVoud = 199; + do { + JDNDaysUT = JDNDaysUT + Daystep; + if ((retval = + RiseSet(JDNDaysUT, dgeo, datm, ObjectName, TypeEvent, helflag, 0, + &tjd_moonevent, serr)) != OK) + return retval; + tjd_moonevent_start = tjd_moonevent; + MinTAV = 199; + OldestMinTAV = MinTAV; + do { + OldestMinTAV = MinTAVoud; + MinTAVoud = MinTAV; + DeltaAltoud = DeltaAlt; + tjd_moonevent = tjd_moonevent - 1.0 / 60.0 / 24.0 * Sgn(Daystep); + if (ObjectLoc + (tjd_moonevent, dgeo, datm, "sun", 0, helflag, &AltS, + serr) == ERR) + return ERR; + if (ObjectLoc + (tjd_moonevent, dgeo, datm, ObjectName, 0, helflag, &AltO, + serr) == ERR) + return ERR; + DeltaAlt = AltO - AltS; + if (DeterTAV + (dobs, tjd_moonevent, dgeo, datm, ObjectName, helflag, + &MinTAV, serr) == ERR) + return ERR; + TimeCheck = + tjd_moonevent - LocalMinStep / 60.0 / 24.0 * Sgn(Daystep); + if (DeterTAV + (dobs, TimeCheck, dgeo, datm, ObjectName, helflag, + &LocalminCheck, serr) == ERR) + return ERR; + /*printf("%f, %f <= %f\n", tjd_moonevent, MinTAV, MinTAVoud);*/ - /* while (MinTAV <= MinTAVoud && fabs(tjd_moonevent - tjd_moonevent_start) < 120.0 / 60.0 / 24.0);*/ - } while ((MinTAV <= MinTAVoud || LocalminCheck < MinTAV) && fabs(tjd_moonevent - tjd_moonevent_start) < 120.0 / 60.0 / 24.0); - /* while (DeltaAlt < MinTAVoud && fabs(JDNDaysUT - JDNDaysUTi) < 15);*/ - } while (DeltaAltoud < MinTAVoud && fabs(JDNDaysUT - JDNDaysUTi) < 15); - if (fabs(JDNDaysUT - JDNDaysUTi) < 15) { - tjd_moonevent += (1 - x2min(MinTAV, MinTAVoud, OldestMinTAV)) * Sgn(Daystep) / 60.0 / 24.0; - } else { - strcpy(serr, "no date found for lunar event"); - return ERR; - } - dret[0] = tjd_moonevent; - return OK; + /* while (MinTAV <= MinTAVoud && fabs(tjd_moonevent - tjd_moonevent_start) < 120.0 / 60.0 / 24.0); */ + } while ((MinTAV <= MinTAVoud || LocalminCheck < MinTAV) + && fabs(tjd_moonevent - tjd_moonevent_start) < + 120.0 / 60.0 / 24.0); + /* while (DeltaAlt < MinTAVoud && fabs(JDNDaysUT - JDNDaysUTi) < 15); */ + } while (DeltaAltoud < MinTAVoud && fabs(JDNDaysUT - JDNDaysUTi) < 15); + if (fabs(JDNDaysUT - JDNDaysUTi) < 15) { + tjd_moonevent += + (1 - + x2min(MinTAV, MinTAVoud, + OldestMinTAV)) * Sgn(Daystep) / 60.0 / 24.0; + } + else { + strcpy(serr, "no date found for lunar event"); + return ERR; + } + dret[0] = tjd_moonevent; + return OK; } -static int32 heliacal_ut_arc_vis(double JDNDaysUTStart, double *dgeo, double *datm, double *dobs, char *ObjectName, int32 TypeEventIn, int32 helflag, double *dret, char *serr_ret) +static int32 +heliacal_ut_arc_vis(double JDNDaysUTStart, double *dgeo, double *datm, double *dobs, char *ObjectName, int32 TypeEventIn, int32 helflag, double *dret, char *serr_ret) { - double x[6]; - double xin[2]; - double xaz[2]; - double dang[3]; - double objectmagn = 0, maxlength, DayStep; - double JDNDaysUT, JDNDaysUTfinal, JDNDaysUTstep, JDNDaysUTstepoud, JDNarcvisUT, tjd_tt, tret, OudeDatum, JDNDaysUTinp = JDNDaysUTStart, JDNDaysUTtijd; - double ArcusVis, ArcusVisDelta, ArcusVisPto, ArcusVisDeltaoud; - double Trise, sunsangle, Theliacal, Tdelta, Angle; - double TimeStep, TimePointer, OldestMinTAV, MinTAVoud, MinTAVact, extrax, TbVR = 0; - double AziS, AltS, AziO, AltO, DeltaAlt; - double direct, Pressure, Temperature, d; - int32 epheflag, retval = OK; - int32 iflag, Planet, eventtype; - int32 TypeEvent = TypeEventIn; - int doneoneday; - char serr[AS_MAXCH]; - *dret = JDNDaysUTStart; - *serr = '\0'; - Planet = DeterObject(ObjectName); - Pressure = datm[0]; - Temperature = datm[1]; - /* determine Magnitude of star*/ - if ((retval = Magnitude(JDNDaysUTStart, dgeo, ObjectName, helflag, &objectmagn, serr)) == ERR) - goto swe_heliacal_err; - epheflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - iflag = SEFLG_TOPOCTR | SEFLG_EQUATORIAL | epheflag; - if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) - iflag |= SEFLG_NONUT | SEFLG_TRUEPOS; - /* start values for search of heliacal rise - * maxlength = phase period in days, smaller than minimal synodic period */ - /* days per step (for heliacal rise) in power of two */ - switch(Planet) { - case SE_MERCURY: - DayStep = 1; maxlength = 100; break; - case SE_VENUS: - DayStep = 64; maxlength = 384; break; - case SE_MARS: - DayStep = 128; maxlength = 640; break; - case SE_JUPITER: - DayStep = 64; maxlength = 384; break; - case SE_SATURN: - DayStep = 64; maxlength = 256; break; - default: - DayStep = 64; maxlength = 256; break; - } - /* heliacal setting */ - eventtype = TypeEvent; - if (eventtype == 2) DayStep = -DayStep; - /* acronychal setting */ - if (eventtype == 4) { - eventtype = 1; - DayStep = -DayStep; - } - /* acronychal rising */ - if (eventtype == 3) eventtype = 2; - eventtype |= SE_BIT_DISC_CENTER; - /* normalize the maxlength to the step size */ - { - /* check each Synodic/phase Period */ - JDNDaysUT = JDNDaysUTStart; - /* make sure one can find an event on the just after the JDNDaysUTStart */ - JDNDaysUTfinal = JDNDaysUT + maxlength; - JDNDaysUT = JDNDaysUT - 1; - if (DayStep < 0) { - JDNDaysUTtijd = JDNDaysUT; - JDNDaysUT = JDNDaysUTfinal; - JDNDaysUTfinal = JDNDaysUTtijd; + double x[6]; + double xin[2]; + double xaz[2]; + double dang[3]; + double objectmagn = 0, maxlength, DayStep; + double JDNDaysUT, + JDNDaysUTfinal, JDNDaysUTstep, JDNDaysUTstepoud, + JDNarcvisUT, tjd_tt, tret, OudeDatum, JDNDaysUTinp = + JDNDaysUTStart, JDNDaysUTtijd; + double ArcusVis, ArcusVisDelta, ArcusVisPto, ArcusVisDeltaoud; + double Trise, sunsangle, Theliacal, Tdelta, Angle; + double TimeStep, TimePointer, OldestMinTAV, MinTAVoud, MinTAVact, extrax, + TbVR = 0; + double AziS, AltS, AziO, AltO, DeltaAlt; + double direct, Pressure, Temperature, d; + int32 epheflag, retval = OK; + int32 iflag, Planet, eventtype; + int32 TypeEvent = TypeEventIn; + int doneoneday; + char serr[AS_MAXCH]; + + *dret = JDNDaysUTStart; + *serr = '\0'; + Planet = DeterObject(ObjectName); + Pressure = datm[0]; + Temperature = datm[1]; + + /* determine Magnitude of star */ + if ((retval = Magnitude(JDNDaysUTStart, dgeo, ObjectName, helflag, &objectmagn, serr)) == ERR) { + goto swe_heliacal_err; } - /* prepair the search */ - JDNDaysUTstep = JDNDaysUT - DayStep; - doneoneday = 0; - ArcusVisDelta = 199; - ArcusVisPto = -5.55; - do { /* this is a do {} while() loop */ - if (fabs(DayStep) == 1) doneoneday = 1; - do { /* this is a do {} while() loop */ - /* init search for heliacal rise */ - JDNDaysUTstepoud = JDNDaysUTstep; - ArcusVisDeltaoud = ArcusVisDelta; - JDNDaysUTstep = JDNDaysUTstep + DayStep; - /* determine rise/set time */ - if ((retval = my_rise_trans(JDNDaysUTstep, SE_SUN, "", eventtype, helflag, dgeo, datm, &tret, serr)) == ERR) - goto swe_heliacal_err; - /* determine time compensation to get Sun's altitude at heliacal rise */ - tjd_tt = tret + DeltaT(tret, 0) / D2S; - if ((retval = swe_calc(tjd_tt, SE_SUN, iflag, x, serr)) == ERR) - goto swe_heliacal_err; - xin[0] = x[0]; - xin[1] = x[1]; - swe_azalt(tret, SE_EQU2HOR, dgeo, Pressure, Temperature, xin, xaz); - Trise = HourAngle(xaz[1], x[1], dgeo[1]); - sunsangle = ArcusVisPto; - if (helflag & SE_HELFLAG_AVKIND_MIN7) sunsangle = -7; - if (helflag & SE_HELFLAG_AVKIND_MIN9) sunsangle = -9; - Theliacal = HourAngle(sunsangle, x[1], dgeo[1]); - Tdelta = Theliacal - Trise; - if (TypeEvent == 2 || TypeEvent== 3) Tdelta = -Tdelta; - /* determine appr.time when sun is at the wanted Sun's altitude */ - JDNarcvisUT = tret - Tdelta / 24; - tjd_tt = JDNarcvisUT + DeltaT(JDNarcvisUT, 0) / D2S; - /* determine Sun's position */ - if ((retval = swe_calc(tjd_tt, SE_SUN, iflag, x, serr)) == ERR) - goto swe_heliacal_err; - xin[0] = x[0]; - xin[1] = x[1]; - swe_azalt(JDNarcvisUT, SE_EQU2HOR, dgeo, Pressure, Temperature, xin, xaz); - AziS = xaz[0] + 180; - if (AziS >= 360) AziS = AziS - 360; - AltS = xaz[1]; - /* determine Moon's position */ -#if 0 - double AltM, AziM; - if ((retval = swe_calc(tjd_tt, SE_MOON, iflag, x, serr)) == ERR) - goto swe_heliacal_err; - xin[0] = x[0]; - xin[1] = x[1]; - swe_azalt(JDNarcvisUT, SE_EQU2HOR, dgeo, Pressure, Temperature, xin, xaz); - AziM = xaz[0] + 180; - if (AziM >= 360) AziM = AziM - 360; - AltM = xaz[1]; -#endif - /* determine object's position */ - if (Planet != -1) { - if ((retval = swe_calc(tjd_tt, Planet, iflag, x, serr)) == ERR) - goto swe_heliacal_err; - /* determine magnitude of Planet */ - if ((retval = Magnitude(JDNarcvisUT, dgeo, ObjectName, helflag, &objectmagn, serr)) == ERR) - goto swe_heliacal_err; - } else { - if ((retval = call_swe_fixstar(ObjectName, tjd_tt, iflag, x, serr)) == ERR) - goto swe_heliacal_err; - } - xin[0] = x[0]; - xin[1] = x[1]; - swe_azalt(JDNarcvisUT, SE_EQU2HOR, dgeo, Pressure, Temperature, xin, xaz); - AziO = xaz[0] + 180; - if (AziO >= 360) AziO = AziO - 360; - AltO = xaz[1]; - /* determine arcusvisionis */ - DeltaAlt = AltO - AltS; - /*if ((retval = HeliacalAngle(objectmagn, dobs, AziO, AltM, AziM, JDNarcvisUT, AziS, dgeo, datm, helflag, dang, serr)) == ERR)*/ - if ((retval = HeliacalAngle(objectmagn, dobs, AziO, -1, 0, JDNarcvisUT, AziS, dgeo, datm, helflag, dang, serr)) == ERR) - goto swe_heliacal_err; - ArcusVis = dang[1]; - ArcusVisPto = dang[2]; - ArcusVisDelta = DeltaAlt - ArcusVis; - /*} while (((ArcusVisDeltaoud > 0 && ArcusVisDelta < 0) || ArcusVisDelta < 0) && (JDNDaysUTfinal - JDNDaysUTstep) * Sgn(DayStep) > 0);*/ - } while ((ArcusVisDeltaoud > 0 || ArcusVisDelta < 0) && (JDNDaysUTfinal - JDNDaysUTstep) * Sgn(DayStep) > 0); - if (doneoneday == 0 && (JDNDaysUTfinal - JDNDaysUTstep) * Sgn(DayStep) > 0) { - /* go back to date before heliacal altitude */ - ArcusVisDelta = ArcusVisDeltaoud; - DayStep = ((int) (fabs(DayStep) / 2.0)) * Sgn(DayStep); - JDNDaysUTstep = JDNDaysUTstepoud; - } - } while (doneoneday == 0 && (JDNDaysUTfinal - JDNDaysUTstep) * Sgn(DayStep) > 0); - } - d = (JDNDaysUTfinal - JDNDaysUTstep) * Sgn(DayStep); - if (d <= 0 || d >= maxlength) { - dret[0] = JDNDaysUTinp; /* no date found, just return input */ - retval = -2; /* marks "not found" within synodic period */ - sprintf(serr, "heliacal event not found within maxlength %f\n", maxlength); - goto swe_heliacal_err; - } -#if 0 - if (helflag & SE_HELFLAG_AVKIND_VR) { - double darr[40]; - if (swe_heliacal_pheno_ut(JDNarcvisUT, dgeo, datm, dobs, ObjectName, TypeEvent, helflag, darr, serr) != OK) - return ERR; - JDNarcvisUT = darr[13]; + + epheflag = helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + iflag = SEFLG_TOPOCTR | SEFLG_EQUATORIAL | epheflag; + + if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) { + iflag |= SEFLG_NONUT | SEFLG_TRUEPOS; } - } + + /* start values for search of heliacal rise + * maxlength = phase period in days, smaller than minimal synodic period */ + /* days per step (for heliacal rise) in power of two */ + switch (Planet) { + case SE_MERCURY: + DayStep = 1; + maxlength = 100; + break; + case SE_VENUS: + DayStep = 64; + maxlength = 384; + break; + case SE_MARS: + DayStep = 128; + maxlength = 640; + break; + case SE_JUPITER: + DayStep = 64; + maxlength = 384; + break; + case SE_SATURN: + DayStep = 64; + maxlength = 256; + break; + default: + DayStep = 64; + maxlength = 256; + break; + } + + /* heliacal setting */ + eventtype = TypeEvent; + + if (eventtype == 2) { + DayStep = -DayStep; + } + + /* acronychal setting */ + if (eventtype == 4) { + eventtype = 1; + DayStep = -DayStep; + } + + /* acronychal rising */ + if (eventtype == 3) { + eventtype = 2; + } + + eventtype |= SE_BIT_DISC_CENTER; + /* normalize the maxlength to the step size */ + { + /* check each Synodic/phase Period */ + JDNDaysUT = JDNDaysUTStart; + /* make sure one can find an event on the just after the JDNDaysUTStart */ + JDNDaysUTfinal = JDNDaysUT + maxlength; + JDNDaysUT = JDNDaysUT - 1; + + if (DayStep < 0) { + JDNDaysUTtijd = JDNDaysUT; + JDNDaysUT = JDNDaysUTfinal; + JDNDaysUTfinal = JDNDaysUTtijd; + } + + /* prepair the search */ + JDNDaysUTstep = JDNDaysUT - DayStep; + doneoneday = 0; + ArcusVisDelta = 199; + ArcusVisPto = -5.55; + + do { + if (fabs(DayStep) == 1) { + doneoneday = 1; + } + + do { + /* init search for heliacal rise */ + JDNDaysUTstepoud = JDNDaysUTstep; + ArcusVisDeltaoud = ArcusVisDelta; + JDNDaysUTstep = JDNDaysUTstep + DayStep; + + /* determine rise/set time */ + if ((retval = my_rise_trans(JDNDaysUTstep, SE_SUN, "", eventtype, helflag, dgeo, datm, &tret, serr)) == ERR) { + goto swe_heliacal_err; + } + + /* determine time compensation to get Sun's altitude at heliacal rise */ + tjd_tt = tret + DeltaT(tret, 0) / D2S; + + if ((retval = swe_calc(tjd_tt, SE_SUN, iflag, x, serr)) == ERR) { + goto swe_heliacal_err; + } + + xin[0] = x[0]; + xin[1] = x[1]; + swe_azalt(tret, SE_EQU2HOR, dgeo, Pressure, Temperature, xin, xaz); + Trise = HourAngle(xaz[1], x[1], dgeo[1]); + sunsangle = ArcusVisPto; + + if (helflag & SE_HELFLAG_AVKIND_MIN7) { + sunsangle = -7; + } + + if (helflag & SE_HELFLAG_AVKIND_MIN9) { + sunsangle = -9; + } + + Theliacal = HourAngle(sunsangle, x[1], dgeo[1]); + Tdelta = Theliacal - Trise; + + if (TypeEvent == 2 || TypeEvent == 3) { + Tdelta = -Tdelta; + } + + /* determine appr.time when sun is at the wanted Sun's altitude */ + JDNarcvisUT = tret - Tdelta / 24; + tjd_tt = JDNarcvisUT + DeltaT(JDNarcvisUT, 0) / D2S; + /* determine Sun's position */ + if ((retval = + swe_calc(tjd_tt, SE_SUN, iflag, x, serr)) == ERR) + goto swe_heliacal_err; + xin[0] = x[0]; + xin[1] = x[1]; + swe_azalt(JDNarcvisUT, SE_EQU2HOR, dgeo, Pressure, + Temperature, xin, xaz); + AziS = xaz[0] + 180; + if (AziS >= 360) + AziS = AziS - 360; + AltS = xaz[1]; + /* determine Moon's position */ +#if 0 + double AltM, AziM; + if ((retval = + swe_calc(tjd_tt, SE_MOON, iflag, x, serr)) == ERR) + goto swe_heliacal_err; + xin[0] = x[0]; + xin[1] = x[1]; + swe_azalt(JDNarcvisUT, SE_EQU2HOR, dgeo, Pressure, + Temperature, xin, xaz); + AziM = xaz[0] + 180; + if (AziM >= 360) + AziM = AziM - 360; + AltM = xaz[1]; #endif - direct = TimeStepDefault / 24.0 / 60.0; - if (DayStep < 0) direct = -direct; - if (helflag & SE_HELFLAG_AVKIND_VR) { - /*te bepalen m.b.v. walkthrough*/ + /* determine object's position */ + if (Planet != -1) { + if ((retval = + swe_calc(tjd_tt, Planet, iflag, x, serr)) == ERR) + goto swe_heliacal_err; + /* determine magnitude of Planet */ + if ((retval = + Magnitude(JDNarcvisUT, dgeo, ObjectName, helflag, + &objectmagn, serr)) == ERR) + goto swe_heliacal_err; + } + else { + if ((retval = + call_swe_fixstar(ObjectName, tjd_tt, iflag, x, + serr)) == ERR) + goto swe_heliacal_err; + } + xin[0] = x[0]; + xin[1] = x[1]; + swe_azalt(JDNarcvisUT, SE_EQU2HOR, dgeo, Pressure, + Temperature, xin, xaz); + AziO = xaz[0] + 180; + if (AziO >= 360) + AziO = AziO - 360; + AltO = xaz[1]; + /* determine arcusvisionis */ + DeltaAlt = AltO - AltS; + /*if ((retval = HeliacalAngle(objectmagn, dobs, AziO, AltM, AziM, JDNarcvisUT, AziS, dgeo, datm, helflag, dang, serr)) == ERR) */ + if ((retval = + HeliacalAngle(objectmagn, dobs, AziO, -1, 0, JDNarcvisUT, + AziS, dgeo, datm, helflag, dang, + serr)) == ERR) + goto swe_heliacal_err; + ArcusVis = dang[1]; + ArcusVisPto = dang[2]; + ArcusVisDelta = DeltaAlt - ArcusVis; + //} while (((ArcusVisDeltaoud > 0 && ArcusVisDelta < 0) || ArcusVisDelta < 0) && (JDNDaysUTfinal - JDNDaysUTstep) * Sgn(DayStep) > 0); + } while ((ArcusVisDeltaoud > 0 || ArcusVisDelta < 0) && (JDNDaysUTfinal - JDNDaysUTstep) * Sgn(DayStep) > 0); + + if (doneoneday == 0 && (JDNDaysUTfinal - JDNDaysUTstep) * Sgn(DayStep) > 0) { + /* go back to date before heliacal altitude */ + ArcusVisDelta = ArcusVisDeltaoud; + DayStep = ((int)(fabs(DayStep) / 2.0)) * Sgn(DayStep); + JDNDaysUTstep = JDNDaysUTstepoud; + } + } while (doneoneday == 0 && (JDNDaysUTfinal - JDNDaysUTstep) * Sgn(DayStep) > 0); + } + d = (JDNDaysUTfinal - JDNDaysUTstep) * Sgn(DayStep); + + if (d <= 0 || d >= maxlength) { + dret[0] = JDNDaysUTinp; /* no date found, just return input */ + retval = -2; /* marks "not found" within synodic period */ + sprintf(serr, "heliacal event not found within maxlength %f\n", + maxlength); + goto swe_heliacal_err; + } +#if 0 + if (helflag & SE_HELFLAG_AVKIND_VR) { + double darr[40]; + if (swe_heliacal_pheno_ut + (JDNarcvisUT, dgeo, datm, dobs, ObjectName, TypeEvent, helflag, + darr, serr) != OK) + return ERR; + JDNarcvisUT = darr[13]; + } +} +#endif +direct = TimeStepDefault / 24.0 / 60.0; +if (DayStep < 0) + direct = -direct; +if (helflag & SE_HELFLAG_AVKIND_VR) { + /*te bepalen m.b.v. walkthrough */ TimeStep = direct; TbVR = 0; TimePointer = JDNarcvisUT; - if (DeterTAV(dobs, TimePointer, dgeo, datm, ObjectName, helflag, &OldestMinTAV, serr) == ERR) - return ERR; - TimePointer = TimePointer + TimeStep; - if (DeterTAV(dobs, TimePointer, dgeo, datm, ObjectName, helflag, &MinTAVoud, serr) == ERR) - return ERR; - if (MinTAVoud > OldestMinTAV) { - TimePointer = JDNarcvisUT; - TimeStep = -TimeStep; - MinTAVact = OldestMinTAV; - } else { - MinTAVact = MinTAVoud; - MinTAVoud = OldestMinTAV; - } - /*TimePointer = TimePointer - Timestep*/ - do { - TimePointer = TimePointer + TimeStep; - OldestMinTAV = MinTAVoud; - MinTAVoud = MinTAVact; - if (DeterTAV(dobs, TimePointer, dgeo, datm, ObjectName, helflag, &MinTAVact, serr) == ERR) + if (DeterTAV + (dobs, TimePointer, dgeo, datm, ObjectName, helflag, &OldestMinTAV, + serr) == ERR) return ERR; - if (MinTAVoud < MinTAVact) { - extrax = x2min(MinTAVact, MinTAVoud, OldestMinTAV); - TbVR = TimePointer - (1 - extrax) * TimeStep; - } + TimePointer = TimePointer + TimeStep; + if (DeterTAV + (dobs, TimePointer, dgeo, datm, ObjectName, helflag, &MinTAVoud, + serr) == ERR) + return ERR; + if (MinTAVoud > OldestMinTAV) { + TimePointer = JDNarcvisUT; + TimeStep = -TimeStep; + MinTAVact = OldestMinTAV; + } + else { + MinTAVact = MinTAVoud; + MinTAVoud = OldestMinTAV; + } + /*TimePointer = TimePointer - Timestep */ + do { + TimePointer = TimePointer + TimeStep; + OldestMinTAV = MinTAVoud; + MinTAVoud = MinTAVact; + if (DeterTAV + (dobs, TimePointer, dgeo, datm, ObjectName, helflag, &MinTAVact, + serr) == ERR) + return ERR; + if (MinTAVoud < MinTAVact) { + extrax = x2min(MinTAVact, MinTAVoud, OldestMinTAV); + TbVR = TimePointer - (1 - extrax) * TimeStep; + } } while (TbVR == 0); JDNarcvisUT = TbVR; - } +} /*if (strncmp(AVkind, "pto", 3) == 0) */ - if (helflag & SE_HELFLAG_AVKIND_PTO) { +if (helflag & SE_HELFLAG_AVKIND_PTO) { do { - OudeDatum = JDNarcvisUT; - JDNarcvisUT = JDNarcvisUT - direct; - tjd_tt = JDNarcvisUT + DeltaT(JDNarcvisUT, 0) / D2S; - if (Planet != -1) { - if ((retval = swe_calc(tjd_tt, Planet, iflag, x, serr)) == ERR) - goto swe_heliacal_err; - } else { - if ((retval = call_swe_fixstar(ObjectName, tjd_tt, iflag, x, serr)) == ERR) - goto swe_heliacal_err; - } - xin[0] = x[0]; - xin[1] = x[1]; - swe_azalt(JDNarcvisUT, SE_EQU2HOR, dgeo, Pressure, Temperature, xin, xaz); - Angle = xaz[1]; + OudeDatum = JDNarcvisUT; + JDNarcvisUT = JDNarcvisUT - direct; + tjd_tt = JDNarcvisUT + DeltaT(JDNarcvisUT, 0) / D2S; + if (Planet != -1) { + if ((retval = swe_calc(tjd_tt, Planet, iflag, x, serr)) == ERR) + goto swe_heliacal_err; + } + else { + if ((retval = + call_swe_fixstar(ObjectName, tjd_tt, iflag, x, serr)) == ERR) + goto swe_heliacal_err; + } + xin[0] = x[0]; + xin[1] = x[1]; + swe_azalt(JDNarcvisUT, SE_EQU2HOR, dgeo, Pressure, Temperature, xin, + xaz); + Angle = xaz[1]; } while (Angle > 0); JDNarcvisUT = (JDNarcvisUT + OudeDatum) / 2.0; - } - if (JDNarcvisUT < -9999999 || JDNarcvisUT > 9999999) { - dret[0] = JDNDaysUT; /* no date found, just return input */ +} +if (JDNarcvisUT < -9999999 || JDNarcvisUT > 9999999) { + dret[0] = JDNDaysUT; /* no date found, just return input */ strcpy(serr, "no heliacal date found"); retval = ERR; goto swe_heliacal_err; - } - dret[0] = JDNarcvisUT; +} +dret[0] = JDNarcvisUT; swe_heliacal_err: - if (serr_ret != NULL && *serr != '\0') +if (serr_ret != NULL && *serr != '\0') strcpy(serr_ret, serr); - return retval; +return retval; } -static int32 get_asc_obl(double tjd, int32 ipl, char *star, int32 iflag, double - *dgeo, AS_BOOL desc_obl, double *daop, char *serr) +static int32 +get_asc_obl(double tjd, int32 ipl, char *star, int32 iflag, double *dgeo, + AS_BOOL desc_obl, double *daop, char *serr) { - int32 retval; - int32 epheflag = iflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - double x[6], adp; - char s[AS_MAXCH]; - char star2[AS_MAXCH]; - strcpy(star2, star); - if (ipl == -1) { - if ((retval = swe_fixstar(star2, tjd, epheflag | SEFLG_EQUATORIAL, x, serr)) == ERR) - return ERR; - } else { - if ((retval = swe_calc(tjd, ipl, epheflag | SEFLG_EQUATORIAL, x, serr)) == ERR) - return ERR; - } - adp = tan(dgeo[1] * DEGTORAD) * tan(x[1] * DEGTORAD); - if (fabs(adp) > 1) { - if (star != NULL && *star != '\0') - strcpy(s, star); + int32 retval; + int32 epheflag = iflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + double x[6], adp; + char s[AS_MAXCH]; + char star2[AS_MAXCH]; + strcpy(star2, star); + if (ipl == -1) { + if ((retval = + swe_fixstar(star2, tjd, epheflag | SEFLG_EQUATORIAL, x, + serr)) == ERR) + return ERR; + } + else { + if ((retval = + swe_calc(tjd, ipl, epheflag | SEFLG_EQUATORIAL, x, serr)) == ERR) + return ERR; + } + adp = tan(dgeo[1] * DEGTORAD) * tan(x[1] * DEGTORAD); + if (fabs(adp) > 1) { + if (star != NULL && *star != '\0') + strcpy(s, star); + else + swe_get_planet_name(ipl, s); + sprintf(serr, "%s is circumpolar, cannot calculate heliacal event", + s); + return -2; + } + adp = asin(adp) / DEGTORAD; + if (desc_obl) + *daop = x[0] + adp; else - swe_get_planet_name(ipl, s); - sprintf(serr, "%s is circumpolar, cannot calculate heliacal event", s); - return -2; - } - adp = asin(adp) / DEGTORAD; - if (desc_obl) - *daop = x[0] + adp; - else - *daop = x[0] - adp; - *daop = swe_degnorm(*daop); - return OK; + *daop = x[0] - adp; + *daop = swe_degnorm(*daop); + return OK; } #if 0 -static int32 get_asc_obl_old(double tjd, int32 ipl, char *star, int32 iflag, double *dgeo, AS_BOOL desc_obl, double *daop, char *serr) +static int32 +get_asc_obl_old(double tjd, int32 ipl, char *star, int32 iflag, double *dgeo, + AS_BOOL desc_obl, double *daop, char *serr) { - int32 retval; - int32 epheflag = iflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - double x[6], adp; - char s[AS_MAXCH]; - if (star != NULL && *star != '\0') { - if ((retval = call_swe_fixstar(star, tjd, epheflag | SEFLG_EQUATORIAL, x, serr)) == ERR) - return ERR; - } else { - if ((retval = swe_calc(tjd, ipl, epheflag | SEFLG_EQUATORIAL, x, serr)) == ERR) - return ERR; - } - adp = tan(dgeo[1] * DEGTORAD) * tan(x[1] * DEGTORAD); - if (fabs(adp) > 1) { - if (star != NULL && *star != '\0') - strcpy(s, star); - else - swe_get_planet_name(ipl, s); - sprintf(serr, "%s is circumpolar, cannot calculate heliacal event", s); - return -2; - } - adp = asin(adp) / DEGTORAD; - if (desc_obl) - *daop = x[0] + adp; - else - *daop = x[0] - adp; - *daop = swe_degnorm(*daop); - return OK; + int32 retval; + int32 epheflag = iflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + double x[6], adp; + char s[AS_MAXCH]; + if (star != NULL && *star != '\0') { + if ((retval = + call_swe_fixstar(star, tjd, epheflag | SEFLG_EQUATORIAL, x, + serr)) == ERR) + return ERR; + } + else { + if ((retval = + swe_calc(tjd, ipl, epheflag | SEFLG_EQUATORIAL, x, serr)) == ERR) + return ERR; + } + adp = tan(dgeo[1] * DEGTORAD) * tan(x[1] * DEGTORAD); + if (fabs(adp) > 1) { + if (star != NULL && *star != '\0') + strcpy(s, star); + else + swe_get_planet_name(ipl, s); + sprintf(serr, "%s is circumpolar, cannot calculate heliacal event", + s); + return -2; + } + adp = asin(adp) / DEGTORAD; + if (desc_obl) + *daop = x[0] + adp; + else + *daop = x[0] - adp; + *daop = swe_degnorm(*daop); + return OK; } #endif -static int32 get_asc_obl_diff(double tjd, int32 ipl, char *star, int32 iflag, double *dgeo, AS_BOOL desc_obl, AS_BOOL is_acronychal, double *dsunpl, char *serr) +static int32 +get_asc_obl_diff(double tjd, int32 ipl, char *star, int32 iflag, double *dgeo, + AS_BOOL desc_obl, AS_BOOL is_acronychal, double *dsunpl, + char *serr) { - int32 retval = OK; - double aosun, aopl; - /* ascensio obliqua of sun */ - retval = get_asc_obl(tjd, SE_SUN, "", iflag, dgeo, desc_obl, &aosun, serr); - if (retval != OK) - return retval; - if (is_acronychal) { - if (desc_obl == TRUE) - desc_obl = FALSE; - else - desc_obl = TRUE; - } - /* ascensio obliqua of body */ - retval = get_asc_obl(tjd, ipl, star, iflag, dgeo, desc_obl, &aopl, serr); - if (retval != OK) - return retval; - *dsunpl = swe_degnorm(aosun - aopl); - if (is_acronychal) - *dsunpl = swe_degnorm(*dsunpl - 180); - if (*dsunpl > 180) *dsunpl -= 360; - return OK; + int32 retval = OK; + double aosun, aopl; + /* ascensio obliqua of sun */ + retval = + get_asc_obl(tjd, SE_SUN, "", iflag, dgeo, desc_obl, &aosun, serr); + if (retval != OK) + return retval; + if (is_acronychal) { + if (desc_obl == TRUE) + desc_obl = FALSE; + else + desc_obl = TRUE; + } + /* ascensio obliqua of body */ + retval = get_asc_obl(tjd, ipl, star, iflag, dgeo, desc_obl, &aopl, serr); + if (retval != OK) + return retval; + *dsunpl = swe_degnorm(aosun - aopl); + if (is_acronychal) + *dsunpl = swe_degnorm(*dsunpl - 180); + if (*dsunpl > 180) + *dsunpl -= 360; + return OK; } #if 0 -static int32 get_asc_obl_diff_old(double tjd, int32 ipl, char *star, int32 iflag, double *dgeo, AS_BOOL desc_obl, double *dsunpl, char *serr) +static int32 +get_asc_obl_diff_old(double tjd, int32 ipl, char *star, int32 iflag, + double *dgeo, AS_BOOL desc_obl, double *dsunpl, + char *serr) { - int32 retval = OK; - double aosun, aopl; - /* ascensio obliqua of sun */ - retval = get_asc_obl(tjd, SE_SUN, "", iflag, dgeo, desc_obl, &aosun, serr); - if (retval != OK) - return retval; - /* ascensio obliqua of body */ - retval = get_asc_obl(tjd, ipl, star, iflag, dgeo, desc_obl, &aopl, serr); - if (retval != OK) - return retval; - *dsunpl = swe_degnorm(aosun - aopl); - return OK; + int32 retval = OK; + double aosun, aopl; + /* ascensio obliqua of sun */ + retval = + get_asc_obl(tjd, SE_SUN, "", iflag, dgeo, desc_obl, &aosun, serr); + if (retval != OK) + return retval; + /* ascensio obliqua of body */ + retval = get_asc_obl(tjd, ipl, star, iflag, dgeo, desc_obl, &aopl, serr); + if (retval != OK) + return retval; + *dsunpl = swe_degnorm(aosun - aopl); + return OK; } #endif @@ -2499,794 +3035,989 @@ static int32 get_asc_obl_diff_old(double tjd, int32 ipl, char *star, int32 iflag * - superior and inferior conjunction (Mercury and Venus) * - conjunction and opposition (ipl >= Mars) */ -static double tcon[] = -{ - 0, 0, - 2451550, 2451550, /* Moon */ - 2451604, 2451670, /* Mercury */ - 2451980, 2452280, /* Venus */ - 2451727, 2452074, /* Mars */ - 2451673, 2451877, /* Jupiter */ - 2451675, 2451868, /* Saturn */ - 2451581, 2451768, /* Uranus */ - 2451568, 2451753, /* Neptune */ +static double tcon[] = { + 0, 0, + 2451550, 2451550, /* Moon */ + 2451604, 2451670, /* Mercury */ + 2451980, 2452280, /* Venus */ + 2451727, 2452074, /* Mars */ + 2451673, 2451877, /* Jupiter */ + 2451675, 2451868, /* Saturn */ + 2451581, 2451768, /* Uranus */ + 2451568, 2451753, /* Neptune */ }; -static int32 find_conjunct_sun(double tjd_start, int32 ipl, int32 helflag, int32 TypeEvent, double *tjd, char *serr) +static int32 +find_conjunct_sun(double tjd_start, int32 ipl, int32 helflag, int32 TypeEvent, + double *tjd, char *serr) { - int32 epheflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - int i; - double tjdcon, tjd0, ds, dsynperiod, x[6], xs[6], daspect = 0; - if (ipl >= SE_MARS && TypeEvent >= 3) - daspect = 180; - i = (TypeEvent - 1) / 2 + ipl * 2; - tjd0 = tcon[i]; - dsynperiod = get_synodic_period(ipl); - tjdcon = tjd0 + ((floor) ((tjd_start - tjd0) / dsynperiod) + 1) * dsynperiod; - ds = 100; - while (ds > 0.5) { - if (swe_calc(tjdcon, ipl, epheflag|SEFLG_SPEED, x, serr) == ERR) - return ERR; - if (swe_calc(tjdcon, SE_SUN, epheflag|SEFLG_SPEED, xs, serr) == ERR) - return ERR; - ds = swe_degnorm(x[0] - xs[0] - daspect); - if (ds > 180) ds -= 360; - tjdcon -= ds / (x[3] - xs[3]); - } - *tjd = tjdcon; - return OK; + int32 epheflag = helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + int i; + double tjdcon, tjd0, ds, dsynperiod, x[6], xs[6], daspect = 0; + if (ipl >= SE_MARS && TypeEvent >= 3) + daspect = 180; + i = (TypeEvent - 1) / 2 + ipl * 2; + tjd0 = tcon[i]; + dsynperiod = get_synodic_period(ipl); + tjdcon = + tjd0 + ((floor) ((tjd_start - tjd0) / dsynperiod) + 1) * dsynperiod; + ds = 100; + while (ds > 0.5) { + if (swe_calc(tjdcon, ipl, epheflag | SEFLG_SPEED, x, serr) == ERR) + return ERR; + if (swe_calc(tjdcon, SE_SUN, epheflag | SEFLG_SPEED, xs, serr) == ERR) + return ERR; + ds = swe_degnorm(x[0] - xs[0] - daspect); + if (ds > 180) + ds -= 360; + tjdcon -= ds / (x[3] - xs[3]); + } + *tjd = tjdcon; + return OK; } -static int32 get_asc_obl_with_sun(double tjd_start, int32 ipl, char *star, int32 helflag, int32 evtyp, double dperiod, double *dgeo, double *tjdret, char *serr) +static int32 +get_asc_obl_with_sun(double tjd_start, int32 ipl, char *star, int32 helflag, + int32 evtyp, double dperiod, double *dgeo, + double *tjdret, char *serr) { - int i, retval; - int32 is_acronychal = FALSE; - int32 epheflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - double dsunpl = 1, dsunpl_save, dsunpl_test, tjd, daystep; - AS_BOOL desc_obl = FALSE, retro = FALSE; - if (evtyp == SE_EVENING_LAST || evtyp == SE_EVENING_FIRST) - desc_obl = TRUE; - if (evtyp == SE_MORNING_FIRST || evtyp == SE_EVENING_LAST) - retro = TRUE; - if (evtyp == SE_ACRONYCHAL_RISING) - desc_obl = TRUE; - if (evtyp == SE_ACRONYCHAL_RISING || evtyp == SE_ACRONYCHAL_SETTING) { - is_acronychal = TRUE; - if (ipl != SE_MOON) - retro = TRUE; - } - // if (evtyp == 3 || evtyp == 4) - // dangsearch = 180; - /* find date when sun and object have the same ascensio obliqua */ - tjd = tjd_start; - dsunpl_save = -999999999; - retval = get_asc_obl_diff(tjd, ipl, star, epheflag, dgeo, desc_obl, is_acronychal, &dsunpl, serr); - if (retval != OK) /* retval may be ERR or -2 */ - return retval; - daystep = 20; - i = 0; - while (dsunpl_save == -999999999 || - /*fabs(dsunpl - dsunpl_save) > 180 ||*/ - fabs(dsunpl) + fabs(dsunpl_save) > 180 || - (retro && !(dsunpl_save < 0 && dsunpl >= 0)) || - (!retro && !(dsunpl_save >= 0 && dsunpl < 0))) { - i++; - if (i > 5000) { - sprintf(serr, "loop in get_asc_obl_with_sun() (1)"); - return ERR; + int i, retval; + int32 is_acronychal = FALSE; + int32 epheflag = helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + double dsunpl = 1, dsunpl_save, dsunpl_test, tjd, daystep; + AS_BOOL desc_obl = FALSE, retro = FALSE; + if (evtyp == SE_EVENING_LAST || evtyp == SE_EVENING_FIRST) + desc_obl = TRUE; + if (evtyp == SE_MORNING_FIRST || evtyp == SE_EVENING_LAST) + retro = TRUE; + if (evtyp == SE_ACRONYCHAL_RISING) + desc_obl = TRUE; + if (evtyp == SE_ACRONYCHAL_RISING || evtyp == SE_ACRONYCHAL_SETTING) { + is_acronychal = TRUE; + if (ipl != SE_MOON) + retro = TRUE; } - dsunpl_save = dsunpl; - tjd += 10.0; - if (dperiod > 0 && tjd - tjd_start > dperiod) - return -2; - retval = get_asc_obl_diff(tjd, ipl, star, epheflag, dgeo, desc_obl, is_acronychal, &dsunpl, serr); - if (retval != OK) /* retval may be ERR or -2 */ - return retval; - } - tjd_start = tjd - daystep; - daystep /= 2.0; - tjd = tjd_start + daystep; - retval = get_asc_obl_diff(tjd, ipl, star, epheflag, dgeo, desc_obl, is_acronychal, &dsunpl_test, serr); - if (retval != OK) /* retval may be ERR or -2 */ - return retval; - i = 0; - while (fabs(dsunpl) > 0.00001) { - i++; - if (i > 5000) { - sprintf(serr, "loop in get_asc_obl_with_sun() (2)"); - return ERR; - } - if (dsunpl_save * dsunpl_test >= 0) { - dsunpl_save = dsunpl_test; - tjd_start = tjd; - } else { - dsunpl = dsunpl_test; + // if (evtyp == 3 || evtyp == 4) + // dangsearch = 180; + /* find date when sun and object have the same ascensio obliqua */ + tjd = tjd_start; + dsunpl_save = -999999999; + retval = + get_asc_obl_diff(tjd, ipl, star, epheflag, dgeo, desc_obl, + is_acronychal, &dsunpl, serr); + if (retval != OK) /* retval may be ERR or -2 */ + return retval; + daystep = 20; + i = 0; + while (dsunpl_save == -999999999 || + /*fabs(dsunpl - dsunpl_save) > 180 || */ + fabs(dsunpl) + fabs(dsunpl_save) > 180 || (retro + && !(dsunpl_save < 0 + && dsunpl >= 0)) + || (!retro && !(dsunpl_save >= 0 && dsunpl < 0))) { + i++; + if (i > 5000) { + sprintf(serr, "loop in get_asc_obl_with_sun() (1)"); + return ERR; + } + dsunpl_save = dsunpl; + tjd += 10.0; + if (dperiod > 0 && tjd - tjd_start > dperiod) + return -2; + retval = + get_asc_obl_diff(tjd, ipl, star, epheflag, dgeo, desc_obl, + is_acronychal, &dsunpl, serr); + if (retval != OK) /* retval may be ERR or -2 */ + return retval; } + tjd_start = tjd - daystep; daystep /= 2.0; tjd = tjd_start + daystep; - retval = get_asc_obl_diff(tjd, ipl, star, epheflag, dgeo, desc_obl, is_acronychal, &dsunpl_test, serr); - if (retval != OK) /* retval may be ERR or -2 */ - return retval; - } - *tjdret = tjd; - return OK; -} - -#if 0 -/* works only for fixed stars */ -static int32 get_asc_obl_with_sun_old(double tjd_start, int32 ipl, char *star, int32 helflag, int32 TypeEvent, double *dgeo, double *tjdret, char *serr) -{ - int retval; - int32 epheflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - double dsunpl = 1, tjd, daystep, dsunpl_save; - double dsynperiod = 367; - double dangsearch = 0; - AS_BOOL desc_obl = FALSE; - if (TypeEvent == 2 || TypeEvent == 3) - desc_obl = TRUE; - if (TypeEvent == 3 || TypeEvent == 4) - dangsearch = 180; - /* find date when sun and object have the same ascensio obliqua */ - daystep = dsynperiod; - tjd = tjd_start; - retval = get_asc_obl_diff(tjd, ipl, star, epheflag, dgeo, desc_obl, &dsunpl, serr); - if (retval != OK) /* retval may be ERR or -2 */ - return retval; - while (dsunpl < 359.99999) { - dsunpl_save = dsunpl; - daystep /= 2.0; - retval = get_asc_obl_diff(tjd + daystep, ipl, star, epheflag, dgeo, desc_obl, &dsunpl, serr); - if (retval != OK) /* retval may be ERR or -2 */ - return retval; - if (dsunpl > dsunpl_save) - tjd += daystep; - else - dsunpl = dsunpl_save; - } - *tjdret = tjd; - return OK; -} -#endif - -#if 0 -/* works only for fixed stars */ -static int32 get_asc_obl_acronychal(double tjd_start, int32 ipl, char *star, int32 helflag, int32 TypeEvent, double *dgeo, double *tjdret, char *serr) -{ - int retval; - int32 epheflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - double dsunpl = 1, tjd, daystep, dsunpl_save; - double dsynperiod = 367; - double aosun, aopl; - AS_BOOL sun_desc = TRUE, obj_desc = FALSE; - daystep = dsynperiod; - tjd = tjd_start; - if (TypeEvent == 4) { - sun_desc = FALSE; - obj_desc = TRUE; - } - /* ascensio (descensio) obliqua of sun */ - retval = get_asc_obl(tjd, SE_SUN, "", epheflag, dgeo, sun_desc, &aosun, serr); - if (retval != OK) /* retval may be ERR or -2 */ - return retval; - /* ascensio (descensio) obliqua of body */ - retval = get_asc_obl(tjd, ipl, star, epheflag, dgeo, obj_desc, &aopl, serr); - if (retval != OK) /* retval may be ERR or -2 */ - return retval; - dsunpl = swe_degnorm(aosun - aopl + 180); - while (dsunpl < 359.99999) { - dsunpl_save = dsunpl; - daystep /= 2.0; - /* ascensio (descensio) obliqua of sun */ - retval = get_asc_obl(tjd+daystep, SE_SUN, "", epheflag, dgeo, sun_desc, &aosun, serr); - if (retval != OK) /* retval may be ERR or -2 */ - return retval; - /* ascensio (descensio) obliqua of body */ - retval = get_asc_obl(tjd+daystep, ipl, star, epheflag, dgeo, obj_desc, &aopl, serr); - if (retval != OK) /* retval may be ERR or -2 */ - return retval; - dsunpl = swe_degnorm(aosun - aopl + 180); - if (dsunpl > dsunpl_save) - tjd += daystep; - else - dsunpl = dsunpl_save; - } - *tjdret = tjd; - return OK; -} -#endif - -static int32 get_heliacal_day(double tjd, double *dgeo, double *datm, double *dobs, char *ObjectName, int32 helflag, int32 TypeEvent, double *thel, char *serr) -{ - int32 is_rise_or_set = 0, ndays, retval, retval_old; - double direct_day = 0, direct_time = 0, tfac, tend, daystep, tday, vdelta, tret; - double darr[30], vd, dmag; - int32 ipl = DeterObject(ObjectName); - /* - * find the day and minute on which the object becomes visible - */ - switch (TypeEvent) { - /* morning first */ - case 1: is_rise_or_set = SE_CALC_RISE; - direct_day = 1; direct_time = -1; - break; - /* evening last */ - case 2: is_rise_or_set = SE_CALC_SET; - direct_day = -1; direct_time = 1; - break; - /* evening first */ - case 3: is_rise_or_set = SE_CALC_SET; - direct_day = 1; direct_time = 1; - break; - /* morning last */ - case 4: is_rise_or_set = SE_CALC_RISE; - direct_day = -1; direct_time = -1; - break; - } - tfac = 1; - switch (ipl) { - case SE_MOON: - ndays = 6; - daystep = 1; - break; - case SE_MERCURY: - ndays = 60; tjd -= 0 * direct_day; - daystep = 5; - tfac = 5; - break; - case SE_VENUS: - ndays = 300; tjd -= 30 * direct_day; - daystep = 5; - if (TypeEvent >= 3) { - daystep = 15; - tfac = 3; - } - break; - case SE_MARS: - ndays = 400; - daystep = 15; - tfac = 5; - break; - case SE_SATURN: - ndays = 300; - daystep = 20; - tfac = 5; - break; - case -1: - ndays = 300; - if (call_swe_fixstar_mag(ObjectName, &dmag, serr) == ERR) - return ERR; - daystep = 15; - tfac = 10; - if (dmag > 2) { - daystep = 15; - } - if (dmag < 0) { - tfac = 3; - } - break; - default: - ndays = 300; - daystep = 15; - tfac = 3; - break; - } - tend = tjd + ndays * direct_day; - retval_old = -2; - for (tday = tjd; - (direct_day > 0 && tday < tend) || (direct_day < 0 && tday > tend); - tday += daystep * direct_day) { - vdelta = -100; - if ((retval = my_rise_trans(tday, SE_SUN, "", is_rise_or_set, helflag, dgeo, datm, &tret, serr)) == ERR) - return ERR; - /* sun does not rise: try next day */ - if (retval == -2) { - retval_old = retval; - continue; + retval = + get_asc_obl_diff(tjd, ipl, star, epheflag, dgeo, desc_obl, + is_acronychal, &dsunpl_test, serr); + if (retval != OK) /* retval may be ERR or -2 */ + return retval; + i = 0; + while (fabs(dsunpl) > 0.00001) { + i++; + if (i > 5000) { + sprintf(serr, "loop in get_asc_obl_with_sun() (2)"); + return ERR; + } + if (dsunpl_save * dsunpl_test >= 0) { + dsunpl_save = dsunpl_test; + tjd_start = tjd; + } + else { + dsunpl = dsunpl_test; + } + daystep /= 2.0; + tjd = tjd_start + daystep; + retval = + get_asc_obl_diff(tjd, ipl, star, epheflag, dgeo, desc_obl, + is_acronychal, &dsunpl_test, serr); + if (retval != OK) /* retval may be ERR or -2 */ + return retval; } - retval = swe_vis_limit_mag(tret, dgeo, datm, dobs, ObjectName, helflag, darr, serr); - if (retval == ERR) - return ERR; -#if 1 - /* object has appeared above horizon: reduce daystep */ - if (retval_old == -2 && retval >= 0 && daystep > 1) { - retval_old = retval; - tday -= daystep * direct_day; - daystep = 1; - /* Note: beyond latitude 55N (?), Mars can have a morning last. - * If the period of visibility is less than 5 days, we may miss the - * event. I don't know if this happens */ - if (ipl >= SE_MARS || ipl == -1) - daystep = 5; - continue; - } - retval_old = retval; -#endif - /* object below horizon: try next day */ - if (retval == -2) - continue; - vdelta = darr[0] - darr[7]; - /* find minute of object's becoming visible */ - while (retval != -2 && (vd = darr[0] - darr[7]) < 0) { - if (vd < -1.0) - tret += 5.0 / 1440.0 * direct_time * tfac; - else if (vd < -0.5) - tret += 2.0 / 1440.0 * direct_time * tfac; - else if (vd < -0.1) - tret += 1.0 / 1440.0 * direct_time * tfac; - else - tret += 1.0 / 1440.0 * direct_time; - retval = swe_vis_limit_mag(tret, dgeo, datm, dobs, ObjectName, helflag, darr, serr); - if (retval == ERR) - return ERR; - } - vdelta = darr[0] - darr[7]; - /* object is visible, save time of appearance */ - if (vdelta > 0) { - if ((ipl >= SE_MARS || ipl == -1) && daystep > 1) { - tday -= daystep * direct_day; - daystep = 1; - } else { - *thel = tret; - return OK; - } - } - } - sprintf(serr, "heliacal event does not happen"); - return -2; -} - -#if 0 -static int32 get_acronychal_day_new(double tjd, double *dgeo, double *datm, double *dobs, char *ObjectName, int32 helflag, int32 TypeEvent, double *thel, char *serr) { - double tjdc = tjd, tret, x[6], xaz[6], AltO = -10; - int32 retval, is_rise_or_set, iter_day; - int32 ipl = DeterObject(ObjectName); - int32 epheflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - int32 iflag = epheflag | SEFLG_EQUATORIAL | SEFLG_TOPOCTR; - if ((retval = my_rise_trans(tret, 0, ObjectName, SE_CALC_RISE, helflag, dgeo, datm, &tret, serr)) == ERR) return ERR; - trise = tret; - tret += 0.01 - if ((retval = my_rise_trans(tret, 0, ObjectName, SE_CALC_SET, helflag, dgeo, datm, &tret, serr)) == ERR) return ERR; - trise = tset; - - *thel = tret; - return OK; -} -#endif - -#if 0 -static int32 get_acronychal_day_old(double tjd, double *dgeo, double *datm, double *dobs, char *ObjectName, int32 helflag, int32 TypeEvent, double *thel, char *serr) { - double tjdc = tjd, tret, x[6], xaz[6], AltO = -10; - int32 retval, is_rise_or_set, iter_day; - int32 ipl = DeterObject(ObjectName); - int32 epheflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - int32 iflag = epheflag | SEFLG_EQUATORIAL | SEFLG_TOPOCTR; - if (TypeEvent == 3) { - is_rise_or_set = SE_CALC_SET; - tret = tjdc - 3; - if (ipl >= SE_MARS) - tret = tjdc - 3; - iter_day = 1; - } else { - is_rise_or_set = SE_CALC_RISE; - tret = tjdc + 3; - if (ipl >= SE_MARS) - tret = tjdc + 3; - iter_day = -1; - } - while (AltO < 0) { - tret += 0.3 * iter_day; - if (iter_day == -1) - tret -= 1; - retval = my_rise_trans(tret, SE_SUN, "", is_rise_or_set, helflag, dgeo, datm, &tret, serr); - if (retval != OK) - return retval; - /* determine object's position */ - if (ipl == -1) - retval = call_swe_fixstar(ObjectName, tret+swe_deltat(tret), iflag, x, serr); - else - retval = swe_calc(tret+swe_deltat(tret), ipl, iflag, x, serr); - if (retval == ERR) return ERR; - swe_azalt(tret, SE_EQU2HOR, dgeo, datm[0], datm[1], x, xaz); - AltO = xaz[2]; - } - *thel = tret; - return OK; -} -#endif - -static int32 time_optimum_visibility(double tjd, double *dgeo, double *datm, double *dobs, char *ObjectName, int32 helflag, double *tret, char *serr) -{ - int32 retval, retval_sv, i; - double d, vl, darr[10], phot_scot_opic, phot_scot_opic_sv; - *tret = tjd; - retval = swe_vis_limit_mag(tjd, dgeo, datm, dobs, ObjectName, helflag, darr, serr); - if (retval == ERR) return ERR; - retval_sv = retval; - vl = darr[0] - darr[7]; - phot_scot_opic_sv = retval & SE_SCOTOPIC_FLAG; - for (i = 0, d = 100.0 / 86400.0; i < 3; i++, d /= 10.0) { - while((retval = swe_vis_limit_mag(tjd - d, dgeo, datm, dobs, ObjectName, helflag, darr, serr)) >= 0 - && darr[0] > darr[7] - && darr[0] - darr[7] > vl) { - tjd -= d; vl = darr[0] - darr[7]; - retval_sv = retval; - phot_scot_opic_sv = retval & SE_SCOTOPIC_FLAG; - /* printf("1: %f\n", darr[8]);*/ - } - if (retval == ERR) return ERR; - while((retval = swe_vis_limit_mag(tjd + d, dgeo, datm, dobs, ObjectName, helflag, darr, serr)) >= 0 - && darr[0] > darr[7] - && darr[0] - darr[7] > vl) { - tjd += d; vl = darr[0] - darr[7]; - retval_sv = retval; - phot_scot_opic_sv = retval & SE_SCOTOPIC_FLAG; - /* printf("2: %f\n", darr[8]);*/ - } - if (retval == ERR) return ERR; - } - /* printf("3: %f <-> %f\n", darr[8], phot_scot_opic_sv);*/ - *tret = tjd; - if (retval >= 0) { - /* search for optimum came to an end because change scotopic/photopic: */ - phot_scot_opic = (retval & SE_SCOTOPIC_FLAG); - if (phot_scot_opic_sv != phot_scot_opic) { - /* calling function writes warning into serr */ - return -2; - } - /* valid result found but it is close to the scotopic/photopic limit */ - if (retval_sv & SE_MIXEDOPIC_FLAG) { - return -2; - } - } - return OK; -} - -static int32 time_limit_invisible(double tjd, double *dgeo, double *datm, double *dobs, char *ObjectName, int32 helflag, int32 direct, double *tret, char *serr) -{ - int32 retval, retval_sv, i, ncnt = 3; - double d = 0, darr[10], phot_scot_opic, phot_scot_opic_sv; - double d0 = 100.0 / 86400.0; - *tret = tjd; - if (strcmp(ObjectName, "moon") == 0) { - d0 *= 10; - ncnt = 4; - } - retval = swe_vis_limit_mag(tjd + d * direct, dgeo, datm, dobs, ObjectName, helflag, darr, serr); - if (retval == ERR) return ERR; - retval_sv = retval; - phot_scot_opic_sv = retval & SE_SCOTOPIC_FLAG; - for (i = 0, d = d0; i < ncnt; i++, d /= 10.0) { - while((retval = swe_vis_limit_mag(tjd + d * direct, dgeo, datm, dobs, ObjectName, helflag, darr, serr)) >= 0 - && darr[0] > darr[7]) { - tjd += d * direct; - retval_sv = retval; - phot_scot_opic_sv = retval & SE_SCOTOPIC_FLAG; - /* printf("%d: %f\n", direct, darr[8]); */ - } - } - /* printf("4: %f, %f/%f %f <-> %f\n", darr[8], darr[0], darr[7], tjd, phot_scot_opic_sv); */ - *tret = tjd; - /* if object disappears at setting, retval is -2, but we want it OK, and - * also suppress the warning "object is below local horizon" */ - *serr = '\0'; - if (retval >= 0) { - /* search for limit came to an end because change scotopic/photopic: */ - phot_scot_opic = (retval & SE_SCOTOPIC_FLAG); - if (phot_scot_opic_sv != phot_scot_opic) { - /* calling function writes warning into serr */ - return -2; - } - /* valid result found but it is close to the scotopic/photopic limit */ - if (retval_sv & SE_MIXEDOPIC_FLAG) { - return -2; - } - } - return OK; -} - -static int32 get_acronychal_day(double tjd, double *dgeo, double *datm, double *dobs, char *ObjectName, int32 helflag, int32 TypeEvent, double *thel, char *serr) { - double tret, tret_dark, darr[30], dtret; - /* x[6], xaz[6], alto, azio, alto_dark, azio_dark;*/ - int32 retval, is_rise_or_set, direct; - int32 ipl = DeterObject(ObjectName); - helflag |= SE_HELFLAG_VISLIM_PHOTOPIC; - /*int32 epheflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH);*/ - /* int32 iflag = epheflag | SEFLG_EQUATORIAL | SEFLG_TOPOCTR;*/ - if (TypeEvent == 3 || TypeEvent == 5) { - is_rise_or_set = SE_CALC_RISE; - /* tret = tjdc - 3; - if (ipl >= SE_MARS) - tret = tjdc - 3;*/ - direct = -1; - } else { - is_rise_or_set = SE_CALC_SET; - /*tret = tjdc + 3; - if (ipl >= SE_MARS) - tret = tjdc + 3;*/ - direct = 1; - } - dtret = 999; -#if 0 - while (fabs(dtret) > 0.5) { -#else - while (fabs(dtret) > 0.5 / 1440.0) { -#endif - tjd += 0.7 * direct; - if (direct < 0) tjd -= 1; - retval = my_rise_trans(tjd, ipl, ObjectName, is_rise_or_set, helflag, dgeo, datm, &tjd, serr); - if (retval == ERR) return ERR; - retval = swe_vis_limit_mag(tjd, dgeo, datm, dobs, ObjectName, helflag, darr, serr); - while(darr[0] < darr[7]) { - tjd += 10.0 / 1440.0 * -direct; - retval = swe_vis_limit_mag(tjd, dgeo, datm, dobs, ObjectName, helflag, darr, serr); - } - retval = time_limit_invisible(tjd, dgeo, datm, dobs, ObjectName, helflag | SE_HELFLAG_VISLIM_DARK, direct, &tret_dark, serr); - if (retval == ERR) return ERR; - retval = time_limit_invisible(tjd, dgeo, datm, dobs, ObjectName, helflag | SE_HELFLAG_VISLIM_NOMOON, direct, &tret, serr); - if (retval == ERR) return ERR; -#if 0 - if (azalt_cart(tret_dark, dgeo, datm, ObjectName, helflag, darr, serr) == ERR) - return ERR; - if (azalt_cart(tret, dgeo, datm, ObjectName, helflag, darr+6, serr) == ERR) - return ERR; - dtret = acos(swi_dot_prod_unit(darr+3, darr+9)) / DEGTORAD; -#else - dtret = fabs(tret - tret_dark); -#endif - } - if (azalt_cart(tret, dgeo, datm, "sun", helflag, darr, serr) == ERR) - return ERR; - *thel = tret; - if (darr[1] < -12) { - sprintf(serr, "acronychal rising/setting not available, %f", darr[1]); + *tjdret = tjd; return OK; - } else { - sprintf(serr, "solar altitude, %f", darr[1]); - } - return OK; } -static int32 get_heliacal_details(double tday, double *dgeo, double *datm, double *dobs, char *ObjectName, int32 TypeEvent, int32 helflag, double *dret, char *serr) +#if 0 + +/* works only for fixed stars */ +static int32 +get_asc_obl_with_sun_old(double tjd_start, int32 ipl, char *star, + int32 helflag, int32 TypeEvent, double *dgeo, + double *tjdret, char *serr) { - int32 i, retval, direct; - AS_BOOL optimum_undefined, limit_1_undefined, limit_2_undefined; - /* find next optimum visibility */ - optimum_undefined = FALSE; - retval = time_optimum_visibility(tday, dgeo, datm, dobs, ObjectName, helflag, &(dret[1]), serr); - if (retval == ERR) return ERR; - if (retval == -2) { - retval = OK; - optimum_undefined = TRUE; /* change photopic <-> scotopic vision */ - } - /* find moment of becoming visible */ - direct = 1; - if (TypeEvent == 1 || TypeEvent == 4) - direct = -1; - limit_1_undefined = FALSE; - retval = time_limit_invisible(tday, dgeo, datm, dobs, ObjectName, helflag, direct, &(dret[0]), serr); - if (retval == ERR) return ERR; - if (retval == -2) { - retval = OK; - limit_1_undefined = TRUE; /* change photopic <-> scotopic vision */ - } - /* find moment of end of visibility */ - direct *= -1; - limit_2_undefined = FALSE; - retval = time_limit_invisible(dret[1], dgeo, datm, dobs, ObjectName, helflag, direct, &(dret[2]), serr); - if (retval == ERR) return ERR; - if (retval == -2) { - retval = OK; - limit_2_undefined = TRUE; /* change photopic <-> scotopic vision */ - } - /* correct sequence of times: - * with event types 2 and 3 swap dret[0] and dret[2] */ - if (TypeEvent == 2 || TypeEvent == 3) { - tday = dret[2]; - dret[2] = dret[0]; - dret[0] = tday; - i = (int) limit_1_undefined; - limit_1_undefined = limit_2_undefined; - limit_2_undefined = (AS_BOOL) i; - } - /*if (retval == OK && dret[0] == dret[1]) */ - if (optimum_undefined || limit_1_undefined || limit_2_undefined) { - sprintf(serr, "return values ["); - if (limit_1_undefined) - strcat(serr, "0,"); - if (optimum_undefined) - strcat(serr, "1,"); - if (limit_2_undefined) - strcat(serr, "2,"); - strcat(serr, "] are uncertain due to change between photopic and scotopic vision"); - } - return OK; + int retval; + int32 epheflag = helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + double dsunpl = 1, tjd, daystep, dsunpl_save; + double dsynperiod = 367; + double dangsearch = 0; + AS_BOOL desc_obl = FALSE; + if (TypeEvent == 2 || TypeEvent == 3) + desc_obl = TRUE; + if (TypeEvent == 3 || TypeEvent == 4) + dangsearch = 180; + /* find date when sun and object have the same ascensio obliqua */ + daystep = dsynperiod; + tjd = tjd_start; + retval = + get_asc_obl_diff(tjd, ipl, star, epheflag, dgeo, desc_obl, &dsunpl, + serr); + if (retval != OK) /* retval may be ERR or -2 */ + return retval; + while (dsunpl < 359.99999) { + dsunpl_save = dsunpl; + daystep /= 2.0; + retval = + get_asc_obl_diff(tjd + daystep, ipl, star, epheflag, dgeo, + desc_obl, &dsunpl, serr); + if (retval != OK) /* retval may be ERR or -2 */ + return retval; + if (dsunpl > dsunpl_save) + tjd += daystep; + else + dsunpl = dsunpl_save; + } + *tjdret = tjd; + return OK; +} +#endif + +#if 0 + +/* works only for fixed stars */ +static int32 +get_asc_obl_acronychal(double tjd_start, int32 ipl, char *star, int32 helflag, + int32 TypeEvent, double *dgeo, double *tjdret, + char *serr) +{ + int retval; + int32 epheflag = helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + double dsunpl = 1, tjd, daystep, dsunpl_save; + double dsynperiod = 367; + double aosun, aopl; + AS_BOOL sun_desc = TRUE, obj_desc = FALSE; + daystep = dsynperiod; + tjd = tjd_start; + if (TypeEvent == 4) { + sun_desc = FALSE; + obj_desc = TRUE; + } + /* ascensio (descensio) obliqua of sun */ + retval = + get_asc_obl(tjd, SE_SUN, "", epheflag, dgeo, sun_desc, &aosun, serr); + if (retval != OK) /* retval may be ERR or -2 */ + return retval; + /* ascensio (descensio) obliqua of body */ + retval = + get_asc_obl(tjd, ipl, star, epheflag, dgeo, obj_desc, &aopl, serr); + if (retval != OK) /* retval may be ERR or -2 */ + return retval; + dsunpl = swe_degnorm(aosun - aopl + 180); + while (dsunpl < 359.99999) { + dsunpl_save = dsunpl; + daystep /= 2.0; + /* ascensio (descensio) obliqua of sun */ + retval = + get_asc_obl(tjd + daystep, SE_SUN, "", epheflag, dgeo, sun_desc, + &aosun, serr); + if (retval != OK) /* retval may be ERR or -2 */ + return retval; + /* ascensio (descensio) obliqua of body */ + retval = + get_asc_obl(tjd + daystep, ipl, star, epheflag, dgeo, obj_desc, + &aopl, serr); + if (retval != OK) /* retval may be ERR or -2 */ + return retval; + dsunpl = swe_degnorm(aosun - aopl + 180); + if (dsunpl > dsunpl_save) + tjd += daystep; + else + dsunpl = dsunpl_save; + } + *tjdret = tjd; + return OK; +} +#endif + +static int32 +get_heliacal_day(double tjd, double *dgeo, double *datm, double *dobs, + char *ObjectName, int32 helflag, int32 TypeEvent, + double *thel, char *serr) +{ + int32 is_rise_or_set = 0, ndays, retval, retval_old; + double direct_day = 0, direct_time = + 0, tfac, tend, daystep, tday, vdelta, tret; + double darr[30], vd, dmag; + int32 ipl = DeterObject(ObjectName); + /* + * find the day and minute on which the object becomes visible + */ + switch (TypeEvent) { + /* morning first */ + case 1: + is_rise_or_set = SE_CALC_RISE; + direct_day = 1; + direct_time = -1; + break; + /* evening last */ + case 2: + is_rise_or_set = SE_CALC_SET; + direct_day = -1; + direct_time = 1; + break; + /* evening first */ + case 3: + is_rise_or_set = SE_CALC_SET; + direct_day = 1; + direct_time = 1; + break; + /* morning last */ + case 4: + is_rise_or_set = SE_CALC_RISE; + direct_day = -1; + direct_time = -1; + break; + } + tfac = 1; + switch (ipl) { + case SE_MOON: + ndays = 6; + daystep = 1; + break; + case SE_MERCURY: + ndays = 60; + tjd -= 0 * direct_day; + daystep = 5; + tfac = 5; + break; + case SE_VENUS: + ndays = 300; + tjd -= 30 * direct_day; + daystep = 5; + if (TypeEvent >= 3) { + daystep = 15; + tfac = 3; + } + break; + case SE_MARS: + ndays = 400; + daystep = 15; + tfac = 5; + break; + case SE_SATURN: + ndays = 300; + daystep = 20; + tfac = 5; + break; + case -1: + ndays = 300; + if (call_swe_fixstar_mag(ObjectName, &dmag, serr) == ERR) + return ERR; + daystep = 15; + tfac = 10; + if (dmag > 2) { + daystep = 15; + } + if (dmag < 0) { + tfac = 3; + } + break; + default: + ndays = 300; + daystep = 15; + tfac = 3; + break; + } + tend = tjd + ndays * direct_day; + retval_old = -2; + for (tday = tjd; + (direct_day > 0 && tday < tend) || (direct_day < 0 && tday > tend); + tday += daystep * direct_day) { + vdelta = -100; + if ((retval = + my_rise_trans(tday, SE_SUN, "", is_rise_or_set, helflag, dgeo, + datm, &tret, serr)) == ERR) + return ERR; + /* sun does not rise: try next day */ + if (retval == -2) { + retval_old = retval; + continue; + } + retval = + swe_vis_limit_mag(tret, dgeo, datm, dobs, ObjectName, helflag, + darr, serr); + if (retval == ERR) + return ERR; +#if 1 + /* object has appeared above horizon: reduce daystep */ + if (retval_old == -2 && retval >= 0 && daystep > 1) { + retval_old = retval; + tday -= daystep * direct_day; + daystep = 1; + /* Note: beyond latitude 55N (?), Mars can have a morning last. + * If the period of visibility is less than 5 days, we may miss the + * event. I don't know if this happens */ + if (ipl >= SE_MARS || ipl == -1) + daystep = 5; + continue; + } + retval_old = retval; +#endif + /* object below horizon: try next day */ + if (retval == -2) + continue; + vdelta = darr[0] - darr[7]; + /* find minute of object's becoming visible */ + while (retval != -2 && (vd = darr[0] - darr[7]) < 0) { + if (vd < -1.0) + tret += 5.0 / 1440.0 * direct_time * tfac; + else if (vd < -0.5) + tret += 2.0 / 1440.0 * direct_time * tfac; + else if (vd < -0.1) + tret += 1.0 / 1440.0 * direct_time * tfac; + else + tret += 1.0 / 1440.0 * direct_time; + retval = + swe_vis_limit_mag(tret, dgeo, datm, dobs, ObjectName, helflag, + darr, serr); + if (retval == ERR) + return ERR; + } + vdelta = darr[0] - darr[7]; + /* object is visible, save time of appearance */ + if (vdelta > 0) { + if ((ipl >= SE_MARS || ipl == -1) && daystep > 1) { + tday -= daystep * direct_day; + daystep = 1; + } + else { + *thel = tret; + return OK; + } + } + } + sprintf(serr, "heliacal event does not happen"); + return -2; } -static int32 heliacal_ut_vis_lim(double tjd_start, double *dgeo, double *datm, double *dobs, char *ObjectName, int32 TypeEventIn, int32 helflag, double *dret, char *serr_ret) +#if 0 +static int32 +get_acronychal_day_new(double tjd, double *dgeo, double *datm, double *dobs, + char *ObjectName, int32 helflag, int32 TypeEvent, + double *thel, char *serr) { - int i; - double d, darr[10], direct = 1, tjd, tday; - int32 epheflag, retval = OK, helflag2; - int32 iflag, ipl; - int32 TypeEvent = TypeEventIn; - char serr[AS_MAXCH]; - for (i = 0; i < 10; i++) - dret[i] = 0; - *dret = tjd_start; - *serr = '\0'; - ipl = DeterObject(ObjectName); - epheflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - iflag = SEFLG_TOPOCTR | SEFLG_EQUATORIAL | epheflag; - if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) - iflag |= SEFLG_NONUT | SEFLG_TRUEPOS; - if (ipl == SE_MERCURY) - tjd = tjd_start - 30; - else - tjd = tjd_start - 50; /* -50 makes sure, that no event is missed, - * but may return an event before start date */ - helflag2 = helflag; - /*helflag2 &= ~SE_HELFLAG_HIGH_PRECISION;*/ - /* - * heliacal event - */ - if (ipl == SE_MERCURY || ipl == SE_VENUS || TypeEvent <= 2) { - if (ipl == -1) { - /* find date when star rises with sun (cosmic rising) */ - retval = get_asc_obl_with_sun(tjd, ipl, ObjectName, helflag, TypeEvent, 0, dgeo, &tjd, serr); - if (retval != OK) - goto swe_heliacal_err; /* retval may be -2 or ERR */ - } else { - /* find date of conjunction of object with sun */ - if ((retval = find_conjunct_sun(tjd, ipl, helflag, TypeEvent, &tjd, serr)) == ERR) - goto swe_heliacal_err; + double tjdc = tjd, tret, x[6], xaz[6], AltO = -10; + int32 retval, is_rise_or_set, iter_day; + int32 ipl = DeterObject(ObjectName); + int32 epheflag = helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + int32 iflag = epheflag | SEFLG_EQUATORIAL | SEFLG_TOPOCTR; + if ((retval = + my_rise_trans(tret, 0, ObjectName, SE_CALC_RISE, helflag, dgeo, datm, + &tret, serr)) == ERR) + return ERR; + trise = tret; + tret += + 0.01 + if ((retval = + my_rise_trans(tret, 0, ObjectName, SE_CALC_SET, helflag, dgeo, + datm, &tret, serr)) == ERR) + return ERR; + trise = tset; + + *thel = tret; + return OK; +} +#endif + +#if 0 +static int32 +get_acronychal_day_old(double tjd, double *dgeo, double *datm, double *dobs, + char *ObjectName, int32 helflag, int32 TypeEvent, + double *thel, char *serr) +{ + double tjdc = tjd, tret, x[6], xaz[6], AltO = -10; + int32 retval, is_rise_or_set, iter_day; + int32 ipl = DeterObject(ObjectName); + int32 epheflag = helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + int32 iflag = epheflag | SEFLG_EQUATORIAL | SEFLG_TOPOCTR; + if (TypeEvent == 3) { + is_rise_or_set = SE_CALC_SET; + tret = tjdc - 3; + if (ipl >= SE_MARS) + tret = tjdc - 3; + iter_day = 1; } - /* find the day and minute on which the object becomes visible */ - retval = get_heliacal_day(tjd, dgeo, datm, dobs, ObjectName, helflag2, TypeEvent, &tday, serr); - if (retval != OK) - goto swe_heliacal_err; - /* - * acronychal event - */ - } else { - if (1 || ipl == -1) { - /*retval = get_asc_obl_acronychal(tjd, ipl, ObjectName, helflag2, TypeEvent, dgeo, &tjd, serr);*/ - retval = get_asc_obl_with_sun(tjd, ipl, ObjectName, helflag, TypeEvent, 0, dgeo, &tjd, serr); - if (retval != OK) - goto swe_heliacal_err; - } else { - /* find date of conjunction of object with sun */ - if ((retval = find_conjunct_sun(tjd, ipl, helflag, TypeEvent, &tjd, serr)) == ERR) - goto swe_heliacal_err; + else { + is_rise_or_set = SE_CALC_RISE; + tret = tjdc + 3; + if (ipl >= SE_MARS) + tret = tjdc + 3; + iter_day = -1; } - tday = tjd; - retval = get_acronychal_day(tjd, dgeo, datm, dobs, ObjectName, helflag2, TypeEvent, &tday, serr); - if (retval != OK) - goto swe_heliacal_err; - } - dret[0] = tday; - if (!(helflag & SE_HELFLAG_NO_DETAILS)) { - /* more precise event times for - * - morning first, evening last - * - venus and mercury's evening first and morning last + while (AltO < 0) { + tret += 0.3 * iter_day; + if (iter_day == -1) + tret -= 1; + retval = + my_rise_trans(tret, SE_SUN, "", is_rise_or_set, helflag, dgeo, + datm, &tret, serr); + if (retval != OK) + return retval; + /* determine object's position */ + if (ipl == -1) + retval = + call_swe_fixstar(ObjectName, tret + swe_deltat(tret), iflag, + x, serr); + else + retval = swe_calc(tret + swe_deltat(tret), ipl, iflag, x, serr); + if (retval == ERR) + return ERR; + swe_azalt(tret, SE_EQU2HOR, dgeo, datm[0], datm[1], x, xaz); + AltO = xaz[2]; + } + *thel = tret; + return OK; +} +#endif + +static int32 +time_optimum_visibility(double tjd, double *dgeo, double *datm, double *dobs, + char *ObjectName, int32 helflag, double *tret, + char *serr) +{ + int32 retval, retval_sv, i; + double d, vl, darr[10], phot_scot_opic, phot_scot_opic_sv; + *tret = tjd; + retval = + swe_vis_limit_mag(tjd, dgeo, datm, dobs, ObjectName, helflag, darr, + serr); + if (retval == ERR) + return ERR; + retval_sv = retval; + vl = darr[0] - darr[7]; + phot_scot_opic_sv = retval & SE_SCOTOPIC_FLAG; + for (i = 0, d = 100.0 / 86400.0; i < 3; i++, d /= 10.0) { + while ((retval = + swe_vis_limit_mag(tjd - d, dgeo, datm, dobs, ObjectName, + helflag, darr, serr)) >= 0 + && darr[0] > darr[7] + && darr[0] - darr[7] > vl) { + tjd -= d; + vl = darr[0] - darr[7]; + retval_sv = retval; + phot_scot_opic_sv = retval & SE_SCOTOPIC_FLAG; + /* printf("1: %f\n", darr[8]); */ + } + if (retval == ERR) + return ERR; + while ((retval = + swe_vis_limit_mag(tjd + d, dgeo, datm, dobs, ObjectName, + helflag, darr, serr)) >= 0 + && darr[0] > darr[7] + && darr[0] - darr[7] > vl) { + tjd += d; + vl = darr[0] - darr[7]; + retval_sv = retval; + phot_scot_opic_sv = retval & SE_SCOTOPIC_FLAG; + /* printf("2: %f\n", darr[8]); */ + } + if (retval == ERR) + return ERR; + } + /* printf("3: %f <-> %f\n", darr[8], phot_scot_opic_sv); */ + *tret = tjd; + if (retval >= 0) { + /* search for optimum came to an end because change scotopic/photopic: */ + phot_scot_opic = (retval & SE_SCOTOPIC_FLAG); + if (phot_scot_opic_sv != phot_scot_opic) { + /* calling function writes warning into serr */ + return -2; + } + /* valid result found but it is close to the scotopic/photopic limit */ + if (retval_sv & SE_MIXEDOPIC_FLAG) { + return -2; + } + } + return OK; +} + +static int32 +time_limit_invisible(double tjd, double *dgeo, double *datm, double *dobs, + char *ObjectName, int32 helflag, int32 direct, + double *tret, char *serr) +{ + int32 retval, retval_sv, i, ncnt = 3; + double d = 0, darr[10], phot_scot_opic, phot_scot_opic_sv; + double d0 = 100.0 / 86400.0; + *tret = tjd; + if (strcmp(ObjectName, "moon") == 0) { + d0 *= 10; + ncnt = 4; + } + retval = + swe_vis_limit_mag(tjd + d * direct, dgeo, datm, dobs, ObjectName, + helflag, darr, serr); + if (retval == ERR) + return ERR; + retval_sv = retval; + phot_scot_opic_sv = retval & SE_SCOTOPIC_FLAG; + for (i = 0, d = d0; i < ncnt; i++, d /= 10.0) { + while ((retval = + swe_vis_limit_mag(tjd + d * direct, dgeo, datm, dobs, + ObjectName, helflag, darr, serr)) >= 0 + && darr[0] > darr[7]) { + tjd += d * direct; + retval_sv = retval; + phot_scot_opic_sv = retval & SE_SCOTOPIC_FLAG; + /* printf("%d: %f\n", direct, darr[8]); */ + } + } + /* printf("4: %f, %f/%f %f <-> %f\n", darr[8], darr[0], darr[7], tjd, phot_scot_opic_sv); */ + *tret = tjd; + /* if object disappears at setting, retval is -2, but we want it OK, and + * also suppress the warning "object is below local horizon" */ + *serr = '\0'; + if (retval >= 0) { + /* search for limit came to an end because change scotopic/photopic: */ + phot_scot_opic = (retval & SE_SCOTOPIC_FLAG); + if (phot_scot_opic_sv != phot_scot_opic) { + /* calling function writes warning into serr */ + return -2; + } + /* valid result found but it is close to the scotopic/photopic limit */ + if (retval_sv & SE_MIXEDOPIC_FLAG) { + return -2; + } + } + return OK; +} + +static int32 +get_acronychal_day(double tjd, double *dgeo, double *datm, double *dobs, + char *ObjectName, int32 helflag, int32 TypeEvent, + double *thel, char *serr) +{ + double tret, tret_dark, darr[30], dtret; + /* x[6], xaz[6], alto, azio, alto_dark, azio_dark; */ + int32 retval, is_rise_or_set, direct; + int32 ipl = DeterObject(ObjectName); + helflag |= SE_HELFLAG_VISLIM_PHOTOPIC; + /*int32 epheflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); */ + /* int32 iflag = epheflag | SEFLG_EQUATORIAL | SEFLG_TOPOCTR; */ + if (TypeEvent == 3 || TypeEvent == 5) { + is_rise_or_set = SE_CALC_RISE; + /* tret = tjdc - 3; + * if (ipl >= SE_MARS) + * tret = tjdc - 3; */ + direct = -1; + } + else { + is_rise_or_set = SE_CALC_SET; + /*tret = tjdc + 3; + * if (ipl >= SE_MARS) + * tret = tjdc + 3; */ + direct = 1; + } + dtret = 999; +#if 0 + while (fabs(dtret) > 0.5) { +#else + while (fabs(dtret) > 0.5 / 1440.0) { +#endif + tjd += 0.7 * direct; + if (direct < 0) + tjd -= 1; + retval = + my_rise_trans(tjd, ipl, ObjectName, is_rise_or_set, helflag, dgeo, + datm, &tjd, serr); + if (retval == ERR) + return ERR; + retval = + swe_vis_limit_mag(tjd, dgeo, datm, dobs, ObjectName, helflag, + darr, serr); + while (darr[0] < darr[7]) { + tjd += 10.0 / 1440.0 * -direct; + retval = + swe_vis_limit_mag(tjd, dgeo, datm, dobs, ObjectName, helflag, + darr, serr); + } + retval = + time_limit_invisible(tjd, dgeo, datm, dobs, ObjectName, + helflag | SE_HELFLAG_VISLIM_DARK, direct, + &tret_dark, serr); + if (retval == ERR) + return ERR; + retval = + time_limit_invisible(tjd, dgeo, datm, dobs, ObjectName, + helflag | SE_HELFLAG_VISLIM_NOMOON, direct, + &tret, serr); + if (retval == ERR) + return ERR; +#if 0 + if (azalt_cart(tret_dark, dgeo, datm, ObjectName, helflag, darr, serr) + == ERR) + return ERR; + if (azalt_cart(tret, dgeo, datm, ObjectName, helflag, darr + 6, serr) + == ERR) + return ERR; + dtret = acos(swi_dot_prod_unit(darr + 3, darr + 9)) / DEGTORAD; +#else + dtret = fabs(tret - tret_dark); +#endif + } + if (azalt_cart(tret, dgeo, datm, "sun", helflag, darr, serr) == ERR) + return ERR; + *thel = tret; + if (darr[1] < -12) { + sprintf(serr, "acronychal rising/setting not available, %f", darr[1]); + return OK; + } + else { + sprintf(serr, "solar altitude, %f", darr[1]); + } + return OK; +} + +static int32 +get_heliacal_details(double tday, double *dgeo, double *datm, double *dobs, + char *ObjectName, int32 TypeEvent, int32 helflag, + double *dret, char *serr) +{ + int32 i, retval, direct; + AS_BOOL optimum_undefined, limit_1_undefined, limit_2_undefined; + /* find next optimum visibility */ + optimum_undefined = FALSE; + retval = + time_optimum_visibility(tday, dgeo, datm, dobs, ObjectName, helflag, + &(dret[1]), serr); + if (retval == ERR) + return ERR; + if (retval == -2) { + retval = OK; + optimum_undefined = TRUE; /* change photopic <-> scotopic vision */ + } + /* find moment of becoming visible */ + direct = 1; + if (TypeEvent == 1 || TypeEvent == 4) + direct = -1; + limit_1_undefined = FALSE; + retval = + time_limit_invisible(tday, dgeo, datm, dobs, ObjectName, helflag, + direct, &(dret[0]), serr); + if (retval == ERR) + return ERR; + if (retval == -2) { + retval = OK; + limit_1_undefined = TRUE; /* change photopic <-> scotopic vision */ + } + /* find moment of end of visibility */ + direct *= -1; + limit_2_undefined = FALSE; + retval = + time_limit_invisible(dret[1], dgeo, datm, dobs, ObjectName, helflag, + direct, &(dret[2]), serr); + if (retval == ERR) + return ERR; + if (retval == -2) { + retval = OK; + limit_2_undefined = TRUE; /* change photopic <-> scotopic vision */ + } + /* correct sequence of times: + * with event types 2 and 3 swap dret[0] and dret[2] */ + if (TypeEvent == 2 || TypeEvent == 3) { + tday = dret[2]; + dret[2] = dret[0]; + dret[0] = tday; + i = (int)limit_1_undefined; + limit_1_undefined = limit_2_undefined; + limit_2_undefined = (AS_BOOL) i; + } + /*if (retval == OK && dret[0] == dret[1]) */ + if (optimum_undefined || limit_1_undefined || limit_2_undefined) { + sprintf(serr, "return values ["); + if (limit_1_undefined) + strcat(serr, "0,"); + if (optimum_undefined) + strcat(serr, "1,"); + if (limit_2_undefined) + strcat(serr, "2,"); + strcat(serr, + "] are uncertain due to change between photopic and scotopic vision"); + } + return OK; +} + +static int32 +heliacal_ut_vis_lim(double tjd_start, double *dgeo, double *datm, + double *dobs, char *ObjectName, int32 TypeEventIn, + int32 helflag, double *dret, char *serr_ret) +{ + int i; + double d, darr[10], direct = 1, tjd, tday; + int32 epheflag, retval = OK, helflag2; + int32 iflag, ipl; + int32 TypeEvent = TypeEventIn; + char serr[AS_MAXCH]; + for (i = 0; i < 10; i++) + dret[i] = 0; + *dret = tjd_start; + *serr = '\0'; + ipl = DeterObject(ObjectName); + epheflag = helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + iflag = SEFLG_TOPOCTR | SEFLG_EQUATORIAL | epheflag; + if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) + iflag |= SEFLG_NONUT | SEFLG_TRUEPOS; + if (ipl == SE_MERCURY) + tjd = tjd_start - 30; + else + tjd = tjd_start - 50; /* -50 makes sure, that no event is missed, + * but may return an event before start date */ + helflag2 = helflag; + /*helflag2 &= ~SE_HELFLAG_HIGH_PRECISION; */ + /* + * heliacal event */ if (ipl == SE_MERCURY || ipl == SE_VENUS || TypeEvent <= 2) { - retval = get_heliacal_details(tday, dgeo, datm, dobs, ObjectName, TypeEvent, helflag2, dret, serr); - if (retval == ERR) goto swe_heliacal_err; - } else if (0) { - if (TypeEvent == 4 || TypeEvent == 6) direct = -1; - for (i = 0, d = 100.0 / 86400.0; i < 3; i++, d /= 10.0) { - while((retval = swe_vis_limit_mag(*dret + d * direct, dgeo, datm, dobs, ObjectName, helflag, darr, serr)) == -2 || (retval >= 0 && darr[0] < darr[7])) { - *dret += d * direct; - } - } - /* the last time step must be added */ - if (retval == OK) - *dret += 1.0 / 86400.0 * direct; + if (ipl == -1) { + /* find date when star rises with sun (cosmic rising) */ + retval = + get_asc_obl_with_sun(tjd, ipl, ObjectName, helflag, TypeEvent, + 0, dgeo, &tjd, serr); + if (retval != OK) + goto swe_heliacal_err; /* retval may be -2 or ERR */ + } + else { + /* find date of conjunction of object with sun */ + if ((retval = + find_conjunct_sun(tjd, ipl, helflag, TypeEvent, &tjd, + serr)) == ERR) + goto swe_heliacal_err; + } + /* find the day and minute on which the object becomes visible */ + retval = + get_heliacal_day(tjd, dgeo, datm, dobs, ObjectName, helflag2, + TypeEvent, &tday, serr); + if (retval != OK) + goto swe_heliacal_err; + /* + * acronychal event + */ } - } /* if (1) */ + else { + if (1 || ipl == -1) { + /*retval = get_asc_obl_acronychal(tjd, ipl, ObjectName, helflag2, TypeEvent, dgeo, &tjd, serr); */ + retval = + get_asc_obl_with_sun(tjd, ipl, ObjectName, helflag, TypeEvent, + 0, dgeo, &tjd, serr); + if (retval != OK) + goto swe_heliacal_err; + } + else { + /* find date of conjunction of object with sun */ + if ((retval = + find_conjunct_sun(tjd, ipl, helflag, TypeEvent, &tjd, + serr)) == ERR) + goto swe_heliacal_err; + } + tday = tjd; + retval = + get_acronychal_day(tjd, dgeo, datm, dobs, ObjectName, helflag2, + TypeEvent, &tday, serr); + if (retval != OK) + goto swe_heliacal_err; + } + dret[0] = tday; + if (!(helflag & SE_HELFLAG_NO_DETAILS)) { + /* more precise event times for + * - morning first, evening last + * - venus and mercury's evening first and morning last + */ + if (ipl == SE_MERCURY || ipl == SE_VENUS || TypeEvent <= 2) { + retval = + get_heliacal_details(tday, dgeo, datm, dobs, ObjectName, + TypeEvent, helflag2, dret, serr); + if (retval == ERR) + goto swe_heliacal_err; + } + else if (0) { + if (TypeEvent == 4 || TypeEvent == 6) + direct = -1; + for (i = 0, d = 100.0 / 86400.0; i < 3; i++, d /= 10.0) { + while ((retval = + swe_vis_limit_mag(*dret + d * direct, dgeo, datm, + dobs, ObjectName, helflag, darr, + serr)) == -2 || (retval >= 0 + && darr[0] < + darr[7])) { + *dret += d * direct; + } + } + /* the last time step must be added */ + if (retval == OK) + *dret += 1.0 / 86400.0 * direct; + } + } /* if (1) */ swe_heliacal_err: - if (serr_ret != NULL && *serr != '\0') - strcpy(serr_ret, serr); - return retval; + if (serr_ret != NULL && *serr != '\0') + strcpy(serr_ret, serr); + return retval; } /*###################################################################*/ -static int32 moon_event_vis_lim(double tjdstart, double *dgeo, double *datm, double *dobs, int32 TypeEvent, int32 helflag, double *dret, char *serr_ret) +static int32 +moon_event_vis_lim(double tjdstart, double *dgeo, double *datm, double *dobs, + int32 TypeEvent, int32 helflag, double *dret, + char *serr_ret) { - double tjd, trise; - char serr[AS_MAXCH]; - char ObjectName[30]; - int32 iflag, ipl, retval, helflag2, direct; - int32 epheflag = helflag & (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH); - dret[0] = tjdstart; /* will be returned in error case */ - if (TypeEvent == 1 || TypeEvent == 2) { - if (serr != NULL) - strcpy(serr, "error: the moon has no morning first or evening last"); - return ERR; - } - strcpy(ObjectName, "moon"); - ipl = SE_MOON; - iflag = SEFLG_TOPOCTR | SEFLG_EQUATORIAL | epheflag; - if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) - iflag |= SEFLG_NONUT|SEFLG_TRUEPOS; - helflag2 = helflag; - helflag2 &= ~SE_HELFLAG_HIGH_PRECISION; - /* check Synodic/phase Period */ - tjd = tjdstart - 30; /* -50 makes sure, that no event is missed, - * but may return an event before start date */ - if ((retval = find_conjunct_sun(tjd, ipl, helflag, TypeEvent, &tjd, serr)) == ERR) - return ERR; - /* find the day and minute on which the object becomes visible */ - retval = get_heliacal_day(tjd, dgeo, datm, dobs, ObjectName, helflag2, TypeEvent, &tjd, serr); - if (retval != OK) - goto moon_event_err; - dret[0] = tjd; - /* find next optimum visibility */ - retval = time_optimum_visibility(tjd, dgeo, datm, dobs, ObjectName, helflag, &tjd, serr); - if (retval == ERR) goto moon_event_err; - dret[1] = tjd; - /* find moment of becoming visible */ - /* Note: The on the day of fist light the moon may become visible - * already during day. It also may appear during day, disappear again - * and then reappear after sunset */ - direct = 1; - if (TypeEvent == 4) - direct = -1; - retval = time_limit_invisible(tjd, dgeo, datm, dobs, ObjectName, helflag, direct, &tjd, serr); - if (retval == ERR) goto moon_event_err; - dret[2] = tjd; - /* find moment of end of visibility */ - direct *= -1; - retval = time_limit_invisible(dret[1], dgeo, datm, dobs, ObjectName, helflag, direct, &tjd, serr); - dret[0] = tjd; - if (retval == ERR) goto moon_event_err; - /* if the moon is visible before sunset, we return sunset as start time */ - if (TypeEvent == 3) { - if ((retval = my_rise_trans(tjd, SE_SUN, "", SE_CALC_SET, helflag, dgeo, datm, &trise, serr)) == ERR) - return ERR; - if (trise < dret[1]) { - dret[0] = trise; - /* do not warn, it happens too often */ - /*strcpy(serr, "start time given is sunset, but moon is observable before that");*/ + double tjd, trise; + char serr[AS_MAXCH]; + char ObjectName[30]; + int32 iflag, ipl, retval, helflag2, direct; + int32 epheflag = helflag & (SEFLG_JPLEPH | SEFLG_SWIEPH | SEFLG_MOSEPH); + dret[0] = tjdstart; /* will be returned in error case */ + if (TypeEvent == 1 || TypeEvent == 2) { + if (serr != NULL) + strcpy(serr, + "error: the moon has no morning first or evening last"); + return ERR; } - /* if the moon is visible after sunrise, we return sunrise as end time */ - } else { - if ((retval = my_rise_trans(dret[1], SE_SUN, "", SE_CALC_RISE, helflag, dgeo, datm, &trise, serr)) == ERR) - return ERR; - if (dret[0] > trise) { - dret[0] = trise; - /* do not warn, it happens too often */ - /*strcpy(serr, "end time given is sunrise, but moon is observable after that");*/ - } - } - /* correct order of the three times: */ - if (TypeEvent == 4) { - tjd = dret[0]; - dret[0] = dret[2]; + strcpy(ObjectName, "moon"); + ipl = SE_MOON; + iflag = SEFLG_TOPOCTR | SEFLG_EQUATORIAL | epheflag; + if (!(helflag & SE_HELFLAG_HIGH_PRECISION)) + iflag |= SEFLG_NONUT | SEFLG_TRUEPOS; + helflag2 = helflag; + helflag2 &= ~SE_HELFLAG_HIGH_PRECISION; + /* check Synodic/phase Period */ + tjd = tjdstart - 30; /* -50 makes sure, that no event is missed, + * but may return an event before start date */ + if ((retval = + find_conjunct_sun(tjd, ipl, helflag, TypeEvent, &tjd, serr)) == ERR) + return ERR; + /* find the day and minute on which the object becomes visible */ + retval = + get_heliacal_day(tjd, dgeo, datm, dobs, ObjectName, helflag2, + TypeEvent, &tjd, serr); + if (retval != OK) + goto moon_event_err; + dret[0] = tjd; + /* find next optimum visibility */ + retval = + time_optimum_visibility(tjd, dgeo, datm, dobs, ObjectName, helflag, + &tjd, serr); + if (retval == ERR) + goto moon_event_err; + dret[1] = tjd; + /* find moment of becoming visible */ + /* Note: The on the day of fist light the moon may become visible + * already during day. It also may appear during day, disappear again + * and then reappear after sunset */ + direct = 1; + if (TypeEvent == 4) + direct = -1; + retval = + time_limit_invisible(tjd, dgeo, datm, dobs, ObjectName, helflag, + direct, &tjd, serr); + if (retval == ERR) + goto moon_event_err; dret[2] = tjd; - } + /* find moment of end of visibility */ + direct *= -1; + retval = + time_limit_invisible(dret[1], dgeo, datm, dobs, ObjectName, helflag, + direct, &tjd, serr); + dret[0] = tjd; + if (retval == ERR) + goto moon_event_err; + /* if the moon is visible before sunset, we return sunset as start time */ + if (TypeEvent == 3) { + if ((retval = + my_rise_trans(tjd, SE_SUN, "", SE_CALC_SET, helflag, dgeo, datm, + &trise, serr)) == ERR) + return ERR; + if (trise < dret[1]) { + dret[0] = trise; + /* do not warn, it happens too often */ + /*strcpy(serr, "start time given is sunset, but moon is observable before that"); */ + } + /* if the moon is visible after sunrise, we return sunrise as end time */ + } + else { + if ((retval = + my_rise_trans(dret[1], SE_SUN, "", SE_CALC_RISE, helflag, dgeo, + datm, &trise, serr)) == ERR) + return ERR; + if (dret[0] > trise) { + dret[0] = trise; + /* do not warn, it happens too often */ + /*strcpy(serr, "end time given is sunrise, but moon is observable after that"); */ + } + } + /* correct order of the three times: */ + if (TypeEvent == 4) { + tjd = dret[0]; + dret[0] = dret[2]; + dret[2] = tjd; + } moon_event_err: - if (serr_ret != NULL && *serr != '\0') - strcpy(serr_ret, serr); - return retval; + if (serr_ret != NULL && *serr != '\0') + strcpy(serr_ret, serr); + return retval; } -static int32 MoonEventJDut(double JDNDaysUTStart, double *dgeo, double *datm, double *dobs, int32 TypeEvent, int32 helflag, double *dret, char *serr) +static int32 +MoonEventJDut(double JDNDaysUTStart, double *dgeo, double *datm, double *dobs, + int32 TypeEvent, int32 helflag, double *dret, char *serr) { - int32 avkind = helflag & SE_HELFLAG_AVKIND; - if (avkind) - return moon_event_arc_vis(JDNDaysUTStart, dgeo, datm, dobs, TypeEvent, helflag, dret, serr); - else - return moon_event_vis_lim(JDNDaysUTStart, dgeo, datm, dobs, TypeEvent, helflag, dret, serr); + int32 avkind = helflag & SE_HELFLAG_AVKIND; + if (avkind) + return moon_event_arc_vis(JDNDaysUTStart, dgeo, datm, dobs, TypeEvent, + helflag, dret, serr); + else + return moon_event_vis_lim(JDNDaysUTStart, dgeo, datm, dobs, TypeEvent, + helflag, dret, serr); } -static int32 heliacal_ut(double JDNDaysUTStart, double *dgeo, double *datm, double *dobs, char *ObjectName, int32 TypeEventIn, int32 helflag, double *dret, char *serr_ret) +static int32 +heliacal_ut(double JDNDaysUTStart, double *dgeo, double *datm, double *dobs, + char *ObjectName, int32 TypeEventIn, int32 helflag, double *dret, + char *serr_ret) { - int32 avkind = helflag & SE_HELFLAG_AVKIND; - if (avkind) - return heliacal_ut_arc_vis(JDNDaysUTStart, dgeo, datm, dobs, ObjectName, TypeEventIn, helflag, dret, serr_ret); - else - return heliacal_ut_vis_lim(JDNDaysUTStart, dgeo, datm, dobs, ObjectName, TypeEventIn, helflag, dret, serr_ret); + int32 avkind = helflag & SE_HELFLAG_AVKIND; + if (avkind) + return heliacal_ut_arc_vis(JDNDaysUTStart, dgeo, datm, dobs, + ObjectName, TypeEventIn, helflag, dret, + serr_ret); + else + return heliacal_ut_vis_lim(JDNDaysUTStart, dgeo, datm, dobs, + ObjectName, TypeEventIn, helflag, dret, + serr_ret); } /*' Magn [-] @@ -3316,120 +4047,143 @@ static int32 heliacal_ut(double JDNDaysUTStart, double *dgeo, double *datm, doub ' dret output: time (tjd_ut) of heliacal event ' see http://www.iol.ie/~geniet/eng/atmoastroextinction.htm */ -int32 FAR PASCAL_CONV swe_heliacal_ut(double JDNDaysUTStart, double *dgeo, double *datm, double *dobs, char *ObjectNameIn, int32 TypeEvent, int32 helflag, double *dret, char *serr_ret) +int32 FAR PASCAL_CONV +swe_heliacal_ut(double JDNDaysUTStart, double *dgeo, double *datm, + double *dobs, char *ObjectNameIn, int32 TypeEvent, + int32 helflag, double *dret, char *serr_ret) { - int32 retval, Planet, itry; - char ObjectName[AS_MAXCH], serr[AS_MAXCH], s[AS_MAXCH]; - double tjd0 = JDNDaysUTStart, tjd, dsynperiod, tjdmax, tadd; - int32 MaxCountSynodicPeriod = MAX_COUNT_SYNPER; - char *sevent[7] = {"", "morning first", "evening last", "evening first", "morning last", "acronychal rising", "acronychal setting"}; - if (helflag & SE_HELFLAG_LONG_SEARCH) - MaxCountSynodicPeriod = MAX_COUNT_SYNPER_MAX; + int32 retval, Planet, itry; + char ObjectName[AS_MAXCH], serr[AS_MAXCH], s[AS_MAXCH]; + double tjd0 = JDNDaysUTStart, tjd, dsynperiod, tjdmax, tadd; + int32 MaxCountSynodicPeriod = MAX_COUNT_SYNPER; + char *sevent[7] = { "", "morning first", "evening last", "evening first", + "morning last", "acronychal rising", "acronychal setting" + }; + if (helflag & SE_HELFLAG_LONG_SEARCH) + MaxCountSynodicPeriod = MAX_COUNT_SYNPER_MAX; + /* if (helflag & SE_HELFLAG_SEARCH_1_PERIOD) MaxCountSynodicPeriod = 1; */ - *serr = '\0'; - if (serr_ret != NULL) - *serr_ret = '\0'; - /* note, the fixed stars functions rewrite the star name. The input string - may be too short, so we have to make sure we have enough space */ - strcpy_VBsafe(ObjectName, ObjectNameIn); - default_heliacal_parameters(datm, dgeo, dobs, helflag); - swe_set_topo(dgeo[0], dgeo[1], dgeo[2]); - Planet = DeterObject(ObjectName); - /* - * Moon events - */ - if (Planet == SE_MOON) { - if (TypeEvent == 1 || TypeEvent == 2) { - if (serr_ret != NULL) - sprintf(serr_ret, "%s (event type %d) does not exist for the moon\n", sevent[TypeEvent], TypeEvent); - return ERR; + *serr = '\0'; + if (serr_ret != NULL) + *serr_ret = '\0'; + /* note, the fixed stars functions rewrite the star name. The input string + * may be too short, so we have to make sure we have enough space */ + strcpy_VBsafe(ObjectName, ObjectNameIn); + default_heliacal_parameters(datm, dgeo, dobs, helflag); + swe_set_topo(dgeo[0], dgeo[1], dgeo[2]); + Planet = DeterObject(ObjectName); + /* + * Moon events + */ + if (Planet == SE_MOON) { + if (TypeEvent == 1 || TypeEvent == 2) { + if (serr_ret != NULL) + sprintf(serr_ret, + "%s (event type %d) does not exist for the moon\n", + sevent[TypeEvent], TypeEvent); + return ERR; + } + tjd = tjd0; + retval = + MoonEventJDut(tjd, dgeo, datm, dobs, TypeEvent, helflag, dret, + serr); + while (retval != -2 && *dret < tjd0) { + tjd += 15; + *serr = '\0'; + retval = + MoonEventJDut(tjd, dgeo, datm, dobs, TypeEvent, helflag, dret, + serr); + } + if (serr_ret != NULL && *serr != '\0') + strcpy(serr_ret, serr); + return retval; } + /* + * planets and fixed stars + */ + if (!(helflag & SE_HELFLAG_AVKIND)) { + if (Planet == -1 || Planet >= SE_MARS) { + if (TypeEvent == 3 || TypeEvent == 4) { + if (serr_ret != NULL) { + if (Planet == -1) + strcpy(s, ObjectName); + else + swe_get_planet_name(Planet, s); + sprintf(serr_ret, + "%s (event type %d) does not exist for %s\n", + sevent[TypeEvent], TypeEvent, s); + } + return ERR; + } + } + } + /* arcus visionis method: set the TypeEvent for acronychal events */ + if (helflag & SE_HELFLAG_AVKIND) { + if (Planet == -1 || Planet >= SE_MARS) { + if (TypeEvent == SE_ACRONYCHAL_RISING) + TypeEvent = 3; + if (TypeEvent == SE_ACRONYCHAL_SETTING) + TypeEvent = 4; + } + /* acronychal rising and setting (cosmic setting) are ill-defined. + * We do not calculate them with the "visibility limit method" */ + } + else if (1) { + if (TypeEvent == SE_ACRONYCHAL_RISING + || TypeEvent == SE_ACRONYCHAL_SETTING) { + if (serr_ret != NULL) { + if (Planet == -1) + strcpy(s, ObjectName); + else + swe_get_planet_name(Planet, s); + sprintf(serr_ret, + "%s (event type %d) is not provided for %s\n", + sevent[TypeEvent], TypeEvent, s); + } + return ERR; + } + } + dsynperiod = get_synodic_period(Planet); + tjdmax = tjd0 + dsynperiod * MaxCountSynodicPeriod; + tadd = dsynperiod * 0.6; + if (Planet == SE_MERCURY) + tadd = 30; + /* + * this is the outer loop over n synodic periods + */ tjd = tjd0; - retval = MoonEventJDut(tjd, dgeo, datm, dobs, TypeEvent, helflag, dret, serr); - while (retval != -2 && *dret < tjd0) { - tjd += 15; - *serr = '\0'; - retval = MoonEventJDut(tjd, dgeo, datm, dobs, TypeEvent, helflag, dret, serr); + retval = -2; /* indicates that another synodic period has to be done */ + for (itry = 0; tjd < tjdmax && retval == -2; itry++, tjd += tadd) { + *serr = '\0'; + retval = + heliacal_ut(tjd, dgeo, datm, dobs, ObjectName, TypeEvent, helflag, + dret, serr); + /* if resulting event date < start date for search (tjd0): retry starting + * from half a period later. The event must be found now, unless there + * is none, as is often the case with Mercury */ + while (retval != -2 && *dret < tjd0) { + tjd += tadd; + *serr = '\0'; + retval = + heliacal_ut(tjd, dgeo, datm, dobs, ObjectName, TypeEvent, + helflag, dret, serr); + } + } + /* + * no event was found within MaxCountSynodicPeriod, return error + */ + if ((helflag & SE_HELFLAG_SEARCH_1_PERIOD) + && (retval == -2 || dret[0] > tjd0 + dsynperiod * 1.5)) { + strcpy(serr, "no heliacal date found within this synodic period"); + retval = -2; + } + else if (retval == -2) { + sprintf(serr, "no heliacal date found within %d synodic periods", + MaxCountSynodicPeriod); + retval = ERR; } if (serr_ret != NULL && *serr != '\0') - strcpy(serr_ret, serr); + strcpy(serr_ret, serr); return retval; - } - /* - * planets and fixed stars - */ - if (!(helflag & SE_HELFLAG_AVKIND)) { - if (Planet == -1 || Planet >= SE_MARS) { - if (TypeEvent == 3 || TypeEvent == 4) { - if (serr_ret != NULL) { - if (Planet == -1) - strcpy(s, ObjectName); - else - swe_get_planet_name(Planet, s); - sprintf(serr_ret, "%s (event type %d) does not exist for %s\n", sevent[TypeEvent], TypeEvent, s); - } - return ERR; - } - } - } - /* arcus visionis method: set the TypeEvent for acronychal events */ - if (helflag & SE_HELFLAG_AVKIND) { - if (Planet == -1 || Planet >= SE_MARS) { - if (TypeEvent == SE_ACRONYCHAL_RISING) - TypeEvent = 3; - if (TypeEvent == SE_ACRONYCHAL_SETTING) - TypeEvent = 4; - } - /* acronychal rising and setting (cosmic setting) are ill-defined. - * We do not calculate them with the "visibility limit method" */ - } else if (1) { - if (TypeEvent == SE_ACRONYCHAL_RISING || TypeEvent == SE_ACRONYCHAL_SETTING) { - if (serr_ret != NULL) { - if (Planet == -1) - strcpy(s, ObjectName); - else - swe_get_planet_name(Planet, s); - sprintf(serr_ret, "%s (event type %d) is not provided for %s\n", sevent[TypeEvent], TypeEvent, s); - } - return ERR; - } - } - dsynperiod = get_synodic_period(Planet); - tjdmax = tjd0 + dsynperiod * MaxCountSynodicPeriod; - tadd = dsynperiod * 0.6; - if (Planet == SE_MERCURY) - tadd = 30; - /* - * this is the outer loop over n synodic periods - */ - tjd = tjd0; - retval = -2; /* indicates that another synodic period has to be done */ - for (itry = 0; - tjd < tjdmax && retval == -2; - itry++, tjd += tadd) { - *serr = '\0'; - retval = heliacal_ut(tjd, dgeo, datm, dobs, ObjectName, TypeEvent, helflag, dret, serr); - /* if resulting event date < start date for search (tjd0): retry starting - * from half a period later. The event must be found now, unless there - * is none, as is often the case with Mercury */ - while (retval != -2 && *dret < tjd0) { - tjd += tadd; - *serr = '\0'; - retval = heliacal_ut(tjd, dgeo, datm, dobs, ObjectName, TypeEvent, helflag, dret, serr); - } - } - /* - * no event was found within MaxCountSynodicPeriod, return error - */ - if ((helflag & SE_HELFLAG_SEARCH_1_PERIOD) && (retval == -2 || dret[0] > tjd0 + dsynperiod * 1.5)) { - strcpy(serr, "no heliacal date found within this synodic period"); - retval = -2; - } else if (retval == -2) { - sprintf(serr, "no heliacal date found within %d synodic periods", MaxCountSynodicPeriod); - retval = ERR; - } - if (serr_ret != NULL && *serr != '\0') - strcpy(serr_ret, serr); - return retval; } diff --git a/swe/src/swehouse.c b/swe/src/swehouse.c index 930b18f..949be26 100644 --- a/swe/src/swehouse.c +++ b/swe/src/swehouse.c @@ -5,6 +5,7 @@ module swehouse.c house and (simple) aspect calculation ************************************************************/ + /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -70,33 +71,17 @@ house and (simple) aspect calculation static double Asc1(double, double, double, double); static double Asc2(double, double, double, double); -static int CalcH( - double th, double fi, double ekl, char hsy, - int iteration_count, struct houses *hsp ); -static int sidereal_houses_ecl_t0(double tjde, - double armc, - double eps, - double *nutlo, - double lat, - int hsys, - double *cusp, - double *ascmc); -static int sidereal_houses_trad(double tjde, - double armc, - double eps, - double nutl, - double lat, - int hsys, - double *cusp, - double *ascmc); -static int sidereal_houses_ssypl(double tjde, - double armc, - double eps, - double *nutlo, - double lat, - int hsys, - double *cusp, - double *ascmc); +static int CalcH(double th, double fi, double ekl, char hsy, + int iteration_count, struct houses *hsp); +static int sidereal_houses_ecl_t0(double tjde, double armc, double eps, + double *nutlo, double lat, int hsys, + double *cusp, double *ascmc); +static int sidereal_houses_trad(double tjde, double armc, double eps, + double nutl, double lat, int hsys, + double *cusp, double *ascmc); +static int sidereal_houses_ssypl(double tjde, double armc, double eps, + double *nutlo, double lat, int hsys, + double *cusp, double *ascmc); /* housasp.c * cusps are returned in double cusp[13], @@ -112,40 +97,41 @@ static int sidereal_houses_ssypl(double tjde, * ascmc[6] = coasc2 * "co-ascendant" (M. Munkasey) * * ascmc[7] = polasc * "polar ascendant" (M. Munkasey) * */ -int FAR PASCAL_CONV swe_houses(double tjd_ut, - double geolat, - double geolon, - int hsys, - double *cusp, - double *ascmc) +int FAR PASCAL_CONV +swe_houses(double tjd_ut, double geolat, double geolon, int hsys, + double *cusp, double *ascmc) { - int i, retc = 0; - double armc, eps, nutlo[2]; - double tjde = tjd_ut + swe_deltat(tjd_ut); - eps = swi_epsiln(tjde) * RADTODEG; - swi_nutation(tjde, nutlo); - for (i = 0; i < 2; i++) - nutlo[i] *= RADTODEG; - armc = swe_degnorm(swe_sidtime0(tjd_ut, eps + nutlo[1], nutlo[0]) * 15 + geolon); + int i, retc = 0; + double armc, eps, nutlo[2]; + double tjde = tjd_ut + swe_deltat(tjd_ut); + eps = swi_epsiln(tjde) * RADTODEG; + swi_nutation(tjde, nutlo); + for (i = 0; i < 2; i++) + nutlo[i] *= RADTODEG; + armc = + swe_degnorm(swe_sidtime0(tjd_ut, eps + nutlo[1], nutlo[0]) * 15 + + geolon); #ifdef TRACE - swi_open_trace(NULL); - if (swi_trace_count <= TRACE_COUNT_MAX) { - if (swi_fp_trace_c != NULL) { - fputs("\n/*SWE_HOUSES*/\n", swi_fp_trace_c); - fprintf(swi_fp_trace_c, "#if 0\n"); - fprintf(swi_fp_trace_c, " tjd = %.9f;", tjd_ut); - fprintf(swi_fp_trace_c, " geolon = %.9f;", geolon); - fprintf(swi_fp_trace_c, " geolat = %.9f;", geolat); - fprintf(swi_fp_trace_c, " hsys = %d;\n", hsys); - fprintf(swi_fp_trace_c, " retc = swe_houses(tjd, geolat, geolon, hsys, cusp, ascmc);\n"); - fprintf(swi_fp_trace_c, " /* swe_houses calls swe_houses_armc as follows: */\n"); - fprintf(swi_fp_trace_c, "#endif\n"); - fflush(swi_fp_trace_c); + swi_open_trace(NULL); + if (swi_trace_count <= TRACE_COUNT_MAX) { + if (swi_fp_trace_c != NULL) { + fputs("\n/*SWE_HOUSES*/\n", swi_fp_trace_c); + fprintf(swi_fp_trace_c, "#if 0\n"); + fprintf(swi_fp_trace_c, " tjd = %.9f;", tjd_ut); + fprintf(swi_fp_trace_c, " geolon = %.9f;", geolon); + fprintf(swi_fp_trace_c, " geolat = %.9f;", geolat); + fprintf(swi_fp_trace_c, " hsys = %d;\n", hsys); + fprintf(swi_fp_trace_c, + " retc = swe_houses(tjd, geolat, geolon, hsys, cusp, ascmc);\n"); + fprintf(swi_fp_trace_c, + " /* swe_houses calls swe_houses_armc as follows: */\n"); + fprintf(swi_fp_trace_c, "#endif\n"); + fflush(swi_fp_trace_c); + } } - } #endif - retc = swe_houses_armc(armc, geolat, eps + nutlo[1], hsys, cusp, ascmc); - return retc; + retc = swe_houses_armc(armc, geolat, eps + nutlo[1], hsys, cusp, ascmc); + return retc; } /* housasp.c @@ -162,66 +148,75 @@ int FAR PASCAL_CONV swe_houses(double tjd_ut, * ascmc[6] = coasc2 * "co-ascendant" (M. Munkasey) * * ascmc[7] = polasc * "polar ascendant" (M. Munkasey) * */ -int FAR PASCAL_CONV swe_houses_ex(double tjd_ut, - int32 iflag, - double geolat, - double geolon, - int hsys, - double *cusp, - double *ascmc) +int FAR PASCAL_CONV +swe_houses_ex(double tjd_ut, int32 iflag, double geolat, double geolon, + int hsys, double *cusp, double *ascmc) { - int i, retc = 0; - double armc, eps_mean, nutlo[2]; - double tjde = tjd_ut + swe_deltat(tjd_ut); - struct sid_data *sip = &swed.sidd; - int ito; - if (toupper(hsys) == 'G') - ito = 36; - else - ito = 12; - if ((iflag & SEFLG_SIDEREAL) && !swed.ayana_is_set) - swe_set_sid_mode(SE_SIDM_FAGAN_BRADLEY, 0, 0); - eps_mean = swi_epsiln(tjde) * RADTODEG; - swi_nutation(tjde, nutlo); - for (i = 0; i < 2; i++) - nutlo[i] *= RADTODEG; -#ifdef TRACE - swi_open_trace(NULL); - if (swi_trace_count <= TRACE_COUNT_MAX) { - if (swi_fp_trace_c != NULL) { - fputs("\n/*SWE_HOUSES_EX*/\n", swi_fp_trace_c); - fprintf(swi_fp_trace_c, "#if 0\n"); - fprintf(swi_fp_trace_c, " tjd = %.9f;", tjd_ut); - fprintf(swi_fp_trace_c, " iflag = %d;\n", iflag); - fprintf(swi_fp_trace_c, " geolon = %.9f;", geolon); - fprintf(swi_fp_trace_c, " geolat = %.9f;", geolat); - fprintf(swi_fp_trace_c, " hsys = %d;\n", hsys); - fprintf(swi_fp_trace_c, " retc = swe_houses_ex(tjd, iflag, geolat, geolon, hsys, cusp, ascmc);\n"); - fprintf(swi_fp_trace_c, " /* swe_houses calls swe_houses_armc as follows: */\n"); - fprintf(swi_fp_trace_c, "#endif\n"); - fflush(swi_fp_trace_c); - } - } -#endif - /*houses_to_sidereal(tjde, geolat, hsys, eps, cusp, ascmc, iflag);*/ - armc = swe_degnorm(swe_sidtime0(tjd_ut, eps_mean + nutlo[1], nutlo[0]) * 15 + geolon); - if (iflag & SEFLG_SIDEREAL) { - if (sip->sid_mode & SE_SIDBIT_ECL_T0) - retc = sidereal_houses_ecl_t0(tjde, armc, eps_mean + nutlo[1], nutlo, geolat, hsys, cusp, ascmc); - else if (sip->sid_mode & SE_SIDBIT_SSY_PLANE) - retc = sidereal_houses_ssypl(tjde, armc, eps_mean + nutlo[1], nutlo, geolat, hsys, cusp, ascmc); + int i, retc = 0; + double armc, eps_mean, nutlo[2]; + double tjde = tjd_ut + swe_deltat(tjd_ut); + struct sid_data *sip = &swed.sidd; + int ito; + if (toupper(hsys) == 'G') + ito = 36; else - retc = sidereal_houses_trad(tjde, armc, eps_mean + nutlo[1], nutlo[0], geolat, hsys, cusp, ascmc); - } else { - retc = swe_houses_armc(armc, geolat, eps_mean + nutlo[1], hsys, cusp, ascmc); - } - if (iflag & SEFLG_RADIANS) { - for (i = 1; i <= ito; i++) - cusp[i] *= DEGTORAD; - for (i = 0; i < SE_NASCMC; i++) - ascmc[i] *= DEGTORAD; - } - return retc; + ito = 12; + if ((iflag & SEFLG_SIDEREAL) && !swed.ayana_is_set) + swe_set_sid_mode(SE_SIDM_FAGAN_BRADLEY, 0, 0); + eps_mean = swi_epsiln(tjde) * RADTODEG; + swi_nutation(tjde, nutlo); + for (i = 0; i < 2; i++) + nutlo[i] *= RADTODEG; +#ifdef TRACE + swi_open_trace(NULL); + if (swi_trace_count <= TRACE_COUNT_MAX) { + if (swi_fp_trace_c != NULL) { + fputs("\n/*SWE_HOUSES_EX*/\n", swi_fp_trace_c); + fprintf(swi_fp_trace_c, "#if 0\n"); + fprintf(swi_fp_trace_c, " tjd = %.9f;", tjd_ut); + fprintf(swi_fp_trace_c, " iflag = %d;\n", iflag); + fprintf(swi_fp_trace_c, " geolon = %.9f;", geolon); + fprintf(swi_fp_trace_c, " geolat = %.9f;", geolat); + fprintf(swi_fp_trace_c, " hsys = %d;\n", hsys); + fprintf(swi_fp_trace_c, + " retc = swe_houses_ex(tjd, iflag, geolat, geolon, hsys, cusp, ascmc);\n"); + fprintf(swi_fp_trace_c, + " /* swe_houses calls swe_houses_armc as follows: */\n"); + fprintf(swi_fp_trace_c, "#endif\n"); + fflush(swi_fp_trace_c); + } + } +#endif + /*houses_to_sidereal(tjde, geolat, hsys, eps, cusp, ascmc, iflag); */ + armc = + swe_degnorm(swe_sidtime0(tjd_ut, eps_mean + nutlo[1], nutlo[0]) * 15 + + geolon); + if (iflag & SEFLG_SIDEREAL) { + if (sip->sid_mode & SE_SIDBIT_ECL_T0) + retc = + sidereal_houses_ecl_t0(tjde, armc, eps_mean + nutlo[1], nutlo, + geolat, hsys, cusp, ascmc); + else if (sip->sid_mode & SE_SIDBIT_SSY_PLANE) + retc = + sidereal_houses_ssypl(tjde, armc, eps_mean + nutlo[1], nutlo, + geolat, hsys, cusp, ascmc); + else + retc = + sidereal_houses_trad(tjde, armc, eps_mean + nutlo[1], + nutlo[0], geolat, hsys, cusp, ascmc); + } + else { + retc = + swe_houses_armc(armc, geolat, eps_mean + nutlo[1], hsys, cusp, + ascmc); + } + if (iflag & SEFLG_RADIANS) { + for (i = 1; i <= ito; i++) + cusp[i] *= DEGTORAD; + for (i = 0; i < SE_NASCMC; i++) + ascmc[i] *= DEGTORAD; + } + return retc; } /* @@ -250,80 +245,75 @@ int FAR PASCAL_CONV swe_houses_ex(double tjd_ut, * 6. subtract this distance from all house cusps. * 7. subtract ayanamsa_t0 from all house cusps. */ -static int sidereal_houses_ecl_t0(double tjde, - double armc, - double eps, - double *nutlo, - double lat, - int hsys, - double *cusp, - double *ascmc) +static int +sidereal_houses_ecl_t0(double tjde, double armc, double eps, double *nutlo, + double lat, int hsys, double *cusp, double *ascmc) { - int i, j, retc = OK; - double x[6], xvpx[6], x2[6], epst0, xnorm[6]; - double rxy, rxyz, c2, epsx, sgn, fac, dvpx, dvpxe; - double armcx; - struct sid_data *sip = &swed.sidd; - int ito; - if (toupper(hsys) == 'G') - ito = 36; - else - ito = 12; - /* epsilon at t0 */ - epst0 = swi_epsiln(sip->t0); - /* cartesian coordinates of an imaginary moving body on the - * the mean ecliptic of t0; we take the vernal point: */ - x[0] = x[4] = 1; - x[1] = x[2] = x[3] = x[5] = 0; - /* to equator */ - swi_coortrf(x, x, -epst0); - swi_coortrf(x+3, x+3, -epst0); - /* to tjd_et */ - swi_precess(x, sip->t0, J_TO_J2000); - swi_precess(x, tjde, J2000_TO_J); - swi_precess(x+3, sip->t0, J_TO_J2000); - swi_precess(x+3, tjde, J2000_TO_J); - /* to true equator of tjd_et */ - swi_coortrf(x, x, (eps - nutlo[1]) * DEGTORAD); - swi_coortrf(x+3, x+3, (eps - nutlo[1]) * DEGTORAD); - swi_cartpol_sp(x, x); - x[0] += nutlo[0] * DEGTORAD; - swi_polcart_sp(x, x); - swi_coortrf(x, x, -eps * DEGTORAD); - swi_coortrf(x+3, x+3, -eps * DEGTORAD); - /* now, we have the moving point precessed to tjd_et. - * next, we compute the auxiliary epsilon: */ - swi_cross_prod(x, x+3, xnorm); - rxy = xnorm[0] * xnorm[0] + xnorm[1] * xnorm[1]; - c2 = (rxy + xnorm[2] * xnorm[2]); - rxyz = sqrt(c2); - rxy = sqrt(rxy); - epsx = asin(rxy / rxyz) * RADTODEG; /* 1a */ - /* auxiliary vernal point */ - if (fabs(x[5]) < 1e-15) - x[5] = 1e-15; - fac = x[2] / x[5]; - sgn = x[5] / fabs(x[5]); - for (j = 0; j <= 2; j++) - xvpx[j] = (x[j] - fac * x[j+3]) * sgn; /* 1b */ - /* distance of the auxiliary vernal point from - * the zero point at tjd_et (a section on the equator): */ - swi_cartpol(xvpx, x2); - dvpx = x2[0] * RADTODEG; /* 2 */ - /* auxiliary armc */ - armcx = swe_degnorm(armc - dvpx); /* 3 */ - /* compute axes and houses: */ - retc = swe_houses_armc(armcx, lat, epsx, hsys, cusp, ascmc); /* 4 */ - /* distance between auxiliary vernal point and - * vernal point of t0 (a section on the sidereal plane) */ - dvpxe = acos(swi_dot_prod_unit(x, xvpx)) * RADTODEG; /* 5 */ - if (tjde < sip->t0) - dvpxe = -dvpxe; - for (i = 1; i <= ito; i++) /* 6, 7 */ - cusp[i] = swe_degnorm(cusp[i] - dvpxe - sip->ayan_t0); - for (i = 0; i <= SE_NASCMC; i++) - ascmc[i] = swe_degnorm(ascmc[i] - dvpxe - sip->ayan_t0); - return retc; + int i, j, retc = OK; + double x[6], xvpx[6], x2[6], epst0, xnorm[6]; + double rxy, rxyz, c2, epsx, sgn, fac, dvpx, dvpxe; + double armcx; + struct sid_data *sip = &swed.sidd; + int ito; + if (toupper(hsys) == 'G') + ito = 36; + else + ito = 12; + /* epsilon at t0 */ + epst0 = swi_epsiln(sip->t0); + /* cartesian coordinates of an imaginary moving body on the + * the mean ecliptic of t0; we take the vernal point: */ + x[0] = x[4] = 1; + x[1] = x[2] = x[3] = x[5] = 0; + /* to equator */ + swi_coortrf(x, x, -epst0); + swi_coortrf(x + 3, x + 3, -epst0); + /* to tjd_et */ + swi_precess(x, sip->t0, J_TO_J2000); + swi_precess(x, tjde, J2000_TO_J); + swi_precess(x + 3, sip->t0, J_TO_J2000); + swi_precess(x + 3, tjde, J2000_TO_J); + /* to true equator of tjd_et */ + swi_coortrf(x, x, (eps - nutlo[1]) * DEGTORAD); + swi_coortrf(x + 3, x + 3, (eps - nutlo[1]) * DEGTORAD); + swi_cartpol_sp(x, x); + x[0] += nutlo[0] * DEGTORAD; + swi_polcart_sp(x, x); + swi_coortrf(x, x, -eps * DEGTORAD); + swi_coortrf(x + 3, x + 3, -eps * DEGTORAD); + /* now, we have the moving point precessed to tjd_et. + * next, we compute the auxiliary epsilon: */ + swi_cross_prod(x, x + 3, xnorm); + rxy = xnorm[0] * xnorm[0] + xnorm[1] * xnorm[1]; + c2 = (rxy + xnorm[2] * xnorm[2]); + rxyz = sqrt(c2); + rxy = sqrt(rxy); + epsx = asin(rxy / rxyz) * RADTODEG; /* 1a */ + /* auxiliary vernal point */ + if (fabs(x[5]) < 1e-15) + x[5] = 1e-15; + fac = x[2] / x[5]; + sgn = x[5] / fabs(x[5]); + for (j = 0; j <= 2; j++) + xvpx[j] = (x[j] - fac * x[j + 3]) * sgn; /* 1b */ + /* distance of the auxiliary vernal point from + * the zero point at tjd_et (a section on the equator): */ + swi_cartpol(xvpx, x2); + dvpx = x2[0] * RADTODEG; /* 2 */ + /* auxiliary armc */ + armcx = swe_degnorm(armc - dvpx); /* 3 */ + /* compute axes and houses: */ + retc = swe_houses_armc(armcx, lat, epsx, hsys, cusp, ascmc); /* 4 */ + /* distance between auxiliary vernal point and + * vernal point of t0 (a section on the sidereal plane) */ + dvpxe = acos(swi_dot_prod_unit(x, xvpx)) * RADTODEG; /* 5 */ + if (tjde < sip->t0) + dvpxe = -dvpxe; + for (i = 1; i <= ito; i++) /* 6, 7 */ + cusp[i] = swe_degnorm(cusp[i] - dvpxe - sip->ayan_t0); + for (i = 0; i <= SE_NASCMC; i++) + ascmc[i] = swe_degnorm(ascmc[i] - dvpxe - sip->ayan_t0); + return retc; } /* @@ -346,138 +336,128 @@ static int sidereal_houses_ecl_t0(double tjde, * 8. subtract ayanamsa_t0 from all house cusps. * 9. subtract ayanamsa_2000 from all house cusps. */ -static int sidereal_houses_ssypl(double tjde, - double armc, - double eps, - double *nutlo, - double lat, - int hsys, - double *cusp, - double *ascmc) +static int +sidereal_houses_ssypl(double tjde, double armc, double eps, double *nutlo, + double lat, int hsys, double *cusp, double *ascmc) { - int i, j, retc = OK; - double x[6], x0[6], xvpx[6], x2[6], xnorm[6]; - double rxy, rxyz, c2, epsx, eps2000, sgn, fac, dvpx, dvpxe, x00; - double armcx; - struct sid_data *sip = &swed.sidd; - int ito; - if (toupper(hsys) == 'G') - ito = 36; - else - ito = 12; - eps2000 = swi_epsiln(J2000); - /* cartesian coordinates of the zero point on the - * the solar system rotation plane */ - x[0] = x[4] = 1; - x[1] = x[2] = x[3] = x[5] = 0; - /* to ecliptic 2000 */ - swi_coortrf(x, x, -SSY_PLANE_INCL); - swi_coortrf(x+3, x+3, -SSY_PLANE_INCL); - swi_cartpol_sp(x, x); - x[0] += SSY_PLANE_NODE_E2000; - swi_polcart_sp(x, x); - /* to equator 2000 */ - swi_coortrf(x, x, -eps2000); - swi_coortrf(x+3, x+3, -eps2000); - /* to mean equator of t */ - swi_precess(x, tjde, J2000_TO_J); - swi_precess(x+3, tjde, J2000_TO_J); - /* to true equator of t */ - swi_coortrf(x, x, (eps - nutlo[1]) * DEGTORAD); - swi_coortrf(x+3, x+3, (eps - nutlo[1]) * DEGTORAD); - swi_cartpol_sp(x, x); - x[0] += nutlo[0] * DEGTORAD; - swi_polcart_sp(x, x); - swi_coortrf(x, x, -eps * DEGTORAD); - swi_coortrf(x+3, x+3, -eps * DEGTORAD); - /* now, we have the moving point precessed to tjd_et. - * next, we compute the auxiliary epsilon: */ - swi_cross_prod(x, x+3, xnorm); - rxy = xnorm[0] * xnorm[0] + xnorm[1] * xnorm[1]; - c2 = (rxy + xnorm[2] * xnorm[2]); - rxyz = sqrt(c2); - rxy = sqrt(rxy); - epsx = asin(rxy / rxyz) * RADTODEG; /* 1a */ - /* auxiliary vernal point */ - if (fabs(x[5]) < 1e-15) - x[5] = 1e-15; - fac = x[2] / x[5]; - sgn = x[5] / fabs(x[5]); - for (j = 0; j <= 2; j++) - xvpx[j] = (x[j] - fac * x[j+3]) * sgn; /* 1b */ - /* distance of the auxiliary vernal point from - * mean vernal point at tjd_et (a section on the equator): */ - swi_cartpol(xvpx, x2); - dvpx = x2[0] * RADTODEG; /* 2 */ - /* auxiliary armc */ - armcx = swe_degnorm(armc - dvpx); /* 3 */ - /* compute axes and houses: */ - retc = swe_houses_armc(armcx, lat, epsx, hsys, cusp, ascmc); /* 4 */ - /* distance between the auxiliary vernal point at t and - * the sidereal zero point of 2000 at t - * (a section on the sidereal plane). - */ - dvpxe = acos(swi_dot_prod_unit(x, xvpx)) * RADTODEG; /* 5 */ - /* (always positive for dates after 5400 bc) */ - dvpxe -= SSY_PLANE_NODE * RADTODEG; - /* ayanamsa between t0 and J2000, measured on solar system plane: */ - /* position of zero point of t0 */ - x0[0] = 1; - x0[1] = x0[2] = 0; - /* zero point of t0 in J2000 system */ - if (sip->t0 != J2000) - swi_precess(x0, sip->t0, J_TO_J2000); - /* zero point to ecliptic 2000 */ - swi_coortrf(x0, x0, eps2000); - /* to solar system plane */ - swi_cartpol(x0, x0); - x0[0] -= SSY_PLANE_NODE_E2000; - swi_polcart(x0, x0); - swi_coortrf(x0, x0, SSY_PLANE_INCL); - swi_cartpol(x0, x0); - x0[0] += SSY_PLANE_NODE; - x00 = x0[0] * RADTODEG; /* 7 */ - for (i = 1; i <= ito; i++) /* 6, 8, 9 */ - cusp[i] = swe_degnorm(cusp[i] - dvpxe - sip->ayan_t0 - x00); - for (i = 0; i <= SE_NASCMC; i++) - ascmc[i] = swe_degnorm(ascmc[i] - dvpxe - sip->ayan_t0 - x00); - return retc; + int i, j, retc = OK; + double x[6], x0[6], xvpx[6], x2[6], xnorm[6]; + double rxy, rxyz, c2, epsx, eps2000, sgn, fac, dvpx, dvpxe, x00; + double armcx; + struct sid_data *sip = &swed.sidd; + int ito; + if (toupper(hsys) == 'G') + ito = 36; + else + ito = 12; + eps2000 = swi_epsiln(J2000); + /* cartesian coordinates of the zero point on the + * the solar system rotation plane */ + x[0] = x[4] = 1; + x[1] = x[2] = x[3] = x[5] = 0; + /* to ecliptic 2000 */ + swi_coortrf(x, x, -SSY_PLANE_INCL); + swi_coortrf(x + 3, x + 3, -SSY_PLANE_INCL); + swi_cartpol_sp(x, x); + x[0] += SSY_PLANE_NODE_E2000; + swi_polcart_sp(x, x); + /* to equator 2000 */ + swi_coortrf(x, x, -eps2000); + swi_coortrf(x + 3, x + 3, -eps2000); + /* to mean equator of t */ + swi_precess(x, tjde, J2000_TO_J); + swi_precess(x + 3, tjde, J2000_TO_J); + /* to true equator of t */ + swi_coortrf(x, x, (eps - nutlo[1]) * DEGTORAD); + swi_coortrf(x + 3, x + 3, (eps - nutlo[1]) * DEGTORAD); + swi_cartpol_sp(x, x); + x[0] += nutlo[0] * DEGTORAD; + swi_polcart_sp(x, x); + swi_coortrf(x, x, -eps * DEGTORAD); + swi_coortrf(x + 3, x + 3, -eps * DEGTORAD); + /* now, we have the moving point precessed to tjd_et. + * next, we compute the auxiliary epsilon: */ + swi_cross_prod(x, x + 3, xnorm); + rxy = xnorm[0] * xnorm[0] + xnorm[1] * xnorm[1]; + c2 = (rxy + xnorm[2] * xnorm[2]); + rxyz = sqrt(c2); + rxy = sqrt(rxy); + epsx = asin(rxy / rxyz) * RADTODEG; /* 1a */ + /* auxiliary vernal point */ + if (fabs(x[5]) < 1e-15) + x[5] = 1e-15; + fac = x[2] / x[5]; + sgn = x[5] / fabs(x[5]); + for (j = 0; j <= 2; j++) + xvpx[j] = (x[j] - fac * x[j + 3]) * sgn; /* 1b */ + /* distance of the auxiliary vernal point from + * mean vernal point at tjd_et (a section on the equator): */ + swi_cartpol(xvpx, x2); + dvpx = x2[0] * RADTODEG; /* 2 */ + /* auxiliary armc */ + armcx = swe_degnorm(armc - dvpx); /* 3 */ + /* compute axes and houses: */ + retc = swe_houses_armc(armcx, lat, epsx, hsys, cusp, ascmc); /* 4 */ + /* distance between the auxiliary vernal point at t and + * the sidereal zero point of 2000 at t + * (a section on the sidereal plane). + */ + dvpxe = acos(swi_dot_prod_unit(x, xvpx)) * RADTODEG; /* 5 */ + /* (always positive for dates after 5400 bc) */ + dvpxe -= SSY_PLANE_NODE * RADTODEG; + /* ayanamsa between t0 and J2000, measured on solar system plane: */ + /* position of zero point of t0 */ + x0[0] = 1; + x0[1] = x0[2] = 0; + /* zero point of t0 in J2000 system */ + if (sip->t0 != J2000) + swi_precess(x0, sip->t0, J_TO_J2000); + /* zero point to ecliptic 2000 */ + swi_coortrf(x0, x0, eps2000); + /* to solar system plane */ + swi_cartpol(x0, x0); + x0[0] -= SSY_PLANE_NODE_E2000; + swi_polcart(x0, x0); + swi_coortrf(x0, x0, SSY_PLANE_INCL); + swi_cartpol(x0, x0); + x0[0] += SSY_PLANE_NODE; + x00 = x0[0] * RADTODEG; /* 7 */ + for (i = 1; i <= ito; i++) /* 6, 8, 9 */ + cusp[i] = swe_degnorm(cusp[i] - dvpxe - sip->ayan_t0 - x00); + for (i = 0; i <= SE_NASCMC; i++) + ascmc[i] = swe_degnorm(ascmc[i] - dvpxe - sip->ayan_t0 - x00); + return retc; } /* common simplified procedure */ -static int sidereal_houses_trad(double tjde, - double armc, - double eps, - double nutl, - double lat, - int hsys, - double *cusp, - double *ascmc) +static int +sidereal_houses_trad(double tjde, double armc, double eps, double nutl, + double lat, int hsys, double *cusp, double *ascmc) { - int i, retc = OK; - double ay; - int ito; - int ihs = toupper(hsys); - int ihs2 = ihs; - ay = swe_get_ayanamsa(tjde); - if (ihs == 'G') - ito = 36; - else - ito = 12; - if (ihs == 'W') /* whole sign houses: treat as 'E' and fix later */ - ihs2 = 'E'; - retc = swe_houses_armc(armc, lat, eps, ihs2, cusp, ascmc); - for (i = 1; i <= ito; i++) { - cusp[i] = swe_degnorm(cusp[i] - ay - nutl); - if (ihs == 'W') /* whole sign houses */ - cusp[i] -= fmod(cusp[i], 30); - } - for (i = 0; i < SE_NASCMC; i++) { - if (i == 2) /* armc */ - continue; - ascmc[i] = swe_degnorm(ascmc[i] - ay - nutl); - } - return retc; + int i, retc = OK; + double ay; + int ito; + int ihs = toupper(hsys); + int ihs2 = ihs; + ay = swe_get_ayanamsa(tjde); + if (ihs == 'G') + ito = 36; + else + ito = 12; + if (ihs == 'W') /* whole sign houses: treat as 'E' and fix later */ + ihs2 = 'E'; + retc = swe_houses_armc(armc, lat, eps, ihs2, cusp, ascmc); + for (i = 1; i <= ito; i++) { + cusp[i] = swe_degnorm(cusp[i] - ay - nutl); + if (ihs == 'W') /* whole sign houses */ + cusp[i] -= fmod(cusp[i], 30); + } + for (i = 0; i < SE_NASCMC; i++) { + if (i == 2) /* armc */ + continue; + ascmc[i] = swe_degnorm(ascmc[i] - ay - nutl); + } + return retc; } /* @@ -497,89 +477,91 @@ static int sidereal_houses_trad(double tjde, * ascmc[6] = coasc2 * "co-ascendant" (M. Munkasey) * * ascmc[7] = polasc * "polar ascendant" (M. Munkasey) * */ -int FAR PASCAL_CONV swe_houses_armc( - double armc, - double geolat, - double eps, - int hsys, - double *cusp, - double *ascmc) +int FAR PASCAL_CONV +swe_houses_armc(double armc, double geolat, double eps, int hsys, + double *cusp, double *ascmc) { - struct houses h; - int i, retc = 0; - int ito; - if (toupper(hsys) == 'G') - ito = 36; - else - ito = 12; - armc = swe_degnorm(armc); - retc = CalcH(armc, - geolat, - eps, - (char)hsys, 2, &h); - cusp[0] = 0; - for (i = 1; i <= ito; i++) { - cusp[i] = h.cusp[i]; - } - ascmc[0] = h.ac; /* Asc */ - ascmc[1] = h.mc; /* Mid */ - ascmc[2] = armc; - ascmc[3] = h.vertex; - ascmc[4] = h.equasc; - ascmc[5] = h.coasc1; /* "co-ascendant" (W. Koch) */ - ascmc[6] = h.coasc2; /* "co-ascendant" (M. Munkasey) */ - ascmc[7] = h.polasc; /* "polar ascendant" (M. Munkasey) */ - for (i = SE_NASCMC; i < 10; i++) - ascmc[i] = 0; + struct houses h; + int i, retc = 0; + int ito; + if (toupper(hsys) == 'G') + ito = 36; + else + ito = 12; + armc = swe_degnorm(armc); + retc = CalcH(armc, geolat, eps, (char)hsys, 2, &h); + cusp[0] = 0; + for (i = 1; i <= ito; i++) { + cusp[i] = h.cusp[i]; + } + ascmc[0] = h.ac; /* Asc */ + ascmc[1] = h.mc; /* Mid */ + ascmc[2] = armc; + ascmc[3] = h.vertex; + ascmc[4] = h.equasc; + ascmc[5] = h.coasc1; /* "co-ascendant" (W. Koch) */ + ascmc[6] = h.coasc2; /* "co-ascendant" (M. Munkasey) */ + ascmc[7] = h.polasc; /* "polar ascendant" (M. Munkasey) */ + for (i = SE_NASCMC; i < 10; i++) + ascmc[i] = 0; #ifdef TRACE - swi_open_trace(NULL); - if (swi_trace_count <= TRACE_COUNT_MAX) { - if (swi_fp_trace_c != NULL) { - fputs("\n/*SWE_HOUSES_ARMC*/\n", swi_fp_trace_c); - fprintf(swi_fp_trace_c, " armc = %.9f;", armc); - fprintf(swi_fp_trace_c, " geolat = %.9f;", geolat); - fprintf(swi_fp_trace_c, " eps = %.9f;", eps); - fprintf(swi_fp_trace_c, " hsys = %d;\n", hsys); - fprintf(swi_fp_trace_c, " retc = swe_houses_armc(armc, geolat, eps, hsys, cusp, ascmc);\n"); - fputs(" printf(\"swe_houses_armc: %f\\t%f\\t%f\\t%c\\t\\n\", ", swi_fp_trace_c); - fputs(" armc, geolat, eps, hsys);\n", swi_fp_trace_c); - fputs(" printf(\"retc = %d\\n\", retc);\n", swi_fp_trace_c); - fputs(" printf(\"cusp:\\n\");\n", swi_fp_trace_c); - fputs(" for (i = 0; i < 12; i++)\n", swi_fp_trace_c); - fputs(" printf(\" %d\\t%f\\n\", i, cusp[i]);\n", swi_fp_trace_c); - fputs(" printf(\"ascmc:\\n\");\n", swi_fp_trace_c); - fputs(" for (i = 0; i < 10; i++)\n", swi_fp_trace_c); - fputs(" printf(\" %d\\t%f\\n\", i, ascmc[i]);\n", swi_fp_trace_c); - fflush(swi_fp_trace_c); + swi_open_trace(NULL); + if (swi_trace_count <= TRACE_COUNT_MAX) { + if (swi_fp_trace_c != NULL) { + fputs("\n/*SWE_HOUSES_ARMC*/\n", swi_fp_trace_c); + fprintf(swi_fp_trace_c, " armc = %.9f;", armc); + fprintf(swi_fp_trace_c, " geolat = %.9f;", geolat); + fprintf(swi_fp_trace_c, " eps = %.9f;", eps); + fprintf(swi_fp_trace_c, " hsys = %d;\n", hsys); + fprintf(swi_fp_trace_c, + " retc = swe_houses_armc(armc, geolat, eps, hsys, cusp, ascmc);\n"); + fputs(" printf(\"swe_houses_armc: %f\\t%f\\t%f\\t%c\\t\\n\", ", + swi_fp_trace_c); + fputs(" armc, geolat, eps, hsys);\n", swi_fp_trace_c); + fputs(" printf(\"retc = %d\\n\", retc);\n", swi_fp_trace_c); + fputs(" printf(\"cusp:\\n\");\n", swi_fp_trace_c); + fputs(" for (i = 0; i < 12; i++)\n", swi_fp_trace_c); + fputs(" printf(\" %d\\t%f\\n\", i, cusp[i]);\n", + swi_fp_trace_c); + fputs(" printf(\"ascmc:\\n\");\n", swi_fp_trace_c); + fputs(" for (i = 0; i < 10; i++)\n", swi_fp_trace_c); + fputs(" printf(\" %d\\t%f\\n\", i, ascmc[i]);\n", + swi_fp_trace_c); + fflush(swi_fp_trace_c); + } + if (swi_fp_trace_out != NULL) { + fprintf(swi_fp_trace_out, "swe_houses_armc: %f\t%f\t%f\t%c\t\n", + armc, geolat, eps, hsys); + fprintf(swi_fp_trace_out, "retc = %d\n", retc); + fputs("cusp:\n", swi_fp_trace_out); + for (i = 0; i < 12; i++) + fprintf(swi_fp_trace_out, " %d\t%f\n", i, cusp[i]); + fputs("ascmc:\n", swi_fp_trace_out); + for (i = 0; i < 10; i++) + fprintf(swi_fp_trace_out, " %d\t%f\n", i, ascmc[i]); + fflush(swi_fp_trace_out); + } } - if (swi_fp_trace_out != NULL) { - fprintf(swi_fp_trace_out, "swe_houses_armc: %f\t%f\t%f\t%c\t\n", armc, geolat, eps, hsys); - fprintf(swi_fp_trace_out, "retc = %d\n", retc); - fputs("cusp:\n", swi_fp_trace_out); - for (i = 0; i < 12; i++) - fprintf(swi_fp_trace_out, " %d\t%f\n", i, cusp[i]); - fputs("ascmc:\n", swi_fp_trace_out); - for (i = 0; i < 10; i++) - fprintf(swi_fp_trace_out, " %d\t%f\n", i, ascmc[i]); - fflush(swi_fp_trace_out); - } - } #endif -#if 0 +#if 0 + /* for test of swe_house_pos(). * 1st house will be 0, second 30, etc. */ -for (i = 1; i <=12; i++) { - double x[6]; - x[0] = cusp[i]; x[1] = 0; x[2] = 1; - cusp[i] = (swe_house_pos(armc, geolat, eps, hsys, x, NULL) - 1) * 30; -} + for (i = 1; i <= 12; i++) { + double x[6]; + x[0] = cusp[i]; + x[1] = 0; + x[2] = 1; + cusp[i] = (swe_house_pos(armc, geolat, eps, hsys, x, NULL) - 1) * 30; + } #endif - return retc; + return retc; } -static int CalcH( - double th, double fi, double ekl, char hsy, - int iteration_count, struct houses *hsp ) +static int +CalcH(double th, double fi, double ekl, char hsy, int iteration_count, + struct houses *hsp) + /* ********************************************************* * Arguments: th = sidereal time (angle 0..360 degrees * hsy = letter code for house system; @@ -613,656 +595,680 @@ static int CalcH( * implemented for arguments in degrees. ***********************************************************/ { - double tane, tanfi, cosfi, tant, sina, cosa, th2; - double a, c, f, fh1, fh2, xh1, xh2, rectasc, ad3, acmc, vemc; - int i, ih, ih2, retc = OK; - double sine, cose; - double x[3], krHorizonLon; /* BK 14.02.2006 */ - cose = cosd(ekl); - sine = sind(ekl); - tane = tand(ekl); - /* north and south poles */ - if (fabs(fabs(fi) - 90) < VERY_SMALL) { - if (fi < 0) - fi = -90 + VERY_SMALL; - else - fi = 90 - VERY_SMALL; - } - tanfi = tand(fi); - /* mc */ - if (fabs(th - 90) > VERY_SMALL - && fabs(th - 270) > VERY_SMALL) { - tant = tand(th); - hsp->mc = atand(tant / cose); - if (th > 90 && th <= 270) - hsp->mc = swe_degnorm(hsp->mc + 180); - } else { - if (fabs(th - 90) <= VERY_SMALL) - hsp->mc = 90; - else - hsp->mc = 270; - } /* if */ - hsp->mc = swe_degnorm(hsp->mc); - /* ascendant */ - hsp->ac = Asc1 (th + 90, fi, sine, cose); - hsp->cusp[1] = hsp->ac; - hsp->cusp[10] = hsp->mc; - if (hsy > 95) hsy = (char) (hsy - 32);/* translate into capital letter */ - switch (hsy) { - case 'A': /* equal houses */ - case 'E': - /* - * within polar circle we swap AC/DC if AC is on wrong side - */ - acmc = swe_difdeg2n(hsp->ac, hsp->mc); - if (acmc < 0) { - hsp->ac = swe_degnorm(hsp->ac + 180); - hsp->cusp[1] = hsp->ac; - } - for (i = 2; i <=12; i++) - hsp->cusp [i] = swe_degnorm(hsp->cusp [1] + (i-1) * 30); - break; - case 'C': /* Campanus houses and Horizon or Azimut system */ - case 'H': - if (hsy == 'H') { - if (fi > 0) - fi = 90 - fi; - else - fi = -90 - fi; - /* equator */ - if (fabs(fabs(fi) - 90) < VERY_SMALL) { + double tane, tanfi, cosfi, tant, sina, cosa, th2; + double a, c, f, fh1, fh2, xh1, xh2, rectasc, ad3, acmc, vemc; + int i, ih, ih2, retc = OK; + double sine, cose; + double x[3], krHorizonLon; /* BK 14.02.2006 */ + cose = cosd(ekl); + sine = sind(ekl); + tane = tand(ekl); + /* north and south poles */ + if (fabs(fabs(fi) - 90) < VERY_SMALL) { if (fi < 0) - fi = -90 + VERY_SMALL; + fi = -90 + VERY_SMALL; else - fi = 90 - VERY_SMALL; - } - th = swe_degnorm(th + 180); + fi = 90 - VERY_SMALL; } - fh1 = asind(sind (fi) / 2); - fh2 = asind(sqrt (3.0) / 2 * sind(fi)); - cosfi = cosd(fi); - if (fabs(cosfi) == 0) { /* '==' should be save! */ - if (fi > 0) - xh1 = xh2 = 90; /* cosfi = VERY_SMALL; */ - else - xh1 = xh2 = 270; /* cosfi = -VERY_SMALL; */ - } else { - xh1 = atand(sqrt (3.0) / cosfi); - xh2 = atand(1 / sqrt (3.0) / cosfi); - } - hsp->cusp [11] = Asc1 (th + 90 - xh1, fh1, sine, cose); - hsp->cusp [12] = Asc1 (th + 90 - xh2, fh2, sine, cose); - if (hsy == 'H') - hsp->cusp [1] = Asc1 (th + 90, fi, sine, cose); - hsp->cusp [2] = Asc1 (th + 90 + xh2, fh2, sine, cose); - hsp->cusp [3] = Asc1 (th + 90 + xh1, fh1, sine, cose); - /* within polar circle, when mc sinks below horizon and - * ascendant changes to western hemisphere, all cusps - * must be added 180 degrees. - * houses will be in clockwise direction */ - if (fabs(fi) >= 90 - ekl) { /* within polar circle */ - acmc = swe_difdeg2n(hsp->ac, hsp->mc); - if (acmc < 0) { - hsp->ac = swe_degnorm(hsp->ac + 180); - hsp->mc = swe_degnorm(hsp->mc + 180); - for (i = 1; i <= 12; i++) - hsp->cusp[i] = swe_degnorm(hsp->cusp[i] + 180); - } - } - if (hsy == 'H') { - for (i = 1; i <= 3; i++) - hsp->cusp[i] = swe_degnorm(hsp->cusp[i] + 180); - for (i = 11; i <= 12; i++) - hsp->cusp[i] = swe_degnorm(hsp->cusp[i] + 180); - /* restore fi and th */ - if (fi > 0) - fi = 90 - fi; - else - fi = -90 - fi; - th = swe_degnorm(th + 180); - acmc = swe_difdeg2n(hsp->ac, hsp->mc); - if (acmc < 0) { - hsp->ac = swe_degnorm(hsp->ac + 180); - } - } - break; - case 'K': /* Koch houses */ - if (fabs(fi) >= 90 - ekl) { /* within polar circle */ - retc = ERR; - goto porphyry; - } - sina = sind(hsp->mc) * sine / cosd(fi); - if (sina > 1) sina = 1; - if (sina < -1) sina = -1; - cosa = sqrt(1 - sina * sina); /* always >> 0 */ - c = atand(tanfi / cosa); - ad3 = asind(sind(c) * sina) / 3.0; - hsp->cusp [11] = Asc1 (th + 30 - 2 * ad3, fi, sine, cose); - hsp->cusp [12] = Asc1 (th + 60 - ad3, fi, sine, cose); - hsp->cusp [2] = Asc1 (th + 120 + ad3, fi, sine, cose); - hsp->cusp [3] = Asc1 (th + 150 + 2 * ad3, fi, sine, cose); - break; - case 'O': /* Porphyry houses */ -porphyry: - /* - * within polar circle we swap AC/DC if AC is on wrong side - */ - acmc = swe_difdeg2n(hsp->ac, hsp->mc); - if (acmc < 0) { - hsp->ac = swe_degnorm(hsp->ac + 180); - hsp->cusp[1] = hsp->ac; - acmc = swe_difdeg2n(hsp->ac, hsp->mc); - } - hsp->cusp [2] = swe_degnorm(hsp->ac + (180 - acmc) / 3); - hsp->cusp [3] = swe_degnorm(hsp->ac + (180 - acmc) / 3 * 2); - hsp->cusp [11] = swe_degnorm(hsp->mc + acmc / 3); - hsp->cusp [12] = swe_degnorm(hsp->mc + acmc / 3 * 2); - break; - case 'R': /* Regiomontanus houses */ - fh1 = atand (tanfi * 0.5); - fh2 = atand (tanfi * cosd(30)); - hsp->cusp [11] = Asc1 (30 + th, fh1, sine, cose); - hsp->cusp [12] = Asc1 (60 + th, fh2, sine, cose); - hsp->cusp [2] = Asc1 (120 + th, fh2, sine, cose); - hsp->cusp [3] = Asc1 (150 + th, fh1, sine, cose); - /* within polar circle, when mc sinks below horizon and - * ascendant changes to western hemisphere, all cusps - * must be added 180 degrees. - * houses will be in clockwise direction */ - if (fabs(fi) >= 90 - ekl) { /* within polar circle */ - acmc = swe_difdeg2n(hsp->ac, hsp->mc); - if (acmc < 0) { - hsp->ac = swe_degnorm(hsp->ac + 180); - hsp->mc = swe_degnorm(hsp->mc + 180); - for (i = 1; i <= 12; i++) - hsp->cusp[i] = swe_degnorm(hsp->cusp[i] + 180); - } - } - break; - case 'T': /* 'topocentric' houses */ - fh1 = atand (tanfi / 3.0); - fh2 = atand (tanfi * 2.0 / 3.0); - hsp->cusp [11] = Asc1 (30 + th, fh1, sine, cose); - hsp->cusp [12] = Asc1 (60 + th, fh2, sine, cose); - hsp->cusp [2] = Asc1 (120 + th, fh2, sine, cose); - hsp->cusp [3] = Asc1 (150 + th, fh1, sine, cose); - /* within polar circle, when mc sinks below horizon and - * ascendant changes to western hemisphere, all cusps - * must be added 180 degrees. - * houses will be in clockwise direction */ - if (fabs(fi) >= 90 - ekl) { /* within polar circle */ - acmc = swe_difdeg2n(hsp->ac, hsp->mc); - if (acmc < 0) { - hsp->ac = swe_degnorm(hsp->ac + 180); - hsp->mc = swe_degnorm(hsp->mc + 180); - for (i = 1; i <= 12; i++) - hsp->cusp[i] = swe_degnorm(hsp->cusp[i] + 180); - } - } - break; - case 'V': /* equal houses after Vehlow */ - /* - * within polar circle we swap AC/DC if AC is on wrong side - */ - acmc = swe_difdeg2n(hsp->ac, hsp->mc); - if (acmc < 0) { - hsp->ac = swe_degnorm(hsp->ac + 180); - hsp->cusp[1] = hsp->ac; - } - hsp->cusp [1] = swe_degnorm(hsp->ac - 15); - for (i = 2; i <=12; i++) - hsp->cusp [i] = swe_degnorm(hsp->cusp [1] + (i-1) * 30); - break; - case 'W': /* equal, whole-sign houses */ - /* - * within polar circle we swap AC/DC if AC is on wrong side - */ - acmc = swe_difdeg2n(hsp->ac, hsp->mc); - if (acmc < 0) { - hsp->ac = swe_degnorm(hsp->ac + 180); - hsp->cusp[1] = hsp->ac; - } - hsp->cusp [1] = hsp->ac - fmod(hsp->ac, 30); - for (i = 2; i <=12; i++) - hsp->cusp [i] = swe_degnorm(hsp->cusp [1] + (i-1) * 30); - break; - case 'X': { - /* - * Meridian or axial rotation system: - * ecliptic points whose rectascensions - * are armc + n * 30 - */ - int j; - double a = th; - for (i = 1; i <= 12; i++) { - j = i + 10; - if (j > 12) j -= 12; - a = swe_degnorm(a + 30); - if (fabs(a - 90) > VERY_SMALL - && fabs(a - 270) > VERY_SMALL) { - tant = tand(a); - hsp->cusp[j] = atand(tant / cose); - if (a > 90 && a <= 270) - hsp->cusp[j] = swe_degnorm(hsp->cusp[j] + 180); - } else { - if (fabs(a - 90) <= VERY_SMALL) - hsp->cusp[j] = 90; - else - hsp->cusp[j] = 270; - } /* if */ - hsp->cusp[j] = swe_degnorm(hsp->cusp[j]); - } - acmc = swe_difdeg2n(hsp->ac, hsp->mc); - if (acmc < 0) { - hsp->ac = swe_degnorm(hsp->ac + 180); - } - break; } - case 'M': { - /* - * Morinus - * points of the equator (armc + n * 30) are transformed - * into the ecliptic coordinate system - */ - int j; - double a = th; - double x[3]; - for (i = 1; i <= 12; i++) { - j = i + 10; - if (j > 12) j -= 12; - a = swe_degnorm(a + 30); - x[0] = a; - x[1] = 0; - swe_cotrans(x, x, ekl); - hsp->cusp[j] = x[0]; - } - acmc = swe_difdeg2n(hsp->ac, hsp->mc); - if (acmc < 0) { - hsp->ac = swe_degnorm(hsp->ac + 180); - } - break; } - case 'B': { /* Alcabitius */ - /* created by Alois 17-sep-2000, followed example in Matrix - electrical library. The code reproduces the example! - See http://www.astro.com/cgi/adict.cgi query: alcabitius - in the resuotl page, see program code example. - I think the Alcabitius code in Walter Pullen's Astrolog 5.40 - is wrong, because he remains in RA and forgets the transform to - the ecliptic. */ - double dek, r, sna, sda, sn3, sd3; -#if FALSE - if (fabs(fi) >= 90 - ekl) { /* within polar circle */ - retc = ERR; - goto porphyry; - } -#endif - acmc = swe_difdeg2n(hsp->ac, hsp->mc); - if (acmc < 0) { - hsp->ac = swe_degnorm(hsp->ac + 180); - hsp->cusp[1] = hsp->ac; - acmc = swe_difdeg2n(hsp->ac, hsp->mc); - } - dek = asind(sind(hsp->ac) * sine); /* declination of Ascendant */ - /* must treat the case fi == 90 or -90 */ - r = -tanfi * tand(dek); - /* must treat the case of abs(r) > 1; probably does not happen - * because dek becomes smaller when fi is large, as ac is close to - * zero Aries/Libra in that case. - */ - sda = acos(r) * RADTODEG; /* semidiurnal arc, measured on equator */ - sna = 180 - sda; /* complement, seminocturnal arc */ - sd3 = sda / 3; - sn3 = sna / 3; - rectasc = swe_degnorm(th + sd3); /* cusp 11 */ - /* project rectasc onto eclipitic with pole height 0, i.e. along the - declination circle */ - hsp->cusp [11] = Asc1 (rectasc, 0, sine, cose); - rectasc = swe_degnorm(th + 2 * sd3); /* cusp 12 */ - hsp->cusp [12] = Asc1 (rectasc, 0, sine, cose); - rectasc = swe_degnorm(th + 180 - 2 * sn3); /* cusp 2 */ - hsp->cusp [2] = Asc1 (rectasc, 0, sine, cose); - rectasc = swe_degnorm(th + 180 - sn3); /* cusp 3 */ - hsp->cusp [3] = Asc1 (rectasc, 0, sine, cose); - } - break; - case 'G': /* 36 Gauquelin sectors */ - for (i = 1; i <= 36; i++) { - hsp->cusp[i] = 0; - } - if (fabs(fi) >= 90 - ekl) { /* within polar circle */ - retc = ERR; - goto porphyry; - } - /*************** forth/second quarter ***************/ - /* note: Gauquelin sectors are counted in clockwise direction */ - a = asind(tand(fi) * tane); - for (ih = 2; ih <= 9; ih++) { - ih2 = 10 - ih; - fh1 = atand(sind(a * ih2 / 9) / tane); - rectasc = swe_degnorm((90 / 9) * ih2 + th); - tant = tand(asind(sine * sind(Asc1 (rectasc, fh1, sine, cose)))); - if (fabs(tant) < VERY_SMALL) { - hsp->cusp[ih] = rectasc; - } else { - /* pole height */ - f = atand(sind(asind(tanfi * tant) * ih2 / 9) /tant); - hsp->cusp [ih] = Asc1 (rectasc, f, sine, cose); - for (i = 1; i <= iteration_count; i++) { - tant = tand(asind(sine * sind(hsp->cusp[ih]))); - if (fabs(tant) < VERY_SMALL) { - hsp->cusp[ih] = rectasc; - break; - } - /* pole height */ - f = atand(sind(asind(tanfi * tant) * ih2 / 9) / tant); - hsp->cusp[ih] = Asc1 (rectasc, f, sine, cose); - } - } - hsp->cusp[ih+18] = swe_degnorm(hsp->cusp[ih] + 180); - } - /*************** first/third quarter ***************/ - for (ih = 29; ih <= 36; ih++) { - ih2 = ih - 28; - fh1 = atand(sind(a * ih2 / 9) / tane); - rectasc = swe_degnorm(180 - ih2 * 90 / 9 + th); - tant = tand(asind(sine * sind(Asc1 (rectasc, fh1, sine, cose)))); - if (fabs(tant) < VERY_SMALL) { - hsp->cusp[ih] = rectasc; - } else { - f = atand(sind(asind(tanfi * tant) * ih2 / 9) / tant); - /* pole height */ - hsp->cusp[ih] = Asc1 (rectasc, f, sine, cose); - for (i = 1; i <= iteration_count; i++) { - tant = tand(asind(sine * sind(hsp->cusp[ih]))); - if (fabs(tant) < VERY_SMALL) { - hsp->cusp[ih] = rectasc; - break; - } - f = atand(sind(asind(tanfi * tant) * ih2 / 9) / tant); - /* pole height */ - hsp->cusp[ih] = Asc1 (rectasc, f, sine, cose); - } - } - hsp->cusp[ih-18] = swe_degnorm(hsp->cusp[ih] + 180); + tanfi = tand(fi); + /* mc */ + if (fabs(th - 90) > VERY_SMALL && fabs(th - 270) > VERY_SMALL) { + tant = tand(th); + hsp->mc = atand(tant / cose); + if (th > 90 && th <= 270) + hsp->mc = swe_degnorm(hsp->mc + 180); } + else { + if (fabs(th - 90) <= VERY_SMALL) + hsp->mc = 90; + else + hsp->mc = 270; + } /* if */ + hsp->mc = swe_degnorm(hsp->mc); + /* ascendant */ + hsp->ac = Asc1(th + 90, fi, sine, cose); hsp->cusp[1] = hsp->ac; hsp->cusp[10] = hsp->mc; - hsp->cusp[19] = swe_degnorm(hsp->ac + 180); - hsp->cusp[28] = swe_degnorm(hsp->mc + 180); - break; - case 'U': /* Krusinski-Pisa */ - /* - * The following code was written by Bogdan Krusinski in 2006. - * bogdan@astrologia.pl - * - * Definition: - * "Krusinski - house system based on the great circle passing through - * ascendant and zenith. This circle is divided into 12 equal parts - * (1st cusp is ascendent, 10th cusp is zenith), then the resulting - * points are projected onto the ecliptic through meridian circles. - * The house cusps in space are half-circles perpendicular to the equator - * and running from the north to the south celestial pole through the - * resulting cusp points on the house circle. The points where they - * cross the ecliptic mark the ecliptic house cusps." - * - * Description of the algorithm: - * Transform into great circle running through Asc and zenit (where arc - * between Asc and zenith is always 90 deg), and then return with - * house cusps into ecliptic. Eg. solve trigonometrical triangle - * with three transformations and two rotations starting from ecliptic. - * House cusps in space are meridian circles. - * - * Notes: - * 1. In this definition we assume MC on ecliptic as point where - * half-meridian (from north to south pole) cuts ecliptic, - * so MC may be below horizon in arctic regions. - * 2. Houses could be calculated in all latitudes except the poles - * themselves (-90,90) and points on arctic circle in cases where - * ecliptic is equal to horizon and then ascendant is undefined. - * But ascendant when 'horizon=ecliptic' could be deduced as limes - * from both sides of that point and houses with that provision can - * be computed also there. - * - * Starting values for calculations: - * - Asc ecliptic longitude - * - right ascension of MC (RAMC) - * - geographic latitude. - */ - /* - * within polar circle we swap AC/DC if AC is on wrong side - */ - acmc = swe_difdeg2n(hsp->ac, hsp->mc); - if (acmc < 0) { - hsp->ac = swe_degnorm(hsp->ac + 180); - } - /* A0. Start point - ecliptic coords of ascendant */ - x[0] = hsp->ac; /* Asc longitude */ - x[1] = 0.0; /* Asc declination */ - x[2] = 1.0; /* Radius to test validity of subsequent transformations. */ - swe_cotrans(x, x, -ekl); /* A1. Transform into equatorial coords */ - x[0] = x[0] - (th-90); /* A2. Rotate */ - swe_cotrans(x, x, -(90-fi)); /* A3. Transform into horizontal coords */ - krHorizonLon = x[0]; /* ...save asc lon on horizon to get back later with house cusp */ - x[0] = x[0] - x[0]; /* A4. Rotate */ - swe_cotrans(x, x, -90); /* A5. Transform into this house system great circle (asc-zenith) */ - /* As it is house circle now, simple add 30 deg increments... */ - for(i = 0; i < 6; i++) { - /* B0. Set 'n-th' house cusp. - * Note that IC/MC are also calculated here to check - * if really this is the asc-zenith great circle. */ - x[0] = 30.0*i; - x[1] = 0.0; - swe_cotrans(x, x, 90); /* B1. Transform back into horizontal coords */ - x[0] = x[0] + krHorizonLon; /* B2. Rotate back. */ - swe_cotrans(x, x, 90-fi); /* B3. Transform back into equatorial coords */ - x[0] = swe_degnorm(x[0] + (th-90)); /* B4. Rotate back -> RA of house cusp as result. */ - /* B5. Where's this house cusp on ecliptic? */ - /* ... so last but not least - get ecliptic longitude of house cusp: */ - hsp->cusp[i+1] = atand(tand(x[0])/cosd(ekl)); - if (x[0] > 90 && x[0] <= 270) - hsp->cusp[i+1] = swe_degnorm(hsp->cusp[i+1] + 180); - hsp->cusp[i+1] = swe_degnorm(hsp->cusp[i+1]); - hsp->cusp[i+7] = swe_degnorm(hsp->cusp[i+1]+180); - } - break; - default: /* Placidus houses */ -#ifndef _WINDOWS - if (hsy != 'P') - fprintf (stderr, "swe_houses: make Placidus, unknown key %c\n", hsy); + if (hsy > 95) + hsy = (char)(hsy - 32); /* translate into capital letter */ + switch (hsy) { + case 'A': /* equal houses */ + case 'E': + /* + * within polar circle we swap AC/DC if AC is on wrong side + */ + acmc = swe_difdeg2n(hsp->ac, hsp->mc); + if (acmc < 0) { + hsp->ac = swe_degnorm(hsp->ac + 180); + hsp->cusp[1] = hsp->ac; + } + for (i = 2; i <= 12; i++) + hsp->cusp[i] = swe_degnorm(hsp->cusp[1] + (i - 1) * 30); + break; + case 'C': /* Campanus houses and Horizon or Azimut system */ + case 'H': + if (hsy == 'H') { + if (fi > 0) + fi = 90 - fi; + else + fi = -90 - fi; + /* equator */ + if (fabs(fabs(fi) - 90) < VERY_SMALL) { + if (fi < 0) + fi = -90 + VERY_SMALL; + else + fi = 90 - VERY_SMALL; + } + th = swe_degnorm(th + 180); + } + fh1 = asind(sind(fi) / 2); + fh2 = asind(sqrt(3.0) / 2 * sind(fi)); + cosfi = cosd(fi); + if (fabs(cosfi) == 0) { /* '==' should be save! */ + if (fi > 0) + xh1 = xh2 = 90; /* cosfi = VERY_SMALL; */ + else + xh1 = xh2 = 270; /* cosfi = -VERY_SMALL; */ + } + else { + xh1 = atand(sqrt(3.0) / cosfi); + xh2 = atand(1 / sqrt(3.0) / cosfi); + } + hsp->cusp[11] = Asc1(th + 90 - xh1, fh1, sine, cose); + hsp->cusp[12] = Asc1(th + 90 - xh2, fh2, sine, cose); + if (hsy == 'H') + hsp->cusp[1] = Asc1(th + 90, fi, sine, cose); + hsp->cusp[2] = Asc1(th + 90 + xh2, fh2, sine, cose); + hsp->cusp[3] = Asc1(th + 90 + xh1, fh1, sine, cose); + /* within polar circle, when mc sinks below horizon and + * ascendant changes to western hemisphere, all cusps + * must be added 180 degrees. + * houses will be in clockwise direction */ + if (fabs(fi) >= 90 - ekl) { /* within polar circle */ + acmc = swe_difdeg2n(hsp->ac, hsp->mc); + if (acmc < 0) { + hsp->ac = swe_degnorm(hsp->ac + 180); + hsp->mc = swe_degnorm(hsp->mc + 180); + for (i = 1; i <= 12; i++) + hsp->cusp[i] = swe_degnorm(hsp->cusp[i] + 180); + } + } + if (hsy == 'H') { + for (i = 1; i <= 3; i++) + hsp->cusp[i] = swe_degnorm(hsp->cusp[i] + 180); + for (i = 11; i <= 12; i++) + hsp->cusp[i] = swe_degnorm(hsp->cusp[i] + 180); + /* restore fi and th */ + if (fi > 0) + fi = 90 - fi; + else + fi = -90 - fi; + th = swe_degnorm(th + 180); + acmc = swe_difdeg2n(hsp->ac, hsp->mc); + if (acmc < 0) { + hsp->ac = swe_degnorm(hsp->ac + 180); + } + } + break; + case 'K': /* Koch houses */ + if (fabs(fi) >= 90 - ekl) { /* within polar circle */ + retc = ERR; + goto porphyry; + } + sina = sind(hsp->mc) * sine / cosd(fi); + if (sina > 1) + sina = 1; + if (sina < -1) + sina = -1; + cosa = sqrt(1 - sina * sina); /* always >> 0 */ + c = atand(tanfi / cosa); + ad3 = asind(sind(c) * sina) / 3.0; + hsp->cusp[11] = Asc1(th + 30 - 2 * ad3, fi, sine, cose); + hsp->cusp[12] = Asc1(th + 60 - ad3, fi, sine, cose); + hsp->cusp[2] = Asc1(th + 120 + ad3, fi, sine, cose); + hsp->cusp[3] = Asc1(th + 150 + 2 * ad3, fi, sine, cose); + break; + case 'O': /* Porphyry houses */ +porphyry: + /* + * within polar circle we swap AC/DC if AC is on wrong side + */ + acmc = swe_difdeg2n(hsp->ac, hsp->mc); + if (acmc < 0) { + hsp->ac = swe_degnorm(hsp->ac + 180); + hsp->cusp[1] = hsp->ac; + acmc = swe_difdeg2n(hsp->ac, hsp->mc); + } + hsp->cusp[2] = swe_degnorm(hsp->ac + (180 - acmc) / 3); + hsp->cusp[3] = swe_degnorm(hsp->ac + (180 - acmc) / 3 * 2); + hsp->cusp[11] = swe_degnorm(hsp->mc + acmc / 3); + hsp->cusp[12] = swe_degnorm(hsp->mc + acmc / 3 * 2); + break; + case 'R': /* Regiomontanus houses */ + fh1 = atand(tanfi * 0.5); + fh2 = atand(tanfi * cosd(30)); + hsp->cusp[11] = Asc1(30 + th, fh1, sine, cose); + hsp->cusp[12] = Asc1(60 + th, fh2, sine, cose); + hsp->cusp[2] = Asc1(120 + th, fh2, sine, cose); + hsp->cusp[3] = Asc1(150 + th, fh1, sine, cose); + /* within polar circle, when mc sinks below horizon and + * ascendant changes to western hemisphere, all cusps + * must be added 180 degrees. + * houses will be in clockwise direction */ + if (fabs(fi) >= 90 - ekl) { /* within polar circle */ + acmc = swe_difdeg2n(hsp->ac, hsp->mc); + if (acmc < 0) { + hsp->ac = swe_degnorm(hsp->ac + 180); + hsp->mc = swe_degnorm(hsp->mc + 180); + for (i = 1; i <= 12; i++) + hsp->cusp[i] = swe_degnorm(hsp->cusp[i] + 180); + } + } + break; + case 'T': /* 'topocentric' houses */ + fh1 = atand(tanfi / 3.0); + fh2 = atand(tanfi * 2.0 / 3.0); + hsp->cusp[11] = Asc1(30 + th, fh1, sine, cose); + hsp->cusp[12] = Asc1(60 + th, fh2, sine, cose); + hsp->cusp[2] = Asc1(120 + th, fh2, sine, cose); + hsp->cusp[3] = Asc1(150 + th, fh1, sine, cose); + /* within polar circle, when mc sinks below horizon and + * ascendant changes to western hemisphere, all cusps + * must be added 180 degrees. + * houses will be in clockwise direction */ + if (fabs(fi) >= 90 - ekl) { /* within polar circle */ + acmc = swe_difdeg2n(hsp->ac, hsp->mc); + if (acmc < 0) { + hsp->ac = swe_degnorm(hsp->ac + 180); + hsp->mc = swe_degnorm(hsp->mc + 180); + for (i = 1; i <= 12; i++) + hsp->cusp[i] = swe_degnorm(hsp->cusp[i] + 180); + } + } + break; + case 'V': /* equal houses after Vehlow */ + /* + * within polar circle we swap AC/DC if AC is on wrong side + */ + acmc = swe_difdeg2n(hsp->ac, hsp->mc); + if (acmc < 0) { + hsp->ac = swe_degnorm(hsp->ac + 180); + hsp->cusp[1] = hsp->ac; + } + hsp->cusp[1] = swe_degnorm(hsp->ac - 15); + for (i = 2; i <= 12; i++) + hsp->cusp[i] = swe_degnorm(hsp->cusp[1] + (i - 1) * 30); + break; + case 'W': /* equal, whole-sign houses */ + /* + * within polar circle we swap AC/DC if AC is on wrong side + */ + acmc = swe_difdeg2n(hsp->ac, hsp->mc); + if (acmc < 0) { + hsp->ac = swe_degnorm(hsp->ac + 180); + hsp->cusp[1] = hsp->ac; + } + hsp->cusp[1] = hsp->ac - fmod(hsp->ac, 30); + for (i = 2; i <= 12; i++) + hsp->cusp[i] = swe_degnorm(hsp->cusp[1] + (i - 1) * 30); + break; + case 'X':{ + /* + * Meridian or axial rotation system: + * ecliptic points whose rectascensions + * are armc + n * 30 + */ + int j; + double a = th; + for (i = 1; i <= 12; i++) { + j = i + 10; + if (j > 12) + j -= 12; + a = swe_degnorm(a + 30); + if (fabs(a - 90) > VERY_SMALL + && fabs(a - 270) > VERY_SMALL) { + tant = tand(a); + hsp->cusp[j] = atand(tant / cose); + if (a > 90 && a <= 270) + hsp->cusp[j] = swe_degnorm(hsp->cusp[j] + 180); + } + else { + if (fabs(a - 90) <= VERY_SMALL) + hsp->cusp[j] = 90; + else + hsp->cusp[j] = 270; + } /* if */ + hsp->cusp[j] = swe_degnorm(hsp->cusp[j]); + } + acmc = swe_difdeg2n(hsp->ac, hsp->mc); + if (acmc < 0) { + hsp->ac = swe_degnorm(hsp->ac + 180); + } + break; + } + case 'M':{ + /* + * Morinus + * points of the equator (armc + n * 30) are transformed + * into the ecliptic coordinate system + */ + int j; + double a = th; + double x[3]; + for (i = 1; i <= 12; i++) { + j = i + 10; + if (j > 12) + j -= 12; + a = swe_degnorm(a + 30); + x[0] = a; + x[1] = 0; + swe_cotrans(x, x, ekl); + hsp->cusp[j] = x[0]; + } + acmc = swe_difdeg2n(hsp->ac, hsp->mc); + if (acmc < 0) { + hsp->ac = swe_degnorm(hsp->ac + 180); + } + break; + } + case 'B':{ /* Alcabitius */ + /* created by Alois 17-sep-2000, followed example in Matrix + * electrical library. The code reproduces the example! + * See http://www.astro.com/cgi/adict.cgi query: alcabitius + * in the resuotl page, see program code example. + * I think the Alcabitius code in Walter Pullen's Astrolog 5.40 + * is wrong, because he remains in RA and forgets the transform to + * the ecliptic. */ + double dek, r, sna, sda, sn3, sd3; +#if FALSE + if (fabs(fi) >= 90 - ekl) { /* within polar circle */ + retc = ERR; + goto porphyry; + } #endif - if (fabs(fi) >= 90 - ekl) { /* within polar circle */ - retc = ERR; - goto porphyry; - } - a = asind(tand(fi) * tane); - fh1 = atand(sind(a / 3) / tane); - fh2 = atand(sind(a * 2 / 3) / tane); - /* ************ house 11 ******************** */ - rectasc = swe_degnorm(30 + th); - tant = tand(asind(sine * sind(Asc1 (rectasc, fh1, sine, cose)))); - if (fabs(tant) < VERY_SMALL) { - hsp->cusp [11] = rectasc; - } else { - /* pole height */ - f = atand(sind(asind(tanfi * tant) / 3) /tant); - hsp->cusp [11] = Asc1 (rectasc, f, sine, cose); - for (i = 1; i <= iteration_count; i++) { - tant = tand(asind(sine * sind(hsp->cusp [11]))); - if (fabs(tant) < VERY_SMALL) { - hsp->cusp [11] = rectasc; - break; - } - /* pole height */ - f = atand(sind(asind(tanfi * tant) / 3) / tant); - hsp->cusp [11] = Asc1 (rectasc, f, sine, cose); - } + acmc = swe_difdeg2n(hsp->ac, hsp->mc); + if (acmc < 0) { + hsp->ac = swe_degnorm(hsp->ac + 180); + hsp->cusp[1] = hsp->ac; + acmc = swe_difdeg2n(hsp->ac, hsp->mc); + } + dek = asind(sind(hsp->ac) * sine); /* declination of Ascendant */ + /* must treat the case fi == 90 or -90 */ + r = -tanfi * tand(dek); + /* must treat the case of abs(r) > 1; probably does not happen + * because dek becomes smaller when fi is large, as ac is close to + * zero Aries/Libra in that case. + */ + sda = acos(r) * RADTODEG; /* semidiurnal arc, measured on equator */ + sna = 180 - sda; /* complement, seminocturnal arc */ + sd3 = sda / 3; + sn3 = sna / 3; + rectasc = swe_degnorm(th + sd3); /* cusp 11 */ + /* project rectasc onto eclipitic with pole height 0, i.e. along the + * declination circle */ + hsp->cusp[11] = Asc1(rectasc, 0, sine, cose); + rectasc = swe_degnorm(th + 2 * sd3); /* cusp 12 */ + hsp->cusp[12] = Asc1(rectasc, 0, sine, cose); + rectasc = swe_degnorm(th + 180 - 2 * sn3); /* cusp 2 */ + hsp->cusp[2] = Asc1(rectasc, 0, sine, cose); + rectasc = swe_degnorm(th + 180 - sn3); /* cusp 3 */ + hsp->cusp[3] = Asc1(rectasc, 0, sine, cose); + } + break; + case 'G': /* 36 Gauquelin sectors */ + for (i = 1; i <= 36; i++) { + hsp->cusp[i] = 0; + } + if (fabs(fi) >= 90 - ekl) { /* within polar circle */ + retc = ERR; + goto porphyry; + } + + /*************** forth/second quarter ***************/ + /* note: Gauquelin sectors are counted in clockwise direction */ + a = asind(tand(fi) * tane); + for (ih = 2; ih <= 9; ih++) { + ih2 = 10 - ih; + fh1 = atand(sind(a * ih2 / 9) / tane); + rectasc = swe_degnorm((90 / 9) * ih2 + th); + tant = + tand(asind(sine * sind(Asc1(rectasc, fh1, sine, cose)))); + if (fabs(tant) < VERY_SMALL) { + hsp->cusp[ih] = rectasc; + } + else { + /* pole height */ + f = atand(sind(asind(tanfi * tant) * ih2 / 9) / tant); + hsp->cusp[ih] = Asc1(rectasc, f, sine, cose); + for (i = 1; i <= iteration_count; i++) { + tant = tand(asind(sine * sind(hsp->cusp[ih]))); + if (fabs(tant) < VERY_SMALL) { + hsp->cusp[ih] = rectasc; + break; + } + /* pole height */ + f = atand(sind(asind(tanfi * tant) * ih2 / 9) / tant); + hsp->cusp[ih] = Asc1(rectasc, f, sine, cose); + } + } + hsp->cusp[ih + 18] = swe_degnorm(hsp->cusp[ih] + 180); + } + + /*************** first/third quarter ***************/ + for (ih = 29; ih <= 36; ih++) { + ih2 = ih - 28; + fh1 = atand(sind(a * ih2 / 9) / tane); + rectasc = swe_degnorm(180 - ih2 * 90 / 9 + th); + tant = + tand(asind(sine * sind(Asc1(rectasc, fh1, sine, cose)))); + if (fabs(tant) < VERY_SMALL) { + hsp->cusp[ih] = rectasc; + } + else { + f = atand(sind(asind(tanfi * tant) * ih2 / 9) / tant); + /* pole height */ + hsp->cusp[ih] = Asc1(rectasc, f, sine, cose); + for (i = 1; i <= iteration_count; i++) { + tant = tand(asind(sine * sind(hsp->cusp[ih]))); + if (fabs(tant) < VERY_SMALL) { + hsp->cusp[ih] = rectasc; + break; + } + f = atand(sind(asind(tanfi * tant) * ih2 / 9) / tant); + /* pole height */ + hsp->cusp[ih] = Asc1(rectasc, f, sine, cose); + } + } + hsp->cusp[ih - 18] = swe_degnorm(hsp->cusp[ih] + 180); + } + hsp->cusp[1] = hsp->ac; + hsp->cusp[10] = hsp->mc; + hsp->cusp[19] = swe_degnorm(hsp->ac + 180); + hsp->cusp[28] = swe_degnorm(hsp->mc + 180); + break; + case 'U': /* Krusinski-Pisa */ + /* + * The following code was written by Bogdan Krusinski in 2006. + * bogdan@astrologia.pl + * + * Definition: + * "Krusinski - house system based on the great circle passing through + * ascendant and zenith. This circle is divided into 12 equal parts + * (1st cusp is ascendent, 10th cusp is zenith), then the resulting + * points are projected onto the ecliptic through meridian circles. + * The house cusps in space are half-circles perpendicular to the equator + * and running from the north to the south celestial pole through the + * resulting cusp points on the house circle. The points where they + * cross the ecliptic mark the ecliptic house cusps." + * + * Description of the algorithm: + * Transform into great circle running through Asc and zenit (where arc + * between Asc and zenith is always 90 deg), and then return with + * house cusps into ecliptic. Eg. solve trigonometrical triangle + * with three transformations and two rotations starting from ecliptic. + * House cusps in space are meridian circles. + * + * Notes: + * 1. In this definition we assume MC on ecliptic as point where + * half-meridian (from north to south pole) cuts ecliptic, + * so MC may be below horizon in arctic regions. + * 2. Houses could be calculated in all latitudes except the poles + * themselves (-90,90) and points on arctic circle in cases where + * ecliptic is equal to horizon and then ascendant is undefined. + * But ascendant when 'horizon=ecliptic' could be deduced as limes + * from both sides of that point and houses with that provision can + * be computed also there. + * + * Starting values for calculations: + * - Asc ecliptic longitude + * - right ascension of MC (RAMC) + * - geographic latitude. + */ + /* + * within polar circle we swap AC/DC if AC is on wrong side + */ + acmc = swe_difdeg2n(hsp->ac, hsp->mc); + if (acmc < 0) { + hsp->ac = swe_degnorm(hsp->ac + 180); + } + /* A0. Start point - ecliptic coords of ascendant */ + x[0] = hsp->ac; /* Asc longitude */ + x[1] = 0.0; /* Asc declination */ + x[2] = 1.0; /* Radius to test validity of subsequent transformations. */ + swe_cotrans(x, x, -ekl); /* A1. Transform into equatorial coords */ + x[0] = x[0] - (th - 90); /* A2. Rotate */ + swe_cotrans(x, x, -(90 - fi)); /* A3. Transform into horizontal coords */ + krHorizonLon = x[0]; /* ...save asc lon on horizon to get back later with house cusp */ + x[0] = x[0] - x[0]; /* A4. Rotate */ + swe_cotrans(x, x, -90); /* A5. Transform into this house system great circle (asc-zenith) */ + /* As it is house circle now, simple add 30 deg increments... */ + for (i = 0; i < 6; i++) { + /* B0. Set 'n-th' house cusp. + * Note that IC/MC are also calculated here to check + * if really this is the asc-zenith great circle. */ + x[0] = 30.0 * i; + x[1] = 0.0; + swe_cotrans(x, x, 90); /* B1. Transform back into horizontal coords */ + x[0] = x[0] + krHorizonLon; /* B2. Rotate back. */ + swe_cotrans(x, x, 90 - fi); /* B3. Transform back into equatorial coords */ + x[0] = swe_degnorm(x[0] + (th - 90)); /* B4. Rotate back -> RA of house cusp as result. */ + /* B5. Where's this house cusp on ecliptic? */ + /* ... so last but not least - get ecliptic longitude of house cusp: */ + hsp->cusp[i + 1] = atand(tand(x[0]) / cosd(ekl)); + if (x[0] > 90 && x[0] <= 270) + hsp->cusp[i + 1] = swe_degnorm(hsp->cusp[i + 1] + 180); + hsp->cusp[i + 1] = swe_degnorm(hsp->cusp[i + 1]); + hsp->cusp[i + 7] = swe_degnorm(hsp->cusp[i + 1] + 180); + } + break; + default: /* Placidus houses */ +#ifndef _WINDOWS + if (hsy != 'P') + fprintf(stderr, "swe_houses: make Placidus, unknown key %c\n", + hsy); +#endif + if (fabs(fi) >= 90 - ekl) { /* within polar circle */ + retc = ERR; + goto porphyry; + } + a = asind(tand(fi) * tane); + fh1 = atand(sind(a / 3) / tane); + fh2 = atand(sind(a * 2 / 3) / tane); + /* ************ house 11 ******************** */ + rectasc = swe_degnorm(30 + th); + tant = tand(asind(sine * sind(Asc1(rectasc, fh1, sine, cose)))); + if (fabs(tant) < VERY_SMALL) { + hsp->cusp[11] = rectasc; + } + else { + /* pole height */ + f = atand(sind(asind(tanfi * tant) / 3) / tant); + hsp->cusp[11] = Asc1(rectasc, f, sine, cose); + for (i = 1; i <= iteration_count; i++) { + tant = tand(asind(sine * sind(hsp->cusp[11]))); + if (fabs(tant) < VERY_SMALL) { + hsp->cusp[11] = rectasc; + break; + } + /* pole height */ + f = atand(sind(asind(tanfi * tant) / 3) / tant); + hsp->cusp[11] = Asc1(rectasc, f, sine, cose); + } + } + /* ************ house 12 ******************** */ + rectasc = swe_degnorm(60 + th); + tant = tand(asind(sine * sind(Asc1(rectasc, fh2, sine, cose)))); + if (fabs(tant) < VERY_SMALL) { + hsp->cusp[12] = rectasc; + } + else { + f = atand(sind(asind(tanfi * tant) / 1.5) / tant); + /* pole height */ + hsp->cusp[12] = Asc1(rectasc, f, sine, cose); + for (i = 1; i <= iteration_count; i++) { + tant = tand(asind(sine * sind(hsp->cusp[12]))); + if (fabs(tant) < VERY_SMALL) { + hsp->cusp[12] = rectasc; + break; + } + f = atand(sind(asind(tanfi * tant) / 1.5) / tant); + /* pole height */ + hsp->cusp[12] = Asc1(rectasc, f, sine, cose); + } + } + /* ************ house 2 ******************** */ + rectasc = swe_degnorm(120 + th); + tant = tand(asind(sine * sind(Asc1(rectasc, fh2, sine, cose)))); + if (fabs(tant) < VERY_SMALL) { + hsp->cusp[2] = rectasc; + } + else { + f = atand(sind(asind(tanfi * tant) / 1.5) / tant); + /* pole height */ + hsp->cusp[2] = Asc1(rectasc, f, sine, cose); + for (i = 1; i <= iteration_count; i++) { + tant = tand(asind(sine * sind(hsp->cusp[2]))); + if (fabs(tant) < VERY_SMALL) { + hsp->cusp[2] = rectasc; + break; + } + f = atand(sind(asind(tanfi * tant) / 1.5) / tant); + /* pole height */ + hsp->cusp[2] = Asc1(rectasc, f, sine, cose); + } + } + /* ************ house 3 ******************** */ + rectasc = swe_degnorm(150 + th); + tant = tand(asind(sine * sind(Asc1(rectasc, fh1, sine, cose)))); + if (fabs(tant) < VERY_SMALL) { + hsp->cusp[3] = rectasc; + } + else { + f = atand(sind(asind(tanfi * tant) / 3) / tant); + /* pole height */ + hsp->cusp[3] = Asc1(rectasc, f, sine, cose); + for (i = 1; i <= iteration_count; i++) { + tant = tand(asind(sine * sind(hsp->cusp[3]))); + if (fabs(tant) < VERY_SMALL) { + hsp->cusp[3] = rectasc; + break; + } + f = atand(sind(asind(tanfi * tant) / 3) / tant); + /* pole height */ + hsp->cusp[3] = Asc1(rectasc, f, sine, cose); + } + } + break; + } /* end switch */ + if (hsy != 'G') { + hsp->cusp[4] = swe_degnorm(hsp->cusp[10] + 180); + hsp->cusp[5] = swe_degnorm(hsp->cusp[11] + 180); + hsp->cusp[6] = swe_degnorm(hsp->cusp[12] + 180); + hsp->cusp[7] = swe_degnorm(hsp->cusp[1] + 180); + hsp->cusp[8] = swe_degnorm(hsp->cusp[2] + 180); + hsp->cusp[9] = swe_degnorm(hsp->cusp[3] + 180); } - /* ************ house 12 ******************** */ - rectasc = swe_degnorm(60 + th); - tant = tand(asind(sine*sind(Asc1 (rectasc, fh2, sine, cose)))); - if (fabs(tant) < VERY_SMALL) { - hsp->cusp [12] = rectasc; - } else { - f = atand(sind(asind(tanfi * tant) / 1.5) / tant); - /* pole height */ - hsp->cusp [12] = Asc1 (rectasc, f, sine, cose); - for (i = 1; i <= iteration_count; i++) { - tant = tand(asind(sine * sind(hsp->cusp [12]))); - if (fabs(tant) < VERY_SMALL) { - hsp->cusp [12] = rectasc; - break; - } - f = atand(sind(asind(tanfi * tant) / 1.5) / tant); - /* pole height */ - hsp->cusp [12] = Asc1 (rectasc, f, sine, cose); - } - } - /* ************ house 2 ******************** */ - rectasc = swe_degnorm(120 + th); - tant = tand(asind(sine * sind(Asc1 (rectasc, fh2, sine, cose)))); - if (fabs(tant) < VERY_SMALL) { - hsp->cusp [2] = rectasc; - } else { - f = atand(sind(asind(tanfi * tant) / 1.5) / tant); - /* pole height */ - hsp->cusp [2] = Asc1 (rectasc, f, sine, cose); - for (i = 1; i <= iteration_count; i++) { - tant = tand(asind(sine * sind(hsp->cusp [2]))); - if (fabs(tant) < VERY_SMALL) { - hsp->cusp [2] = rectasc; - break; - } - f = atand(sind(asind(tanfi * tant) / 1.5) / tant); - /* pole height */ - hsp->cusp [2] = Asc1 (rectasc, f, sine, cose); - } - } - /* ************ house 3 ******************** */ - rectasc = swe_degnorm(150 + th); - tant = tand(asind(sine * sind(Asc1 (rectasc, fh1, sine, cose)))); - if (fabs(tant) < VERY_SMALL) { - hsp->cusp [3] = rectasc; - } else { - f = atand(sind(asind(tanfi * tant) / 3) / tant); - /* pole height */ - hsp->cusp [3] = Asc1(rectasc, f, sine, cose); - for (i = 1; i <= iteration_count; i++) { - tant = tand(asind(sine * sind(hsp->cusp [3]))); - if (fabs(tant) < VERY_SMALL) { - hsp->cusp [3] = rectasc; - break; - } - f = atand(sind(asind(tanfi * tant) / 3) / tant); - /* pole height */ - hsp->cusp [3] = Asc1 (rectasc, f, sine, cose); - } - } - break; - } /* end switch */ - if (hsy != 'G') { - hsp->cusp [4] = swe_degnorm(hsp->cusp [10] + 180); - hsp->cusp [5] = swe_degnorm(hsp->cusp [11] + 180); - hsp->cusp [6] = swe_degnorm(hsp->cusp [12] + 180); - hsp->cusp [7] = swe_degnorm(hsp->cusp [1] + 180); - hsp->cusp [8] = swe_degnorm(hsp->cusp [2] + 180); - hsp->cusp [9] = swe_degnorm(hsp->cusp [3] + 180); - } - /* vertex */ - if (fi >= 0) - f = 90 - fi; - else - f = -90 - fi; - hsp->vertex = Asc1 (th - 90, f, sine, cose); - /* with tropical latitudes, the vertex behaves strange, - * in a similar way as the ascendant within the polar - * circle. we keep it always on the western hemisphere.*/ - if (fabs(fi) <= ekl) { - vemc = swe_difdeg2n(hsp->vertex, hsp->mc); - if (vemc > 0) - hsp->vertex = swe_degnorm(hsp->vertex + 180); - } - /* - * some strange points: - */ - /* equasc (equatorial ascendant) */ - th2 = swe_degnorm(th + 90); - if (fabs(th2 - 90) > VERY_SMALL - && fabs(th2 - 270) > VERY_SMALL) { - tant = tand(th2); - hsp->equasc = atand(tant / cose); - if (th2 > 90 && th2 <= 270) - hsp->equasc = swe_degnorm(hsp->equasc + 180); - } else { - if (fabs(th2 - 90) <= VERY_SMALL) - hsp->equasc = 90; + /* vertex */ + if (fi >= 0) + f = 90 - fi; else - hsp->equasc = 270; - } /* if */ - hsp->equasc = swe_degnorm(hsp->equasc); - /* "co-ascendant" W. Koch */ - hsp->coasc1 = swe_degnorm(Asc1 (th - 90, fi, sine, cose) + 180); - /* "co-ascendant" M. Munkasey */ - if (fi >= 0) - hsp->coasc2 = Asc1 (th + 90, 90 - fi, sine, cose); - else /* southern hemisphere */ - hsp->coasc2 = Asc1 (th + 90, -90 - fi, sine, cose); - /* "polar ascendant" M. Munkasey */ - hsp->polasc = Asc1 (th - 90, fi, sine, cose); - return retc; -} /* procedure houses */ + f = -90 - fi; + hsp->vertex = Asc1(th - 90, f, sine, cose); + /* with tropical latitudes, the vertex behaves strange, + * in a similar way as the ascendant within the polar + * circle. we keep it always on the western hemisphere.*/ + if (fabs(fi) <= ekl) { + vemc = swe_difdeg2n(hsp->vertex, hsp->mc); + if (vemc > 0) + hsp->vertex = swe_degnorm(hsp->vertex + 180); + } + /* + * some strange points: + */ + /* equasc (equatorial ascendant) */ + th2 = swe_degnorm(th + 90); + if (fabs(th2 - 90) > VERY_SMALL && fabs(th2 - 270) > VERY_SMALL) { + tant = tand(th2); + hsp->equasc = atand(tant / cose); + if (th2 > 90 && th2 <= 270) + hsp->equasc = swe_degnorm(hsp->equasc + 180); + } + else { + if (fabs(th2 - 90) <= VERY_SMALL) + hsp->equasc = 90; + else + hsp->equasc = 270; + } /* if */ + hsp->equasc = swe_degnorm(hsp->equasc); + /* "co-ascendant" W. Koch */ + hsp->coasc1 = swe_degnorm(Asc1(th - 90, fi, sine, cose) + 180); + /* "co-ascendant" M. Munkasey */ + if (fi >= 0) + hsp->coasc2 = Asc1(th + 90, 90 - fi, sine, cose); + else /* southern hemisphere */ + hsp->coasc2 = Asc1(th + 90, -90 - fi, sine, cose); + /* "polar ascendant" M. Munkasey */ + hsp->polasc = Asc1(th - 90, fi, sine, cose); + return retc; +} /* procedure houses */ /******************************/ -static double Asc1 (double x1, double f, double sine, double cose) -{ - int n; - double ass; - x1 = swe_degnorm(x1); - n = (int) ((x1 / 90) + 1); - if (n == 1) - ass = ( Asc2 (x1, f, sine, cose)); - else if (n == 2) - ass = (180 - Asc2 (180 - x1, - f, sine, cose)); - else if (n == 3) - ass = (180 + Asc2 (x1 - 180, - f, sine, cose)); - else - ass = (360 - Asc2 (360- x1, f, sine, cose)); - ass = swe_degnorm(ass); - if (fabs(ass - 90) < VERY_SMALL) /* rounding, e.g.: if */ - ass = 90; /* fi = 0 & st = 0, ac = 89.999... */ - if (fabs(ass - 180) < VERY_SMALL) - ass = 180; - if (fabs(ass - 270) < VERY_SMALL) /* rounding, e.g.: if */ - ass = 270; /* fi = 0 & st = 0, ac = 89.999... */ - if (fabs(ass - 360) < VERY_SMALL) - ass = 0; - return ass; -} /* Asc1 */ - -static double Asc2 (double x, double f, double sine, double cose) +static double +Asc1(double x1, double f, double sine, double cose) { - double ass, sinx; - ass = - tand(f) * sine + cose * cosd(x); - if (fabs(ass) < VERY_SMALL) - ass = 0; - sinx = sind(x); - if (fabs(sinx) < VERY_SMALL) - sinx = 0; - if (sinx == 0) { + int n; + double ass; + x1 = swe_degnorm(x1); + n = (int)((x1 / 90) + 1); + if (n == 1) + ass = (Asc2(x1, f, sine, cose)); + else if (n == 2) + ass = (180 - Asc2(180 - x1, -f, sine, cose)); + else if (n == 3) + ass = (180 + Asc2(x1 - 180, -f, sine, cose)); + else + ass = (360 - Asc2(360 - x1, f, sine, cose)); + ass = swe_degnorm(ass); + if (fabs(ass - 90) < VERY_SMALL) /* rounding, e.g.: if */ + ass = 90; /* fi = 0 & st = 0, ac = 89.999... */ + if (fabs(ass - 180) < VERY_SMALL) + ass = 180; + if (fabs(ass - 270) < VERY_SMALL) /* rounding, e.g.: if */ + ass = 270; /* fi = 0 & st = 0, ac = 89.999... */ + if (fabs(ass - 360) < VERY_SMALL) + ass = 0; + return ass; +} /* Asc1 */ + +static double +Asc2(double x, double f, double sine, double cose) +{ + double ass, sinx; + ass = -tand(f) * sine + cose * cosd(x); + if (fabs(ass) < VERY_SMALL) + ass = 0; + sinx = sind(x); + if (fabs(sinx) < VERY_SMALL) + sinx = 0; + if (sinx == 0) { + if (ass < 0) + ass = -VERY_SMALL; + else + ass = VERY_SMALL; + } + else if (ass == 0) { + if (sinx < 0) + ass = -90; + else + ass = 90; + } + else { + ass = atand(sinx / ass); + } if (ass < 0) - ass = -VERY_SMALL; - else - ass = VERY_SMALL; - } else if (ass == 0) { - if (sinx < 0) - ass = -90; - else - ass = 90; - } else { - ass = atand(sinx / ass); - } - if (ass < 0) - ass = 180 + ass; - return (ass); -} /* Asc2 */ + ass = 180 + ass; + return (ass); +} /* Asc2 */ /* Computes the house position of a planet or another point, @@ -1292,448 +1298,471 @@ static double Asc2 (double x, double f, double sine, double cose) * equal, Porphyry, Alcabitius, Koch, Krusinski (all others should work). * The Swiss Ephemeris currently does not handle these cases. */ -double FAR PASCAL_CONV swe_house_pos( - double armc, double geolat, double eps, int hsys, double *xpin, char *serr) +double FAR PASCAL_CONV +swe_house_pos(double armc, double geolat, double eps, int hsys, double *xpin, + char *serr) { - double xp[6], xeq[6], ra, de, mdd, mdn, sad, san; - double hpos, sinad, ad, a, admc, adp, samc, demc, asc, mc, acmc, tant; - double fh, ra0, tanfi, fac, dfac; - double x[3], xasc[3], raep, raaz, oblaz, xtemp; /* BK 21.02.2006 */ - double sine = sind(eps); - double cose = cosd(eps); - AS_BOOL is_above_hor = FALSE; - AS_BOOL is_invalid = FALSE; - AS_BOOL is_circumpolar = FALSE; - if (serr != NULL) - *serr = '\0'; - hsys = toupper(hsys); - xeq[0] = xpin[0]; - xeq[1] = xpin[1]; - xeq[2] = 1; - swe_cotrans(xpin, xeq, -eps); - ra = xeq[0]; - de = xeq[1]; - mdd = swe_degnorm(ra - armc); - mdn = swe_degnorm(mdd + 180); - if (mdd >= 180) - mdd -= 360; - if (mdn >= 180) - mdn -= 360; - /* xp[0] will contain the house position, a value between 0 and 360 */ - switch(hsys) { - case 'A': - case 'E': - case 'V': - case 'W': - asc = Asc1 (swe_degnorm(armc + 90), geolat, sine, cose); - demc = atand(sind(armc) * tand(eps)); - if (geolat >= 0 && 90 - geolat + demc < 0) - asc = swe_degnorm(asc + 180); - if (geolat < 0 && -90 - geolat + demc > 0) - asc = swe_degnorm(asc + 180); - xp[0] = swe_degnorm(xpin[0] - asc); - if (hsys == 'V') - xp[0] = swe_degnorm(xp[0] + 15); - if (hsys == 'W') - xp[0] = swe_degnorm(xp[0] + fmod(asc, 30)); - /* to make sure that a call with a house cusp position returns - * a value within the house, 0.001" is added */ - xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); - hpos = xp[0] / 30.0 + 1; - break; - case 'O': /* Porphyry */ - case 'B': /* Alcabitius */ - asc = Asc1 (swe_degnorm(armc + 90), geolat, sine, cose); - demc = atand(sind(armc) * tand(eps)); - /* mc */ - if (fabs(armc - 90) > VERY_SMALL - && fabs(armc - 270) > VERY_SMALL) { - tant = tand(armc); - mc = swe_degnorm(atand(tant / cose)); - if (armc > 90 && armc <= 270) - mc = swe_degnorm(mc + 180); - } else { - if (fabs(armc - 90) <= VERY_SMALL) - mc = 90; - else - mc = 270; - } - /* while MC is always south, - * Asc must always be in eastern hemisphere */ - if (geolat >= 0 && 90 - geolat + demc < 0) { - asc = swe_degnorm(asc + 180); - } - if (geolat < 0 && -90 - geolat + demc > 0) { - asc = swe_degnorm(asc + 180); - } - if (hsys == 'O') { - xp[0] = swe_degnorm(xpin[0] - asc); - /* to make sure that a call with a house cusp position returns - * a value within the house, 0.001" is added */ - xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); - if (xp[0] < 180) - hpos = 1; - else { - hpos = 7; - xp[0] -= 180; - } - acmc = swe_difdeg2n(asc, mc); - if (xp[0] < 180 - acmc) - hpos += xp[0] * 3 / (180 - acmc); - else - hpos += 3 + (xp[0] - 180 + acmc) * 3 / acmc; - } else { /* Alcabitius */ - double dek, r, sna, sda; - dek = asind(sind(asc) * sine); /* declination of Ascendant */ - /* must treat the case fi == 90 or -90 */ - tanfi = tand(geolat); - r = -tanfi * tand(dek); - /* must treat the case of abs(r) > 1; probably does not happen - * because dek becomes smaller when fi is large, as ac is close to - * zero Aries/Libra in that case. - */ - sda = acos(r) * RADTODEG; /* semidiurnal arc, measured on equator */ - sna = 180 - sda; /* complement, seminocturnal arc */ - if (mdd > 0) { - if (mdd < sda) - hpos = mdd * 90 / sda; - else - hpos = 90 + (mdd - sda) * 90 / sna; - } else { - if (mdd > -sna) - hpos = 360 + mdd * 90 / sna; - else - hpos = 270 + (mdd + sna) * 90 / sda; - } - hpos = swe_degnorm(hpos - 90) / 30.0 + 1.0; - if (hpos >= 13.0) hpos -= 12; - } - break; - case 'X': /* Merdidian or axial rotation system */ - hpos = swe_degnorm(mdd - 90) / 30.0 + 1.0; - break; - case 'M': { /* Morinus */ - double a = xpin[0]; - if (fabs(a - 90) > VERY_SMALL - && fabs(a - 270) > VERY_SMALL) { - tant = tand(a); - hpos = atand(tant / cose); - if (a > 90 && a <= 270) - hpos = swe_degnorm(hpos + 180); - } else { - if (fabs(a - 90) <= VERY_SMALL) - hpos = 90; - else - hpos = 270; - } /* if */ - hpos = swe_degnorm(hpos - armc - 90); - hpos = hpos / 30.0 + 1; + double xp[6], xeq[6], ra, de, mdd, mdn, sad, san; + double hpos, sinad, ad, a, admc, adp, samc, demc, asc, mc, acmc, tant; + double fh, ra0, tanfi, fac, dfac; + double x[3], xasc[3], raep, raaz, oblaz, xtemp; /* BK 21.02.2006 */ + double sine = sind(eps); + double cose = cosd(eps); + AS_BOOL is_above_hor = FALSE; + AS_BOOL is_invalid = FALSE; + AS_BOOL is_circumpolar = FALSE; + if (serr != NULL) + *serr = '\0'; + hsys = toupper(hsys); + xeq[0] = xpin[0]; + xeq[1] = xpin[1]; + xeq[2] = 1; + swe_cotrans(xpin, xeq, -eps); + ra = xeq[0]; + de = xeq[1]; + mdd = swe_degnorm(ra - armc); + mdn = swe_degnorm(mdd + 180); + if (mdd >= 180) + mdd -= 360; + if (mdn >= 180) + mdn -= 360; + /* xp[0] will contain the house position, a value between 0 and 360 */ + switch (hsys) { + case 'A': + case 'E': + case 'V': + case 'W': + asc = Asc1(swe_degnorm(armc + 90), geolat, sine, cose); + demc = atand(sind(armc) * tand(eps)); + if (geolat >= 0 && 90 - geolat + demc < 0) + asc = swe_degnorm(asc + 180); + if (geolat < 0 && -90 - geolat + demc > 0) + asc = swe_degnorm(asc + 180); + xp[0] = swe_degnorm(xpin[0] - asc); + if (hsys == 'V') + xp[0] = swe_degnorm(xp[0] + 15); + if (hsys == 'W') + xp[0] = swe_degnorm(xp[0] + fmod(asc, 30)); + /* to make sure that a call with a house cusp position returns + * a value within the house, 0.001" is added */ + xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); + hpos = xp[0] / 30.0 + 1; + break; + case 'O': /* Porphyry */ + case 'B': /* Alcabitius */ + asc = Asc1(swe_degnorm(armc + 90), geolat, sine, cose); + demc = atand(sind(armc) * tand(eps)); + /* mc */ + if (fabs(armc - 90) > VERY_SMALL && fabs(armc - 270) > VERY_SMALL) { + tant = tand(armc); + mc = swe_degnorm(atand(tant / cose)); + if (armc > 90 && armc <= 270) + mc = swe_degnorm(mc + 180); + } + else { + if (fabs(armc - 90) <= VERY_SMALL) + mc = 90; + else + mc = 270; + } + /* while MC is always south, + * Asc must always be in eastern hemisphere */ + if (geolat >= 0 && 90 - geolat + demc < 0) { + asc = swe_degnorm(asc + 180); + } + if (geolat < 0 && -90 - geolat + demc > 0) { + asc = swe_degnorm(asc + 180); + } + if (hsys == 'O') { + xp[0] = swe_degnorm(xpin[0] - asc); + /* to make sure that a call with a house cusp position returns + * a value within the house, 0.001" is added */ + xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); + if (xp[0] < 180) + hpos = 1; + else { + hpos = 7; + xp[0] -= 180; + } + acmc = swe_difdeg2n(asc, mc); + if (xp[0] < 180 - acmc) + hpos += xp[0] * 3 / (180 - acmc); + else + hpos += 3 + (xp[0] - 180 + acmc) * 3 / acmc; + } + else { /* Alcabitius */ + double dek, r, sna, sda; + dek = asind(sind(asc) * sine); /* declination of Ascendant */ + /* must treat the case fi == 90 or -90 */ + tanfi = tand(geolat); + r = -tanfi * tand(dek); + /* must treat the case of abs(r) > 1; probably does not happen + * because dek becomes smaller when fi is large, as ac is close to + * zero Aries/Libra in that case. + */ + sda = acos(r) * RADTODEG; /* semidiurnal arc, measured on equator */ + sna = 180 - sda; /* complement, seminocturnal arc */ + if (mdd > 0) { + if (mdd < sda) + hpos = mdd * 90 / sda; + else + hpos = 90 + (mdd - sda) * 90 / sna; + } + else { + if (mdd > -sna) + hpos = 360 + mdd * 90 / sna; + else + hpos = 270 + (mdd + sna) * 90 / sda; + } + hpos = swe_degnorm(hpos - 90) / 30.0 + 1.0; + if (hpos >= 13.0) + hpos -= 12; + } + break; + case 'X': /* Merdidian or axial rotation system */ + hpos = swe_degnorm(mdd - 90) / 30.0 + 1.0; + break; + case 'M':{ /* Morinus */ + double a = xpin[0]; + if (fabs(a - 90) > VERY_SMALL && fabs(a - 270) > VERY_SMALL) { + tant = tand(a); + hpos = atand(tant / cose); + if (a > 90 && a <= 270) + hpos = swe_degnorm(hpos + 180); + } + else { + if (fabs(a - 90) <= VERY_SMALL) + hpos = 90; + else + hpos = 270; + } /* if */ + hpos = swe_degnorm(hpos - armc - 90); + hpos = hpos / 30.0 + 1; + } + break; +#if 0 + /* old version of Koch method */ + case 'K': + demc = atand(sind(armc) * tand(eps)); + /* if body is within circumpolar region, error */ + if (90 - fabs(geolat) <= fabs(de)) { + if (serr != NULL) + strcpy(serr, + "no Koch house position, because planet is circumpolar."); + xp[0] = 0; + hpos = 0; /* Error */ + } + else if (90 - fabs(geolat) <= fabs(demc)) { + if (serr != NULL) + strcpy(serr, + "no Koch house position, because mc is circumpolar."); + xp[0] = 0; + hpos = 0; /* Error */ + } + else { + admc = asind(tand(eps) * tand(geolat) * sind(armc)); + adp = asind(tand(geolat) * tand(de)); + samc = 90 + admc; + if (mdd >= 0) { /* east */ + xp[0] = swe_degnorm(((mdd - adp + admc) / samc - 1) * 90); + } + else { + xp[0] = + swe_degnorm(((mdd + 180 + adp + admc) / samc + + 1) * 90); + } + /* to make sure that a call with a house cusp position returns + * a value within the house, 0.001" is added */ + xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); + hpos = xp[0] / 30.0 + 1; + } + break; +#endif + /* version of Koch method: do calculations within circumpolar circle, + * if possible; make sure house positions 4 - 9 only appear on western + * hemisphere */ + case 'K': + demc = atand(sind(armc) * tand(eps)); + is_invalid = FALSE; + is_circumpolar = FALSE; + /* object is within a circumpolar circle */ + if (90 - geolat < de || -90 - geolat > de) { + adp = 90; + is_circumpolar = TRUE; + } + /* object is within a circumpolar circle, southern hemisphere */ + else if (geolat - 90 > de || geolat + 90 < de) { + adp = -90; + is_circumpolar = TRUE; + } + /* object does rise and set */ + else { + adp = asind(tand(geolat) * tand(de)); + } +#if 0 + if (fabs(adp) == 90) + is_invalid = TRUE; /* omit this to use the above values */ +#endif + admc = tand(eps) * tand(geolat) * sind(armc); + /* midheaven is circumpolar */ + if (fabs(admc) > 1) { +#if 0 + is_invalid = TRUE; /* omit this line to use the below values */ +#endif + if (admc > 1) + admc = 1; + else + admc = -1; + is_circumpolar = TRUE; + } + admc = asind(admc); + samc = 90 + admc; + if (samc == 0) + is_invalid = TRUE; + if (fabs(samc) > 0) { + if (mdd >= 0) { /* east */ + dfac = (mdd - adp + admc) / samc; + xp[0] = swe_degnorm((dfac - 1) * 90); + xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); + /* eastern object has longer SA than midheaven */ + if (dfac > 2 || dfac < 0) + is_invalid = TRUE; /* if this is omitted, funny things happen */ + } + else { + dfac = (mdd + 180 + adp + admc) / samc; + xp[0] = swe_degnorm((dfac + 1) * 90); + xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); + /* western object has longer SA than midheaven */ + if (dfac > 2 || dfac < 0) + is_invalid = TRUE; /* if this is omitted, funny things happen */ + } + } + if (is_invalid) { + xp[0] = 0; + hpos = 0; + if (serr != NULL) + strcpy(serr, + "Koch house position failed in circumpolar area"); + break; + } + if (is_circumpolar) { + if (serr != NULL) + strcpy(serr, + "Koch house position, doubtful result in circumpolar area"); + } + /* to make sure that a call with a house cusp position returns + * a value within the house, 0.001" is added */ + hpos = xp[0] / 30.0 + 1; + break; + case 'C': + xeq[0] = swe_degnorm(mdd - 90); + swe_cotrans(xeq, xp, -geolat); + /* to make sure that a call with a house cusp position returns + * a value within the house, 0.001" is added */ + xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); + hpos = xp[0] / 30.0 + 1; + break; + case 'U': /* Krusinski-Pisa-Goelzer */ + /* Purpose: find point where planet's house circle (meridian) + * cuts house plane, giving exact planet's house position. + * Input data: ramc, geolat, asc. + */ + asc = Asc1(swe_degnorm(armc + 90), geolat, sine, cose); + demc = atand(sind(armc) * tand(eps)); + /* while MC is always south, + * Asc must always be in eastern hemisphere */ + if (geolat >= 0 && 90 - geolat + demc < 0) { + asc = swe_degnorm(asc + 180); + } + if (geolat < 0 && -90 - geolat + demc > 0) { + asc = swe_degnorm(asc + 180); + } + /* + * Descr: find the house plane 'asc-zenith' - where it intersects + * with equator and at what angle, and then simple find arc + * from asc on that plane to planet's meridian intersection + * with this plane. + */ + /* I. find plane of 'asc-zenith' great circle relative to equator: + * solve spherical triangle 'EP-asc-intersection of house circle with equator' */ + /* Ia. Find intersection of house plane with equator: */ + x[0] = asc; + x[1] = 0.0; + x[2] = 1.0; /* 1. Start with ascendent on ecliptic */ + swe_cotrans(x, x, -eps); /* 2. Transform asc into equatorial coords */ + raep = swe_degnorm(armc + 90); /* 3. RA of east point */ + x[0] = swe_degnorm(raep - x[0]); /* 4. Rotation - found arc raas-raep */ + swe_cotrans(x, x, -(90 - geolat)); /* 5. Transform into horizontal coords - arc EP-asc on horizon */ + xtemp = atand(tand(x[0]) / cosd((90 - geolat))); /* 6. Rotation from horizon on circle perpendicular to equator */ + if (x[0] > 90 && x[0] <= 270) + xtemp = swe_degnorm(xtemp + 180); + x[0] = swe_degnorm(xtemp); + raaz = swe_degnorm(raep - x[0]); /* result: RA of intersection 'asc-zenith' great circle with equator */ + /* Ib. Find obliquity to equator of 'asc-zenith' house plane: */ + x[0] = raaz; + x[1] = 0.0; + x[0] = swe_degnorm(raep - x[0]); /* 1. Rotate start point relative to EP */ + swe_cotrans(x, x, -(90 - geolat)); /* 2. Transform into horizontal coords */ + x[1] = x[1] + 90; /* 3. Add 90 deg do decl - so get the point on house plane most distant from equ. */ + swe_cotrans(x, x, 90 - geolat); /* 4. Rotate back to equator */ + oblaz = x[1]; /* 5. Obliquity of house plane to equator */ + /* II. Next find asc and planet position on house plane, + * so to find relative distance of planet from + * coords beginning. */ + /* IIa. Asc on house plane relative to intersection + * of equator with 'asc-zenith' plane. */ + xasc[0] = asc; + xasc[1] = 0.0; + xasc[2] = 1.0; + swe_cotrans(xasc, xasc, -eps); + xasc[0] = swe_degnorm(xasc[0] - raaz); + xtemp = atand(tand(xasc[0]) / cosd(oblaz)); + if (xasc[0] > 90 && xasc[0] <= 270) + xtemp = swe_degnorm(xtemp + 180); + xasc[0] = swe_degnorm(xtemp); + /* IIb. Planet on house plane relative to intersection + * of equator with 'asc-zenith' plane */ + xp[0] = swe_degnorm(xeq[0] - raaz); /* Rotate on equator */ + xtemp = atand(tand(xp[0]) / cosd(oblaz)); /* Find arc on house plane from equator */ + if (xp[0] > 90 && xp[0] <= 270) + xtemp = swe_degnorm(xtemp + 180); + xp[0] = swe_degnorm(xtemp); + xp[0] = swe_degnorm(xp[0] - xasc[0]); /* find arc between asc and planet, and get planet house position */ + /* IIc. Distance from planet to house plane on declination circle: */ + x[0] = xeq[0]; + x[1] = xeq[1]; + swe_cotrans(x, x, oblaz); + xp[1] = xeq[1] - x[1]; /* How many degrees is the point on declination circle from house circle */ + /* to make sure that a call with a house cusp position returns + * a value within the house, 0.001" is added */ + xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); + hpos = xp[0] / 30.0 + 1; + break; + case 'H': + xeq[0] = swe_degnorm(mdd - 90); + swe_cotrans(xeq, xp, 90 - geolat); + /* to make sure that a call with a house cusp position returns + * a value within the house, 0.001" is added */ + xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); + hpos = xp[0] / 30.0 + 1; + break; + case 'R': + if (fabs(mdd) < VERY_SMALL) + xp[0] = 270; + else if (180 - fabs(mdd) < VERY_SMALL) + xp[0] = 90; + else { + if (90 - fabs(geolat) < VERY_SMALL) { + if (geolat > 0) + geolat = 90 - VERY_SMALL; + else + geolat = -90 + VERY_SMALL; + } + if (90 - fabs(de) < VERY_SMALL) { + if (de > 0) + de = 90 - VERY_SMALL; + else + de = -90 + VERY_SMALL; + } + a = tand(geolat) * tand(de) + cosd(mdd); + xp[0] = swe_degnorm(atand(-a / sind(mdd))); + if (mdd < 0) + xp[0] += 180; + xp[0] = swe_degnorm(xp[0]); + /* to make sure that a call with a house cusp position returns + * a value within the house, 0.001" is added */ + xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); + } + hpos = xp[0] / 30.0 + 1; + break; + case 'T': + mdd = swe_degnorm(mdd); + if (de > 90 - VERY_SMALL) + de = 90 - VERY_SMALL; + if (de < -90 + VERY_SMALL) + de = -90 + VERY_SMALL; + sinad = tand(de) * tand(geolat); + ad = asind(sinad); + a = sinad + cosd(mdd); + if (a >= 0) + is_above_hor = TRUE; + /* mirror everything below the horizon to the opposite point + * above the horizon */ + if (!is_above_hor) { + ra = swe_degnorm(ra + 180); + de = -de; + mdd = swe_degnorm(mdd + 180); + } + /* mirror everything on western hemisphere to eastern hemisphere */ + if (mdd > 180) { + ra = swe_degnorm(armc - mdd); + } + /* binary search for "topocentric" position line of body */ + tanfi = tand(geolat); + fh = geolat; + ra0 = swe_degnorm(armc + 90); + xp[1] = 1; + xeq[1] = de; + fac = 2; + while (fabs(xp[1]) > 0.000001) { + if (xp[1] > 0) { + fh = atand(tand(fh) - tanfi / fac); + ra0 -= 90 / fac; + } + else { + fh = atand(tand(fh) + tanfi / fac); + ra0 += 90 / fac; + } + xeq[0] = swe_degnorm(ra - ra0); + swe_cotrans(xeq, xp, 90 - fh); + fac *= 2; + } + hpos = swe_degnorm(ra0 - armc); + /* mirror back to west */ + if (mdd > 180) + hpos = swe_degnorm(-hpos); + /* mirror back to below horizon */ + if (!is_above_hor) + hpos = swe_degnorm(hpos + 180); + hpos = swe_degnorm(hpos - 90) / 30 + 1; + break; + case 'P': + case 'G': + default: + /* circumpolar region */ + if (90 - fabs(de) <= fabs(geolat)) { + if (de * geolat < 0) + xp[0] = swe_degnorm(90 + mdn / 2); + else + xp[0] = swe_degnorm(270 + mdd / 2); + if (serr != NULL) + strcpy(serr, + "Otto Ludwig procedure within circumpolar regions."); + } + else { + sinad = tand(de) * tand(geolat); + ad = asind(sinad); + a = sinad + cosd(mdd); + if (a >= 0) + is_above_hor = TRUE; + sad = 90 + ad; + san = 90 - ad; + if (is_above_hor) + xp[0] = (mdd / sad + 3) * 90; + else + xp[0] = (mdn / san + 1) * 90; + /* to make sure that a call with a house cusp position returns + * a value within the house, 0.001" is added */ + xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); + } + if (hsys == 'G') { + xp[0] = 360 - xp[0]; /* Gauquelin sectors are in clockwise direction */ + hpos = xp[0] / 10.0 + 1; + } + else { + hpos = xp[0] / 30.0 + 1; + } + break; } - break; -#if 0 - /* old version of Koch method */ - case 'K': - demc = atand(sind(armc) * tand(eps)); - /* if body is within circumpolar region, error */ - if (90 - fabs(geolat) <= fabs(de)) { - if (serr != NULL) - strcpy(serr, "no Koch house position, because planet is circumpolar."); - xp[0] = 0; - hpos = 0; /* Error */ - } else if (90 - fabs(geolat) <= fabs(demc)) { - if (serr != NULL) - strcpy(serr, "no Koch house position, because mc is circumpolar."); - xp[0] = 0; - hpos = 0; /* Error */ - } else { - admc = asind(tand(eps) * tand(geolat) * sind(armc)); - adp = asind(tand(geolat) * tand(de)); - samc = 90 + admc; - if (mdd >= 0) { /* east */ - xp[0] = swe_degnorm(((mdd - adp + admc) / samc - 1) * 90); - } else { - xp[0] = swe_degnorm(((mdd + 180 + adp + admc) / samc + 1) * 90); - } - /* to make sure that a call with a house cusp position returns - * a value within the house, 0.001" is added */ - xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); - hpos = xp[0] / 30.0 + 1; - } - break; -#endif - /* version of Koch method: do calculations within circumpolar circle, - * if possible; make sure house positions 4 - 9 only appear on western - * hemisphere */ - case 'K': - demc = atand(sind(armc) * tand(eps)); - is_invalid = FALSE; - is_circumpolar = FALSE; - /* object is within a circumpolar circle */ - if (90 - geolat < de || -90 - geolat > de) { - adp = 90; - is_circumpolar = TRUE; - } - /* object is within a circumpolar circle, southern hemisphere */ - else if (geolat - 90 > de || geolat + 90 < de) { - adp = -90; - is_circumpolar = TRUE; - } - /* object does rise and set */ - else { - adp = asind(tand(geolat) * tand(de)); - } -#if 0 - if (fabs(adp) == 90) - is_invalid = TRUE; /* omit this to use the above values */ -#endif - admc = tand(eps) * tand(geolat) * sind(armc); - /* midheaven is circumpolar */ - if (fabs(admc) > 1) { -#if 0 - is_invalid = TRUE; /* omit this line to use the below values */ -#endif - if (admc > 1) - admc = 1; - else - admc = -1; - is_circumpolar = TRUE; - } - admc = asind(admc); - samc = 90 + admc; - if (samc == 0) - is_invalid = TRUE; - if (fabs(samc) > 0) { - if (mdd >= 0) { /* east */ - dfac = (mdd - adp + admc) / samc; - xp[0] = swe_degnorm((dfac - 1) * 90); - xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); - /* eastern object has longer SA than midheaven */ - if (dfac > 2 || dfac < 0) - is_invalid = TRUE; /* if this is omitted, funny things happen */ - } else { - dfac = (mdd + 180 + adp + admc) / samc; - xp[0] = swe_degnorm((dfac + 1) * 90); - xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); - /* western object has longer SA than midheaven */ - if (dfac > 2 || dfac < 0) - is_invalid = TRUE; /* if this is omitted, funny things happen */ - } - } - if (is_invalid) { - xp[0] = 0; - hpos = 0; - if (serr != NULL) - strcpy(serr, "Koch house position failed in circumpolar area"); - break; - } - if (is_circumpolar) { - if (serr != NULL) - strcpy(serr, "Koch house position, doubtful result in circumpolar area"); - } - /* to make sure that a call with a house cusp position returns - * a value within the house, 0.001" is added */ - hpos = xp[0] / 30.0 + 1; - break; - case 'C': - xeq[0] = swe_degnorm(mdd - 90); - swe_cotrans(xeq, xp, -geolat); - /* to make sure that a call with a house cusp position returns - * a value within the house, 0.001" is added */ - xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); - hpos = xp[0] / 30.0 + 1; - break; - case 'U': /* Krusinski-Pisa-Goelzer */ - /* Purpose: find point where planet's house circle (meridian) - * cuts house plane, giving exact planet's house position. - * Input data: ramc, geolat, asc. - */ - asc = Asc1 (swe_degnorm(armc + 90), geolat, sine, cose); - demc = atand(sind(armc) * tand(eps)); - /* while MC is always south, - * Asc must always be in eastern hemisphere */ - if (geolat >= 0 && 90 - geolat + demc < 0) { - asc = swe_degnorm(asc + 180); - } - if (geolat < 0 && -90 - geolat + demc > 0) { - asc = swe_degnorm(asc + 180); - } - /* - * Descr: find the house plane 'asc-zenith' - where it intersects - * with equator and at what angle, and then simple find arc - * from asc on that plane to planet's meridian intersection - * with this plane. - */ - /* I. find plane of 'asc-zenith' great circle relative to equator: - * solve spherical triangle 'EP-asc-intersection of house circle with equator' */ - /* Ia. Find intersection of house plane with equator: */ - x[0] = asc; x[1] = 0.0; x[2] = 1.0; /* 1. Start with ascendent on ecliptic */ - swe_cotrans(x, x, -eps); /* 2. Transform asc into equatorial coords */ - raep = swe_degnorm(armc + 90); /* 3. RA of east point */ - x[0] = swe_degnorm(raep - x[0]); /* 4. Rotation - found arc raas-raep */ - swe_cotrans(x, x, -(90-geolat)); /* 5. Transform into horizontal coords - arc EP-asc on horizon */ - xtemp = atand(tand(x[0])/cosd((90-geolat))); /* 6. Rotation from horizon on circle perpendicular to equator */ - if (x[0] > 90 && x[0] <= 270) - xtemp = swe_degnorm(xtemp + 180); - x[0] = swe_degnorm(xtemp); - raaz = swe_degnorm(raep - x[0]); /* result: RA of intersection 'asc-zenith' great circle with equator */ - /* Ib. Find obliquity to equator of 'asc-zenith' house plane: */ - x[0] = raaz; x[1] = 0.0; - x[0] = swe_degnorm(raep - x[0]); /* 1. Rotate start point relative to EP */ - swe_cotrans(x, x, -(90-geolat)); /* 2. Transform into horizontal coords */ - x[1] = x[1] + 90; /* 3. Add 90 deg do decl - so get the point on house plane most distant from equ. */ - swe_cotrans(x, x, 90-geolat); /* 4. Rotate back to equator */ - oblaz = x[1]; /* 5. Obliquity of house plane to equator */ - /* II. Next find asc and planet position on house plane, - * so to find relative distance of planet from - * coords beginning. */ - /* IIa. Asc on house plane relative to intersection - * of equator with 'asc-zenith' plane. */ - xasc[0] = asc; xasc[1] = 0.0; xasc[2] = 1.0; - swe_cotrans(xasc, xasc, -eps); - xasc[0] = swe_degnorm(xasc[0] - raaz); - xtemp = atand(tand(xasc[0])/cosd(oblaz)); - if (xasc[0] > 90 && xasc[0] <= 270) - xtemp = swe_degnorm(xtemp + 180); - xasc[0] = swe_degnorm(xtemp); - /* IIb. Planet on house plane relative to intersection - * of equator with 'asc-zenith' plane */ - xp[0] = swe_degnorm(xeq[0] - raaz); /* Rotate on equator */ - xtemp = atand(tand(xp[0])/cosd(oblaz)); /* Find arc on house plane from equator */ - if (xp[0] > 90 && xp[0] <= 270) - xtemp = swe_degnorm(xtemp + 180); - xp[0] = swe_degnorm(xtemp); - xp[0] = swe_degnorm(xp[0]-xasc[0]); /* find arc between asc and planet, and get planet house position */ - /* IIc. Distance from planet to house plane on declination circle: */ - x[0] = xeq[0]; - x[1] = xeq[1]; - swe_cotrans(x, x, oblaz); - xp[1] = xeq[1] - x[1]; /* How many degrees is the point on declination circle from house circle */ - /* to make sure that a call with a house cusp position returns - * a value within the house, 0.001" is added */ - xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); - hpos = xp[0] / 30.0 + 1; - break; - case 'H': - xeq[0] = swe_degnorm(mdd - 90); - swe_cotrans(xeq, xp, 90 - geolat); - /* to make sure that a call with a house cusp position returns - * a value within the house, 0.001" is added */ - xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); - hpos = xp[0] / 30.0 + 1; - break; - case 'R': - if (fabs(mdd) < VERY_SMALL) - xp[0] = 270; - else if (180 - fabs(mdd) < VERY_SMALL) - xp[0] = 90; - else { - if (90 - fabs(geolat) < VERY_SMALL) { - if (geolat > 0) - geolat = 90 - VERY_SMALL; - else - geolat = -90 + VERY_SMALL; - } - if (90 - fabs(de) < VERY_SMALL) { - if (de > 0) - de = 90 - VERY_SMALL; - else - de = -90 + VERY_SMALL; - } - a = tand(geolat) * tand(de) + cosd(mdd); - xp[0] = swe_degnorm(atand(-a / sind(mdd))); - if (mdd < 0) - xp[0] += 180; - xp[0] = swe_degnorm(xp[0]); - /* to make sure that a call with a house cusp position returns - * a value within the house, 0.001" is added */ - xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); - } - hpos = xp[0] / 30.0 + 1; - break; - case 'T': - mdd = swe_degnorm(mdd); - if (de > 90 - VERY_SMALL) - de = 90 - VERY_SMALL; - if (de < -90 + VERY_SMALL) - de = -90 + VERY_SMALL; - sinad = tand(de) * tand(geolat); - ad = asind(sinad); - a = sinad + cosd(mdd); - if (a >= 0) - is_above_hor = TRUE; - /* mirror everything below the horizon to the opposite point - * above the horizon */ - if (!is_above_hor) { - ra = swe_degnorm(ra + 180); - de = -de; - mdd = swe_degnorm(mdd + 180); - } - /* mirror everything on western hemisphere to eastern hemisphere */ - if (mdd > 180) { - ra = swe_degnorm(armc - mdd); - } - /* binary search for "topocentric" position line of body */ - tanfi = tand(geolat); - fh = geolat; - ra0 = swe_degnorm(armc + 90); - xp[1] = 1; - xeq[1] = de; - fac = 2; - while (fabs(xp[1]) > 0.000001) { - if (xp[1] > 0) { - fh = atand(tand(fh) - tanfi / fac); - ra0 -= 90 / fac; - } else { - fh = atand(tand(fh) + tanfi / fac); - ra0 += 90 / fac; - } - xeq[0] = swe_degnorm(ra - ra0); - swe_cotrans(xeq, xp, 90 - fh); - fac *= 2; - } - hpos = swe_degnorm(ra0 - armc); - /* mirror back to west */ - if (mdd > 180) - hpos = swe_degnorm(-hpos); - /* mirror back to below horizon */ - if (!is_above_hor) - hpos = swe_degnorm(hpos + 180); - hpos = swe_degnorm(hpos - 90) / 30 + 1; - break; - case 'P': - case 'G': - default: - /* circumpolar region */ - if (90 - fabs(de) <= fabs(geolat)) { - if (de * geolat < 0) - xp[0] = swe_degnorm(90 + mdn / 2); - else - xp[0] = swe_degnorm(270 + mdd / 2); - if (serr != NULL) - strcpy(serr, "Otto Ludwig procedure within circumpolar regions."); - } else { - sinad = tand(de) * tand(geolat); - ad = asind(sinad); - a = sinad + cosd(mdd); - if (a >= 0) - is_above_hor = TRUE; - sad = 90 + ad; - san = 90 - ad; - if (is_above_hor) - xp[0] = (mdd / sad + 3) * 90; - else - xp[0] = (mdn / san + 1) * 90; - /* to make sure that a call with a house cusp position returns - * a value within the house, 0.001" is added */ - xp[0] = swe_degnorm(xp[0] + MILLIARCSEC); - } - if (hsys == 'G') { - xp[0] = 360 - xp[0]; /* Gauquelin sectors are in clockwise direction */ - hpos = xp[0] / 10.0 + 1; - } else { - hpos = xp[0] / 30.0 + 1; - } - break; - } - return hpos; + return hpos; } diff --git a/swe/src/swehouse.h b/swe/src/swehouse.h index 34d9361..9f72f6b 100644 --- a/swe/src/swehouse.h +++ b/swe/src/swehouse.h @@ -1,3 +1,4 @@ + /******************************************************* $Header: /home/dieter/sweph/RCS/swehouse.h,v 1.74 2008/06/16 10:07:20 dieter Exp $ module swehouse.h @@ -59,16 +60,17 @@ house and (simple) aspect calculation for promoting such software, products or services. */ -struct houses { - double cusp[37]; - double ac; - double mc; - double vertex; - double equasc; - double coasc1; - double coasc2; - double polasc; - }; +struct houses +{ + double cusp[37]; + double ac; + double mc; + double vertex; + double equasc; + double coasc1; + double coasc2; + double polasc; +}; #define HOUSES struct houses #define VERY_SMALL 1E-10 diff --git a/swe/src/swejpl.c b/swe/src/swejpl.c index d52e437..6d11ae2 100644 --- a/swe/src/swejpl.c +++ b/swe/src/swejpl.c @@ -12,6 +12,7 @@ Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich ************************************************************/ + /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -75,31 +76,33 @@ #define DEBUG_DO_SHOW FALSE #ifndef NO_JPL + /* * local globals */ -struct jpl_save { - char *jplfname; - char *jplfpath; - FILE *jplfptr; - short do_reorder; - double eh_cval[400]; - double eh_ss[3], eh_au, eh_emrat; - int32 eh_denum, eh_ncon, eh_ipt[39]; - char ch_cnam[6*400]; - double pv[78]; - double pvsun[6]; - double buf[1500]; - double pc[18], vc[18], ac[18], jc[18]; - short do_km; +struct jpl_save +{ + char *jplfname; + char *jplfpath; + FILE *jplfptr; + short do_reorder; + double eh_cval[400]; + double eh_ss[3], eh_au, eh_emrat; + int32 eh_denum, eh_ncon, eh_ipt[39]; + char ch_cnam[6 * 400]; + double pv[78]; + double pvsun[6]; + double buf[1500]; + double pc[18], vc[18], ac[18], jc[18]; + short do_km; }; static struct jpl_save *FAR js; -static int state (double et, int32 *list, int do_bary, - double *pv, double *pvsun, double *nut, char *serr); -static int interp(double FAR *buf, double t, double intv, int32 ncfin, - int32 ncmin, int32 nain, int32 ifl, double *pv); +static int state(double et, int32 * list, int do_bary, double *pv, + double *pvsun, double *nut, char *serr); +static int interp(double FAR * buf, double t, double intv, int32 ncfin, + int32 ncmin, int32 nain, int32 ifl, double *pv); static int32 fsizer(char *serr); static void reorder(char *x, int size, int number); static int read_const_jpl(double *ss, char *serr); @@ -170,132 +173,141 @@ DE200 DE102 DE403 * set to a fixed value depending as in previous releases. The caller of * fsizer() will verify by data comparison whether it computed correctly. */ -static int32 fsizer(char *serr) +static int32 +fsizer(char *serr) { - /* Local variables */ - int32 ncon; - double emrat; - int32 numde; - double au, ss[3]; - int i, kmx, khi, nd; - int32 ksize, lpt[3]; - char ttl[6*14*3]; - if ((js->jplfptr = swi_fopen(SEI_FILE_PLANET, js->jplfname, js->jplfpath, serr)) == NULL) { - return NOT_AVAILABLE; - } - /* ttl = ephemeris title, e.g. - * "JPL Planetary Ephemeris DE404/LE404 - * Start Epoch: JED= 625296.5-3001 DEC 21 00:00:00 - * Final Epoch: JED= 2817168.5 3001 JAN 17 00:00:00c */ - fread((void *) &ttl[0], 1, 252, js->jplfptr); - /* cnam = names of constants */ - fread((void *) js->ch_cnam, 1, 6*400, js->jplfptr); - /* ss[0] = start epoch of ephemeris - * ss[1] = end epoch - * ss[2] = segment size in days */ - fread((void *) &ss[0], sizeof(double), 3, js->jplfptr); - /* reorder ? */ - if (ss[2] < 1 || ss[2] > 200) - js->do_reorder = TRUE; - else - js->do_reorder = 0; - for (i = 0; i < 3; i++) - js->eh_ss[i] = ss[i]; - if (js->do_reorder) - reorder((char *) &js->eh_ss[0], sizeof(double), 3); - /* plausibility test of these constants. Start and end date must be - * between -20000 and +20000, segment size >= 1 and <= 200 */ - if (js->eh_ss[0] < -5583942 || js->eh_ss[1] > 9025909 || js->eh_ss[2] < 1 || js->eh_ss[2] > 200) { - if (serr != NULL) - sprintf(serr, "alleged ephemeris file (%s) has invalid format.", js->jplfname); - return(NOT_AVAILABLE); - } - /* ncon = number of constants */ - fread((void *) &ncon, sizeof(int32), 1, js->jplfptr); - if (js->do_reorder) - reorder((char *) &ncon, sizeof(int32), 1); - /* au = astronomical unit */ - fread((void *) &au, sizeof(double), 1, js->jplfptr); - if (js->do_reorder) - reorder((char *) &au, sizeof(double), 1); - /* emrat = earth moon mass ratio */ - fread((void *) &emrat, sizeof(double), 1, js->jplfptr); - if (js->do_reorder) - reorder((char *) &emrat, sizeof(double), 1); - /* ipt[i+0]: coefficients of planet i start at buf[ipt[i+0]-1] - * ipt[i+1]: number of coefficients (interpolation order - 1) - * ipt[i+2]: number of intervals in segment */ - fread((void *) &js->eh_ipt[0], sizeof(int32), 36, js->jplfptr); - if (js->do_reorder) - reorder((char *) &js->eh_ipt[0], sizeof(int32), 36); - /* numde = number of jpl ephemeris "404" with de404 */ - fread((void *) &numde, sizeof(int32), 1, js->jplfptr); - if (js->do_reorder) - reorder((char *) &numde, sizeof(int32), 1); - /* read librations */ - fread(&lpt[0], sizeof(int32), 3, js->jplfptr); - if (js->do_reorder) - reorder((char *) &lpt[0], sizeof(int32), 3); - /* fill librations into eh_ipt[36]..[38] */ - for (i = 0; i < 3; ++i) - js->eh_ipt[i + 36] = lpt[i]; - rewind(js->jplfptr); - /* find the number of ephemeris coefficients from the pointers */ - /* re-activated this code on 26-aug-2008 */ - kmx = 0; - khi = 0; - for (i = 0; i < 13; i++) { - if (js->eh_ipt[i * 3] > kmx) { - kmx = js->eh_ipt[i * 3]; - khi = i + 1; + /* Local variables */ + int32 ncon; + double emrat; + int32 numde; + double au, ss[3]; + int i, kmx, khi, nd; + int32 ksize, lpt[3]; + char ttl[6 * 14 * 3]; + if ((js->jplfptr = + swi_fopen(SEI_FILE_PLANET, js->jplfname, js->jplfpath, + serr)) == NULL) { + return NOT_AVAILABLE; + } + /* ttl = ephemeris title, e.g. + * "JPL Planetary Ephemeris DE404/LE404 + * Start Epoch: JED= 625296.5-3001 DEC 21 00:00:00 + * Final Epoch: JED= 2817168.5 3001 JAN 17 00:00:00c */ + fread((void *)&ttl[0], 1, 252, js->jplfptr); + /* cnam = names of constants */ + fread((void *)js->ch_cnam, 1, 6 * 400, js->jplfptr); + /* ss[0] = start epoch of ephemeris + * ss[1] = end epoch + * ss[2] = segment size in days */ + fread((void *)&ss[0], sizeof(double), 3, js->jplfptr); + /* reorder ? */ + if (ss[2] < 1 || ss[2] > 200) + js->do_reorder = TRUE; + else + js->do_reorder = 0; + for (i = 0; i < 3; i++) + js->eh_ss[i] = ss[i]; + if (js->do_reorder) + reorder((char *)&js->eh_ss[0], sizeof(double), 3); + /* plausibility test of these constants. Start and end date must be + * between -20000 and +20000, segment size >= 1 and <= 200 */ + if (js->eh_ss[0] < -5583942 || js->eh_ss[1] > 9025909 || js->eh_ss[2] < 1 + || js->eh_ss[2] > 200) { + if (serr != NULL) + sprintf(serr, "alleged ephemeris file (%s) has invalid format.", + js->jplfname); + return (NOT_AVAILABLE); + } + /* ncon = number of constants */ + fread((void *)&ncon, sizeof(int32), 1, js->jplfptr); + if (js->do_reorder) + reorder((char *)&ncon, sizeof(int32), 1); + /* au = astronomical unit */ + fread((void *)&au, sizeof(double), 1, js->jplfptr); + if (js->do_reorder) + reorder((char *)&au, sizeof(double), 1); + /* emrat = earth moon mass ratio */ + fread((void *)&emrat, sizeof(double), 1, js->jplfptr); + if (js->do_reorder) + reorder((char *)&emrat, sizeof(double), 1); + /* ipt[i+0]: coefficients of planet i start at buf[ipt[i+0]-1] + * ipt[i+1]: number of coefficients (interpolation order - 1) + * ipt[i+2]: number of intervals in segment */ + fread((void *)&js->eh_ipt[0], sizeof(int32), 36, js->jplfptr); + if (js->do_reorder) + reorder((char *)&js->eh_ipt[0], sizeof(int32), 36); + /* numde = number of jpl ephemeris "404" with de404 */ + fread((void *)&numde, sizeof(int32), 1, js->jplfptr); + if (js->do_reorder) + reorder((char *)&numde, sizeof(int32), 1); + /* read librations */ + fread(&lpt[0], sizeof(int32), 3, js->jplfptr); + if (js->do_reorder) + reorder((char *)&lpt[0], sizeof(int32), 3); + /* fill librations into eh_ipt[36]..[38] */ + for (i = 0; i < 3; ++i) + js->eh_ipt[i + 36] = lpt[i]; + rewind(js->jplfptr); + /* find the number of ephemeris coefficients from the pointers */ + /* re-activated this code on 26-aug-2008 */ + kmx = 0; + khi = 0; + for (i = 0; i < 13; i++) { + if (js->eh_ipt[i * 3] > kmx) { + kmx = js->eh_ipt[i * 3]; + khi = i + 1; + } + } + if (khi == 12) + nd = 2; + else + nd = 3; + ksize = + (js->eh_ipt[khi * 3 - 3] + + nd * js->eh_ipt[khi * 3 - 2] * js->eh_ipt[khi * 3 - 1] - 1L) * 2L; + /* + * de102 files give wrong ksize, because they contain 424 empty bytes + * per record. Fixed by hand! + */ + if (ksize == 1546) + ksize = 1652; +#if 0 /* we prefer to compute ksize to be comaptible + * with new DE releases */ + switch (numde) { + case 403: + case 405: + case 410: + case 413: + case 414: + case 418: + case 421: + ksize = 2036; + break; + case 404: + case 406: + ksize = 1456; + break; + case 200: + ksize = 1652; + break; + case 102: + ksize = 1652; /* de102 is filled with blanks to length of de200 */ + break; + default: + if (serr != NULL) + sprintf(serr, "unknown numde value %d;", numde); + return ERR; } - } - if (khi == 12) - nd = 2; - else - nd = 3; - ksize = (js->eh_ipt[khi * 3 - 3] + nd * js->eh_ipt[khi * 3 - 2] * js->eh_ipt[khi * 3 - 1] - 1L) * 2L; - /* - * de102 files give wrong ksize, because they contain 424 empty bytes - * per record. Fixed by hand! - */ - if (ksize == 1546) - ksize = 1652; -#if 0 /* we prefer to compute ksize to be comaptible - with new DE releases */ - switch (numde) { - case 403: - case 405: - case 410: - case 413: - case 414: - case 418: - case 421: - ksize = 2036; - break; - case 404: - case 406: - ksize = 1456; - break; - case 200: - ksize = 1652; - break; - case 102: - ksize = 1652; /* de102 is filled with blanks to length of de200 */ - break; - default: - if (serr != NULL) - sprintf(serr,"unknown numde value %d;", numde); - return ERR; - } #endif - if (ksize < 1000 || ksize > 5000) { - if (serr != NULL) - sprintf(serr, "JPL ephemeris file does not provide valid ksize (%d)", ksize);/**/ - return NOT_AVAILABLE; - } - return ksize; -} + if (ksize < 1000 || ksize > 5000) { + if (serr != NULL) + sprintf(serr, + "JPL ephemeris file does not provide valid ksize (%d)", + ksize); + /**/ return NOT_AVAILABLE; + } + return ksize; +} /* * This subroutine reads the jpl planetary ephemeris @@ -329,94 +341,100 @@ static int32 fsizer(char *serr) * The option is available to have the units in km and km/sec. * For this, set do_km=TRUE (default FALSE). */ -int swi_pleph(double et, int ntarg, int ncent, double *rrd, char *serr) +int +swi_pleph(double et, int ntarg, int ncent, double *rrd, char *serr) { - int i, retc; - int32 list[12]; - double FAR *pv = js->pv; - double FAR *pvsun = js->pvsun; - for (i = 0; i < 6; ++i) - rrd[i] = 0.0; - if (ntarg == ncent) - return 0; - for (i = 0; i < 12; ++i) - list[i] = 0; - /* check for nutation call */ - if (ntarg == J_NUT) { - if (js->eh_ipt[34] > 0) { - list[10] = 2; - return(state(et, list, FALSE, pv, pvsun, rrd, serr)); - } else { - if (serr != NULL) - sprintf(serr,"No nutations on the JPL ephemeris file;"); - return (NOT_AVAILABLE); + int i, retc; + int32 list[12]; + double FAR *pv = js->pv; + double FAR *pvsun = js->pvsun; + for (i = 0; i < 6; ++i) + rrd[i] = 0.0; + if (ntarg == ncent) + return 0; + for (i = 0; i < 12; ++i) + list[i] = 0; + /* check for nutation call */ + if (ntarg == J_NUT) { + if (js->eh_ipt[34] > 0) { + list[10] = 2; + return (state(et, list, FALSE, pv, pvsun, rrd, serr)); + } + else { + if (serr != NULL) + sprintf(serr, "No nutations on the JPL ephemeris file;"); + return (NOT_AVAILABLE); + } } - } - if (ntarg == J_LIB) { - if (js->eh_ipt[37] > 0) { - list[11] = 2; - if ((retc = state(et, list, FALSE, pv, pvsun, rrd, serr)) != OK) - return (retc); - for (i = 0; i < 6; ++i) - rrd[i] = pv[i + 60]; - return 0; - } else { - if (serr != NULL) - sprintf(serr,"No librations on the ephemeris file;"); - return (NOT_AVAILABLE); + if (ntarg == J_LIB) { + if (js->eh_ipt[37] > 0) { + list[11] = 2; + if ((retc = state(et, list, FALSE, pv, pvsun, rrd, serr)) != OK) + return (retc); + for (i = 0; i < 6; ++i) + rrd[i] = pv[i + 60]; + return 0; + } + else { + if (serr != NULL) + sprintf(serr, "No librations on the ephemeris file;"); + return (NOT_AVAILABLE); + } } - } - /* set up proper entries in 'list' array for state call */ - if (ntarg < J_SUN) - list[ntarg] = 2; - if (ntarg == J_MOON) /* Mooon needs Earth */ - list[J_EARTH] = 2; - if (ntarg == J_EARTH) /* Earth needs Moon */ - list[J_MOON] = 2; - if (ntarg == J_EMB) /* EMB needs Earth */ - list[J_EARTH] = 2; - if (ncent < J_SUN) - list[ncent] = 2; - if (ncent == J_MOON) /* Mooon needs Earth */ - list[J_EARTH] = 2; - if (ncent == J_EARTH) /* Earth needs Moon */ - list[J_MOON] = 2; - if (ncent == J_EMB) /* EMB needs Earth */ - list[J_EARTH] = 2; - if ((retc = state(et, list, TRUE, pv, pvsun, rrd, serr)) != OK) - return (retc); - if (ntarg == J_SUN || ncent == J_SUN) { - for (i = 0; i < 6; ++i) - pv[i + 6*J_SUN] = pvsun[i]; - } - if (ntarg == J_SBARY || ncent == J_SBARY) { - for (i = 0; i < 6; ++i) { - pv[i + 6*J_SBARY] = 0.; + /* set up proper entries in 'list' array for state call */ + if (ntarg < J_SUN) + list[ntarg] = 2; + if (ntarg == J_MOON) /* Mooon needs Earth */ + list[J_EARTH] = 2; + if (ntarg == J_EARTH) /* Earth needs Moon */ + list[J_MOON] = 2; + if (ntarg == J_EMB) /* EMB needs Earth */ + list[J_EARTH] = 2; + if (ncent < J_SUN) + list[ncent] = 2; + if (ncent == J_MOON) /* Mooon needs Earth */ + list[J_EARTH] = 2; + if (ncent == J_EARTH) /* Earth needs Moon */ + list[J_MOON] = 2; + if (ncent == J_EMB) /* EMB needs Earth */ + list[J_EARTH] = 2; + if ((retc = state(et, list, TRUE, pv, pvsun, rrd, serr)) != OK) + return (retc); + if (ntarg == J_SUN || ncent == J_SUN) { + for (i = 0; i < 6; ++i) + pv[i + 6 * J_SUN] = pvsun[i]; } - } - if (ntarg == J_EMB || ncent == J_EMB) { - for (i = 0; i < 6; ++i) - pv[i + 6*J_EMB] = pv[i + 6*J_EARTH]; - } - if ((ntarg==J_EARTH && ncent==J_MOON) || (ntarg == J_MOON && ncent==J_EARTH)){ - for (i = 0; i < 6; ++i) - pv[i + 6*J_EARTH] = 0.; - - } else { - if (list[J_EARTH] == 2) { - for (i = 0; i < 6; ++i) - pv[i + 6*J_EARTH] -= pv[i + 6*J_MOON] / (js->eh_emrat + 1.); + if (ntarg == J_SBARY || ncent == J_SBARY) { + for (i = 0; i < 6; ++i) { + pv[i + 6 * J_SBARY] = 0.; + } } - if (list[J_MOON] == 2) { - for (i = 0; i < 6; ++i) { - pv[i + 6*J_MOON] += pv[i + 6*J_EARTH]; - } + if (ntarg == J_EMB || ncent == J_EMB) { + for (i = 0; i < 6; ++i) + pv[i + 6 * J_EMB] = pv[i + 6 * J_EARTH]; } - } - for (i = 0; i < 6; ++i) - rrd[i] = pv[i + ntarg * 6] - pv[i + ncent * 6]; - return OK; -} + if ((ntarg == J_EARTH && ncent == J_MOON) + || (ntarg == J_MOON && ncent == J_EARTH)) { + for (i = 0; i < 6; ++i) + pv[i + 6 * J_EARTH] = 0.; + + } + else { + if (list[J_EARTH] == 2) { + for (i = 0; i < 6; ++i) + pv[i + 6 * J_EARTH] -= + pv[i + 6 * J_MOON] / (js->eh_emrat + 1.); + } + if (list[J_MOON] == 2) { + for (i = 0; i < 6; ++i) { + pv[i + 6 * J_MOON] += pv[i + 6 * J_EARTH]; + } + } + } + for (i = 0; i < 6; ++i) + rrd[i] = pv[i + ntarg * 6] - pv[i + ncent * 6]; + return OK; +} /* * This subroutine differentiates and interpolates a @@ -439,125 +457,126 @@ int swi_pleph(double et, int ntarg, int ncent, double *rrd, char *serr) * pv d.p. interpolated quantities requested. * assumed dimension is pv(ncm,fl). */ -static int interp(double FAR *buf, double t, double intv, int32 ncfin, - int32 ncmin, int32 nain, int32 ifl, double *pv) +static int +interp(double FAR * buf, double t, double intv, int32 ncfin, int32 ncmin, + int32 nain, int32 ifl, double *pv) { - /* Initialized data */ - static int FAR np, nv; - static int FAR nac; - static int FAR njk; - static double FAR twot = 0.; - double FAR *pc = js->pc; - double FAR *vc = js->vc; - double FAR *ac = js->ac; - double FAR *jc = js->jc; - int ncf = (int) ncfin; - int ncm = (int) ncmin; - int na = (int) nain; - /* Local variables */ - double temp; - int i, j, ni; - double tc; - double dt1, bma; - double bma2, bma3; - /* - | get correct sub-interval number for this set of coefficients and then - | get normalized chebyshev time within that subinterval. - */ - if (t >= 0) - dt1 = floor(t); - else - dt1 = -floor(-t); - temp = na * t; - ni = (int) (temp - dt1); - /* tc is the normalized chebyshev time (-1 <= tc <= 1) */ - tc = (fmod(temp, 1.0) + dt1) * 2. - 1.; - /* - * check to see whether chebyshev time has changed, - * and compute new polynomial values if it has. - * (the element pc(2) is the value of t1(tc) and hence - * contains the value of tc on the previous call.) - */ - if (tc != pc[1]) { - np = 2; - nv = 3; - nac = 4; - njk = 5; - pc[1] = tc; - twot = tc + tc; - } - /* - * be sure that at least 'ncf' polynomials have been evaluated - * and are stored in the array 'pc'. - */ - if (np < ncf) { - for (i = np; i < ncf; ++i) - pc[i] = twot * pc[i - 1] - pc[i - 2]; - np = ncf; - } - /* interpolate to get position for each component */ - for (i = 0; i < ncm; ++i) { - pv[i] = 0.; - for (j = ncf-1; j >= 0; --j) - pv[i] += pc[j] * buf[j + (i + ni * ncm) * ncf]; - } - if (ifl <= 1) + /* Initialized data */ + static int FAR np, nv; + static int FAR nac; + static int FAR njk; + static double FAR twot = 0.; + double FAR *pc = js->pc; + double FAR *vc = js->vc; + double FAR *ac = js->ac; + double FAR *jc = js->jc; + int ncf = (int)ncfin; + int ncm = (int)ncmin; + int na = (int)nain; + /* Local variables */ + double temp; + int i, j, ni; + double tc; + double dt1, bma; + double bma2, bma3; + /* + * | get correct sub-interval number for this set of coefficients and then + * | get normalized chebyshev time within that subinterval. + */ + if (t >= 0) + dt1 = floor(t); + else + dt1 = -floor(-t); + temp = na * t; + ni = (int)(temp - dt1); + /* tc is the normalized chebyshev time (-1 <= tc <= 1) */ + tc = (fmod(temp, 1.0) + dt1) * 2. - 1.; + /* + * check to see whether chebyshev time has changed, + * and compute new polynomial values if it has. + * (the element pc(2) is the value of t1(tc) and hence + * contains the value of tc on the previous call.) + */ + if (tc != pc[1]) { + np = 2; + nv = 3; + nac = 4; + njk = 5; + pc[1] = tc; + twot = tc + tc; + } + /* + * be sure that at least 'ncf' polynomials have been evaluated + * and are stored in the array 'pc'. + */ + if (np < ncf) { + for (i = np; i < ncf; ++i) + pc[i] = twot * pc[i - 1] - pc[i - 2]; + np = ncf; + } + /* interpolate to get position for each component */ + for (i = 0; i < ncm; ++i) { + pv[i] = 0.; + for (j = ncf - 1; j >= 0; --j) + pv[i] += pc[j] * buf[j + (i + ni * ncm) * ncf]; + } + if (ifl <= 1) + return 0; + /* + * if velocity interpolation is wanted, be sure enough + * derivative polynomials have been generated and stored. + */ + bma = (na + na) / intv; + vc[2] = twot + twot; + if (nv < ncf) { + for (i = nv; i < ncf; ++i) + vc[i] = twot * vc[i - 1] + pc[i - 1] + pc[i - 1] - vc[i - 2]; + nv = ncf; + } + /* interpolate to get velocity for each component */ + for (i = 0; i < ncm; ++i) { + pv[i + ncm] = 0.; + for (j = ncf - 1; j >= 1; --j) + pv[i + ncm] += vc[j] * buf[j + (i + ni * ncm) * ncf]; + pv[i + ncm] *= bma; + } + if (ifl == 2) + return 0; + /* check acceleration polynomial values, and */ + /* re-do if necessary */ + bma2 = bma * bma; + ac[3] = pc[1] * 24.; + if (nac < ncf) { + nac = ncf; + for (i = nac; i < ncf; ++i) + ac[i] = twot * ac[i - 1] + vc[i - 1] * 4. - ac[i - 2]; + } + /* get acceleration for each component */ + for (i = 0; i < ncm; ++i) { + pv[i + ncm * 2] = 0.; + for (j = ncf - 1; j >= 2; --j) + pv[i + ncm * 2] += ac[j] * buf[j + (i + ni * ncm) * ncf]; + pv[i + ncm * 2] *= bma2; + } + if (ifl == 3) + return 0; + /* check jerk polynomial values, and */ + /* re-do if necessary */ + bma3 = bma * bma2; + jc[4] = pc[1] * 192.; + if (njk < ncf) { + njk = ncf; + for (i = njk; i < ncf; ++i) + jc[i] = twot * jc[i - 1] + ac[i - 1] * 6. - jc[i - 2]; + } + /* get jerk for each component */ + for (i = 0; i < ncm; ++i) { + pv[i + ncm * 3] = 0.; + for (j = ncf - 1; j >= 3; --j) + pv[i + ncm * 3] += jc[j] * buf[j + (i + ni * ncm) * ncf]; + pv[i + ncm * 3] *= bma3; + } return 0; - /* - * if velocity interpolation is wanted, be sure enough - * derivative polynomials have been generated and stored. - */ - bma = (na + na) / intv; - vc[2] = twot + twot; - if (nv < ncf) { - for (i = nv; i < ncf; ++i) - vc[i] = twot * vc[i - 1] + pc[i - 1] + pc[i - 1] - vc[i - 2]; - nv = ncf; - } - /* interpolate to get velocity for each component */ - for (i = 0; i < ncm; ++i) { - pv[i + ncm] = 0.; - for (j = ncf-1; j >= 1; --j) - pv[i + ncm] += vc[j] * buf[j + (i + ni * ncm) * ncf]; - pv[i + ncm] *= bma; - } - if (ifl == 2) - return 0; - /* check acceleration polynomial values, and */ - /* re-do if necessary */ - bma2 = bma * bma; - ac[3] = pc[1] * 24.; - if (nac < ncf) { - nac = ncf; - for (i = nac; i < ncf; ++i) - ac[i] = twot * ac[i - 1] + vc[i - 1] * 4. - ac[i - 2]; - } - /* get acceleration for each component */ - for (i = 0; i < ncm; ++i) { - pv[i + ncm * 2] = 0.; - for (j = ncf-1; j >= 2; --j) - pv[i + ncm * 2] += ac[j] * buf[j + (i + ni * ncm) * ncf]; - pv[i + ncm * 2] *= bma2; - } - if (ifl == 3) - return 0; - /* check jerk polynomial values, and */ - /* re-do if necessary */ - bma3 = bma * bma2; - jc[4] = pc[1] * 192.; - if (njk < ncf) { - njk = ncf; - for (i = njk; i < ncf; ++i) - jc[i] = twot * jc[i - 1] + ac[i - 1] * 6. - jc[i - 2]; - } - /* get jerk for each component */ - for (i = 0; i < ncm; ++i) { - pv[i + ncm * 3] = 0.; - for (j = ncf-1; j >= 3; --j) - pv[i + ncm * 3] += jc[j] * buf[j + (i + ni * ncm) * ncf]; - pv[i + ncm * 3] *= bma3; - } - return 0; } /* @@ -619,319 +638,339 @@ static int interp(double FAR *buf, double t, double intv, int32 ncfin, | default value = FALSE (km determines time unit | for nutations and librations. angle unit is always radians.) */ -static int state(double et, int32 *list, int do_bary, - double *pv, double *pvsun, double *nut, char *serr) +static int +state(double et, int32 * list, int do_bary, double *pv, double *pvsun, + double *nut, char *serr) { - int i, j, k; - int32 flen, nseg, nb; - double FAR *buf = js->buf; - double aufac, s, t, intv, ts[4]; - int32 nrecl, ksize; - int32 nr; - double et_mn, et_fr; - int32 FAR *ipt = js->eh_ipt; - char ch_ttl[252]; - static int32 irecsz; - static int32 nrl, lpt[3], ncoeffs; - if (js->jplfptr == NULL) { - ksize = fsizer(serr); /* the number of single precision words in a record */ - nrecl = 4; - if (ksize == NOT_AVAILABLE) - return NOT_AVAILABLE; - irecsz = nrecl * ksize; /* record size in bytes */ - ncoeffs = ksize / 2; /* # of coefficients, doubles */ - /* ttl = ephemeris title, e.g. - * "JPL Planetary Ephemeris DE404/LE404 - * Start Epoch: JED= 625296.5-3001 DEC 21 00:00:00 - * Final Epoch: JED= 2817168.5 3001 JAN 17 00:00:00c */ - fread((void *) ch_ttl, 1, 252, js->jplfptr); - /* cnam = names of constants */ - fread((void *) js->ch_cnam, 1, 2400, js->jplfptr); - /* ss[0] = start epoch of ephemeris - * ss[1] = end epoch - * ss[2] = segment size in days */ - fread((void *) &js->eh_ss[0], sizeof(double), 3, js->jplfptr); - if (js->do_reorder) - reorder((char *) &js->eh_ss[0], sizeof(double), 3); - /* ncon = number of constants */ - fread((void *) &js->eh_ncon, sizeof(int32), 1, js->jplfptr); - if (js->do_reorder) - reorder((char *) &js->eh_ncon, sizeof(int32), 1); - /* au = astronomical unit */ - fread((void *) &js->eh_au, sizeof(double), 1, js->jplfptr); - if (js->do_reorder) - reorder((char *) &js->eh_au, sizeof(double), 1); - /* emrat = earth moon mass ratio */ - fread((void *) &js->eh_emrat, sizeof(double), 1, js->jplfptr); - if (js->do_reorder) - reorder((char *) &js->eh_emrat, sizeof(double), 1); - /* ipt[i+0]: coefficients of planet i start at buf[ipt[i+0]-1] - * ipt[i+1]: number of coefficients (interpolation order - 1) - * ipt[i+2]: number of intervals in segment */ - fread((void *) &ipt[0], sizeof(int32), 36, js->jplfptr); - if (js->do_reorder) - reorder((char *) &ipt[0], sizeof(int32), 36); - /* numde = number of jpl ephemeris "404" with de404 */ - fread((void *) &js->eh_denum, sizeof(int32), 1, js->jplfptr); - if (js->do_reorder) - reorder((char *) &js->eh_denum, sizeof(int32), 1); - fread((void *) &lpt[0], sizeof(int32), 3, js->jplfptr); - if (js->do_reorder) - reorder((char *) &lpt[0], sizeof(int32), 3); - /* cval[]: other constants in next record */ - fseek(js->jplfptr, 1L * irecsz, 0); - fread((void *) &js->eh_cval[0], sizeof(double), 400, js->jplfptr); - if (js->do_reorder) - reorder((char *) &js->eh_cval[0], sizeof(double), 400); - /* new 26-aug-2008: verify correct block size */ + int i, j, k; + int32 flen, nseg, nb; + double FAR *buf = js->buf; + double aufac, s, t, intv, ts[4]; + int32 nrecl, ksize; + int32 nr; + double et_mn, et_fr; + int32 FAR *ipt = js->eh_ipt; + char ch_ttl[252]; + static int32 irecsz; + static int32 nrl, lpt[3], ncoeffs; + if (js->jplfptr == NULL) { + ksize = fsizer(serr); /* the number of single precision words in a record */ + nrecl = 4; + if (ksize == NOT_AVAILABLE) + return NOT_AVAILABLE; + irecsz = nrecl * ksize; /* record size in bytes */ + ncoeffs = ksize / 2; /* # of coefficients, doubles */ + /* ttl = ephemeris title, e.g. + * "JPL Planetary Ephemeris DE404/LE404 + * Start Epoch: JED= 625296.5-3001 DEC 21 00:00:00 + * Final Epoch: JED= 2817168.5 3001 JAN 17 00:00:00c */ + fread((void *)ch_ttl, 1, 252, js->jplfptr); + /* cnam = names of constants */ + fread((void *)js->ch_cnam, 1, 2400, js->jplfptr); + /* ss[0] = start epoch of ephemeris + * ss[1] = end epoch + * ss[2] = segment size in days */ + fread((void *)&js->eh_ss[0], sizeof(double), 3, js->jplfptr); + if (js->do_reorder) + reorder((char *)&js->eh_ss[0], sizeof(double), 3); + /* ncon = number of constants */ + fread((void *)&js->eh_ncon, sizeof(int32), 1, js->jplfptr); + if (js->do_reorder) + reorder((char *)&js->eh_ncon, sizeof(int32), 1); + /* au = astronomical unit */ + fread((void *)&js->eh_au, sizeof(double), 1, js->jplfptr); + if (js->do_reorder) + reorder((char *)&js->eh_au, sizeof(double), 1); + /* emrat = earth moon mass ratio */ + fread((void *)&js->eh_emrat, sizeof(double), 1, js->jplfptr); + if (js->do_reorder) + reorder((char *)&js->eh_emrat, sizeof(double), 1); + /* ipt[i+0]: coefficients of planet i start at buf[ipt[i+0]-1] + * ipt[i+1]: number of coefficients (interpolation order - 1) + * ipt[i+2]: number of intervals in segment */ + fread((void *)&ipt[0], sizeof(int32), 36, js->jplfptr); + if (js->do_reorder) + reorder((char *)&ipt[0], sizeof(int32), 36); + /* numde = number of jpl ephemeris "404" with de404 */ + fread((void *)&js->eh_denum, sizeof(int32), 1, js->jplfptr); + if (js->do_reorder) + reorder((char *)&js->eh_denum, sizeof(int32), 1); + fread((void *)&lpt[0], sizeof(int32), 3, js->jplfptr); + if (js->do_reorder) + reorder((char *)&lpt[0], sizeof(int32), 3); + /* cval[]: other constants in next record */ + fseek(js->jplfptr, 1L * irecsz, 0); + fread((void *)&js->eh_cval[0], sizeof(double), 400, js->jplfptr); + if (js->do_reorder) + reorder((char *)&js->eh_cval[0], sizeof(double), 400); + /* new 26-aug-2008: verify correct block size */ #if 0 - sp = strstr(js->ch_cnam, "EMRAT "); - if (sp == NULL) { - if (serr != NULL) - sprintf(serr, "JPL ephemeris file strange, constant name 'EMRAT' missing"); - return ERR; - } - i = (sp - js->ch_cnam); - if (i % 6 != 0) { - if (serr != NULL) - sprintf(serr, "JPL ephemeris file strange, constant name 'EMRAT' not at multiple of 6"); - return ERR; - } - i = i / 6; /* position of EMRAT in constant array eh_cval */ - if (js->eh_cval[i] != js->eh_emrat) { - if (serr != NULL) - sprintf(serr, "JPL ephemeris file error, record size failed EMRAT check"); - return ERR; - } + sp = strstr(js->ch_cnam, "EMRAT "); + if (sp == NULL) { + if (serr != NULL) + sprintf(serr, + "JPL ephemeris file strange, constant name 'EMRAT' missing"); + return ERR; + } + i = (sp - js->ch_cnam); + if (i % 6 != 0) { + if (serr != NULL) + sprintf(serr, + "JPL ephemeris file strange, constant name 'EMRAT' not at multiple of 6"); + return ERR; + } + i = i / 6; /* position of EMRAT in constant array eh_cval */ + if (js->eh_cval[i] != js->eh_emrat) { + if (serr != NULL) + sprintf(serr, + "JPL ephemeris file error, record size failed EMRAT check"); + return ERR; + } #endif - for (i = 0; i < 3; ++i) - ipt[i + 36] = lpt[i]; - nrl = 0; - /* is file length correct? */ - /* file length */ - fseek(js->jplfptr, 0L, SEEK_END); - flen = ftell(js->jplfptr); - /* # of segments in file */ - nseg = (int32) ((js->eh_ss[1] - js->eh_ss[0]) / js->eh_ss[2]); - /* sum of all cheby coeffs of all planets and segments */ - for(i = 0, nb = 0; i < 13; i++) { - k = 3; - if (i == 11) - k = 2; - nb += (ipt[i*3+1] * ipt[i*3+2]) * k * nseg; - } - /* add start and end epochs of segments */ - nb += 2 * nseg; - /* doubles to bytes */ - nb *= 8; - /* add size of header and constants section */ - nb += 2 * ksize * nrecl; + for (i = 0; i < 3; ++i) + ipt[i + 36] = lpt[i]; + nrl = 0; + /* is file length correct? */ + /* file length */ + fseek(js->jplfptr, 0L, SEEK_END); + flen = ftell(js->jplfptr); + /* # of segments in file */ + nseg = (int32) ((js->eh_ss[1] - js->eh_ss[0]) / js->eh_ss[2]); + /* sum of all cheby coeffs of all planets and segments */ + for (i = 0, nb = 0; i < 13; i++) { + k = 3; + if (i == 11) + k = 2; + nb += (ipt[i * 3 + 1] * ipt[i * 3 + 2]) * k * nseg; + } + /* add start and end epochs of segments */ + nb += 2 * nseg; + /* doubles to bytes */ + nb *= 8; + /* add size of header and constants section */ + nb += 2 * ksize * nrecl; #if 0 - printf("hallo %d %d\n", nb, flen); - printf("hallo %d %d\n", nb-flen, ksize); + printf("hallo %d %d\n", nb, flen); + printf("hallo %d %d\n", nb - flen, ksize); #endif - if (flen != nb - /* some of our files are one record too long */ - && flen - nb != ksize * nrecl) { - if (serr != NULL) { - sprintf(serr, "JPL ephemeris file is mutilated; length = %d instead of %d.", flen, nb); - if (strlen(serr) + strlen(js->jplfname) < AS_MAXCH - 1) - sprintf(serr, "JPL ephemeris file %s is mutilated; length = %d instead of %d.", js->jplfname, flen, nb); - } - return(NOT_AVAILABLE); + if (flen != nb + /* some of our files are one record too long */ + && flen - nb != ksize * nrecl) { + if (serr != NULL) { + sprintf(serr, + "JPL ephemeris file is mutilated; length = %d instead of %d.", + flen, nb); + if (strlen(serr) + strlen(js->jplfname) < AS_MAXCH - 1) + sprintf(serr, + "JPL ephemeris file %s is mutilated; length = %d instead of %d.", + js->jplfname, flen, nb); + } + return (NOT_AVAILABLE); + } + /* check if start and end dates in segments are the same as in + * file header */ + fseek(js->jplfptr, 2L * irecsz, 0); + fread((void *)&ts[0], sizeof(double), 2, js->jplfptr); + if (js->do_reorder) + reorder((char *)&ts[0], sizeof(double), 2); + fseek(js->jplfptr, (nseg + 2 - 1) * irecsz, 0); + fread((void *)&ts[2], sizeof(double), 2, js->jplfptr); + if (js->do_reorder) + reorder((char *)&ts[2], sizeof(double), 2); + if (ts[0] != js->eh_ss[0] || ts[3] != js->eh_ss[1]) { + if (serr != NULL) + strcpy(serr, + "JPL ephemeris file is corrupt; start/end date check failed."); + return NOT_AVAILABLE; + } } - /* check if start and end dates in segments are the same as in - * file header */ - fseek(js->jplfptr, 2L * irecsz, 0); - fread((void *) &ts[0], sizeof(double), 2, js->jplfptr); - if (js->do_reorder) - reorder((char *) &ts[0], sizeof(double), 2); - fseek(js->jplfptr, (nseg + 2 - 1) * irecsz, 0); - fread((void *) &ts[2], sizeof(double), 2, js->jplfptr); - if (js->do_reorder) - reorder((char *) &ts[2], sizeof(double), 2); - if (ts[0] != js->eh_ss[0] || ts[3] != js->eh_ss[1]) { - if (serr != NULL) - strcpy(serr, "JPL ephemeris file is corrupt; start/end date check failed."); - return NOT_AVAILABLE; + if (list == NULL) + return 0; + s = et - .5; + et_mn = floor(s); + et_fr = s - et_mn; /* fraction of days since previous midnight */ + et_mn += .5; /* midnight before epoch */ + /* error return for epoch out of range */ + if (et < js->eh_ss[0] || et > js->eh_ss[1]) { + if (serr != NULL) + sprintf(serr, "jd %f outside JPL eph. range %.2f .. %.2f;", et, + js->eh_ss[0], js->eh_ss[1]); + return BEYOND_EPH_LIMITS; } - } - if (list == NULL) - return 0; - s = et - .5; - et_mn = floor(s); - et_fr = s - et_mn; /* fraction of days since previous midnight */ - et_mn += .5; /* midnight before epoch */ - /* error return for epoch out of range */ - if (et < js->eh_ss[0] || et > js->eh_ss[1]) { - if (serr != NULL) - sprintf(serr,"jd %f outside JPL eph. range %.2f .. %.2f;", et, js->eh_ss[0], js->eh_ss[1]); - return BEYOND_EPH_LIMITS; - } - /* calculate record # and relative time in interval */ - nr = (int32) ((et_mn - js->eh_ss[0]) / js->eh_ss[2]) + 2; - if (et_mn == js->eh_ss[1]) - --nr; /* end point of ephemeris, use last record */ - t = (et_mn - ((nr - 2) * js->eh_ss[2] + js->eh_ss[0]) + et_fr) / js->eh_ss[2]; - /* read correct record if not in core */ - if (nr != nrl) { - nrl = nr; - if (fseek(js->jplfptr, nr * irecsz, 0) != 0) { - if (serr != NULL) - sprintf(serr, "Read error in JPL eph. at %f\n", et); - return NOT_AVAILABLE; + /* calculate record # and relative time in interval */ + nr = (int32) ((et_mn - js->eh_ss[0]) / js->eh_ss[2]) + 2; + if (et_mn == js->eh_ss[1]) + --nr; /* end point of ephemeris, use last record */ + t = (et_mn - ((nr - 2) * js->eh_ss[2] + js->eh_ss[0]) + + et_fr) / js->eh_ss[2]; + /* read correct record if not in core */ + if (nr != nrl) { + nrl = nr; + if (fseek(js->jplfptr, nr * irecsz, 0) != 0) { + if (serr != NULL) + sprintf(serr, "Read error in JPL eph. at %f\n", et); + return NOT_AVAILABLE; + } + for (k = 1; k <= ncoeffs; ++k) { + if (fread((void *)&buf[k - 1], sizeof(double), 1, js->jplfptr) != + 1) { + if (serr != NULL) + sprintf(serr, "Read error in JPL eph. at %f\n", et); + return NOT_AVAILABLE; + } + if (js->do_reorder) + reorder((char *)&buf[k - 1], sizeof(double), 1); + } } - for (k = 1; k <= ncoeffs; ++k) { - if ( fread((void *) &buf[k - 1], sizeof(double), 1, js->jplfptr) != 1) { - if (serr != NULL) - sprintf(serr, "Read error in JPL eph. at %f\n", et); - return NOT_AVAILABLE; - } - if (js->do_reorder) - reorder((char *) &buf[k-1], sizeof(double), 1); + if (js->do_km) { + intv = js->eh_ss[2] * 86400.; + aufac = 1.; } - } - if (js->do_km) { - intv = js->eh_ss[2] * 86400.; - aufac = 1.; - } else { - intv = js->eh_ss[2]; - aufac = 1. / js->eh_au; - } - /* interpolate ssbary sun */ - interp(&buf[(int) ipt[30] - 1], t, intv, ipt[31], 3L, ipt[32], 2L, pvsun); - for (i = 0; i < 6; ++i) { - pvsun[i] *= aufac; - } - /* check and interpolate whichever bodies are requested */ - for (i = 0; i < 10; ++i) { - if (list[i] > 0) { - interp(&buf[(int) ipt[i * 3] - 1], t, intv, ipt[i * 3 + 1], 3L, - ipt[i * 3 + 2], list[i], &pv[i * 6]); - for (j = 0; j < 6; ++j) { - if (i < 9 && ! do_bary) { - pv[j + i * 6] = pv[j + i * 6] * aufac - pvsun[j]; - } else { - pv[j + i * 6] *= aufac; - } - } + else { + intv = js->eh_ss[2]; + aufac = 1. / js->eh_au; } - } - /* do nutations if requested (and if on file) */ - if (list[10] > 0 && ipt[34] > 0) { - interp(&buf[(int) ipt[33] - 1], t, intv, ipt[34], 2L, ipt[35], - list[10], nut); - } - /* get librations if requested (and if on file) */ - if (list[11] > 0 && ipt[37] > 0) { - interp(&buf[(int) ipt[36] - 1], t, intv, ipt[37], 3L, ipt[38], list[1], - &pv[60]); - } - return OK; -} + /* interpolate ssbary sun */ + interp(&buf[(int)ipt[30] - 1], t, intv, ipt[31], 3L, ipt[32], 2L, pvsun); + for (i = 0; i < 6; ++i) { + pvsun[i] *= aufac; + } + /* check and interpolate whichever bodies are requested */ + for (i = 0; i < 10; ++i) { + if (list[i] > 0) { + interp(&buf[(int)ipt[i * 3] - 1], t, intv, ipt[i * 3 + 1], 3L, + ipt[i * 3 + 2], list[i], &pv[i * 6]); + for (j = 0; j < 6; ++j) { + if (i < 9 && !do_bary) { + pv[j + i * 6] = pv[j + i * 6] * aufac - pvsun[j]; + } + else { + pv[j + i * 6] *= aufac; + } + } + } + } + /* do nutations if requested (and if on file) */ + if (list[10] > 0 && ipt[34] > 0) { + interp(&buf[(int)ipt[33] - 1], t, intv, ipt[34], 2L, ipt[35], + list[10], nut); + } + /* get librations if requested (and if on file) */ + if (list[11] > 0 && ipt[37] > 0) { + interp(&buf[(int)ipt[36] - 1], t, intv, ipt[37], 3L, ipt[38], list[1], + &pv[60]); + } + return OK; +} /* * this entry obtains the constants from the ephemeris file * call state to initialize the ephemeris and read in the constants */ -static int read_const_jpl(double *ss, char *serr) +static int +read_const_jpl(double *ss, char *serr) { - int i, retc; - retc = state(0.0, NULL, FALSE, NULL, NULL, NULL, serr); - if (retc != OK) - return (retc); - for (i = 0; i < 3; i++) - ss[i] = js->eh_ss[i]; + int i, retc; + retc = state(0.0, NULL, FALSE, NULL, NULL, NULL, serr); + if (retc != OK) + return (retc); + for (i = 0; i < 3; i++) + ss[i] = js->eh_ss[i]; #if DEBUG_DO_SHOW - { - static char FAR *bname[] = { - "Mercury", "Venus", "EMB", "Mars", "Jupiter", "Saturn", - "Uranus", "Neptune", "Pluto", "Moon", "SunBary", "Nut", "Libr"}; - int j, k; - int32 nb, nc; - printf(" JPL TEST-EPHEMERIS program. Version October 1995.\n"); - for (i = 0; i < 13; i++) { - j = i * 3; - k = 3; - if (i == 11) k = 2; - nb = js->eh_ipt[j+1] * js->eh_ipt[j+2] * k; - nc = (int32) (nb * 36525L / js->eh_ss[2] * 8L); - printf("%s\t%d\tipt[%d]\t%3ld %2ld %2ld,\t", - bname[i], i, j, js->eh_ipt[j], js->eh_ipt[j+1], js->eh_ipt[j+2]); - printf("%3ld double, bytes per century = %6ld\n", nb, nc); - fflush(stdout); + { + static char FAR *bname[] = { + "Mercury", "Venus", "EMB", "Mars", "Jupiter", "Saturn", + "Uranus", "Neptune", "Pluto", "Moon", "SunBary", "Nut", "Libr" + }; + int j, k; + int32 nb, nc; + printf(" JPL TEST-EPHEMERIS program. Version October 1995.\n"); + for (i = 0; i < 13; i++) { + j = i * 3; + k = 3; + if (i == 11) + k = 2; + nb = js->eh_ipt[j + 1] * js->eh_ipt[j + 2] * k; + nc = (int32) (nb * 36525L / js->eh_ss[2] * 8L); + printf("%s\t%d\tipt[%d]\t%3ld %2ld %2ld,\t", bname[i], i, j, + js->eh_ipt[j], js->eh_ipt[j + 1], js->eh_ipt[j + 2]); + printf("%3ld double, bytes per century = %6ld\n", nb, nc); + fflush(stdout); + } + printf("%16.2f %16.2f %16.2f\n", js->eh_ss[0], js->eh_ss[1], + js->eh_ss[2]); + for (i = 0; i < js->eh_ncon; ++i) + printf("%.6s\t%24.16f\n", js->ch_cnam + i * 6, js->eh_cval[i]); + fflush(stdout); } - printf("%16.2f %16.2f %16.2f\n", js->eh_ss[0], js->eh_ss[1], js->eh_ss[2]); - for (i = 0; i < js->eh_ncon; ++i) - printf("%.6s\t%24.16f\n", js->ch_cnam + i * 6, js->eh_cval[i]); - fflush(stdout); - } #endif - return OK; -} - -static void reorder(char *x, int size, int number) -{ - int i, j; - char s[8]; - char *sp1 = x; - char *sp2 = &s[0]; - for (i = 0; i < number; i++) { - for (j = 0; j < size; j++) - *(sp2 + j) = *(sp1 + size - j - 1); - for (j = 0; j < size; j++) - *(sp1 + j) = *(sp2 + j); - sp1 += size; - } -} - -void swi_close_jpl_file(void) -{ - if (js != NULL) { - if (js->jplfptr != NULL) - fclose(js->jplfptr); - if (js->jplfname != NULL) - FREE((void *) js->jplfname); - if (js->jplfpath != NULL) - FREE((void *) js->jplfpath); - FREE((void *) js); - js = NULL; - } -} - -int swi_open_jpl_file(double *ss, char *fname, char *fpath, char *serr) -{ - int retc = OK; - /* if open, return */ - if (js != NULL && js->jplfptr != NULL) return OK; - if ((js = (struct jpl_save *) CALLOC(1, sizeof(struct jpl_save))) == NULL - || (js->jplfname = MALLOC(strlen(fname)+1)) == NULL - || (js->jplfpath = MALLOC(strlen(fpath)+1)) == NULL - ) { - if (serr != NULL) - strcpy(serr, "error in malloc() with JPL ephemeris."); - return ERR; - } - strcpy(js->jplfname, fname); - strcpy(js->jplfpath, fpath); - retc = read_const_jpl(ss, serr); - if (retc != OK) - swi_close_jpl_file(); - else { - /* intializations for function interpol() */ - js->pc[0] = 1; - js->pc[1] = 2; - js->vc[1] = 1; - js->ac[2] = 4; - js->jc[3] = 24; - } - return retc; } -int32 swi_get_jpl_denum() +static void +reorder(char *x, int size, int number) { - return js->eh_denum; + int i, j; + char s[8]; + char *sp1 = x; + char *sp2 = &s[0]; + for (i = 0; i < number; i++) { + for (j = 0; j < size; j++) + *(sp2 + j) = *(sp1 + size - j - 1); + for (j = 0; j < size; j++) + *(sp1 + j) = *(sp2 + j); + sp1 += size; + } } -#endif /* NO_JPL */ +void +swi_close_jpl_file(void) +{ + if (js != NULL) { + if (js->jplfptr != NULL) + fclose(js->jplfptr); + if (js->jplfname != NULL) + FREE((void *)js->jplfname); + if (js->jplfpath != NULL) + FREE((void *)js->jplfpath); + FREE((void *)js); + js = NULL; + } +} + +int +swi_open_jpl_file(double *ss, char *fname, char *fpath, char *serr) +{ + int retc = OK; + /* if open, return */ + if (js != NULL && js->jplfptr != NULL) + return OK; + if ((js = (struct jpl_save *)CALLOC(1, sizeof(struct jpl_save))) == NULL + || (js->jplfname = MALLOC(strlen(fname) + 1)) == NULL + || (js->jplfpath = MALLOC(strlen(fpath) + 1)) == NULL) { + if (serr != NULL) + strcpy(serr, "error in malloc() with JPL ephemeris."); + return ERR; + } + strcpy(js->jplfname, fname); + strcpy(js->jplfpath, fpath); + retc = read_const_jpl(ss, serr); + if (retc != OK) + swi_close_jpl_file(); + else { + /* intializations for function interpol() */ + js->pc[0] = 1; + js->pc[1] = 2; + js->vc[1] = 1; + js->ac[2] = 4; + js->jc[3] = 24; + } + return retc; +} + +int32 +swi_get_jpl_denum() +{ + return js->eh_denum; +} +#endif /* NO_JPL */ diff --git a/swe/src/swejpl.h b/swe/src/swejpl.h index 59c3550..3a885ea 100644 --- a/swe/src/swejpl.h +++ b/swe/src/swejpl.h @@ -1,3 +1,4 @@ + /* | $Header: /home/dieter/sweph/RCS/swejpl.h,v 1.74 2008/06/16 10:07:20 dieter Exp $ | @@ -10,6 +11,7 @@ Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich **************************************************************/ + /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -67,8 +69,8 @@ #include "sweodef.h" -#define J_MERCURY 0 /* jpl body indices, modified by Alois */ -#define J_VENUS 1 /* now they start at 0 and not at 1 */ +#define J_MERCURY 0 /* jpl body indices, modified by Alois */ +#define J_VENUS 1 /* now they start at 0 and not at 1 */ #define J_EARTH 2 #define J_MARS 3 #define J_JUPITER 4 @@ -89,7 +91,8 @@ * ntarg can be all of the above, ncent all except J_NUT and J_LIB. * Librations and Nutations are not affected by ncent. */ -extern int swi_pleph(double et, int ntarg, int ncent, double *rrd, char *serr); +extern int swi_pleph(double et, int ntarg, int ncent, double *rrd, + char *serr); /* * read the ephemeris constants. ss[0..2] returns start, end and granule size. @@ -97,9 +100,9 @@ extern int swi_pleph(double et, int ntarg, int ncent, double *rrd, char *serr); */ extern void swi_close_jpl_file(void); -extern int swi_open_jpl_file(double *ss, char *fname, char *fpath, char *serr); +extern int swi_open_jpl_file(double *ss, char *fname, char *fpath, + char *serr); extern int32 swi_get_jpl_denum(void); extern void swi_IERS_FK5(double *xin, double *xout, int dir); - diff --git a/swe/src/swemmoon.c b/swe/src/swemmoon.c index dd4d9cf..aff2de2 100644 --- a/swe/src/swemmoon.c +++ b/swe/src/swemmoon.c @@ -1,9 +1,11 @@ + /* SWISSEPH $Header: /home/dieter/sweph/RCS/swemmoon.c,v 1.74 2008/06/16 10:07:20 dieter Exp $ * * Steve Moshier's analytical lunar ephemeris **************************************************************/ + /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -60,123 +62,123 @@ /* - * Expansions for the geocentric ecliptic longitude, - * latitude, and distance of the Moon referred to the mean equinox - * and ecliptic of date. - * - * This version of cmoon.c adjusts the ELP2000-85 analytical Lunar - * theory of Chapront-Touze and Chapront to fit the Jet Propulsion - * Laboratory's DE404 long ephemeris on the interval from 3000 B.C. - * to 3000 A.D. - * - * The fit is much better in the remote past and future if - * secular terms are included in the arguments of the oscillatory - * perturbations. Such adjustments cannot easily be incorporated - * into the 1991 lunar tables. In this program the traditional - * literal arguments are used instead, with mean elements adjusted - * for a best fit to the reference ephemeris. - * - * This program omits many oscillatory terms from the analytical - * theory which, if they were included, would yield a much higher - * accuracy for modern dates. Detailed statistics of the precision - * are given in the table below. Comparing at 64-day intervals - * over the period -3000 to +3000, the maximum discrepancies noted - * were 7" longitude, 5" latitude, and 5 x 10^-8 au radius. - * The expressions used for precession in this comparision were - * those of Simon et al (1994). - * - * The adjusted coefficients were found by an unweighted least squares - * fit to the numerical ephemeris in the mentioned test interval. - * The approximation error increases rapidly outside this interval. - * J. Chapront (1994) has described the basic fitting procedure. - * - * A major change from DE200 to DE404 is in the coefficient - * of tidal acceleration of the Moon, which causes the Moon's - * longitude to depart by about -0.9" per century squared - * from DE200. Uncertainty in this quantity continues to - * be the limiting factor in long term projections of the Moon's - * ephemeris. - * - * Since the Lunar theory is cast in the ecliptic of date, it makes - * some difference what formula you use for precession. The adjustment - * to DE404 was carried out relative to the mean equinox and ecliptic - * of date as defined in Williams (1994). An earlier version of this - * program used the precession given by Simon et al (1994). The difference - * between these two precession formulas amounts to about 12" in Lunar - * longitude at 3000 B.C. - * - * Maximum deviations between DE404 and this program - * in a set of 34274 samples spaced 64 days apart - * - * Interval Longitude Latitude Radius - * Julian Year arc sec arc sec 10^-8 au - * -3000 to -2500 5.66 4.66 4.93 - * -2500 to -2000 5.49 3.98 4.56 - * -2000 to -1500 6.98 4.17 4.81 - * -1500 to -1000 5.74 3.53 4.87 - * -1000 to -500 5.95 3.42 4.67 - * -500 to 0 4.94 3.07 4.04 - * 0 to 500 4.42 2.65 4.55 - * 500 to 1000 5.68 3.30 3.99 - * 1000 to 1500 4.32 3.21 3.83 - * 1500 to 2000 2.70 2.69 3.71 - * 2000 to 2500 3.35 2.32 3.85 - * 2500 to 3000 4.62 2.39 4.11 - * - * - * - * References: - * - * James G. Williams, "Contributions to the Earth's obliquity rate, - * precession, and nutation," Astron. J. 108, 711-724 (1994) - * - * DE403 and DE404 ephemerides by E. M. Standish, X. X. Newhall, and - * J. G. Williams are at the JPL computer site navigator.jpl.nasa.gov. - * - * J. L. Simon, P. Bretagnon, J. Chapront, M. Chapront-Touze', G. Francou, - * and J. Laskar, "Numerical Expressions for precession formulae and - * mean elements for the Moon and the planets," Astronomy and Astrophysics - * 282, 663-683 (1994) - * - * P. Bretagnon and Francou, G., "Planetary theories in rectangular - * and spherical variables. VSOP87 solutions," Astronomy and - * Astrophysics 202, 309-315 (1988) - * - * M. Chapront-Touze' and J. Chapront, "ELP2000-85: a semi-analytical - * lunar ephemeris adequate for historical times," Astronomy and - * Astrophysics 190, 342-352 (1988). - * - * M. Chapront-Touze' and J. Chapront, _Lunar Tables and - * Programs from 4000 B.C. to A.D. 8000_, Willmann-Bell (1991) - * - * J. Laskar, "Secular terms of classical planetary theories - * using the results of general theory," Astronomy and Astrophysics - * 157, 59070 (1986) - * - * S. L. Moshier, "Comparison of a 7000-year lunar ephemeris - * with analytical theory," Astronomy and Astrophysics 262, - * 613-616 (1992) - * - * J. Chapront, "Representation of planetary ephemerides by frequency - * analysis. Application to the five outer planets," Astronomy and - * Astrophysics Suppl. Ser. 109, 181-192 (1994) - * - * - * Entry swi_moshmoon2() returns the geometric position of the Moon - * relative to the Earth. Its calling procedure is as follows: - * - * double JD; input Julian Ephemeris Date - * double pol[3]; output ecliptic polar coordinatees in radians and au - * pol[0] longitude, pol[1] latitude, pol[2] radius - * swi_moshmoon2( JD, pol ); - * - * - S. L. Moshier, August, 1991 - * DE200 fit: July, 1992 - * DE404 fit: October, 1995 - * - * Dieter Koch: adaptation to SWISSEPH, April 1996 - * 18-feb-2006 replaced LP by SWELP because of name collision - */ + * Expansions for the geocentric ecliptic longitude, + * latitude, and distance of the Moon referred to the mean equinox + * and ecliptic of date. + * + * This version of cmoon.c adjusts the ELP2000-85 analytical Lunar + * theory of Chapront-Touze and Chapront to fit the Jet Propulsion + * Laboratory's DE404 long ephemeris on the interval from 3000 B.C. + * to 3000 A.D. + * + * The fit is much better in the remote past and future if + * secular terms are included in the arguments of the oscillatory + * perturbations. Such adjustments cannot easily be incorporated + * into the 1991 lunar tables. In this program the traditional + * literal arguments are used instead, with mean elements adjusted + * for a best fit to the reference ephemeris. + * + * This program omits many oscillatory terms from the analytical + * theory which, if they were included, would yield a much higher + * accuracy for modern dates. Detailed statistics of the precision + * are given in the table below. Comparing at 64-day intervals + * over the period -3000 to +3000, the maximum discrepancies noted + * were 7" longitude, 5" latitude, and 5 x 10^-8 au radius. + * The expressions used for precession in this comparision were + * those of Simon et al (1994). + * + * The adjusted coefficients were found by an unweighted least squares + * fit to the numerical ephemeris in the mentioned test interval. + * The approximation error increases rapidly outside this interval. + * J. Chapront (1994) has described the basic fitting procedure. + * + * A major change from DE200 to DE404 is in the coefficient + * of tidal acceleration of the Moon, which causes the Moon's + * longitude to depart by about -0.9" per century squared + * from DE200. Uncertainty in this quantity continues to + * be the limiting factor in long term projections of the Moon's + * ephemeris. + * + * Since the Lunar theory is cast in the ecliptic of date, it makes + * some difference what formula you use for precession. The adjustment + * to DE404 was carried out relative to the mean equinox and ecliptic + * of date as defined in Williams (1994). An earlier version of this + * program used the precession given by Simon et al (1994). The difference + * between these two precession formulas amounts to about 12" in Lunar + * longitude at 3000 B.C. + * + * Maximum deviations between DE404 and this program + * in a set of 34274 samples spaced 64 days apart + * + * Interval Longitude Latitude Radius + * Julian Year arc sec arc sec 10^-8 au + * -3000 to -2500 5.66 4.66 4.93 + * -2500 to -2000 5.49 3.98 4.56 + * -2000 to -1500 6.98 4.17 4.81 + * -1500 to -1000 5.74 3.53 4.87 + * -1000 to -500 5.95 3.42 4.67 + * -500 to 0 4.94 3.07 4.04 + * 0 to 500 4.42 2.65 4.55 + * 500 to 1000 5.68 3.30 3.99 + * 1000 to 1500 4.32 3.21 3.83 + * 1500 to 2000 2.70 2.69 3.71 + * 2000 to 2500 3.35 2.32 3.85 + * 2500 to 3000 4.62 2.39 4.11 + * + * + * + * References: + * + * James G. Williams, "Contributions to the Earth's obliquity rate, + * precession, and nutation," Astron. J. 108, 711-724 (1994) + * + * DE403 and DE404 ephemerides by E. M. Standish, X. X. Newhall, and + * J. G. Williams are at the JPL computer site navigator.jpl.nasa.gov. + * + * J. L. Simon, P. Bretagnon, J. Chapront, M. Chapront-Touze', G. Francou, + * and J. Laskar, "Numerical Expressions for precession formulae and + * mean elements for the Moon and the planets," Astronomy and Astrophysics + * 282, 663-683 (1994) + * + * P. Bretagnon and Francou, G., "Planetary theories in rectangular + * and spherical variables. VSOP87 solutions," Astronomy and + * Astrophysics 202, 309-315 (1988) + * + * M. Chapront-Touze' and J. Chapront, "ELP2000-85: a semi-analytical + * lunar ephemeris adequate for historical times," Astronomy and + * Astrophysics 190, 342-352 (1988). + * + * M. Chapront-Touze' and J. Chapront, _Lunar Tables and + * Programs from 4000 B.C. to A.D. 8000_, Willmann-Bell (1991) + * + * J. Laskar, "Secular terms of classical planetary theories + * using the results of general theory," Astronomy and Astrophysics + * 157, 59070 (1986) + * + * S. L. Moshier, "Comparison of a 7000-year lunar ephemeris + * with analytical theory," Astronomy and Astrophysics 262, + * 613-616 (1992) + * + * J. Chapront, "Representation of planetary ephemerides by frequency + * analysis. Application to the five outer planets," Astronomy and + * Astrophysics Suppl. Ser. 109, 181-192 (1994) + * + * + * Entry swi_moshmoon2() returns the geometric position of the Moon + * relative to the Earth. Its calling procedure is as follows: + * + * double JD; input Julian Ephemeris Date + * double pol[3]; output ecliptic polar coordinatees in radians and au + * pol[0] longitude, pol[1] latitude, pol[2] radius + * swi_moshmoon2( JD, pol ); + * + * - S. L. Moshier, August, 1991 + * DE200 fit: July, 1992 + * DE404 fit: October, 1995 + * + * Dieter Koch: adaptation to SWISSEPH, April 1996 + * 18-feb-2006 replaced LP by SWELP because of name collision + */ #include #include "swephexp.h" @@ -187,9 +189,9 @@ static void mean_elements(void); static void mean_elements_pl(void); static double mods3600(double x); static void ecldat_equ2000(double tjd, double *xpm); -static void chewm(short *pt, int nlines, int nangles, - int typflg, double *ans ); -static void sscc(int k, double arg, int n ); +static void chewm(short *pt, int nlines, int nangles, int typflg, + double *ans); +static void sscc(int k, double arg, int n); static void moon1(void); static void moon2(void); static void moon3(void); @@ -197,6 +199,7 @@ static void moon4(void); #ifdef MOSH_MOON_200 + /* The following coefficients were calculated by a simultaneous least * squares fit between the analytical theory and the continued DE200 * numerically integrated ephemeris from 9000 BC to 13000 AD. @@ -204,532 +207,542 @@ static void moon4(void); * The 71 coefficients were estimated from 42,529 Lunar positions. */ static double z[] = { --1.225346551567e+001, /* F, t^2 */ --1.096676093208e-003, /* F, t^3 */ --2.165750777942e-006, /* F, t^4 */ --2.790392351314e-009, /* F, t^5 */ - 4.189032191814e-011, /* F, t^6 */ - 4.474984866301e-013, /* F, t^7 */ - 3.239398410335e+001, /* l, t^2 */ - 5.185305877294e-002, /* l, t^3 */ --2.536291235258e-004, /* l, t^4 */ --2.506365935364e-008, /* l, t^5 */ - 3.452144225877e-011, /* l, t^6 */ --1.755312760154e-012, /* l, t^7 */ --5.870522364514e+000, /* D, t^2 */ - 6.493037519768e-003, /* D, t^3 */ --3.702060118571e-005, /* D, t^4 */ - 2.560078201452e-009, /* D, t^5 */ - 2.555243317839e-011, /* D, t^6 */ --3.207663637426e-013, /* D, t^7 */ --4.776684245026e+000, /* L, t^2 */ - 6.580112707824e-003, /* L, t^3 */ --6.073960534117e-005, /* L, t^4 */ --1.024222633731e-008, /* L, t^5 */ - 2.235210987108e-010, /* L, t^6 */ - 7.200592540556e-014, /* L, t^7 */ --8.552017636339e+001, /* t^2 cos(18V - 16E - l) */ --2.055794304596e+002, /* t^2 sin(18V - 16E - l) */ --1.097555241866e+000, /* t^3 cos(18V - 16E - l) */ - 5.219423171002e-001, /* t^3 sin(18V - 16E - l) */ - 2.088802640755e-003, /* t^4 cos(18V - 16E - l) */ - 4.616541527921e-003, /* t^4 sin(18V - 16E - l) */ - 4.794930645807e+000, /* t^2 cos(10V - 3E - l) */ --4.595134364283e+001, /* t^2 sin(10V - 3E - l) */ --6.659812174691e-002, /* t^3 cos(10V - 3E - l) */ --2.570048828246e-001, /* t^3 sin(10V - 3E - l) */ - 6.229863046223e-004, /* t^4 cos(10V - 3E - l) */ - 5.504368344700e-003, /* t^4 sin(10V - 3E - l) */ --3.084830597278e+000, /* t^2 cos(8V - 13E) */ --1.000471012253e+001, /* t^2 sin(8V - 13E) */ - 6.590112074510e-002, /* t^3 cos(8V - 13E) */ --3.212573348278e-003, /* t^3 sin(8V - 13E) */ - 5.409038312567e-004, /* t^4 cos(8V - 13E) */ - 1.293377988163e-003, /* t^4 sin(8V - 13E) */ - 2.311794636111e+001, /* t^2 cos(4E - 8M + 3J) */ --3.157036220040e+000, /* t^2 sin(4E - 8M + 3J) */ --3.019293162417e+000, /* t^2 cos(18V - 16E) */ --9.211526858975e+000, /* t^2 sin(18V - 16E) */ --4.993704215784e-002, /* t^3 cos(18V - 16E) */ - 2.991187525454e-002, /* t^3 sin(18V - 16E) */ --3.827414182969e+000, /* t^2 cos(18V - 16E - 2l) */ --9.891527703219e+000, /* t^2 sin(18V - 16E - 2l) */ --5.322093802878e-002, /* t^3 cos(18V - 16E - 2l) */ - 3.164702647371e-002, /* t^3 sin(18V - 16E - 2l) */ - 7.713905234217e+000, /* t^2 cos(2J - 5S) */ --6.077986950734e+000, /* t^3 sin(2J - 5S) */ --1.278232501462e-001, /* t^2 cos(L - F) */ - 4.760967236383e-001, /* t^2 sin(L - F) */ --6.759005756460e-001, /* t^3 sin(l') */ - 1.655727996357e-003, /* t^4 sin(l') */ - 1.646526117252e-001, /* t^3 sin(2D - l') */ --4.167078100233e-004, /* t^4 sin(2D - l') */ - 2.067529538504e-001, /* t^3 sin(2D - l' - l) */ --5.219127398748e-004, /* t^4 sin(2D - l' - l) */ --1.526335222289e-001, /* t^3 sin(l' - l) */ --1.120545131358e-001, /* t^3 sin(l' + l) */ - 4.619472391553e-002, /* t^3 sin(2D - 2l') */ - 4.863621236157e-004, /* t^4 sin(2D - 2l') */ --4.280059182608e-002, /* t^3 sin(2l') */ --4.328378207833e-004, /* t^4 sin(2l') */ --8.371028286974e-003, /* t^3 sin(2D - l) */ - 4.089447328174e-002, /* t^3 sin(2D - 2l' - l) */ --1.238363006354e-002, /* t^3 sin(2D + 2l' - l) */ + -1.225346551567e+001, /* F, t^2 */ + -1.096676093208e-003, /* F, t^3 */ + -2.165750777942e-006, /* F, t^4 */ + -2.790392351314e-009, /* F, t^5 */ + 4.189032191814e-011, /* F, t^6 */ + 4.474984866301e-013, /* F, t^7 */ + 3.239398410335e+001, /* l, t^2 */ + 5.185305877294e-002, /* l, t^3 */ + -2.536291235258e-004, /* l, t^4 */ + -2.506365935364e-008, /* l, t^5 */ + 3.452144225877e-011, /* l, t^6 */ + -1.755312760154e-012, /* l, t^7 */ + -5.870522364514e+000, /* D, t^2 */ + 6.493037519768e-003, /* D, t^3 */ + -3.702060118571e-005, /* D, t^4 */ + 2.560078201452e-009, /* D, t^5 */ + 2.555243317839e-011, /* D, t^6 */ + -3.207663637426e-013, /* D, t^7 */ + -4.776684245026e+000, /* L, t^2 */ + 6.580112707824e-003, /* L, t^3 */ + -6.073960534117e-005, /* L, t^4 */ + -1.024222633731e-008, /* L, t^5 */ + 2.235210987108e-010, /* L, t^6 */ + 7.200592540556e-014, /* L, t^7 */ + -8.552017636339e+001, /* t^2 cos(18V - 16E - l) */ + -2.055794304596e+002, /* t^2 sin(18V - 16E - l) */ + -1.097555241866e+000, /* t^3 cos(18V - 16E - l) */ + 5.219423171002e-001, /* t^3 sin(18V - 16E - l) */ + 2.088802640755e-003, /* t^4 cos(18V - 16E - l) */ + 4.616541527921e-003, /* t^4 sin(18V - 16E - l) */ + 4.794930645807e+000, /* t^2 cos(10V - 3E - l) */ + -4.595134364283e+001, /* t^2 sin(10V - 3E - l) */ + -6.659812174691e-002, /* t^3 cos(10V - 3E - l) */ + -2.570048828246e-001, /* t^3 sin(10V - 3E - l) */ + 6.229863046223e-004, /* t^4 cos(10V - 3E - l) */ + 5.504368344700e-003, /* t^4 sin(10V - 3E - l) */ + -3.084830597278e+000, /* t^2 cos(8V - 13E) */ + -1.000471012253e+001, /* t^2 sin(8V - 13E) */ + 6.590112074510e-002, /* t^3 cos(8V - 13E) */ + -3.212573348278e-003, /* t^3 sin(8V - 13E) */ + 5.409038312567e-004, /* t^4 cos(8V - 13E) */ + 1.293377988163e-003, /* t^4 sin(8V - 13E) */ + 2.311794636111e+001, /* t^2 cos(4E - 8M + 3J) */ + -3.157036220040e+000, /* t^2 sin(4E - 8M + 3J) */ + -3.019293162417e+000, /* t^2 cos(18V - 16E) */ + -9.211526858975e+000, /* t^2 sin(18V - 16E) */ + -4.993704215784e-002, /* t^3 cos(18V - 16E) */ + 2.991187525454e-002, /* t^3 sin(18V - 16E) */ + -3.827414182969e+000, /* t^2 cos(18V - 16E - 2l) */ + -9.891527703219e+000, /* t^2 sin(18V - 16E - 2l) */ + -5.322093802878e-002, /* t^3 cos(18V - 16E - 2l) */ + 3.164702647371e-002, /* t^3 sin(18V - 16E - 2l) */ + 7.713905234217e+000, /* t^2 cos(2J - 5S) */ + -6.077986950734e+000, /* t^3 sin(2J - 5S) */ + -1.278232501462e-001, /* t^2 cos(L - F) */ + 4.760967236383e-001, /* t^2 sin(L - F) */ + -6.759005756460e-001, /* t^3 sin(l') */ + 1.655727996357e-003, /* t^4 sin(l') */ + 1.646526117252e-001, /* t^3 sin(2D - l') */ + -4.167078100233e-004, /* t^4 sin(2D - l') */ + 2.067529538504e-001, /* t^3 sin(2D - l' - l) */ + -5.219127398748e-004, /* t^4 sin(2D - l' - l) */ + -1.526335222289e-001, /* t^3 sin(l' - l) */ + -1.120545131358e-001, /* t^3 sin(l' + l) */ + 4.619472391553e-002, /* t^3 sin(2D - 2l') */ + 4.863621236157e-004, /* t^4 sin(2D - 2l') */ + -4.280059182608e-002, /* t^3 sin(2l') */ + -4.328378207833e-004, /* t^4 sin(2l') */ + -8.371028286974e-003, /* t^3 sin(2D - l) */ + 4.089447328174e-002, /* t^3 sin(2D - 2l' - l) */ + -1.238363006354e-002, /* t^3 sin(2D + 2l' - l) */ }; #else + /* The following coefficients were calculated by a simultaneous least * squares fit between the analytical theory and DE404 on the finite * interval from -3000 to +3000. * The coefficients were estimated from 34,247 Lunar positions. */ static double FAR z[] = { + /* The following are scaled in arc seconds, time in Julian centuries. They replace the corresponding terms in the mean elements. */ --1.312045233711e+01, /* F, t^2 */ --1.138215912580e-03, /* F, t^3 */ --9.646018347184e-06, /* F, t^4 */ - 3.146734198839e+01, /* l, t^2 */ - 4.768357585780e-02, /* l, t^3 */ --3.421689790404e-04, /* l, t^4 */ --6.847070905410e+00, /* D, t^2 */ --5.834100476561e-03, /* D, t^3 */ --2.905334122698e-04, /* D, t^4 */ --5.663161722088e+00, /* L, t^2 */ - 5.722859298199e-03, /* L, t^3 */ --8.466472828815e-05, /* L, t^4 */ + -1.312045233711e+01, /* F, t^2 */ + -1.138215912580e-03, /* F, t^3 */ + -9.646018347184e-06, /* F, t^4 */ + 3.146734198839e+01, /* l, t^2 */ + 4.768357585780e-02, /* l, t^3 */ + -3.421689790404e-04, /* l, t^4 */ + -6.847070905410e+00, /* D, t^2 */ + -5.834100476561e-03, /* D, t^3 */ + -2.905334122698e-04, /* D, t^4 */ + -5.663161722088e+00, /* L, t^2 */ + 5.722859298199e-03, /* L, t^3 */ + -8.466472828815e-05, /* L, t^4 */ + /* The following longitude terms are in arc seconds times 10^5. */ --8.429817796435e+01, /* t^2 cos(18V - 16E - l) */ --2.072552484689e+02, /* t^2 sin(18V - 16E - l) */ - 7.876842214863e+00, /* t^2 cos(10V - 3E - l) */ - 1.836463749022e+00, /* t^2 sin(10V - 3E - l) */ --1.557471855361e+01, /* t^2 cos(8V - 13E) */ --2.006969124724e+01, /* t^2 sin(8V - 13E) */ - 2.152670284757e+01, /* t^2 cos(4E - 8M + 3J) */ --6.179946916139e+00, /* t^2 sin(4E - 8M + 3J) */ --9.070028191196e-01, /* t^2 cos(18V - 16E) */ --1.270848233038e+01, /* t^2 sin(18V - 16E) */ --2.145589319058e+00, /* t^2 cos(2J - 5S) */ - 1.381936399935e+01, /* t^2 sin(2J - 5S) */ --1.999840061168e+00, /* t^3 sin(l') */ + -8.429817796435e+01, /* t^2 cos(18V - 16E - l) */ + -2.072552484689e+02, /* t^2 sin(18V - 16E - l) */ + 7.876842214863e+00, /* t^2 cos(10V - 3E - l) */ + 1.836463749022e+00, /* t^2 sin(10V - 3E - l) */ + -1.557471855361e+01, /* t^2 cos(8V - 13E) */ + -2.006969124724e+01, /* t^2 sin(8V - 13E) */ + 2.152670284757e+01, /* t^2 cos(4E - 8M + 3J) */ + -6.179946916139e+00, /* t^2 sin(4E - 8M + 3J) */ + -9.070028191196e-01, /* t^2 cos(18V - 16E) */ + -1.270848233038e+01, /* t^2 sin(18V - 16E) */ + -2.145589319058e+00, /* t^2 cos(2J - 5S) */ + 1.381936399935e+01, /* t^2 sin(2J - 5S) */ + -1.999840061168e+00, /* t^3 sin(l') */ }; -#endif /* ! MOSH_MOON_200 */ +#endif /* ! MOSH_MOON_200 */ /* Perturbation tables */ #define NLR 118 -static short FAR LR[8*NLR] = { +static short FAR LR[8 * NLR] = { + /* Longitude Radius D l' l F 1" .0001" 1km .0001km */ - 0, 0, 1, 0, 22639, 5858,-20905,-3550, - 2, 0,-1, 0, 4586, 4383, -3699,-1109, - 2, 0, 0, 0, 2369, 9139, -2955,-9676, - 0, 0, 2, 0, 769, 257, -569,-9251, - 0, 1, 0, 0, -666,-4171, 48, 8883, - 0, 0, 0, 2, -411,-5957, -3,-1483, - 2, 0,-2, 0, 211, 6556, 246, 1585, - 2,-1,-1, 0, 205, 4358, -152,-1377, - 2, 0, 1, 0, 191, 9562, -170,-7331, - 2,-1, 0, 0, 164, 7285, -204,-5860, - 0, 1,-1, 0, -147,-3213, -129,-6201, - 1, 0, 0, 0, -124,-9881, 108, 7427, - 0, 1, 1, 0, -109,-3803, 104, 7552, - 2, 0, 0,-2, 55, 1771, 10, 3211, - 0, 0, 1, 2, -45, -996, 0, 0, - 0, 0, 1,-2, 39, 5333, 79, 6606, - 4, 0,-1, 0, 38, 4298, -34,-7825, - 0, 0, 3, 0, 36, 1238, -23,-2104, - 4, 0,-2, 0, 30, 7726, -21,-6363, - 2, 1,-1, 0, -28,-3971, 24, 2085, - 2, 1, 0, 0, -24,-3582, 30, 8238, - 1, 0,-1, 0, -18,-5847, -8,-3791, - 1, 1, 0, 0, 17, 9545, -16,-6747, - 2,-1, 1, 0, 14, 5303, -12,-8314, - 2, 0, 2, 0, 14, 3797, -10,-4448, - 4, 0, 0, 0, 13, 8991, -11,-6500, - 2, 0,-3, 0, 13, 1941, 14, 4027, - 0, 1,-2, 0, -9,-6791, -7, -27, - 2, 0,-1, 2, -9,-3659, 0, 7740, - 2,-1,-2, 0, 8, 6055, 10, 562, - 1, 0, 1, 0, -8,-4531, 6, 3220, - 2,-2, 0, 0, 8, 502, -9,-8845, - 0, 1, 2, 0, -7,-6302, 5, 7509, - 0, 2, 0, 0, -7,-4475, 1, 657, - 2,-2,-1, 0, 7, 3712, -4,-9501, - 2, 0, 1,-2, -6,-3832, 4, 1311, - 2, 0, 0, 2, -5,-7416, 0, 0, - 4,-1,-1, 0, 4, 3740, -3,-9580, - 0, 0, 2, 2, -3,-9976, 0, 0, - 3, 0,-1, 0, -3,-2097, 3, 2582, - 2, 1, 1, 0, -2,-9145, 2, 6164, - 4,-1,-2, 0, 2, 7319, -1,-8970, - 0, 2,-1, 0, -2,-5679, -2,-1171, - 2, 2,-1, 0, -2,-5212, 2, 3536, - 2, 1,-2, 0, 2, 4889, 0, 1437, - 2,-1, 0,-2, 2, 1461, 0, 6571, - 4, 0, 1, 0, 1, 9777, -1,-4226, - 0, 0, 4, 0, 1, 9337, -1,-1169, - 4,-1, 0, 0, 1, 8708, -1,-5714, - 1, 0,-2, 0, -1,-7530, -1,-7385, - 2, 1, 0,-2, -1,-4372, 0,-1357, - 0, 0, 2,-2, -1,-3726, -4,-4212, - 1, 1, 1, 0, 1, 2618, 0,-9333, - 3, 0,-2, 0, -1,-2241, 0, 8624, - 4, 0,-3, 0, 1, 1868, 0,-5142, - 2,-1, 2, 0, 1, 1770, 0,-8488, - 0, 2, 1, 0, -1,-1617, 1, 1655, - 1, 1,-1, 0, 1, 777, 0, 8512, - 2, 0, 3, 0, 1, 595, 0,-6697, - 2, 0, 1, 2, 0,-9902, 0, 0, - 2, 0,-4, 0, 0, 9483, 0, 7785, - 2,-2, 1, 0, 0, 7517, 0,-6575, - 0, 1,-3, 0, 0,-6694, 0,-4224, - 4, 1,-1, 0, 0,-6352, 0, 5788, - 1, 0, 2, 0, 0,-5840, 0, 3785, - 1, 0, 0,-2, 0,-5833, 0,-7956, - 6, 0,-2, 0, 0, 5716, 0,-4225, - 2, 0,-2,-2, 0,-5606, 0, 4726, - 1,-1, 0, 0, 0,-5569, 0, 4976, - 0, 1, 3, 0, 0,-5459, 0, 3551, - 2, 0,-2, 2, 0,-5357, 0, 7740, - 2, 0,-1,-2, 0, 1790, 8, 7516, - 3, 0, 0, 0, 0, 4042, -1,-4189, - 2,-1,-3, 0, 0, 4784, 0, 4950, - 2,-1, 3, 0, 0, 932, 0, -585, - 2, 0, 2,-2, 0,-4538, 0, 2840, - 2,-1,-1, 2, 0,-4262, 0, 373, - 0, 0, 0, 4, 0, 4203, 0, 0, - 0, 1, 0, 2, 0, 4134, 0,-1580, - 6, 0,-1, 0, 0, 3945, 0,-2866, - 2,-1, 0, 2, 0,-3821, 0, 0, - 2,-1, 1,-2, 0,-3745, 0, 2094, - 4, 1,-2, 0, 0,-3576, 0, 2370, - 1, 1,-2, 0, 0, 3497, 0, 3323, - 2,-3, 0, 0, 0, 3398, 0,-4107, - 0, 0, 3, 2, 0,-3286, 0, 0, - 4,-2,-1, 0, 0,-3087, 0,-2790, - 0, 1,-1,-2, 0, 3015, 0, 0, - 4, 0,-1,-2, 0, 3009, 0,-3218, - 2,-2,-2, 0, 0, 2942, 0, 3430, - 6, 0,-3, 0, 0, 2925, 0,-1832, - 2, 1, 2, 0, 0,-2902, 0, 2125, - 4, 1, 0, 0, 0,-2891, 0, 2445, - 4,-1, 1, 0, 0, 2825, 0,-2029, - 3, 1,-1, 0, 0, 2737, 0,-2126, - 0, 1, 1, 2, 0, 2634, 0, 0, - 1, 0, 0, 2, 0, 2543, 0, 0, - 3, 0, 0,-2, 0,-2530, 0, 2010, - 2, 2,-2, 0, 0,-2499, 0,-1089, - 2,-3,-1, 0, 0, 2469, 0,-1481, - 3,-1,-1, 0, 0,-2314, 0, 2556, - 4, 0, 2, 0, 0, 2185, 0,-1392, - 4, 0,-1, 2, 0,-2013, 0, 0, - 0, 2,-2, 0, 0,-1931, 0, 0, - 2, 2, 0, 0, 0,-1858, 0, 0, - 2, 1,-3, 0, 0, 1762, 0, 0, - 4, 0,-2, 2, 0,-1698, 0, 0, - 4,-2,-2, 0, 0, 1578, 0,-1083, - 4,-2, 0, 0, 0, 1522, 0,-1281, - 3, 1, 0, 0, 0, 1499, 0,-1077, - 1,-1,-1, 0, 0,-1364, 0, 1141, - 1,-3, 0, 0, 0,-1281, 0, 0, - 6, 0, 0, 0, 0, 1261, 0, -859, - 2, 0, 2, 2, 0,-1239, 0, 0, - 1,-1, 1, 0, 0,-1207, 0, 1100, - 0, 0, 5, 0, 0, 1110, 0, -589, - 0, 3, 0, 0, 0,-1013, 0, 213, - 4,-1,-3, 0, 0, 998, 0, 0, + 0, 0, 1, 0, 22639, 5858, -20905, -3550, + 2, 0, -1, 0, 4586, 4383, -3699, -1109, + 2, 0, 0, 0, 2369, 9139, -2955, -9676, + 0, 0, 2, 0, 769, 257, -569, -9251, + 0, 1, 0, 0, -666, -4171, 48, 8883, + 0, 0, 0, 2, -411, -5957, -3, -1483, + 2, 0, -2, 0, 211, 6556, 246, 1585, + 2, -1, -1, 0, 205, 4358, -152, -1377, + 2, 0, 1, 0, 191, 9562, -170, -7331, + 2, -1, 0, 0, 164, 7285, -204, -5860, + 0, 1, -1, 0, -147, -3213, -129, -6201, + 1, 0, 0, 0, -124, -9881, 108, 7427, + 0, 1, 1, 0, -109, -3803, 104, 7552, + 2, 0, 0, -2, 55, 1771, 10, 3211, + 0, 0, 1, 2, -45, -996, 0, 0, + 0, 0, 1, -2, 39, 5333, 79, 6606, + 4, 0, -1, 0, 38, 4298, -34, -7825, + 0, 0, 3, 0, 36, 1238, -23, -2104, + 4, 0, -2, 0, 30, 7726, -21, -6363, + 2, 1, -1, 0, -28, -3971, 24, 2085, + 2, 1, 0, 0, -24, -3582, 30, 8238, + 1, 0, -1, 0, -18, -5847, -8, -3791, + 1, 1, 0, 0, 17, 9545, -16, -6747, + 2, -1, 1, 0, 14, 5303, -12, -8314, + 2, 0, 2, 0, 14, 3797, -10, -4448, + 4, 0, 0, 0, 13, 8991, -11, -6500, + 2, 0, -3, 0, 13, 1941, 14, 4027, + 0, 1, -2, 0, -9, -6791, -7, -27, + 2, 0, -1, 2, -9, -3659, 0, 7740, + 2, -1, -2, 0, 8, 6055, 10, 562, + 1, 0, 1, 0, -8, -4531, 6, 3220, + 2, -2, 0, 0, 8, 502, -9, -8845, + 0, 1, 2, 0, -7, -6302, 5, 7509, + 0, 2, 0, 0, -7, -4475, 1, 657, + 2, -2, -1, 0, 7, 3712, -4, -9501, + 2, 0, 1, -2, -6, -3832, 4, 1311, + 2, 0, 0, 2, -5, -7416, 0, 0, + 4, -1, -1, 0, 4, 3740, -3, -9580, + 0, 0, 2, 2, -3, -9976, 0, 0, + 3, 0, -1, 0, -3, -2097, 3, 2582, + 2, 1, 1, 0, -2, -9145, 2, 6164, + 4, -1, -2, 0, 2, 7319, -1, -8970, + 0, 2, -1, 0, -2, -5679, -2, -1171, + 2, 2, -1, 0, -2, -5212, 2, 3536, + 2, 1, -2, 0, 2, 4889, 0, 1437, + 2, -1, 0, -2, 2, 1461, 0, 6571, + 4, 0, 1, 0, 1, 9777, -1, -4226, + 0, 0, 4, 0, 1, 9337, -1, -1169, + 4, -1, 0, 0, 1, 8708, -1, -5714, + 1, 0, -2, 0, -1, -7530, -1, -7385, + 2, 1, 0, -2, -1, -4372, 0, -1357, + 0, 0, 2, -2, -1, -3726, -4, -4212, + 1, 1, 1, 0, 1, 2618, 0, -9333, + 3, 0, -2, 0, -1, -2241, 0, 8624, + 4, 0, -3, 0, 1, 1868, 0, -5142, + 2, -1, 2, 0, 1, 1770, 0, -8488, + 0, 2, 1, 0, -1, -1617, 1, 1655, + 1, 1, -1, 0, 1, 777, 0, 8512, + 2, 0, 3, 0, 1, 595, 0, -6697, + 2, 0, 1, 2, 0, -9902, 0, 0, + 2, 0, -4, 0, 0, 9483, 0, 7785, + 2, -2, 1, 0, 0, 7517, 0, -6575, + 0, 1, -3, 0, 0, -6694, 0, -4224, + 4, 1, -1, 0, 0, -6352, 0, 5788, + 1, 0, 2, 0, 0, -5840, 0, 3785, + 1, 0, 0, -2, 0, -5833, 0, -7956, + 6, 0, -2, 0, 0, 5716, 0, -4225, + 2, 0, -2, -2, 0, -5606, 0, 4726, + 1, -1, 0, 0, 0, -5569, 0, 4976, + 0, 1, 3, 0, 0, -5459, 0, 3551, + 2, 0, -2, 2, 0, -5357, 0, 7740, + 2, 0, -1, -2, 0, 1790, 8, 7516, + 3, 0, 0, 0, 0, 4042, -1, -4189, + 2, -1, -3, 0, 0, 4784, 0, 4950, + 2, -1, 3, 0, 0, 932, 0, -585, + 2, 0, 2, -2, 0, -4538, 0, 2840, + 2, -1, -1, 2, 0, -4262, 0, 373, + 0, 0, 0, 4, 0, 4203, 0, 0, + 0, 1, 0, 2, 0, 4134, 0, -1580, + 6, 0, -1, 0, 0, 3945, 0, -2866, + 2, -1, 0, 2, 0, -3821, 0, 0, + 2, -1, 1, -2, 0, -3745, 0, 2094, + 4, 1, -2, 0, 0, -3576, 0, 2370, + 1, 1, -2, 0, 0, 3497, 0, 3323, + 2, -3, 0, 0, 0, 3398, 0, -4107, + 0, 0, 3, 2, 0, -3286, 0, 0, + 4, -2, -1, 0, 0, -3087, 0, -2790, + 0, 1, -1, -2, 0, 3015, 0, 0, + 4, 0, -1, -2, 0, 3009, 0, -3218, + 2, -2, -2, 0, 0, 2942, 0, 3430, + 6, 0, -3, 0, 0, 2925, 0, -1832, + 2, 1, 2, 0, 0, -2902, 0, 2125, + 4, 1, 0, 0, 0, -2891, 0, 2445, + 4, -1, 1, 0, 0, 2825, 0, -2029, + 3, 1, -1, 0, 0, 2737, 0, -2126, + 0, 1, 1, 2, 0, 2634, 0, 0, + 1, 0, 0, 2, 0, 2543, 0, 0, + 3, 0, 0, -2, 0, -2530, 0, 2010, + 2, 2, -2, 0, 0, -2499, 0, -1089, + 2, -3, -1, 0, 0, 2469, 0, -1481, + 3, -1, -1, 0, 0, -2314, 0, 2556, + 4, 0, 2, 0, 0, 2185, 0, -1392, + 4, 0, -1, 2, 0, -2013, 0, 0, + 0, 2, -2, 0, 0, -1931, 0, 0, + 2, 2, 0, 0, 0, -1858, 0, 0, + 2, 1, -3, 0, 0, 1762, 0, 0, + 4, 0, -2, 2, 0, -1698, 0, 0, + 4, -2, -2, 0, 0, 1578, 0, -1083, + 4, -2, 0, 0, 0, 1522, 0, -1281, + 3, 1, 0, 0, 0, 1499, 0, -1077, + 1, -1, -1, 0, 0, -1364, 0, 1141, + 1, -3, 0, 0, 0, -1281, 0, 0, + 6, 0, 0, 0, 0, 1261, 0, -859, + 2, 0, 2, 2, 0, -1239, 0, 0, + 1, -1, 1, 0, 0, -1207, 0, 1100, + 0, 0, 5, 0, 0, 1110, 0, -589, + 0, 3, 0, 0, 0, -1013, 0, 213, + 4, -1, -3, 0, 0, 998, 0, 0, }; #ifdef MOSH_MOON_200 #define NMB 56 -static short FAR MB[6*NMB] = { +static short FAR MB[6 * NMB] = { + /* Latitude D l' l F 1" .0001" */ - 0, 0, 0, 1,18461, 2387, - 0, 0, 1, 1, 1010, 1671, - 0, 0, 1,-1, 999, 6936, - 2, 0, 0,-1, 623, 6524, - 2, 0,-1, 1, 199, 4837, - 2, 0,-1,-1, 166, 5741, - 2, 0, 0, 1, 117, 2607, - 0, 0, 2, 1, 61, 9120, - 2, 0, 1,-1, 33, 3572, - 0, 0, 2,-1, 31, 7597, - 2,-1, 0,-1, 29, 5766, - 2, 0,-2,-1, 15, 5663, - 2, 0, 1, 1, 15, 1216, - 2, 1, 0,-1, -12, -941, - 2,-1,-1, 1, 8, 8681, - 2,-1, 0, 1, 7, 9586, - 2,-1,-1,-1, 7, 4346, - 0, 1,-1,-1, -6,-7314, - 4, 0,-1,-1, 6, 5796, - 0, 1, 0, 1, -6,-4601, - 0, 0, 0, 3, -6,-2965, - 0, 1,-1, 1, -5,-6324, - 1, 0, 0, 1, -5,-3684, - 0, 1, 1, 1, -5,-3113, - 0, 1, 1,-1, -5, -759, - 0, 1, 0,-1, -4,-8396, - 1, 0, 0,-1, -4,-8057, - 0, 0, 3, 1, 3, 9841, - 4, 0, 0,-1, 3, 6745, - 4, 0,-1, 1, 2, 9985, - 0, 0, 1,-3, 2, 7986, - 4, 0,-2, 1, 2, 4139, - 2, 0, 0,-3, 2, 1863, - 2, 0, 2,-1, 2, 1462, - 2,-1, 1,-1, 1, 7660, - 2, 0,-2, 1, -1,-6244, - 0, 0, 3,-1, 1, 5813, - 2, 0, 2, 1, 1, 5198, - 2, 0,-3,-1, 1, 5156, - 2, 1,-1, 1, -1,-3178, - 2, 1, 0, 1, -1,-2643, - 4, 0, 0, 1, 1, 1919, - 2,-1, 1, 1, 1, 1346, - 2,-2, 0,-1, 1, 859, - 0, 0, 1, 3, -1, -194, - 2, 1, 1,-1, 0,-8227, - 1, 1, 0,-1, 0, 8042, - 1, 1, 0, 1, 0, 8026, - 0, 1,-2,-1, 0,-7932, - 2, 1,-1,-1, 0,-7910, - 1, 0, 1, 1, 0,-6674, - 2,-1,-2,-1, 0, 6502, - 0, 1, 2, 1, 0,-6388, - 4, 0,-2,-1, 0, 6337, - 4,-1,-1,-1, 0, 5958, - 1, 0, 1,-1, 0,-5889, + 0, 0, 0, 1, 18461, 2387, + 0, 0, 1, 1, 1010, 1671, + 0, 0, 1, -1, 999, 6936, + 2, 0, 0, -1, 623, 6524, + 2, 0, -1, 1, 199, 4837, + 2, 0, -1, -1, 166, 5741, + 2, 0, 0, 1, 117, 2607, + 0, 0, 2, 1, 61, 9120, + 2, 0, 1, -1, 33, 3572, + 0, 0, 2, -1, 31, 7597, + 2, -1, 0, -1, 29, 5766, + 2, 0, -2, -1, 15, 5663, + 2, 0, 1, 1, 15, 1216, + 2, 1, 0, -1, -12, -941, + 2, -1, -1, 1, 8, 8681, + 2, -1, 0, 1, 7, 9586, + 2, -1, -1, -1, 7, 4346, + 0, 1, -1, -1, -6, -7314, + 4, 0, -1, -1, 6, 5796, + 0, 1, 0, 1, -6, -4601, + 0, 0, 0, 3, -6, -2965, + 0, 1, -1, 1, -5, -6324, + 1, 0, 0, 1, -5, -3684, + 0, 1, 1, 1, -5, -3113, + 0, 1, 1, -1, -5, -759, + 0, 1, 0, -1, -4, -8396, + 1, 0, 0, -1, -4, -8057, + 0, 0, 3, 1, 3, 9841, + 4, 0, 0, -1, 3, 6745, + 4, 0, -1, 1, 2, 9985, + 0, 0, 1, -3, 2, 7986, + 4, 0, -2, 1, 2, 4139, + 2, 0, 0, -3, 2, 1863, + 2, 0, 2, -1, 2, 1462, + 2, -1, 1, -1, 1, 7660, + 2, 0, -2, 1, -1, -6244, + 0, 0, 3, -1, 1, 5813, + 2, 0, 2, 1, 1, 5198, + 2, 0, -3, -1, 1, 5156, + 2, 1, -1, 1, -1, -3178, + 2, 1, 0, 1, -1, -2643, + 4, 0, 0, 1, 1, 1919, + 2, -1, 1, 1, 1, 1346, + 2, -2, 0, -1, 1, 859, + 0, 0, 1, 3, -1, -194, + 2, 1, 1, -1, 0, -8227, + 1, 1, 0, -1, 0, 8042, + 1, 1, 0, 1, 0, 8026, + 0, 1, -2, -1, 0, -7932, + 2, 1, -1, -1, 0, -7910, + 1, 0, 1, 1, 0, -6674, + 2, -1, -2, -1, 0, 6502, + 0, 1, 2, 1, 0, -6388, + 4, 0, -2, -1, 0, 6337, + 4, -1, -1, -1, 0, 5958, + 1, 0, 1, -1, 0, -5889, }; #else #define NMB 77 -static short FAR MB[6*NMB] = { +static short FAR MB[6 * NMB] = { + /* Latitude D l' l F 1" .0001" */ - 0, 0, 0, 1,18461, 2387, - 0, 0, 1, 1, 1010, 1671, - 0, 0, 1,-1, 999, 6936, - 2, 0, 0,-1, 623, 6524, - 2, 0,-1, 1, 199, 4837, - 2, 0,-1,-1, 166, 5741, - 2, 0, 0, 1, 117, 2607, - 0, 0, 2, 1, 61, 9120, - 2, 0, 1,-1, 33, 3572, - 0, 0, 2,-1, 31, 7597, - 2,-1, 0,-1, 29, 5766, - 2, 0,-2,-1, 15, 5663, - 2, 0, 1, 1, 15, 1216, - 2, 1, 0,-1, -12, -941, - 2,-1,-1, 1, 8, 8681, - 2,-1, 0, 1, 7, 9586, - 2,-1,-1,-1, 7, 4346, - 0, 1,-1,-1, -6,-7314, - 4, 0,-1,-1, 6, 5796, - 0, 1, 0, 1, -6,-4601, - 0, 0, 0, 3, -6,-2965, - 0, 1,-1, 1, -5,-6324, - 1, 0, 0, 1, -5,-3684, - 0, 1, 1, 1, -5,-3113, - 0, 1, 1,-1, -5, -759, - 0, 1, 0,-1, -4,-8396, - 1, 0, 0,-1, -4,-8057, - 0, 0, 3, 1, 3, 9841, - 4, 0, 0,-1, 3, 6745, - 4, 0,-1, 1, 2, 9985, - 0, 0, 1,-3, 2, 7986, - 4, 0,-2, 1, 2, 4139, - 2, 0, 0,-3, 2, 1863, - 2, 0, 2,-1, 2, 1462, - 2,-1, 1,-1, 1, 7660, - 2, 0,-2, 1, -1,-6244, - 0, 0, 3,-1, 1, 5813, - 2, 0, 2, 1, 1, 5198, - 2, 0,-3,-1, 1, 5156, - 2, 1,-1, 1, -1,-3178, - 2, 1, 0, 1, -1,-2643, - 4, 0, 0, 1, 1, 1919, - 2,-1, 1, 1, 1, 1346, - 2,-2, 0,-1, 1, 859, - 0, 0, 1, 3, -1, -194, - 2, 1, 1,-1, 0,-8227, - 1, 1, 0,-1, 0, 8042, - 1, 1, 0, 1, 0, 8026, - 0, 1,-2,-1, 0,-7932, - 2, 1,-1,-1, 0,-7910, - 1, 0, 1, 1, 0,-6674, - 2,-1,-2,-1, 0, 6502, - 0, 1, 2, 1, 0,-6388, - 4, 0,-2,-1, 0, 6337, - 4,-1,-1,-1, 0, 5958, - 1, 0, 1,-1, 0,-5889, - 4, 0, 1,-1, 0, 4734, - 1, 0,-1,-1, 0,-4299, - 4,-1, 0,-1, 0, 4149, - 2,-2, 0, 1, 0, 3835, - 3, 0, 0,-1, 0,-3518, - 4,-1,-1, 1, 0, 3388, - 2, 0,-1,-3, 0, 3291, - 2,-2,-1, 1, 0, 3147, - 0, 1, 2,-1, 0,-3129, - 3, 0,-1,-1, 0,-3052, - 0, 1,-2, 1, 0,-3013, - 2, 0, 1,-3, 0,-2912, - 2,-2,-1,-1, 0, 2686, - 0, 0, 4, 1, 0, 2633, - 2, 0,-3, 1, 0, 2541, - 2, 0,-1, 3, 0,-2448, - 2, 1, 1, 1, 0,-2370, - 4,-1,-2, 1, 0, 2138, - 4, 0, 1, 1, 0, 2126, - 3, 0,-1, 1, 0,-2059, - 4, 1,-1,-1, 0,-1719, + 0, 0, 0, 1, 18461, 2387, + 0, 0, 1, 1, 1010, 1671, + 0, 0, 1, -1, 999, 6936, + 2, 0, 0, -1, 623, 6524, + 2, 0, -1, 1, 199, 4837, + 2, 0, -1, -1, 166, 5741, + 2, 0, 0, 1, 117, 2607, + 0, 0, 2, 1, 61, 9120, + 2, 0, 1, -1, 33, 3572, + 0, 0, 2, -1, 31, 7597, + 2, -1, 0, -1, 29, 5766, + 2, 0, -2, -1, 15, 5663, + 2, 0, 1, 1, 15, 1216, + 2, 1, 0, -1, -12, -941, + 2, -1, -1, 1, 8, 8681, + 2, -1, 0, 1, 7, 9586, + 2, -1, -1, -1, 7, 4346, + 0, 1, -1, -1, -6, -7314, + 4, 0, -1, -1, 6, 5796, + 0, 1, 0, 1, -6, -4601, + 0, 0, 0, 3, -6, -2965, + 0, 1, -1, 1, -5, -6324, + 1, 0, 0, 1, -5, -3684, + 0, 1, 1, 1, -5, -3113, + 0, 1, 1, -1, -5, -759, + 0, 1, 0, -1, -4, -8396, + 1, 0, 0, -1, -4, -8057, + 0, 0, 3, 1, 3, 9841, + 4, 0, 0, -1, 3, 6745, + 4, 0, -1, 1, 2, 9985, + 0, 0, 1, -3, 2, 7986, + 4, 0, -2, 1, 2, 4139, + 2, 0, 0, -3, 2, 1863, + 2, 0, 2, -1, 2, 1462, + 2, -1, 1, -1, 1, 7660, + 2, 0, -2, 1, -1, -6244, + 0, 0, 3, -1, 1, 5813, + 2, 0, 2, 1, 1, 5198, + 2, 0, -3, -1, 1, 5156, + 2, 1, -1, 1, -1, -3178, + 2, 1, 0, 1, -1, -2643, + 4, 0, 0, 1, 1, 1919, + 2, -1, 1, 1, 1, 1346, + 2, -2, 0, -1, 1, 859, + 0, 0, 1, 3, -1, -194, + 2, 1, 1, -1, 0, -8227, + 1, 1, 0, -1, 0, 8042, + 1, 1, 0, 1, 0, 8026, + 0, 1, -2, -1, 0, -7932, + 2, 1, -1, -1, 0, -7910, + 1, 0, 1, 1, 0, -6674, + 2, -1, -2, -1, 0, 6502, + 0, 1, 2, 1, 0, -6388, + 4, 0, -2, -1, 0, 6337, + 4, -1, -1, -1, 0, 5958, + 1, 0, 1, -1, 0, -5889, + 4, 0, 1, -1, 0, 4734, + 1, 0, -1, -1, 0, -4299, + 4, -1, 0, -1, 0, 4149, + 2, -2, 0, 1, 0, 3835, + 3, 0, 0, -1, 0, -3518, + 4, -1, -1, 1, 0, 3388, + 2, 0, -1, -3, 0, 3291, + 2, -2, -1, 1, 0, 3147, + 0, 1, 2, -1, 0, -3129, + 3, 0, -1, -1, 0, -3052, + 0, 1, -2, 1, 0, -3013, + 2, 0, 1, -3, 0, -2912, + 2, -2, -1, -1, 0, 2686, + 0, 0, 4, 1, 0, 2633, + 2, 0, -3, 1, 0, 2541, + 2, 0, -1, 3, 0, -2448, + 2, 1, 1, 1, 0, -2370, + 4, -1, -2, 1, 0, 2138, + 4, 0, 1, 1, 0, 2126, + 3, 0, -1, 1, 0, -2059, + 4, 1, -1, -1, 0, -1719, }; -#endif /* ! MOSH_MOON_200 */ +#endif /* ! MOSH_MOON_200 */ #define NLRT 38 -static short FAR LRT[8*NLRT] = { +static short FAR LRT[8 * NLRT] = { + /* Multiply by T Longitude Radius D l' l F .1" .00001" .1km .00001km */ - 0, 1, 0, 0, 16, 7680, -1,-2302, - 2,-1,-1, 0, -5,-1642, 3, 8245, - 2,-1, 0, 0, -4,-1383, 5, 1395, - 0, 1,-1, 0, 3, 7115, 3, 2654, - 0, 1, 1, 0, 2, 7560, -2,-6396, - 2, 1,-1, 0, 0, 7118, 0,-6068, - 2, 1, 0, 0, 0, 6128, 0,-7754, - 1, 1, 0, 0, 0,-4516, 0, 4194, - 2,-2, 0, 0, 0,-4048, 0, 4970, - 0, 2, 0, 0, 0, 3747, 0, -540, - 2,-2,-1, 0, 0,-3707, 0, 2490, - 2,-1, 1, 0, 0,-3649, 0, 3222, - 0, 1,-2, 0, 0, 2438, 0, 1760, - 2,-1,-2, 0, 0,-2165, 0,-2530, - 0, 1, 2, 0, 0, 1923, 0,-1450, - 0, 2,-1, 0, 0, 1292, 0, 1070, - 2, 2,-1, 0, 0, 1271, 0,-6070, - 4,-1,-1, 0, 0,-1098, 0, 990, - 2, 0, 0, 0, 0, 1073, 0,-1360, - 2, 0,-1, 0, 0, 839, 0, -630, - 2, 1, 1, 0, 0, 734, 0, -660, - 4,-1,-2, 0, 0, -688, 0, 480, - 2, 1,-2, 0, 0, -630, 0, 0, - 0, 2, 1, 0, 0, 587, 0, -590, - 2,-1, 0,-2, 0, -540, 0, -170, - 4,-1, 0, 0, 0, -468, 0, 390, - 2,-2, 1, 0, 0, -378, 0, 330, - 2, 1, 0,-2, 0, 364, 0, 0, - 1, 1, 1, 0, 0, -317, 0, 240, - 2,-1, 2, 0, 0, -295, 0, 210, - 1, 1,-1, 0, 0, -270, 0, -210, - 2,-3, 0, 0, 0, -256, 0, 310, - 2,-3,-1, 0, 0, -187, 0, 110, - 0, 1,-3, 0, 0, 169, 0, 110, - 4, 1,-1, 0, 0, 158, 0, -150, - 4,-2,-1, 0, 0, -155, 0, 140, - 0, 0, 1, 0, 0, 155, 0, -250, - 2,-2,-2, 0, 0, -148, 0, -170, + 0, 1, 0, 0, 16, 7680, -1, -2302, + 2, -1, -1, 0, -5, -1642, 3, 8245, + 2, -1, 0, 0, -4, -1383, 5, 1395, + 0, 1, -1, 0, 3, 7115, 3, 2654, + 0, 1, 1, 0, 2, 7560, -2, -6396, + 2, 1, -1, 0, 0, 7118, 0, -6068, + 2, 1, 0, 0, 0, 6128, 0, -7754, + 1, 1, 0, 0, 0, -4516, 0, 4194, + 2, -2, 0, 0, 0, -4048, 0, 4970, + 0, 2, 0, 0, 0, 3747, 0, -540, + 2, -2, -1, 0, 0, -3707, 0, 2490, + 2, -1, 1, 0, 0, -3649, 0, 3222, + 0, 1, -2, 0, 0, 2438, 0, 1760, + 2, -1, -2, 0, 0, -2165, 0, -2530, + 0, 1, 2, 0, 0, 1923, 0, -1450, + 0, 2, -1, 0, 0, 1292, 0, 1070, + 2, 2, -1, 0, 0, 1271, 0, -6070, + 4, -1, -1, 0, 0, -1098, 0, 990, + 2, 0, 0, 0, 0, 1073, 0, -1360, + 2, 0, -1, 0, 0, 839, 0, -630, + 2, 1, 1, 0, 0, 734, 0, -660, + 4, -1, -2, 0, 0, -688, 0, 480, + 2, 1, -2, 0, 0, -630, 0, 0, + 0, 2, 1, 0, 0, 587, 0, -590, + 2, -1, 0, -2, 0, -540, 0, -170, + 4, -1, 0, 0, 0, -468, 0, 390, + 2, -2, 1, 0, 0, -378, 0, 330, + 2, 1, 0, -2, 0, 364, 0, 0, + 1, 1, 1, 0, 0, -317, 0, 240, + 2, -1, 2, 0, 0, -295, 0, 210, + 1, 1, -1, 0, 0, -270, 0, -210, + 2, -3, 0, 0, 0, -256, 0, 310, + 2, -3, -1, 0, 0, -187, 0, 110, + 0, 1, -3, 0, 0, 169, 0, 110, + 4, 1, -1, 0, 0, 158, 0, -150, + 4, -2, -1, 0, 0, -155, 0, 140, + 0, 0, 1, 0, 0, 155, 0, -250, + 2, -2, -2, 0, 0, -148, 0, -170, }; #define NBT 16 -static short FAR BT[5*NBT] = { +static short FAR BT[5 * NBT] = { + /* Multiply by T Latitude D l' l F .00001" */ - 2,-1, 0,-1, -7430, - 2, 1, 0,-1, 3043, - 2,-1,-1, 1, -2229, - 2,-1, 0, 1, -1999, - 2,-1,-1,-1, -1869, - 0, 1,-1,-1, 1696, - 0, 1, 0, 1, 1623, - 0, 1,-1, 1, 1418, - 0, 1, 1, 1, 1339, - 0, 1, 1,-1, 1278, - 0, 1, 0,-1, 1217, - 2,-2, 0,-1, -547, - 2,-1, 1,-1, -443, - 2, 1,-1, 1, 331, - 2, 1, 0, 1, 317, - 2, 0, 0,-1, 295, + 2, -1, 0, -1, -7430, + 2, 1, 0, -1, 3043, + 2, -1, -1, 1, -2229, + 2, -1, 0, 1, -1999, + 2, -1, -1, -1, -1869, + 0, 1, -1, -1, 1696, + 0, 1, 0, 1, 1623, + 0, 1, -1, 1, 1418, + 0, 1, 1, 1, 1339, + 0, 1, 1, -1, 1278, + 0, 1, 0, -1, 1217, + 2, -2, 0, -1, -547, + 2, -1, 1, -1, -443, + 2, 1, -1, 1, 331, + 2, 1, 0, 1, 317, + 2, 0, 0, -1, 295, }; #define NLRT2 25 -static short FAR LRT2[6*NLRT2] = { +static short FAR LRT2[6 * NLRT2] = { + /* Multiply by T^2 Longitude Radius D l' l F .00001" .00001km */ - 0, 1, 0, 0, 487, -36, - 2,-1,-1, 0, -150, 111, - 2,-1, 0, 0, -120, 149, - 0, 1,-1, 0, 108, 95, - 0, 1, 1, 0, 80, -77, - 2, 1,-1, 0, 21, -18, - 2, 1, 0, 0, 20, -23, - 1, 1, 0, 0, -13, 12, - 2,-2, 0, 0, -12, 14, - 2,-1, 1, 0, -11, 9, - 2,-2,-1, 0, -11, 7, - 0, 2, 0, 0, 11, 0, - 2,-1,-2, 0, -6, -7, - 0, 1,-2, 0, 7, 5, - 0, 1, 2, 0, 6, -4, - 2, 2,-1, 0, 5, -3, - 0, 2,-1, 0, 5, 3, - 4,-1,-1, 0, -3, 3, - 2, 0, 0, 0, 3, -4, - 4,-1,-2, 0, -2, 0, - 2, 1,-2, 0, -2, 0, - 2,-1, 0,-2, -2, 0, - 2, 1, 1, 0, 2, -2, - 2, 0,-1, 0, 2, 0, - 0, 2, 1, 0, 2, 0, + 0, 1, 0, 0, 487, -36, + 2, -1, -1, 0, -150, 111, + 2, -1, 0, 0, -120, 149, + 0, 1, -1, 0, 108, 95, + 0, 1, 1, 0, 80, -77, + 2, 1, -1, 0, 21, -18, + 2, 1, 0, 0, 20, -23, + 1, 1, 0, 0, -13, 12, + 2, -2, 0, 0, -12, 14, + 2, -1, 1, 0, -11, 9, + 2, -2, -1, 0, -11, 7, + 0, 2, 0, 0, 11, 0, + 2, -1, -2, 0, -6, -7, + 0, 1, -2, 0, 7, 5, + 0, 1, 2, 0, 6, -4, + 2, 2, -1, 0, 5, -3, + 0, 2, -1, 0, 5, 3, + 4, -1, -1, 0, -3, 3, + 2, 0, 0, 0, 3, -4, + 4, -1, -2, 0, -2, 0, + 2, 1, -2, 0, -2, 0, + 2, -1, 0, -2, -2, 0, + 2, 1, 1, 0, 2, -2, + 2, 0, -1, 0, 2, 0, + 0, 2, 1, 0, 2, 0, }; #define NBT2 12 -static short FAR BT2[5*NBT2] = { +static short FAR BT2[5 * NBT2] = { + /* Multiply by T^2 Latitiude D l' l F .00001" */ - 2,-1, 0,-1, -22, - 2, 1, 0,-1, 9, - 2,-1, 0, 1, -6, - 2,-1,-1, 1, -6, - 2,-1,-1,-1, -5, - 0, 1, 0, 1, 5, - 0, 1,-1,-1, 5, - 0, 1, 1, 1, 4, - 0, 1, 1,-1, 4, - 0, 1, 0,-1, 4, - 0, 1,-1, 1, 4, - 2,-2, 0,-1, -2, + 2, -1, 0, -1, -22, + 2, 1, 0, -1, 9, + 2, -1, 0, 1, -6, + 2, -1, -1, 1, -6, + 2, -1, -1, -1, -5, + 0, 1, 0, 1, 5, + 0, 1, -1, -1, 5, + 0, 1, 1, 1, 4, + 0, 1, 1, -1, 4, + 0, 1, 0, -1, 4, + 0, 1, -1, 1, 4, + 2, -2, 0, -1, -2, }; /* The following times are set up by update() and refer * to the same instant. The distinction between them * is required by altaz(). */ -static double FAR ss[5][8]; +static double FAR ss[5][8]; static double FAR cc[5][8]; -static double l; /* Moon's ecliptic longitude */ -static double B; /* Ecliptic latitude */ +static double l; /* Moon's ecliptic longitude */ +static double B; /* Ecliptic latitude */ static double moonpol[3]; @@ -762,20 +775,21 @@ static double l4; /* Calculate geometric coordinates of Moon * without light time or nutation correction. */ -int swi_moshmoon2(double J, double *pol) +int +swi_moshmoon2(double J, double *pol) { -int i; -T = (J-J2000)/36525.0; -T2 = T*T; -mean_elements(); -mean_elements_pl(); -moon1(); -moon2(); -moon3(); -moon4(); -for( i=0; i<3; i++ ) - pol[i] = moonpol[i]; -return(0); + int i; + T = (J - J2000) / 36525.0; + T2 = T * T; + mean_elements(); + mean_elements_pl(); + moon1(); + moon2(); + moon3(); + moon4(); + for (i = 0; i < 3; i++) + pol[i] = moonpol[i]; + return (0); } /* Moshier's moom @@ -783,323 +797,328 @@ return(0); * xpm array of 6 doubles for moon's position and speed vectors * serr pointer to error string */ -int swi_moshmoon(double tjd, AS_BOOL do_save, double *xpmret, char *serr) +int +swi_moshmoon(double tjd, AS_BOOL do_save, double *xpmret, char *serr) { - int i; - double a, b, x1[6], x2[6], t; - double xx[6], *xpm; - struct plan_data *pdp = &swed.pldat[SEI_MOON]; - char s[AS_MAXCH]; - if (do_save) - xpm = pdp->x; - else - xpm = xx; - /* allow 0.2 day tolerance so that true node interval fits in */ - if (tjd < MOSHLUEPH_START - 0.2 || tjd > MOSHLUEPH_END + 0.2) { - if (serr != NULL) { - sprintf(s, "jd %f outside Moshier's Moon range %.2f .. %.2f ", - tjd, MOSHLUEPH_START, MOSHLUEPH_END); - if (strlen(serr) + strlen(s) < AS_MAXCH) - strcat(serr, s); + int i; + double a, b, x1[6], x2[6], t; + double xx[6], *xpm; + struct plan_data *pdp = &swed.pldat[SEI_MOON]; + char s[AS_MAXCH]; + if (do_save) + xpm = pdp->x; + else + xpm = xx; + /* allow 0.2 day tolerance so that true node interval fits in */ + if (tjd < MOSHLUEPH_START - 0.2 || tjd > MOSHLUEPH_END + 0.2) { + if (serr != NULL) { + sprintf(s, "jd %f outside Moshier's Moon range %.2f .. %.2f ", + tjd, MOSHLUEPH_START, MOSHLUEPH_END); + if (strlen(serr) + strlen(s) < AS_MAXCH) + strcat(serr, s); + } + return (ERR); } - return(ERR); - } - /* if moon has already been computed */ - if (tjd == pdp->teval && pdp->iephe == SEFLG_MOSEPH) { - if (xpmret != NULL) - for (i = 0; i <= 5; i++) - xpmret[i] = pdp->x[i]; - return(OK); - } - /* else compute moon */ - swi_moshmoon2(tjd, xpm); - if (do_save) { - pdp->teval = tjd; - pdp->xflgs = -1; - pdp->iephe = SEFLG_MOSEPH; - } - /* Moshier moon is referred to ecliptic of date. But we need - * equatorial positions for several reasons. - * e.g. computation of earth from emb and moon - * of heliocentric moon - * Besides, this helps to keep the program structure simpler - */ - ecldat_equ2000(tjd, xpm); - /* speed */ - /* from 2 other positions. */ - /* one would be good enough for computation of osculating node, - * but not for osculating apogee */ - t = tjd + MOON_SPEED_INTV; - swi_moshmoon2(t, x1); - ecldat_equ2000(t, x1); - t = tjd - MOON_SPEED_INTV; - swi_moshmoon2(t, x2); - ecldat_equ2000(t, x2); - for (i = 0; i <= 2; i++) { + /* if moon has already been computed */ + if (tjd == pdp->teval && pdp->iephe == SEFLG_MOSEPH) { + if (xpmret != NULL) + for (i = 0; i <= 5; i++) + xpmret[i] = pdp->x[i]; + return (OK); + } + /* else compute moon */ + swi_moshmoon2(tjd, xpm); + if (do_save) { + pdp->teval = tjd; + pdp->xflgs = -1; + pdp->iephe = SEFLG_MOSEPH; + } + /* Moshier moon is referred to ecliptic of date. But we need + * equatorial positions for several reasons. + * e.g. computation of earth from emb and moon + * of heliocentric moon + * Besides, this helps to keep the program structure simpler + */ + ecldat_equ2000(tjd, xpm); + /* speed */ + /* from 2 other positions. */ + /* one would be good enough for computation of osculating node, + * but not for osculating apogee */ + t = tjd + MOON_SPEED_INTV; + swi_moshmoon2(t, x1); + ecldat_equ2000(t, x1); + t = tjd - MOON_SPEED_INTV; + swi_moshmoon2(t, x2); + ecldat_equ2000(t, x2); + for (i = 0; i <= 2; i++) { #if 0 - xpm[i+3] = (x1[i] - x2[i]) / MOON_SPEED_INTV / 2; + xpm[i + 3] = (x1[i] - x2[i]) / MOON_SPEED_INTV / 2; #else - b = (x1[i] - x2[i]) / 2; - a = (x1[i] + x2[i]) / 2 - xpm[i]; - xpm[i+3] = (2 * a + b) / MOON_SPEED_INTV; + b = (x1[i] - x2[i]) / 2; + a = (x1[i] + x2[i]) / 2 - xpm[i]; + xpm[i + 3] = (2 * a + b) / MOON_SPEED_INTV; #endif - } - if (xpmret != NULL) - for (i = 0; i <= 5; i++) - xpmret[i] = xpm[i]; - return(OK); + } + if (xpmret != NULL) + for (i = 0; i <= 5; i++) + xpmret[i] = xpm[i]; + return (OK); } #ifdef MOSH_MOON_200 -static void moon1() +static void +moon1() { -double a; + double a; -sscc( 0, STR*D, 6 ); -sscc( 1, STR*M, 4 ); -sscc( 2, STR*MP, 4 ); -sscc( 3, STR*NF, 4 ); + sscc(0, STR * D, 6); + sscc(1, STR * M, 4); + sscc(2, STR * MP, 4); + sscc(3, STR * NF, 4); -moonpol[0] = 0.0; -moonpol[1] = 0.0; -moonpol[2] = 0.0; + moonpol[0] = 0.0; + moonpol[1] = 0.0; + moonpol[2] = 0.0; /* terms in T^2, scale 1.0 = 10^-5" */ -chewm( LRT2, NLRT2, 4, 2, moonpol ); -chewm( BT2, NBT2, 4, 4, moonpol ); + chewm(LRT2, NLRT2, 4, 2, moonpol); + chewm(BT2, NBT2, 4, 4, moonpol); -f = 18 * Ve - 16 * Ea; + f = 18 * Ve - 16 * Ea; -g = STR*(f - MP ); /* 18V - 16E - l */ -cg = cos(g); -sg = sin(g); -l = 6.367278 * cg + 12.747036 * sg; /* t^0 */ -l1 = 23123.70 * cg - 10570.02 * sg; /* t^1 */ -l2 = z[24] * cg + z[25] * sg; /* t^2 */ -l3 = z[26] * cg + z[27] * sg; /* t^3 */ -l4 = z[28] * cg + z[29] * sg; /* t^4 */ -moonpol[2] += 5.01 * cg + 2.72 * sg; + g = STR * (f - MP); /* 18V - 16E - l */ + cg = cos(g); + sg = sin(g); + l = 6.367278 * cg + 12.747036 * sg; /* t^0 */ + l1 = 23123.70 * cg - 10570.02 * sg; /* t^1 */ + l2 = z[24] * cg + z[25] * sg; /* t^2 */ + l3 = z[26] * cg + z[27] * sg; /* t^3 */ + l4 = z[28] * cg + z[29] * sg; /* t^4 */ + moonpol[2] += 5.01 * cg + 2.72 * sg; -g = STR * (10.*Ve - 3.*Ea - MP); -cg = cos(g); -sg = sin(g); -l += -0.253102 * cg + 0.503359 * sg; -l1 += 1258.46 * cg + 707.29 * sg; -l2 += z[30] * cg + z[31] * sg; -l3 += z[32] * cg + z[33] * sg; -l4 += z[34] * cg + z[35] * sg; + g = STR * (10. * Ve - 3. * Ea - MP); + cg = cos(g); + sg = sin(g); + l += -0.253102 * cg + 0.503359 * sg; + l1 += 1258.46 * cg + 707.29 * sg; + l2 += z[30] * cg + z[31] * sg; + l3 += z[32] * cg + z[33] * sg; + l4 += z[34] * cg + z[35] * sg; -g = STR*(8.*Ve - 13.*Ea); -cg = cos(g); -sg = sin(g); -l += -0.187231 * cg - 0.127481 * sg; -l1 += -319.87 * cg - 18.34 * sg; -l2 += z[36] * cg + z[37] * sg; -l3 += z[38] * cg + z[39] * sg; -l4 += z[40] * cg + z[41] * sg; + g = STR * (8. * Ve - 13. * Ea); + cg = cos(g); + sg = sin(g); + l += -0.187231 * cg - 0.127481 * sg; + l1 += -319.87 * cg - 18.34 * sg; + l2 += z[36] * cg + z[37] * sg; + l3 += z[38] * cg + z[39] * sg; + l4 += z[40] * cg + z[41] * sg; -a = 4.0*Ea - 8.0*Ma + 3.0*Ju; -g = STR * a; -cg = cos(g); -sg = sin(g); -l += -0.866287 * cg + 0.248192 * sg; -l1 += 41.87 * cg + 1053.97 * sg; -l2 += z[42] * cg + z[43] * sg; + a = 4.0 * Ea - 8.0 * Ma + 3.0 * Ju; + g = STR * a; + cg = cos(g); + sg = sin(g); + l += -0.866287 * cg + 0.248192 * sg; + l1 += 41.87 * cg + 1053.97 * sg; + l2 += z[42] * cg + z[43] * sg; -g = STR*(a - MP); -cg = cos(g); -sg = sin(g); -l += -0.165009 * cg + 0.044176 * sg; -l1 += 4.67 * cg + 201.55 * sg; + g = STR * (a - MP); + cg = cos(g); + sg = sin(g); + l += -0.165009 * cg + 0.044176 * sg; + l1 += 4.67 * cg + 201.55 * sg; -g = STR*f; /* 18V - 16E */ -cg = cos(g); -sg = sin(g); -l += 0.330401 * cg + 0.661362 * sg; -l1 += 1202.67 * cg - 555.59 * sg; -l2 += z[44] * cg + z[45] * sg; -l3 += z[46] * cg + z[47] * sg; + g = STR * f; /* 18V - 16E */ + cg = cos(g); + sg = sin(g); + l += 0.330401 * cg + 0.661362 * sg; + l1 += 1202.67 * cg - 555.59 * sg; + l2 += z[44] * cg + z[45] * sg; + l3 += z[46] * cg + z[47] * sg; -g = STR*(f - 2.0*MP ); /* 18V - 16E - 2l */ -cg = cos(g); -sg = sin(g); -l += 0.352185 * cg + 0.705041 * sg; -l1 += 1283.59 * cg - 586.43 * sg; -l2 += z[48] * cg + z[49] * sg; -l3 += z[50] * cg + z[51] * sg; + g = STR * (f - 2.0 * MP); /* 18V - 16E - 2l */ + cg = cos(g); + sg = sin(g); + l += 0.352185 * cg + 0.705041 * sg; + l1 += 1283.59 * cg - 586.43 * sg; + l2 += z[48] * cg + z[49] * sg; + l3 += z[50] * cg + z[51] * sg; -g = STR * (2.0*Ju - 5.0*Sa); -cg = cos(g); -sg = sin(g); -l += -0.034700 * cg + 0.160041 * sg; -l2 += z[52] * cg + z[53] * sg; + g = STR * (2.0 * Ju - 5.0 * Sa); + cg = cos(g); + sg = sin(g); + l += -0.034700 * cg + 0.160041 * sg; + l2 += z[52] * cg + z[53] * sg; -g = STR * (SWELP - NF); -cg = cos(g); -sg = sin(g); -l += 0.000116 * cg + 7.063040 * sg; -l1 += 298.8 * sg; -l2 += z[54] * cg + z[55] * sg; + g = STR * (SWELP - NF); + cg = cos(g); + sg = sin(g); + l += 0.000116 * cg + 7.063040 * sg; + l1 += 298.8 * sg; + l2 += z[54] * cg + z[55] * sg; /* T^3 terms */ -sg = sin( STR * M ); -l3 += z[56] * sg; -l4 += z[57] * sg; + sg = sin(STR * M); + l3 += z[56] * sg; + l4 += z[57] * sg; -g = STR * (2.0*D - M); -sg = sin(g); -cg = cos(g); -l3 += z[58] * sg; -l4 += z[59] * sg; -moonpol[2] += -0.2655 * cg * T; + g = STR * (2.0 * D - M); + sg = sin(g); + cg = cos(g); + l3 += z[58] * sg; + l4 += z[59] * sg; + moonpol[2] += -0.2655 * cg * T; -g = g - STR * MP; -sg = sin(g); -l3 += z[60] * sg; -l4 += z[61] * sg; + g = g - STR * MP; + sg = sin(g); + l3 += z[60] * sg; + l4 += z[61] * sg; -g = STR * (M - MP); -l3 += z[62] * sin( g ); -moonpol[2] += -0.1568 * cos( g ) * T; + g = STR * (M - MP); + l3 += z[62] * sin(g); + moonpol[2] += -0.1568 * cos(g) * T; -g = STR * (M + MP); -l3 += z[63] * sin( g ); -moonpol[2] += 0.1309 * cos( g ) * T; + g = STR * (M + MP); + l3 += z[63] * sin(g); + moonpol[2] += 0.1309 * cos(g) * T; -g = STR * 2.0 * (D - M); -sg = sin(g); -l3 += z[64] * sg; -l4 += z[65] * sg; + g = STR * 2.0 * (D - M); + sg = sin(g); + l3 += z[64] * sg; + l4 += z[65] * sg; -g = STR * 2.0 * M; -sg = sin(g); -l3 += z[66] * sg; -l4 += z[67] * sg; + g = STR * 2.0 * M; + sg = sin(g); + l3 += z[66] * sg; + l4 += z[67] * sg; -g = STR * (2.0*D - MP); -sg = sin(g); -l3 += z[68] * sg; + g = STR * (2.0 * D - MP); + sg = sin(g); + l3 += z[68] * sg; -g = STR * (2.0*(D - M) - MP); -sg = sin(g); -l3 += z[69] * sg; + g = STR * (2.0 * (D - M) - MP); + sg = sin(g); + l3 += z[69] * sg; -g = STR * (2.0*(D + M) - MP); -sg = sin(g); -cg = cos(g); -l3 += z[70] * sg; -moonpol[2] += 0.5568 * cg * T; + g = STR * (2.0 * (D + M) - MP); + sg = sin(g); + cg = cos(g); + l3 += z[70] * sg; + moonpol[2] += 0.5568 * cg * T; -l2 += moonpol[0]; + l2 += moonpol[0]; -g = STR*(2.0*D - M - MP); -moonpol[2] += -0.1910 * cos( g ) * T; + g = STR * (2.0 * D - M - MP); + moonpol[2] += -0.1910 * cos(g) * T; -moonpol[1] *= T; -moonpol[2] *= T; + moonpol[1] *= T; + moonpol[2] *= T; /* terms in T */ -moonpol[0] = 0.0; -chewm( BT, NBT, 4, 4, moonpol ); -chewm( LRT, NLRT, 4, 1, moonpol ); -g = STR*(f - MP - NF - 2355767.6); /* 18V - 16E - l - F */ -moonpol[1] += -1127. * sin(g); -g = STR*(f - MP + NF - 235353.6); /* 18V - 16E - l + F */ -moonpol[1] += -1123. * sin(g); -g = STR*(Ea + D + 51987.6); -moonpol[1] += 1303. * sin(g); -g = STR*SWELP; -moonpol[1] += 342. * sin(g); + moonpol[0] = 0.0; + chewm(BT, NBT, 4, 4, moonpol); + chewm(LRT, NLRT, 4, 1, moonpol); + g = STR * (f - MP - NF - 2355767.6); /* 18V - 16E - l - F */ + moonpol[1] += -1127. * sin(g); + g = STR * (f - MP + NF - 235353.6); /* 18V - 16E - l + F */ + moonpol[1] += -1123. * sin(g); + g = STR * (Ea + D + 51987.6); + moonpol[1] += 1303. * sin(g); + g = STR * SWELP; + moonpol[1] += 342. * sin(g); -g = STR*(2.*Ve - 3.*Ea); -cg = cos(g); -sg = sin(g); -l += -0.343550 * cg - 0.000276 * sg; -l1 += 105.90 * cg + 336.53 * sg; + g = STR * (2. * Ve - 3. * Ea); + cg = cos(g); + sg = sin(g); + l += -0.343550 * cg - 0.000276 * sg; + l1 += 105.90 * cg + 336.53 * sg; -g = STR*(f - 2.*D); /* 18V - 16E - 2D */ -cg = cos(g); -sg = sin(g); -l += 0.074668 * cg + 0.149501 * sg; -l1 += 271.77 * cg - 124.20 * sg; + g = STR * (f - 2. * D); /* 18V - 16E - 2D */ + cg = cos(g); + sg = sin(g); + l += 0.074668 * cg + 0.149501 * sg; + l1 += 271.77 * cg - 124.20 * sg; -g = STR*(f - 2.*D - MP); -cg = cos(g); -sg = sin(g); -l += 0.073444 * cg + 0.147094 * sg; -l1 += 265.24 * cg - 121.16 * sg; + g = STR * (f - 2. * D - MP); + cg = cos(g); + sg = sin(g); + l += 0.073444 * cg + 0.147094 * sg; + l1 += 265.24 * cg - 121.16 * sg; -g = STR*(f + 2.*D - MP); -cg = cos(g); -sg = sin(g); -l += 0.072844 * cg + 0.145829 * sg; -l1 += 265.18 * cg - 121.29 * sg; + g = STR * (f + 2. * D - MP); + cg = cos(g); + sg = sin(g); + l += 0.072844 * cg + 0.145829 * sg; + l1 += 265.18 * cg - 121.29 * sg; -g = STR*(f + 2.*(D - MP)); -cg = cos(g); -sg = sin(g); -l += 0.070201 * cg + 0.140542 * sg; -l1 += 255.36 * cg - 116.79 * sg; + g = STR * (f + 2. * (D - MP)); + cg = cos(g); + sg = sin(g); + l += 0.070201 * cg + 0.140542 * sg; + l1 += 255.36 * cg - 116.79 * sg; -g = STR*(Ea + D - NF); -cg = cos(g); -sg = sin(g); -l += 0.288209 * cg - 0.025901 * sg; -l1 += -63.51 * cg - 240.14 * sg; + g = STR * (Ea + D - NF); + cg = cos(g); + sg = sin(g); + l += 0.288209 * cg - 0.025901 * sg; + l1 += -63.51 * cg - 240.14 * sg; -g = STR*(2.*Ea - 3.*Ju + 2.*D - MP); -cg = cos(g); -sg = sin(g); -l += 0.077865 * cg + 0.438460 * sg; -l1 += 210.57 * cg + 124.84 * sg; + g = STR * (2. * Ea - 3. * Ju + 2. * D - MP); + cg = cos(g); + sg = sin(g); + l += 0.077865 * cg + 0.438460 * sg; + l1 += 210.57 * cg + 124.84 * sg; -g = STR*(Ea - 2.*Ma); -cg = cos(g); -sg = sin(g); -l += -0.216579 * cg + 0.241702 * sg; -l1 += 197.67 * cg + 125.23 * sg; + g = STR * (Ea - 2. * Ma); + cg = cos(g); + sg = sin(g); + l += -0.216579 * cg + 0.241702 * sg; + l1 += 197.67 * cg + 125.23 * sg; -g = STR*(a + MP); -cg = cos(g); -sg = sin(g); -l += -0.165009 * cg + 0.044176 * sg; -l1 += 4.67 * cg + 201.55 * sg; + g = STR * (a + MP); + cg = cos(g); + sg = sin(g); + l += -0.165009 * cg + 0.044176 * sg; + l1 += 4.67 * cg + 201.55 * sg; -g = STR*(a + 2.*D - MP); -cg = cos(g); -sg = sin(g); -l += -0.133533 * cg + 0.041116 * sg; -l1 += 6.95 * cg + 187.07 * sg; + g = STR * (a + 2. * D - MP); + cg = cos(g); + sg = sin(g); + l += -0.133533 * cg + 0.041116 * sg; + l1 += 6.95 * cg + 187.07 * sg; -g = STR*(a - 2.*D + MP); -cg = cos(g); -sg = sin(g); -l += -0.133430 * cg + 0.041079 * sg; -l1 += 6.28 * cg + 169.08 * sg; + g = STR * (a - 2. * D + MP); + cg = cos(g); + sg = sin(g); + l += -0.133430 * cg + 0.041079 * sg; + l1 += 6.28 * cg + 169.08 * sg; -g = STR*(3.*Ve - 4.*Ea); -cg = cos(g); -sg = sin(g); -l += -0.175074 * cg + 0.003035 * sg; -l1 += 49.17 * cg + 150.57 * sg; + g = STR * (3. * Ve - 4. * Ea); + cg = cos(g); + sg = sin(g); + l += -0.175074 * cg + 0.003035 * sg; + l1 += 49.17 * cg + 150.57 * sg; -g = STR*(2.*(Ea + D - MP) - 3.*Ju + 213534.); -l1 += 158.4 * sin(g); -l1 += moonpol[0]; + g = STR * (2. * (Ea + D - MP) - 3. * Ju + 213534.); + l1 += 158.4 * sin(g); + l1 += moonpol[0]; -a = 0.1 * T; /* set amplitude scale of 1.0 = 10^-4 arcsec */ -moonpol[1] *= a; -moonpol[2] *= a; + a = 0.1 * T; /* set amplitude scale of 1.0 = 10^-4 arcsec */ + moonpol[1] *= a; + moonpol[2] *= a; } #else -static void moon1() +static void +moon1() { -double a; + double a; + /* This code added by Bhanu Pinnamaneni, 17-aug-2009 */ + /* Note by Dieter: Bhanu noted that ss and cc are not sufficiently * initialised and random values are used for the calculation. * However, this may be only part of the bug. @@ -1107,277 +1126,287 @@ double a; * the 116th line of NLR, where the value "5" may be wrong. * Still, this will make a maximum difference of only 0.1", while the error * of the Moshier lunar ephemeris can reach 7". */ -int i, j; -for (i = 0; i < 5; i++) { - for (j = 0; j < 8; j++) { - ss[i][j] = 0; - cc[i][j] = 0; - } -} + int i, j; + for (i = 0; i < 5; i++) { + for (j = 0; j < 8; j++) { + ss[i][j] = 0; + cc[i][j] = 0; + } + } + /* End of code addition */ -sscc( 0, STR*D, 6 ); -sscc( 1, STR*M, 4 ); -sscc( 2, STR*MP, 4 ); -sscc( 3, STR*NF, 4 ); -moonpol[0] = 0.0; -moonpol[1] = 0.0; -moonpol[2] = 0.0; + sscc(0, STR * D, 6); + sscc(1, STR * M, 4); + sscc(2, STR * MP, 4); + sscc(3, STR * NF, 4); + moonpol[0] = 0.0; + moonpol[1] = 0.0; + moonpol[2] = 0.0; + /* terms in T^2, scale 1.0 = 10^-5" */ -chewm( LRT2, NLRT2, 4, 2, moonpol ); -chewm( BT2, NBT2, 4, 4, moonpol ); -f = 18 * Ve - 16 * Ea; -g = STR*(f - MP ); /* 18V - 16E - l */ -cg = cos(g); -sg = sin(g); -l = 6.367278 * cg + 12.747036 * sg; /* t^0 */ -l1 = 23123.70 * cg - 10570.02 * sg; /* t^1 */ -l2 = z[12] * cg + z[13] * sg; /* t^2 */ -moonpol[2] += 5.01 * cg + 2.72 * sg; -g = STR * (10.*Ve - 3.*Ea - MP); -cg = cos(g); -sg = sin(g); -l += -0.253102 * cg + 0.503359 * sg; -l1 += 1258.46 * cg + 707.29 * sg; -l2 += z[14] * cg + z[15] * sg; -g = STR*(8.*Ve - 13.*Ea); -cg = cos(g); -sg = sin(g); -l += -0.187231 * cg - 0.127481 * sg; -l1 += -319.87 * cg - 18.34 * sg; -l2 += z[16] * cg + z[17] * sg; -a = 4.0*Ea - 8.0*Ma + 3.0*Ju; -g = STR * a; -cg = cos(g); -sg = sin(g); -l += -0.866287 * cg + 0.248192 * sg; -l1 += 41.87 * cg + 1053.97 * sg; -l2 += z[18] * cg + z[19] * sg; -g = STR*(a - MP); -cg = cos(g); -sg = sin(g); -l += -0.165009 * cg + 0.044176 * sg; -l1 += 4.67 * cg + 201.55 * sg; -g = STR*f; /* 18V - 16E */ -cg = cos(g); -sg = sin(g); -l += 0.330401 * cg + 0.661362 * sg; -l1 += 1202.67 * cg - 555.59 * sg; -l2 += z[20] * cg + z[21] * sg; -g = STR*(f - 2.0*MP ); /* 18V - 16E - 2l */ -cg = cos(g); -sg = sin(g); -l += 0.352185 * cg + 0.705041 * sg; -l1 += 1283.59 * cg - 586.43 * sg; -g = STR * (2.0*Ju - 5.0*Sa); -cg = cos(g); -sg = sin(g); -l += -0.034700 * cg + 0.160041 * sg; -l2 += z[22] * cg + z[23] * sg; -g = STR * (SWELP - NF); -cg = cos(g); -sg = sin(g); -l += 0.000116 * cg + 7.063040 * sg; -l1 += 298.8 * sg; + chewm(LRT2, NLRT2, 4, 2, moonpol); + chewm(BT2, NBT2, 4, 4, moonpol); + f = 18 * Ve - 16 * Ea; + g = STR * (f - MP); /* 18V - 16E - l */ + cg = cos(g); + sg = sin(g); + l = 6.367278 * cg + 12.747036 * sg; /* t^0 */ + l1 = 23123.70 * cg - 10570.02 * sg; /* t^1 */ + l2 = z[12] * cg + z[13] * sg; /* t^2 */ + moonpol[2] += 5.01 * cg + 2.72 * sg; + g = STR * (10. * Ve - 3. * Ea - MP); + cg = cos(g); + sg = sin(g); + l += -0.253102 * cg + 0.503359 * sg; + l1 += 1258.46 * cg + 707.29 * sg; + l2 += z[14] * cg + z[15] * sg; + g = STR * (8. * Ve - 13. * Ea); + cg = cos(g); + sg = sin(g); + l += -0.187231 * cg - 0.127481 * sg; + l1 += -319.87 * cg - 18.34 * sg; + l2 += z[16] * cg + z[17] * sg; + a = 4.0 * Ea - 8.0 * Ma + 3.0 * Ju; + g = STR * a; + cg = cos(g); + sg = sin(g); + l += -0.866287 * cg + 0.248192 * sg; + l1 += 41.87 * cg + 1053.97 * sg; + l2 += z[18] * cg + z[19] * sg; + g = STR * (a - MP); + cg = cos(g); + sg = sin(g); + l += -0.165009 * cg + 0.044176 * sg; + l1 += 4.67 * cg + 201.55 * sg; + g = STR * f; /* 18V - 16E */ + cg = cos(g); + sg = sin(g); + l += 0.330401 * cg + 0.661362 * sg; + l1 += 1202.67 * cg - 555.59 * sg; + l2 += z[20] * cg + z[21] * sg; + g = STR * (f - 2.0 * MP); /* 18V - 16E - 2l */ + cg = cos(g); + sg = sin(g); + l += 0.352185 * cg + 0.705041 * sg; + l1 += 1283.59 * cg - 586.43 * sg; + g = STR * (2.0 * Ju - 5.0 * Sa); + cg = cos(g); + sg = sin(g); + l += -0.034700 * cg + 0.160041 * sg; + l2 += z[22] * cg + z[23] * sg; + g = STR * (SWELP - NF); + cg = cos(g); + sg = sin(g); + l += 0.000116 * cg + 7.063040 * sg; + l1 += 298.8 * sg; + /* T^3 terms */ -sg = sin( STR * M ); + sg = sin(STR * M); + /* l3 += z[24] * sg; moshier! l3 not initialized! */ -l3 = z[24] * sg; -l4 = 0; -g = STR * (2.0*D - M); -sg = sin(g); -cg = cos(g); -moonpol[2] += -0.2655 * cg * T; -g = STR * (M - MP); -moonpol[2] += -0.1568 * cos( g ) * T; -g = STR * (M + MP); -moonpol[2] += 0.1309 * cos( g ) * T; -g = STR * (2.0*(D + M) - MP); -sg = sin(g); -cg = cos(g); -moonpol[2] += 0.5568 * cg * T; -l2 += moonpol[0]; -g = STR*(2.0*D - M - MP); -moonpol[2] += -0.1910 * cos( g ) * T; -moonpol[1] *= T; -moonpol[2] *= T; + l3 = z[24] * sg; + l4 = 0; + g = STR * (2.0 * D - M); + sg = sin(g); + cg = cos(g); + moonpol[2] += -0.2655 * cg * T; + g = STR * (M - MP); + moonpol[2] += -0.1568 * cos(g) * T; + g = STR * (M + MP); + moonpol[2] += 0.1309 * cos(g) * T; + g = STR * (2.0 * (D + M) - MP); + sg = sin(g); + cg = cos(g); + moonpol[2] += 0.5568 * cg * T; + l2 += moonpol[0]; + g = STR * (2.0 * D - M - MP); + moonpol[2] += -0.1910 * cos(g) * T; + moonpol[1] *= T; + moonpol[2] *= T; + /* terms in T */ -moonpol[0] = 0.0; -chewm( BT, NBT, 4, 4, moonpol ); -chewm( LRT, NLRT, 4, 1, moonpol ); -g = STR*(f - MP - NF - 2355767.6); /* 18V - 16E - l - F */ -moonpol[1] += -1127. * sin(g); -g = STR*(f - MP + NF - 235353.6); /* 18V - 16E - l + F */ -moonpol[1] += -1123. * sin(g); -g = STR*(Ea + D + 51987.6); -moonpol[1] += 1303. * sin(g); -g = STR*SWELP; -moonpol[1] += 342. * sin(g); -g = STR*(2.*Ve - 3.*Ea); -cg = cos(g); -sg = sin(g); -l += -0.343550 * cg - 0.000276 * sg; -l1 += 105.90 * cg + 336.53 * sg; -g = STR*(f - 2.*D); /* 18V - 16E - 2D */ -cg = cos(g); -sg = sin(g); -l += 0.074668 * cg + 0.149501 * sg; -l1 += 271.77 * cg - 124.20 * sg; -g = STR*(f - 2.*D - MP); -cg = cos(g); -sg = sin(g); -l += 0.073444 * cg + 0.147094 * sg; -l1 += 265.24 * cg - 121.16 * sg; -g = STR*(f + 2.*D - MP); -cg = cos(g); -sg = sin(g); -l += 0.072844 * cg + 0.145829 * sg; -l1 += 265.18 * cg - 121.29 * sg; -g = STR*(f + 2.*(D - MP)); -cg = cos(g); -sg = sin(g); -l += 0.070201 * cg + 0.140542 * sg; -l1 += 255.36 * cg - 116.79 * sg; -g = STR*(Ea + D - NF); -cg = cos(g); -sg = sin(g); -l += 0.288209 * cg - 0.025901 * sg; -l1 += -63.51 * cg - 240.14 * sg; -g = STR*(2.*Ea - 3.*Ju + 2.*D - MP); -cg = cos(g); -sg = sin(g); -l += 0.077865 * cg + 0.438460 * sg; -l1 += 210.57 * cg + 124.84 * sg; -g = STR*(Ea - 2.*Ma); -cg = cos(g); -sg = sin(g); -l += -0.216579 * cg + 0.241702 * sg; -l1 += 197.67 * cg + 125.23 * sg; -g = STR*(a + MP); -cg = cos(g); -sg = sin(g); -l += -0.165009 * cg + 0.044176 * sg; -l1 += 4.67 * cg + 201.55 * sg; -g = STR*(a + 2.*D - MP); -cg = cos(g); -sg = sin(g); -l += -0.133533 * cg + 0.041116 * sg; -l1 += 6.95 * cg + 187.07 * sg; -g = STR*(a - 2.*D + MP); -cg = cos(g); -sg = sin(g); -l += -0.133430 * cg + 0.041079 * sg; -l1 += 6.28 * cg + 169.08 * sg; -g = STR*(3.*Ve - 4.*Ea); -cg = cos(g); -sg = sin(g); -l += -0.175074 * cg + 0.003035 * sg; -l1 += 49.17 * cg + 150.57 * sg; -g = STR*(2.*(Ea + D - MP) - 3.*Ju + 213534.); -l1 += 158.4 * sin(g); -l1 += moonpol[0]; -a = 0.1 * T; /* set amplitude scale of 1.0 = 10^-4 arcsec */ -moonpol[1] *= a; -moonpol[2] *= a; + moonpol[0] = 0.0; + chewm(BT, NBT, 4, 4, moonpol); + chewm(LRT, NLRT, 4, 1, moonpol); + g = STR * (f - MP - NF - 2355767.6); /* 18V - 16E - l - F */ + moonpol[1] += -1127. * sin(g); + g = STR * (f - MP + NF - 235353.6); /* 18V - 16E - l + F */ + moonpol[1] += -1123. * sin(g); + g = STR * (Ea + D + 51987.6); + moonpol[1] += 1303. * sin(g); + g = STR * SWELP; + moonpol[1] += 342. * sin(g); + g = STR * (2. * Ve - 3. * Ea); + cg = cos(g); + sg = sin(g); + l += -0.343550 * cg - 0.000276 * sg; + l1 += 105.90 * cg + 336.53 * sg; + g = STR * (f - 2. * D); /* 18V - 16E - 2D */ + cg = cos(g); + sg = sin(g); + l += 0.074668 * cg + 0.149501 * sg; + l1 += 271.77 * cg - 124.20 * sg; + g = STR * (f - 2. * D - MP); + cg = cos(g); + sg = sin(g); + l += 0.073444 * cg + 0.147094 * sg; + l1 += 265.24 * cg - 121.16 * sg; + g = STR * (f + 2. * D - MP); + cg = cos(g); + sg = sin(g); + l += 0.072844 * cg + 0.145829 * sg; + l1 += 265.18 * cg - 121.29 * sg; + g = STR * (f + 2. * (D - MP)); + cg = cos(g); + sg = sin(g); + l += 0.070201 * cg + 0.140542 * sg; + l1 += 255.36 * cg - 116.79 * sg; + g = STR * (Ea + D - NF); + cg = cos(g); + sg = sin(g); + l += 0.288209 * cg - 0.025901 * sg; + l1 += -63.51 * cg - 240.14 * sg; + g = STR * (2. * Ea - 3. * Ju + 2. * D - MP); + cg = cos(g); + sg = sin(g); + l += 0.077865 * cg + 0.438460 * sg; + l1 += 210.57 * cg + 124.84 * sg; + g = STR * (Ea - 2. * Ma); + cg = cos(g); + sg = sin(g); + l += -0.216579 * cg + 0.241702 * sg; + l1 += 197.67 * cg + 125.23 * sg; + g = STR * (a + MP); + cg = cos(g); + sg = sin(g); + l += -0.165009 * cg + 0.044176 * sg; + l1 += 4.67 * cg + 201.55 * sg; + g = STR * (a + 2. * D - MP); + cg = cos(g); + sg = sin(g); + l += -0.133533 * cg + 0.041116 * sg; + l1 += 6.95 * cg + 187.07 * sg; + g = STR * (a - 2. * D + MP); + cg = cos(g); + sg = sin(g); + l += -0.133430 * cg + 0.041079 * sg; + l1 += 6.28 * cg + 169.08 * sg; + g = STR * (3. * Ve - 4. * Ea); + cg = cos(g); + sg = sin(g); + l += -0.175074 * cg + 0.003035 * sg; + l1 += 49.17 * cg + 150.57 * sg; + g = STR * (2. * (Ea + D - MP) - 3. * Ju + 213534.); + l1 += 158.4 * sin(g); + l1 += moonpol[0]; + a = 0.1 * T; /* set amplitude scale of 1.0 = 10^-4 arcsec */ + moonpol[1] *= a; + moonpol[2] *= a; } -#endif /* MOSH_MOON_200 */ +#endif /* MOSH_MOON_200 */ -static void moon2() +static void +moon2() { + /* terms in T^0 */ -g = STR*(2*(Ea-Ju+D)-MP+648431.172); -l += 1.14307 * sin(g); -g = STR*(Ve-Ea+648035.568); -l += 0.82155 * sin(g); -g = STR*(3*(Ve-Ea)+2*D-MP+647933.184); -l += 0.64371 * sin(g); -g = STR*(Ea-Ju+4424.04); -l += 0.63880 * sin(g); -g = STR*(SWELP + MP - NF + 4.68); -l += 0.49331 * sin(g); -g = STR*(SWELP - MP - NF + 4.68); -l += 0.4914 * sin(g); -g = STR*(SWELP+NF+2.52); -l += 0.36061 * sin(g); -g = STR*(2.*Ve - 2.*Ea + 736.2); -l += 0.30154 * sin(g); -g = STR*(2.*Ea - 3.*Ju + 2.*D - 2.*MP + 36138.2); -l += 0.28282 * sin(g); -g = STR*(2.*Ea - 2.*Ju + 2.*D - 2.*MP + 311.0); -l += 0.24516 * sin(g); -g = STR*(Ea - Ju - 2.*D + MP + 6275.88); -l += 0.21117 * sin(g); -g = STR*(2.*(Ea - Ma) - 846.36); -l += 0.19444 * sin(g); -g = STR*(2.*(Ea - Ju) + 1569.96); -l -= 0.18457 * sin(g); -g = STR*(2.*(Ea - Ju) - MP - 55.8); -l += 0.18256 * sin(g); -g = STR*(Ea - Ju - 2.*D + 6490.08); -l += 0.16499 * sin(g); -g = STR*(Ea - 2.*Ju - 212378.4); -l += 0.16427 * sin(g); -g = STR*(2.*(Ve - Ea - D) + MP + 1122.48); -l += 0.16088 * sin(g); -g = STR*(Ve - Ea - MP + 32.04); -l -= 0.15350 * sin(g); -g = STR*(Ea - Ju - MP + 4488.88); -l += 0.14346 * sin(g); -g = STR*(2.*(Ve - Ea + D) - MP - 8.64); -l += 0.13594 * sin(g); -g = STR*(2.*(Ve - Ea - D) + 1319.76); -l += 0.13432 * sin(g); -g = STR*(Ve - Ea - 2.*D + MP - 56.16); -l -= 0.13122 * sin(g); -g = STR*(Ve - Ea + MP + 54.36); -l -= 0.12722 * sin(g); -g = STR*(3.*(Ve - Ea) - MP + 433.8); -l += 0.12539 * sin(g); -g = STR*(Ea - Ju + MP + 4002.12); -l += 0.10994 * sin(g); -g = STR*(20.*Ve - 21.*Ea - 2.*D + MP - 317511.72); -l += 0.10652 * sin(g); -g = STR*(26.*Ve - 29.*Ea - MP + 270002.52); -l += 0.10490 * sin(g); -g = STR*(3.*Ve - 4.*Ea + D - MP - 322765.56); -l += 0.10386 * sin(g); -g = STR*(SWELP+648002.556); -B = 8.04508 * sin(g); -g = STR*(Ea+D+996048.252); -B += 1.51021 * sin(g); -g = STR*(f - MP + NF + 95554.332); -B += 0.63037 * sin(g); -g = STR*(f - MP - NF + 95553.792); -B += 0.63014 * sin(g); -g = STR*(SWELP - MP + 2.9); -B += 0.45587 * sin(g); -g = STR*(SWELP + MP + 2.5); -B += -0.41573 * sin(g); -g = STR*(SWELP - 2.0*NF + 3.2); -B += 0.32623 * sin(g); -g = STR*(SWELP - 2.0*D + 2.5); -B += 0.29855 * sin(g); + g = STR * (2 * (Ea - Ju + D) - MP + 648431.172); + l += 1.14307 * sin(g); + g = STR * (Ve - Ea + 648035.568); + l += 0.82155 * sin(g); + g = STR * (3 * (Ve - Ea) + 2 * D - MP + 647933.184); + l += 0.64371 * sin(g); + g = STR * (Ea - Ju + 4424.04); + l += 0.63880 * sin(g); + g = STR * (SWELP + MP - NF + 4.68); + l += 0.49331 * sin(g); + g = STR * (SWELP - MP - NF + 4.68); + l += 0.4914 * sin(g); + g = STR * (SWELP + NF + 2.52); + l += 0.36061 * sin(g); + g = STR * (2. * Ve - 2. * Ea + 736.2); + l += 0.30154 * sin(g); + g = STR * (2. * Ea - 3. * Ju + 2. * D - 2. * MP + 36138.2); + l += 0.28282 * sin(g); + g = STR * (2. * Ea - 2. * Ju + 2. * D - 2. * MP + 311.0); + l += 0.24516 * sin(g); + g = STR * (Ea - Ju - 2. * D + MP + 6275.88); + l += 0.21117 * sin(g); + g = STR * (2. * (Ea - Ma) - 846.36); + l += 0.19444 * sin(g); + g = STR * (2. * (Ea - Ju) + 1569.96); + l -= 0.18457 * sin(g); + g = STR * (2. * (Ea - Ju) - MP - 55.8); + l += 0.18256 * sin(g); + g = STR * (Ea - Ju - 2. * D + 6490.08); + l += 0.16499 * sin(g); + g = STR * (Ea - 2. * Ju - 212378.4); + l += 0.16427 * sin(g); + g = STR * (2. * (Ve - Ea - D) + MP + 1122.48); + l += 0.16088 * sin(g); + g = STR * (Ve - Ea - MP + 32.04); + l -= 0.15350 * sin(g); + g = STR * (Ea - Ju - MP + 4488.88); + l += 0.14346 * sin(g); + g = STR * (2. * (Ve - Ea + D) - MP - 8.64); + l += 0.13594 * sin(g); + g = STR * (2. * (Ve - Ea - D) + 1319.76); + l += 0.13432 * sin(g); + g = STR * (Ve - Ea - 2. * D + MP - 56.16); + l -= 0.13122 * sin(g); + g = STR * (Ve - Ea + MP + 54.36); + l -= 0.12722 * sin(g); + g = STR * (3. * (Ve - Ea) - MP + 433.8); + l += 0.12539 * sin(g); + g = STR * (Ea - Ju + MP + 4002.12); + l += 0.10994 * sin(g); + g = STR * (20. * Ve - 21. * Ea - 2. * D + MP - 317511.72); + l += 0.10652 * sin(g); + g = STR * (26. * Ve - 29. * Ea - MP + 270002.52); + l += 0.10490 * sin(g); + g = STR * (3. * Ve - 4. * Ea + D - MP - 322765.56); + l += 0.10386 * sin(g); + g = STR * (SWELP + 648002.556); + B = 8.04508 * sin(g); + g = STR * (Ea + D + 996048.252); + B += 1.51021 * sin(g); + g = STR * (f - MP + NF + 95554.332); + B += 0.63037 * sin(g); + g = STR * (f - MP - NF + 95553.792); + B += 0.63014 * sin(g); + g = STR * (SWELP - MP + 2.9); + B += 0.45587 * sin(g); + g = STR * (SWELP + MP + 2.5); + B += -0.41573 * sin(g); + g = STR * (SWELP - 2.0 * NF + 3.2); + B += 0.32623 * sin(g); + g = STR * (SWELP - 2.0 * D + 2.5); + B += 0.29855 * sin(g); } -static void moon3() +static void +moon3() { + /* terms in T^0 */ -moonpol[0] = 0.0; -chewm( LR, NLR, 4, 1, moonpol ); -chewm( MB, NMB, 4, 3, moonpol ); -l += (((l4 * T + l3) * T + l2) * T + l1) * T * 1.0e-5; -moonpol[0] = SWELP + l + 1.0e-4 * moonpol[0]; -moonpol[1] = 1.0e-4 * moonpol[1] + B; -moonpol[2] = 1.0e-4 * moonpol[2] + 385000.52899; /* kilometers */ + moonpol[0] = 0.0; + chewm(LR, NLR, 4, 1, moonpol); + chewm(MB, NMB, 4, 3, moonpol); + l += (((l4 * T + l3) * T + l2) * T + l1) * T * 1.0e-5; + moonpol[0] = SWELP + l + 1.0e-4 * moonpol[0]; + moonpol[1] = 1.0e-4 * moonpol[1] + B; + moonpol[2] = 1.0e-4 * moonpol[2] + 385000.52899; /* kilometers */ } /* Compute final ecliptic polar coordinates */ -static void moon4() +static void +moon4() { -moonpol[2] /= AUNIT / 1000; -moonpol[0] = STR * mods3600( moonpol[0] ); -moonpol[1] = STR * moonpol[1]; -B = moonpol[1]; + moonpol[2] /= AUNIT / 1000; + moonpol[0] = STR * mods3600(moonpol[0]); + moonpol[1] = STR * moonpol[1]; + B = moonpol[1]; } /* mean lunar node @@ -1385,45 +1414,47 @@ B = moonpol[1]; * pol return array for position and velocity * (polar coordinates of ecliptic of date) */ -int swi_mean_node(double J, double *pol, char *serr) +int +swi_mean_node(double J, double *pol, char *serr) { #if 0 - double a, b, c; + double a, b, c; #endif - char s[AS_MAXCH]; - T = (J-J2000)/36525.0; - T2 = T*T; - T3 = T*T2; - T4 = T2*T2; - /* with elements from swi_moshmoon2(), which are fitted to jpl-ephemeris */ - if (J < MOSHNDEPH_START || J > MOSHNDEPH_END) { - if (serr != NULL) { - sprintf(s, "jd %f outside mean node range %.2f .. %.2f ", - J, MOSHNDEPH_START, MOSHNDEPH_END); - if (strlen(serr) + strlen(s) < AS_MAXCH) - strcat(serr, s); + char s[AS_MAXCH]; + T = (J - J2000) / 36525.0; + T2 = T * T; + T3 = T * T2; + T4 = T2 * T2; + /* with elements from swi_moshmoon2(), which are fitted to jpl-ephemeris */ + if (J < MOSHNDEPH_START || J > MOSHNDEPH_END) { + if (serr != NULL) { + sprintf(s, "jd %f outside mean node range %.2f .. %.2f ", J, + MOSHNDEPH_START, MOSHNDEPH_END); + if (strlen(serr) + strlen(s) < AS_MAXCH) + strcat(serr, s); + } + return ERR; } - return ERR; - } - mean_elements(); - /* longitude */ - pol[0] = swi_mod2PI((SWELP - NF) * STR); - /* latitude */ - pol[1] = 0.0; - /* distance */ - pol[2] = MOON_MEAN_DIST / AUNIT; /* or should it be derived from mean - * orbital ellipse? */ + mean_elements(); + /* longitude */ + pol[0] = swi_mod2PI((SWELP - NF) * STR); + /* latitude */ + pol[1] = 0.0; + /* distance */ + pol[2] = MOON_MEAN_DIST / AUNIT; /* or should it be derived from mean + * orbital ellipse? */ #if 0 - a = pol[0]; - /* Chapront, according to Meeus, German, p. 339 */ - pol[0] = 125.0445550 - 1934.1361849 * T + 0.0020762 * T2 + - T3 / 467410 - T4 / 60616000; - pol[0] = swi_mod2PI(pol[0] * DEGTORAD); - c = pol[0]; - printf ("mean node\n"); - printf ("moshier de404 - chapront %f\"\n", (a-c) * RADTODEG * 3600); + a = pol[0]; + /* Chapront, according to Meeus, German, p. 339 */ + pol[0] = + 125.0445550 - 1934.1361849 * T + 0.0020762 * T2 + T3 / 467410 - + T4 / 60616000; + pol[0] = swi_mod2PI(pol[0] * DEGTORAD); + c = pol[0]; + printf("mean node\n"); + printf("moshier de404 - chapront %f\"\n", (a - c) * RADTODEG * 3600); #endif - return OK; + return OK; } /* mean lunar apogee ('dark moon', 'lilith') @@ -1432,185 +1463,192 @@ int swi_mean_node(double J, double *pol, char *serr) * (polar coordinates of ecliptic of date) * serr error return string */ -int swi_mean_apog(double J, double *pol, char *serr) +int +swi_mean_apog(double J, double *pol, char *serr) { #if 0 - int i; - double a, b; - double x[3]; + int i; + double a, b; + double x[3]; #endif - double node; - char s[AS_MAXCH]; - T = (J-J2000)/36525.0; - T2 = T*T; - T3 = T*T2; - T4 = T2*T2; - /* with elements from swi_moshmoon2(), which are fitted to jpl-ephemeris */ - if (J < MOSHNDEPH_START || J > MOSHNDEPH_END) { - if (serr != NULL) { - sprintf(s, "jd %f outside mean apogee range %.2f .. %.2f ", - J, MOSHNDEPH_START, MOSHNDEPH_END); - if (strlen(serr) + strlen(s) < AS_MAXCH) - strcat(serr, s); + double node; + char s[AS_MAXCH]; + T = (J - J2000) / 36525.0; + T2 = T * T; + T3 = T * T2; + T4 = T2 * T2; + /* with elements from swi_moshmoon2(), which are fitted to jpl-ephemeris */ + if (J < MOSHNDEPH_START || J > MOSHNDEPH_END) { + if (serr != NULL) { + sprintf(s, "jd %f outside mean apogee range %.2f .. %.2f ", J, + MOSHNDEPH_START, MOSHNDEPH_END); + if (strlen(serr) + strlen(s) < AS_MAXCH) + strcat(serr, s); + } + return (ERR); } - return(ERR); - } - mean_elements(); - pol[0] = swi_mod2PI((SWELP - MP) * STR + PI); + mean_elements(); + pol[0] = swi_mod2PI((SWELP - MP) * STR + PI); #if 0 - a = pol[0]; - /* Chapront, according to Meeus, German, p. 339 */ - pol[0] = 83.3532430 + 4069.0137111 * T - 0.0103238 * T2 - - T3 / 80053 + T4 / 18999000; - pol[0] = swi_mod2PI(pol[0] * DEGTORAD + PI); - b = pol[0]; - printf ("mean apogee\n"); - printf ("moshier de404 - chapront %f\"\n", (a-b) * RADTODEG * 3600); + a = pol[0]; + /* Chapront, according to Meeus, German, p. 339 */ + pol[0] = + 83.3532430 + 4069.0137111 * T - 0.0103238 * T2 - T3 / 80053 + + T4 / 18999000; + pol[0] = swi_mod2PI(pol[0] * DEGTORAD + PI); + b = pol[0]; + printf("mean apogee\n"); + printf("moshier de404 - chapront %f\"\n", (a - b) * RADTODEG * 3600); #endif - pol[1] = 0; - pol[2] = MOON_MEAN_DIST * (1 + MOON_MEAN_ECC) / AUNIT; /* apogee */ + pol[1] = 0; + pol[2] = MOON_MEAN_DIST * (1 + MOON_MEAN_ECC) / AUNIT; /* apogee */ #if 0 - pol[2] = 2 * MOON_MEAN_ECC * MOON_MEAN_DIST / AUNIT; /* 2nd focus */ + pol[2] = 2 * MOON_MEAN_ECC * MOON_MEAN_DIST / AUNIT; /* 2nd focus */ #endif - /* Lilith or Dark Moon is either the empty focal point of the mean - * lunar ellipse or, for some people, its apogee ("aphelion"). - * This is 180 degrees from the perigee. - * - * Since the lunar orbit is not in the ecliptic, the apogee must be - * projected onto the ecliptic. - * Joelle de Gravelaine has in her book "Lilith der schwarze Mond" - * (Astrodata, 1990) an ephemeris which gives noon (12.00) positions - * but does not project them onto the ecliptic. - * This results in a mistake of several arc minutes. - * - * There is also another problem. The other focal point doesn't - * coincide with the geocenter but with the barycenter of the - * earth-moon-system. The difference is about 4700 km. If one - * took this into account, it would result in an oscillation - * of the Black Moon. If defined as the apogee, this oscillation - * would be about +/- 40 arcmin. - * If defined as the second focus, the effect is very large: - * +/- 6 deg! - * We neglect this influence. - */ - /* apogee is now projected onto ecliptic */ - node = (SWELP - NF) * STR; - pol[0] = swi_mod2PI(pol[0] - node); - swi_polcart(pol, pol); - swi_coortrf(pol, pol, -MOON_MEAN_INCL * DEGTORAD); - swi_cartpol(pol, pol); - pol[0] = swi_mod2PI(pol[0] + node); + /* Lilith or Dark Moon is either the empty focal point of the mean + * lunar ellipse or, for some people, its apogee ("aphelion"). + * This is 180 degrees from the perigee. + * + * Since the lunar orbit is not in the ecliptic, the apogee must be + * projected onto the ecliptic. + * Joelle de Gravelaine has in her book "Lilith der schwarze Mond" + * (Astrodata, 1990) an ephemeris which gives noon (12.00) positions + * but does not project them onto the ecliptic. + * This results in a mistake of several arc minutes. + * + * There is also another problem. The other focal point doesn't + * coincide with the geocenter but with the barycenter of the + * earth-moon-system. The difference is about 4700 km. If one + * took this into account, it would result in an oscillation + * of the Black Moon. If defined as the apogee, this oscillation + * would be about +/- 40 arcmin. + * If defined as the second focus, the effect is very large: + * +/- 6 deg! + * We neglect this influence. + */ + /* apogee is now projected onto ecliptic */ + node = (SWELP - NF) * STR; + pol[0] = swi_mod2PI(pol[0] - node); + swi_polcart(pol, pol); + swi_coortrf(pol, pol, -MOON_MEAN_INCL * DEGTORAD); + swi_cartpol(pol, pol); + pol[0] = swi_mod2PI(pol[0] + node); #if 0 - /* speed */ - mean_elements(T-PLAN_SPEED_INTV, &SWELP, &MP, &NF, &M, &D); - pol[3] = swi_mod2PI((SWELP - MP) * STR + PI); - pol[4] = 0; - pol[5] = MOON_MEAN_DIST * (1 + MOON_MEAN_ECC) / AUNIT; /* apogee */ + /* speed */ + mean_elements(T - PLAN_SPEED_INTV, &SWELP, &MP, &NF, &M, &D); + pol[3] = swi_mod2PI((SWELP - MP) * STR + PI); + pol[4] = 0; + pol[5] = MOON_MEAN_DIST * (1 + MOON_MEAN_ECC) / AUNIT; /* apogee */ #if 0 - pol[2] = 2 * MOON_MEAN_ECC * MOON_MEAN_DIST / AUNIT; /* 2nd focus */ + pol[2] = 2 * MOON_MEAN_ECC * MOON_MEAN_DIST / AUNIT; /* 2nd focus */ #endif - node = (SWELP - NF) * STR; - pol[3] = swi_mod2PI(pol[3] - node); - swi_polcart(pol+3, pol+3); - swi_coortrf(pol+3, pol+3, -MOON_MEAN_INCL * DEGTORAD); - swi_cartpol(pol+3, pol+3); - pol[3] = swi_mod2PI(pol[3] + node); - for (i = 0; i <= 2; i++) - pol[3+i] = pol[i] - pol[3+i]; - pol[3] = swi_mod2PI(pol[3]); + node = (SWELP - NF) * STR; + pol[3] = swi_mod2PI(pol[3] - node); + swi_polcart(pol + 3, pol + 3); + swi_coortrf(pol + 3, pol + 3, -MOON_MEAN_INCL * DEGTORAD); + swi_cartpol(pol + 3, pol + 3); + pol[3] = swi_mod2PI(pol[3] + node); + for (i = 0; i <= 2; i++) + pol[3 + i] = pol[i] - pol[3 + i]; + pol[3] = swi_mod2PI(pol[3]); #endif - return OK; + return OK; } /* Program to step through the perturbation table */ -static void chewm(short *pt, int nlines, int nangles, int typflg, double *ans ) +static void +chewm(short *pt, int nlines, int nangles, int typflg, double *ans) { - int i, j, k, k1, m; - double cu, su, cv, sv, ff; - for( i=0; i 0 */ - /* sin, cos (k*angle) from lookup table */ - su = ss[m][k-1]; - cu = cc[m][k-1]; - if( j < 0 ) su = -su; /* negative angle factor */ - if( k1 == 0 ) { - /* Set sin, cos of first angle. */ - sv = su; - cv = cu; - k1 = 1; - } - else { - /* Combine angles by trigonometry. */ - ff = su*cv + cu*sv; - cv = cu*cv - su*sv; - sv = ff; - } - } + int i, j, k, k1, m; + double cu, su, cv, sv, ff; + for (i = 0; i < nlines; i++) { + k1 = 0; + sv = 0.0; + cv = 0.0; + for (m = 0; m < nangles; m++) { + j = *pt++; /* multiple angle factor */ + if (j) { + k = j; + if (j < 0) + k = -k; /* make angle factor > 0 */ + /* sin, cos (k*angle) from lookup table */ + su = ss[m][k - 1]; + cu = cc[m][k - 1]; + if (j < 0) + su = -su; /* negative angle factor */ + if (k1 == 0) { + /* Set sin, cos of first angle. */ + sv = su; + cv = cu; + k1 = 1; + } + else { + /* Combine angles by trigonometry. */ + ff = su * cv + cu * sv; + cv = cu * cv - su * sv; + sv = ff; + } + } + } + /* Accumulate + */ + switch (typflg) { + /* large longitude and radius */ + case 1: + j = *pt++; + k = *pt++; + ans[0] += (10000.0 * j + k) * sv; + j = *pt++; + k = *pt++; + if (k) + ans[2] += (10000.0 * j + k) * cv; + break; + /* longitude and radius */ + case 2: + j = *pt++; + k = *pt++; + ans[0] += j * sv; + ans[2] += k * cv; + break; + /* large latitude */ + case 3: + j = *pt++; + k = *pt++; + ans[1] += (10000.0 * j + k) * sv; + break; + /* latitude */ + case 4: + j = *pt++; + ans[1] += j * sv; + break; + } } - /* Accumulate - */ - switch( typflg ) { - /* large longitude and radius */ - case 1: - j = *pt++; - k = *pt++; - ans[0] += (10000.0 * j + k) * sv; - j = *pt++; - k = *pt++; - if( k ) ans[2] += (10000.0 * j + k) * cv; - break; - /* longitude and radius */ - case 2: - j = *pt++; - k = *pt++; - ans[0] += j * sv; - ans[2] += k * cv; - break; - /* large latitude */ - case 3: - j = *pt++; - k = *pt++; - ans[1] += ( 10000.0*j + k)*sv; - break; - /* latitude */ - case 4: - j = *pt++; - ans[1] += j * sv; - break; - } - } } /* Prepare lookup table of sin and cos ( i*Lj ) * for required multiple angles */ -static void sscc(int k, double arg, int n ) +static void +sscc(int k, double arg, int n) { - double cu, su, cv, sv, s; - int i; - su = sin(arg); - cu = cos(arg); - ss[k][0] = su; /* sin(L) */ - cc[k][0] = cu; /* cos(L) */ - sv = 2.0*su*cu; - cv = cu*cu - su*su; - ss[k][1] = sv; /* sin(2L) */ - cc[k][1] = cv; - for( i=2; imax_harmonic[i]) > 0) - { - sr = (mods3600 (freqs[i] * T) + phases[i]) * STR; - sscc (i, sr, j); - } + T = (J - J2000) / TIMESCALE; + /* Calculate sin( i*MM ), etc. for needed multiple angles. */ + for (i = 0; i < 9; i++) { + if ((j = plan->max_harmonic[i]) > 0) { + sr = (mods3600(freqs[i] * T) + phases[i]) * STR; + sscc(i, sr, j); + } } - /* Point to start of table of arguments. */ - p = plan->arg_tbl; - /* Point to tabulated cosine and sine amplitudes. */ - pl = plan->lon_tbl; - pb = plan->lat_tbl; - pr = plan->rad_tbl; - sl = 0.0; - sb = 0.0; - sr = 0.0; + /* Point to start of table of arguments. */ + p = plan->arg_tbl; + /* Point to tabulated cosine and sine amplitudes. */ + pl = plan->lon_tbl; + pb = plan->lat_tbl; + pr = plan->rad_tbl; + sl = 0.0; + sb = 0.0; + sr = 0.0; - for (;;) - { - /* argument of sine and cosine */ - /* Number of periodic arguments. */ - np = *p++; - if (np < 0) - break; - if (np == 0) - { /* It is a polynomial term. */ - nt = *p++; - /* Longitude polynomial. */ - cu = *pl++; - for (ip = 0; ip < nt; ip++) - { - cu = cu * T + *pl++; - } - sl += mods3600 (cu); - /* Latitude polynomial. */ - cu = *pb++; - for (ip = 0; ip < nt; ip++) - { - cu = cu * T + *pb++; - } - sb += cu; - /* Radius polynomial. */ - cu = *pr++; - for (ip = 0; ip < nt; ip++) - { - cu = cu * T + *pr++; - } - sr += cu; - continue; - } - k1 = 0; - cv = 0.0; - sv = 0.0; - for (ip = 0; ip < np; ip++) - { - /* What harmonic. */ - j = *p++; - /* Which planet. */ - m = *p++ - 1; - if (j) - { - k = j; - if (j < 0) - k = -k; - k -= 1; - su = ss[m][k]; /* sin(k*angle) */ - if (j < 0) - su = -su; - cu = cc[m][k]; - if (k1 == 0) - { /* set first angle */ - sv = su; - cv = cu; - k1 = 1; - } - else - { /* combine angles */ - t = su * cv + cu * sv; - cv = cu * cv - su * sv; - sv = t; - } - } - } - /* Highest power of T. */ - nt = *p++; - /* Longitude. */ - cu = *pl++; - su = *pl++; - for (ip = 0; ip < nt; ip++) - { - cu = cu * T + *pl++; - su = su * T + *pl++; - } - sl += cu * cv + su * sv; - /* Latitiude. */ - cu = *pb++; - su = *pb++; - for (ip = 0; ip < nt; ip++) - { - cu = cu * T + *pb++; - su = su * T + *pb++; - } - sb += cu * cv + su * sv; - /* Radius. */ - cu = *pr++; - su = *pr++; - for (ip = 0; ip < nt; ip++) - { - cu = cu * T + *pr++; - su = su * T + *pr++; - } - sr += cu * cv + su * sv; + for (;;) { + /* argument of sine and cosine */ + /* Number of periodic arguments. */ + np = *p++; + if (np < 0) + break; + if (np == 0) { /* It is a polynomial term. */ + nt = *p++; + /* Longitude polynomial. */ + cu = *pl++; + for (ip = 0; ip < nt; ip++) { + cu = cu * T + *pl++; + } + sl += mods3600(cu); + /* Latitude polynomial. */ + cu = *pb++; + for (ip = 0; ip < nt; ip++) { + cu = cu * T + *pb++; + } + sb += cu; + /* Radius polynomial. */ + cu = *pr++; + for (ip = 0; ip < nt; ip++) { + cu = cu * T + *pr++; + } + sr += cu; + continue; + } + k1 = 0; + cv = 0.0; + sv = 0.0; + for (ip = 0; ip < np; ip++) { + /* What harmonic. */ + j = *p++; + /* Which planet. */ + m = *p++ - 1; + if (j) { + k = j; + if (j < 0) + k = -k; + k -= 1; + su = ss[m][k]; /* sin(k*angle) */ + if (j < 0) + su = -su; + cu = cc[m][k]; + if (k1 == 0) { /* set first angle */ + sv = su; + cv = cu; + k1 = 1; + } + else { /* combine angles */ + t = su * cv + cu * sv; + cv = cu * cv - su * sv; + sv = t; + } + } + } + /* Highest power of T. */ + nt = *p++; + /* Longitude. */ + cu = *pl++; + su = *pl++; + for (ip = 0; ip < nt; ip++) { + cu = cu * T + *pl++; + su = su * T + *pl++; + } + sl += cu * cv + su * sv; + /* Latitiude. */ + cu = *pb++; + su = *pb++; + for (ip = 0; ip < nt; ip++) { + cu = cu * T + *pb++; + su = su * T + *pb++; + } + sb += cu * cv + su * sv; + /* Radius. */ + cu = *pr++; + su = *pr++; + for (ip = 0; ip < nt; ip++) { + cu = cu * T + *pr++; + su = su * T + *pr++; + } + sr += cu * cv + su * sv; } - pobj[0] = STR * sl; - pobj[1] = STR * sb; - pobj[2] = STR * plan->distance * sr + plan->distance; - return OK; + pobj[0] = STR * sl; + pobj[1] = STR * sb; + pobj[2] = STR * plan->distance * sr + plan->distance; + return OK; } /* Moshier ephemeris. @@ -274,137 +263,142 @@ int swi_moshplan2 (double J, int iplm, double *pobj) * xe earth's * serr error string */ -int swi_moshplan(double tjd, int ipli, AS_BOOL do_save, double *xpret, double *xeret, char *serr) +int +swi_moshplan(double tjd, int ipli, AS_BOOL do_save, double *xpret, + double *xeret, char *serr) { - int i; - int do_earth = FALSE; - double dx[3], x2[3], xxe[6], xxp[6]; - double *xp, *xe; - double dt; - char s[AS_MAXCH]; - int iplm = pnoint2msh[ipli]; - struct plan_data *pdp = &swed.pldat[ipli]; - struct plan_data *pedp = &swed.pldat[SEI_EARTH]; - double seps2000 = swed.oec2000.seps; - double ceps2000 = swed.oec2000.ceps; - if (do_save) { - xp = pdp->x; - xe = pedp->x; - } else { - xp = xxp; - xe = xxe; - } - if (do_save || ipli == SEI_EARTH || xeret != NULL) - do_earth = TRUE; - /* tjd beyond ephemeris limits, give some margin for spped at edge */ - if (tjd < MOSHPLEPH_START - 0.3 || tjd > MOSHPLEPH_END + 0.3) { - if (serr != NULL) { - sprintf(s, "jd %f outside Moshier planet range %.2f .. %.2f ", - tjd, MOSHPLEPH_START, MOSHPLEPH_END); - if (strlen(serr) + strlen(s) < AS_MAXCH) - strcat(serr, s); + int i; + int do_earth = FALSE; + double dx[3], x2[3], xxe[6], xxp[6]; + double *xp, *xe; + double dt; + char s[AS_MAXCH]; + int iplm = pnoint2msh[ipli]; + struct plan_data *pdp = &swed.pldat[ipli]; + struct plan_data *pedp = &swed.pldat[SEI_EARTH]; + double seps2000 = swed.oec2000.seps; + double ceps2000 = swed.oec2000.ceps; + if (do_save) { + xp = pdp->x; + xe = pedp->x; } - return(ERR); - } - /* earth, for geocentric position */ - if (do_earth) { - if (tjd == pedp->teval - && pedp->iephe == SEFLG_MOSEPH) { - xe = pedp->x; - } else { - /* emb */ - swi_moshplan2(tjd, pnoint2msh[SEI_EMB], xe); /* emb hel. ecl. 2000 polar */ - swi_polcart(xe, xe); /* to cartesian */ - swi_coortrf2(xe, xe, -seps2000, ceps2000);/* and equator 2000 */ - embofs_mosh(tjd, xe); /* emb -> earth */ - if (do_save) { - pedp->teval = tjd; - pedp->xflgs = -1; - pedp->iephe = SEFLG_MOSEPH; - } - /* one more position for speed. */ - swi_moshplan2(tjd - PLAN_SPEED_INTV, pnoint2msh[SEI_EMB], x2); - swi_polcart(x2, x2); - swi_coortrf2(x2, x2, -seps2000, ceps2000); - embofs_mosh(tjd - PLAN_SPEED_INTV, x2);/**/ - for (i = 0; i <= 2; i++) - dx[i] = (xe[i] - x2[i]) / PLAN_SPEED_INTV; - /* store speed */ - for (i = 0; i <= 2; i++) { - xe[i+3] = dx[i]; - } + else { + xp = xxp; + xe = xxe; } - if (xeret != NULL) - for (i = 0; i <= 5; i++) - xeret[i] = xe[i]; - } - /* earth is the planet wanted */ - if (ipli == SEI_EARTH) { - xp = xe; - } else { - /* other planet */ - /* if planet has already been computed, return */ - if (tjd == pdp->teval && pdp->iephe == SEFLG_MOSEPH) { - xp = pdp->x; - } else { - swi_moshplan2(tjd, iplm, xp); - swi_polcart(xp, xp); - swi_coortrf2(xp, xp, -seps2000, ceps2000); - if (do_save) { - pdp->teval = tjd;/**/ - pdp->xflgs = -1; - pdp->iephe = SEFLG_MOSEPH; - } - /* one more position for speed. - * the following dt gives good speed for light-time correction - */ - #if 0 - for (i = 0; i <= 2; i++) - dx[i] = xp[i] - pedp->x[i]; - dt = LIGHTTIME_AUNIT * sqrt(square_sum(dx)); - #endif - dt = PLAN_SPEED_INTV; - swi_moshplan2(tjd - dt, iplm, x2); - swi_polcart(x2, x2); - swi_coortrf2(x2, x2, -seps2000, ceps2000); - for (i = 0; i <= 2; i++) - dx[i] = (xp[i] - x2[i]) / dt; - /* store speed */ - for (i = 0; i <= 2; i++) { - xp[i+3] = dx[i]; - } + if (do_save || ipli == SEI_EARTH || xeret != NULL) + do_earth = TRUE; + /* tjd beyond ephemeris limits, give some margin for spped at edge */ + if (tjd < MOSHPLEPH_START - 0.3 || tjd > MOSHPLEPH_END + 0.3) { + if (serr != NULL) { + sprintf(s, "jd %f outside Moshier planet range %.2f .. %.2f ", + tjd, MOSHPLEPH_START, MOSHPLEPH_END); + if (strlen(serr) + strlen(s) < AS_MAXCH) + strcat(serr, s); + } + return (ERR); } - if (xpret != NULL) - for (i = 0; i <= 5; i++) - xpret[i] = xp[i]; - } - return(OK); + /* earth, for geocentric position */ + if (do_earth) { + if (tjd == pedp->teval && pedp->iephe == SEFLG_MOSEPH) { + xe = pedp->x; + } + else { + /* emb */ + swi_moshplan2(tjd, pnoint2msh[SEI_EMB], xe); /* emb hel. ecl. 2000 polar */ + swi_polcart(xe, xe); /* to cartesian */ + swi_coortrf2(xe, xe, -seps2000, ceps2000); /* and equator 2000 */ + embofs_mosh(tjd, xe); /* emb -> earth */ + if (do_save) { + pedp->teval = tjd; + pedp->xflgs = -1; + pedp->iephe = SEFLG_MOSEPH; + } + /* one more position for speed. */ + swi_moshplan2(tjd - PLAN_SPEED_INTV, pnoint2msh[SEI_EMB], x2); + swi_polcart(x2, x2); + swi_coortrf2(x2, x2, -seps2000, ceps2000); + embofs_mosh(tjd - PLAN_SPEED_INTV, x2); + /**/ for (i = 0; i <= 2; i++) + dx[i] = (xe[i] - x2[i]) / PLAN_SPEED_INTV; + /* store speed */ + for (i = 0; i <= 2; i++) { + xe[i + 3] = dx[i]; + } + } + if (xeret != NULL) + for (i = 0; i <= 5; i++) + xeret[i] = xe[i]; + } + /* earth is the planet wanted */ + if (ipli == SEI_EARTH) { + xp = xe; + } + else { + /* other planet */ + /* if planet has already been computed, return */ + if (tjd == pdp->teval && pdp->iephe == SEFLG_MOSEPH) { + xp = pdp->x; + } + else { + swi_moshplan2(tjd, iplm, xp); + swi_polcart(xp, xp); + swi_coortrf2(xp, xp, -seps2000, ceps2000); + if (do_save) { + pdp->teval = tjd; + /**/ pdp->xflgs = -1; + pdp->iephe = SEFLG_MOSEPH; + } + /* one more position for speed. + * the following dt gives good speed for light-time correction + */ +#if 0 + for (i = 0; i <= 2; i++) + dx[i] = xp[i] - pedp->x[i]; + dt = LIGHTTIME_AUNIT * sqrt(square_sum(dx)); +#endif + dt = PLAN_SPEED_INTV; + swi_moshplan2(tjd - dt, iplm, x2); + swi_polcart(x2, x2); + swi_coortrf2(x2, x2, -seps2000, ceps2000); + for (i = 0; i <= 2; i++) + dx[i] = (xp[i] - x2[i]) / dt; + /* store speed */ + for (i = 0; i <= 2; i++) { + xp[i + 3] = dx[i]; + } + } + if (xpret != NULL) + for (i = 0; i <= 5; i++) + xpret[i] = xp[i]; + } + return (OK); } /* Prepare lookup table of sin and cos ( i*Lj ) * for required multiple angles */ -static void sscc (int k, double arg, int n) +static void +sscc(int k, double arg, int n) { - double cu, su, cv, sv, s; - int i; + double cu, su, cv, sv, s; + int i; - su = sin (arg); - cu = cos (arg); - ss[k][0] = su; /* sin(L) */ - cc[k][0] = cu; /* cos(L) */ - sv = 2.0 * su * cu; - cv = cu * cu - su * su; - ss[k][1] = sv; /* sin(2L) */ - cc[k][1] = cv; - for (i = 2; i < n; i++) - { - s = su * cv + cu * sv; - cv = cu * cv - su * sv; - sv = s; - ss[k][i] = sv; /* sin( i+1 L ) */ - cc[k][i] = cv; + su = sin(arg); + cu = cos(arg); + ss[k][0] = su; /* sin(L) */ + cc[k][0] = cu; /* cos(L) */ + sv = 2.0 * su * cu; + cv = cu * cu - su * su; + ss[k][1] = sv; /* sin(2L) */ + cc[k][1] = cv; + for (i = 2; i < n; i++) { + s = su * cv + cu * sv; + cv = cu * cv - su * sv; + sv = s; + ss[k][i] = sv; /* sin( i+1 L ) */ + cc[k][i] = cv; } } @@ -414,82 +408,80 @@ static void sscc (int k, double arg, int n) * J = Julian day number * xemb = rectangular equatorial coordinates of Earth */ -static void embofs_mosh(double tjd, double *xemb) +static void +embofs_mosh(double tjd, double *xemb) { - double T, M, a, L, B, p; - double smp, cmp, s2mp, c2mp, s2d, c2d, sf, cf; - double s2f, sx, cx, xyz[6]; - double seps = swed.oec.seps; - double ceps = swed.oec.ceps; - int i; - /* Short series for position of the Moon - */ - T = (tjd-J1900)/36525.0; - /* Mean anomaly of moon (MP) */ - a = swe_degnorm(((1.44e-5*T + 0.009192)*T + 477198.8491)*T + 296.104608); - a *= DEGTORAD; - smp = sin(a); - cmp = cos(a); - s2mp = 2.0*smp*cmp; /* sin(2MP) */ - c2mp = cmp*cmp - smp*smp; /* cos(2MP) */ - /* Mean elongation of moon (D) */ - a = swe_degnorm(((1.9e-6*T - 0.001436)*T + 445267.1142)*T + 350.737486); - a = 2.0 * DEGTORAD * a; - s2d = sin(a); - c2d = cos(a); - /* Mean distance of moon from its ascending node (F) */ - a = swe_degnorm((( -3.e-7*T - 0.003211)*T + 483202.0251)*T + 11.250889); - a *= DEGTORAD; - sf = sin(a); - cf = cos(a); - s2f = 2.0*sf*cf; /* sin(2F) */ - sx = s2d*cmp - c2d*smp; /* sin(2D - MP) */ - cx = c2d*cmp + s2d*smp; /* cos(2D - MP) */ - /* Mean longitude of moon (LP) */ - L = ((1.9e-6*T - 0.001133)*T + 481267.8831)*T + 270.434164; - /* Mean anomaly of sun (M) */ - M = swe_degnorm((( -3.3e-6*T - 1.50e-4)*T + 35999.0498)*T + 358.475833); - /* Ecliptic longitude of the moon */ - L = L - + 6.288750*smp - + 1.274018*sx - + 0.658309*s2d - + 0.213616*s2mp - - 0.185596*sin( DEGTORAD * M ) - - 0.114336*s2f; - /* Ecliptic latitude of the moon */ - a = smp*cf; - sx = cmp*sf; - B = 5.128189*sf - + 0.280606*(a+sx) /* sin(MP+F) */ - + 0.277693*(a-sx) /* sin(MP-F) */ - + 0.173238*(s2d*cf - c2d*sf); /* sin(2D-F) */ - B *= DEGTORAD; - /* Parallax of the moon */ - p = 0.950724 - +0.051818*cmp - +0.009531*cx - +0.007843*c2d - +0.002824*c2mp; - p *= DEGTORAD; - /* Elongation of Moon from Sun - */ - L = swe_degnorm(L); - L *= DEGTORAD; - /* Distance in au */ - a = 4.263523e-5/sin(p); - /* Convert to rectangular ecliptic coordinates */ - xyz[0] = L; - xyz[1] = B; - xyz[2] = a; - swi_polcart(xyz, xyz); - /* Convert to equatorial */ - swi_coortrf2(xyz, xyz, -seps, ceps); - /* Precess to equinox of J2000.0 */ - swi_precess(xyz, tjd, J_TO_J2000);/**/ - /* now emb -> earth */ - for (i = 0; i <= 2; i++) - xemb[i] -= xyz[i] / (EARTH_MOON_MRAT + 1.0); + double T, M, a, L, B, p; + double smp, cmp, s2mp, c2mp, s2d, c2d, sf, cf; + double s2f, sx, cx, xyz[6]; + double seps = swed.oec.seps; + double ceps = swed.oec.ceps; + int i; + /* Short series for position of the Moon + */ + T = (tjd - J1900) / 36525.0; + /* Mean anomaly of moon (MP) */ + a = swe_degnorm(((1.44e-5 * T + 0.009192) * T + 477198.8491) * T + + 296.104608); + a *= DEGTORAD; + smp = sin(a); + cmp = cos(a); + s2mp = 2.0 * smp * cmp; /* sin(2MP) */ + c2mp = cmp * cmp - smp * smp; /* cos(2MP) */ + /* Mean elongation of moon (D) */ + a = swe_degnorm(((1.9e-6 * T - 0.001436) * T + 445267.1142) * T + + 350.737486); + a = 2.0 * DEGTORAD * a; + s2d = sin(a); + c2d = cos(a); + /* Mean distance of moon from its ascending node (F) */ + a = swe_degnorm(((-3.e-7 * T - 0.003211) * T + 483202.0251) * T + + 11.250889); + a *= DEGTORAD; + sf = sin(a); + cf = cos(a); + s2f = 2.0 * sf * cf; /* sin(2F) */ + sx = s2d * cmp - c2d * smp; /* sin(2D - MP) */ + cx = c2d * cmp + s2d * smp; /* cos(2D - MP) */ + /* Mean longitude of moon (LP) */ + L = ((1.9e-6 * T - 0.001133) * T + 481267.8831) * T + 270.434164; + /* Mean anomaly of sun (M) */ + M = swe_degnorm(((-3.3e-6 * T - 1.50e-4) * T + 35999.0498) * T + + 358.475833); + /* Ecliptic longitude of the moon */ + L = L + 6.288750 * smp + 1.274018 * sx + 0.658309 * s2d + + 0.213616 * s2mp - 0.185596 * sin(DEGTORAD * M) + - 0.114336 * s2f; + /* Ecliptic latitude of the moon */ + a = smp * cf; + sx = cmp * sf; + B = 5.128189 * sf + 0.280606 * (a + sx) /* sin(MP+F) */ + +0.277693 * (a - sx) /* sin(MP-F) */ + +0.173238 * (s2d * cf - c2d * sf); /* sin(2D-F) */ + B *= DEGTORAD; + /* Parallax of the moon */ + p = 0.950724 + 0.051818 * cmp + 0.009531 * cx + 0.007843 * c2d + + 0.002824 * c2mp; + p *= DEGTORAD; + /* Elongation of Moon from Sun + */ + L = swe_degnorm(L); + L *= DEGTORAD; + /* Distance in au */ + a = 4.263523e-5 / sin(p); + /* Convert to rectangular ecliptic coordinates */ + xyz[0] = L; + xyz[1] = B; + xyz[2] = a; + swi_polcart(xyz, xyz); + /* Convert to equatorial */ + swi_coortrf2(xyz, xyz, -seps, ceps); + /* Precess to equinox of J2000.0 */ + swi_precess(xyz, tjd, J_TO_J2000); + /**/ + /* now emb -> earth */ + for (i = 0; i <= 2; i++) + xemb[i] -= xyz[i] / (EARTH_MOON_MRAT + 1.0); } /* orbital elements of planets that are computed from osculating elements @@ -505,69 +497,73 @@ static void embofs_mosh(double tjd, double *xemb) #define SE_NEELY /* use James Neely's revised elements * of Uranian planets*/ static char *plan_fict_nam[SE_NFICT_ELEM] = - {"Cupido", "Hades", "Zeus", "Kronos", - "Apollon", "Admetos", "Vulkanus", "Poseidon", - "Isis-Transpluto", "Nibiru", "Harrington", - "Leverrier", "Adams", - "Lowell", "Pickering",}; + { "Cupido", "Hades", "Zeus", "Kronos", + "Apollon", "Admetos", "Vulkanus", "Poseidon", + "Isis-Transpluto", "Nibiru", "Harrington", + "Leverrier", "Adams", + "Lowell", "Pickering", +}; -char *swi_get_fict_name(int32 ipl, char *snam) +char * +swi_get_fict_name(int32 ipl, char *snam) { - if (read_elements_file(ipl, 0, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, - snam, NULL, NULL) == ERR) - strcpy(snam, "name not found"); - return snam; + if (read_elements_file + (ipl, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, snam, NULL, + NULL) == ERR) + strcpy(snam, "name not found"); + return snam; } static double plan_oscu_elem[SE_NFICT_ELEM][8] = { #ifdef SE_NEELY - {J1900, J1900, 163.7409, 40.99837, 0.00460, 171.4333, 129.8325, 1.0833},/* Cupido Neely */ - {J1900, J1900, 27.6496, 50.66744, 0.00245, 148.1796, 161.3339, 1.0500},/* Hades Neely */ - {J1900, J1900, 165.1232, 59.21436, 0.00120, 299.0440, 0.0000, 0.0000},/* Zeus Neely */ - {J1900, J1900, 169.0193, 64.81960, 0.00305, 208.8801, 0.0000, 0.0000},/* Kronos Neely */ - {J1900, J1900, 138.0533, 70.29949, 0.00000, 0.0000, 0.0000, 0.0000},/* Apollon Neely */ - {J1900, J1900, 351.3350, 73.62765, 0.00000, 0.0000, 0.0000, 0.0000},/* Admetos Neely */ - {J1900, J1900, 55.8983, 77.25568, 0.00000, 0.0000, 0.0000, 0.0000},/* Vulcanus Neely */ - {J1900, J1900, 165.5163, 83.66907, 0.00000, 0.0000, 0.0000, 0.0000},/* Poseidon Neely */ + {J1900, J1900, 163.7409, 40.99837, 0.00460, 171.4333, 129.8325, 1.0833}, /* Cupido Neely */ + {J1900, J1900, 27.6496, 50.66744, 0.00245, 148.1796, 161.3339, 1.0500}, /* Hades Neely */ + {J1900, J1900, 165.1232, 59.21436, 0.00120, 299.0440, 0.0000, 0.0000}, /* Zeus Neely */ + {J1900, J1900, 169.0193, 64.81960, 0.00305, 208.8801, 0.0000, 0.0000}, /* Kronos Neely */ + {J1900, J1900, 138.0533, 70.29949, 0.00000, 0.0000, 0.0000, 0.0000}, /* Apollon Neely */ + {J1900, J1900, 351.3350, 73.62765, 0.00000, 0.0000, 0.0000, 0.0000}, /* Admetos Neely */ + {J1900, J1900, 55.8983, 77.25568, 0.00000, 0.0000, 0.0000, 0.0000}, /* Vulcanus Neely */ + {J1900, J1900, 165.5163, 83.66907, 0.00000, 0.0000, 0.0000, 0.0000}, /* Poseidon Neely */ #else - {J1900, J1900, 104.5959, 40.99837, 0, 0, 0, 0}, /* Cupido */ - {J1900, J1900, 337.4517, 50.667443, 0, 0, 0, 0}, /* Hades */ - {J1900, J1900, 104.0904, 59.214362, 0, 0, 0, 0}, /* Zeus */ - {J1900, J1900, 17.7346, 64.816896, 0, 0, 0, 0}, /* Kronos */ - {J1900, J1900, 138.0354, 70.361652, 0, 0, 0, 0}, /* Apollon */ - {J1900, J1900, -8.678, 73.736476, 0, 0, 0, 0}, /* Admetos */ - {J1900, J1900, 55.9826, 77.445895, 0, 0, 0, 0}, /* Vulkanus */ - {J1900, J1900, 165.3595, 83.493733, 0, 0, 0, 0}, /* Poseidon */ + {J1900, J1900, 104.5959, 40.99837, 0, 0, 0, 0}, /* Cupido */ + {J1900, J1900, 337.4517, 50.667443, 0, 0, 0, 0}, /* Hades */ + {J1900, J1900, 104.0904, 59.214362, 0, 0, 0, 0}, /* Zeus */ + {J1900, J1900, 17.7346, 64.816896, 0, 0, 0, 0}, /* Kronos */ + {J1900, J1900, 138.0354, 70.361652, 0, 0, 0, 0}, /* Apollon */ + {J1900, J1900, -8.678, 73.736476, 0, 0, 0, 0}, /* Admetos */ + {J1900, J1900, 55.9826, 77.445895, 0, 0, 0, 0}, /* Vulkanus */ + {J1900, J1900, 165.3595, 83.493733, 0, 0, 0, 0}, /* Poseidon */ #endif - /* Isis-Transpluto; elements from "Die Sterne" 3/1952, p. 70ff. - * Strubell does not give an equinox. 1945 is taken to best reproduce - * ASTRON ephemeris. (This is a strange choice, though.) - * The epoch is 1772.76. The year is understood to have 366 days. - * The fraction is counted from 1 Jan. 1772 */ - {2368547.66, 2431456.5, 0.0, 77.775, 0.3, 0.7, 0, 0}, - /* Nibiru, elements from Christian Woeltge, Hannover */ - {1856113.380954, 1856113.380954, 0.0, 234.8921, 0.981092, 103.966, -44.567, 158.708}, - /* Harrington, elements from Astronomical Journal 96(4), Oct. 1988 */ - {2374696.5, J2000, 0.0, 101.2, 0.411, 208.5, 275.4, 32.4}, - /* Leverrier's Neptune, - according to W.G. Hoyt, "Planets X and Pluto", Tucson 1980, p. 63 */ - {2395662.5, 2395662.5, 34.05, 36.15, 0.10761, 284.75, 0, 0}, - /* Adam's Neptune */ - {2395662.5, 2395662.5, 24.28, 37.25, 0.12062, 299.11, 0, 0}, - /* Lowell's Pluto */ - {2425977.5, 2425977.5, 281, 43.0, 0.202, 204.9, 0, 0}, - /* Pickering's Pluto */ - {2425977.5, 2425977.5, 48.95, 55.1, 0.31, 280.1, 100, 15}, /**/ -#if 0 /* Ceres JPL 1600, without perturbations from other minor planets, - * from following initial elements: - * 2450600.5 2000 0 1 164.7073602 73.0340746 80.5995101 - * 10.5840296 0.07652422 0.0 2.770176095 */ - {2305447.5, J2000, 0.5874558977449977e+02, 0.2766536058742327e+01, - 0.7870946565779195e-01, 0.5809199028919189e+02, - 0.8650119410725021e+02, 0.1066835622280712e+02}, - /* Chiron, Bowell database 18-mar-1997 */ - {2450500.5, J2000, 7.258191, 13.67387471, 0.38174778, 339.558345, 209.379239, 6.933360}, /**/ + /* Isis-Transpluto; elements from "Die Sterne" 3/1952, p. 70ff. + * Strubell does not give an equinox. 1945 is taken to best reproduce + * ASTRON ephemeris. (This is a strange choice, though.) + * The epoch is 1772.76. The year is understood to have 366 days. + * The fraction is counted from 1 Jan. 1772 */ + {2368547.66, 2431456.5, 0.0, 77.775, 0.3, 0.7, 0, 0}, + /* Nibiru, elements from Christian Woeltge, Hannover */ + {1856113.380954, 1856113.380954, 0.0, 234.8921, 0.981092, 103.966, + -44.567, 158.708}, + /* Harrington, elements from Astronomical Journal 96(4), Oct. 1988 */ + {2374696.5, J2000, 0.0, 101.2, 0.411, 208.5, 275.4, 32.4}, + /* Leverrier's Neptune, + * according to W.G. Hoyt, "Planets X and Pluto", Tucson 1980, p. 63 */ + {2395662.5, 2395662.5, 34.05, 36.15, 0.10761, 284.75, 0, 0}, + /* Adam's Neptune */ + {2395662.5, 2395662.5, 24.28, 37.25, 0.12062, 299.11, 0, 0}, + /* Lowell's Pluto */ + {2425977.5, 2425977.5, 281, 43.0, 0.202, 204.9, 0, 0}, + /* Pickering's Pluto */ + {2425977.5, 2425977.5, 48.95, 55.1, 0.31, 280.1, 100, 15}, /**/ +#if 0 /* Ceres JPL 1600, without perturbations from other minor planets, + * from following initial elements: + * 2450600.5 2000 0 1 164.7073602 73.0340746 80.5995101 + * 10.5840296 0.07652422 0.0 2.770176095 */ + {2305447.5, J2000, 0.5874558977449977e+02, 0.2766536058742327e+01, + 0.7870946565779195e-01, 0.5809199028919189e+02, + 0.8650119410725021e+02, 0.1066835622280712e+02}, + /* Chiron, Bowell database 18-mar-1997 */ + {2450500.5, J2000, 7.258191, 13.67387471, 0.38174778, 339.558345, + 209.379239, 6.933360}, /**/ #endif }; @@ -577,383 +573,402 @@ static double plan_oscu_elem[SE_NFICT_ELEM][8] = { * ipli body number in planetary data structure * iflag flags */ -int swi_osc_el_plan(double tjd, double *xp, int ipl, int ipli, double *xearth, double *xsun, char *serr) +int +swi_osc_el_plan(double tjd, double *xp, int ipl, int ipli, double *xearth, + double *xsun, char *serr) { - double pqr[9], x[6]; - double eps, K, fac, rho, cose, sine; - double alpha, beta, zeta, sigma, M2, Msgn, M_180_or_0; - double tjd0, tequ, mano, sema, ecce, parg, node, incl, dmot; - double cosnode, sinnode, cosincl, sinincl, cosparg, sinparg; - double M, E; - struct plan_data *pedp = &swed.pldat[SEI_EARTH]; - struct plan_data *pdp = &swed.pldat[ipli]; - int32 fict_ifl = 0; - int i; - /* orbital elements, either from file or, if file not found, - * from above built-in set - */ - if (read_elements_file(ipl, tjd, &tjd0, &tequ, - &mano, &sema, &ecce, &parg, &node, &incl, - NULL, &fict_ifl, serr) == ERR) - return ERR; - dmot = 0.9856076686 * DEGTORAD / sema / sqrt(sema); /* daily motion */ - if (fict_ifl & FICT_GEO) - dmot /= sqrt(SUN_EARTH_MRAT); - cosnode = cos(node); - sinnode = sin(node); - cosincl = cos(incl); - sinincl = sin(incl); - cosparg = cos(parg); - sinparg = sin(parg); - /* Gaussian vector */ - pqr[0] = cosparg * cosnode - sinparg * cosincl * sinnode; - pqr[1] = -sinparg * cosnode - cosparg * cosincl * sinnode; - pqr[2] = sinincl * sinnode; - pqr[3] = cosparg * sinnode + sinparg * cosincl * cosnode; - pqr[4] = -sinparg * sinnode + cosparg * cosincl * cosnode; - pqr[5] = -sinincl * cosnode; - pqr[6] = sinparg * sinincl; - pqr[7] = cosparg * sinincl; - pqr[8] = cosincl; - /* Kepler problem */ - E = M = swi_mod2PI(mano + (tjd - tjd0) * dmot); /* mean anomaly of date */ - /* better E for very high eccentricity and small M */ - if (ecce > 0.975) { - M2 = M * RADTODEG; - if (M2 > 150 && M2 < 210) { - M2 -= 180; - M_180_or_0 = 180; - } else - M_180_or_0 = 0; - if (M2 > 330) - M2 -= 360; - if (M2 < 0) { - M2 = -M2; - Msgn = -1; - } else - Msgn = 1; - if (M2 < 30) { - M2 *= DEGTORAD; - alpha = (1 - ecce) / (4 * ecce + 0.5); - beta = M2 / (8 * ecce + 1); - zeta = pow(beta + sqrt(beta * beta + alpha * alpha), 1/3); - sigma = zeta - alpha / 2; - sigma = sigma - 0.078 * sigma * sigma * sigma * sigma * sigma / (1 + ecce); - E = Msgn * (M2 + ecce * (3 * sigma - 4 * sigma * sigma * sigma)) - + M_180_or_0; + double pqr[9], x[6]; + double eps, K, fac, rho, cose, sine; + double alpha, beta, zeta, sigma, M2, Msgn, M_180_or_0; + double tjd0, tequ, mano, sema, ecce, parg, node, incl, dmot; + double cosnode, sinnode, cosincl, sinincl, cosparg, sinparg; + double M, E; + struct plan_data *pedp = &swed.pldat[SEI_EARTH]; + struct plan_data *pdp = &swed.pldat[ipli]; + int32 fict_ifl = 0; + int i; + /* orbital elements, either from file or, if file not found, + * from above built-in set + */ + if (read_elements_file + (ipl, tjd, &tjd0, &tequ, &mano, &sema, &ecce, &parg, &node, &incl, + NULL, &fict_ifl, serr) == ERR) + return ERR; + dmot = 0.9856076686 * DEGTORAD / sema / sqrt(sema); /* daily motion */ + if (fict_ifl & FICT_GEO) + dmot /= sqrt(SUN_EARTH_MRAT); + cosnode = cos(node); + sinnode = sin(node); + cosincl = cos(incl); + sinincl = sin(incl); + cosparg = cos(parg); + sinparg = sin(parg); + /* Gaussian vector */ + pqr[0] = cosparg * cosnode - sinparg * cosincl * sinnode; + pqr[1] = -sinparg * cosnode - cosparg * cosincl * sinnode; + pqr[2] = sinincl * sinnode; + pqr[3] = cosparg * sinnode + sinparg * cosincl * cosnode; + pqr[4] = -sinparg * sinnode + cosparg * cosincl * cosnode; + pqr[5] = -sinincl * cosnode; + pqr[6] = sinparg * sinincl; + pqr[7] = cosparg * sinincl; + pqr[8] = cosincl; + /* Kepler problem */ + E = M = swi_mod2PI(mano + (tjd - tjd0) * dmot); /* mean anomaly of date */ + /* better E for very high eccentricity and small M */ + if (ecce > 0.975) { + M2 = M * RADTODEG; + if (M2 > 150 && M2 < 210) { + M2 -= 180; + M_180_or_0 = 180; + } + else + M_180_or_0 = 0; + if (M2 > 330) + M2 -= 360; + if (M2 < 0) { + M2 = -M2; + Msgn = -1; + } + else + Msgn = 1; + if (M2 < 30) { + M2 *= DEGTORAD; + alpha = (1 - ecce) / (4 * ecce + 0.5); + beta = M2 / (8 * ecce + 1); + zeta = pow(beta + sqrt(beta * beta + alpha * alpha), 1 / 3); + sigma = zeta - alpha / 2; + sigma = + sigma - 0.078 * sigma * sigma * sigma * sigma * sigma / (1 + + ecce); + E = Msgn * (M2 + ecce * (3 * sigma - 4 * sigma * sigma * sigma)) + + M_180_or_0; + } } - } - E = swi_kepler(E, M, ecce); - /* position and speed, referred to orbital plane */ - if (fict_ifl & FICT_GEO) - K = KGAUSS_GEO / sqrt(sema); - else - K = KGAUSS / sqrt(sema); - cose = cos(E); - sine = sin(E); - fac = sqrt((1 - ecce) * (1 + ecce)); - rho = 1 - ecce * cose; - x[0] = sema * (cose - ecce); - x[1] = sema * fac * sine; - x[3] = -K * sine / rho; - x[4] = K * fac * cose / rho; - /* transformation to ecliptic */ - xp[0] = pqr[0] * x[0] + pqr[1] * x[1]; - xp[1] = pqr[3] * x[0] + pqr[4] * x[1]; - xp[2] = pqr[6] * x[0] + pqr[7] * x[1]; - xp[3] = pqr[0] * x[3] + pqr[1] * x[4]; - xp[4] = pqr[3] * x[3] + pqr[4] * x[4]; - xp[5] = pqr[6] * x[3] + pqr[7] * x[4]; - /* transformation to equator */ - eps = swi_epsiln(tequ); - swi_coortrf(xp, xp, -eps); - swi_coortrf(xp+3, xp+3, -eps); - /* precess to J2000 */ - if (tequ != J2000) { - swi_precess(xp, tequ, J_TO_J2000); - swi_precess(xp+3, tequ, J_TO_J2000); - } - /* to solar system barycentre */ - if (fict_ifl & FICT_GEO) { - for (i = 0; i <= 5; i++) { - xp[i] += xearth[i]; + E = swi_kepler(E, M, ecce); + /* position and speed, referred to orbital plane */ + if (fict_ifl & FICT_GEO) + K = KGAUSS_GEO / sqrt(sema); + else + K = KGAUSS / sqrt(sema); + cose = cos(E); + sine = sin(E); + fac = sqrt((1 - ecce) * (1 + ecce)); + rho = 1 - ecce * cose; + x[0] = sema * (cose - ecce); + x[1] = sema * fac * sine; + x[3] = -K * sine / rho; + x[4] = K * fac * cose / rho; + /* transformation to ecliptic */ + xp[0] = pqr[0] * x[0] + pqr[1] * x[1]; + xp[1] = pqr[3] * x[0] + pqr[4] * x[1]; + xp[2] = pqr[6] * x[0] + pqr[7] * x[1]; + xp[3] = pqr[0] * x[3] + pqr[1] * x[4]; + xp[4] = pqr[3] * x[3] + pqr[4] * x[4]; + xp[5] = pqr[6] * x[3] + pqr[7] * x[4]; + /* transformation to equator */ + eps = swi_epsiln(tequ); + swi_coortrf(xp, xp, -eps); + swi_coortrf(xp + 3, xp + 3, -eps); + /* precess to J2000 */ + if (tequ != J2000) { + swi_precess(xp, tequ, J_TO_J2000); + swi_precess(xp + 3, tequ, J_TO_J2000); } - } else { - for (i = 0; i <= 5; i++) { - xp[i] += xsun[i]; - } - } - if (pdp->x == xp) { - pdp->teval = tjd; /* for precession! */ - pdp->iephe = pedp->iephe; - } - return OK; + /* to solar system barycentre */ + if (fict_ifl & FICT_GEO) { + for (i = 0; i <= 5; i++) { + xp[i] += xearth[i]; + } + } + else { + for (i = 0; i <= 5; i++) { + xp[i] += xsun[i]; + } + } + if (pdp->x == xp) { + pdp->teval = tjd; /* for precession! */ + pdp->iephe = pedp->iephe; + } + return OK; } #if 1 + /* note: input parameter tjd is required for T terms in elements */ -static int read_elements_file(int32 ipl, double tjd, - double *tjd0, double *tequ, - double *mano, double *sema, double *ecce, - double *parg, double *node, double *incl, - char *pname, int32 *fict_ifl, char *serr) +static int +read_elements_file(int32 ipl, double tjd, double *tjd0, double *tequ, + double *mano, double *sema, double *ecce, double *parg, + double *node, double *incl, char *pname, int32 * fict_ifl, + char *serr) { - int i, iline, iplan, retc, ncpos; - FILE *fp = NULL; - char s[AS_MAXCH], *sp; - char *cpos[20], serri[AS_MAXCH]; - AS_BOOL elem_found = FALSE; - double tt = 0; - /* -1, because file information is not saved, file is always closed */ - if ((fp = swi_fopen(-1, SE_FICTFILE, swed.ephepath, serr)) == NULL) { - /* file does not exist, use built-in bodies */ - if (ipl >= SE_NFICT_ELEM) { - if (serr != NULL) - sprintf(serr, "error no elements for fictitious body no %7.0f", (double) ipl); - return ERR; + int i, iline, iplan, retc, ncpos; + FILE *fp = NULL; + char s[AS_MAXCH], *sp; + char *cpos[20], serri[AS_MAXCH]; + AS_BOOL elem_found = FALSE; + double tt = 0; + /* -1, because file information is not saved, file is always closed */ + if ((fp = swi_fopen(-1, SE_FICTFILE, swed.ephepath, serr)) == NULL) { + /* file does not exist, use built-in bodies */ + if (ipl >= SE_NFICT_ELEM) { + if (serr != NULL) + sprintf(serr, + "error no elements for fictitious body no %7.0f", + (double)ipl); + return ERR; + } + if (tjd0 != NULL) + *tjd0 = plan_oscu_elem[ipl][0]; /* epoch */ + if (tequ != NULL) + *tequ = plan_oscu_elem[ipl][1]; /* equinox */ + if (mano != NULL) + *mano = plan_oscu_elem[ipl][2] * DEGTORAD; /* mean anomaly */ + if (sema != NULL) + *sema = plan_oscu_elem[ipl][3]; /* semi-axis */ + if (ecce != NULL) + *ecce = plan_oscu_elem[ipl][4]; /* eccentricity */ + if (parg != NULL) + *parg = plan_oscu_elem[ipl][5] * DEGTORAD; /* arg. of peri. */ + if (node != NULL) + *node = plan_oscu_elem[ipl][6] * DEGTORAD; /* asc. node */ + if (incl != NULL) + *incl = plan_oscu_elem[ipl][7] * DEGTORAD; /* inclination */ + if (pname != NULL) + strcpy(pname, plan_fict_nam[ipl]); + return OK; } - if (tjd0 != NULL) - *tjd0 = plan_oscu_elem[ipl][0]; /* epoch */ - if (tequ != NULL) - *tequ = plan_oscu_elem[ipl][1]; /* equinox */ - if (mano != NULL) - *mano = plan_oscu_elem[ipl][2] * DEGTORAD; /* mean anomaly */ - if (sema != NULL) - *sema = plan_oscu_elem[ipl][3]; /* semi-axis */ - if (ecce != NULL) - *ecce = plan_oscu_elem[ipl][4]; /* eccentricity */ - if (parg != NULL) - *parg = plan_oscu_elem[ipl][5] * DEGTORAD; /* arg. of peri. */ - if (node != NULL) - *node = plan_oscu_elem[ipl][6] * DEGTORAD; /* asc. node */ - if (incl != NULL) - *incl = plan_oscu_elem[ipl][7] * DEGTORAD; /* inclination */ - if (pname != NULL) - strcpy(pname, plan_fict_nam[ipl]); + /* + * find elements in file + */ + iline = 0; + iplan = -1; + while (fgets(s, AS_MAXCH, fp) != NULL) { + iline++; + sp = s; + while (*sp == ' ' || *sp == '\t') + sp++; + swi_strcpy(s, sp); + if (*s == '#') + continue; + if (*s == '\r') + continue; + if (*s == '\n') + continue; + if (*s == '\0') + continue; + if ((sp = strchr(s, '#')) != NULL) + *sp = '\0'; + ncpos = swi_cutstr(s, ",", cpos, 20); + sprintf(serri, "error in file %s, line %7.0f:", SE_FICTFILE, + (double)iline); + if (ncpos < 9) { + if (serr != NULL) + sprintf(serr, "%s nine elements required", serri); + return ERR; + } + iplan++; + if (iplan != ipl) + continue; + elem_found = TRUE; + /* epoch of elements */ + if (tjd0 != NULL) { + sp = cpos[0]; + for (i = 0; i < 5; i++) + sp[i] = tolower(sp[i]); + if (strncmp(sp, "j2000", 5) == OK) + *tjd0 = J2000; + else if (strncmp(sp, "b1950", 5) == OK) + *tjd0 = B1950; + else if (strncmp(sp, "j1900", 5) == OK) + *tjd0 = J1900; + else if (*sp == 'j' || *sp == 'b') { + if (serr != NULL) + sprintf(serr, "%s invalid epoch", serri); + goto return_err; + } + else + *tjd0 = atof(sp); + tt = tjd - *tjd0; + } + /* equinox */ + if (tequ != NULL) { + sp = cpos[1]; + while (*sp == ' ' || *sp == '\t') + sp++; + for (i = 0; i < 5; i++) + sp[i] = tolower(sp[i]); + if (strncmp(sp, "j2000", 5) == OK) + *tequ = J2000; + else if (strncmp(sp, "b1950", 5) == OK) + *tequ = B1950; + else if (strncmp(sp, "j1900", 5) == OK) + *tequ = J1900; + else if (strncmp(sp, "jdate", 5) == OK) + *tequ = tjd; + else if (*sp == 'j' || *sp == 'b') { + if (serr != NULL) + sprintf(serr, "%s invalid equinox", serri); + goto return_err; + } + else + *tequ = atof(sp); + } + /* mean anomaly t0 */ + if (mano != NULL) { + retc = check_t_terms(tt, cpos[2], mano); + *mano = swe_degnorm(*mano); + if (retc == ERR) { + if (serr != NULL) + sprintf(serr, "%s mean anomaly value invalid", serri); + goto return_err; + } + /* if mean anomaly has t terms (which happens with fictitious + * planet Vulcan), we set + * epoch = tjd, so that no motion will be added anymore + * equinox = tjd */ + if (retc == 1) { + *tjd0 = tjd; + } + *mano *= DEGTORAD; + } + /* semi-axis */ + if (sema != NULL) { + retc = check_t_terms(tt, cpos[3], sema); + if (*sema <= 0 || retc == ERR) { + if (serr != NULL) + sprintf(serr, "%s semi-axis value invalid", serri); + goto return_err; + } + } + /* eccentricity */ + if (ecce != NULL) { + retc = check_t_terms(tt, cpos[4], ecce); + if (*ecce >= 1 || *ecce < 0 || retc == ERR) { + if (serr != NULL) + sprintf(serr, + "%s eccentricity invalid (no parabolic or hyperbolic orbits allowed)", + serri); + goto return_err; + } + } + /* perihelion argument */ + if (parg != NULL) { + retc = check_t_terms(tt, cpos[5], parg); + *parg = swe_degnorm(*parg); + if (retc == ERR) { + if (serr != NULL) + sprintf(serr, "%s perihelion argument value invalid", + serri); + goto return_err; + } + *parg *= DEGTORAD; + } + /* node */ + if (node != NULL) { + retc = check_t_terms(tt, cpos[6], node); + *node = swe_degnorm(*node); + if (retc == ERR) { + if (serr != NULL) + sprintf(serr, "%s node value invalid", serri); + goto return_err; + } + *node *= DEGTORAD; + } + /* inclination */ + if (incl != NULL) { + retc = check_t_terms(tt, cpos[7], incl); + *incl = swe_degnorm(*incl); + if (retc == ERR) { + if (serr != NULL) + sprintf(serr, "%s inclination value invalid", serri); + goto return_err; + } + *incl *= DEGTORAD; + } + /* planet name */ + if (pname != NULL) { + sp = cpos[8]; + while (*sp == ' ' || *sp == '\t') + sp++; + swi_right_trim(sp); + strcpy(pname, sp); + } + /* geocentric */ + if (fict_ifl != NULL && ncpos > 9) { + for (sp = cpos[9]; *sp != '\0'; sp++) + *sp = tolower(*sp); + if (strstr(cpos[9], "geo") != NULL) + *fict_ifl |= FICT_GEO; + } + break; + } + if (!elem_found) { + if (serr != NULL) + sprintf(serr, "%s elements for planet %7.0f not found", serri, + (double)ipl); + goto return_err; + } + fclose(fp); return OK; - } - /* - * find elements in file - */ - iline = 0; - iplan = -1; - while (fgets(s, AS_MAXCH, fp) != NULL) { - iline++; - sp = s; - while(*sp == ' ' || *sp == '\t') - sp++; - swi_strcpy(s, sp); - if (*s == '#') - continue; - if (*s == '\r') - continue; - if (*s == '\n') - continue; - if (*s == '\0') - continue; - if ((sp = strchr(s, '#')) != NULL) - *sp = '\0'; - ncpos = swi_cutstr(s, ",", cpos, 20); - sprintf(serri, "error in file %s, line %7.0f:", - SE_FICTFILE, (double) iline); - if (ncpos < 9) { - if (serr != NULL) - sprintf(serr, "%s nine elements required", serri); - return ERR; - } - iplan++; - if (iplan != ipl) - continue; - elem_found = TRUE; - /* epoch of elements */ - if (tjd0 != NULL) { - sp = cpos[0]; - for (i = 0; i < 5; i++) - sp[i] = tolower(sp[i]); - if (strncmp(sp, "j2000", 5) == OK) - *tjd0 = J2000; - else if (strncmp(sp, "b1950", 5) == OK) - *tjd0 = B1950; - else if (strncmp(sp, "j1900", 5) == OK) - *tjd0 = J1900; - else if (*sp == 'j' || *sp == 'b') { - if (serr != NULL) - sprintf(serr, "%s invalid epoch", serri); - goto return_err; - } else - *tjd0 = atof(sp); - tt = tjd - *tjd0; - } - /* equinox */ - if (tequ != NULL) { - sp = cpos[1]; - while(*sp == ' ' || *sp == '\t') - sp++; - for (i = 0; i < 5; i++) - sp[i] = tolower(sp[i]); - if (strncmp(sp, "j2000", 5) == OK) - *tequ = J2000; - else if (strncmp(sp, "b1950", 5) == OK) - *tequ = B1950; - else if (strncmp(sp, "j1900", 5) == OK) - *tequ = J1900; - else if (strncmp(sp, "jdate", 5) == OK) - *tequ = tjd; - else if (*sp == 'j' || *sp == 'b') { - if (serr != NULL) - sprintf(serr, "%s invalid equinox", serri); - goto return_err; - } else - *tequ = atof(sp); - } - /* mean anomaly t0 */ - if (mano != NULL) { - retc = check_t_terms(tt, cpos[2], mano); - *mano = swe_degnorm(*mano); - if (retc == ERR) { - if (serr != NULL) - sprintf(serr, "%s mean anomaly value invalid", serri); - goto return_err; - } - /* if mean anomaly has t terms (which happens with fictitious - * planet Vulcan), we set - * epoch = tjd, so that no motion will be added anymore - * equinox = tjd */ - if (retc == 1) { - *tjd0 = tjd; - } - *mano *= DEGTORAD; - } - /* semi-axis */ - if (sema != NULL) { - retc = check_t_terms(tt, cpos[3], sema); - if (*sema <= 0 || retc == ERR) { - if (serr != NULL) - sprintf(serr, "%s semi-axis value invalid", serri); - goto return_err; - } - } - /* eccentricity */ - if (ecce != NULL) { - retc = check_t_terms(tt, cpos[4], ecce); - if (*ecce >= 1 || *ecce < 0 || retc == ERR) { - if (serr != NULL) - sprintf(serr, "%s eccentricity invalid (no parabolic or hyperbolic orbits allowed)", serri); - goto return_err; - } - } - /* perihelion argument */ - if (parg != NULL) { - retc = check_t_terms(tt, cpos[5], parg); - *parg = swe_degnorm(*parg); - if (retc == ERR) { - if (serr != NULL) - sprintf(serr, "%s perihelion argument value invalid", serri); - goto return_err; - } - *parg *= DEGTORAD; - } - /* node */ - if (node != NULL) { - retc = check_t_terms(tt, cpos[6], node); - *node = swe_degnorm(*node); - if (retc == ERR) { - if (serr != NULL) - sprintf(serr, "%s node value invalid", serri); - goto return_err; - } - *node *= DEGTORAD; - } - /* inclination */ - if (incl != NULL) { - retc = check_t_terms(tt, cpos[7], incl); - *incl = swe_degnorm(*incl); - if (retc == ERR) { - if (serr != NULL) - sprintf(serr, "%s inclination value invalid", serri); - goto return_err; - } - *incl *= DEGTORAD; - } - /* planet name */ - if (pname != NULL) { - sp = cpos[8]; - while(*sp == ' ' || *sp == '\t') - sp++; - swi_right_trim(sp); - strcpy(pname, sp); - } - /* geocentric */ - if (fict_ifl != NULL && ncpos > 9) { - for (sp = cpos[9]; *sp != '\0'; sp++) - *sp = tolower(*sp); - if (strstr(cpos[9], "geo") != NULL) - *fict_ifl |= FICT_GEO; - } - break; - } - if (!elem_found) { - if (serr != NULL) - sprintf(serr, "%s elements for planet %7.0f not found", serri, (double) ipl); - goto return_err; - } - fclose(fp); - return OK; return_err: - fclose(fp); - return ERR; + fclose(fp); + return ERR; } #endif -static int check_t_terms(double t, char *sinp, double *doutp) +static int +check_t_terms(double t, char *sinp, double *doutp) { - int i, isgn = 1, z; - int retc = 0; - char *sp; - double tt[5], fac; - tt[0] = t / 36525; - tt[1] = tt[0]; - tt[2] = tt[1] * tt[1]; - tt[3] = tt[2] * tt[1]; - tt[4] = tt[3] * tt[1]; - if ((sp = strpbrk(sinp, "+-")) != NULL) - retc = 1; /* with additional terms */ - sp = sinp; - *doutp = 0; - fac = 1; - z = 0; - while (1) { - while(*sp != '\0' && strchr(" \t", *sp) != NULL) - sp++; - if (strchr("+-", *sp) || *sp == '\0') { - if (z > 0) - *doutp += fac; - isgn = 1; - if (*sp == '-') - isgn = -1; - fac = 1 * isgn; - if (*sp == '\0') - return retc; - sp++; - } else { - while(*sp != '\0' && strchr("* \t", *sp) != NULL) - sp++; - if (*sp != '\0' && strchr("tT", *sp) != NULL) { - /* a T */ - sp++; - if (*sp != '\0' && strchr("+-", *sp)) - fac *= tt[0]; - else if ((i = atoi(sp)) <= 4 && i >= 0) - fac *= tt[i]; - } else { - /* a number */ - if (atof(sp) != 0 || *sp == '0') - fac *= atof(sp); - } - while (*sp != '\0' && strchr("0123456789.", *sp)) - sp++; - } - z++; - } - return retc; /* there have been additional terms */ + int i, isgn = 1, z; + int retc = 0; + char *sp; + double tt[5], fac; + tt[0] = t / 36525; + tt[1] = tt[0]; + tt[2] = tt[1] * tt[1]; + tt[3] = tt[2] * tt[1]; + tt[4] = tt[3] * tt[1]; + if ((sp = strpbrk(sinp, "+-")) != NULL) + retc = 1; /* with additional terms */ + sp = sinp; + *doutp = 0; + fac = 1; + z = 0; + while (1) { + while (*sp != '\0' && strchr(" \t", *sp) != NULL) + sp++; + if (strchr("+-", *sp) || *sp == '\0') { + if (z > 0) + *doutp += fac; + isgn = 1; + if (*sp == '-') + isgn = -1; + fac = 1 * isgn; + if (*sp == '\0') + return retc; + sp++; + } + else { + while (*sp != '\0' && strchr("* \t", *sp) != NULL) + sp++; + if (*sp != '\0' && strchr("tT", *sp) != NULL) { + /* a T */ + sp++; + if (*sp != '\0' && strchr("+-", *sp)) + fac *= tt[0]; + else if ((i = atoi(sp)) <= 4 && i >= 0) + fac *= tt[i]; + } + else { + /* a number */ + if (atof(sp) != 0 || *sp == '0') + fac *= atof(sp); + } + while (*sp != '\0' && strchr("0123456789.", *sp)) + sp++; + } + z++; + } + return retc; /* there have been additional terms */ } diff --git a/swe/src/swemptab.c b/swe/src/swemptab.c index bf77df6..221f156 100644 --- a/swe/src/swemptab.c +++ b/swe/src/swemptab.c @@ -1,3 +1,4 @@ + /* SWISSEPH $Header: /home/dieter/sweph/RCS/swemptab.c,v 1.74 2008/06/16 10:07:20 dieter Exp $ @@ -5,6 +6,7 @@ as it is #included by swemplan **************************************************************/ + /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -77,1009 +79,1012 @@ Days per record = 4.0 3000.0 to 3000.8: 0.252 0.087 0.115 */ static double FAR mertabl[] = { - 35.85255, -163.26379, 53810162857.56026, 908082.18475, + 35.85255, -163.26379, 53810162857.56026, 908082.18475, - 0.05214, -0.07712, + 0.05214, -0.07712, - 1.07258, 0.04008, 0.49259, 0.00230, - 0.02324, 0.05869, + 1.07258, 0.04008, 0.49259, 0.00230, + 0.02324, 0.05869, - 0.24516, 0.22898, -0.06037, 0.13023, + 0.24516, 0.22898, -0.06037, 0.13023, - 0.00331, -0.03576, + 0.00331, -0.03576, - 0.06464, 0.00089, + 0.06464, 0.00089, - 0.03103, 0.05078, + 0.03103, 0.05078, - -0.01133, 0.01520, + -0.01133, 0.01520, - 0.14654, 0.07538, 0.25112, -0.24473, - -0.17928, -0.53366, + 0.14654, 0.07538, 0.25112, -0.24473, + -0.17928, -0.53366, - -0.06367, 0.20458, -0.42985, 0.14848, - -0.35317, -0.61364, + -0.06367, 0.20458, -0.42985, 0.14848, + -0.35317, -0.61364, - 0.00325, -0.08617, -0.23180, 0.08576, - 0.22995, 0.43569, + 0.00325, -0.08617, -0.23180, 0.08576, + 0.22995, 0.43569, - 1.92114, 2.89319, -5.55637, 4.70329, - -4.91411, -5.45521, + 1.92114, 2.89319, -5.55637, 4.70329, + -4.91411, -5.45521, - 0.02607, 0.04468, + 0.02607, 0.04468, - -0.05439, 0.13476, -0.07329, -0.00985, + -0.05439, 0.13476, -0.07329, -0.00985, - -0.00278, 0.05377, + -0.00278, 0.05377, - 0.07474, -0.09658, 0.29818, 0.20422, - -0.29074, 0.44962, + 0.07474, -0.09658, 0.29818, 0.20422, + -0.29074, 0.44962, - -0.15411, -0.04287, 0.29907, -1.02948, - 3.62183, 0.84869, + -0.15411, -0.04287, 0.29907, -1.02948, + 3.62183, 0.84869, - -0.08157, 0.02754, + -0.08157, 0.02754, - -0.03610, -0.12909, 0.09195, -0.04424, + -0.03610, -0.12909, 0.09195, -0.04424, - -0.08845, 0.09347, + -0.08845, 0.09347, - -0.27140, 0.08185, + -0.27140, 0.08185, - 0.24783, 0.19543, -0.25154, 0.41371, + 0.24783, 0.19543, -0.25154, 0.41371, - -0.00046, 0.01524, + -0.00046, 0.01524, - 0.04127, 0.06663, + 0.04127, 0.06663, - 0.43023, 0.11790, + 0.43023, 0.11790, - 0.04427, 0.05329, + 0.04427, 0.05329, - 0.00411, -0.71074, + 0.00411, -0.71074, - -0.07111, -0.09824, + -0.07111, -0.09824, - 0.01264, -0.02075, + 0.01264, -0.02075, - -0.00068, -0.01678, + -0.00068, -0.01678, - 0.01186, 0.00181, + 0.01186, 0.00181, - 0.00302, -0.21963, + 0.00302, -0.21963, - -0.06412, -0.10155, -0.36856, 0.20240, - 0.32282, 0.65133, + -0.06412, -0.10155, -0.36856, 0.20240, + 0.32282, 0.65133, - -0.07178, -0.01876, 0.13399, -0.39522, - 1.28413, 0.33790, + -0.07178, -0.01876, 0.13399, -0.39522, + 1.28413, 0.33790, - 0.05040, -0.01679, + 0.05040, -0.01679, - -0.00794, 0.01117, + -0.00794, 0.01117, - 0.02630, 0.00575, + 0.02630, 0.00575, - -0.07113, -0.11414, 0.16422, -0.23060, - 0.35198, 0.05409, + -0.07113, -0.11414, 0.16422, -0.23060, + 0.35198, 0.05409, - 1.11486, -0.35833, 0.87313, 1.66304, - -1.28434, 0.72067, + 1.11486, -0.35833, 0.87313, 1.66304, + -1.28434, 0.72067, - 0.01400, 0.00971, + 0.01400, 0.00971, - 0.21044, -0.87385, 3.20820, 0.67957, + 0.21044, -0.87385, 3.20820, 0.67957, - -0.01716, 0.00111, + -0.01716, 0.00111, - -0.13776, -0.02650, + -0.13776, -0.02650, - -0.06778, 0.00908, 0.00616, -0.04520, + -0.06778, 0.00908, 0.00616, -0.04520, - -0.31625, -0.61913, + -0.31625, -0.61913, - 0.36184, 0.09373, + 0.36184, 0.09373, - 0.00984, -0.03292, + 0.00984, -0.03292, - 0.01944, 0.00530, + 0.01944, 0.00530, - 0.00243, -0.00123, + 0.00243, -0.00123, - 0.01589, 0.02223, + 0.01589, 0.02223, - -0.02992, -0.01086, + -0.02992, -0.01086, - 4356.04809, -5859.86328, 2918.27323, -4796.67315, - 510.24783, -1220.02233, 127.48927, 250.10654, - 3250.43013, -904.27614, -5667.40042, -22634.00922, - -82471.79425, 18615.92342, + 4356.04809, -5859.86328, 2918.27323, -4796.67315, + 510.24783, -1220.02233, 127.48927, 250.10654, + 3250.43013, -904.27614, -5667.40042, -22634.00922, + -82471.79425, 18615.92342, - 0.01941, 0.00372, + 0.01941, 0.00372, - 0.01830, -0.00652, + 0.01830, -0.00652, - -0.02548, -0.01157, + -0.02548, -0.01157, - 0.00635, 0.02343, + 0.00635, 0.02343, - -0.00980, 0.00961, + -0.00980, 0.00961, - 0.12137, 0.10068, 0.16676, -0.07257, + 0.12137, 0.10068, 0.16676, -0.07257, - -0.07267, -0.13761, 0.25305, -0.28112, + -0.07267, -0.13761, 0.25305, -0.28112, - -0.07974, 0.07866, + -0.07974, 0.07866, - -0.41726, 0.49991, -1.55187, -1.14150, - 1.54754, -2.35141, + -0.41726, 0.49991, -1.55187, -1.14150, + 1.54754, -2.35141, - -0.00862, 0.00808, + -0.00862, 0.00808, - 0.00218, -0.03726, + 0.00218, -0.03726, - 0.06914, -0.08986, + 0.06914, -0.08986, - -0.00501, 2.09577, + -0.00501, 2.09577, - -0.01409, -0.01842, + -0.01409, -0.01842, - 0.04138, 0.05961, + 0.04138, 0.05961, - -0.12276, -0.04929, + -0.12276, -0.04929, - -0.03963, -0.06080, + -0.03963, -0.06080, - -0.27697, -0.09329, + -0.27697, -0.09329, - -0.01011, 0.00295, + -0.01011, 0.00295, - -0.01374, 0.01328, + -0.01374, 0.01328, - -0.00171, 0.25815, + -0.00171, 0.25815, - 0.01446, 0.00782, + 0.01446, 0.00782, - 0.17909, -0.04683, + 0.17909, -0.04683, - 0.03765, -0.04990, + 0.03765, -0.04990, - 0.00036, 0.00528, + 0.00036, 0.00528, - 0.05508, -0.01369, + 0.05508, -0.01369, - -0.11751, -0.10624, -0.14448, 0.10522, + -0.11751, -0.10624, -0.14448, 0.10522, - -0.00884, 0.43006, + -0.00884, 0.43006, - 0.01162, 0.01659, + 0.01162, 0.01659, - -0.00076, 0.10143, + -0.00076, 0.10143, - 0.55779, 0.05510, 0.12350, -0.34025, + 0.55779, 0.05510, 0.12350, -0.34025, - 0.01320, 0.92985, + 0.01320, 0.92985, - -0.00026, -0.03426, + -0.00026, -0.03426, - 0.01305, 0.00041, + 0.01305, 0.00041, - 0.13187, -0.11903, + 0.13187, -0.11903, - 0.00058, 0.09877, + 0.00058, 0.09877, - -33.10230, -41.96782, -268.28908, 174.29259, - 731.20089, 1508.07639, 5223.99114, -3008.08849, - -3909.34957, -9646.69156, + -33.10230, -41.96782, -268.28908, 174.29259, + 731.20089, 1508.07639, 5223.99114, -3008.08849, + -3909.34957, -9646.69156, - 0.02988, 0.03182, + 0.02988, 0.03182, - 0.07149, 0.04513, + 0.07149, 0.04513, - -0.02356, -0.01641, + -0.02356, -0.01641, - -0.03188, -0.03711, 0.15084, -0.22436, - 0.61987, 0.25706, + -0.03188, -0.03711, 0.15084, -0.22436, + 0.61987, 0.25706, - 0.02425, 0.01200, + 0.02425, 0.01200, - -0.05543, -0.14435, -0.53398, 0.10997, + -0.05543, -0.14435, -0.53398, 0.10997, - 0.00465, -0.01893, + 0.00465, -0.01893, - 0.01260, -0.01314, + 0.01260, -0.01314, - 0.00650, -0.05499, + 0.00650, -0.05499, - -0.06804, 0.01608, + -0.06804, 0.01608, - 0.02134, 0.04160, + 0.02134, 0.04160, - 0.00636, 0.01293, + 0.00636, 0.01293, - -0.03470, -0.02697, + -0.03470, -0.02697, - -0.11323, 0.02409, + -0.11323, 0.02409, - -0.02618, 0.00827, + -0.02618, 0.00827, - 0.01879, 0.16838, 0.08978, 0.01934, + 0.01879, 0.16838, 0.08978, 0.01934, - -0.23564, 0.05565, + -0.23564, 0.05565, - 0.03686, 0.02644, + 0.03686, 0.02644, - -0.02471, 0.00558, + -0.02471, 0.00558, - -140.22669, -120.40692, -501.88143, 434.05868, - 1044.54998, 1162.72084, 1527.78437, -882.37371, + -140.22669, -120.40692, -501.88143, 434.05868, + 1044.54998, 1162.72084, 1527.78437, -882.37371, - -0.00768, 0.02213, + -0.00768, 0.02213, - -0.04090, 0.16718, + -0.04090, 0.16718, - -0.05923, -0.12595, + -0.05923, -0.12595, - 0.01154, -0.00025, + 0.01154, -0.00025, - -0.00776, -0.01653, + -0.00776, -0.01653, - -0.01213, -0.02773, + -0.01213, -0.02773, - 0.00344, 0.02180, + 0.00344, 0.02180, - -0.02558, -0.05682, + -0.02558, -0.05682, - -0.00490, 0.01050, + -0.00490, 0.01050, - 38.75496, -78.17502, -189.90700, -136.33371, - -249.94062, 319.76423, 205.73478, 272.64549, + 38.75496, -78.17502, -189.90700, -136.33371, + -249.94062, 319.76423, 205.73478, 272.64549, - -0.01132, -0.01071, -0.04607, -0.00390, + -0.01132, -0.01071, -0.04607, -0.00390, - 0.02903, -0.02070, + 0.02903, -0.02070, - 0.01326, -0.00901, + 0.01326, -0.00901, - 35.38435, 7.45358, 31.08987, -70.52685, - -92.13879, -51.58876, -51.80016, 48.98102, + 35.38435, 7.45358, 31.08987, -70.52685, + -92.13879, -51.58876, -51.80016, 48.98102, - -0.00124, -0.01159, + -0.00124, -0.01159, - 0.47335, 13.71886, 23.71637, 5.55804, - 10.06850, -25.65292, -11.85300, -10.20802, + 0.47335, 13.71886, 23.71637, 5.55804, + 10.06850, -25.65292, -11.85300, -10.20802, - -4.72861, 1.27151, -0.47322, 7.46754, - 6.99528, 1.79089, 2.05336, -2.90866, + -4.72861, 1.27151, -0.47322, 7.46754, + 6.99528, 1.79089, 2.05336, -2.90866, - -1.97528, 0.72236, -0.25084, 1.90269, - 0.72127, 0.41354, + -1.97528, 0.72236, -0.25084, 1.90269, + 0.72127, 0.41354, - -0.30286, -0.53125, -0.50883, -0.01200, - -0.08301, 0.18083, + -0.30286, -0.53125, -0.50883, -0.01200, + -0.08301, 0.18083, - -0.04286, -0.10963, -0.04544, -0.01645, + -0.04286, -0.10963, -0.04544, -0.01645, - -0.00013, -0.00986, + -0.00013, -0.00986, }; + static double FAR mertabb[] = { - 68.33369, 422.77623, -2057.26405, -2522.29068, + 68.33369, 422.77623, -2057.26405, -2522.29068, - -0.00030, -0.00009, + -0.00030, -0.00009, - 0.02400, -0.06471, 0.02074, -0.00904, - 0.00044, 0.00261, + 0.02400, -0.06471, 0.02074, -0.00904, + 0.00044, 0.00261, - -0.00174, -0.00088, -0.00027, 0.00003, + -0.00174, -0.00088, -0.00027, 0.00003, - 0.00005, -0.00004, + 0.00005, -0.00004, - -0.00036, 0.00200, + -0.00036, 0.00200, - 0.01432, 0.01199, + 0.01432, 0.01199, - 0.00006, -0.00004, + 0.00006, -0.00004, - 0.00236, 0.00803, 0.01235, 0.00406, - -0.03253, 0.00179, + 0.00236, 0.00803, 0.01235, 0.00406, + -0.03253, 0.00179, - -0.00243, 0.00132, -0.00352, 0.00011, - -0.00146, -0.01154, + -0.00243, 0.00132, -0.00352, 0.00011, + -0.00146, -0.01154, - 0.00824, -0.01195, -0.01829, -0.00465, - 0.12540, 0.09997, + 0.00824, -0.01195, -0.01829, -0.00465, + 0.12540, 0.09997, - 0.00400, 0.00288, -0.02848, 0.01094, - -0.02273, -0.07051, + 0.00400, 0.00288, -0.02848, 0.01094, + -0.02273, -0.07051, - 0.01305, 0.01078, + 0.01305, 0.01078, - -0.00119, 0.00136, -0.00107, -0.00066, + -0.00119, 0.00136, -0.00107, -0.00066, - 0.00097, -0.00315, + 0.00097, -0.00315, - 0.00120, 0.00430, -0.00710, -0.00157, - 0.06052, -0.04777, + 0.00120, 0.00430, -0.00710, -0.00157, + 0.06052, -0.04777, - 0.00192, -0.00229, -0.02077, 0.00647, - 0.06907, 0.07644, + 0.00192, -0.00229, -0.02077, 0.00647, + 0.06907, 0.07644, - -0.00717, 0.00451, + -0.00717, 0.00451, - 0.00052, -0.00262, 0.00345, 0.00039, + 0.00052, -0.00262, 0.00345, 0.00039, - -0.00674, 0.00346, + -0.00674, 0.00346, - -0.02880, 0.00807, + -0.02880, 0.00807, - 0.00054, 0.00206, -0.01745, 0.00517, + 0.00054, 0.00206, -0.01745, 0.00517, - -0.00044, 0.00049, + -0.00044, 0.00049, - 0.01749, 0.01230, + 0.01749, 0.01230, - 0.01703, 0.01563, + 0.01703, 0.01563, - 0.00934, 0.02372, + 0.00934, 0.02372, - 0.01610, -0.01136, + 0.01610, -0.01136, - 0.00186, -0.00503, + 0.00186, -0.00503, - 0.00082, -0.00673, + 0.00082, -0.00673, - 0.00170, -0.00539, + 0.00170, -0.00539, - 0.00042, 0.00037, + 0.00042, 0.00037, - 0.00415, -0.00430, + 0.00415, -0.00430, - 0.00258, -0.00914, -0.01761, -0.00251, - 0.15909, 0.13276, + 0.00258, -0.00914, -0.01761, -0.00251, + 0.15909, 0.13276, - 0.02436, -0.00791, 0.00491, 0.03890, - -0.02982, 0.05645, + 0.02436, -0.00791, 0.00491, 0.03890, + -0.02982, 0.05645, - -0.00003, 0.00427, + -0.00003, 0.00427, - -0.00363, 0.00221, + -0.00363, 0.00221, - 0.00077, 0.00130, + 0.00077, 0.00130, - 0.00131, -0.00071, 0.00796, 0.00453, - 0.01186, 0.01631, + 0.00131, -0.00071, 0.00796, 0.00453, + 0.01186, 0.01631, - 0.12949, -0.02546, 0.03613, 0.32854, - -0.43001, 0.01417, + 0.12949, -0.02546, 0.03613, 0.32854, + -0.43001, 0.01417, - 0.00034, 0.00095, + 0.00034, 0.00095, - -0.03268, 0.04034, 0.11407, 0.15049, + -0.03268, 0.04034, 0.11407, 0.15049, - -0.00079, -0.00052, + -0.00079, -0.00052, - -0.04009, 0.00988, + -0.04009, 0.00988, - -0.00259, -0.00085, 0.00221, -0.00133, + -0.00259, -0.00085, 0.00221, -0.00133, - 0.00003, -0.01733, + 0.00003, -0.01733, - 0.01055, 0.01976, + 0.01055, 0.01976, - 0.00222, 0.00085, + 0.00222, 0.00085, - 0.00089, 0.00087, + 0.00089, 0.00087, - 0.00014, 0.00001, + 0.00014, 0.00001, - 0.00145, 0.00802, + 0.00145, 0.00802, - 0.00122, 0.00068, + 0.00122, 0.00068, - 947.79367, -1654.39690, 542.00864, -1281.09901, - 90.02068, -318.36115, -87.67090, 92.91960, - 376.98232, -419.10705, 5094.60412, 2476.97098, - -18160.57888, 16010.48165, + 947.79367, -1654.39690, 542.00864, -1281.09901, + 90.02068, -318.36115, -87.67090, 92.91960, + 376.98232, -419.10705, 5094.60412, 2476.97098, + -18160.57888, 16010.48165, - 0.00621, -0.00128, + 0.00621, -0.00128, - 0.00186, -0.00153, + 0.00186, -0.00153, - -0.00790, 0.00011, + -0.00790, 0.00011, - -0.00032, 0.00165, + -0.00032, 0.00165, - -0.00277, 0.00539, + -0.00277, 0.00539, - 0.00552, 0.00682, 0.01086, -0.00978, + 0.00552, 0.00682, 0.01086, -0.00978, - -0.02292, -0.01300, 0.02940, -0.04427, + -0.02292, -0.01300, 0.02940, -0.04427, - -0.02051, 0.04860, + -0.02051, 0.04860, - -0.05020, 0.29089, -0.50763, -0.04900, - 0.11177, -0.41357, + -0.05020, 0.29089, -0.50763, -0.04900, + 0.11177, -0.41357, - -0.00222, 0.00504, + -0.00222, 0.00504, - -0.00006, -0.00459, + -0.00006, -0.00459, - -0.00175, -0.02691, + -0.00175, -0.02691, - 0.05921, 0.18938, + 0.05921, 0.18938, - -0.00181, -0.00154, + -0.00181, -0.00154, - 0.00322, 0.00586, + 0.00322, 0.00586, - -0.01098, -0.00520, + -0.01098, -0.00520, - -0.00861, -0.01342, + -0.00861, -0.01342, - -0.02694, -0.00706, + -0.02694, -0.00706, - -0.00103, 0.00012, + -0.00103, 0.00012, - -0.00284, 0.00797, + -0.00284, 0.00797, - 0.00743, 0.02523, + 0.00743, 0.02523, - 0.00872, 0.00096, + 0.00872, 0.00096, - 0.03155, -0.01644, + 0.03155, -0.01644, - 0.00414, -0.00583, + 0.00414, -0.00583, - 0.00029, 0.00066, + 0.00029, 0.00066, - 0.00935, -0.00619, + 0.00935, -0.00619, - -0.02498, -0.01600, -0.03545, 0.07623, + -0.02498, -0.01600, -0.03545, 0.07623, - 0.01649, 0.06498, + 0.01649, 0.06498, - 0.00148, 0.00209, + 0.00148, 0.00209, - 0.00621, 0.02014, + 0.00621, 0.02014, - 0.17407, -0.05022, -0.03485, -0.17012, + 0.17407, -0.05022, -0.03485, -0.17012, - 0.06164, 0.20059, + 0.06164, 0.20059, - -0.00804, -0.01475, + -0.00804, -0.01475, - 0.00296, -0.00068, + 0.00296, -0.00068, - 0.01880, -0.03797, + 0.01880, -0.03797, - 0.00608, 0.02270, + 0.00608, 0.02270, - 5.89651, -6.62562, -37.41057, -10.51542, - -47.22373, 95.76862, 494.45951, -5.37252, - -3991.04809, -2886.97750, + 5.89651, -6.62562, -37.41057, -10.51542, + -47.22373, 95.76862, 494.45951, -5.37252, + -3991.04809, -2886.97750, - 0.01232, 0.00487, + 0.01232, 0.00487, - 0.03163, 0.00561, + 0.03163, 0.00561, - -0.01847, -0.00207, + -0.01847, -0.00207, - -0.10138, 0.01430, -0.04269, -0.22338, - 0.24955, -0.02066, + -0.10138, 0.01430, -0.04269, -0.22338, + 0.24955, -0.02066, - 0.01119, -0.00186, + 0.01119, -0.00186, - 0.03416, 0.01805, -0.12498, 0.10385, + 0.03416, 0.01805, -0.12498, 0.10385, - -0.00210, -0.01011, + -0.00210, -0.01011, - 0.00346, -0.00682, + 0.00346, -0.00682, - -0.00683, -0.02227, + -0.00683, -0.02227, - -0.01649, 0.01259, + -0.01649, 0.01259, - 0.01392, 0.01174, + 0.01392, 0.01174, - 0.00440, 0.00351, + 0.00440, 0.00351, - -0.02871, -0.00375, + -0.02871, -0.00375, - -0.03170, 0.02246, + -0.03170, 0.02246, - -0.00833, 0.00596, + -0.00833, 0.00596, - 0.04081, 0.06666, 0.05400, -0.02387, + 0.04081, 0.06666, 0.05400, -0.02387, - -0.07852, 0.05781, + -0.07852, 0.05781, - 0.01881, 0.00324, + 0.01881, 0.00324, - -0.00868, 0.00606, + -0.00868, 0.00606, - -6.52157, -19.74446, -72.46009, 43.12366, - 321.78233, 215.45201, 452.61804, -1025.05619, + -6.52157, -19.74446, -72.46009, 43.12366, + 321.78233, 215.45201, 452.61804, -1025.05619, - 0.00119, 0.01169, + 0.00119, 0.01169, - 0.02239, 0.09003, + 0.02239, 0.09003, - -0.05329, -0.03974, + -0.05329, -0.03974, - 0.00688, -0.00421, + 0.00688, -0.00421, - -0.00676, -0.00515, + -0.00676, -0.00515, - -0.01171, -0.00952, + -0.01171, -0.00952, - 0.01337, 0.01270, + 0.01337, 0.01270, - -0.02791, -0.02184, + -0.02791, -0.02184, - 0.00058, 0.00679, + 0.00058, 0.00679, - 8.42102, -11.87757, -49.07247, -25.34584, - -43.54829, 161.26509, 261.70993, 56.25777, + 8.42102, -11.87757, -49.07247, -25.34584, + -43.54829, 161.26509, 261.70993, 56.25777, - 0.00568, 0.00871, -0.02656, 0.01582, + 0.00568, 0.00871, -0.02656, 0.01582, - 0.00875, -0.02114, + 0.00875, -0.02114, - 0.00464, -0.01075, + 0.00464, -0.01075, - 9.08966, 1.37810, 3.44548, -27.44651, - -59.62749, -0.73611, -0.77613, 65.72607, + 9.08966, 1.37810, 3.44548, -27.44651, + -59.62749, -0.73611, -0.77613, 65.72607, - -0.00664, -0.00723, + -0.00664, -0.00723, - 1.04214, 4.78920, 11.67397, -1.84524, - -4.16685, -19.14211, -16.14483, 3.02496, + 1.04214, 4.78920, 11.67397, -1.84524, + -4.16685, -19.14211, -16.14483, 3.02496, - -1.98140, 1.16261, 1.81526, 4.21224, - 5.59020, -2.55741, -1.54151, -3.85817, + -1.98140, 1.16261, 1.81526, 4.21224, + 5.59020, -2.55741, -1.54151, -3.85817, - -1.08723, 1.23372, 1.12378, 1.51554, - 0.88937, -0.57631, + -1.08723, 1.23372, 1.12378, 1.51554, + 0.88937, -0.57631, - -0.50549, -0.25617, -0.37618, 0.42163, - 0.18902, 0.19575, + -0.50549, -0.25617, -0.37618, 0.42163, + 0.18902, 0.19575, - -0.15402, -0.04062, -0.04017, 0.05717, + -0.15402, -0.04062, -0.04017, 0.05717, - -0.01665, -0.00199, + -0.01665, -0.00199, }; + static double FAR mertabr[] = { - -8.30490, -11.68232, 86.54880, 4361.05018, + -8.30490, -11.68232, 86.54880, 4361.05018, - 0.00002, -0.00001, + 0.00002, -0.00001, - -0.01102, 0.00410, 0.00007, -0.00276, - 0.00117, 0.00082, + -0.01102, 0.00410, 0.00007, -0.00276, + 0.00117, 0.00082, - 0.00049, 0.00007, 0.00003, -0.00001, + 0.00049, 0.00007, 0.00003, -0.00001, - 0.00012, 0.00005, + 0.00012, 0.00005, - -0.00186, -0.00534, + -0.00186, -0.00534, - -0.03301, 0.01808, + -0.03301, 0.01808, - 0.00008, 0.00005, + 0.00008, 0.00005, - -0.00394, 0.00202, 0.02362, -0.00359, - 0.00638, -0.06767, + -0.00394, 0.00202, 0.02362, -0.00359, + 0.00638, -0.06767, - 0.00422, -0.00493, 0.00660, 0.00513, - -0.00417, 0.00708, + 0.00422, -0.00493, 0.00660, 0.00513, + -0.00417, 0.00708, - 0.05849, -0.00213, -0.07647, -0.16162, - -0.30551, 0.13856, + 0.05849, -0.00213, -0.07647, -0.16162, + -0.30551, 0.13856, - -0.02789, 0.01811, -0.04155, -0.06229, - 0.05729, -0.03694, + -0.02789, 0.01811, -0.04155, -0.06229, + 0.05729, -0.03694, - -0.03087, 0.01610, + -0.03087, 0.01610, - -0.00297, -0.00167, 0.00041, -0.00157, + -0.00297, -0.00167, 0.00041, -0.00157, - -0.00115, 0.00058, + -0.00115, 0.00058, - 0.00796, 0.00436, -0.01393, 0.02921, - -0.05902, -0.02363, + 0.00796, 0.00436, -0.01393, 0.02921, + -0.05902, -0.02363, - 0.00459, -0.01512, 0.10038, 0.02964, - -0.08369, 0.34570, + 0.00459, -0.01512, 0.10038, 0.02964, + -0.08369, 0.34570, - -0.00749, -0.02653, + -0.00749, -0.02653, - 0.01361, -0.00326, 0.00406, 0.00952, + 0.01361, -0.00326, 0.00406, 0.00952, - -0.00594, -0.00829, + -0.00594, -0.00829, - -0.02763, -0.09933, + -0.02763, -0.09933, - -0.04143, 0.05152, -0.08436, -0.05294, + -0.04143, 0.05152, -0.08436, -0.05294, - -0.00329, -0.00016, + -0.00329, -0.00016, - -0.04340, 0.02566, + -0.04340, 0.02566, - -0.03027, 0.10904, + -0.03027, 0.10904, - 0.03665, -0.03070, + 0.03665, -0.03070, - 0.23525, 0.00182, + 0.23525, 0.00182, - 0.03092, -0.02212, + 0.03092, -0.02212, - 0.01255, 0.00777, + 0.01255, 0.00777, - -0.01025, 0.00042, + -0.01025, 0.00042, - -0.00065, 0.00440, + -0.00065, 0.00440, - 0.08688, 0.00136, + 0.08688, 0.00136, - 0.05700, -0.03616, -0.11272, -0.20838, - -0.37048, 0.18314, + 0.05700, -0.03616, -0.11272, -0.20838, + -0.37048, 0.18314, - 0.00717, -0.02911, 0.15848, 0.05266, - -0.13451, 0.51639, + 0.00717, -0.02911, 0.15848, 0.05266, + -0.13451, 0.51639, - 0.00688, 0.02029, + 0.00688, 0.02029, - 0.00596, 0.00423, + 0.00596, 0.00423, - -0.00253, 0.01196, + -0.00253, 0.01196, - 0.05264, -0.03301, 0.10669, 0.07558, - -0.02461, 0.16282, + 0.05264, -0.03301, 0.10669, 0.07558, + -0.02461, 0.16282, - -0.18481, -0.57118, 0.85303, -0.44876, - 0.37090, 0.65915, + -0.18481, -0.57118, 0.85303, -0.44876, + 0.37090, 0.65915, - -0.00458, 0.00660, + -0.00458, 0.00660, - 0.41186, 0.09829, -0.31999, 1.51149, + 0.41186, 0.09829, -0.31999, 1.51149, - -0.00052, -0.00809, + -0.00052, -0.00809, - 0.01384, -0.07114, + 0.01384, -0.07114, - -0.00435, -0.03237, 0.02162, 0.00294, + -0.00435, -0.03237, 0.02162, 0.00294, - 0.29742, -0.15430, + 0.29742, -0.15430, - -0.04508, 0.17436, + -0.04508, 0.17436, - 0.01577, 0.00485, + 0.01577, 0.00485, - -0.00258, 0.00946, + -0.00258, 0.00946, - 0.00061, 0.00119, + 0.00061, 0.00119, - 0.01095, -0.00788, + 0.01095, -0.00788, - 0.00530, -0.01478, + 0.00530, -0.01478, - 2885.06380, 2152.76256, 2361.91098, 1442.28586, - 602.45147, 251.18991, -121.68155, 71.20167, - 404.94753, 1607.37580, 11211.04090, -2905.37340, - -9066.27933, -40747.62807, + 2885.06380, 2152.76256, 2361.91098, 1442.28586, + 602.45147, 251.18991, -121.68155, 71.20167, + 404.94753, 1607.37580, 11211.04090, -2905.37340, + -9066.27933, -40747.62807, - -0.00189, 0.00957, + -0.00189, 0.00957, - 0.00332, 0.00907, + 0.00332, 0.00907, - 0.00574, -0.01255, + 0.00574, -0.01255, - -0.01134, 0.00291, + -0.01134, 0.00291, - -0.00666, -0.00615, + -0.00666, -0.00615, - -0.04947, 0.06182, 0.03965, 0.08091, + -0.04947, 0.06182, 0.03965, 0.08091, - 0.06846, -0.03612, 0.13966, 0.12543, + 0.06846, -0.03612, 0.13966, 0.12543, - -0.05494, -0.05043, + -0.05494, -0.05043, - -0.24454, -0.20507, 0.56201, -0.75997, - 1.15728, 0.76203, + -0.24454, -0.20507, 0.56201, -0.75997, + 1.15728, 0.76203, - -0.00559, -0.00536, + -0.00559, -0.00536, - 0.01872, 0.00104, + 0.01872, 0.00104, - 0.03044, 0.02504, + 0.03044, 0.02504, - -1.07241, -0.00288, + -1.07241, -0.00288, - 0.00950, -0.00760, + 0.00950, -0.00760, - -0.03211, 0.02261, + -0.03211, 0.02261, - 0.02678, -0.06868, + 0.02678, -0.06868, - 0.03008, -0.02062, + 0.03008, -0.02062, - 0.04997, -0.15164, + 0.04997, -0.15164, - -0.00176, -0.00580, + -0.00176, -0.00580, - -0.00730, -0.00676, + -0.00730, -0.00676, - -0.13906, -0.00089, + -0.13906, -0.00089, - -0.00362, 0.00817, + -0.00362, 0.00817, - 0.02021, 0.07719, + 0.02021, 0.07719, - 0.02788, 0.02061, + 0.02788, 0.02061, - -0.00274, 0.00016, + -0.00274, 0.00016, - 0.00566, 0.02293, + 0.00566, 0.02293, - 0.04691, -0.05005, -0.05095, -0.06225, + 0.04691, -0.05005, -0.05095, -0.06225, - -0.19770, -0.00456, + -0.19770, -0.00456, - -0.00848, 0.00595, + -0.00848, 0.00595, - -0.04506, -0.00172, + -0.04506, -0.00172, - -0.01960, 0.22971, 0.14459, 0.04362, + -0.01960, 0.22971, 0.14459, 0.04362, - -0.40199, 0.00386, + -0.40199, 0.00386, - 0.01442, -0.00088, + 0.01442, -0.00088, - -0.00020, 0.00544, + -0.00020, 0.00544, - 0.04768, 0.05222, + 0.04768, 0.05222, - -0.04069, -0.00003, + -0.04069, -0.00003, - 15.71084, -12.28846, -66.23443, -109.83758, - -586.31996, 311.09606, 1070.75040, 2094.34080, - 3839.04103, -1797.34193, + 15.71084, -12.28846, -66.23443, -109.83758, + -586.31996, 311.09606, 1070.75040, 2094.34080, + 3839.04103, -1797.34193, - -0.01216, 0.01244, + -0.01216, 0.01244, - -0.01666, 0.02627, + -0.01666, 0.02627, - 0.00687, -0.01291, + 0.00687, -0.01291, - 0.00939, -0.01905, 0.09401, 0.05027, - -0.09398, 0.23942, + 0.00939, -0.01905, 0.09401, 0.05027, + -0.09398, 0.23942, - -0.00379, 0.00834, + -0.00379, 0.00834, - 0.05632, -0.01907, -0.04654, -0.21243, + 0.05632, -0.01907, -0.04654, -0.21243, - 0.00255, 0.00179, + 0.00255, 0.00179, - 0.00540, 0.00497, + 0.00540, 0.00497, - 0.01427, 0.00243, + 0.01427, 0.00243, - -0.00697, -0.02792, + -0.00697, -0.02792, - -0.01524, 0.00810, + -0.01524, 0.00810, - -0.00461, 0.00238, + -0.00461, 0.00238, - 0.00899, -0.01515, + 0.00899, -0.01515, - -0.01011, -0.04390, + -0.01011, -0.04390, - -0.00447, -0.00992, + -0.00447, -0.00992, - -0.06110, 0.00975, -0.00261, 0.03415, + -0.06110, 0.00975, -0.00261, 0.03415, - -0.02336, -0.08776, + -0.02336, -0.08776, - -0.00883, 0.01346, + -0.00883, 0.01346, - -0.00229, -0.00895, + -0.00229, -0.00895, - 42.18049, -48.21316, -148.61588, -171.57236, - -414.27195, 343.09118, 394.59044, 511.79914, + 42.18049, -48.21316, -148.61588, -171.57236, + -414.27195, 343.09118, 394.59044, 511.79914, - -0.00911, -0.00220, + -0.00911, -0.00220, - -0.06315, -0.00988, + -0.06315, -0.00988, - 0.04357, -0.02389, + 0.04357, -0.02389, - 0.00004, 0.00232, + 0.00004, 0.00232, - 0.00581, -0.00317, + 0.00581, -0.00317, - 0.00948, -0.00497, + 0.00948, -0.00497, - -0.00734, 0.00300, + -0.00734, 0.00300, - 0.01883, -0.01055, + 0.01883, -0.01055, - -0.00365, -0.00126, + -0.00365, -0.00126, - 24.18074, 12.28004, 43.18187, -58.69806, - -102.40566, -79.48349, -74.81060, 89.71332, + 24.18074, 12.28004, 43.18187, -58.69806, + -102.40566, -79.48349, -74.81060, 89.71332, - 0.00241, -0.00135, -0.00136, -0.01617, + 0.00241, -0.00135, -0.00136, -0.01617, - 0.00818, 0.00873, + 0.00818, 0.00873, - 0.00368, 0.00383, + 0.00368, 0.00383, - -2.25893, 10.18542, 20.73104, 9.07389, - 13.73458, -29.10491, -20.62071, -10.63404, + -2.25893, 10.18542, 20.73104, 9.07389, + 13.73458, -29.10491, -20.62071, -10.63404, - 0.00382, -0.00143, + 0.00382, -0.00143, - -3.77385, 0.12725, -1.30842, 6.75795, - 7.94463, 1.79092, 1.24458, -4.73211, + -3.77385, 0.12725, -1.30842, 6.75795, + 7.94463, 1.79092, 1.24458, -4.73211, - -0.36978, -1.25710, -2.06373, 0.06194, - -0.00509, 2.08851, 1.07491, 0.04112, + -0.36978, -1.25710, -2.06373, 0.06194, + -0.00509, 2.08851, 1.07491, 0.04112, - -0.28582, -0.51413, -0.53312, 0.11936, - 0.04447, 0.23945, + -0.28582, -0.51413, -0.53312, 0.11936, + 0.04447, 0.23945, - 0.12450, -0.11821, -0.06100, -0.12924, - -0.05193, 0.02219, + 0.12450, -0.11821, -0.06100, -0.12924, + -0.05193, 0.02219, - 0.01977, -0.02933, -0.00771, -0.01077, + 0.01977, -0.02933, -0.00771, -0.01077, - 0.00109, -0.00273, + 0.00109, -0.00273, }; static signed char FAR merargs[] = { - 0, 3, - 3, 1, 1,-10, 3, 11, 4, 0, - 2, 2, 5, -5, 6, 2, - 3, 5, 1,-14, 2, 2, 3, 1, - 3, 1, 1, -5, 2, 4, 3, 0, - 1, 1, 6, 0, - 1, 2, 6, 0, - 3, 2, 1, -7, 2, 3, 3, 0, - 1, 1, 5, 2, - 2, 1, 1, -4, 3, 2, - 1, 2, 5, 2, - 2, 2, 1, -5, 2, 2, - 1, 3, 5, 0, - 2, 4, 1,-10, 2, 1, - 2, 3, 1, -8, 2, 0, - 2, 1, 1, -3, 2, 2, - 2, 1, 1, -2, 2, 2, - 1, 1, 3, 0, - 2, 3, 1, -7, 2, 1, - 2, 1, 1, -3, 3, 0, - 1, 1, 2, 0, - 2, 2, 1, -4, 2, 1, - 2, 4, 1, -9, 2, 0, - 1, 2, 3, 0, - 2, 1, 1, -2, 3, 0, - 2, 1, 1, -4, 2, 0, - 2, 1, 1, -1, 2, 0, - 2, 3, 1, -6, 2, 0, - 1, 3, 3, 0, - 2, 2, 1, -7, 2, 0, - 2, 1, 1, -2, 4, 0, - 2, 1, 1, -1, 3, 0, - 1, 2, 2, 2, - 2, 2, 1, -3, 2, 2, - 2, 4, 1, -8, 2, 0, - 2, 3, 1,-10, 2, 0, - 2, 1, 1, -4, 5, 0, - 2, 1, 1, -3, 5, 2, - 2, 1, 1, -5, 2, 2, - 2, 1, 1, -5, 6, 0, - 2, 1, 1, -2, 5, 1, - 3, 1, 1, -4, 5, 5, 6, 0, - 1, 4, 3, 0, - 2, 1, 1, -3, 6, 1, - 2, 1, 1, -1, 5, 0, - 2, 1, 1, -2, 6, 0, - 2, 1, 1, -1, 6, 0, - 2, 1, 1, -2, 7, 0, - 2, 1, 1, -1, 7, 0, - 3, 4, 1,-14, 2, 2, 3, 0, - 3, 1, 1, 2, 5, -5, 6, 0, - 1, 1, 1, 6, - 3, 2, 1,-10, 3, 11, 4, 0, - 3, 1, 1, -2, 5, 5, 6, 0, - 3, 6, 1,-14, 2, 2, 3, 0, - 2, 1, 1, 1, 6, 0, - 2, 1, 1, 2, 6, 0, - 2, 1, 1, 1, 5, 1, - 2, 2, 1, -4, 3, 1, - 2, 1, 1, 2, 5, 0, - 2, 3, 1, -5, 2, 2, - 2, 1, 1, 3, 5, 0, - 2, 5, 1,-10, 2, 0, - 1, 3, 2, 0, - 2, 2, 1, -2, 2, 0, - 2, 1, 1, 1, 3, 0, - 2, 4, 1, -7, 2, 0, - 2, 2, 1, -3, 3, 0, - 2, 1, 1, 1, 2, 0, - 2, 3, 1, -4, 2, 0, - 2, 5, 1, -9, 2, 0, - 2, 1, 1, 2, 3, 0, - 2, 2, 1, -2, 3, 0, - 1, 4, 2, 0, - 2, 2, 1, -1, 2, 0, - 2, 4, 1, -6, 2, 0, - 2, 2, 1, -2, 4, 0, - 2, 2, 1, -1, 3, 0, - 2, 1, 1, 2, 2, 1, - 2, 3, 1, -3, 2, 0, - 2, 5, 1, -8, 2, 0, - 2, 2, 1, -3, 5, 0, - 1, 5, 2, 1, - 2, 2, 1, -2, 5, 0, - 2, 1, 1, 4, 3, 0, - 2, 2, 1, -3, 6, 0, - 2, 2, 1, -1, 5, 0, - 2, 2, 1, -2, 6, 0, - 1, 2, 1, 4, - 2, 2, 1, 1, 5, 0, - 2, 3, 1, -4, 3, 0, - 2, 2, 1, 2, 5, 0, - 2, 4, 1, -5, 2, 2, - 2, 1, 1, 3, 2, 0, - 2, 3, 1, -2, 2, 1, - 2, 3, 1, -3, 3, 0, - 2, 2, 1, 1, 2, 0, - 2, 4, 1, -4, 2, 0, - 2, 3, 1, -2, 3, 0, - 2, 3, 1, -1, 2, 0, - 2, 3, 1, -1, 3, 0, - 2, 2, 1, 2, 2, 0, - 2, 4, 1, -3, 2, 0, - 2, 3, 1, -3, 5, 0, - 2, 1, 1, 5, 2, 1, - 2, 3, 1, -2, 5, 0, - 2, 3, 1, -1, 5, 0, - 2, 3, 1, -2, 6, 0, - 1, 3, 1, 3, - 2, 4, 1, -4, 3, 0, - 2, 5, 1, -5, 2, 0, - 2, 4, 1, -2, 2, 0, - 2, 5, 1, -4, 2, 0, - 2, 4, 1, -2, 3, 0, - 2, 5, 1, -3, 2, 0, - 2, 2, 1, 5, 2, 0, - 2, 4, 1, -2, 5, 0, - 2, 4, 1, -1, 5, 0, - 1, 4, 1, 3, - 2, 6, 1, -5, 2, 1, - 2, 5, 1, -2, 2, 0, - 2, 5, 1, -2, 5, 0, - 1, 5, 1, 3, - 2, 7, 1, -5, 2, 0, - 1, 6, 1, 3, - 1, 7, 1, 3, - 1, 8, 1, 2, - 1, 9, 1, 2, - 1, 10, 1, 1, - 1, 11, 1, 0, - -1 + 0, 3, + 3, 1, 1, -10, 3, 11, 4, 0, + 2, 2, 5, -5, 6, 2, + 3, 5, 1, -14, 2, 2, 3, 1, + 3, 1, 1, -5, 2, 4, 3, 0, + 1, 1, 6, 0, + 1, 2, 6, 0, + 3, 2, 1, -7, 2, 3, 3, 0, + 1, 1, 5, 2, + 2, 1, 1, -4, 3, 2, + 1, 2, 5, 2, + 2, 2, 1, -5, 2, 2, + 1, 3, 5, 0, + 2, 4, 1, -10, 2, 1, + 2, 3, 1, -8, 2, 0, + 2, 1, 1, -3, 2, 2, + 2, 1, 1, -2, 2, 2, + 1, 1, 3, 0, + 2, 3, 1, -7, 2, 1, + 2, 1, 1, -3, 3, 0, + 1, 1, 2, 0, + 2, 2, 1, -4, 2, 1, + 2, 4, 1, -9, 2, 0, + 1, 2, 3, 0, + 2, 1, 1, -2, 3, 0, + 2, 1, 1, -4, 2, 0, + 2, 1, 1, -1, 2, 0, + 2, 3, 1, -6, 2, 0, + 1, 3, 3, 0, + 2, 2, 1, -7, 2, 0, + 2, 1, 1, -2, 4, 0, + 2, 1, 1, -1, 3, 0, + 1, 2, 2, 2, + 2, 2, 1, -3, 2, 2, + 2, 4, 1, -8, 2, 0, + 2, 3, 1, -10, 2, 0, + 2, 1, 1, -4, 5, 0, + 2, 1, 1, -3, 5, 2, + 2, 1, 1, -5, 2, 2, + 2, 1, 1, -5, 6, 0, + 2, 1, 1, -2, 5, 1, + 3, 1, 1, -4, 5, 5, 6, 0, + 1, 4, 3, 0, + 2, 1, 1, -3, 6, 1, + 2, 1, 1, -1, 5, 0, + 2, 1, 1, -2, 6, 0, + 2, 1, 1, -1, 6, 0, + 2, 1, 1, -2, 7, 0, + 2, 1, 1, -1, 7, 0, + 3, 4, 1, -14, 2, 2, 3, 0, + 3, 1, 1, 2, 5, -5, 6, 0, + 1, 1, 1, 6, + 3, 2, 1, -10, 3, 11, 4, 0, + 3, 1, 1, -2, 5, 5, 6, 0, + 3, 6, 1, -14, 2, 2, 3, 0, + 2, 1, 1, 1, 6, 0, + 2, 1, 1, 2, 6, 0, + 2, 1, 1, 1, 5, 1, + 2, 2, 1, -4, 3, 1, + 2, 1, 1, 2, 5, 0, + 2, 3, 1, -5, 2, 2, + 2, 1, 1, 3, 5, 0, + 2, 5, 1, -10, 2, 0, + 1, 3, 2, 0, + 2, 2, 1, -2, 2, 0, + 2, 1, 1, 1, 3, 0, + 2, 4, 1, -7, 2, 0, + 2, 2, 1, -3, 3, 0, + 2, 1, 1, 1, 2, 0, + 2, 3, 1, -4, 2, 0, + 2, 5, 1, -9, 2, 0, + 2, 1, 1, 2, 3, 0, + 2, 2, 1, -2, 3, 0, + 1, 4, 2, 0, + 2, 2, 1, -1, 2, 0, + 2, 4, 1, -6, 2, 0, + 2, 2, 1, -2, 4, 0, + 2, 2, 1, -1, 3, 0, + 2, 1, 1, 2, 2, 1, + 2, 3, 1, -3, 2, 0, + 2, 5, 1, -8, 2, 0, + 2, 2, 1, -3, 5, 0, + 1, 5, 2, 1, + 2, 2, 1, -2, 5, 0, + 2, 1, 1, 4, 3, 0, + 2, 2, 1, -3, 6, 0, + 2, 2, 1, -1, 5, 0, + 2, 2, 1, -2, 6, 0, + 1, 2, 1, 4, + 2, 2, 1, 1, 5, 0, + 2, 3, 1, -4, 3, 0, + 2, 2, 1, 2, 5, 0, + 2, 4, 1, -5, 2, 2, + 2, 1, 1, 3, 2, 0, + 2, 3, 1, -2, 2, 1, + 2, 3, 1, -3, 3, 0, + 2, 2, 1, 1, 2, 0, + 2, 4, 1, -4, 2, 0, + 2, 3, 1, -2, 3, 0, + 2, 3, 1, -1, 2, 0, + 2, 3, 1, -1, 3, 0, + 2, 2, 1, 2, 2, 0, + 2, 4, 1, -3, 2, 0, + 2, 3, 1, -3, 5, 0, + 2, 1, 1, 5, 2, 1, + 2, 3, 1, -2, 5, 0, + 2, 3, 1, -1, 5, 0, + 2, 3, 1, -2, 6, 0, + 1, 3, 1, 3, + 2, 4, 1, -4, 3, 0, + 2, 5, 1, -5, 2, 0, + 2, 4, 1, -2, 2, 0, + 2, 5, 1, -4, 2, 0, + 2, 4, 1, -2, 3, 0, + 2, 5, 1, -3, 2, 0, + 2, 2, 1, 5, 2, 0, + 2, 4, 1, -2, 5, 0, + 2, 4, 1, -1, 5, 0, + 1, 4, 1, 3, + 2, 6, 1, -5, 2, 1, + 2, 5, 1, -2, 2, 0, + 2, 5, 1, -2, 5, 0, + 1, 5, 1, 3, + 2, 7, 1, -5, 2, 0, + 1, 6, 1, 3, + 1, 7, 1, 3, + 1, 8, 1, 2, + 1, 9, 1, 2, + 1, 10, 1, 1, + 1, 11, 1, 0, + -1 }; + /* Total terms = 130, small = 128 */ static struct plantbl FAR mer404 = { - { 11, 14, 10, 11, 4, 5, 2, 0, 0,}, - 6, - merargs, - mertabl, - mertabb, - mertabr, - 3.8709830979999998e-01, + {11, 14, 10, 11, 4, 5, 2, 0, 0,}, + 6, + merargs, + mertabl, + mertabb, + mertabr, + 3.8709830979999998e-01, }; @@ -1101,810 +1106,813 @@ Days per record = 4.0 3000.0 to 3000.8: 0.116 0.062 0.058 */ static double FAR ventabl[] = { - 9.08078, 55.42416, 21066413644.98911, 655127.20186, + 9.08078, 55.42416, 21066413644.98911, 655127.20186, - 0.00329, 0.10408, + 0.00329, 0.10408, - 0.00268, -0.01908, + 0.00268, -0.01908, - 0.00653, 0.00183, + 0.00653, 0.00183, - 0.15083, -0.21997, + 0.15083, -0.21997, - 6.08596, 2.34841, 3.70668, -0.22740, - -2.29376, -1.46741, + 6.08596, 2.34841, 3.70668, -0.22740, + -2.29376, -1.46741, - -0.03840, 0.01242, + -0.03840, 0.01242, - 0.00176, 0.00913, + 0.00176, 0.00913, - 0.00121, -0.01222, + 0.00121, -0.01222, - -1.22624, 0.65264, -1.15974, -1.28172, - 1.00656, -0.66266, + -1.22624, 0.65264, -1.15974, -1.28172, + 1.00656, -0.66266, - 0.01560, -0.00654, 0.00896, 0.00069, + 0.01560, -0.00654, 0.00896, 0.00069, - 0.21649, -0.01786, + 0.21649, -0.01786, - 0.01239, 0.00255, + 0.01239, 0.00255, - 0.00084, -0.06086, + 0.00084, -0.06086, - -0.00041, 0.00887, + -0.00041, 0.00887, - 0.13453, -0.20013, 0.08234, 0.01575, + 0.13453, -0.20013, 0.08234, 0.01575, - 0.00658, -0.00214, + 0.00658, -0.00214, - 0.00254, 0.00857, + 0.00254, 0.00857, - -0.01047, -0.00519, + -0.01047, -0.00519, - 0.63215, -0.40914, 0.34271, -1.53258, + 0.63215, -0.40914, 0.34271, -1.53258, - 0.00038, -0.01437, + 0.00038, -0.01437, - -0.02599, -2.27805, -0.36873, -1.01799, - -0.36798, 1.41356, + -0.02599, -2.27805, -0.36873, -1.01799, + -0.36798, 1.41356, - -0.08167, 0.01368, 0.20676, 0.06807, + -0.08167, 0.01368, 0.20676, 0.06807, - 0.02282, -0.04691, + 0.02282, -0.04691, - 0.30308, -0.20218, 0.24785, 0.27522, + 0.30308, -0.20218, 0.24785, 0.27522, - 0.00197, -0.00499, + 0.00197, -0.00499, - 1.43909, -0.46154, 0.93459, 2.99583, - -3.43274, 0.05672, + 1.43909, -0.46154, 0.93459, 2.99583, + -3.43274, 0.05672, - -0.06586, 0.12467, 0.02505, -0.08433, + -0.06586, 0.12467, 0.02505, -0.08433, - 0.00743, 0.00174, + 0.00743, 0.00174, - -0.04013, 0.17715, + -0.04013, 0.17715, - -0.00603, -0.01024, + -0.00603, -0.01024, - 0.01542, -0.02378, + 0.01542, -0.02378, - 0.00676, 0.00002, + 0.00676, 0.00002, - -0.00168, -4.89487, + -0.00168, -4.89487, - 0.02393, -0.03064, + 0.02393, -0.03064, - 0.00090, 0.00977, + 0.00090, 0.00977, - 0.01223, 0.00381, + 0.01223, 0.00381, - 0.28135, -0.09158, 0.18550, 0.58372, - -0.67437, 0.01409, + 0.28135, -0.09158, 0.18550, 0.58372, + -0.67437, 0.01409, - -0.25404, -0.06863, + -0.25404, -0.06863, - 0.06763, -0.02939, + 0.06763, -0.02939, - -0.00009, -0.04888, + -0.00009, -0.04888, - 0.01718, -0.00978, + 0.01718, -0.00978, - -0.01945, 0.08847, + -0.01945, 0.08847, - -0.00135, -11.29920, + -0.00135, -11.29920, - 0.01689, -0.04756, + 0.01689, -0.04756, - 0.02075, -0.01667, + 0.02075, -0.01667, - 0.01397, 0.00443, + 0.01397, 0.00443, - -0.28437, 0.07600, 0.17996, -0.44326, + -0.28437, 0.07600, 0.17996, -0.44326, - 0.29356, 1.41869, -1.58617, 0.03206, + 0.29356, 1.41869, -1.58617, 0.03206, - 0.00229, -0.00753, + 0.00229, -0.00753, - -0.03076, -2.96766, + -0.03076, -2.96766, - 0.00245, 0.00697, + 0.00245, 0.00697, - 0.01063, -0.02468, + 0.01063, -0.02468, - -0.00351, -0.18179, + -0.00351, -0.18179, - -0.01088, 0.00380, + -0.01088, 0.00380, - 0.00496, 0.02072, + 0.00496, 0.02072, - -0.12890, 0.16719, -0.06820, -0.03234, + -0.12890, 0.16719, -0.06820, -0.03234, - -60.36135, -11.74485, -11.03752, -3.80145, - -21.33955, -284.54495, -763.43839, 248.50823, - 1493.02775, 1288.79621, -2091.10921, -1851.15420, + -60.36135, -11.74485, -11.03752, -3.80145, + -21.33955, -284.54495, -763.43839, 248.50823, + 1493.02775, 1288.79621, -2091.10921, -1851.15420, - -0.00922, 0.06233, + -0.00922, 0.06233, - 0.00004, 0.00785, + 0.00004, 0.00785, - 0.10363, -0.16770, 0.45497, 0.24051, - -0.28057, 0.61126, + 0.10363, -0.16770, 0.45497, 0.24051, + -0.28057, 0.61126, - -0.02057, 0.00010, + -0.02057, 0.00010, - 0.00561, 0.01994, + 0.00561, 0.01994, - 0.01416, -0.00442, + 0.01416, -0.00442, - 0.03073, -0.14961, + 0.03073, -0.14961, - -0.06272, 0.08301, + -0.06272, 0.08301, - 0.02040, 7.12824, + 0.02040, 7.12824, - -0.00453, -0.01815, + -0.00453, -0.01815, - 0.00004, -0.00013, + 0.00004, -0.00013, - -0.03593, -0.18147, 0.20353, -0.00683, + -0.03593, -0.18147, 0.20353, -0.00683, - 0.00003, 0.06226, + 0.00003, 0.06226, - -0.00443, 0.00257, + -0.00443, 0.00257, - 0.03194, 0.03254, + 0.03194, 0.03254, - 0.00282, -0.01401, + 0.00282, -0.01401, - 0.00422, 1.03169, + 0.00422, 1.03169, - -0.00169, -0.00591, + -0.00169, -0.00591, - -0.00307, 0.00540, + -0.00307, 0.00540, - 0.05511, 0.00347, + 0.05511, 0.00347, - 0.07896, 0.06583, + 0.07896, 0.06583, - 0.00783, 0.01926, + 0.00783, 0.01926, - 0.03109, 0.15967, + 0.03109, 0.15967, - 0.00343, 0.88734, + 0.00343, 0.88734, - 0.01047, 0.32054, + 0.01047, 0.32054, - 0.00814, 0.00051, + 0.00814, 0.00051, - 0.02474, 0.00047, + 0.02474, 0.00047, - 0.00052, 0.03763, + 0.00052, 0.03763, - -57.06618, 20.34614, -45.06541, -115.20465, - 136.46887, -84.67046, 92.93308, 160.44644, + -57.06618, 20.34614, -45.06541, -115.20465, + 136.46887, -84.67046, 92.93308, 160.44644, - -0.00020, -0.00082, + -0.00020, -0.00082, - 0.02496, 0.00279, + 0.02496, 0.00279, - 0.00849, 0.00195, + 0.00849, 0.00195, - -0.05013, -0.04331, + -0.05013, -0.04331, - -0.00136, 0.14491, + -0.00136, 0.14491, - -0.00183, -0.00406, + -0.00183, -0.00406, - 0.01163, 0.00093, + 0.01163, 0.00093, - -0.00604, -0.00680, + -0.00604, -0.00680, - -0.00036, 0.06861, + -0.00036, 0.06861, - -0.00450, -0.00969, + -0.00450, -0.00969, - 0.00171, 0.00979, + 0.00171, 0.00979, - -0.00152, 0.03929, + -0.00152, 0.03929, - 0.00631, 0.00048, + 0.00631, 0.00048, - -0.00709, -0.00864, + -0.00709, -0.00864, - 1.51002, -0.24657, 1.27338, 2.64699, - -2.40990, -0.57413, + 1.51002, -0.24657, 1.27338, 2.64699, + -2.40990, -0.57413, - -0.00023, 0.03528, + -0.00023, 0.03528, - 0.00268, 0.00522, + 0.00268, 0.00522, - -0.00010, 0.01933, + -0.00010, 0.01933, - -0.00006, 0.01100, + -0.00006, 0.01100, - 0.06313, -0.09939, 0.08571, 0.03206, + 0.06313, -0.09939, 0.08571, 0.03206, - -0.00004, 0.00645, + -0.00004, 0.00645, }; + static double FAR ventabb[] = { - -23.91858, 31.44154, 25.93273, -67.68643, + -23.91858, 31.44154, 25.93273, -67.68643, - -0.00171, 0.00123, + -0.00171, 0.00123, - 0.00001, -0.00018, + 0.00001, -0.00018, - -0.00005, 0.00018, + -0.00005, 0.00018, - -0.00001, 0.00019, + -0.00001, 0.00019, - 0.00733, 0.00030, -0.00038, 0.00011, - 0.00181, 0.00120, + 0.00733, 0.00030, -0.00038, 0.00011, + 0.00181, 0.00120, - 0.00010, 0.00002, + 0.00010, 0.00002, - -0.00012, 0.00002, + -0.00012, 0.00002, - 0.00021, 0.00004, + 0.00021, 0.00004, - -0.00403, 0.00101, 0.00342, -0.00328, - 0.01564, 0.01212, + -0.00403, 0.00101, 0.00342, -0.00328, + 0.01564, 0.01212, - 0.00011, 0.00010, -0.00002, -0.00004, + 0.00011, 0.00010, -0.00002, -0.00004, - -0.00524, 0.00079, + -0.00524, 0.00079, - 0.00011, 0.00002, + 0.00011, 0.00002, - -0.00001, 0.00003, + -0.00001, 0.00003, - 0.00001, 0.00000, + 0.00001, 0.00000, - 0.00108, 0.00035, 0.00003, 0.00064, + 0.00108, 0.00035, 0.00003, 0.00064, - -0.00000, -0.00002, + -0.00000, -0.00002, - -0.00069, 0.00031, + -0.00069, 0.00031, - 0.00020, 0.00003, + 0.00020, 0.00003, - 0.00768, 0.03697, -0.07906, 0.01673, + 0.00768, 0.03697, -0.07906, 0.01673, - -0.00003, -0.00001, + -0.00003, -0.00001, - -0.00198, -0.01045, 0.01761, -0.00803, - -0.00751, 0.04199, + -0.00198, -0.01045, 0.01761, -0.00803, + -0.00751, 0.04199, - 0.00280, -0.00213, -0.00482, -0.00209, + 0.00280, -0.00213, -0.00482, -0.00209, - -0.01077, 0.00715, + -0.01077, 0.00715, - 0.00048, -0.00004, 0.00199, 0.00237, + 0.00048, -0.00004, 0.00199, 0.00237, - 0.00017, -0.00032, + 0.00017, -0.00032, - -0.07513, -0.00658, -0.04213, 0.16065, - 0.27661, 0.06515, + -0.07513, -0.00658, -0.04213, 0.16065, + 0.27661, 0.06515, - 0.02156, -0.08144, -0.23994, -0.05674, + 0.02156, -0.08144, -0.23994, -0.05674, - 0.00167, 0.00069, + 0.00167, 0.00069, - 0.00244, -0.01247, + 0.00244, -0.01247, - -0.00100, 0.00036, + -0.00100, 0.00036, - 0.00240, 0.00012, + 0.00240, 0.00012, - 0.00010, 0.00018, + 0.00010, 0.00018, - 0.00208, -0.00098, + 0.00208, -0.00098, - -0.00217, 0.00707, + -0.00217, 0.00707, - -0.00338, 0.01260, + -0.00338, 0.01260, - -0.00127, -0.00039, + -0.00127, -0.00039, - -0.03516, -0.00544, -0.01746, 0.08258, - 0.10633, 0.02523, + -0.03516, -0.00544, -0.01746, 0.08258, + 0.10633, 0.02523, - 0.00077, -0.00214, + 0.00077, -0.00214, - -0.02335, 0.00976, + -0.02335, 0.00976, - -0.00019, 0.00003, + -0.00019, 0.00003, - 0.00041, 0.00039, + 0.00041, 0.00039, - 0.00199, -0.01098, + 0.00199, -0.01098, - 0.00813, -0.00853, + 0.00813, -0.00853, - 0.02230, 0.00349, + 0.02230, 0.00349, - -0.02250, 0.08119, + -0.02250, 0.08119, - -0.00214, -0.00052, + -0.00214, -0.00052, - -0.00220, 0.15216, 0.17152, 0.08051, + -0.00220, 0.15216, 0.17152, 0.08051, - -0.01561, 0.27727, 0.25837, 0.07021, + -0.01561, 0.27727, 0.25837, 0.07021, - -0.00005, -0.00000, + -0.00005, -0.00000, - -0.02692, -0.00047, + -0.02692, -0.00047, - -0.00007, -0.00016, + -0.00007, -0.00016, - 0.01072, 0.01418, + 0.01072, 0.01418, - -0.00076, 0.00379, + -0.00076, 0.00379, - -0.00807, 0.03463, + -0.00807, 0.03463, - -0.05199, 0.06680, + -0.05199, 0.06680, - -0.00622, 0.00787, 0.00672, 0.00453, + -0.00622, 0.00787, 0.00672, 0.00453, - -10.69951, -67.43445, -183.55956, -37.87932, - -102.30497, -780.40465, 2572.21990, -446.97798, - 1665.42632, 5698.61327, -11889.66501, 2814.93799, + -10.69951, -67.43445, -183.55956, -37.87932, + -102.30497, -780.40465, 2572.21990, -446.97798, + 1665.42632, 5698.61327, -11889.66501, 2814.93799, - 0.03204, -0.09479, + 0.03204, -0.09479, - 0.00014, -0.00001, + 0.00014, -0.00001, - -0.04118, -0.04562, 0.03435, -0.05878, - 0.01700, 0.02566, + -0.04118, -0.04562, 0.03435, -0.05878, + 0.01700, 0.02566, - -0.00121, 0.00170, + -0.00121, 0.00170, - 0.02390, 0.00403, + 0.02390, 0.00403, - 0.04629, 0.01896, + 0.04629, 0.01896, - -0.00521, 0.03215, + -0.00521, 0.03215, - -0.01051, 0.00696, + -0.01051, 0.00696, - -0.01332, -0.08937, + -0.01332, -0.08937, - -0.00469, -0.00751, + -0.00469, -0.00751, - 0.00016, -0.00035, + 0.00016, -0.00035, - 0.00492, -0.03930, -0.04742, -0.01013, + 0.00492, -0.03930, -0.04742, -0.01013, - 0.00065, 0.00021, + 0.00065, 0.00021, - -0.00006, 0.00017, + -0.00006, 0.00017, - 0.06768, -0.01558, + 0.06768, -0.01558, - -0.00055, 0.00322, + -0.00055, 0.00322, - -0.00287, -0.01656, + -0.00287, -0.01656, - 0.00061, -0.00041, + 0.00061, -0.00041, - 0.00030, 0.00047, + 0.00030, 0.00047, - -0.01436, -0.00148, + -0.01436, -0.00148, - 0.30302, -0.05511, + 0.30302, -0.05511, - -0.00020, -0.00005, + -0.00020, -0.00005, - 0.00042, -0.00025, + 0.00042, -0.00025, - 0.01270, 0.00458, + 0.01270, 0.00458, - -0.00593, -0.04480, + -0.00593, -0.04480, - 0.00005, -0.00008, + 0.00005, -0.00008, - 0.08457, -0.01569, + 0.08457, -0.01569, - 0.00062, 0.00018, + 0.00062, 0.00018, - 9.79942, -2.48836, 4.17423, 6.72044, - -63.33456, 34.63597, 39.11878, -72.89581, + 9.79942, -2.48836, 4.17423, 6.72044, + -63.33456, 34.63597, 39.11878, -72.89581, - -0.00066, 0.00036, + -0.00066, 0.00036, - -0.00045, -0.00062, + -0.00045, -0.00062, - -0.00287, -0.00118, + -0.00287, -0.00118, - -0.21879, 0.03947, + -0.21879, 0.03947, - 0.00086, 0.00671, + 0.00086, 0.00671, - -0.00113, 0.00122, + -0.00113, 0.00122, - -0.00193, -0.00029, + -0.00193, -0.00029, - -0.03612, 0.00635, + -0.03612, 0.00635, - 0.00024, 0.00207, + 0.00024, 0.00207, - -0.00273, 0.00443, + -0.00273, 0.00443, - -0.00055, 0.00030, + -0.00055, 0.00030, - -0.00451, 0.00175, + -0.00451, 0.00175, - -0.00110, -0.00015, + -0.00110, -0.00015, - -0.02608, 0.00480, + -0.02608, 0.00480, - 2.16555, -0.70419, 1.74648, 0.97514, - -1.15360, 1.73688, + 2.16555, -0.70419, 1.74648, 0.97514, + -1.15360, 1.73688, - 0.00004, 0.00105, + 0.00004, 0.00105, - 0.00187, -0.00311, + 0.00187, -0.00311, - 0.00005, 0.00055, + 0.00005, 0.00055, - 0.00004, 0.00032, + 0.00004, 0.00032, - -0.04629, 0.02292, -0.00363, -0.03807, + -0.04629, 0.02292, -0.00363, -0.03807, - 0.00002, 0.00020, + 0.00002, 0.00020, }; + static double FAR ventabr[] = { - -0.24459, 3.72698, -6.67281, 5.24378, + -0.24459, 3.72698, -6.67281, 5.24378, - 0.00030, 0.00003, + 0.00030, 0.00003, - -0.00002, -0.00000, + -0.00002, -0.00000, - -0.00000, 0.00001, + -0.00000, 0.00001, - 0.00032, 0.00021, + 0.00032, 0.00021, - -0.00326, 0.01002, 0.00067, 0.00653, - 0.00243, -0.00417, + -0.00326, 0.01002, 0.00067, 0.00653, + 0.00243, -0.00417, - -0.00004, -0.00010, + -0.00004, -0.00010, - -0.00002, -0.00001, + -0.00002, -0.00001, - 0.00004, -0.00002, + 0.00004, -0.00002, - -0.00638, -0.01453, 0.01458, -0.01235, - 0.00755, 0.01030, + -0.00638, -0.01453, 0.01458, -0.01235, + 0.00755, 0.01030, - 0.00006, 0.00014, 0.00000, 0.00009, + 0.00006, 0.00014, 0.00000, 0.00009, - 0.00063, 0.00176, + 0.00063, 0.00176, - 0.00003, -0.00022, + 0.00003, -0.00022, - 0.00112, 0.00001, + 0.00112, 0.00001, - -0.00014, -0.00001, + -0.00014, -0.00001, - 0.00485, 0.00322, -0.00035, 0.00198, + 0.00485, 0.00322, -0.00035, 0.00198, - 0.00004, 0.00013, + 0.00004, 0.00013, - -0.00015, -0.00003, + -0.00015, -0.00003, - 0.00011, -0.00025, + 0.00011, -0.00025, - 0.00634, 0.02207, 0.04620, 0.00160, + 0.00634, 0.02207, 0.04620, 0.00160, - 0.00045, 0.00001, + 0.00045, 0.00001, - -0.11563, 0.00643, -0.05947, 0.02018, - 0.07704, 0.01574, + -0.11563, 0.00643, -0.05947, 0.02018, + 0.07704, 0.01574, - -0.00090, -0.00471, -0.00322, 0.01104, + -0.00090, -0.00471, -0.00322, 0.01104, - 0.00265, -0.00038, + 0.00265, -0.00038, - 0.01395, 0.02165, -0.01948, 0.01713, + 0.01395, 0.02165, -0.01948, 0.01713, - -0.00057, -0.00019, + -0.00057, -0.00019, - 0.04889, 0.13403, -0.28327, 0.10597, - -0.02325, -0.35829, + 0.04889, 0.13403, -0.28327, 0.10597, + -0.02325, -0.35829, - 0.01171, -0.00904, 0.00747, 0.02546, + 0.01171, -0.00904, 0.00747, 0.02546, - 0.00029, -0.00190, + 0.00029, -0.00190, - -0.03408, -0.00703, + -0.03408, -0.00703, - 0.00176, -0.00109, + 0.00176, -0.00109, - 0.00463, 0.00293, + 0.00463, 0.00293, - 0.00000, 0.00148, + 0.00000, 0.00148, - 1.06691, -0.00054, + 1.06691, -0.00054, - -0.00935, -0.00790, + -0.00935, -0.00790, - 0.00552, -0.00084, + 0.00552, -0.00084, - -0.00100, 0.00336, + -0.00100, 0.00336, - 0.02874, 0.08604, -0.17876, 0.05973, - -0.00720, -0.21195, + 0.02874, 0.08604, -0.17876, 0.05973, + -0.00720, -0.21195, - 0.02134, -0.07980, + 0.02134, -0.07980, - 0.01500, 0.01398, + 0.01500, 0.01398, - 0.01758, -0.00004, + 0.01758, -0.00004, - 0.00371, 0.00650, + 0.00371, 0.00650, - -0.03375, -0.00723, + -0.03375, -0.00723, - 4.65465, -0.00040, + 4.65465, -0.00040, - 0.02040, 0.00707, + 0.02040, 0.00707, - -0.00727, -0.01144, + -0.00727, -0.01144, - -0.00196, 0.00620, + -0.00196, 0.00620, - -0.03396, -0.12904, 0.20160, 0.08092, + -0.03396, -0.12904, 0.20160, 0.08092, - -0.67045, 0.14014, -0.01571, -0.75141, + -0.67045, 0.14014, -0.01571, -0.75141, - 0.00361, 0.00110, + 0.00361, 0.00110, - 1.42165, -0.01499, + 1.42165, -0.01499, - -0.00334, 0.00117, + -0.00334, 0.00117, - 0.01187, 0.00507, + 0.01187, 0.00507, - 0.08935, -0.00174, + 0.08935, -0.00174, - -0.00211, -0.00525, + -0.00211, -0.00525, - 0.01035, -0.00252, + 0.01035, -0.00252, - -0.08355, -0.06442, 0.01616, -0.03409, + -0.08355, -0.06442, 0.01616, -0.03409, - 5.55241, -30.62428, 2.03824, -6.26978, - 143.07279, -10.24734, -125.25411, -380.85360, - -644.78411, 745.02852, 926.70000, -1045.09820, + 5.55241, -30.62428, 2.03824, -6.26978, + 143.07279, -10.24734, -125.25411, -380.85360, + -644.78411, 745.02852, 926.70000, -1045.09820, - -0.03124, -0.00465, + -0.03124, -0.00465, - -0.00396, 0.00002, + -0.00396, 0.00002, - 0.08518, 0.05248, -0.12178, 0.23023, - -0.30943, -0.14208, + 0.08518, 0.05248, -0.12178, 0.23023, + -0.30943, -0.14208, - -0.00005, -0.01054, + -0.00005, -0.01054, - -0.00894, 0.00233, + -0.00894, 0.00233, - -0.00173, -0.00768, + -0.00173, -0.00768, - 0.07881, 0.01633, + 0.07881, 0.01633, - -0.04463, -0.03347, + -0.04463, -0.03347, - -3.92991, 0.00945, + -3.92991, 0.00945, - 0.01524, -0.00422, + 0.01524, -0.00422, - -0.00011, -0.00005, + -0.00011, -0.00005, - 0.10842, -0.02126, 0.00349, 0.12097, + 0.10842, -0.02126, 0.00349, 0.12097, - -0.03752, 0.00001, + -0.03752, 0.00001, - -0.00156, -0.00270, + -0.00156, -0.00270, - -0.01520, 0.01349, + -0.01520, 0.01349, - 0.00895, 0.00186, + 0.00895, 0.00186, - -0.67751, 0.00180, + -0.67751, 0.00180, - 0.00516, -0.00151, + 0.00516, -0.00151, - -0.00365, -0.00210, + -0.00365, -0.00210, - -0.00276, 0.03793, + -0.00276, 0.03793, - -0.02637, 0.03235, + -0.02637, 0.03235, - -0.01343, 0.00541, + -0.01343, 0.00541, - -0.11270, 0.02169, + -0.11270, 0.02169, - -0.63365, 0.00122, + -0.63365, 0.00122, - -0.24329, 0.00428, + -0.24329, 0.00428, - -0.00040, 0.00586, + -0.00040, 0.00586, - 0.00581, 0.01112, + 0.00581, 0.01112, - -0.02731, 0.00008, + -0.02731, 0.00008, - -2.69091, 0.42729, 2.78805, 3.43849, - -0.87998, -6.62373, 0.56882, 4.69370, + -2.69091, 0.42729, 2.78805, 3.43849, + -0.87998, -6.62373, 0.56882, 4.69370, - 0.00005, -0.00008, + 0.00005, -0.00008, - -0.00181, 0.01767, + -0.00181, 0.01767, - -0.00168, 0.00660, + -0.00168, 0.00660, - 0.01802, -0.01836, + 0.01802, -0.01836, - -0.11245, -0.00061, + -0.11245, -0.00061, - 0.00199, -0.00070, + 0.00199, -0.00070, - -0.00076, 0.00919, + -0.00076, 0.00919, - 0.00311, -0.00165, + 0.00311, -0.00165, - -0.05650, -0.00018, + -0.05650, -0.00018, - 0.00121, -0.00069, + 0.00121, -0.00069, - -0.00803, 0.00146, + -0.00803, 0.00146, - -0.03260, -0.00072, + -0.03260, -0.00072, - -0.00042, 0.00524, + -0.00042, 0.00524, - 0.00464, -0.00339, + 0.00464, -0.00339, - -0.06203, -0.00278, 0.04145, 0.02871, - -0.01962, -0.01362, + -0.06203, -0.00278, 0.04145, 0.02871, + -0.01962, -0.01362, - -0.03040, -0.00010, + -0.03040, -0.00010, - 0.00085, -0.00001, + 0.00085, -0.00001, - -0.01712, -0.00006, + -0.01712, -0.00006, - -0.00996, -0.00003, + -0.00996, -0.00003, - -0.00029, 0.00026, 0.00016, -0.00005, + -0.00029, 0.00026, 0.00016, -0.00005, - -0.00594, -0.00003, + -0.00594, -0.00003, }; static signed char FAR venargs[] = { - 0, 3, - 2, 2, 5, -5, 6, 0, - 3, 2, 2, 1, 3, -8, 4, 0, - 3, 5, 1,-14, 2, 2, 3, 0, - 3, 3, 2, -7, 3, 4, 4, 0, - 2, 8, 2,-13, 3, 2, - 3, 6, 2,-10, 3, 3, 5, 0, - 1, 1, 7, 0, - 2, 1, 5, -2, 6, 0, - 2, 1, 2, -3, 4, 2, - 2, 2, 5, -4, 6, 1, - 1, 1, 6, 0, - 3, 3, 2, -5, 3, 1, 5, 0, - 3, 3, 2, -5, 3, 2, 5, 0, - 2, 1, 5, -1, 6, 0, - 2, 2, 2, -6, 4, 1, - 2, 2, 5, -3, 6, 0, - 1, 2, 6, 0, - 2, 3, 5, -5, 6, 0, - 1, 1, 5, 1, - 2, 2, 5, -2, 6, 0, - 2, 3, 2, -5, 3, 2, - 2, 5, 2, -8, 3, 1, - 1, 2, 5, 0, - 2, 2, 1, -5, 2, 1, - 2, 6, 2,-10, 3, 0, - 2, 2, 2, -3, 3, 2, - 2, 1, 2, -2, 3, 1, - 2, 4, 2, -7, 3, 0, - 2, 4, 2, -6, 3, 0, - 1, 1, 4, 0, - 2, 1, 2, -2, 4, 0, - 2, 2, 2, -5, 4, 0, - 2, 1, 2, -1, 3, 0, - 2, 1, 1, -3, 2, 0, - 2, 2, 2, -4, 3, 0, - 2, 6, 2, -9, 3, 0, - 2, 3, 2, -4, 3, 2, - 2, 1, 1, -2, 2, 0, - 1, 1, 3, 0, - 2, 1, 2, -1, 4, 0, - 2, 2, 2, -4, 4, 0, - 2, 5, 2, -7, 3, 0, - 2, 2, 2, -2, 3, 0, - 2, 1, 2, -3, 5, 0, - 2, 1, 2, -3, 3, 0, - 2, 7, 2,-10, 3, 0, - 2, 1, 2, -2, 5, 1, - 2, 4, 2, -5, 3, 1, - 3, 1, 2, 1, 5, -5, 6, 0, - 2, 1, 2, -1, 5, 0, - 3, 1, 2, -3, 5, 5, 6, 0, - 2, 1, 2, -2, 6, 0, - 2, 1, 2, -1, 6, 0, - 1, 3, 4, 0, - 2, 7, 2,-13, 3, 0, - 3, 1, 2, 2, 5, -5, 6, 1, - 1, 1, 2, 5, - 2, 9, 2,-13, 3, 0, - 3, 1, 2, 1, 5, -2, 6, 0, - 2, 2, 2, -3, 4, 2, - 2, 3, 2, -6, 4, 0, - 2, 1, 2, 1, 5, 0, - 2, 2, 2, -5, 3, 0, - 2, 6, 2, -8, 3, 0, - 2, 2, 1, -4, 2, 0, - 2, 3, 2, -3, 3, 0, - 1, 2, 3, 0, - 2, 3, 2, -7, 3, 0, - 2, 5, 2, -6, 3, 1, - 2, 2, 2, -2, 4, 0, - 2, 3, 2, -5, 4, 0, - 2, 2, 2, -1, 3, 0, - 2, 7, 2, -9, 3, 0, - 2, 4, 2, -4, 3, 0, - 2, 1, 2, 1, 3, 0, - 2, 3, 2, -4, 4, 0, - 2, 6, 2, -7, 3, 0, - 2, 3, 2, -2, 3, 0, - 2, 2, 2, -4, 5, 0, - 2, 2, 2, -3, 5, 0, - 2, 2, 2, -2, 5, 0, - 2, 5, 2, -5, 3, 0, - 2, 2, 2, -3, 6, 0, - 2, 2, 2, -1, 5, 0, - 2, 2, 2, -2, 6, 0, - 1, 2, 2, 3, - 2, 2, 2, 1, 5, 0, - 2, 7, 2, -8, 3, 0, - 2, 2, 1, -3, 2, 0, - 2, 4, 2, -3, 3, 0, - 2, 6, 2, -6, 3, 0, - 2, 3, 2, -1, 3, 0, - 2, 8, 2, -9, 3, 0, - 2, 5, 2, -4, 3, 0, - 2, 7, 2, -7, 3, 0, - 2, 4, 2, -2, 3, 0, - 2, 3, 2, -4, 5, 0, - 2, 3, 2, -3, 5, 0, - 2, 9, 2,-10, 3, 0, - 2, 3, 2, -2, 5, 0, - 1, 3, 2, 2, - 2, 8, 2, -8, 3, 0, - 2, 5, 2, -3, 3, 0, - 2, 9, 2, -9, 3, 0, - 2, 10, 2,-10, 3, 0, - 1, 4, 2, 1, - 2, 11, 2,-11, 3, 0, - -1 + 0, 3, + 2, 2, 5, -5, 6, 0, + 3, 2, 2, 1, 3, -8, 4, 0, + 3, 5, 1, -14, 2, 2, 3, 0, + 3, 3, 2, -7, 3, 4, 4, 0, + 2, 8, 2, -13, 3, 2, + 3, 6, 2, -10, 3, 3, 5, 0, + 1, 1, 7, 0, + 2, 1, 5, -2, 6, 0, + 2, 1, 2, -3, 4, 2, + 2, 2, 5, -4, 6, 1, + 1, 1, 6, 0, + 3, 3, 2, -5, 3, 1, 5, 0, + 3, 3, 2, -5, 3, 2, 5, 0, + 2, 1, 5, -1, 6, 0, + 2, 2, 2, -6, 4, 1, + 2, 2, 5, -3, 6, 0, + 1, 2, 6, 0, + 2, 3, 5, -5, 6, 0, + 1, 1, 5, 1, + 2, 2, 5, -2, 6, 0, + 2, 3, 2, -5, 3, 2, + 2, 5, 2, -8, 3, 1, + 1, 2, 5, 0, + 2, 2, 1, -5, 2, 1, + 2, 6, 2, -10, 3, 0, + 2, 2, 2, -3, 3, 2, + 2, 1, 2, -2, 3, 1, + 2, 4, 2, -7, 3, 0, + 2, 4, 2, -6, 3, 0, + 1, 1, 4, 0, + 2, 1, 2, -2, 4, 0, + 2, 2, 2, -5, 4, 0, + 2, 1, 2, -1, 3, 0, + 2, 1, 1, -3, 2, 0, + 2, 2, 2, -4, 3, 0, + 2, 6, 2, -9, 3, 0, + 2, 3, 2, -4, 3, 2, + 2, 1, 1, -2, 2, 0, + 1, 1, 3, 0, + 2, 1, 2, -1, 4, 0, + 2, 2, 2, -4, 4, 0, + 2, 5, 2, -7, 3, 0, + 2, 2, 2, -2, 3, 0, + 2, 1, 2, -3, 5, 0, + 2, 1, 2, -3, 3, 0, + 2, 7, 2, -10, 3, 0, + 2, 1, 2, -2, 5, 1, + 2, 4, 2, -5, 3, 1, + 3, 1, 2, 1, 5, -5, 6, 0, + 2, 1, 2, -1, 5, 0, + 3, 1, 2, -3, 5, 5, 6, 0, + 2, 1, 2, -2, 6, 0, + 2, 1, 2, -1, 6, 0, + 1, 3, 4, 0, + 2, 7, 2, -13, 3, 0, + 3, 1, 2, 2, 5, -5, 6, 1, + 1, 1, 2, 5, + 2, 9, 2, -13, 3, 0, + 3, 1, 2, 1, 5, -2, 6, 0, + 2, 2, 2, -3, 4, 2, + 2, 3, 2, -6, 4, 0, + 2, 1, 2, 1, 5, 0, + 2, 2, 2, -5, 3, 0, + 2, 6, 2, -8, 3, 0, + 2, 2, 1, -4, 2, 0, + 2, 3, 2, -3, 3, 0, + 1, 2, 3, 0, + 2, 3, 2, -7, 3, 0, + 2, 5, 2, -6, 3, 1, + 2, 2, 2, -2, 4, 0, + 2, 3, 2, -5, 4, 0, + 2, 2, 2, -1, 3, 0, + 2, 7, 2, -9, 3, 0, + 2, 4, 2, -4, 3, 0, + 2, 1, 2, 1, 3, 0, + 2, 3, 2, -4, 4, 0, + 2, 6, 2, -7, 3, 0, + 2, 3, 2, -2, 3, 0, + 2, 2, 2, -4, 5, 0, + 2, 2, 2, -3, 5, 0, + 2, 2, 2, -2, 5, 0, + 2, 5, 2, -5, 3, 0, + 2, 2, 2, -3, 6, 0, + 2, 2, 2, -1, 5, 0, + 2, 2, 2, -2, 6, 0, + 1, 2, 2, 3, + 2, 2, 2, 1, 5, 0, + 2, 7, 2, -8, 3, 0, + 2, 2, 1, -3, 2, 0, + 2, 4, 2, -3, 3, 0, + 2, 6, 2, -6, 3, 0, + 2, 3, 2, -1, 3, 0, + 2, 8, 2, -9, 3, 0, + 2, 5, 2, -4, 3, 0, + 2, 7, 2, -7, 3, 0, + 2, 4, 2, -2, 3, 0, + 2, 3, 2, -4, 5, 0, + 2, 3, 2, -3, 5, 0, + 2, 9, 2, -10, 3, 0, + 2, 3, 2, -2, 5, 0, + 1, 3, 2, 2, + 2, 8, 2, -8, 3, 0, + 2, 5, 2, -3, 3, 0, + 2, 9, 2, -9, 3, 0, + 2, 10, 2, -10, 3, 0, + 1, 4, 2, 1, + 2, 11, 2, -11, 3, 0, + -1 }; + /* Total terms = 108, small = 107 */ static struct plantbl FAR ven404 = { - { 5, 14, 13, 8, 4, 5, 1, 0, 0,}, - 5, - venargs, - ventabl, - ventabb, - ventabr, - 7.2332982000000001e-01, + {5, 14, 13, 8, 4, 5, 1, 0, 0,}, + 5, + venargs, + ventabl, + ventabb, + ventabr, + 7.2332982000000001e-01, }; /* @@ -1925,1029 +1933,1032 @@ Days per record = 6.0 */ static double FAR eartabl[] = { - -65.54655, -232.74963, 12959774227.57587, 361678.59587, + -65.54655, -232.74963, 12959774227.57587, 361678.59587, - 2.52679, -4.93511, 2.46852, -8.88928, - 6.66257, -1.94502, + 2.52679, -4.93511, 2.46852, -8.88928, + 6.66257, -1.94502, - 0.66887, -0.06141, 0.08893, 0.18971, + 0.66887, -0.06141, 0.08893, 0.18971, - 0.00068, -0.00307, + 0.00068, -0.00307, - 0.03092, 0.03214, -0.14321, 0.22548, + 0.03092, 0.03214, -0.14321, 0.22548, - 0.00314, -0.00221, + 0.00314, -0.00221, - 8.98017, 7.25747, -1.06655, 1.19671, - -2.42276, 0.29621, 1.55635, 0.99167, + 8.98017, 7.25747, -1.06655, 1.19671, + -2.42276, 0.29621, 1.55635, 0.99167, - -0.00026, 0.00187, + -0.00026, 0.00187, - 0.00189, 0.02742, + 0.00189, 0.02742, - 0.00158, 0.01475, + 0.00158, 0.01475, - 0.00353, -0.02048, + 0.00353, -0.02048, - -0.01775, -0.01023, 0.01927, -0.03122, + -0.01775, -0.01023, 0.01927, -0.03122, - -1.55440, -4.97423, 2.14765, -2.77045, - 1.02707, 0.55507, -0.08066, 0.18479, + -1.55440, -4.97423, 2.14765, -2.77045, + 1.02707, 0.55507, -0.08066, 0.18479, - 0.00750, 0.00583, + 0.00750, 0.00583, - -0.16977, 0.35555, 0.32036, 0.01309, + -0.16977, 0.35555, 0.32036, 0.01309, - 0.54625, 0.08167, 0.10681, 0.17231, - -0.02287, 0.01631, + 0.54625, 0.08167, 0.10681, 0.17231, + -0.02287, 0.01631, - -0.00866, -0.00190, + -0.00866, -0.00190, - 0.00016, -0.01514, + 0.00016, -0.01514, - -0.00073, 0.04205, + -0.00073, 0.04205, - -0.00072, 0.01490, + -0.00072, 0.01490, - -0.38831, 0.41043, -1.11857, -0.84329, - 1.15123, -1.34167, + -0.38831, 0.41043, -1.11857, -0.84329, + 1.15123, -1.34167, - 0.01026, -0.00432, + 0.01026, -0.00432, - -0.02833, -0.00705, -0.00285, 0.01645, + -0.02833, -0.00705, -0.00285, 0.01645, - -0.01234, 0.05609, -0.01893, -0.00171, + -0.01234, 0.05609, -0.01893, -0.00171, - -0.30527, 0.45390, 0.56713, 0.70030, - 1.27125, -0.76481, 0.34857, -2.60318, + -0.30527, 0.45390, 0.56713, 0.70030, + 1.27125, -0.76481, 0.34857, -2.60318, - -0.00160, 0.00643, + -0.00160, 0.00643, - 0.28492, -0.37998, 0.23347, 0.00540, - 0.00342, 0.04406, + 0.28492, -0.37998, 0.23347, 0.00540, + 0.00342, 0.04406, - 0.00037, -0.02449, + 0.00037, -0.02449, - 0.01469, 1.59358, 0.24956, 0.71066, - 0.25477, -0.98371, + 0.01469, 1.59358, 0.24956, 0.71066, + 0.25477, -0.98371, - -0.69412, 0.19687, -0.44423, -0.83331, - 0.49647, -0.31021, + -0.69412, 0.19687, -0.44423, -0.83331, + 0.49647, -0.31021, - 0.05696, -0.00802, -0.14423, -0.04719, + 0.05696, -0.00802, -0.14423, -0.04719, - 0.16762, -0.01234, 0.02481, 0.03465, + 0.16762, -0.01234, 0.02481, 0.03465, - 0.01091, 0.02123, + 0.01091, 0.02123, - 0.08212, -0.07375, 0.01524, -0.07388, + 0.08212, -0.07375, 0.01524, -0.07388, - 0.06673, -0.22486, 0.10026, -0.00559, + 0.06673, -0.22486, 0.10026, -0.00559, - 0.14711, -0.11680, 0.05460, 0.02749, + 0.14711, -0.11680, 0.05460, 0.02749, - -1.04467, 0.34273, -0.67582, -2.15117, - 2.47372, -0.04332, + -1.04467, 0.34273, -0.67582, -2.15117, + 2.47372, -0.04332, - 0.05016, -0.03991, 0.01908, 0.00943, + 0.05016, -0.03991, 0.01908, 0.00943, - 0.07321, -0.23637, 0.10564, -0.00446, + 0.07321, -0.23637, 0.10564, -0.00446, - -0.09523, -0.30710, 0.17400, -0.10681, + -0.09523, -0.30710, 0.17400, -0.10681, - 0.05104, -0.14078, 0.01390, 0.07288, + 0.05104, -0.14078, 0.01390, 0.07288, - -0.26308, -0.20717, 0.20773, -0.37096, + -0.26308, -0.20717, 0.20773, -0.37096, - -0.00205, -0.27274, + -0.00205, -0.27274, - -0.00792, -0.00183, + -0.00792, -0.00183, - 0.02985, 0.04895, 0.03785, -0.14731, + 0.02985, 0.04895, 0.03785, -0.14731, - 0.02976, -0.02495, -0.02644, -0.04085, + 0.02976, -0.02495, -0.02644, -0.04085, - -0.00843, 0.00027, + -0.00843, 0.00027, - 0.00090, 0.00611, + 0.00090, 0.00611, - 0.00040, 4.83425, + 0.00040, 4.83425, - 0.01692, -0.01335, + 0.01692, -0.01335, - 0.04482, -0.03602, 0.01672, 0.00838, + 0.04482, -0.03602, 0.01672, 0.00838, - 0.03682, -0.11206, 0.05163, -0.00219, + 0.03682, -0.11206, 0.05163, -0.00219, - -0.08381, -0.20911, 0.16400, -0.13325, + -0.08381, -0.20911, 0.16400, -0.13325, - -0.05945, 0.02114, -0.00710, -0.04695, + -0.05945, 0.02114, -0.00710, -0.04695, - -0.01657, -0.00513, + -0.01657, -0.00513, - -0.06999, -0.23054, 0.13128, -0.07975, + -0.06999, -0.23054, 0.13128, -0.07975, - 0.00054, -0.00699, + 0.00054, -0.00699, - -0.01253, -0.04007, 0.00658, -0.00607, + -0.01253, -0.04007, 0.00658, -0.00607, - -0.48696, 0.31859, -0.84292, -0.87950, - 1.30507, -0.94042, + -0.48696, 0.31859, -0.84292, -0.87950, + 1.30507, -0.94042, - -0.00234, 0.00339, + -0.00234, 0.00339, - -0.30647, -0.24605, 0.24948, -0.43369, + -0.30647, -0.24605, 0.24948, -0.43369, - -0.64033, 0.20754, -0.43829, -1.31801, - 1.55412, -0.02893, + -0.64033, 0.20754, -0.43829, -1.31801, + 1.55412, -0.02893, - -0.02323, 0.02181, -0.00398, -0.01548, + -0.02323, 0.02181, -0.00398, -0.01548, - -0.08005, -0.01537, -0.00362, -0.02033, + -0.08005, -0.01537, -0.00362, -0.02033, - 0.00028, -0.03732, -0.14083, -7.21175, + 0.00028, -0.03732, -0.14083, -7.21175, - -0.07430, 0.01886, -0.00223, 0.01915, + -0.07430, 0.01886, -0.00223, 0.01915, - -0.02270, -0.03702, 0.10167, -0.02917, + -0.02270, -0.03702, 0.10167, -0.02917, - 0.00879, -2.04198, + 0.00879, -2.04198, - -0.00433, -0.41764, + -0.00433, -0.41764, - 0.00671, -0.00030, + 0.00671, -0.00030, - 0.00070, -0.01066, + 0.00070, -0.01066, - 0.01144, -0.03190, + 0.01144, -0.03190, - -0.29653, 0.38638, -0.16611, -0.07661, + -0.29653, 0.38638, -0.16611, -0.07661, - 0.22071, 0.14665, 0.02487, 0.13524, + 0.22071, 0.14665, 0.02487, 0.13524, - -275.60942, -335.52251, -413.89009, 359.65390, - 1396.49813, 1118.56095, 2559.41622, -3393.39088, - -6717.66079, -1543.17403, + -275.60942, -335.52251, -413.89009, 359.65390, + 1396.49813, 1118.56095, 2559.41622, -3393.39088, + -6717.66079, -1543.17403, - -1.90405, -0.22958, -0.57989, -0.36584, - -0.04547, -0.14164, + -1.90405, -0.22958, -0.57989, -0.36584, + -0.04547, -0.14164, - 0.00749, -0.03973, + 0.00749, -0.03973, - 0.00033, 0.01842, + 0.00033, 0.01842, - -0.08301, -0.03523, -0.00408, -0.02008, + -0.08301, -0.03523, -0.00408, -0.02008, - 0.00008, 0.00778, + 0.00008, 0.00778, - -0.00046, 0.02760, + -0.00046, 0.02760, - -0.03135, 0.07710, 0.06130, 0.04003, + -0.03135, 0.07710, 0.06130, 0.04003, - -0.04703, 0.00671, -0.00754, -0.01000, + -0.04703, 0.00671, -0.00754, -0.01000, - -0.01902, -0.00125, + -0.01902, -0.00125, - -0.00264, -0.00903, + -0.00264, -0.00903, - -0.02672, 0.12765, + -0.02672, 0.12765, - -0.03872, 0.03532, -0.01534, -0.00710, + -0.03872, 0.03532, -0.01534, -0.00710, - -0.01087, 0.01124, + -0.01087, 0.01124, - -0.01664, 0.06304, -0.02779, 0.00214, + -0.01664, 0.06304, -0.02779, 0.00214, - -0.01279, -5.51814, + -0.01279, -5.51814, - 0.05847, -0.02093, 0.03950, 0.06696, - -0.04064, 0.02687, + 0.05847, -0.02093, 0.03950, 0.06696, + -0.04064, 0.02687, - 0.01478, -0.02169, 0.05821, 0.03301, - -0.03861, 0.07535, + 0.01478, -0.02169, 0.05821, 0.03301, + -0.03861, 0.07535, - 0.00290, -0.00644, + 0.00290, -0.00644, - 0.00631, 0.12905, + 0.00631, 0.12905, - 0.02400, 0.13194, -0.14339, 0.00529, + 0.02400, 0.13194, -0.14339, 0.00529, - 0.00343, 0.00819, + 0.00343, 0.00819, - 0.02692, -0.03332, -0.07284, -0.02064, + 0.02692, -0.03332, -0.07284, -0.02064, - 0.07038, 0.03999, 0.02759, 0.07599, + 0.07038, 0.03999, 0.02759, 0.07599, - 0.00033, 0.00641, + 0.00033, 0.00641, - 0.00128, 0.02032, -0.00852, 0.00680, + 0.00128, 0.02032, -0.00852, 0.00680, - 0.23019, 0.17100, 0.09861, 0.55013, + 0.23019, 0.17100, 0.09861, 0.55013, - -0.00192, 0.00953, + -0.00192, 0.00953, - -0.00943, 0.01783, + -0.00943, 0.01783, - 0.05975, 0.01486, 0.00160, 0.01558, + 0.05975, 0.01486, 0.00160, 0.01558, - -0.01629, -0.02035, 0.01533, 2.73176, + -0.01629, -0.02035, 0.01533, 2.73176, - 0.05858, -0.01327, 0.00209, -0.01506, + 0.05858, -0.01327, 0.00209, -0.01506, - 0.00755, 0.03300, + 0.00755, 0.03300, - -0.00796, -0.65270, + -0.00796, -0.65270, - 0.02305, 0.00165, + 0.02305, 0.00165, - -0.02512, 0.06560, 0.16108, -0.02087, + -0.02512, 0.06560, 0.16108, -0.02087, - 0.00016, 0.10729, + 0.00016, 0.10729, - 0.04175, 0.00559, + 0.04175, 0.00559, - 0.01176, 0.00110, + 0.01176, 0.00110, - 15.15730, -0.52460, -37.16535, -25.85564, - -60.94577, 4.29961, 57.11617, 67.96463, - 31.41414, -64.75731, + 15.15730, -0.52460, -37.16535, -25.85564, + -60.94577, 4.29961, 57.11617, 67.96463, + 31.41414, -64.75731, - 0.00848, 0.02971, -0.03690, -0.00010, + 0.00848, 0.02971, -0.03690, -0.00010, - -0.03568, 0.06325, 0.11311, 0.02431, + -0.03568, 0.06325, 0.11311, 0.02431, - -0.00383, 0.00421, + -0.00383, 0.00421, - -0.00140, 0.00680, + -0.00140, 0.00680, - 0.00069, -0.21036, + 0.00069, -0.21036, - 0.00386, 0.04210, + 0.00386, 0.04210, - -0.01324, 0.16454, + -0.01324, 0.16454, - -0.01398, -0.00109, + -0.01398, -0.00109, - 0.02548, -0.03842, -0.06504, -0.02204, + 0.02548, -0.03842, -0.06504, -0.02204, - 0.01359, 0.00232, + 0.01359, 0.00232, - 0.07634, -1.64648, -1.73103, 0.89176, - 0.81398, 0.65209, + 0.07634, -1.64648, -1.73103, 0.89176, + 0.81398, 0.65209, - 0.00021, -0.08441, + 0.00021, -0.08441, - -0.00012, 0.01262, + -0.00012, 0.01262, - -0.00666, -0.00050, + -0.00666, -0.00050, - -0.00130, 0.01596, + -0.00130, 0.01596, - -0.00485, -0.00213, + -0.00485, -0.00213, - 0.00009, -0.03941, + 0.00009, -0.03941, - -0.02266, -0.04421, -0.01341, 0.01083, + -0.02266, -0.04421, -0.01341, 0.01083, - -0.00011, 0.00004, 0.00003, -0.02017, + -0.00011, 0.00004, 0.00003, -0.02017, - 0.00003, -0.01096, + 0.00003, -0.01096, - 0.00002, -0.00623, + 0.00002, -0.00623, }; + static double FAR eartabb[] = { - -41.97860, -48.43539, 74.72897, 0.00075, + -41.97860, -48.43539, 74.72897, 0.00075, - -0.12774, -0.10188, -0.00943, -0.04574, - 0.00265, -0.00217, + -0.12774, -0.10188, -0.00943, -0.04574, + 0.00265, -0.00217, - 0.00254, 0.00168, 0.00008, 0.00026, + 0.00254, 0.00168, 0.00008, 0.00026, - -0.00000, -0.00000, + -0.00000, -0.00000, - 0.00004, -0.00003, 0.00001, -0.00003, + 0.00004, -0.00003, 0.00001, -0.00003, - -0.00002, -0.00006, + -0.00002, -0.00006, - 0.03351, -0.02699, 0.00896, -0.01315, - -0.00019, -0.00054, -0.00020, -0.00003, + 0.03351, -0.02699, 0.00896, -0.01315, + -0.00019, -0.00054, -0.00020, -0.00003, - 0.00002, 0.00001, + 0.00002, 0.00001, - -0.00000, 0.00000, + -0.00000, 0.00000, - -0.00002, -0.00001, + -0.00002, -0.00001, - -0.00001, 0.00003, + -0.00001, 0.00003, - 0.00017, -0.00008, 0.00000, -0.00003, + 0.00017, -0.00008, 0.00000, -0.00003, - 0.00501, -0.00083, 0.00414, 0.00202, - 0.00051, 0.00060, 0.00002, 0.00000, + 0.00501, -0.00083, 0.00414, 0.00202, + 0.00051, 0.00060, 0.00002, 0.00000, - -0.00002, 0.00002, + -0.00002, 0.00002, - -0.00016, -0.00443, -0.00083, -0.00031, + -0.00016, -0.00443, -0.00083, -0.00031, - -0.00394, 0.00148, -0.00035, 0.00099, - 0.00005, 0.00009, + -0.00394, 0.00148, -0.00035, 0.00099, + 0.00005, 0.00009, - 0.00004, -0.00002, + 0.00004, -0.00002, - -0.00001, -0.00002, + -0.00001, -0.00002, - 0.00012, -0.00005, + 0.00012, -0.00005, - 0.00001, 0.00001, + 0.00001, 0.00001, - -0.00577, -0.00631, -0.00017, 0.01993, - -0.00234, -0.00218, + -0.00577, -0.00631, -0.00017, 0.01993, + -0.00234, -0.00218, - -0.00001, 0.00002, + -0.00001, 0.00002, - -0.00101, -0.00044, -0.00036, 0.00041, + -0.00101, -0.00044, -0.00036, 0.00041, - 0.00294, -0.00109, 0.00043, -0.00006, + 0.00294, -0.00109, 0.00043, -0.00006, - 0.09650, 0.15003, 0.01087, 0.04905, - 0.00093, -0.06986, -0.01471, -0.00221, + 0.09650, 0.15003, 0.01087, 0.04905, + 0.00093, -0.06986, -0.01471, -0.00221, - -0.00002, -0.00003, + -0.00002, -0.00003, - 0.00440, -0.00083, 0.00102, -0.00024, - 0.00005, -0.00002, + 0.00440, -0.00083, 0.00102, -0.00024, + 0.00005, -0.00002, - -0.00004, 0.00001, + -0.00004, 0.00001, - 0.00505, 0.00930, -0.01609, -0.00183, - -0.00113, 0.00214, + 0.00505, 0.00930, -0.01609, -0.00183, + -0.00113, 0.00214, - 0.00439, -0.00295, -0.00280, 0.00402, - -0.00047, -0.00145, + 0.00439, -0.00295, -0.00280, 0.00402, + -0.00047, -0.00145, - -0.00114, -0.00178, 0.00097, 0.00022, + -0.00114, -0.00178, 0.00097, 0.00022, - 0.00019, 0.00002, 0.00009, -0.00005, + 0.00019, 0.00002, 0.00009, -0.00005, - -0.00002, 0.00006, + -0.00002, 0.00006, - -0.01618, -0.01033, -0.00372, 0.00301, + -0.01618, -0.01033, -0.00372, 0.00301, - -0.00199, 0.00003, 0.00012, -0.00068, + -0.00199, 0.00003, 0.00012, -0.00068, - -0.00027, -0.00011, 0.00009, -0.00020, + -0.00027, -0.00011, 0.00009, -0.00020, - -0.00618, 0.00129, 0.00452, 0.00620, - -0.06411, -0.01524, + -0.00618, 0.00129, 0.00452, 0.00620, + -0.06411, -0.01524, - -0.00207, -0.00140, 0.00005, -0.00036, + -0.00207, -0.00140, 0.00005, -0.00036, - -0.00009, 0.00005, 0.00012, -0.00053, + -0.00009, 0.00005, 0.00012, -0.00053, - 0.00050, -0.00068, -0.00059, -0.00132, + 0.00050, -0.00068, -0.00059, -0.00132, - 0.00719, -0.13368, -0.08789, -0.02072, + 0.00719, -0.13368, -0.08789, -0.02072, - 0.00031, -0.00360, -0.00241, -0.00182, + 0.00031, -0.00360, -0.00241, -0.00182, - 0.00284, 0.00196, + 0.00284, 0.00196, - 0.00083, 0.00008, + 0.00083, 0.00008, - 0.00203, -0.00097, -0.00120, 0.00748, + 0.00203, -0.00097, -0.00120, 0.00748, - 0.00326, -0.00145, -0.00276, 0.00236, + 0.00326, -0.00145, -0.00276, 0.00236, - -0.00048, -0.00258, + -0.00048, -0.00258, - 0.00011, 0.00001, + 0.00011, 0.00001, - -0.00284, 0.00795, + -0.00284, 0.00795, - -0.00156, 0.00106, + -0.00156, 0.00106, - -0.00040, -0.00069, 0.00026, -0.00039, + -0.00040, -0.00069, 0.00026, -0.00039, - -0.00102, -0.00098, 0.00017, -0.00125, + -0.00102, -0.00098, 0.00017, -0.00125, - -0.00180, -0.01103, -0.01854, 0.00742, + -0.00180, -0.01103, -0.01854, 0.00742, - -0.02751, -0.00773, -0.00263, 0.01059, + -0.02751, -0.00773, -0.00263, 0.01059, - 0.00152, 0.00047, + 0.00152, 0.00047, - -0.00106, -0.00034, -0.00126, -0.00291, + -0.00106, -0.00034, -0.00126, -0.00291, - -0.00014, 0.00006, + -0.00014, 0.00006, - 0.00069, 0.00316, -0.00087, 0.00022, + 0.00069, 0.00316, -0.00087, 0.00022, - 0.05381, 0.03791, 0.05011, -0.15168, - -0.16315, 0.03037, + 0.05381, 0.03791, 0.05011, -0.15168, + -0.16315, 0.03037, - 0.00068, -0.00067, + 0.00068, -0.00067, - -0.00457, -0.00146, -0.00643, -0.00451, + -0.00457, -0.00146, -0.00643, -0.00451, - 0.07806, 0.00729, 0.03356, -0.16465, - -0.20388, -0.04854, + 0.07806, 0.00729, 0.03356, -0.16465, + -0.20388, -0.04854, - -0.00163, -0.00178, 0.00185, 0.00405, + -0.00163, -0.00178, 0.00185, 0.00405, - -0.00009, 0.00068, -0.00003, 0.00005, + -0.00009, 0.00068, -0.00003, 0.00005, - -0.01186, 0.00347, -0.01776, 0.00258, + -0.01186, 0.00347, -0.01776, 0.00258, - 0.00081, -0.00014, 0.00003, -0.00021, + 0.00081, -0.00014, 0.00003, -0.00021, - -0.01218, -0.03048, -0.03109, 0.01387, + -0.01218, -0.03048, -0.03109, 0.01387, - -0.00740, -0.00113, + -0.00740, -0.00113, - -0.00155, 0.00679, + -0.00155, 0.00679, - -0.00053, -0.00007, + -0.00053, -0.00007, - -0.00004, -0.00002, + -0.00004, -0.00002, - 0.00248, 0.00127, + 0.00248, 0.00127, - -0.00386, 0.00394, 0.01213, 0.00748, + -0.00386, 0.00394, 0.01213, 0.00748, - -0.04669, -0.00319, 0.00315, 0.00010, + -0.04669, -0.00319, 0.00315, 0.00010, - 85.02966, -55.85765, 215.62111, 519.00334, - -1941.10461, 508.68393, -419.80123, -4679.60117, - -0.00916, 0.00204, + 85.02966, -55.85765, 215.62111, 519.00334, + -1941.10461, 508.68393, -419.80123, -4679.60117, + -0.00916, 0.00204, - -0.13900, -0.08473, -0.07614, -0.03445, - 0.00359, -0.00136, + -0.13900, -0.08473, -0.07614, -0.03445, + 0.00359, -0.00136, - -0.00111, 0.01028, + -0.00111, 0.01028, - 0.00021, -0.00002, + 0.00021, -0.00002, - 0.00039, 0.00246, -0.00084, -0.00007, + 0.00039, 0.00246, -0.00084, -0.00007, - -0.00191, 0.00491, + -0.00191, 0.00491, - 0.00474, -0.00676, + 0.00474, -0.00676, - -0.00549, 0.02234, 0.02087, 0.00575, + -0.00549, 0.02234, 0.02087, 0.00575, - -0.00011, 0.00079, -0.00060, 0.00029, + -0.00011, 0.00079, -0.00060, 0.00029, - -0.00239, -0.00257, + -0.00239, -0.00257, - 0.00020, 0.00163, + 0.00020, 0.00163, - 0.00301, -0.01723, + 0.00301, -0.01723, - 0.00049, 0.00086, -0.00046, 0.00057, + 0.00049, 0.00086, -0.00046, 0.00057, - -0.00049, 0.00024, + -0.00049, 0.00024, - 0.00103, -0.00072, -0.00005, 0.00095, + 0.00103, -0.00072, -0.00005, 0.00095, - 0.00598, -0.01127, + 0.00598, -0.01127, - -0.00538, 0.00317, -0.00178, -0.00010, - 0.00061, 0.00132, + -0.00538, 0.00317, -0.00178, -0.00010, + 0.00061, 0.00132, - -0.00001, 0.00318, -0.00206, 0.00113, - 0.00153, 0.00097, + -0.00001, 0.00318, -0.00206, 0.00113, + 0.00153, 0.00097, - 0.00161, -0.00363, + 0.00161, -0.00363, - 0.00142, -0.00047, + 0.00142, -0.00047, - -0.00281, 0.03085, 0.02895, 0.00688, + -0.00281, 0.03085, 0.02895, 0.00688, - 0.00025, -0.00016, + 0.00025, -0.00016, - -0.00197, -0.08112, 0.02859, -0.00683, + -0.00197, -0.08112, 0.02859, -0.00683, - 0.00004, 0.00016, 0.00158, -0.00065, + 0.00004, 0.00016, 0.00158, -0.00065, - 0.00004, -0.00001, + 0.00004, -0.00001, - 0.00002, -0.00008, 0.00019, 0.00039, + 0.00002, -0.00008, 0.00019, 0.00039, - -0.00344, 0.00364, 0.00579, -0.00144, + -0.00344, 0.00364, 0.00579, -0.00144, - 0.00031, -0.00190, + 0.00031, -0.00190, - 0.00066, 0.00025, + 0.00066, 0.00025, - 0.00011, -0.00069, 0.00001, -0.00011, + 0.00011, -0.00069, 0.00001, -0.00011, - -0.01202, 0.00842, 0.00067, -0.00297, + -0.01202, 0.00842, 0.00067, -0.00297, - -0.00000, 0.00008, 0.00005, 0.00000, + -0.00000, 0.00008, 0.00005, 0.00000, - 0.00086, -0.00057, + 0.00086, -0.00057, - 0.00354, -0.00548, + 0.00354, -0.00548, - 0.00009, -0.00003, + 0.00009, -0.00003, - 0.00179, 0.07922, 0.00490, 0.00065, + 0.00179, 0.07922, 0.00490, 0.00065, - -0.00005, -0.00059, + -0.00005, -0.00059, - 0.00061, -0.00319, + 0.00061, -0.00319, - 0.00007, -0.00048, + 0.00007, -0.00048, - 3.49661, -1.52414, -6.26431, -1.76193, - -26.45666, 7.62583, 77.77395, 10.67040, - 0.00032, 0.00090, + 3.49661, -1.52414, -6.26431, -1.76193, + -26.45666, 7.62583, 77.77395, 10.67040, + 0.00032, 0.00090, - -0.00026, 0.00680, 0.00827, 0.00199, + -0.00026, 0.00680, 0.00827, 0.00199, - -0.00271, 0.04278, 0.02257, -0.00532, + -0.00271, 0.04278, 0.02257, -0.00532, - 0.00006, 0.00011, + 0.00006, 0.00011, - 0.00006, 0.00010, + 0.00006, 0.00010, - -0.00017, -0.00081, + -0.00017, -0.00081, - 0.00050, 0.00001, + 0.00050, 0.00001, - 0.00012, 0.00082, + 0.00012, 0.00082, - 0.00326, 0.00040, + 0.00326, 0.00040, - -0.00003, -0.03209, 0.00042, 0.00008, + -0.00003, -0.03209, 0.00042, 0.00008, - 0.01059, -0.00218, + 0.01059, -0.00218, - -0.87557, -1.06369, -0.52928, 1.38498, - 0.00082, -0.00040, + -0.87557, -1.06369, -0.52928, 1.38498, + 0.00082, -0.00040, - 0.00009, -0.00047, + 0.00009, -0.00047, - 0.00007, 0.00007, + 0.00007, 0.00007, - 0.00155, 0.00019, + 0.00155, 0.00019, - 0.00002, 0.00008, + 0.00002, 0.00008, - 0.00001, 0.00023, + 0.00001, 0.00023, - 0.00010, -0.00029, + 0.00010, -0.00029, - -0.03336, -0.00987, 0.00012, -0.00006, + -0.03336, -0.00987, 0.00012, -0.00006, - -0.00198, 0.00333, -0.00004, 0.00026, + -0.00198, 0.00333, -0.00004, 0.00026, - 0.00042, 0.00006, + 0.00042, 0.00006, - 0.00025, 0.00021, + 0.00025, 0.00021, }; + static double FAR eartabr[] = { - 0.64577, -2.90183, -14.50280, 28.85196, + 0.64577, -2.90183, -14.50280, 28.85196, - 0.08672, -0.05643, 0.02353, -0.00404, - 0.00019, -0.00137, + 0.08672, -0.05643, 0.02353, -0.00404, + 0.00019, -0.00137, - 0.00128, -0.00310, 0.00143, 0.00050, + 0.00128, -0.00310, 0.00143, 0.00050, - 0.00000, 0.00000, + 0.00000, 0.00000, - -0.00023, -0.00003, -0.00057, -0.00032, + -0.00023, -0.00003, -0.00057, -0.00032, - -0.00002, 0.00009, + -0.00002, 0.00009, - -0.09716, 0.04111, -0.03108, 0.00633, - -0.00220, -0.00595, -0.00279, 0.00491, + -0.09716, 0.04111, -0.03108, 0.00633, + -0.00220, -0.00595, -0.00279, 0.00491, - -0.00004, -0.00003, + -0.00004, -0.00003, - -0.00010, -0.00004, + -0.00010, -0.00004, - -0.00013, -0.00010, + -0.00013, -0.00010, - 0.00017, -0.00010, + 0.00017, -0.00010, - -0.00075, 0.00002, -0.00054, -0.00025, + -0.00075, 0.00002, -0.00054, -0.00025, - 0.12572, 0.00948, 0.05937, 0.04900, - -0.00785, 0.01815, -0.00303, -0.00120, + 0.12572, 0.00948, 0.05937, 0.04900, + -0.00785, 0.01815, -0.00303, -0.00120, - -0.00010, 0.00010, + -0.00010, 0.00010, - -0.00317, -0.00143, 0.00068, 0.00213, + -0.00317, -0.00143, 0.00068, 0.00213, - -0.00043, -0.00420, 0.00406, -0.00041, - 0.00048, 0.00062, + -0.00043, -0.00420, 0.00406, -0.00041, + 0.00048, 0.00062, - -0.00005, 0.00029, + -0.00005, 0.00029, - 0.00043, -0.00002, + 0.00043, -0.00002, - -0.00126, -0.00009, + -0.00126, -0.00009, - -0.00040, 0.00000, + -0.00040, 0.00000, - 0.03557, 0.02143, -0.02196, 0.04671, - -0.05571, -0.03425, + 0.03557, 0.02143, -0.02196, 0.04671, + -0.05571, -0.03425, - 0.00016, 0.00031, + 0.00016, 0.00031, - 0.00020, -0.00153, -0.00142, -0.00051, + 0.00020, -0.00153, -0.00142, -0.00051, - -0.00214, 0.00001, 0.00002, -0.00061, + -0.00214, 0.00001, 0.00002, -0.00061, - -0.06824, 0.00030, -0.05717, 0.04196, - 0.05887, 0.07531, 0.12313, -0.04113, + -0.06824, 0.00030, -0.05717, 0.04196, + 0.05887, 0.07531, 0.12313, -0.04113, - 0.00025, 0.00021, + 0.00025, 0.00021, - 0.02218, 0.01747, 0.00011, 0.01367, - -0.00247, 0.00029, + 0.02218, 0.01747, 0.00011, 0.01367, + -0.00247, 0.00029, - 0.00120, -0.00003, + 0.00120, -0.00003, - 0.13373, -0.02072, 0.06706, -0.01009, - -0.09515, -0.01901, + 0.13373, -0.02072, 0.06706, -0.01009, + -0.09515, -0.01901, - 0.01767, 0.06939, -0.06702, 0.04159, - -0.02809, -0.03968, + 0.01767, 0.06939, -0.06702, 0.04159, + -0.02809, -0.03968, - 0.00257, 0.00553, 0.00411, -0.01309, + 0.00257, 0.00553, 0.00411, -0.01309, - 0.00139, 0.01591, -0.00322, 0.00245, + 0.00139, 0.01591, -0.00322, 0.00245, - -0.00202, 0.00093, + -0.00202, 0.00093, - 0.01845, -0.00018, -0.00247, -0.00771, + 0.01845, -0.00018, -0.00247, -0.00771, - -0.02834, -0.00691, -0.00154, -0.01244, + -0.02834, -0.00691, -0.00154, -0.01244, - 0.01512, 0.01884, -0.00359, 0.00731, + 0.01512, 0.01884, -0.00359, 0.00731, - -0.05395, -0.18108, 0.36303, -0.12751, - 0.01877, 0.43653, + -0.05395, -0.18108, 0.36303, -0.12751, + 0.01877, 0.43653, - -0.00725, -0.00692, 0.00115, -0.00327, + -0.00725, -0.00692, 0.00115, -0.00327, - 0.04030, 0.01171, 0.00107, 0.01793, + 0.04030, 0.01171, 0.00107, 0.01793, - 0.06335, -0.02171, 0.02229, 0.03533, + 0.06335, -0.02171, 0.02229, 0.03533, - -0.06038, -0.00356, 0.01325, -0.03798, + -0.06038, -0.00356, 0.01325, -0.03798, - 0.04963, -0.06258, 0.08931, 0.04904, + 0.04963, -0.06258, 0.08931, 0.04904, - 0.07115, -0.00073, + 0.07115, -0.00073, - -0.00104, 0.00354, + -0.00104, 0.00354, - -0.01549, 0.00647, 0.04418, 0.01061, + -0.01549, 0.00647, 0.04418, 0.01061, - 0.00568, 0.00957, 0.01102, -0.00819, + 0.00568, 0.00957, 0.01102, -0.00819, - -0.00089, 0.00368, + -0.00089, 0.00368, - -0.00214, 0.00031, + -0.00214, 0.00031, - -1.11935, -0.00029, + -1.11935, -0.00029, - 0.00457, 0.00550, + 0.00457, 0.00550, - 0.01409, 0.01664, -0.00306, 0.00629, + 0.01409, 0.01664, -0.00306, 0.00629, - 0.04531, 0.01460, 0.00092, 0.02074, + 0.04531, 0.01460, 0.00092, 0.02074, - 0.07900, -0.03241, 0.05122, 0.06151, + 0.07900, -0.03241, 0.05122, 0.06151, - 0.01319, 0.03075, -0.02814, 0.00329, + 0.01319, 0.03075, -0.02814, 0.00329, - 0.00208, -0.00681, + 0.00208, -0.00681, - 0.09887, -0.02956, 0.03410, 0.05617, + 0.09887, -0.02956, 0.03410, 0.05617, - 0.00295, 0.00022, + 0.00295, 0.00022, - 0.01727, -0.00666, 0.00255, 0.00256, + 0.01727, -0.00666, 0.00255, 0.00256, - -0.14161, -0.20656, 0.36936, -0.35793, - 0.40122, 0.54675, + -0.14161, -0.20656, 0.36936, -0.35793, + 0.40122, 0.54675, - -0.00109, -0.00135, + -0.00109, -0.00135, - 0.11179, -0.13803, 0.19591, 0.11327, + 0.11179, -0.13803, 0.19591, 0.11327, - -0.08785, -0.29929, 0.60319, -0.20484, - 0.01418, 0.71392, + -0.08785, -0.29929, 0.60319, -0.20484, + 0.01418, 0.71392, - -0.01039, -0.01041, 0.00694, -0.00183, + -0.01039, -0.01041, 0.00694, -0.00183, - 0.00707, -0.03745, 0.00943, -0.00174, + 0.00707, -0.03745, 0.00943, -0.00174, - 0.01781, 0.00069, 3.35806, -0.06731, + 0.01781, 0.00069, 3.35806, -0.06731, - -0.01015, -0.03402, -0.00913, -0.00094, + -0.01015, -0.03402, -0.00913, -0.00094, - 0.01682, -0.01066, 0.01361, 0.04752, + 0.01682, -0.01066, 0.01361, 0.04752, - 0.97349, 0.00504, + 0.97349, 0.00504, - 0.20303, -0.00206, + 0.20303, -0.00206, - 0.00012, 0.00327, + 0.00012, 0.00327, - 0.00504, 0.00040, + 0.00504, 0.00040, - -0.01599, -0.00570, + -0.01599, -0.00570, - -0.19375, -0.14714, 0.03820, -0.08283, + -0.19375, -0.14714, 0.03820, -0.08283, - -0.07716, 0.10543, -0.06772, 0.01131, + -0.07716, 0.10543, -0.06772, 0.01131, - 163.23023, -126.90743, -183.43441, -201.49515, - -559.82622, 698.28238, 1696.58461, 1279.45831, - 771.51923, -3358.57619, + 163.23023, -126.90743, -183.43441, -201.49515, + -559.82622, 698.28238, 1696.58461, 1279.45831, + 771.51923, -3358.57619, - -0.05911, 0.89279, -0.15861, 0.28577, - -0.06958, 0.02406, + -0.05911, 0.89279, -0.15861, 0.28577, + -0.06958, 0.02406, - 0.01999, 0.00382, + 0.01999, 0.00382, - -0.00934, 0.00014, + -0.00934, 0.00014, - 0.01792, -0.04249, 0.01019, -0.00210, + 0.01792, -0.04249, 0.01019, -0.00210, - -0.00386, 0.00009, + -0.00386, 0.00009, - -0.01353, 0.00101, + -0.01353, 0.00101, - -0.03828, -0.01677, -0.02026, 0.03079, + -0.03828, -0.01677, -0.02026, 0.03079, - -0.00285, -0.02484, 0.00537, -0.00397, + -0.00285, -0.02484, 0.00537, -0.00397, - -0.00064, 0.00906, + -0.00064, 0.00906, - -0.00411, 0.00100, + -0.00411, 0.00100, - -0.06940, -0.01482, + -0.06940, -0.01482, - -0.01966, -0.02171, 0.00388, -0.00840, + -0.01966, -0.02171, 0.00388, -0.00840, - -0.00621, -0.00597, + -0.00621, -0.00597, - -0.03690, -0.00959, -0.00115, -0.01557, + -0.03690, -0.00959, -0.00115, -0.01557, - 3.24906, -0.00580, + 3.24906, -0.00580, - 0.00745, 0.03347, -0.04023, 0.02174, - -0.01544, -0.02389, + 0.00745, 0.03347, -0.04023, 0.02174, + -0.01544, -0.02389, - 0.00935, -0.00141, -0.02018, 0.03258, - -0.04479, -0.02360, + 0.00935, -0.00141, -0.02018, 0.03258, + -0.04479, -0.02360, - -0.00542, -0.00194, + -0.00542, -0.00194, - -0.07906, 0.00273, + -0.07906, 0.00273, - -0.08439, 0.01534, -0.00264, -0.09205, + -0.08439, 0.01534, -0.00264, -0.09205, - -0.00539, 0.00220, + -0.00539, 0.00220, - 0.01263, 0.01593, 0.01103, -0.03324, + 0.01263, 0.01593, 0.01103, -0.03324, - -0.02720, 0.04749, -0.05099, 0.01807, + -0.02720, 0.04749, -0.05099, 0.01807, - -0.00443, 0.00024, + -0.00443, 0.00024, - -0.01386, 0.00029, -0.00443, -0.00591, + -0.01386, 0.00029, -0.00443, -0.00591, - -0.11899, 0.15817, -0.37728, 0.06552, + -0.11899, 0.15817, -0.37728, 0.06552, - -0.00669, -0.00140, + -0.00669, -0.00140, - -0.01168, -0.00690, + -0.01168, -0.00690, - -0.01032, 0.04315, -0.01082, 0.00123, + -0.01032, 0.04315, -0.01082, 0.00123, - 0.01192, -0.01071, -1.90746, 0.00700, + 0.01192, -0.01071, -1.90746, 0.00700, - 0.00779, 0.04261, 0.01052, 0.00173, + 0.00779, 0.04261, 0.01052, 0.00173, - -0.02138, 0.00307, + -0.02138, 0.00307, - 0.50118, -0.00330, + 0.50118, -0.00330, - -0.00111, 0.01624, + -0.00111, 0.01624, - -0.02601, 0.00305, 0.02348, 0.07058, + -0.02601, 0.00305, 0.02348, 0.07058, - -0.07622, 0.00006, + -0.07622, 0.00006, - -0.00183, 0.01636, + -0.00183, 0.01636, - -0.00037, 0.00564, + -0.00037, 0.00564, - 4.72127, 3.53639, 13.37363, -6.68745, - -12.29946, -22.51893, -27.18616, 22.85033, - 25.89912, 12.56594, + 4.72127, 3.53639, 13.37363, -6.68745, + -12.29946, -22.51893, -27.18616, 22.85033, + 25.89912, 12.56594, - -0.02566, 0.00307, -0.00064, -0.02727, + -0.02566, 0.00307, -0.00064, -0.02727, - -0.02634, -0.01101, -0.01029, 0.04755, + -0.02634, -0.01101, -0.01029, 0.04755, - -0.00372, -0.00292, + -0.00372, -0.00292, - -0.00582, -0.00053, + -0.00582, -0.00053, - 0.17840, 0.00027, + 0.17840, 0.00027, - -0.03400, 0.00357, + -0.03400, 0.00357, - -0.13428, -0.00611, + -0.13428, -0.00611, - 0.00099, -0.01169, + 0.00099, -0.01169, - 0.01909, 0.01338, 0.01302, -0.03071, + 0.01909, 0.01338, 0.01302, -0.03071, - -0.00051, 0.00577, + -0.00051, 0.00577, - 0.61945, -0.32627, -0.30811, -0.60197, - -0.22597, 0.28183, + 0.61945, -0.32627, -0.30811, -0.60197, + -0.22597, 0.28183, - 0.07739, 0.00011, + 0.07739, 0.00011, - 0.01336, -0.00010, + 0.01336, -0.00010, - 0.00049, -0.00592, + 0.00049, -0.00592, - -0.01407, -0.00081, + -0.01407, -0.00081, - 0.00146, -0.00280, + 0.00146, -0.00280, - 0.03795, 0.00003, + 0.03795, 0.00003, - 0.01173, -0.00655, -0.00344, -0.00403, + 0.01173, -0.00655, -0.00344, -0.00403, - 0.00036, -0.00047, 0.02000, 0.00001, + 0.00036, -0.00047, 0.02000, 0.00001, - 0.01105, 0.00002, + 0.01105, 0.00002, - 0.00620, -0.00052, + 0.00620, -0.00052, }; static signed char FAR earargs[] = { - 0, 3, - 3, 4, 3, -8, 4, 3, 5, 2, - 2, 2, 5, -5, 6, 1, - 3, 2, 2, 1, 3, -8, 4, 0, - 3, 3, 2, -7, 3, 4, 4, 1, - 3, 7, 3,-13, 4, -1, 5, 0, - 2, 8, 2,-13, 3, 3, - 3, 1, 2, -8, 3, 12, 4, 0, - 1, 1, 8, 0, - 1, 1, 7, 0, - 2, 1, 5, -2, 6, 0, - 3, 3, 3, -6, 4, 2, 5, 1, - 2, 8, 3,-15, 4, 3, - 2, 2, 5, -4, 6, 0, - 1, 1, 6, 1, - 2, 9, 3,-17, 4, 2, - 3, 3, 2, -5, 3, 1, 5, 0, - 3, 2, 3, -4, 4, 2, 5, 0, - 3, 3, 2, -5, 3, 2, 5, 0, - 2, 1, 5, -1, 6, 0, - 2, 1, 3, -2, 4, 2, - 2, 2, 5, -3, 6, 0, - 1, 2, 6, 1, - 2, 3, 5, -5, 6, 1, - 1, 1, 5, 3, - 2, 1, 5, -5, 6, 0, - 2, 7, 3,-13, 4, 2, - 2, 2, 5, -2, 6, 0, - 2, 3, 2, -5, 3, 2, - 2, 2, 3, -4, 4, 2, - 2, 5, 2, -8, 3, 1, - 2, 6, 3,-11, 4, 1, - 2, 1, 1, -4, 3, 0, - 1, 2, 5, 1, - 2, 3, 3, -6, 4, 1, - 2, 5, 3, -9, 4, 1, - 2, 2, 2, -3, 3, 2, - 2, 4, 3, -8, 4, 1, - 2, 4, 3, -7, 4, 1, - 2, 3, 3, -5, 4, 1, - 2, 1, 2, -2, 3, 1, - 2, 2, 3, -3, 4, 1, - 2, 1, 3, -1, 4, 0, - 2, 4, 2, -7, 3, 0, - 2, 4, 2, -6, 3, 1, - 1, 1, 4, 1, - 2, 1, 3, -3, 4, 0, - 2, 7, 3,-12, 4, 0, - 2, 1, 2, -1, 3, 0, - 2, 1, 3, -4, 5, 0, - 2, 6, 3,-10, 4, 1, - 2, 5, 3, -8, 4, 1, - 2, 1, 3, -3, 5, 1, - 2, 2, 2, -4, 3, 1, - 2, 6, 2, -9, 3, 0, - 2, 4, 3, -6, 4, 1, - 3, 1, 3, -3, 5, 2, 6, 0, - 2, 1, 3, -5, 6, 1, - 2, 1, 3, -2, 5, 2, - 3, 1, 3, -4, 5, 5, 6, 0, - 2, 3, 3, -4, 4, 1, - 2, 3, 2, -4, 3, 2, - 2, 1, 3, -3, 6, 1, - 3, 1, 3, 1, 5, -5, 6, 1, - 2, 1, 3, -1, 5, 1, - 3, 1, 3, -3, 5, 5, 6, 1, - 2, 1, 3, -2, 6, 1, - 2, 2, 3, -2, 4, 0, - 2, 1, 3, -1, 6, 0, - 2, 1, 3, -2, 7, 0, - 2, 1, 3, -1, 7, 0, - 2, 8, 2,-14, 3, 0, - 3, 1, 3, 2, 5, -5, 6, 1, - 3, 5, 3, -8, 4, 3, 5, 1, - 1, 1, 3, 4, - 3, 3, 3, -8, 4, 3, 5, 2, - 2, 8, 2,-12, 3, 0, - 3, 1, 3, 1, 5, -2, 6, 0, - 2, 9, 3,-15, 4, 1, - 2, 1, 3, 1, 6, 0, - 1, 2, 4, 0, - 2, 1, 3, 1, 5, 1, - 2, 8, 3,-13, 4, 1, - 2, 3, 2, -6, 3, 0, - 2, 1, 3, -4, 4, 0, - 2, 5, 2, -7, 3, 0, - 2, 7, 3,-11, 4, 1, - 2, 1, 1, -3, 3, 0, - 2, 6, 3, -9, 4, 1, - 2, 2, 2, -2, 3, 0, - 2, 5, 3, -7, 4, 2, - 2, 4, 3, -5, 4, 2, - 2, 1, 2, -3, 3, 0, - 2, 3, 3, -3, 4, 0, - 2, 4, 2, -5, 3, 1, - 2, 2, 3, -5, 5, 0, - 1, 1, 2, 1, - 2, 2, 3, -4, 5, 1, - 3, 2, 3, -4, 5, 2, 6, 0, - 2, 6, 3, -8, 4, 1, - 2, 2, 3, -3, 5, 1, - 2, 6, 2, -8, 3, 0, - 2, 5, 3, -6, 4, 0, - 2, 2, 3, -5, 6, 1, - 2, 2, 3, -2, 5, 1, - 3, 2, 3, -4, 5, 5, 6, 1, - 2, 4, 3, -4, 4, 0, - 2, 3, 2, -3, 3, 0, - 2, 2, 3, -3, 6, 0, - 2, 2, 3, -1, 5, 1, - 2, 2, 3, -2, 6, 0, - 2, 3, 3, -2, 4, 0, - 2, 2, 3, -1, 6, 0, - 1, 2, 3, 4, - 2, 5, 2, -6, 3, 1, - 2, 2, 2, -1, 3, 1, - 2, 6, 3, -7, 4, 0, - 2, 5, 3, -5, 4, 0, - 2, 4, 2, -4, 3, 0, - 2, 3, 3, -4, 5, 0, - 2, 3, 3, -3, 5, 0, - 2, 6, 2, -7, 3, 0, - 2, 3, 3, -2, 5, 1, - 2, 3, 2, -2, 3, 0, - 1, 3, 3, 2, - 2, 5, 2, -5, 3, 0, - 2, 1, 1, -1, 3, 0, - 2, 7, 2, -8, 3, 0, - 2, 4, 3, -4, 5, 0, - 2, 4, 3, -3, 5, 0, - 2, 6, 2, -6, 3, 0, - 1, 4, 3, 1, - 2, 7, 2, -7, 3, 1, - 2, 8, 2, -8, 3, 0, - 2, 9, 2, -9, 3, 0, - -1 + 0, 3, + 3, 4, 3, -8, 4, 3, 5, 2, + 2, 2, 5, -5, 6, 1, + 3, 2, 2, 1, 3, -8, 4, 0, + 3, 3, 2, -7, 3, 4, 4, 1, + 3, 7, 3, -13, 4, -1, 5, 0, + 2, 8, 2, -13, 3, 3, + 3, 1, 2, -8, 3, 12, 4, 0, + 1, 1, 8, 0, + 1, 1, 7, 0, + 2, 1, 5, -2, 6, 0, + 3, 3, 3, -6, 4, 2, 5, 1, + 2, 8, 3, -15, 4, 3, + 2, 2, 5, -4, 6, 0, + 1, 1, 6, 1, + 2, 9, 3, -17, 4, 2, + 3, 3, 2, -5, 3, 1, 5, 0, + 3, 2, 3, -4, 4, 2, 5, 0, + 3, 3, 2, -5, 3, 2, 5, 0, + 2, 1, 5, -1, 6, 0, + 2, 1, 3, -2, 4, 2, + 2, 2, 5, -3, 6, 0, + 1, 2, 6, 1, + 2, 3, 5, -5, 6, 1, + 1, 1, 5, 3, + 2, 1, 5, -5, 6, 0, + 2, 7, 3, -13, 4, 2, + 2, 2, 5, -2, 6, 0, + 2, 3, 2, -5, 3, 2, + 2, 2, 3, -4, 4, 2, + 2, 5, 2, -8, 3, 1, + 2, 6, 3, -11, 4, 1, + 2, 1, 1, -4, 3, 0, + 1, 2, 5, 1, + 2, 3, 3, -6, 4, 1, + 2, 5, 3, -9, 4, 1, + 2, 2, 2, -3, 3, 2, + 2, 4, 3, -8, 4, 1, + 2, 4, 3, -7, 4, 1, + 2, 3, 3, -5, 4, 1, + 2, 1, 2, -2, 3, 1, + 2, 2, 3, -3, 4, 1, + 2, 1, 3, -1, 4, 0, + 2, 4, 2, -7, 3, 0, + 2, 4, 2, -6, 3, 1, + 1, 1, 4, 1, + 2, 1, 3, -3, 4, 0, + 2, 7, 3, -12, 4, 0, + 2, 1, 2, -1, 3, 0, + 2, 1, 3, -4, 5, 0, + 2, 6, 3, -10, 4, 1, + 2, 5, 3, -8, 4, 1, + 2, 1, 3, -3, 5, 1, + 2, 2, 2, -4, 3, 1, + 2, 6, 2, -9, 3, 0, + 2, 4, 3, -6, 4, 1, + 3, 1, 3, -3, 5, 2, 6, 0, + 2, 1, 3, -5, 6, 1, + 2, 1, 3, -2, 5, 2, + 3, 1, 3, -4, 5, 5, 6, 0, + 2, 3, 3, -4, 4, 1, + 2, 3, 2, -4, 3, 2, + 2, 1, 3, -3, 6, 1, + 3, 1, 3, 1, 5, -5, 6, 1, + 2, 1, 3, -1, 5, 1, + 3, 1, 3, -3, 5, 5, 6, 1, + 2, 1, 3, -2, 6, 1, + 2, 2, 3, -2, 4, 0, + 2, 1, 3, -1, 6, 0, + 2, 1, 3, -2, 7, 0, + 2, 1, 3, -1, 7, 0, + 2, 8, 2, -14, 3, 0, + 3, 1, 3, 2, 5, -5, 6, 1, + 3, 5, 3, -8, 4, 3, 5, 1, + 1, 1, 3, 4, + 3, 3, 3, -8, 4, 3, 5, 2, + 2, 8, 2, -12, 3, 0, + 3, 1, 3, 1, 5, -2, 6, 0, + 2, 9, 3, -15, 4, 1, + 2, 1, 3, 1, 6, 0, + 1, 2, 4, 0, + 2, 1, 3, 1, 5, 1, + 2, 8, 3, -13, 4, 1, + 2, 3, 2, -6, 3, 0, + 2, 1, 3, -4, 4, 0, + 2, 5, 2, -7, 3, 0, + 2, 7, 3, -11, 4, 1, + 2, 1, 1, -3, 3, 0, + 2, 6, 3, -9, 4, 1, + 2, 2, 2, -2, 3, 0, + 2, 5, 3, -7, 4, 2, + 2, 4, 3, -5, 4, 2, + 2, 1, 2, -3, 3, 0, + 2, 3, 3, -3, 4, 0, + 2, 4, 2, -5, 3, 1, + 2, 2, 3, -5, 5, 0, + 1, 1, 2, 1, + 2, 2, 3, -4, 5, 1, + 3, 2, 3, -4, 5, 2, 6, 0, + 2, 6, 3, -8, 4, 1, + 2, 2, 3, -3, 5, 1, + 2, 6, 2, -8, 3, 0, + 2, 5, 3, -6, 4, 0, + 2, 2, 3, -5, 6, 1, + 2, 2, 3, -2, 5, 1, + 3, 2, 3, -4, 5, 5, 6, 1, + 2, 4, 3, -4, 4, 0, + 2, 3, 2, -3, 3, 0, + 2, 2, 3, -3, 6, 0, + 2, 2, 3, -1, 5, 1, + 2, 2, 3, -2, 6, 0, + 2, 3, 3, -2, 4, 0, + 2, 2, 3, -1, 6, 0, + 1, 2, 3, 4, + 2, 5, 2, -6, 3, 1, + 2, 2, 2, -1, 3, 1, + 2, 6, 3, -7, 4, 0, + 2, 5, 3, -5, 4, 0, + 2, 4, 2, -4, 3, 0, + 2, 3, 3, -4, 5, 0, + 2, 3, 3, -3, 5, 0, + 2, 6, 2, -7, 3, 0, + 2, 3, 3, -2, 5, 1, + 2, 3, 2, -2, 3, 0, + 1, 3, 3, 2, + 2, 5, 2, -5, 3, 0, + 2, 1, 1, -1, 3, 0, + 2, 7, 2, -8, 3, 0, + 2, 4, 3, -4, 5, 0, + 2, 4, 3, -3, 5, 0, + 2, 6, 2, -6, 3, 0, + 1, 4, 3, 1, + 2, 7, 2, -7, 3, 1, + 2, 8, 2, -8, 3, 0, + 2, 9, 2, -9, 3, 0, + -1 }; + /* Total terms = 135, small = 134 */ static struct plantbl FAR ear404 = { - { 1, 9, 14, 17, 5, 5, 2, 1, 0,}, - 4, - earargs, - eartabl, - eartabb, - eartabr, - 1.0, + {1, 9, 14, 17, 5, 5, 2, 1, 0,}, + 4, + earargs, + eartabl, + eartabb, + eartabr, + 1.0, }; /* @@ -2968,1545 +2979,1548 @@ Days per record = 4.0 */ static double FAR martabl[] = { - 43471.66140, 21291.11063, 2033.37848, 6890507597.78366, - 1279543.73631, + 43471.66140, 21291.11063, 2033.37848, 6890507597.78366, + 1279543.73631, - 317.74183, 730.69258, -15.26502, 277.56960, - -62.96711, 20.96285, + 317.74183, 730.69258, -15.26502, 277.56960, + -62.96711, 20.96285, - 1.01857, -2.19395, + 1.01857, -2.19395, - 3.75708, 3.65854, 0.01049, 1.09183, + 3.75708, 3.65854, 0.01049, 1.09183, - -0.00605, -0.04769, + -0.00605, -0.04769, - 0.41839, 0.10091, 0.03887, 0.11666, + 0.41839, 0.10091, 0.03887, 0.11666, - -0.03301, 0.02664, + -0.03301, 0.02664, - 0.38777, -0.56974, + 0.38777, -0.56974, - 0.02974, -0.15041, 0.02179, -0.00808, + 0.02974, -0.15041, 0.02179, -0.00808, - 0.08594, 0.09773, + 0.08594, 0.09773, - -0.00902, -0.04597, 0.00762, -0.03858, + -0.00902, -0.04597, 0.00762, -0.03858, - -0.00139, 0.01562, + -0.00139, 0.01562, - 0.02019, 0.01878, + 0.02019, 0.01878, - -0.01244, 0.00795, + -0.01244, 0.00795, - 0.00815, 0.03501, + 0.00815, 0.03501, - -0.00335, -0.02970, + -0.00335, -0.02970, - -0.00518, -0.01763, + -0.00518, -0.01763, - 0.17257, 0.14698, -0.14417, 0.26028, + 0.17257, 0.14698, -0.14417, 0.26028, - 0.00062, -0.00180, + 0.00062, -0.00180, - 13.35262, 39.38771, -15.49558, 22.00150, - -7.71321, -4.20035, 0.62074, -1.42376, + 13.35262, 39.38771, -15.49558, 22.00150, + -7.71321, -4.20035, 0.62074, -1.42376, - 0.07043, -0.06670, 0.16960, -0.06859, - 0.07787, 0.01845, + 0.07043, -0.06670, 0.16960, -0.06859, + 0.07787, 0.01845, - -0.01608, -0.00914, + -0.01608, -0.00914, - 5.60438, -3.44436, 5.88876, 6.77238, - -5.29704, 3.48944, + 5.60438, -3.44436, 5.88876, 6.77238, + -5.29704, 3.48944, - 0.01291, 0.01280, + 0.01291, 0.01280, - -0.53532, 0.86584, 0.79604, 0.31635, + -0.53532, 0.86584, 0.79604, 0.31635, - -3.92977, -0.94829, -0.74254, -1.37947, - 0.17871, -0.12477, + -3.92977, -0.94829, -0.74254, -1.37947, + 0.17871, -0.12477, - 0.00171, 0.11537, + 0.00171, 0.11537, - 0.02281, -0.03922, + 0.02281, -0.03922, - -0.00165, 0.02965, + -0.00165, 0.02965, - 1.59773, 1.24565, -0.35802, 1.37272, - -0.44811, -0.08611, + 1.59773, 1.24565, -0.35802, 1.37272, + -0.44811, -0.08611, - 3.04184, -3.39729, 8.86270, 6.65967, - -9.10580, 10.66103, + 3.04184, -3.39729, 8.86270, 6.65967, + -9.10580, 10.66103, - 0.02015, -0.00902, + 0.02015, -0.00902, - -0.01166, -0.23957, -0.12128, -0.04640, + -0.01166, -0.23957, -0.12128, -0.04640, - -0.07114, 0.14053, -0.04966, -0.01665, + -0.07114, 0.14053, -0.04966, -0.01665, - 0.28411, -0.37754, -1.26265, 1.01377, - 3.70433, -0.21025, + 0.28411, -0.37754, -1.26265, 1.01377, + 3.70433, -0.21025, - -0.00972, 0.00350, + -0.00972, 0.00350, - 0.00997, 0.00450, + 0.00997, 0.00450, - -2.15305, 3.18147, -1.81957, -0.02321, - -0.02560, -0.35188, + -2.15305, 3.18147, -1.81957, -0.02321, + -0.02560, -0.35188, - 0.00003, -0.01110, + 0.00003, -0.01110, - 0.00244, -0.05083, + 0.00244, -0.05083, - -0.00216, -0.02026, + -0.00216, -0.02026, - 0.05179, 0.04188, + 0.05179, 0.04188, - 5.92031, -1.61316, 3.72001, 6.98783, - -4.17690, 2.61250, + 5.92031, -1.61316, 3.72001, 6.98783, + -4.17690, 2.61250, - 0.04157, 2.76453, -1.34043, 0.74586, - -0.20258, -0.30467, + 0.04157, 2.76453, -1.34043, 0.74586, + -0.20258, -0.30467, - 0.00733, 0.00376, + 0.00733, 0.00376, - 1.72800, 0.76593, 1.26577, -2.02682, - -1.14637, -0.91894, + 1.72800, 0.76593, 1.26577, -2.02682, + -1.14637, -0.91894, - -0.00002, 0.00036, + -0.00002, 0.00036, - 2.54213, 0.89533, -0.04166, 2.36838, - -0.97069, 0.05486, + 2.54213, 0.89533, -0.04166, 2.36838, + -0.97069, 0.05486, - 0.46927, 0.04500, 0.23388, 0.35005, + 0.46927, 0.04500, 0.23388, 0.35005, - 1.61402, 2.30209, -0.99859, 1.63349, - -0.51490, -0.26112, + 1.61402, 2.30209, -0.99859, 1.63349, + -0.51490, -0.26112, - 0.27848, -0.26100, -0.07645, -0.22001, + 0.27848, -0.26100, -0.07645, -0.22001, - 0.92901, 1.12627, -0.39829, 0.77120, - -0.23716, -0.11245, + 0.92901, 1.12627, -0.39829, 0.77120, + -0.23716, -0.11245, - -0.02387, 0.03960, + -0.02387, 0.03960, - -0.00802, 0.02179, + -0.00802, 0.02179, - 2.86448, 1.00246, -0.14647, 2.80278, - -1.14143, 0.05177, + 2.86448, 1.00246, -0.14647, 2.80278, + -1.14143, 0.05177, - 1.68671, -1.23451, 3.16285, 0.70070, - 0.25817, 3.17416, + 1.68671, -1.23451, 3.16285, 0.70070, + 0.25817, 3.17416, - 0.07447, -0.08116, -0.03029, -0.02795, + 0.07447, -0.08116, -0.03029, -0.02795, - 0.00816, 0.01023, + 0.00816, 0.01023, - 0.00685, -0.01075, + 0.00685, -0.01075, - -0.34268, 0.03680, -0.05488, -0.07430, + -0.34268, 0.03680, -0.05488, -0.07430, - -0.00041, -0.02968, + -0.00041, -0.02968, - 3.13228, -0.83209, 1.95765, 3.78394, - -2.26196, 1.38520, + 3.13228, -0.83209, 1.95765, 3.78394, + -2.26196, 1.38520, - -0.00401, -0.01397, + -0.00401, -0.01397, - 1.01604, -0.99485, 0.62465, 0.22431, - -0.05076, 0.12025, + 1.01604, -0.99485, 0.62465, 0.22431, + -0.05076, 0.12025, - 4.35229, -5.04483, 14.87533, 9.00826, - -10.37595, 19.26596, + 4.35229, -5.04483, 14.87533, 9.00826, + -10.37595, 19.26596, - 0.40352, 0.19895, 0.09463, -0.10774, + 0.40352, 0.19895, 0.09463, -0.10774, - -0.17809, -0.08979, -0.00796, -0.04313, + -0.17809, -0.08979, -0.00796, -0.04313, - 0.01520, -0.03538, + 0.01520, -0.03538, - 1.53301, -1.75553, 4.87236, 3.23662, - -3.62305, 6.42351, + 1.53301, -1.75553, 4.87236, 3.23662, + -3.62305, 6.42351, - -0.00439, -0.01305, + -0.00439, -0.01305, - 0.17194, -0.64003, 0.26609, 0.06600, + 0.17194, -0.64003, 0.26609, 0.06600, - 0.01767, -0.00251, + 0.01767, -0.00251, - -0.08871, -0.15523, 0.01201, -0.03408, + -0.08871, -0.15523, 0.01201, -0.03408, - -0.29126, -0.07093, -0.00998, -0.07876, + -0.29126, -0.07093, -0.00998, -0.07876, - 1.05932, -25.38650, + 1.05932, -25.38650, - -0.29354, 0.04179, -0.01726, 0.07473, + -0.29354, 0.04179, -0.01726, 0.07473, - -0.07607, -0.08859, 0.00842, -0.02359, + -0.07607, -0.08859, 0.00842, -0.02359, - 0.47858, -0.39809, 1.25061, 0.87017, - -0.82453, 1.56864, + 0.47858, -0.39809, 1.25061, 0.87017, + -0.82453, 1.56864, - -0.00463, 0.02385, + -0.00463, 0.02385, - -0.29070, 8.56535, + -0.29070, 8.56535, - -0.12495, 0.06580, -0.03395, -0.02465, + -0.12495, 0.06580, -0.03395, -0.02465, - -1.06759, 0.47004, -0.40281, -0.23957, - 0.03572, -0.07012, + -1.06759, 0.47004, -0.40281, -0.23957, + 0.03572, -0.07012, - 0.00571, -0.00731, + 0.00571, -0.00731, - 0.18601, -1.34068, + 0.18601, -1.34068, - 0.03798, -0.00532, 0.00448, -0.01147, + 0.03798, -0.00532, 0.00448, -0.01147, - 1.41208, -0.00668, 0.25883, 1.23788, - -0.57774, 0.09166, + 1.41208, -0.00668, 0.25883, 1.23788, + -0.57774, 0.09166, - -2.49664, -0.25235, -0.53582, -0.80126, - 0.10827, -0.08861, + -2.49664, -0.25235, -0.53582, -0.80126, + 0.10827, -0.08861, - -0.03577, 0.06825, + -0.03577, 0.06825, - -0.00143, 0.04633, + -0.00143, 0.04633, - 0.01586, -0.01056, + 0.01586, -0.01056, - -0.02106, 0.03804, + -0.02106, 0.03804, - -0.00088, -0.03458, + -0.00088, -0.03458, - -0.00033, -0.01079, + -0.00033, -0.01079, - 0.05821, -0.02445, + 0.05821, -0.02445, - 0.00602, 0.00721, + 0.00602, 0.00721, - -0.00315, -0.01021, + -0.00315, -0.01021, - -0.65454, 1.08478, -0.44593, -0.21492, + -0.65454, 1.08478, -0.44593, -0.21492, - -1.35004, 4.47299, -4.19170, 3.51236, + -1.35004, 4.47299, -4.19170, 3.51236, - 1946.04629, 13960.88247, 576.24572, 8023.81797, - 2402.48512, -753.87007, -6376.99217, -10278.88014, - -25743.89874, 15506.87748, 15609.59853, 35173.63133, + 1946.04629, 13960.88247, 576.24572, 8023.81797, + 2402.48512, -753.87007, -6376.99217, -10278.88014, + -25743.89874, 15506.87748, 15609.59853, 35173.63133, - -3.70370, 6.29538, -4.84183, -0.76942, + -3.70370, 6.29538, -4.84183, -0.76942, - -0.02465, -0.03840, + -0.02465, -0.03840, - 0.00565, -0.06071, + 0.00565, -0.06071, - 0.01174, 0.00253, + 0.01174, 0.00253, - -0.00230, 0.05252, + -0.00230, 0.05252, - -0.02813, 0.01359, + -0.02813, 0.01359, - 0.23208, 0.03393, 0.01734, 0.04838, + 0.23208, 0.03393, 0.01734, 0.04838, - -0.46340, -0.18941, 0.25428, -0.56925, + -0.46340, -0.18941, 0.25428, -0.56925, - 0.05213, 0.24704, 0.12922, -0.01531, + 0.05213, 0.24704, 0.12922, -0.01531, - 0.06885, -0.08510, 0.01853, -0.00390, + 0.06885, -0.08510, 0.01853, -0.00390, - 0.01196, -0.30530, 0.13117, -0.03533, + 0.01196, -0.30530, 0.13117, -0.03533, - 1.79597, -0.42743, 0.98545, 2.13503, - -1.32942, 0.68005, + 1.79597, -0.42743, 0.98545, 2.13503, + -1.32942, 0.68005, - -0.01226, 0.00571, + -0.01226, 0.00571, - 0.31081, 0.34932, 0.34531, -0.32947, + 0.31081, 0.34932, 0.34531, -0.32947, - -0.00548, 0.00186, -0.00157, -0.00065, + -0.00548, 0.00186, -0.00157, -0.00065, - 0.30877, -0.03864, 0.04921, 0.06693, + 0.30877, -0.03864, 0.04921, 0.06693, - 0.01761, -0.04119, + 0.01761, -0.04119, - 1.28318, 0.38546, 0.06462, 1.18337, - -0.48698, 0.07086, + 1.28318, 0.38546, 0.06462, 1.18337, + -0.48698, 0.07086, - 0.26031, -0.22813, 0.10272, 0.04737, + 0.26031, -0.22813, 0.10272, 0.04737, - -0.04506, -0.38581, -0.16624, -0.04588, + -0.04506, -0.38581, -0.16624, -0.04588, - 0.00992, 0.00722, + 0.00992, 0.00722, - -0.21041, 0.20560, -0.09267, -0.03438, + -0.21041, 0.20560, -0.09267, -0.03438, - 0.32264, -0.07383, + 0.32264, -0.07383, - 0.09553, -0.38730, 0.17109, -0.01342, + 0.09553, -0.38730, 0.17109, -0.01342, - -0.02336, -0.01286, + -0.02336, -0.01286, - 0.00230, 0.04626, + 0.00230, 0.04626, - 0.01176, 0.01868, + 0.01176, 0.01868, - -0.15411, -0.32799, 0.22083, -0.14077, + -0.15411, -0.32799, 0.22083, -0.14077, - 1.98392, 1.68058, + 1.98392, 1.68058, - -0.02526, -0.13164, -0.04447, -0.00153, + -0.02526, -0.13164, -0.04447, -0.00153, - 0.01277, 0.00553, + 0.01277, 0.00553, - -0.26035, -0.11362, 0.14672, -0.32242, + -0.26035, -0.11362, 0.14672, -0.32242, - 0.16686, -0.69957, 0.40091, -0.06721, - 0.00837, 0.09635, + 0.16686, -0.69957, 0.40091, -0.06721, + 0.00837, 0.09635, - -0.08545, 0.25178, -0.22486, 16.03256, + -0.08545, 0.25178, -0.22486, 16.03256, - 0.34130, -0.06313, 0.01469, -0.09012, + 0.34130, -0.06313, 0.01469, -0.09012, - -0.00744, -0.02510, + -0.00744, -0.02510, - -0.08492, -0.13733, + -0.08492, -0.13733, - -0.07620, -0.15329, 0.13716, -0.03769, + -0.07620, -0.15329, 0.13716, -0.03769, - 2.01176, -1.35991, -1.04319, -2.97226, + 2.01176, -1.35991, -1.04319, -2.97226, - -0.01433, 0.61219, + -0.01433, 0.61219, - -0.55522, 0.38579, 0.31831, 0.81843, + -0.55522, 0.38579, 0.31831, 0.81843, - -0.04583, -0.14585, + -0.04583, -0.14585, - -0.10218, 0.16039, -0.06552, -0.01802, + -0.10218, 0.16039, -0.06552, -0.01802, - 0.06480, -0.06641, 0.01672, -0.00287, + 0.06480, -0.06641, 0.01672, -0.00287, - 0.00308, 0.09982, -0.05679, -0.00249, + 0.00308, 0.09982, -0.05679, -0.00249, - -0.36034, 0.52385, -0.29759, 0.59539, + -0.36034, 0.52385, -0.29759, 0.59539, - -3.59641, -1.02499, + -3.59641, -1.02499, - -547.53774, 734.11470, 441.86760, -626.68255, - -2255.81376, -1309.01028, -2025.69590, 2774.69901, - 1711.21478, 1509.99797, + -547.53774, 734.11470, 441.86760, -626.68255, + -2255.81376, -1309.01028, -2025.69590, 2774.69901, + 1711.21478, 1509.99797, - -0.99274, 0.61858, -0.47634, -0.33034, + -0.99274, 0.61858, -0.47634, -0.33034, - 0.00261, 0.01183, + 0.00261, 0.01183, - -0.00038, 0.11687, + -0.00038, 0.11687, - 0.00994, -0.01122, + 0.00994, -0.01122, - 0.03482, -0.01942, + 0.03482, -0.01942, - -0.11557, 0.38237, -0.17826, 0.00830, + -0.11557, 0.38237, -0.17826, 0.00830, - 0.01193, -0.05469, + 0.01193, -0.05469, - 0.01557, 0.01747, + 0.01557, 0.01747, - 0.02730, -0.01182, + 0.02730, -0.01182, - -0.11284, 0.12939, -0.05621, -0.01615, + -0.11284, 0.12939, -0.05621, -0.01615, - 0.04258, 0.01058, + 0.04258, 0.01058, - -0.01723, 0.00963, + -0.01723, 0.00963, - 0.20666, 0.11742, + 0.20666, 0.11742, - 0.07830, -0.02922, + 0.07830, -0.02922, - -0.10659, -0.05407, 0.07254, -0.13005, + -0.10659, -0.05407, 0.07254, -0.13005, - -0.02365, 0.24583, 0.31915, 1.27060, + -0.02365, 0.24583, 0.31915, 1.27060, - 0.00009, -0.21541, + 0.00009, -0.21541, - -0.55324, -0.45999, -1.45885, 0.86530, - 0.85932, 1.92999, + -0.55324, -0.45999, -1.45885, 0.86530, + 0.85932, 1.92999, - -0.00755, -0.00715, + -0.00755, -0.00715, - -0.02004, -0.00788, + -0.02004, -0.00788, - 0.01539, 0.00837, + 0.01539, 0.00837, - 0.27652, -0.50297, -0.26703, -0.28159, + 0.27652, -0.50297, -0.26703, -0.28159, - 0.03950, 0.07182, + 0.03950, 0.07182, - -0.07177, 0.14140, 0.07693, 0.07564, + -0.07177, 0.14140, 0.07693, 0.07564, - -0.01316, -0.01259, + -0.01316, -0.01259, - 0.01529, 0.07773, + 0.01529, 0.07773, - -90.74225, -378.15784, -510.30190, -52.35396, - -89.15267, 415.56828, 181.52119, 54.01570, + -90.74225, -378.15784, -510.30190, -52.35396, + -89.15267, 415.56828, 181.52119, 54.01570, - -0.01093, -0.05931, + -0.01093, -0.05931, - -0.01344, -0.02390, + -0.01344, -0.02390, - 0.01432, -0.02470, + 0.01432, -0.02470, - -0.01509, -0.01346, + -0.01509, -0.01346, - 0.03352, 0.02248, + 0.03352, 0.02248, - 0.02588, -0.00948, + 0.02588, -0.00948, - 0.03610, 0.17238, + 0.03610, 0.17238, - 0.02909, -0.04065, + 0.02909, -0.04065, - 0.00155, -0.07025, + 0.00155, -0.07025, - -0.09508, 0.14487, 0.12441, 0.16451, + -0.09508, 0.14487, 0.12441, 0.16451, - 0.00001, -0.00005, + 0.00001, -0.00005, - -0.00982, -0.01895, + -0.00982, -0.01895, - -0.16968, 0.36565, 0.20234, 0.17789, + -0.16968, 0.36565, 0.20234, 0.17789, - -0.04519, -0.00588, + -0.04519, -0.00588, - 0.01268, 0.00107, + 0.01268, 0.00107, - -56.32137, -58.22145, -80.55270, 28.14532, - 11.43301, 52.05752, 17.79480, -2.61997, + -56.32137, -58.22145, -80.55270, 28.14532, + 11.43301, 52.05752, 17.79480, -2.61997, - -0.00005, -0.02629, + -0.00005, -0.02629, - 0.01080, -0.00390, + 0.01080, -0.00390, - 0.00744, 0.03132, + 0.00744, 0.03132, - 0.01156, -0.01621, + 0.01156, -0.01621, - 0.02162, 0.02552, + 0.02162, 0.02552, - 0.00075, -0.02497, + 0.00075, -0.02497, - 0.02495, 0.00830, + 0.02495, 0.00830, - 0.03230, 0.00103, + 0.03230, 0.00103, - -14.84965, -4.50200, -9.73043, 9.40426, - 4.08054, 5.38571, 1.53731, -1.01288, + -14.84965, -4.50200, -9.73043, 9.40426, + 4.08054, 5.38571, 1.53731, -1.01288, - 0.21076, 1.74227, 0.79760, 0.39583, - 0.09879, -0.16736, + 0.21076, 1.74227, 0.79760, 0.39583, + 0.09879, -0.16736, - -0.00723, -0.01536, + -0.00723, -0.01536, }; + static double FAR martabb[] = { - -364.49380, -47.17612, -554.97858, -430.63121, - 596.44312, + -364.49380, -47.17612, -554.97858, -430.63121, + 596.44312, - -3.94434, -7.43169, -0.06665, -2.23987, - 0.10366, -0.05567, + -3.94434, -7.43169, -0.06665, -2.23987, + 0.10366, -0.05567, - -0.01463, 0.01908, + -0.01463, 0.01908, - -0.02611, -0.00350, -0.01057, -0.00610, + -0.02611, -0.00350, -0.01057, -0.00610, - -0.00015, 0.00002, + -0.00015, 0.00002, - 0.00010, 0.00033, 0.00007, -0.00000, + 0.00010, 0.00033, 0.00007, -0.00000, - -0.00010, -0.00004, + -0.00010, -0.00004, - 0.00012, 0.00002, + 0.00012, 0.00002, - -0.00014, -0.00048, -0.00003, -0.00007, + -0.00014, -0.00048, -0.00003, -0.00007, - 0.00008, -0.00005, + 0.00008, -0.00005, - -0.00043, -0.00003, -0.00010, -0.00004, + -0.00043, -0.00003, -0.00010, -0.00004, - 0.00001, 0.00001, + 0.00001, 0.00001, - -0.00003, -0.00003, + -0.00003, -0.00003, - 0.00004, 0.00007, + 0.00004, 0.00007, - -0.00041, 0.00031, + -0.00041, 0.00031, - 0.00076, 0.00062, + 0.00076, 0.00062, - 0.00001, -0.00002, + 0.00001, -0.00002, - 0.00035, 0.00053, 0.00026, 0.00019, + 0.00035, 0.00053, 0.00026, 0.00019, - 0.00020, 0.00010, + 0.00020, 0.00010, - 0.02936, 0.09624, -0.01153, 0.01386, - 0.00551, -0.00690, 0.00196, 0.00148, + 0.02936, 0.09624, -0.01153, 0.01386, + 0.00551, -0.00690, 0.00196, 0.00148, - -0.00408, -0.00673, -0.00067, -0.00152, - -0.00014, -0.00005, + -0.00408, -0.00673, -0.00067, -0.00152, + -0.00014, -0.00005, - 0.00000, 0.00005, + 0.00000, 0.00005, - -0.00116, 0.00276, -0.00391, 0.00983, - -0.01327, -0.01986, + -0.00116, 0.00276, -0.00391, 0.00983, + -0.01327, -0.01986, - -0.00003, 0.00001, + -0.00003, 0.00001, - 0.01104, 0.00631, -0.01364, 0.01152, + 0.01104, 0.00631, -0.01364, 0.01152, - -0.00439, 0.01103, -0.00546, 0.00181, - -0.00039, -0.00083, + -0.00439, 0.01103, -0.00546, 0.00181, + -0.00039, -0.00083, - 0.00007, 0.00002, + 0.00007, 0.00002, - -0.00010, -0.00008, + -0.00010, -0.00008, - 0.00005, 0.00002, + 0.00005, 0.00002, - -0.00584, 0.00512, -0.00722, -0.00174, - 0.00101, -0.00316, + -0.00584, 0.00512, -0.00722, -0.00174, + 0.00101, -0.00316, - -0.02229, -0.02797, -0.10718, 0.05741, - 0.11403, 0.10033, + -0.02229, -0.02797, -0.10718, 0.05741, + 0.11403, 0.10033, - 0.00036, -0.00022, + 0.00036, -0.00022, - 0.00787, 0.01191, 0.01756, -0.02121, + 0.00787, 0.01191, 0.01756, -0.02121, - -0.00169, -0.00364, 0.00070, -0.00051, + -0.00169, -0.00364, 0.00070, -0.00051, - 0.01850, -0.06836, 0.21471, 0.00162, - -0.29165, 0.16799, + 0.01850, -0.06836, 0.21471, 0.00162, + -0.29165, 0.16799, - -0.00002, 0.00011, + -0.00002, 0.00011, - -0.00075, -0.00077, + -0.00075, -0.00077, - -0.00675, -0.00814, 0.00029, -0.00599, - 0.00107, 0.00013, + -0.00675, -0.00814, 0.00029, -0.00599, + 0.00107, 0.00013, - 0.00010, -0.00002, + 0.00010, -0.00002, - 0.00005, 0.00020, + 0.00005, 0.00020, - 0.00355, 0.00306, + 0.00355, 0.00306, - -0.00013, -0.00061, + -0.00013, -0.00061, - -0.02950, -0.00847, 0.01037, -0.04783, - 0.04237, 0.11662, + -0.02950, -0.00847, 0.01037, -0.04783, + 0.04237, 0.11662, - -0.00331, 0.00207, -0.00107, -0.00264, - 0.00072, -0.00023, + -0.00331, 0.00207, -0.00107, -0.00264, + 0.00072, -0.00023, - -0.00151, 0.00146, + -0.00151, 0.00146, - -0.12847, 0.02294, 0.03611, 0.19705, - 0.16855, -0.28279, + -0.12847, 0.02294, 0.03611, 0.19705, + 0.16855, -0.28279, - -0.00000, -0.00002, + -0.00000, -0.00002, - -0.00525, -0.03619, 0.05048, -0.00481, - -0.00745, 0.04618, + -0.00525, -0.03619, 0.05048, -0.00481, + -0.00745, 0.04618, - 0.00286, 0.00443, 0.00521, -0.00351, + 0.00286, 0.00443, 0.00521, -0.00351, - 0.00200, 0.00474, -0.00149, 0.00031, - -0.00003, 0.00029, + 0.00200, 0.00474, -0.00149, 0.00031, + -0.00003, 0.00029, - 0.00686, 0.02467, 0.04275, -0.02223, + 0.00686, 0.02467, 0.04275, -0.02223, - 0.02282, -0.04228, 0.03312, 0.01847, - -0.01253, 0.01601, + 0.02282, -0.04228, 0.03312, 0.01847, + -0.01253, 0.01601, - 0.00076, 0.00091, + 0.00076, 0.00091, - 0.00045, 0.00035, + 0.00045, 0.00035, - 0.00658, 0.01586, -0.00310, 0.00628, - -0.00045, 0.00316, + 0.00658, 0.01586, -0.00310, 0.00628, + -0.00045, 0.00316, - -0.01602, -0.00340, -0.01744, 0.04907, - 0.06426, 0.02275, + -0.01602, -0.00340, -0.01744, 0.04907, + 0.06426, 0.02275, - -0.00217, -0.00377, -0.00091, 0.00037, + -0.00217, -0.00377, -0.00091, 0.00037, - 0.00040, -0.00003, + 0.00040, -0.00003, - -0.00017, -0.00027, + -0.00017, -0.00027, - 0.00366, 0.02693, -0.00934, 0.00386, + 0.00366, 0.02693, -0.00934, 0.00386, - 0.00616, -0.00037, + 0.00616, -0.00037, - 0.02028, 0.02120, -0.01768, 0.02421, - 0.00102, 0.00877, + 0.02028, 0.02120, -0.01768, 0.02421, + 0.00102, 0.00877, - 0.00012, 0.00030, + 0.00012, 0.00030, - -0.00019, -0.02165, 0.01245, -0.00742, - 0.00172, 0.00320, + -0.00019, -0.02165, 0.01245, -0.00742, + 0.00172, 0.00320, - -0.17117, -0.12908, -0.43134, 0.15617, - 0.21216, 0.56432, + -0.17117, -0.12908, -0.43134, 0.15617, + 0.21216, 0.56432, - 0.01139, -0.00937, -0.00058, -0.00337, + 0.01139, -0.00937, -0.00058, -0.00337, - -0.00999, 0.01862, -0.00621, -0.00080, + -0.00999, 0.01862, -0.00621, -0.00080, - -0.00025, -0.00140, + -0.00025, -0.00140, - 0.09250, 0.01173, -0.03549, 0.14651, - -0.01784, 0.00945, + 0.09250, 0.01173, -0.03549, 0.14651, + -0.01784, 0.00945, - 0.00000, -0.00006, + 0.00000, -0.00006, - -0.00500, 0.00086, 0.01079, -0.00002, + -0.00500, 0.00086, 0.01079, -0.00002, - -0.00012, -0.00029, + -0.00012, -0.00029, - -0.02661, 0.00140, -0.00524, -0.00460, + -0.02661, 0.00140, -0.00524, -0.00460, - -0.00352, -0.00563, -0.00277, -0.00052, + -0.00352, -0.00563, -0.00277, -0.00052, - -0.10171, -0.02001, + -0.10171, -0.02001, - 0.00045, 0.00265, -0.00082, 0.00160, + 0.00045, 0.00265, -0.00082, 0.00160, - -0.00302, -0.00434, -0.00022, -0.00134, + -0.00302, -0.00434, -0.00022, -0.00134, - 0.03285, 0.02964, -0.05612, -0.00668, - -0.01821, 0.06590, + 0.03285, 0.02964, -0.05612, -0.00668, + -0.01821, 0.06590, - 0.00039, 0.00061, + 0.00039, 0.00061, - -0.13531, -0.03831, + -0.13531, -0.03831, - 0.02553, 0.02130, -0.00336, 0.00468, + 0.02553, 0.02130, -0.00336, 0.00468, - -0.04522, -0.05540, 0.00129, -0.01767, - 0.00181, 0.00031, + -0.04522, -0.05540, 0.00129, -0.01767, + 0.00181, 0.00031, - -0.00011, -0.00034, + -0.00011, -0.00034, - -0.00146, 0.01101, + -0.00146, 0.01101, - -0.00030, 0.00240, -0.00039, 0.00072, + -0.00030, 0.00240, -0.00039, 0.00072, - -0.01954, -0.03822, 0.09682, -0.04541, - -0.01567, 0.09617, + -0.01954, -0.03822, 0.09682, -0.04541, + -0.01567, 0.09617, - -0.03371, 0.33028, -0.12102, 0.05874, - -0.00990, -0.02236, + -0.03371, 0.33028, -0.12102, 0.05874, + -0.00990, -0.02236, - 0.00109, 0.00158, + 0.00109, 0.00158, - -0.00482, 0.00019, + -0.00482, 0.00019, - -0.00036, 0.00004, + -0.00036, 0.00004, - 0.00024, 0.00201, + 0.00024, 0.00201, - 0.00017, 0.00011, + 0.00017, 0.00011, - -0.00012, 0.00002, + -0.00012, 0.00002, - -0.00323, -0.01062, + -0.00323, -0.01062, - -0.00130, 0.00091, + -0.00130, 0.00091, - 0.00056, -0.00017, + 0.00056, -0.00017, - 0.00774, 0.00601, 0.02550, 0.01700, + 0.00774, 0.00601, 0.02550, 0.01700, - -0.84327, 0.77533, -0.71414, -0.50643, + -0.84327, 0.77533, -0.71414, -0.50643, - -473.30877, -1504.79179, -458.52274, -865.82237, - -417.34994, -681.03976, 765.50697, -1653.67165, - 4427.33176, 710.53895, -5016.39367, 4280.60361, + -473.30877, -1504.79179, -458.52274, -865.82237, + -417.34994, -681.03976, 765.50697, -1653.67165, + 4427.33176, 710.53895, -5016.39367, 4280.60361, - 0.33957, 0.38390, -0.38631, 0.81193, + 0.33957, 0.38390, -0.38631, 0.81193, - 0.00154, -0.00043, + 0.00154, -0.00043, - 0.01103, -0.00017, + 0.01103, -0.00017, - -0.00046, 0.00221, + -0.00046, 0.00221, - 0.00059, 0.00014, + 0.00059, 0.00014, - 0.00160, 0.00475, + 0.00160, 0.00475, - 0.06191, -0.13289, 0.02884, -0.00566, + 0.06191, -0.13289, 0.02884, -0.00566, - -0.01572, 0.23780, -0.05140, -0.03228, + -0.01572, 0.23780, -0.05140, -0.03228, - -0.00716, -0.00978, -0.01048, 0.01317, + -0.00716, -0.00978, -0.01048, 0.01317, - -0.01267, -0.01198, 0.00037, -0.00330, + -0.01267, -0.01198, 0.00037, -0.00330, - -0.02305, 0.00355, -0.00121, -0.00496, + -0.02305, 0.00355, -0.00121, -0.00496, - -0.04369, -0.01343, 0.05347, -0.12433, - 0.02090, 0.17683, + -0.04369, -0.01343, 0.05347, -0.12433, + 0.02090, 0.17683, - 0.00028, -0.00490, + 0.00028, -0.00490, - -0.02778, -0.05587, -0.01658, 0.05655, + -0.02778, -0.05587, -0.01658, 0.05655, - 0.00204, -0.00092, 0.00020, 0.00014, + 0.00204, -0.00092, 0.00020, 0.00014, - -0.00603, -0.03829, 0.00778, -0.00588, + -0.00603, -0.03829, 0.00778, -0.00588, - -0.00266, 0.00097, + -0.00266, 0.00097, - -0.02158, -0.07742, 0.09306, -0.01827, - -0.01048, 0.07885, + -0.02158, -0.07742, 0.09306, -0.01827, + -0.01048, 0.07885, - -0.02485, -0.02505, 0.00471, -0.01026, + -0.02485, -0.02505, 0.00471, -0.01026, - 0.06663, 0.01110, 0.00469, -0.05347, + 0.06663, 0.01110, 0.00469, -0.05347, - -0.00016, -0.00013, + -0.00016, -0.00013, - 0.02622, 0.02273, -0.01009, 0.01391, + 0.02622, 0.02273, -0.01009, 0.01391, - -0.01042, -0.00444, + -0.01042, -0.00444, - -0.04293, -0.00767, -0.00154, -0.01739, + -0.04293, -0.00767, -0.00154, -0.01739, - 0.00353, -0.00763, + 0.00353, -0.00763, - -0.00060, 0.00010, + -0.00060, 0.00010, - -0.00053, -0.00146, + -0.00053, -0.00146, - -0.05317, 0.05760, -0.01801, -0.02099, + -0.05317, 0.05760, -0.01801, -0.02099, - -0.02611, -0.01836, + -0.02611, -0.01836, - -0.00256, 0.00812, -0.00145, 0.00054, + -0.00256, 0.00812, -0.00145, 0.00054, - -0.00008, 0.00015, + -0.00008, 0.00015, - -0.04087, 0.08860, -0.05385, -0.02134, + -0.04087, 0.08860, -0.05385, -0.02134, - 0.02771, 0.02441, -0.00234, 0.01571, - -0.00260, 0.00097, + 0.02771, 0.02441, -0.00234, 0.01571, + -0.00260, 0.00097, - 0.10151, 0.49378, -0.28555, 0.11428, + 0.10151, 0.49378, -0.28555, 0.11428, - -0.00286, 0.01224, 0.00160, 0.00069, + -0.00286, 0.01224, 0.00160, 0.00069, - 0.00000, -0.00040, + 0.00000, -0.00040, - -0.13286, 0.00448, + -0.13286, 0.00448, - 0.01225, -0.00568, 0.00341, 0.00224, + 0.01225, -0.00568, 0.00341, 0.00224, - -0.23483, -0.07859, 0.30733, -0.21548, + -0.23483, -0.07859, 0.30733, -0.21548, - -0.02608, 0.00756, + -0.02608, 0.00756, - 0.09789, 0.02878, -0.11968, 0.08981, + 0.09789, 0.02878, -0.11968, 0.08981, - 0.02046, -0.00888, + 0.02046, -0.00888, - 0.02955, 0.01486, -0.00981, 0.01542, + 0.02955, 0.01486, -0.00981, 0.01542, - -0.01674, -0.01540, 0.00019, -0.00449, + -0.01674, -0.01540, 0.00019, -0.00449, - -0.02140, 0.00638, 0.00112, -0.00730, + -0.02140, 0.00638, 0.00112, -0.00730, - -0.08571, 0.13811, -0.16951, -0.02917, + -0.08571, 0.13811, -0.16951, -0.02917, - -0.03931, -0.32643, + -0.03931, -0.32643, - -68.64541, -81.00521, -47.97737, 15.75290, - 181.76392, -36.00647, -48.32098, -259.02226, - -265.57466, 554.05904, + -68.64541, -81.00521, -47.97737, 15.75290, + 181.76392, -36.00647, -48.32098, -259.02226, + -265.57466, 554.05904, - 0.09017, 0.18803, -0.12459, 0.10852, + 0.09017, 0.18803, -0.12459, 0.10852, - 0.00211, 0.00002, + 0.00211, 0.00002, - 0.00304, -0.00370, + 0.00304, -0.00370, - 0.00174, 0.00279, + 0.00174, 0.00279, - 0.00139, 0.00095, + 0.00139, 0.00095, - 0.04881, 0.00262, -0.01020, 0.03762, + 0.04881, 0.00262, -0.01020, 0.03762, - 0.00987, 0.00612, + 0.00987, 0.00612, - 0.00054, -0.00036, + 0.00054, -0.00036, - 0.00009, -0.00094, + 0.00009, -0.00094, - 0.02279, 0.01785, -0.00778, 0.01263, + 0.02279, 0.01785, -0.00778, 0.01263, - 0.00040, -0.00112, + 0.00040, -0.00112, - -0.00452, -0.00662, + -0.00452, -0.00662, - 0.00483, -0.00030, + 0.00483, -0.00030, - -0.00054, -0.00205, + -0.00054, -0.00205, - -0.00052, -0.00362, -0.00215, -0.00247, + -0.00052, -0.00362, -0.00215, -0.00247, - 0.02893, -0.01965, -0.00004, 0.04114, + 0.02893, -0.01965, -0.00004, 0.04114, - -0.00284, -0.00103, + -0.00284, -0.00103, - 0.01827, -0.07822, 0.18010, 0.04805, - -0.21702, 0.18808, + 0.01827, -0.07822, 0.18010, 0.04805, + -0.21702, 0.18808, - 0.00095, -0.00132, + 0.00095, -0.00132, - -0.01488, 0.00746, + -0.01488, 0.00746, - 0.00198, 0.00190, + 0.00198, 0.00190, - 0.01032, 0.03392, 0.04318, -0.07332, + 0.01032, 0.03392, 0.04318, -0.07332, - -0.01004, 0.00787, + -0.01004, 0.00787, - -0.00308, -0.01177, -0.01431, 0.02659, + -0.00308, -0.01177, -0.01431, 0.02659, - 0.00273, -0.00374, + 0.00273, -0.00374, - -0.02545, 0.00644, + -0.02545, 0.00644, - 28.68376, 13.74978, 29.60401, -47.98255, - -65.91944, -18.48404, -1.73580, 64.67487, + 28.68376, 13.74978, 29.60401, -47.98255, + -65.91944, -18.48404, -1.73580, 64.67487, - -0.02492, 0.00104, + -0.02492, 0.00104, - -0.00829, -0.00134, + -0.00829, -0.00134, - 0.00077, 0.00005, + 0.00077, 0.00005, - -0.00513, 0.00403, + -0.00513, 0.00403, - 0.00071, -0.00047, + 0.00071, -0.00047, - -0.00023, -0.00063, + -0.00023, -0.00063, - 0.00120, 0.00370, + 0.00120, 0.00370, - -0.00038, -0.00037, + -0.00038, -0.00037, - 0.00080, -0.00018, + 0.00080, -0.00018, - 0.00866, 0.00156, -0.01064, 0.02131, + 0.00866, 0.00156, -0.01064, 0.02131, - 0.00000, -0.00001, + 0.00000, -0.00001, - 0.00038, -0.00068, + 0.00038, -0.00068, - -0.00909, -0.02187, -0.02599, 0.05507, + -0.00909, -0.02187, -0.02599, 0.05507, - -0.00022, -0.01468, + -0.00022, -0.01468, - 0.00032, 0.00500, + 0.00032, 0.00500, - 9.86233, -2.85314, -2.25791, -13.83444, - -12.38794, 3.79861, 2.76343, 6.63505, + 9.86233, -2.85314, -2.25791, -13.83444, + -12.38794, 3.79861, 2.76343, 6.63505, - 0.00066, 0.00007, + 0.00066, 0.00007, - -0.00016, -0.00039, + -0.00016, -0.00039, - 0.00014, 0.00059, + 0.00014, 0.00059, - -0.00031, -0.00024, + -0.00031, -0.00024, - -0.00168, 0.00259, + -0.00168, 0.00259, - 0.00007, -0.00005, + 0.00007, -0.00005, - -0.00052, 0.00558, + -0.00052, 0.00558, - 0.00110, 0.01037, + 0.00110, 0.01037, - 1.59224, -2.37284, -2.00023, -2.28280, - -1.49571, 1.48293, 0.60041, 0.56376, + 1.59224, -2.37284, -2.00023, -2.28280, + -1.49571, 1.48293, 0.60041, 0.56376, - -0.54386, 0.03568, -0.10392, 0.31005, - 0.09104, 0.03015, + -0.54386, 0.03568, -0.10392, 0.31005, + 0.09104, 0.03015, - 0.00826, -0.00524, + 0.00826, -0.00524, }; + static double FAR martabr[] = { - -816.07287, -381.41365, -33.69436, 177.22955, - 0.18630, + -816.07287, -381.41365, -33.69436, 177.22955, + 0.18630, - -8.29605, -11.15519, -0.57407, -3.53642, - 0.16663, -0.06334, + -8.29605, -11.15519, -0.57407, -3.53642, + 0.16663, -0.06334, - -0.03056, 0.02767, + -0.03056, 0.02767, - -0.04161, 0.03917, -0.02425, 0.00204, + -0.04161, 0.03917, -0.02425, 0.00204, - -0.00034, 0.00023, + -0.00034, 0.00023, - 0.00058, -0.00111, 0.00039, -0.00015, + 0.00058, -0.00111, 0.00039, -0.00015, - 0.00006, -0.00023, + 0.00006, -0.00023, - 0.00237, 0.00191, + 0.00237, 0.00191, - 0.00154, -0.00029, 0.00009, 0.00011, + 0.00154, -0.00029, 0.00009, 0.00011, - -0.00041, 0.00037, + -0.00041, 0.00037, - -0.00010, -0.00064, 0.00015, -0.00005, + -0.00010, -0.00064, 0.00015, -0.00005, - 0.00012, -0.00003, + 0.00012, -0.00003, - -0.00034, 0.00026, + -0.00034, 0.00026, - 0.00011, -0.00007, + 0.00011, -0.00007, - -0.00158, 0.00087, + -0.00158, 0.00087, - 0.00278, 0.00137, + 0.00278, 0.00137, - 0.00024, -0.00020, + 0.00024, -0.00020, - 0.00530, -0.00448, 0.00780, 0.00408, + 0.00530, -0.00448, 0.00780, 0.00408, - 0.00062, 0.00035, + 0.00062, 0.00035, - -1.35261, 0.79891, -0.81597, -0.43774, - 0.14713, -0.27415, 0.05298, 0.02230, + -1.35261, 0.79891, -0.81597, -0.43774, + 0.14713, -0.27415, 0.05298, 0.02230, - -0.02089, -0.01070, -0.00374, 0.00342, - -0.00142, 0.00270, + -0.02089, -0.01070, -0.00374, 0.00342, + -0.00142, 0.00270, - -0.00039, 0.00063, + -0.00039, 0.00063, - 0.16024, 0.27088, -0.32127, 0.27467, - -0.16615, -0.24460, + 0.16024, 0.27088, -0.32127, 0.27467, + -0.16615, -0.24460, - -0.00073, 0.00032, + -0.00073, 0.00032, - -0.05710, -0.05265, -0.06025, 0.05120, + -0.05710, -0.05265, -0.06025, 0.05120, - -0.05295, 0.23477, -0.08211, 0.04575, - -0.00769, -0.01067, + -0.05295, 0.23477, -0.08211, 0.04575, + -0.00769, -0.01067, - -0.00570, 0.00015, + -0.00570, 0.00015, - -0.00251, -0.00140, + -0.00251, -0.00140, - -0.00131, -0.00018, + -0.00131, -0.00018, - -0.12246, 0.15836, -0.13065, -0.03222, - 0.00795, -0.04232, + -0.12246, 0.15836, -0.13065, -0.03222, + 0.00795, -0.04232, - -0.36585, -0.31154, 0.68504, -0.96006, - 1.19304, 0.88631, + -0.36585, -0.31154, 0.68504, -0.96006, + 1.19304, 0.88631, - 0.00132, 0.00046, + 0.00132, 0.00046, - 0.13105, 0.04252, 0.05164, -0.06837, + 0.13105, 0.04252, 0.05164, -0.06837, - -0.01351, -0.01458, 0.00376, -0.00557, + -0.01351, -0.01458, 0.00376, -0.00557, - 0.28532, -0.17290, -0.53946, -0.79365, - -0.95246, 0.74984, + 0.28532, -0.17290, -0.53946, -0.79365, + -0.95246, 0.74984, - 0.00019, 0.00132, + 0.00019, 0.00132, - -0.00163, -0.00295, + -0.00163, -0.00295, - -0.40106, -0.26573, -0.00155, -0.22655, - 0.04349, -0.00376, + -0.40106, -0.26573, -0.00155, -0.22655, + 0.04349, -0.00376, - 0.00149, -0.00001, + 0.00149, -0.00001, - 0.00523, 0.00078, + 0.00523, 0.00078, - 0.01203, 0.00558, + 0.01203, 0.00558, - -0.00708, 0.00520, + -0.00708, 0.00520, - -0.36428, -1.28827, 1.50845, -0.83063, - 0.58802, 0.89998, + -0.36428, -1.28827, 1.50845, -0.83063, + 0.58802, 0.89998, - -0.55256, 0.01255, -0.15169, -0.26715, - 0.06061, -0.04122, + -0.55256, 0.01255, -0.15169, -0.26715, + 0.06061, -0.04122, - -0.00397, 0.00534, + -0.00397, 0.00534, - -0.52576, 1.22031, 1.44098, 0.92406, - 0.67214, -0.85486, + -0.52576, 1.22031, 1.44098, 0.92406, + 0.67214, -0.85486, - -0.00010, 0.00001, + -0.00010, 0.00001, - 0.28820, -0.84198, 0.78291, 0.00251, - 0.02398, 0.32093, + 0.28820, -0.84198, 0.78291, 0.00251, + 0.02398, 0.32093, - -0.02331, 0.10109, -0.07555, 0.03557, + -0.02331, 0.10109, -0.07555, 0.03557, - -0.61580, 0.43399, -0.43779, -0.26390, - 0.06885, -0.13803, + -0.61580, 0.43399, -0.43779, -0.26390, + 0.06885, -0.13803, - 0.17694, 0.19245, 0.15119, -0.05100, + 0.17694, 0.19245, 0.15119, -0.05100, - 0.49469, -0.45028, 0.33590, 0.15677, - -0.04702, 0.10265, + 0.49469, -0.45028, 0.33590, 0.15677, + -0.04702, 0.10265, - -0.00942, -0.00580, + -0.00942, -0.00580, - -0.00555, -0.00252, + -0.00555, -0.00252, - -0.32933, 0.92539, -0.91004, -0.04490, - -0.01812, -0.37121, + -0.32933, 0.92539, -0.91004, -0.04490, + -0.01812, -0.37121, - 0.34695, 0.50855, -0.24721, 0.86063, - -0.84747, 0.01983, + 0.34695, 0.50855, -0.24721, 0.86063, + -0.84747, 0.01983, - 0.01948, 0.02039, 0.00748, -0.00727, + 0.01948, 0.02039, 0.00748, -0.00727, - -0.00271, 0.00220, + -0.00271, 0.00220, - 0.00309, 0.00196, + 0.00309, 0.00196, - 0.02030, 0.17201, -0.03716, 0.02801, + 0.02030, 0.17201, -0.03716, 0.02801, - 0.01871, 0.00002, + 0.01871, 0.00002, - 0.31736, 1.17319, -1.42245, 0.73416, - -0.52302, -0.85056, + 0.31736, 1.17319, -1.42245, 0.73416, + -0.52302, -0.85056, - 0.00522, -0.00126, + 0.00522, -0.00126, - 0.33571, 0.34594, -0.07709, 0.21114, - -0.04066, -0.01742, + 0.33571, 0.34594, -0.07709, 0.21114, + -0.04066, -0.01742, - 1.72228, 1.46934, -3.06437, 5.06723, - -6.53800, -3.55839, + 1.72228, 1.46934, -3.06437, 5.06723, + -6.53800, -3.55839, - -0.06933, 0.13815, 0.03684, 0.03284, + -0.06933, 0.13815, 0.03684, 0.03284, - -0.04841, 0.09571, -0.02350, 0.00418, + -0.04841, 0.09571, -0.02350, 0.00418, - 0.01302, 0.00579, + 0.01302, 0.00579, - 0.73408, 0.64718, -1.37437, 2.04816, - -2.70756, -1.52808, + 0.73408, 0.64718, -1.37437, 2.04816, + -2.70756, -1.52808, - 0.00523, -0.00166, + 0.00523, -0.00166, - 0.25915, 0.06900, -0.02758, 0.10707, + 0.25915, 0.06900, -0.02758, 0.10707, - 0.00062, 0.00744, + 0.00062, 0.00744, - -0.08117, 0.04840, -0.01806, -0.00637, + -0.08117, 0.04840, -0.01806, -0.00637, - 0.03034, -0.12414, 0.03419, -0.00388, + 0.03034, -0.12414, 0.03419, -0.00388, - 10.92603, 0.48169, + 10.92603, 0.48169, - -0.01753, -0.12853, -0.03207, -0.00801, + -0.01753, -0.12853, -0.03207, -0.00801, - 0.03904, -0.03326, 0.01033, 0.00366, + 0.03904, -0.03326, 0.01033, 0.00366, - 0.17249, 0.20846, -0.38157, 0.54639, - -0.68518, -0.36121, + 0.17249, 0.20846, -0.38157, 0.54639, + -0.68518, -0.36121, - -0.01043, -0.00186, + -0.01043, -0.00186, - -3.33843, -0.16353, + -3.33843, -0.16353, - 0.03462, 0.06669, -0.01305, 0.01803, + 0.03462, 0.06669, -0.01305, 0.01803, - -0.22703, -0.52219, 0.11709, -0.19628, - 0.03410, 0.01741, + -0.22703, -0.52219, 0.11709, -0.19628, + 0.03410, 0.01741, - 0.00338, 0.00265, + 0.00338, 0.00265, - 0.63213, 0.08944, + 0.63213, 0.08944, - 0.00236, 0.01829, 0.00546, 0.00218, + 0.00236, 0.01829, 0.00546, 0.00218, - 0.00073, -0.72570, 0.63698, -0.13340, - 0.04698, 0.29716, + 0.00073, -0.72570, 0.63698, -0.13340, + 0.04698, 0.29716, - -0.13126, 1.27705, -0.40980, 0.27400, - -0.04525, -0.05529, + -0.13126, 1.27705, -0.40980, 0.27400, + -0.04525, -0.05529, - -0.03249, -0.01696, + -0.03249, -0.01696, - -0.02314, -0.00076, + -0.02314, -0.00076, - 0.00510, 0.00764, + 0.00510, 0.00764, - -0.01847, -0.01021, + -0.01847, -0.01021, - 0.01688, -0.00044, + 0.01688, -0.00044, - 0.00531, -0.00016, + 0.00531, -0.00016, - -0.01219, -0.02903, + -0.01219, -0.02903, - -0.00361, 0.00299, + -0.00361, 0.00299, - 0.00504, -0.00153, + 0.00504, -0.00153, - -0.53625, -0.32460, 0.10642, -0.22070, + -0.53625, -0.32460, 0.10642, -0.22070, - -2.21651, -0.66036, -1.74652, -2.08198, + -2.21651, -0.66036, -1.74652, -2.08198, - -6810.78679, 967.02869, -3915.97140, 291.65905, - 372.99563, 1196.01966, 5108.01033, -3172.64698, - -7685.78246, -12789.43898, -17474.50562, 7757.84703, + -6810.78679, 967.02869, -3915.97140, 291.65905, + 372.99563, 1196.01966, 5108.01033, -3172.64698, + -7685.78246, -12789.43898, -17474.50562, 7757.84703, - 3.13224, 1.84743, -0.38257, 2.40590, + 3.13224, 1.84743, -0.38257, 2.40590, - 0.01860, -0.01217, + 0.01860, -0.01217, - 0.03004, 0.00278, + 0.03004, 0.00278, - -0.00125, 0.00579, + -0.00125, 0.00579, - -0.02673, -0.00112, + -0.02673, -0.00112, - 0.00662, 0.01374, + 0.00662, 0.01374, - -0.02729, 0.13109, -0.02836, 0.00877, + -0.02729, 0.13109, -0.02836, 0.00877, - 0.12171, -0.27475, 0.34765, 0.15882, + 0.12171, -0.27475, 0.34765, 0.15882, - -0.12548, 0.02603, 0.00710, 0.06538, + -0.12548, 0.02603, 0.00710, 0.06538, - -0.04039, -0.03257, -0.00186, -0.00880, + -0.04039, -0.03257, -0.00186, -0.00880, - 0.16643, 0.00707, 0.01918, 0.07156, + 0.16643, 0.00707, 0.01918, 0.07156, - -0.20459, -0.85107, 1.01832, -0.47158, - 0.32582, 0.63002, + -0.20459, -0.85107, 1.01832, -0.47158, + 0.32582, 0.63002, - -0.00282, -0.00711, + -0.00282, -0.00711, - -0.19695, 0.15053, 0.15676, 0.17847, + -0.19695, 0.15053, 0.15676, 0.17847, - 0.00071, 0.00286, -0.00039, 0.00083, + 0.00071, 0.00286, -0.00039, 0.00083, - 0.02009, 0.17859, -0.03894, 0.02805, + 0.02009, 0.17859, -0.03894, 0.02805, - 0.02379, 0.00752, + 0.02379, 0.00752, - 0.17529, -0.57783, 0.53257, -0.02829, - 0.03211, 0.21777, + 0.17529, -0.57783, 0.53257, -0.02829, + 0.03211, 0.21777, - 0.13813, 0.16305, -0.02996, 0.06303, + 0.13813, 0.16305, -0.02996, 0.06303, - 0.21058, -0.02659, 0.02596, -0.08808, + 0.21058, -0.02659, 0.02596, -0.08808, - -0.00389, 0.00586, + -0.00389, 0.00586, - 0.08986, 0.09204, -0.01480, 0.04031, + 0.08986, 0.09204, -0.01480, 0.04031, - 0.06115, 0.18366, + 0.06115, 0.18366, - 0.25636, 0.06905, 0.00719, 0.11391, + 0.25636, 0.06905, 0.00719, 0.11391, - 0.00636, -0.01113, + 0.00636, -0.01113, - -0.02808, 0.00150, + -0.02808, 0.00150, - -0.01219, 0.00832, + -0.01219, 0.00832, - 0.28626, -0.09573, 0.10481, 0.16559, + 0.28626, -0.09573, 0.10481, 0.16559, - -0.94578, 1.26394, + -0.94578, 1.26394, - 0.08846, -0.01623, 0.00082, -0.02640, + 0.08846, -0.01623, 0.00082, -0.02640, - -0.00347, 0.00798, + -0.00347, 0.00798, - 0.12873, -0.21248, 0.27999, 0.14348, + 0.12873, -0.21248, 0.27999, 0.14348, - 0.44082, 0.10453, 0.04362, 0.25332, - -0.06077, 0.00555, + 0.44082, 0.10453, 0.04362, 0.25332, + -0.06077, 0.00555, - -0.06947, -0.05511, -10.08703, -0.10614, + -0.06947, -0.05511, -10.08703, -0.10614, - 0.04059, 0.21355, 0.05632, 0.00871, + 0.04059, 0.21355, 0.05632, 0.00871, - 0.01599, -0.00531, + 0.01599, -0.00531, - 0.36835, -0.03530, + 0.36835, -0.03530, - 0.09519, -0.04961, 0.02568, 0.08613, + 0.09519, -0.04961, 0.02568, 0.08613, - 0.57033, 0.84599, 1.27123, -0.41266, + 0.57033, 0.84599, 1.27123, -0.41266, - -0.36937, -0.00655, + -0.36937, -0.00655, - -0.16547, -0.24000, -0.35213, 0.13345, + -0.16547, -0.24000, -0.35213, 0.13345, - 0.05870, -0.01524, + 0.05870, -0.01524, - 0.06419, 0.04136, -0.00681, 0.02606, + 0.06419, 0.04136, -0.00681, 0.02606, - -0.02519, -0.02732, -0.00105, -0.00677, + -0.02519, -0.02732, -0.00105, -0.00677, - -0.03891, 0.00106, 0.00087, -0.02256, + -0.03891, 0.00106, 0.00087, -0.02256, - -0.20834, -0.14624, -0.23178, -0.11786, + -0.20834, -0.14624, -0.23178, -0.11786, - 0.32479, -1.41222, + 0.32479, -1.41222, - -303.74549, -202.79324, 260.20290, 184.84320, - 536.68016, -881.56427, -1125.64824, -791.09928, - -596.61162, 659.35664, + -303.74549, -202.79324, 260.20290, 184.84320, + 536.68016, -881.56427, -1125.64824, -791.09928, + -596.61162, 659.35664, - 0.24561, 0.39519, -0.12601, 0.18709, + 0.24561, 0.39519, -0.12601, 0.18709, - -0.00700, 0.00136, + -0.00700, 0.00136, - 0.30750, 0.00009, + 0.30750, 0.00009, - 0.00443, 0.00384, + 0.00443, 0.00384, - 0.01170, 0.02078, + 0.01170, 0.02078, - 0.15043, 0.04802, 0.00386, 0.06942, + 0.15043, 0.04802, 0.00386, 0.06942, - 0.02107, 0.00495, + 0.02107, 0.00495, - -0.01067, 0.00951, + -0.01067, 0.00951, - 0.00937, 0.01996, + 0.00937, 0.01996, - 0.04922, 0.04337, -0.00583, 0.02110, + 0.04922, 0.04337, -0.00583, 0.02110, - -0.00691, 0.02793, + -0.00691, 0.02793, - -0.00364, -0.00682, + -0.00364, -0.00682, - -0.09143, 0.15369, + -0.09143, 0.15369, - 0.02043, 0.05451, + 0.02043, 0.05451, - 0.04053, -0.08179, 0.09645, 0.05330, + 0.04053, -0.08179, 0.09645, 0.05330, - -0.10149, -0.01594, -0.96773, 0.13660, + -0.10149, -0.01594, -0.96773, 0.13660, - 0.17326, 0.00013, + 0.17326, 0.00013, - 0.20990, -0.23184, -0.38407, -0.64733, - -0.84754, 0.38889, + 0.20990, -0.23184, -0.38407, -0.64733, + -0.84754, 0.38889, - 0.00310, -0.00340, + 0.00310, -0.00340, - 0.00970, -0.00788, + 0.00970, -0.00788, - -0.01111, 0.00677, + -0.01111, 0.00677, - 0.18147, 0.09968, 0.10170, -0.09233, + 0.18147, 0.09968, 0.10170, -0.09233, - -0.03165, 0.01790, + -0.03165, 0.01790, - -0.04727, -0.02364, -0.02546, 0.02451, + -0.04727, -0.02364, -0.02546, 0.02451, - 0.00442, -0.00426, + 0.00442, -0.00426, - -0.02540, 0.00471, + -0.02540, 0.00471, - 130.42585, -31.30051, 17.99957, -174.75585, - -142.96798, -27.89752, -19.42122, 59.14872, + 130.42585, -31.30051, 17.99957, -174.75585, + -142.96798, -27.89752, -19.42122, 59.14872, - -0.01899, 0.00388, + -0.01899, 0.00388, - -0.01265, 0.00694, + -0.01265, 0.00694, - 0.01966, 0.01140, + 0.01966, 0.01140, - -0.00439, 0.00503, + -0.00439, 0.00503, - -0.01867, 0.02826, + -0.01867, 0.02826, - 0.00752, 0.02012, + 0.00752, 0.02012, - -0.14734, 0.01909, + -0.14734, 0.01909, - 0.03312, 0.02327, + 0.03312, 0.02327, - 0.05843, 0.00061, + 0.05843, 0.00061, - -0.06958, -0.05798, -0.09174, 0.06242, + -0.06958, -0.05798, -0.09174, 0.06242, - 0.00003, 0.00001, + 0.00003, 0.00001, - 0.00670, -0.00305, + 0.00670, -0.00305, - -0.13637, -0.06058, -0.06372, 0.07257, + -0.13637, -0.06058, -0.06372, 0.07257, - 0.00209, -0.01369, + 0.00209, -0.01369, - -0.00044, 0.00355, + -0.00044, 0.00355, - 17.90079, -17.48270, -8.77915, -24.54483, - -15.67123, 3.62668, 0.52038, 5.13220, + 17.90079, -17.48270, -8.77915, -24.54483, + -15.67123, 3.62668, 0.52038, 5.13220, - 0.02574, 0.00003, + 0.02574, 0.00003, - 0.00339, 0.00919, + 0.00339, 0.00919, - -0.02778, 0.00464, + -0.02778, 0.00464, - 0.01429, 0.01003, + 0.01429, 0.01003, - -0.01661, 0.01327, + -0.01661, 0.01327, - 0.02216, 0.00034, + 0.02216, 0.00034, - -0.00389, 0.01076, + -0.00389, 0.01076, - -0.00035, 0.00983, + -0.00035, 0.00983, - 1.23731, -4.18017, -2.61932, -2.66346, - -1.45540, 1.10310, 0.23322, 0.40775, + 1.23731, -4.18017, -2.61932, -2.66346, + -1.45540, 1.10310, 0.23322, 0.40775, - -0.43623, 0.06212, -0.09900, 0.19456, - 0.03639, 0.02566, + -0.43623, 0.06212, -0.09900, 0.19456, + 0.03639, 0.02566, - 0.00309, -0.00116, + 0.00309, -0.00116, }; static signed char FAR marargs[] = { - 0, 4, - 3, 4, 3, -8, 4, 3, 5, 2, - 3, 5, 2, -6, 3, -4, 4, 0, - 2, 2, 5, -5, 6, 1, - 3, 12, 3,-24, 4, 9, 5, 0, - 3, 2, 2, 1, 3, -8, 4, 1, - 3, 11, 3,-21, 4, 2, 5, 0, - 3, 3, 2, -7, 3, 4, 4, 0, - 3, 7, 3,-13, 4, -1, 5, 1, - 3, 1, 3, -2, 4, 2, 6, 0, - 3, 1, 2, -8, 3, 12, 4, 1, - 3, 1, 4, -8, 5, 4, 6, 0, - 3, 1, 4, -7, 5, 2, 6, 0, - 3, 1, 4, -9, 5, 7, 6, 0, - 1, 1, 7, 0, - 2, 1, 5, -2, 6, 0, - 3, 1, 3, -2, 4, 1, 5, 0, - 3, 3, 3, -6, 4, 2, 5, 1, - 3, 12, 3,-23, 4, 3, 5, 0, - 2, 8, 3,-15, 4, 3, - 2, 1, 4, -6, 5, 2, - 3, 2, 2, -7, 3, 7, 4, 0, - 2, 1, 2, -3, 4, 2, - 2, 2, 5, -4, 6, 0, - 1, 1, 6, 1, - 2, 9, 3,-17, 4, 2, - 3, 2, 3, -4, 4, 2, 5, 0, - 3, 2, 3, -4, 4, 1, 5, 0, - 2, 1, 5, -1, 6, 0, - 2, 2, 2, -6, 4, 2, - 2, 1, 3, -2, 4, 2, - 2, 2, 5, -3, 6, 0, - 1, 2, 6, 1, - 2, 3, 5, -5, 6, 1, - 1, 1, 5, 2, - 3, 4, 3, -8, 4, 2, 5, 0, - 2, 1, 5, -5, 6, 0, - 2, 7, 3,-13, 4, 2, - 2, 3, 2, -9, 4, 0, - 2, 2, 5, -2, 6, 0, - 1, 3, 6, 0, - 2, 1, 4, -5, 5, 0, - 2, 2, 3, -4, 4, 2, - 2, 6, 3,-11, 4, 2, - 2, 4, 5, -5, 6, 0, - 1, 2, 5, 2, - 3, 1, 4, -3, 5, -3, 6, 0, - 2, 3, 3, -6, 4, 2, - 2, 1, 4, -4, 5, 1, - 2, 5, 3, -9, 4, 2, - 1, 3, 5, 1, - 2, 4, 3, -8, 4, 2, - 3, 1, 4, -4, 5, 2, 6, 0, - 3, 1, 4, -1, 5, -5, 6, 0, - 2, 4, 3, -7, 4, 2, - 2, 1, 4, -3, 5, 2, - 3, 1, 4, -5, 5, 5, 6, 1, - 3, 1, 4, -4, 5, 3, 6, 0, - 3, 1, 4, -3, 5, 1, 6, 0, - 2, 5, 3,-10, 4, 1, - 1, 4, 5, 0, - 2, 3, 3, -5, 4, 2, - 3, 1, 4, -3, 5, 2, 6, 0, - 2, 1, 4, -5, 6, 2, - 2, 1, 4, -2, 5, 2, - 3, 1, 4, -4, 5, 5, 6, 1, - 2, 6, 3,-12, 4, 1, - 2, 1, 4, -4, 6, 0, - 2, 2, 3, -3, 4, 2, - 2, 10, 3,-18, 4, 0, - 2, 1, 4, -3, 6, 1, - 3, 1, 4, -2, 5, 2, 6, 0, - 2, 7, 3,-14, 4, 1, - 3, 1, 4, 1, 5, -5, 6, 1, - 2, 1, 4, -1, 5, 0, - 3, 1, 4, -3, 5, 5, 6, 1, - 3, 1, 4, 2, 5, -7, 6, 1, - 2, 1, 4, -2, 6, 2, - 3, 1, 4, -2, 5, 3, 6, 0, - 2, 1, 3, -1, 4, 0, - 2, 2, 2, -7, 4, 1, - 2, 9, 3,-16, 4, 2, - 2, 1, 4, -3, 7, 0, - 2, 1, 4, -1, 6, 0, - 3, 1, 4, -2, 5, 4, 6, 1, - 2, 1, 2, -4, 4, 2, - 2, 8, 3,-16, 4, 2, - 2, 1, 4, -2, 7, 0, - 3, 3, 3, -5, 4, 2, 5, 0, - 3, 1, 4, 1, 5, -3, 6, 0, - 2, 1, 4, -2, 8, 0, - 2, 1, 4, -1, 7, 0, - 2, 1, 4, -1, 8, 0, - 3, 3, 2, -7, 3, 3, 4, 0, - 3, 2, 2, 1, 3, -7, 4, 0, - 3, 1, 4, 1, 6, -3, 7, 0, - 3, 1, 4, 2, 5, -5, 6, 1, - 3, 4, 3, -7, 4, 3, 5, 1, - 1, 1, 4, 5, - 3, 4, 3, -9, 4, 3, 5, 1, - 3, 1, 4, -2, 5, 5, 6, 0, - 3, 3, 2, -7, 3, 5, 4, 0, - 3, 1, 3, -1, 4, 2, 6, 0, - 3, 1, 4, 1, 5, -2, 6, 0, - 3, 3, 3, -7, 4, 2, 5, 0, - 2, 8, 3,-14, 4, 1, - 2, 1, 2, -2, 4, 1, - 2, 1, 4, 1, 6, 1, - 2, 9, 3,-18, 4, 1, - 2, 2, 2, -5, 4, 1, - 2, 1, 3, -3, 4, 2, - 2, 1, 4, 2, 6, 0, - 2, 1, 4, 1, 5, 1, - 3, 4, 3, -9, 4, 2, 5, 1, - 2, 7, 3,-12, 4, 1, - 2, 2, 4, -5, 5, 0, - 2, 2, 3, -5, 4, 2, - 2, 6, 3,-10, 4, 1, - 2, 1, 4, 2, 5, 1, - 3, 2, 4, -5, 5, 2, 6, 0, - 2, 3, 3, -7, 4, 1, - 2, 2, 4, -4, 5, 0, - 2, 5, 3, -8, 4, 1, - 2, 1, 4, 3, 5, 0, - 3, 2, 4, -4, 5, 2, 6, 0, - 3, 2, 4, -1, 5, -5, 6, 0, - 2, 4, 3, -6, 4, 1, - 2, 2, 4, -3, 5, 0, - 3, 2, 4, -5, 5, 5, 6, 1, - 3, 2, 4, -4, 5, 3, 6, 0, - 2, 3, 3, -4, 4, 1, - 2, 2, 4, -5, 6, 2, - 2, 2, 4, -2, 5, 1, - 3, 2, 4, -4, 5, 5, 6, 1, - 2, 2, 4, -4, 6, 0, - 2, 2, 3, -2, 4, 0, - 2, 2, 4, -3, 6, 1, - 2, 2, 4, -1, 5, 1, - 2, 2, 4, -2, 6, 0, - 1, 1, 3, 1, - 2, 2, 4, -1, 6, 0, - 2, 1, 2, -5, 4, 1, - 2, 8, 3,-17, 4, 1, - 3, 2, 4, 2, 5, -5, 6, 1, - 3, 4, 3, -6, 4, 3, 5, 1, - 3, 10, 3,-17, 4, 3, 6, 0, - 1, 2, 4, 4, - 3, 4, 3,-10, 4, 3, 5, 1, - 2, 8, 3,-13, 4, 0, - 2, 1, 2, -1, 4, 0, - 2, 2, 4, 1, 6, 0, - 2, 2, 2, -4, 4, 0, - 2, 1, 3, -4, 4, 1, - 2, 2, 4, 1, 5, 0, - 2, 7, 3,-11, 4, 0, - 2, 3, 4, -5, 5, 0, - 2, 2, 3, -6, 4, 1, - 2, 6, 3, -9, 4, 0, - 2, 2, 4, 2, 5, 0, - 2, 3, 4, -4, 5, 0, - 2, 5, 3, -7, 4, 0, - 2, 4, 3, -5, 4, 1, - 2, 3, 4, -3, 5, 1, - 2, 3, 3, -3, 4, 0, - 2, 3, 4, -2, 5, 2, - 3, 3, 4, -4, 5, 5, 6, 0, - 2, 2, 3, -1, 4, 0, - 2, 3, 4, -3, 6, 0, - 2, 3, 4, -1, 5, 1, - 2, 3, 4, -2, 6, 0, - 2, 1, 3, 1, 4, 1, - 2, 3, 4, -1, 6, 0, - 3, 4, 3, -5, 4, 3, 5, 0, - 1, 3, 4, 3, - 3, 4, 3,-11, 4, 3, 5, 0, - 1, 1, 2, 0, - 2, 2, 2, -3, 4, 0, - 2, 1, 3, -5, 4, 0, - 2, 4, 4, -5, 5, 0, - 2, 6, 3, -8, 4, 0, - 2, 4, 4, -4, 5, 0, - 2, 5, 3, -6, 4, 0, - 2, 4, 3, -4, 4, 0, - 2, 4, 4, -3, 5, 1, - 3, 6, 3, -8, 4, 2, 5, 0, - 2, 3, 3, -2, 4, 0, - 2, 4, 4, -2, 5, 1, - 2, 4, 4, -1, 5, 0, - 2, 1, 3, 2, 4, 0, - 1, 4, 4, 3, - 2, 2, 2, -2, 4, 0, - 2, 7, 3, -9, 4, 0, - 2, 5, 4, -5, 5, 0, - 2, 6, 3, -7, 4, 0, - 2, 5, 4, -4, 5, 0, - 2, 5, 3, -5, 4, 0, - 2, 5, 4, -3, 5, 0, - 2, 5, 4, -2, 5, 0, - 1, 5, 4, 3, - 1, 6, 4, 2, - 1, 7, 4, 0, - -1 + 0, 4, + 3, 4, 3, -8, 4, 3, 5, 2, + 3, 5, 2, -6, 3, -4, 4, 0, + 2, 2, 5, -5, 6, 1, + 3, 12, 3, -24, 4, 9, 5, 0, + 3, 2, 2, 1, 3, -8, 4, 1, + 3, 11, 3, -21, 4, 2, 5, 0, + 3, 3, 2, -7, 3, 4, 4, 0, + 3, 7, 3, -13, 4, -1, 5, 1, + 3, 1, 3, -2, 4, 2, 6, 0, + 3, 1, 2, -8, 3, 12, 4, 1, + 3, 1, 4, -8, 5, 4, 6, 0, + 3, 1, 4, -7, 5, 2, 6, 0, + 3, 1, 4, -9, 5, 7, 6, 0, + 1, 1, 7, 0, + 2, 1, 5, -2, 6, 0, + 3, 1, 3, -2, 4, 1, 5, 0, + 3, 3, 3, -6, 4, 2, 5, 1, + 3, 12, 3, -23, 4, 3, 5, 0, + 2, 8, 3, -15, 4, 3, + 2, 1, 4, -6, 5, 2, + 3, 2, 2, -7, 3, 7, 4, 0, + 2, 1, 2, -3, 4, 2, + 2, 2, 5, -4, 6, 0, + 1, 1, 6, 1, + 2, 9, 3, -17, 4, 2, + 3, 2, 3, -4, 4, 2, 5, 0, + 3, 2, 3, -4, 4, 1, 5, 0, + 2, 1, 5, -1, 6, 0, + 2, 2, 2, -6, 4, 2, + 2, 1, 3, -2, 4, 2, + 2, 2, 5, -3, 6, 0, + 1, 2, 6, 1, + 2, 3, 5, -5, 6, 1, + 1, 1, 5, 2, + 3, 4, 3, -8, 4, 2, 5, 0, + 2, 1, 5, -5, 6, 0, + 2, 7, 3, -13, 4, 2, + 2, 3, 2, -9, 4, 0, + 2, 2, 5, -2, 6, 0, + 1, 3, 6, 0, + 2, 1, 4, -5, 5, 0, + 2, 2, 3, -4, 4, 2, + 2, 6, 3, -11, 4, 2, + 2, 4, 5, -5, 6, 0, + 1, 2, 5, 2, + 3, 1, 4, -3, 5, -3, 6, 0, + 2, 3, 3, -6, 4, 2, + 2, 1, 4, -4, 5, 1, + 2, 5, 3, -9, 4, 2, + 1, 3, 5, 1, + 2, 4, 3, -8, 4, 2, + 3, 1, 4, -4, 5, 2, 6, 0, + 3, 1, 4, -1, 5, -5, 6, 0, + 2, 4, 3, -7, 4, 2, + 2, 1, 4, -3, 5, 2, + 3, 1, 4, -5, 5, 5, 6, 1, + 3, 1, 4, -4, 5, 3, 6, 0, + 3, 1, 4, -3, 5, 1, 6, 0, + 2, 5, 3, -10, 4, 1, + 1, 4, 5, 0, + 2, 3, 3, -5, 4, 2, + 3, 1, 4, -3, 5, 2, 6, 0, + 2, 1, 4, -5, 6, 2, + 2, 1, 4, -2, 5, 2, + 3, 1, 4, -4, 5, 5, 6, 1, + 2, 6, 3, -12, 4, 1, + 2, 1, 4, -4, 6, 0, + 2, 2, 3, -3, 4, 2, + 2, 10, 3, -18, 4, 0, + 2, 1, 4, -3, 6, 1, + 3, 1, 4, -2, 5, 2, 6, 0, + 2, 7, 3, -14, 4, 1, + 3, 1, 4, 1, 5, -5, 6, 1, + 2, 1, 4, -1, 5, 0, + 3, 1, 4, -3, 5, 5, 6, 1, + 3, 1, 4, 2, 5, -7, 6, 1, + 2, 1, 4, -2, 6, 2, + 3, 1, 4, -2, 5, 3, 6, 0, + 2, 1, 3, -1, 4, 0, + 2, 2, 2, -7, 4, 1, + 2, 9, 3, -16, 4, 2, + 2, 1, 4, -3, 7, 0, + 2, 1, 4, -1, 6, 0, + 3, 1, 4, -2, 5, 4, 6, 1, + 2, 1, 2, -4, 4, 2, + 2, 8, 3, -16, 4, 2, + 2, 1, 4, -2, 7, 0, + 3, 3, 3, -5, 4, 2, 5, 0, + 3, 1, 4, 1, 5, -3, 6, 0, + 2, 1, 4, -2, 8, 0, + 2, 1, 4, -1, 7, 0, + 2, 1, 4, -1, 8, 0, + 3, 3, 2, -7, 3, 3, 4, 0, + 3, 2, 2, 1, 3, -7, 4, 0, + 3, 1, 4, 1, 6, -3, 7, 0, + 3, 1, 4, 2, 5, -5, 6, 1, + 3, 4, 3, -7, 4, 3, 5, 1, + 1, 1, 4, 5, + 3, 4, 3, -9, 4, 3, 5, 1, + 3, 1, 4, -2, 5, 5, 6, 0, + 3, 3, 2, -7, 3, 5, 4, 0, + 3, 1, 3, -1, 4, 2, 6, 0, + 3, 1, 4, 1, 5, -2, 6, 0, + 3, 3, 3, -7, 4, 2, 5, 0, + 2, 8, 3, -14, 4, 1, + 2, 1, 2, -2, 4, 1, + 2, 1, 4, 1, 6, 1, + 2, 9, 3, -18, 4, 1, + 2, 2, 2, -5, 4, 1, + 2, 1, 3, -3, 4, 2, + 2, 1, 4, 2, 6, 0, + 2, 1, 4, 1, 5, 1, + 3, 4, 3, -9, 4, 2, 5, 1, + 2, 7, 3, -12, 4, 1, + 2, 2, 4, -5, 5, 0, + 2, 2, 3, -5, 4, 2, + 2, 6, 3, -10, 4, 1, + 2, 1, 4, 2, 5, 1, + 3, 2, 4, -5, 5, 2, 6, 0, + 2, 3, 3, -7, 4, 1, + 2, 2, 4, -4, 5, 0, + 2, 5, 3, -8, 4, 1, + 2, 1, 4, 3, 5, 0, + 3, 2, 4, -4, 5, 2, 6, 0, + 3, 2, 4, -1, 5, -5, 6, 0, + 2, 4, 3, -6, 4, 1, + 2, 2, 4, -3, 5, 0, + 3, 2, 4, -5, 5, 5, 6, 1, + 3, 2, 4, -4, 5, 3, 6, 0, + 2, 3, 3, -4, 4, 1, + 2, 2, 4, -5, 6, 2, + 2, 2, 4, -2, 5, 1, + 3, 2, 4, -4, 5, 5, 6, 1, + 2, 2, 4, -4, 6, 0, + 2, 2, 3, -2, 4, 0, + 2, 2, 4, -3, 6, 1, + 2, 2, 4, -1, 5, 1, + 2, 2, 4, -2, 6, 0, + 1, 1, 3, 1, + 2, 2, 4, -1, 6, 0, + 2, 1, 2, -5, 4, 1, + 2, 8, 3, -17, 4, 1, + 3, 2, 4, 2, 5, -5, 6, 1, + 3, 4, 3, -6, 4, 3, 5, 1, + 3, 10, 3, -17, 4, 3, 6, 0, + 1, 2, 4, 4, + 3, 4, 3, -10, 4, 3, 5, 1, + 2, 8, 3, -13, 4, 0, + 2, 1, 2, -1, 4, 0, + 2, 2, 4, 1, 6, 0, + 2, 2, 2, -4, 4, 0, + 2, 1, 3, -4, 4, 1, + 2, 2, 4, 1, 5, 0, + 2, 7, 3, -11, 4, 0, + 2, 3, 4, -5, 5, 0, + 2, 2, 3, -6, 4, 1, + 2, 6, 3, -9, 4, 0, + 2, 2, 4, 2, 5, 0, + 2, 3, 4, -4, 5, 0, + 2, 5, 3, -7, 4, 0, + 2, 4, 3, -5, 4, 1, + 2, 3, 4, -3, 5, 1, + 2, 3, 3, -3, 4, 0, + 2, 3, 4, -2, 5, 2, + 3, 3, 4, -4, 5, 5, 6, 0, + 2, 2, 3, -1, 4, 0, + 2, 3, 4, -3, 6, 0, + 2, 3, 4, -1, 5, 1, + 2, 3, 4, -2, 6, 0, + 2, 1, 3, 1, 4, 1, + 2, 3, 4, -1, 6, 0, + 3, 4, 3, -5, 4, 3, 5, 0, + 1, 3, 4, 3, + 3, 4, 3, -11, 4, 3, 5, 0, + 1, 1, 2, 0, + 2, 2, 2, -3, 4, 0, + 2, 1, 3, -5, 4, 0, + 2, 4, 4, -5, 5, 0, + 2, 6, 3, -8, 4, 0, + 2, 4, 4, -4, 5, 0, + 2, 5, 3, -6, 4, 0, + 2, 4, 3, -4, 4, 0, + 2, 4, 4, -3, 5, 1, + 3, 6, 3, -8, 4, 2, 5, 0, + 2, 3, 3, -2, 4, 0, + 2, 4, 4, -2, 5, 1, + 2, 4, 4, -1, 5, 0, + 2, 1, 3, 2, 4, 0, + 1, 4, 4, 3, + 2, 2, 2, -2, 4, 0, + 2, 7, 3, -9, 4, 0, + 2, 5, 4, -5, 5, 0, + 2, 6, 3, -7, 4, 0, + 2, 5, 4, -4, 5, 0, + 2, 5, 3, -5, 4, 0, + 2, 5, 4, -3, 5, 0, + 2, 5, 4, -2, 5, 0, + 1, 5, 4, 3, + 1, 6, 4, 2, + 1, 7, 4, 0, + -1 }; + /* Total terms = 201, small = 199 */ static struct plantbl FAR mar404 = { - { 0, 5, 12, 24, 9, 7, 3, 2, 0,}, - 5, - marargs, - martabl, - martabb, - martabr, - 1.5303348827100001e+00, + {0, 5, 12, 24, 9, 7, 3, 2, 0,}, + 5, + marargs, + martabl, + martabb, + martabr, + 1.5303348827100001e+00, }; /* @@ -4529,1198 +4543,1201 @@ Days per record = 131.0 3000.0 to 3000.4: 0.526 0.023 0.190 */ static double FAR juptabl[] = { - 153429.13855, 130818.16897, 18120.42948, -8463.12663, - -5058.91447, 1092566021.02148, 123671.25097, + 153429.13855, 130818.16897, 18120.42948, -8463.12663, + -5058.91447, 1092566021.02148, 123671.25097, - -5.43364, 12.06012, + -5.43364, 12.06012, - 30428.31077, -74667.61443, 46848.16236, -66373.44474, - 24312.54264, -26045.64766, 18353.92564, -4022.13679, - 4037.97936, 10059.82468, -4622.55896, 1383.21617, - -187.25468, -1171.66028, + 30428.31077, -74667.61443, 46848.16236, -66373.44474, + 24312.54264, -26045.64766, 18353.92564, -4022.13679, + 4037.97936, 10059.82468, -4622.55896, 1383.21617, + -187.25468, -1171.66028, - -0.00062, -0.21713, + -0.00062, -0.21713, - -1198.83945, 1178.62445, -1492.07393, 153.07155, - -245.57966, -391.94010, 82.26400, -40.92104, - 3.72520, 10.57242, + -1198.83945, 1178.62445, -1492.07393, 153.07155, + -245.57966, -391.94010, 82.26400, -40.92104, + 3.72520, 10.57242, - -0.04720, -0.04448, -0.04329, -0.06043, + -0.04720, -0.04448, -0.04329, -0.06043, - -0.03905, 0.15712, + -0.03905, 0.15712, - -0.05644, -0.00129, + -0.05644, -0.00129, - -0.00342, 0.02473, + -0.00342, 0.02473, - 0.00434, -0.01862, + 0.00434, -0.01862, - 0.00431, -0.03993, + 0.00431, -0.03993, - -0.03159, -0.15982, + -0.03159, -0.15982, - -0.09928, 0.04430, -0.00357, 0.31312, + -0.09928, 0.04430, -0.00357, 0.31312, - -0.01346, -0.00180, + -0.01346, -0.00180, - -0.09107, 0.01215, + -0.09107, 0.01215, - 0.02485, 0.01024, + 0.02485, 0.01024, - 27.29869, 2.70896, 12.91956, 19.21726, - -6.91384, 5.12954, -1.07533, -1.71691, + 27.29869, 2.70896, 12.91956, 19.21726, + -6.91384, 5.12954, -1.07533, -1.71691, - -0.01423, 0.03121, + -0.01423, 0.03121, - -32.48652, -26.13483, 46.78162, -62.02701, - 94.96809, 81.73791, -20.13673, 131.05065, + -32.48652, -26.13483, 46.78162, -62.02701, + 94.96809, 81.73791, -20.13673, 131.05065, - -0.00798, 0.01786, + -0.00798, 0.01786, - 13.99591, 16.87756, -8.51726, 21.59490, - -14.28833, -9.45530, 7.73954, -6.53078, + 13.99591, 16.87756, -8.51726, 21.59490, + -14.28833, -9.45530, 7.73954, -6.53078, - 0.03175, -0.04295, + 0.03175, -0.04295, - 3.06742, -0.11838, 1.03630, 0.94004, - -0.14085, 0.14434, + 3.06742, -0.11838, 1.03630, 0.94004, + -0.14085, 0.14434, - -0.03363, 0.00993, + -0.03363, 0.00993, - -0.00007, -0.02748, + -0.00007, -0.02748, - 26.01507, -7.37178, 16.96955, 6.24203, - -0.40481, 3.72456, -0.53597, -0.14938, + 26.01507, -7.37178, 16.96955, 6.24203, + -0.40481, 3.72456, -0.53597, -0.14938, - 37.82081, 26.15887, -2.82115, 78.26478, - -63.39155, -5.52419, 13.11482, -43.54977, - 15.64940, 6.67505, + 37.82081, 26.15887, -2.82115, 78.26478, + -63.39155, -5.52419, 13.11482, -43.54977, + 15.64940, 6.67505, - -10.25616, -7.39672, -12.37441, 12.24417, - 8.54922, 9.68451, + -10.25616, -7.39672, -12.37441, 12.24417, + 8.54922, 9.68451, - -0.03658, -0.00963, + -0.03658, -0.00963, - 1.65523, 0.43093, 0.32023, 0.71365, - -0.12226, 0.03759, + 1.65523, 0.43093, 0.32023, 0.71365, + -0.12226, 0.03759, - 0.10388, 0.47212, -0.02791, 0.09929, + 0.10388, 0.47212, -0.02791, 0.09929, - -0.04116, -0.03125, + -0.04116, -0.03125, - -0.10240, -0.23199, -0.03524, -0.13625, + -0.10240, -0.23199, -0.03524, -0.13625, - 7.52726, 6.86314, 0.01239, 13.46530, - -5.22256, 1.56116, -0.15925, -1.19571, + 7.52726, 6.86314, 0.01239, 13.46530, + -5.22256, 1.56116, -0.15925, -1.19571, - 3.26302, 0.06097, -0.14444, -0.20301, - 1.93822, -80.12566, + 3.26302, 0.06097, -0.14444, -0.20301, + 1.93822, -80.12566, - 0.98665, -7.52986, 3.86703, -2.43028, - 0.64180, 0.78351, + 0.98665, -7.52986, 3.86703, -2.43028, + 0.64180, 0.78351, - 0.00190, -0.00633, + 0.00190, -0.00633, - -0.00321, -0.04403, + -0.00321, -0.04403, - 0.19018, 0.14335, 0.10315, 0.53154, + 0.19018, 0.14335, 0.10315, 0.53154, - -0.00062, -0.00464, + -0.00062, -0.00464, - -0.00109, 0.02150, + -0.00109, 0.02150, - 1.19993, 47.21638, -24.56067, 25.06332, - -7.50751, -6.36250, 1.39443, -1.23806, + 1.19993, 47.21638, -24.56067, 25.06332, + -7.50751, -6.36250, 1.39443, -1.23806, - 0.04951, 0.02176, + 0.04951, 0.02176, - 0.02802, -0.01665, + 0.02802, -0.01665, - -0.10698, -0.13635, + -0.10698, -0.13635, - 73.54797, -52.34968, 74.98754, 86.56283, - -69.01463, 44.56866, + 73.54797, -52.34968, 74.98754, 86.56283, + -69.01463, 44.56866, - 0.04387, -0.05925, + 0.04387, -0.05925, - -0.03732, -0.03264, + -0.03732, -0.03264, - 0.00967, 0.02143, + 0.00967, 0.02143, - 10.59429, 26.48226, 34.03470, 3.96160, - 4.15919, -20.22616, -5.25903, -3.40177, + 10.59429, 26.48226, 34.03470, 3.96160, + 4.15919, -20.22616, -5.25903, -3.40177, - 0.05111, -0.06788, + 0.05111, -0.06788, - 0.06497, 1.21024, -0.29607, 0.49991, - -0.06055, -0.03464, + 0.06497, 1.21024, -0.29607, 0.49991, + -0.06055, -0.03464, - 0.02950, 0.16429, + 0.02950, 0.16429, - 0.00722, -0.90806, + 0.00722, -0.90806, - -0.02161, 0.00902, + -0.02161, 0.00902, - -0.00261, 0.00077, + -0.00261, 0.00077, - 0.00434, -0.29231, + 0.00434, -0.29231, - 0.00456, 0.04781, + 0.00456, 0.04781, - 1.33214, -2.62015, 0.79761, -0.81850, - 0.06371, 0.00119, + 1.33214, -2.62015, 0.79761, -0.81850, + 0.06371, 0.00119, - 0.03049, -0.03553, 0.02373, -0.01411, + 0.03049, -0.03553, 0.02373, -0.01411, - -189.06132, -169.17940, 5.27464, -227.72664, - 83.72511, -12.04794, 0.23965, 23.75496, - -3.43532, -0.34276, + -189.06132, -169.17940, 5.27464, -227.72664, + 83.72511, -12.04794, 0.23965, 23.75496, + -3.43532, -0.34276, - -1.35880, 0.45053, -0.34298, -0.11441, + -1.35880, 0.45053, -0.34298, -0.11441, - -0.16328, 0.07423, + -0.16328, 0.07423, - 481.48150, 79.82461, 453.82764, 941.94205, - -635.83924, 397.29087, -81.54066, -417.22420, - 149.91822, 10.53490, + 481.48150, 79.82461, 453.82764, 941.94205, + -635.83924, 397.29087, -81.54066, -417.22420, + 149.91822, 10.53490, - -0.13210, 0.36740, + -0.13210, 0.36740, - 0.33777, 0.15893, + 0.33777, 0.15893, - -2562.04968, 2442.77844, -2602.66709, 2838.87348, - 723.50715, -1284.58208, -4557.23362, -4514.61100, - -8960.81693, 4663.55087, -4947.61530, 19377.42027, + -2562.04968, 2442.77844, -2602.66709, 2838.87348, + 723.50715, -1284.58208, -4557.23362, -4514.61100, + -8960.81693, 4663.55087, -4947.61530, 19377.42027, - -0.16786, -0.19514, + -0.16786, -0.19514, - 0.32100, 0.91502, + 0.32100, 0.91502, - 4.96600, -1.11836, + 4.96600, -1.11836, - 307.38057, 175.14618, 16.02093, 444.42376, - -219.80047, 62.39286, -18.14266, -52.23698, + 307.38057, 175.14618, 16.02093, 444.42376, + -219.80047, 62.39286, -18.14266, -52.23698, - 0.02111, 0.00469, + 0.02111, 0.00469, - -20.97409, -34.48296, -2.03906, -27.07560, - 3.73818, -3.00599, 0.24112, 0.41430, + -20.97409, -34.48296, -2.03906, -27.07560, + 3.73818, -3.00599, 0.24112, 0.41430, - -0.03552, 0.00394, + -0.03552, 0.00394, - -0.00217, 0.02307, + -0.00217, 0.02307, - 0.03686, 0.00510, + 0.03686, 0.00510, - 34.46537, 10.23293, 9.99520, 28.88781, - -11.31210, 3.52646, -0.48062, -2.93641, + 34.46537, 10.23293, 9.99520, 28.88781, + -11.31210, 3.52646, -0.48062, -2.93641, - -0.00987, -0.05310, + -0.00987, -0.05310, - -38.39539, 0.04568, -31.73684, -1.83151, - -24.97332, -1.71244, 0.33498, 7.03899, - -4.15247, 200.43434, + -38.39539, 0.04568, -31.73684, -1.83151, + -24.97332, -1.71244, 0.33498, 7.03899, + -4.15247, 200.43434, - -0.00800, 0.04462, + -0.00800, 0.04462, - 37.83113, -13.40661, 9.49434, -35.41588, - -14.72767, -3.84674, -0.31412, 3.97734, + 37.83113, -13.40661, 9.49434, -35.41588, + -14.72767, -3.84674, -0.31412, 3.97734, - 0.02908, -0.00353, + 0.02908, -0.00353, - 1.89935, -14.31774, 7.77051, -7.08945, - 1.90915, 1.78908, -0.41445, 0.30506, + 1.89935, -14.31774, 7.77051, -7.08945, + 1.90915, 1.78908, -0.41445, 0.30506, - -14.43121, 7.30707, -11.97842, -17.64121, - 13.38962, -7.20982, + -14.43121, 7.30707, -11.97842, -17.64121, + 13.38962, -7.20982, - -5.23362, 2.11364, -0.45605, 4.08835, - 1.42683, 0.24838, + -5.23362, 2.11364, -0.45605, 4.08835, + 1.42683, 0.24838, - -0.00605, 0.03199, + -0.00605, 0.03199, - -0.17609, -1.43091, 0.32444, -0.51371, - 0.06182, 0.03733, + -0.17609, -1.43091, 0.32444, -0.51371, + 0.06182, 0.03733, - 0.00696, -0.13438, + 0.00696, -0.13438, - 4.67581, 4.42379, -1.52602, 4.20659, - -1.31757, -0.72910, + 4.67581, 4.42379, -1.52602, 4.20659, + -1.31757, -0.72910, - 1.29012, 0.97780, 2.25895, -0.85306, - 1.74120, -5.09507, + 1.29012, 0.97780, 2.25895, -0.85306, + 1.74120, -5.09507, - 0.28107, -0.05040, 0.05508, -0.06349, + 0.28107, -0.05040, 0.05508, -0.06349, - -0.00061, 0.48249, + -0.00061, 0.48249, - -2.37749, 1.78180, -1.67423, -0.35618, - 0.05789, -0.35287, + -2.37749, 1.78180, -1.67423, -0.35618, + 0.05789, -0.35287, - 0.56252, -0.66584, 0.61979, 4.84016, - -4.64462, 17.48002, + 0.56252, -0.66584, 0.61979, 4.84016, + -4.64462, 17.48002, - 0.40982, -4.19214, -1.55252, -1.87505, - -0.31070, 0.15554, + 0.40982, -4.19214, -1.55252, -1.87505, + -0.31070, 0.15554, - -0.00034, 0.11102, + -0.00034, 0.11102, - 0.01116, -0.04166, + 0.01116, -0.04166, - 9.27689, -4.32090, 6.84888, 1.78741, - -0.09306, 1.68391, -0.27482, -0.04197, + 9.27689, -4.32090, 6.84888, 1.78741, + -0.09306, 1.68391, -0.27482, -0.04197, - -7.83068, 37.71086, -37.53346, 7.18559, - 0.74427, -24.29751, 10.87837, 1.35503, + -7.83068, 37.71086, -37.53346, 7.18559, + 0.74427, -24.29751, 10.87837, 1.35503, - 0.00998, -0.03395, + 0.00998, -0.03395, - -133.52206, -150.11329, 4.27494, -173.79469, - 150.87961, -356.29181, -330.17873, -426.29809, - -607.98186, 126.35464, -299.69623, 556.41055, + -133.52206, -150.11329, 4.27494, -173.79469, + 150.87961, -356.29181, -330.17873, -426.29809, + -607.98186, 126.35464, -299.69623, 556.41055, - -0.00342, 0.04411, + -0.00342, 0.04411, - 44.65946, 42.07312, 85.71397, 5.95130, - 24.98064, -41.20026, -14.05970, -10.46101, - -2.24038, 2.89211, + 44.65946, 42.07312, 85.71397, 5.95130, + 24.98064, -41.20026, -14.05970, -10.46101, + -2.24038, 2.89211, - 0.06175, 0.08128, 0.00705, 0.01939, + 0.06175, 0.08128, 0.00705, 0.01939, - -1.08361, -0.08213, -0.20868, -0.36268, + -1.08361, -0.08213, -0.20868, -0.36268, - -4.96489, -2.05966, -6.16586, 3.65514, - -3.12555, 12.20821, + -4.96489, -2.05966, -6.16586, 3.65514, + -3.12555, 12.20821, - -1.11236, -1.73772, -1.34045, -0.22774, - -0.08639, 0.27355, + -1.11236, -1.73772, -1.34045, -0.22774, + -0.08639, 0.27355, - -0.07700, 1.06260, -0.46013, 0.31916, - -0.04969, -0.09488, + -0.07700, 1.06260, -0.46013, 0.31916, + -0.04969, -0.09488, - -1.54000, 0.04949, -0.07616, -0.95933, - 0.93303, 3.43183, + -1.54000, 0.04949, -0.07616, -0.95933, + 0.93303, 3.43183, - -0.82917, -0.82042, -0.68158, 0.17083, - 0.06942, 0.17491, + -0.82917, -0.82042, -0.68158, 0.17083, + 0.06942, 0.17491, - -0.02699, -0.01051, + -0.02699, -0.01051, - 0.00657, 0.03063, + 0.00657, 0.03063, - -0.52595, 0.84035, -0.88323, -0.70188, - 0.60928, -0.48179, + -0.52595, 0.84035, -0.88323, -0.70188, + 0.60928, -0.48179, - 0.38290, 0.04482, 0.26456, -0.32369, + 0.38290, 0.04482, 0.26456, -0.32369, - -0.00615, 0.03218, + -0.00615, 0.03218, - -0.32943, 0.14675, -0.10782, -0.09036, + -0.32943, 0.14675, -0.10782, -0.09036, - -0.58003, 0.72888, -0.46654, 1.17977, + -0.58003, 0.72888, -0.46654, 1.17977, - 0.00222, 0.01541, + 0.00222, 0.01541, - -0.19226, -0.07770, -0.01829, -0.05070, + -0.19226, -0.07770, -0.01829, -0.05070, - -1.75385, -1.32969, 0.52361, -1.36036, - 0.67222, 1.34612, + -1.75385, -1.32969, 0.52361, -1.36036, + 0.67222, 1.34612, - 6.96841, -29.24025, -23.76900, -39.91647, - -41.01215, -2.23638, -18.81024, 20.77095, + 6.96841, -29.24025, -23.76900, -39.91647, + -41.01215, -2.23638, -18.81024, 20.77095, - -0.68592, -2.26212, -1.14065, -0.76493, - -0.18044, 0.15193, + -0.68592, -2.26212, -1.14065, -0.76493, + -0.18044, 0.15193, - -0.20669, -0.44387, 0.25697, -0.17880, + -0.20669, -0.44387, 0.25697, -0.17880, - -0.53097, 0.43181, -0.35187, 0.71934, + -0.53097, 0.43181, -0.35187, 0.71934, - -0.14962, 0.09220, -0.05031, -0.03924, + -0.14962, 0.09220, -0.05031, -0.03924, - 0.06571, 0.29487, + 0.06571, 0.29487, - 0.05170, 0.36847, + 0.05170, 0.36847, - 0.02754, -0.00411, + 0.02754, -0.00411, - -0.08313, -0.16907, 0.10273, -0.07315, + -0.08313, -0.16907, 0.10273, -0.07315, - -0.02312, 0.04912, + -0.02312, 0.04912, - -0.01062, -0.02713, + -0.01062, -0.02713, - 0.03806, 0.13401, + 0.03806, 0.13401, - -1.79865, -2.04540, -2.69965, -0.65706, - -1.17916, 0.79292, + -1.79865, -2.04540, -2.69965, -0.65706, + -1.17916, 0.79292, - 0.02415, 0.14001, + 0.02415, 0.14001, - -0.01767, 0.04209, + -0.01767, 0.04209, - 0.05212, -0.01795, + 0.05212, -0.01795, - 0.01285, 0.04028, + 0.01285, 0.04028, - 0.01075, 0.05533, + 0.01075, 0.05533, - 0.02323, -0.00864, + 0.02323, -0.00864, - -0.04691, 0.03128, + -0.04691, 0.03128, - 0.00548, 0.02254, + 0.00548, 0.02254, - 0.00011, 0.12033, + 0.00011, 0.12033, }; + static double FAR juptabb[] = { - 548.59659, 594.29629, 219.97664, 59.71822, - 23.62157, 40.77732, 227.07380, + 548.59659, 594.29629, 219.97664, 59.71822, + 23.62157, 40.77732, 227.07380, - 0.00293, -0.00745, + 0.00293, -0.00745, - -307.33226, -347.92807, -309.49383, -428.18929, - -96.59506, -191.36254, 2.11014, -34.44145, - 2.23085, 6.77110, -5.43468, -0.28391, - 0.28355, -1.81690, + -307.33226, -347.92807, -309.49383, -428.18929, + -96.59506, -191.36254, 2.11014, -34.44145, + 2.23085, 6.77110, -5.43468, -0.28391, + 0.28355, -1.81690, - 0.00036, 0.00078, + 0.00036, 0.00078, - -1.83259, 1.17464, -2.66976, -0.92339, - -0.23645, -1.20623, 0.25248, -0.04958, - 0.00064, 0.03599, + -1.83259, 1.17464, -2.66976, -0.92339, + -0.23645, -1.20623, 0.25248, -0.04958, + 0.00064, 0.03599, - -0.00079, 0.00004, -0.00005, -0.00010, + -0.00079, 0.00004, -0.00005, -0.00010, - -0.00024, 0.00051, + -0.00024, 0.00051, - 0.00001, 0.00005, + 0.00001, 0.00005, - 0.00015, 0.00010, + 0.00015, 0.00010, - 0.00017, -0.00004, + 0.00017, -0.00004, - 0.00113, -0.00011, + 0.00113, -0.00011, - 0.00021, 0.00087, + 0.00021, 0.00087, - 0.00120, -0.00114, -0.00881, -0.00020, + 0.00120, -0.00114, -0.00881, -0.00020, - -0.00005, 0.00009, + -0.00005, 0.00009, - 0.00005, 0.00007, + 0.00005, 0.00007, - 0.00002, -0.00033, + 0.00002, -0.00033, - -0.00554, -0.32274, 0.23695, -0.11184, - 0.04050, 0.09929, -0.02189, 0.00305, + -0.00554, -0.32274, 0.23695, -0.11184, + 0.04050, 0.09929, -0.02189, 0.00305, - -0.00142, -0.00055, + -0.00142, -0.00055, - 0.66623, 0.34590, 0.74913, -0.23202, - -1.08316, -1.40407, 1.72287, -0.07604, + 0.66623, 0.34590, 0.74913, -0.23202, + -1.08316, -1.40407, 1.72287, -0.07604, - 0.00024, 0.00004, + 0.00024, 0.00004, - 0.03592, 0.91143, -1.11848, -0.17473, - 0.91500, -1.34912, 0.85229, 0.69029, + 0.03592, 0.91143, -1.11848, -0.17473, + 0.91500, -1.34912, 0.85229, 0.69029, - -0.00019, 0.00075, + -0.00019, 0.00075, - 0.03615, 0.30768, -0.08733, 0.12016, - -0.01716, -0.01138, + 0.03615, 0.30768, -0.08733, 0.12016, + -0.01716, -0.01138, - 0.00021, 0.00004, + 0.00021, 0.00004, - 0.00531, 0.00098, + 0.00531, 0.00098, - -0.14354, -0.02364, -0.05559, -0.07561, - 0.01419, -0.01141, 0.00014, 0.00218, + -0.14354, -0.02364, -0.05559, -0.07561, + 0.01419, -0.01141, 0.00014, 0.00218, - -0.36564, 0.13498, -0.13283, -0.11462, - 0.23741, 0.14960, -0.23173, 0.25148, - 0.00763, -0.05987, + -0.36564, 0.13498, -0.13283, -0.11462, + 0.23741, 0.14960, -0.23173, 0.25148, + 0.00763, -0.05987, - -0.00857, 0.20312, -0.29399, 0.34831, - -1.33166, -0.46808, + -0.00857, 0.20312, -0.29399, 0.34831, + -1.33166, -0.46808, - -0.00027, 0.00046, + -0.00027, 0.00046, - 0.15729, 0.01367, 0.04093, 0.07447, - -0.01598, 0.00785, + 0.15729, 0.01367, 0.04093, 0.07447, + -0.01598, 0.00785, - 0.00583, 0.00324, 0.00053, 0.00160, + 0.00583, 0.00324, 0.00053, 0.00160, - -0.00030, 0.00043, + -0.00030, 0.00043, - -0.00208, 0.00334, -0.00316, 0.00136, + -0.00208, 0.00334, -0.00316, 0.00136, - 0.23086, 0.05711, 0.19558, 0.05897, - 0.01070, 0.05021, -0.00818, -0.02242, + 0.23086, 0.05711, 0.19558, 0.05897, + 0.01070, 0.05021, -0.00818, -0.02242, - 0.06301, -0.26483, 0.66177, 0.02125, - 0.13477, 0.19376, + 0.06301, -0.26483, 0.66177, 0.02125, + 0.13477, 0.19376, - -0.36520, 0.83588, -0.69848, -0.00877, - 0.01626, -0.23878, + -0.36520, 0.83588, -0.69848, -0.00877, + 0.01626, -0.23878, - -0.00373, 0.00044, + -0.00373, 0.00044, - 0.00008, -0.00004, + 0.00008, -0.00004, - -0.00374, -0.00283, 0.01104, -0.00619, + -0.00374, -0.00283, 0.01104, -0.00619, - 0.00004, 0.00015, + 0.00004, 0.00015, - 0.00026, 0.00013, + 0.00026, 0.00013, - 0.04630, -0.11815, 0.00773, 0.03796, - -0.05172, 0.00149, 0.00444, -0.01493, + 0.04630, -0.11815, 0.00773, 0.03796, + -0.05172, 0.00149, 0.00444, -0.01493, - -0.00064, -0.00044, + -0.00064, -0.00044, - -0.00033, 0.00002, + -0.00033, 0.00002, - -0.00012, 0.00284, + -0.00012, 0.00284, - -0.15622, -0.92158, -0.82690, -1.52101, - -0.55934, 0.69375, + -0.15622, -0.92158, -0.82690, -1.52101, + -0.55934, 0.69375, - -0.00171, 0.00031, + -0.00171, 0.00031, - 0.00129, -0.00013, + 0.00129, -0.00013, - -0.00024, -0.00083, + -0.00024, -0.00083, - 0.66101, -0.21764, -0.43967, 0.30157, - 0.53389, 1.59141, 1.94286, 0.14146, + 0.66101, -0.21764, -0.43967, 0.30157, + 0.53389, 1.59141, 1.94286, 0.14146, - -0.00064, -0.00006, + -0.00064, -0.00006, - 0.21850, -0.02912, 0.08594, 0.08734, - -0.01678, 0.01629, + 0.21850, -0.02912, 0.08594, 0.08734, + -0.01678, 0.01629, - 0.00133, 0.00562, + 0.00133, 0.00562, - 0.00128, -0.00025, + 0.00128, -0.00025, - -0.00005, 0.00027, + -0.00005, 0.00027, - 0.00032, 0.00001, + 0.00032, 0.00001, - 0.00037, 0.00042, + 0.00037, 0.00042, - 0.00070, 0.00003, + 0.00070, 0.00003, - 0.00275, -0.13096, 0.02329, -0.05582, - 0.00405, -0.00251, + 0.00275, -0.13096, 0.02329, -0.05582, + 0.00405, -0.00251, - 0.01316, -0.01165, 0.00279, -0.00374, + 0.01316, -0.01165, 0.00279, -0.00374, - -39.62783, 20.91467, -28.97236, 3.77560, - -3.30029, 0.11472, -0.48216, 1.05814, - -0.21607, -0.03055, + -39.62783, 20.91467, -28.97236, 3.77560, + -3.30029, 0.11472, -0.48216, 1.05814, + -0.21607, -0.03055, - -0.64162, -0.57355, -0.05861, -0.18592, + -0.64162, -0.57355, -0.05861, -0.18592, - -0.12207, -0.06279, + -0.12207, -0.06279, - -38.55325, -125.74207, -47.22357, 41.75842, - -119.38841, 18.88515, -11.04830, -50.98851, - 16.64895, 1.76553, + -38.55325, -125.74207, -47.22357, 41.75842, + -119.38841, 18.88515, -11.04830, -50.98851, + 16.64895, 1.76553, - 0.09474, 0.03714, + 0.09474, 0.03714, - 0.02593, 0.07967, + 0.02593, 0.07967, - -1187.61854, -1094.91786, -1011.21939, -1102.25998, - -575.88672, -107.84860, -890.58889, -807.06589, - 971.78461, -1287.24560, -4601.44669, -849.54329, + -1187.61854, -1094.91786, -1011.21939, -1102.25998, + -575.88672, -107.84860, -890.58889, -807.06589, + 971.78461, -1287.24560, -4601.44669, -849.54329, - -0.00904, 0.06233, + -0.00904, 0.06233, - -0.19456, -0.05521, + -0.19456, -0.05521, - -0.36915, 1.15363, + -0.36915, 1.15363, - 32.64763, -85.19705, 114.34437, -13.37747, - 15.92865, 55.84857, -13.10538, 3.07629, + 32.64763, -85.19705, 114.34437, -13.37747, + 15.92865, 55.84857, -13.10538, 3.07629, - -0.00327, 0.00104, + -0.00327, 0.00104, - -7.81035, 6.19960, -6.36096, 1.00493, - -0.66971, -0.84572, 0.09943, -0.04583, + -7.81035, 6.19960, -6.36096, 1.00493, + -0.66971, -0.84572, 0.09943, -0.04583, - 0.00200, -0.00032, + 0.00200, -0.00032, - -0.00265, 0.00047, + -0.00265, 0.00047, - -0.00053, 0.00046, + -0.00053, 0.00046, - -0.24396, 0.20664, -0.30820, -0.04917, - 0.06184, -0.12642, 0.03053, 0.05054, + -0.24396, 0.20664, -0.30820, -0.04917, + 0.06184, -0.12642, 0.03053, 0.05054, - 0.00035, 0.00012, + 0.00035, 0.00012, - 0.42063, -0.58254, 0.90517, -0.66276, - 0.64765, 0.39338, -1.40645, 0.33017, - -1.43377, -0.67089, + 0.42063, -0.58254, 0.90517, -0.66276, + 0.64765, 0.39338, -1.40645, 0.33017, + -1.43377, -0.67089, - -0.00045, -0.00036, + -0.00045, -0.00036, - 0.23690, 0.07185, 0.28386, -0.04397, - 0.02836, -0.13082, -0.00978, 0.00108, + 0.23690, 0.07185, 0.28386, -0.04397, + 0.02836, -0.13082, -0.00978, 0.00108, - 0.00046, 0.00083, + 0.00046, 0.00083, - -0.01665, 0.32499, -0.09980, 0.18611, - -0.02561, 0.00239, -0.00084, -0.00110, + -0.01665, 0.32499, -0.09980, 0.18611, + -0.02561, 0.00239, -0.00084, -0.00110, - 0.46854, -0.35113, 0.69908, 0.53244, - 0.12875, 0.01115, + 0.46854, -0.35113, 0.69908, 0.53244, + 0.12875, 0.01115, - 0.13930, 0.02747, -0.10587, -0.17759, - -0.26850, 0.04400, + 0.13930, 0.02747, -0.10587, -0.17759, + -0.26850, 0.04400, - 0.00010, -0.00015, + 0.00010, -0.00015, - 0.00164, -0.01308, 0.00488, -0.01046, - 0.00170, 0.00024, + 0.00164, -0.01308, 0.00488, -0.01046, + 0.00170, 0.00024, - 0.00084, 0.00014, + 0.00084, 0.00014, - -0.08481, -0.02547, -0.02290, -0.02281, - -0.03946, -0.02810, + -0.08481, -0.02547, -0.02290, -0.02281, + -0.03946, -0.02810, - 0.01298, 0.08658, 0.05575, -0.01081, - 1.09695, 0.35441, + 0.01298, 0.08658, 0.05575, -0.01081, + 1.09695, 0.35441, - -0.03127, 0.07946, 0.01245, 0.02578, + -0.03127, 0.07946, 0.01245, 0.02578, - -0.00524, -0.00027, + -0.00524, -0.00027, - 0.08217, -0.31742, 0.15273, -0.07804, - 0.01197, 0.03053, + 0.08217, -0.31742, 0.15273, -0.07804, + 0.01197, 0.03053, - 0.81596, 0.38640, -0.89777, 0.59499, - -0.39581, -0.87375, + 0.81596, 0.38640, -0.89777, 0.59499, + -0.39581, -0.87375, - 0.02096, 0.49772, 0.29986, 0.24210, - 0.14038, -0.03016, + 0.02096, 0.49772, 0.29986, 0.24210, + 0.14038, -0.03016, - -0.00208, 0.00045, + -0.00208, 0.00045, - 0.01024, 0.00114, + 0.01024, 0.00114, - 1.23010, 1.75663, -0.12741, 1.44996, - -0.31607, 0.03151, 0.00259, -0.04741, + 1.23010, 1.75663, -0.12741, 1.44996, + -0.31607, 0.03151, 0.00259, -0.04741, - -11.57091, 8.00331, -9.24028, -6.36906, - 4.71248, -2.43695, 0.38630, 1.90625, + -11.57091, 8.00331, -9.24028, -6.36906, + 4.71248, -2.43695, 0.38630, 1.90625, - 0.01401, 0.00114, + 0.01401, 0.00114, - 33.56690, -55.17784, 33.21425, -52.57002, - 27.04138, 13.78610, 69.60307, -81.16312, - 27.53960, -158.28336, -205.94418, -95.08051, + 33.56690, -55.17784, 33.21425, -52.57002, + 27.04138, 13.78610, 69.60307, -81.16312, + 27.53960, -158.28336, -205.94418, -95.08051, - -0.01407, -0.00364, + -0.01407, -0.00364, - -18.56128, 6.02270, -10.11059, 24.69471, - 12.31878, 9.94393, 3.81994, -4.84109, - -1.08440, -0.72136, + -18.56128, 6.02270, -10.11059, 24.69471, + 12.31878, 9.94393, 3.81994, -4.84109, + -1.08440, -0.72136, - 0.03731, -0.02094, 0.00789, -0.00176, + 0.03731, -0.02094, 0.00789, -0.00176, - 0.09673, -0.11181, 0.03112, -0.00065, + 0.09673, -0.11181, 0.03112, -0.00065, - -0.29167, -0.82083, 0.40866, -0.77487, - -2.23349, -0.46973, + -0.29167, -0.82083, 0.40866, -0.77487, + -2.23349, -0.46973, - 0.41024, -0.14274, 0.07755, -0.24895, - -0.04965, -0.01197, + 0.41024, -0.14274, 0.07755, -0.24895, + -0.04965, -0.01197, - -0.02264, 0.05917, -0.02817, 0.01242, - -0.00250, -0.00247, + -0.02264, 0.05917, -0.02817, 0.01242, + -0.00250, -0.00247, - -0.14414, -0.03739, 0.14708, -0.07908, - 0.05843, 0.15173, + -0.14414, -0.03739, 0.14708, -0.07908, + 0.05843, 0.15173, - -0.01601, -0.07844, -0.05957, -0.03143, - -0.01830, 0.01257, + -0.01601, -0.07844, -0.05957, -0.03143, + -0.01830, 0.01257, - -0.00109, -0.00000, + -0.00109, -0.00000, - 0.00174, 0.00050, + 0.00174, 0.00050, - -0.02119, 0.06918, -0.02470, 0.00185, - 0.02372, -0.02417, + -0.02119, 0.06918, -0.02470, 0.00185, + 0.02372, -0.02417, - 0.01081, 0.05222, 0.09820, 0.05931, + 0.01081, 0.05222, 0.09820, 0.05931, - -0.00588, -0.00086, + -0.00588, -0.00086, - 0.01688, -0.00133, -0.00073, 0.00041, + 0.01688, -0.00133, -0.00073, 0.00041, - -0.02280, -0.05706, -0.17694, -0.12027, + -0.02280, -0.05706, -0.17694, -0.12027, - 0.00196, -0.00060, + 0.00196, -0.00060, - 0.00051, -0.02426, 0.00314, -0.00302, + 0.00051, -0.02426, 0.00314, -0.00302, - 0.17923, -0.78343, 0.52073, -0.02398, - -0.03978, 0.20841, + 0.17923, -0.78343, 0.52073, -0.02398, + -0.03978, 0.20841, - 6.51325, 3.37139, 12.88844, -6.72098, - 3.40949, -14.34313, -9.68278, -7.85143, + 6.51325, 3.37139, 12.88844, -6.72098, + 3.40949, -14.34313, -9.68278, -7.85143, - 1.06886, -0.21727, 0.36675, -0.49815, - -0.07289, -0.07537, + 1.06886, -0.21727, 0.36675, -0.49815, + -0.07289, -0.07537, - 0.01107, -0.00644, 0.01013, -0.00306, + 0.01107, -0.00644, 0.01013, -0.00306, - -0.00708, -0.13488, -0.23041, -0.10698, + -0.00708, -0.13488, -0.23041, -0.10698, - -0.00049, -0.00692, -0.00142, -0.00211, + -0.00049, -0.00692, -0.00142, -0.00211, - -0.04021, 0.01805, + -0.04021, 0.01805, - 0.00479, 0.00620, + 0.00479, 0.00620, - 0.00739, 0.00566, + 0.00739, 0.00566, - -0.00101, -0.00022, 0.00261, -0.00188, + -0.00101, -0.00022, 0.00261, -0.00188, - -0.01812, -0.01205, + -0.01812, -0.01205, - -0.00061, -0.00061, + -0.00061, -0.00061, - -0.02479, 0.01157, + -0.02479, 0.01157, - 0.91642, -0.65781, 0.39969, -1.13699, - -0.43337, -0.57828, + 0.91642, -0.65781, 0.39969, -1.13699, + -0.43337, -0.57828, - 0.00145, 0.00281, + 0.00145, 0.00281, - -0.01675, -0.00975, + -0.01675, -0.00975, - 0.00119, -0.00074, + 0.00119, -0.00074, - -0.00343, 0.00139, + -0.00343, 0.00139, - 0.00061, 0.00086, + 0.00061, 0.00086, - 0.00054, -0.00046, + 0.00054, -0.00046, - -0.01996, -0.02689, + -0.01996, -0.02689, - 0.00034, 0.00037, + 0.00034, 0.00037, - -0.00006, 0.00001, + -0.00006, 0.00001, }; + static double FAR juptabr[] = { - -734.58857, -1081.04460, -551.65750, -148.79782, - -25.23171, 164.64781, 248.64813, + -734.58857, -1081.04460, -551.65750, -148.79782, + -25.23171, 164.64781, 248.64813, - -0.05163, -0.02413, + -0.05163, -0.02413, - -1306.61004, 560.02437, -1622.58047, 589.92513, - -812.39674, 166.85340, -157.92826, -107.14755, - 68.98900, -18.95875, -0.16183, 36.24345, - -9.19972, -2.29315, + -1306.61004, 560.02437, -1622.58047, 589.92513, + -812.39674, 166.85340, -157.92826, -107.14755, + 68.98900, -18.95875, -0.16183, 36.24345, + -9.19972, -2.29315, - -0.00316, 0.00222, + -0.00316, 0.00222, - 10.95234, 21.37177, -6.29550, 21.83656, - -7.70755, 1.38228, -0.21770, -1.49525, - 0.17951, 0.01043, + 10.95234, 21.37177, -6.29550, 21.83656, + -7.70755, 1.38228, -0.21770, -1.49525, + 0.17951, 0.01043, - 0.00062, 0.00208, -0.00066, 0.00050, + 0.00062, 0.00208, -0.00066, 0.00050, - 0.00313, 0.00187, + 0.00313, 0.00187, - 0.00010, 0.00131, + 0.00010, 0.00131, - 0.00102, 0.00047, + 0.00102, 0.00047, - 0.00102, 0.00012, + 0.00102, 0.00012, - 0.00012, -0.00037, + 0.00012, -0.00037, - 0.00808, 0.00027, + 0.00808, 0.00027, - -0.01219, -0.00961, -0.04166, -0.00327, + -0.01219, -0.00961, -0.04166, -0.00327, - -0.00001, -0.00146, + -0.00001, -0.00146, - -0.00092, -0.00989, + -0.00092, -0.00989, - -0.00135, 0.00196, + -0.00135, 0.00196, - 0.19216, 2.48442, -1.43599, 1.39651, - -0.48549, -0.53272, 0.14066, -0.10352, + 0.19216, 2.48442, -1.43599, 1.39651, + -0.48549, -0.53272, 0.14066, -0.10352, - 0.00141, 0.00066, + 0.00141, 0.00066, - 2.96838, -3.09575, 6.27741, 5.24306, - -8.77080, 9.03247, -10.98350, -3.58579, + 2.96838, -3.09575, 6.27741, 5.24306, + -8.77080, 9.03247, -10.98350, -3.58579, - -0.00168, -0.00100, + -0.00168, -0.00100, - 0.20234, -0.75737, 0.36838, -0.58241, - 0.41430, -0.35784, 0.47038, -0.10586, + 0.20234, -0.75737, 0.36838, -0.58241, + 0.41430, -0.35784, 0.47038, -0.10586, - 0.00539, 0.00490, + 0.00539, 0.00490, - -0.01375, -0.01950, 0.00145, 0.00723, - -0.00391, 0.00391, + -0.01375, -0.01950, 0.00145, 0.00723, + -0.00391, 0.00391, - -0.00131, -0.00568, + -0.00131, -0.00568, - 0.01317, 0.00319, + 0.01317, 0.00319, - 1.31006, 5.89394, -1.61753, 3.68814, - -0.80644, -0.14747, 0.04481, -0.11361, + 1.31006, 5.89394, -1.61753, 3.68814, + -0.80644, -0.14747, 0.04481, -0.11361, - -4.36130, 7.92488, -16.29047, -1.52163, - 2.14492, -14.38028, 9.65573, 3.56881, - -1.87208, 3.36213, + -4.36130, 7.92488, -16.29047, -1.52163, + 2.14492, -14.38028, 9.65573, 3.56881, + -1.87208, 3.36213, - 1.84499, -2.41575, -2.77076, -3.23915, - -3.34573, 1.40979, + 1.84499, -2.41575, -2.77076, -3.23915, + -3.34573, 1.40979, - 0.00217, -0.00841, + 0.00217, -0.00841, - 0.29313, -0.36246, 0.22043, 0.02328, - -0.01182, 0.04074, + 0.29313, -0.36246, 0.22043, 0.02328, + -0.01182, 0.04074, - -0.15728, 0.02468, -0.03185, -0.01099, + -0.15728, 0.02468, -0.03185, -0.01099, - 0.01059, -0.01274, + 0.01059, -0.01274, - 0.07362, -0.02642, 0.04035, -0.00968, + 0.07362, -0.02642, 0.04035, -0.00968, - -2.14457, 2.53297, -4.34196, -0.11421, - -0.38757, -1.73872, 0.39784, -0.01397, + -2.14457, 2.53297, -4.34196, -0.11421, + -0.38757, -1.73872, 0.39784, -0.01397, - -0.03311, 0.97723, 0.16060, -0.07486, - 25.96413, 0.75088, + -0.03311, 0.97723, 0.16060, -0.07486, + 25.96413, 0.75088, - -3.04736, 0.30340, -1.43451, -1.35136, - 0.26526, -0.40247, + -3.04736, 0.30340, -1.43451, -1.35136, + 0.26526, -0.40247, - -0.00460, -0.00056, + -0.00460, -0.00056, - 0.01633, -0.00128, + 0.01633, -0.00128, - -0.05197, 0.07002, -0.19450, 0.03737, + -0.05197, 0.07002, -0.19450, 0.03737, - 0.00188, -0.00037, + 0.00188, -0.00037, - -0.00903, -0.00059, + -0.00903, -0.00059, - -19.73809, 0.58424, -10.42034, -10.14579, - 2.65990, -3.07889, 0.50884, 0.58508, + -19.73809, 0.58424, -10.42034, -10.14579, + 2.65990, -3.07889, 0.50884, 0.58508, - -0.00970, 0.02099, + -0.00970, 0.02099, - 0.00716, 0.01161, + 0.00716, 0.01161, - 0.05751, -0.04515, + 0.05751, -0.04515, - 22.08042, 30.82415, -36.27430, 31.40265, - -18.30150, -29.16403, + 22.08042, 30.82415, -36.27430, 31.40265, + -18.30150, -29.16403, - 0.02454, 0.01834, + 0.02454, 0.01834, - -0.01312, 0.01576, + -0.01312, 0.01576, - -0.00928, 0.00330, + -0.00928, 0.00330, - -11.78094, 4.06738, -2.51590, 15.05277, - 9.12747, 2.88088, 2.32916, -2.08271, + -11.78094, 4.06738, -2.51590, 15.05277, + 9.12747, 2.88088, 2.32916, -2.08271, - 0.02872, 0.02194, + 0.02872, 0.02194, - 0.60494, -0.04597, 0.24749, 0.15971, - -0.02185, 0.03384, + 0.60494, -0.04597, 0.24749, 0.15971, + -0.02185, 0.03384, - -0.07075, 0.01287, + -0.07075, 0.01287, - 0.40201, 0.00347, + 0.40201, 0.00347, - -0.00410, -0.00998, + -0.00410, -0.00998, - -0.00005, -0.00121, + -0.00005, -0.00121, - 0.13770, 0.00186, + 0.13770, 0.00186, - -0.02268, 0.00210, + -0.02268, 0.00210, - 1.26291, 0.65546, 0.38885, 0.38880, - -0.00184, 0.03067, + 1.26291, 0.65546, 0.38885, 0.38880, + -0.00184, 0.03067, - 0.01273, 0.01136, 0.00557, 0.01117, + 0.01273, 0.01136, 0.00557, 0.01117, - 94.13171, -88.37882, 120.53292, 8.32903, - 7.77313, 43.46523, -11.66698, 0.44639, - 0.15092, -1.68367, + 94.13171, -88.37882, 120.53292, 8.32903, + 7.77313, 43.46523, -11.66698, 0.44639, + 0.15092, -1.68367, - -0.30833, -0.49030, 0.01971, -0.14144, + -0.30833, -0.49030, 0.01971, -0.14144, - -0.04019, -0.05110, + -0.04019, -0.05110, - -39.70024, 272.91667, -468.46263, 256.77696, - -200.63130, -307.98554, 206.56301, -41.76039, - -4.74242, 74.19909, + -39.70024, 272.91667, -468.46263, 256.77696, + -200.63130, -307.98554, 206.56301, -41.76039, + -4.74242, 74.19909, - 0.18474, 0.05547, + 0.18474, 0.05547, - -0.06732, 0.16515, + -0.06732, 0.16515, - -1156.31285, -1102.97666, -1346.99288, -1121.01090, - 666.84550, 421.92305, 2259.49740, -2268.69758, - -2325.87639, -4476.46256, -9683.77583, -2472.92565, + -1156.31285, -1102.97666, -1346.99288, -1121.01090, + 666.84550, 421.92305, 2259.49740, -2268.69758, + -2325.87639, -4476.46256, -9683.77583, -2472.92565, - -0.10400, 0.08075, + -0.10400, 0.08075, - -0.45225, 0.16621, + -0.45225, 0.16621, - 0.57789, 2.43804, + 0.57789, 2.43804, - 85.21675, -154.17208, 219.91042, -9.71116, - 31.13240, 108.60117, -25.85622, 8.98402, + 85.21675, -154.17208, 219.91042, -9.71116, + 31.13240, 108.60117, -25.85622, 8.98402, - -0.00233, 0.01030, + -0.00233, 0.01030, - -17.01324, 10.41588, -13.34449, 1.08782, - -1.48199, -1.81734, 0.20334, -0.11734, + -17.01324, 10.41588, -13.34449, 1.08782, + -1.48199, -1.81734, 0.20334, -0.11734, - -0.00230, -0.01869, + -0.00230, -0.01869, - -0.01182, -0.00129, + -0.01182, -0.00129, - -0.00281, 0.02021, + -0.00281, 0.02021, - -5.75973, 19.13309, -16.13690, 5.53382, - -1.96585, -6.29211, 1.63105, -0.26089, + -5.75973, 19.13309, -16.13690, 5.53382, + -1.96585, -6.29211, 1.63105, -0.26089, - 0.02935, -0.00555, + 0.02935, -0.00555, - 0.30700, -19.96182, 0.99825, -16.32664, - 0.83052, -13.76201, -3.15609, 0.17360, - -111.81423, -2.05419, + 0.30700, -19.96182, 0.99825, -16.32664, + 0.83052, -13.76201, -3.15609, 0.17360, + -111.81423, -2.05419, - -0.02455, -0.00478, + -0.02455, -0.00478, - 7.45114, 21.53296, 19.90263, 5.69420, - 2.31253, -8.15116, -2.17440, -0.23014, + 7.45114, 21.53296, 19.90263, 5.69420, + 2.31253, -8.15116, -2.17440, -0.23014, - 0.00168, 0.01590, + 0.00168, 0.01590, - 8.78005, 0.71418, 4.48561, 4.50680, - -1.05713, 1.17880, -0.19327, -0.24877, + 8.78005, 0.71418, 4.48561, 4.50680, + -1.05713, 1.17880, -0.19327, -0.24877, - -5.00870, -8.66354, 10.51902, -7.71011, - 4.65486, 8.05673, + -5.00870, -8.66354, 10.51902, -7.71011, + 4.65486, 8.05673, - -1.39635, -3.07669, -2.40347, -0.11167, - -0.04064, 0.83512, + -1.39635, -3.07669, -2.40347, -0.11167, + -0.04064, 0.83512, - -0.02041, -0.00351, + -0.02041, -0.00351, - 0.97375, -0.15795, 0.36361, 0.19913, - -0.02142, 0.04193, + 0.97375, -0.15795, 0.36361, 0.19913, + -0.02142, 0.04193, - 0.08801, 0.00475, + 0.08801, 0.00475, - -2.81010, 3.11341, -2.79191, -0.93313, - 0.44570, -0.88287, + -2.81010, 3.11341, -2.79191, -0.93313, + 0.44570, -0.88287, - -0.51815, 0.54776, 0.29736, 0.99779, - 2.28957, 0.82183, + -0.51815, 0.54776, 0.29736, 0.99779, + 2.28957, 0.82183, - 0.03386, 0.12855, 0.03124, 0.02454, + 0.03386, 0.12855, 0.03124, 0.02454, - -0.31958, 0.00070, + -0.31958, 0.00070, - -1.48184, -1.28195, 0.03965, -1.12026, - 0.23910, 0.01293, + -1.48184, -1.28195, 0.03965, -1.12026, + 0.23910, 0.01293, - 0.36146, -0.64483, -1.88470, 0.21469, - -11.79819, -1.87287, + 0.36146, -0.64483, -1.88470, 0.21469, + -11.79819, -1.87287, - 2.65699, -0.36287, 0.88148, -1.26883, - -0.19657, -0.14279, + 2.65699, -0.36287, 0.88148, -1.26883, + -0.19657, -0.14279, - -0.07536, -0.00004, + -0.07536, -0.00004, - 0.01496, 0.00537, + 0.01496, 0.00537, - 2.48352, 3.75581, -0.34909, 3.26696, - -0.82105, 0.11287, -0.00755, -0.13764, + 2.48352, 3.75581, -0.34909, 3.26696, + -0.82105, 0.11287, -0.00755, -0.13764, - -15.34429, -2.79957, -3.22976, -15.46084, - 10.66793, -0.26054, -0.12188, 5.06211, + -15.34429, -2.79957, -3.22976, -15.46084, + 10.66793, -0.26054, -0.12188, 5.06211, - 0.01313, 0.00424, + 0.01313, 0.00424, - 84.34332, -57.05646, 92.68150, -0.02024, - 149.62698, 59.14407, 174.04569, -129.26785, - -55.99789, -238.01484, -212.51618, -115.94914, + 84.34332, -57.05646, 92.68150, -0.02024, + 149.62698, 59.14407, 174.04569, -129.26785, + -55.99789, -238.01484, -212.51618, -115.94914, - -0.01720, -0.00158, + -0.01720, -0.00158, - -13.65602, 17.47396, 0.16714, 32.66367, - 16.30095, 9.18345, 3.98555, -5.39985, - -1.09958, -0.86072, + -13.65602, 17.47396, 0.16714, 32.66367, + 16.30095, 9.18345, 3.98555, -5.39985, + -1.09958, -0.86072, - 0.02752, -0.02474, 0.00671, -0.00278, + 0.02752, -0.02474, 0.00671, -0.00278, - -0.21030, -0.73658, 0.20708, -0.21378, + -0.21030, -0.73658, 0.20708, -0.21378, - 0.78462, -2.14051, -1.60070, -2.60915, - -5.02441, -1.19246, + 0.78462, -2.14051, -1.60070, -2.60915, + -5.02441, -1.19246, - 0.67622, -0.41889, 0.07430, -0.53204, - -0.11214, -0.03417, + 0.67622, -0.41889, 0.07430, -0.53204, + -0.11214, -0.03417, - -0.72636, -0.15535, -0.16815, -0.35603, - 0.07530, -0.02521, + -0.72636, -0.15535, -0.16815, -0.35603, + 0.07530, -0.02521, - -0.01261, -0.94883, 0.39930, -0.05370, - -2.77309, 0.38431, + -0.01261, -0.94883, 0.39930, -0.05370, + -2.77309, 0.38431, - 0.72127, -0.52030, -0.01804, -0.51188, - -0.11993, 0.02189, + 0.72127, -0.52030, -0.01804, -0.51188, + -0.11993, 0.02189, - 0.00928, -0.02129, + 0.00928, -0.02129, - -0.02760, 0.00441, + -0.02760, 0.00441, - -0.56832, -0.48114, 0.64192, -0.65656, - 0.37483, 0.51883, + -0.56832, -0.48114, 0.64192, -0.65656, + 0.37483, 0.51883, - -0.08474, 0.20324, 0.12783, 0.13041, + -0.08474, 0.20324, 0.12783, 0.13041, - -0.01545, -0.00282, + -0.01545, -0.00282, - -0.16196, -0.26980, 0.06584, -0.09987, + -0.16196, -0.26980, 0.06584, -0.09987, - -0.36305, -0.27610, -0.57074, -0.13607, + -0.36305, -0.27610, -0.57074, -0.13607, - -0.00824, 0.00369, + -0.00824, 0.00369, - 0.06094, -0.12214, 0.03581, -0.00876, + 0.06094, -0.12214, 0.03581, -0.00876, - 0.49346, -0.74596, 0.47814, 0.18201, - -1.00640, 0.24465, + 0.49346, -0.74596, 0.47814, 0.18201, + -1.00640, 0.24465, - 10.09808, 2.30496, 13.63359, -7.94007, - 0.29792, -13.55724, -6.48556, -5.99581, + 10.09808, 2.30496, 13.63359, -7.94007, + 0.29792, -13.55724, -6.48556, -5.99581, - 0.69686, -0.22434, 0.23198, -0.35579, - -0.04736, -0.05683, + 0.69686, -0.22434, 0.23198, -0.35579, + -0.04736, -0.05683, - 0.36710, -0.16571, 0.14876, 0.21824, + 0.36710, -0.16571, 0.14876, 0.21824, - -0.18940, -0.15063, -0.23692, -0.09990, + -0.18940, -0.15063, -0.23692, -0.09990, - -0.08923, -0.12222, 0.02998, -0.04560, + -0.08923, -0.12222, 0.02998, -0.04560, - -0.16229, 0.04552, + -0.16229, 0.04552, - -0.33051, 0.02585, + -0.33051, 0.02585, - -0.00622, 0.01583, + -0.00622, 0.01583, - 0.15436, -0.07109, 0.06429, 0.09218, + 0.15436, -0.07109, 0.06429, 0.09218, - -0.01277, -0.00019, + -0.01277, -0.00019, - 0.02345, -0.01057, + 0.02345, -0.01057, - -0.07294, 0.02506, + -0.07294, 0.02506, - 0.62063, -0.52533, 0.16814, -0.77168, - -0.20614, -0.31828, + 0.62063, -0.52533, 0.16814, -0.77168, + -0.20614, -0.31828, - -0.12856, 0.01316, + -0.12856, 0.01316, - -0.01522, -0.00126, + -0.01522, -0.00126, - 0.01558, 0.04765, + 0.01558, 0.04765, - -0.02776, 0.01166, + -0.02776, 0.01166, - -0.05185, 0.00674, + -0.05185, 0.00674, - 0.00754, 0.02183, + 0.00754, 0.02183, - -0.00645, -0.01050, + -0.00645, -0.01050, - -0.02155, 0.00375, + -0.02155, 0.00375, - 0.12040, -0.00004, + 0.12040, -0.00004, }; static signed char FAR jupargs[] = { - 0, 6, - 3, 2, 5, -6, 6, 3, 7, 0, - 2, 2, 5, -5, 6, 6, - 3, 1, 5, -2, 6, -3, 8, 0, - 2, 4, 5,-10, 6, 4, - 3, 2, 5, -4, 6, -3, 7, 1, - 3, 3, 5,-10, 6, 7, 7, 0, - 2, 6, 5,-15, 6, 0, - 3, 1, 5, -4, 6, 4, 7, 0, - 3, 3, 5, -8, 6, 2, 7, 0, - 3, 1, 5, -3, 6, 1, 7, 0, - 3, 1, 5, -3, 6, 2, 7, 0, - 1, 1, 7, 1, - 2, 5, 5,-12, 6, 0, - 3, 2, 5, -7, 6, 7, 7, 0, - 3, 1, 5, -1, 6, -3, 7, 0, - 2, 3, 5, -7, 6, 3, - 3, 1, 5, -4, 6, 3, 7, 0, - 2, 1, 5, -2, 6, 3, - 3, 3, 5, -8, 6, 3, 7, 0, - 2, 1, 5, -3, 6, 3, - 3, 1, 5, -3, 6, 3, 7, 0, - 2, 3, 5, -8, 6, 2, - 3, 2, 5, -5, 6, 2, 7, 0, - 1, 2, 7, 0, - 2, 4, 5, -9, 6, 3, - 2, 2, 5, -4, 6, 4, - 1, 1, 6, 2, - 3, 2, 5, -5, 6, 3, 7, 0, - 2, 2, 5, -6, 6, 2, - 2, 5, 5,-11, 6, 1, - 3, 1, 5, -2, 7, -2, 8, 0, - 2, 1, 5, -3, 7, 1, - 2, 3, 5, -6, 6, 3, - 2, 1, 5, -1, 6, 2, - 2, 1, 5, -4, 6, 2, - 2, 3, 5, -9, 6, 0, - 3, 2, 5, -4, 6, 2, 7, 0, - 2, 1, 5, -2, 7, 1, - 2, 6, 5,-13, 6, 0, - 3, 2, 5, -2, 6, -3, 7, 0, - 2, 4, 5, -8, 6, 3, - 2, 3, 6, -3, 7, 0, - 3, 6, 5,-14, 6, 3, 7, 0, - 3, 1, 5, -2, 7, 1, 8, 0, - 2, 2, 5, -3, 6, 2, - 3, 1, 5, -4, 7, 5, 8, 0, - 3, 2, 5, -8, 6, 3, 7, 0, - 3, 4, 5, -9, 6, 3, 7, 0, - 1, 2, 6, 3, - 3, 2, 5, -4, 6, 3, 7, 0, - 2, 2, 5, -7, 6, 2, - 2, 1, 5, -2, 8, 0, - 2, 1, 5, -1, 7, 0, - 3, 3, 5, -6, 6, 2, 7, 0, - 3, 4, 5, -8, 6, 2, 8, 0, - 2, 1, 5, -1, 8, 0, - 3, 2, 5, -3, 6, 1, 7, 0, - 2, 7, 5,-15, 6, 2, - 3, 3, 5, -4, 6, -3, 7, 1, - 2, 5, 5,-10, 6, 4, - 3, 1, 5, 1, 6, -3, 7, 1, - 3, 7, 5,-16, 6, 3, 7, 0, - 2, 3, 5, -5, 6, 4, - 3, 1, 5, -6, 6, 3, 7, 0, - 3, 5, 5,-11, 6, 3, 7, 0, - 1, 1, 5, 5, - 3, 3, 5,-11, 6, 3, 7, 0, - 3, 3, 5, -6, 6, 3, 7, 0, - 2, 2, 5, -7, 7, 0, - 2, 1, 5, -5, 6, 3, - 3, 1, 5, -1, 6, 3, 7, 0, - 2, 3, 5,-10, 6, 3, - 3, 2, 5, -3, 6, 2, 7, 0, - 2, 1, 5, 1, 7, 0, - 3, 2, 5, -1, 6, -3, 7, 0, - 2, 4, 5, -7, 6, 3, - 2, 4, 6, -3, 7, 0, - 2, 2, 5, -2, 6, 4, - 3, 4, 5, -8, 6, 3, 7, 0, - 1, 3, 6, 3, - 3, 2, 5, -3, 6, 3, 7, 0, - 2, 5, 5, -9, 6, 3, - 2, 3, 5, -4, 6, 2, - 2, 1, 5, 1, 6, 2, - 2, 2, 5, -4, 7, 0, - 2, 6, 5,-11, 6, 2, - 2, 2, 5, -3, 7, 0, - 2, 4, 5, -6, 6, 2, - 2, 2, 5, -1, 6, 2, - 1, 4, 6, 1, - 2, 2, 5, -2, 7, 0, - 2, 5, 5, -8, 6, 2, - 2, 3, 5, -3, 6, 2, - 2, 1, 5, 2, 6, 2, - 2, 2, 5, -2, 8, 0, - 2, 2, 5, -1, 7, 0, - 2, 6, 5,-10, 6, 3, - 2, 4, 5, -5, 6, 3, - 2, 6, 6, -3, 7, 0, - 1, 2, 5, 5, - 3, 4, 5, -6, 6, 3, 7, 0, - 1, 5, 6, 4, - 2, 2, 5,-10, 6, 1, - 2, 5, 5, -7, 6, 1, - 2, 3, 5, -2, 6, 2, - 2, 1, 5, 3, 6, 2, - 2, 6, 5, -9, 6, 2, - 2, 4, 5, -4, 6, 2, - 2, 2, 5, 1, 6, 2, - 2, 7, 5,-11, 6, 0, - 2, 3, 5, -3, 7, 0, - 2, 5, 5, -6, 6, 2, - 2, 3, 5, -1, 6, 1, - 2, 3, 5, -2, 7, 0, - 2, 6, 5, -8, 6, 1, - 2, 4, 5, -3, 6, 1, - 2, 2, 5, 2, 6, 0, - 2, 7, 5,-10, 6, 1, - 2, 5, 5, -5, 6, 2, - 1, 3, 5, 3, - 2, 1, 5, 5, 6, 2, - 2, 6, 5, -7, 6, 1, - 2, 4, 5, -2, 6, 1, - 2, 7, 5, -9, 6, 1, - 2, 5, 5, -4, 6, 0, - 2, 6, 5, -6, 6, 0, - 2, 4, 5, -1, 6, 0, - 2, 7, 5, -8, 6, 1, - 2, 5, 5, -3, 6, 0, - 2, 8, 5,-10, 6, 0, - 2, 6, 5, -5, 6, 0, - 1, 4, 5, 2, - 2, 7, 5, -7, 6, 0, - 2, 5, 5, -2, 6, 0, - 2, 8, 5, -9, 6, 0, - 2, 7, 5, -6, 6, 0, - 2, 8, 5, -8, 6, 0, - 2, 9, 5,-10, 6, 0, - 1, 5, 5, 0, - 2, 9, 5, -9, 6, 0, - 2, 1, 3, -1, 5, 0, - -1 + 0, 6, + 3, 2, 5, -6, 6, 3, 7, 0, + 2, 2, 5, -5, 6, 6, + 3, 1, 5, -2, 6, -3, 8, 0, + 2, 4, 5, -10, 6, 4, + 3, 2, 5, -4, 6, -3, 7, 1, + 3, 3, 5, -10, 6, 7, 7, 0, + 2, 6, 5, -15, 6, 0, + 3, 1, 5, -4, 6, 4, 7, 0, + 3, 3, 5, -8, 6, 2, 7, 0, + 3, 1, 5, -3, 6, 1, 7, 0, + 3, 1, 5, -3, 6, 2, 7, 0, + 1, 1, 7, 1, + 2, 5, 5, -12, 6, 0, + 3, 2, 5, -7, 6, 7, 7, 0, + 3, 1, 5, -1, 6, -3, 7, 0, + 2, 3, 5, -7, 6, 3, + 3, 1, 5, -4, 6, 3, 7, 0, + 2, 1, 5, -2, 6, 3, + 3, 3, 5, -8, 6, 3, 7, 0, + 2, 1, 5, -3, 6, 3, + 3, 1, 5, -3, 6, 3, 7, 0, + 2, 3, 5, -8, 6, 2, + 3, 2, 5, -5, 6, 2, 7, 0, + 1, 2, 7, 0, + 2, 4, 5, -9, 6, 3, + 2, 2, 5, -4, 6, 4, + 1, 1, 6, 2, + 3, 2, 5, -5, 6, 3, 7, 0, + 2, 2, 5, -6, 6, 2, + 2, 5, 5, -11, 6, 1, + 3, 1, 5, -2, 7, -2, 8, 0, + 2, 1, 5, -3, 7, 1, + 2, 3, 5, -6, 6, 3, + 2, 1, 5, -1, 6, 2, + 2, 1, 5, -4, 6, 2, + 2, 3, 5, -9, 6, 0, + 3, 2, 5, -4, 6, 2, 7, 0, + 2, 1, 5, -2, 7, 1, + 2, 6, 5, -13, 6, 0, + 3, 2, 5, -2, 6, -3, 7, 0, + 2, 4, 5, -8, 6, 3, + 2, 3, 6, -3, 7, 0, + 3, 6, 5, -14, 6, 3, 7, 0, + 3, 1, 5, -2, 7, 1, 8, 0, + 2, 2, 5, -3, 6, 2, + 3, 1, 5, -4, 7, 5, 8, 0, + 3, 2, 5, -8, 6, 3, 7, 0, + 3, 4, 5, -9, 6, 3, 7, 0, + 1, 2, 6, 3, + 3, 2, 5, -4, 6, 3, 7, 0, + 2, 2, 5, -7, 6, 2, + 2, 1, 5, -2, 8, 0, + 2, 1, 5, -1, 7, 0, + 3, 3, 5, -6, 6, 2, 7, 0, + 3, 4, 5, -8, 6, 2, 8, 0, + 2, 1, 5, -1, 8, 0, + 3, 2, 5, -3, 6, 1, 7, 0, + 2, 7, 5, -15, 6, 2, + 3, 3, 5, -4, 6, -3, 7, 1, + 2, 5, 5, -10, 6, 4, + 3, 1, 5, 1, 6, -3, 7, 1, + 3, 7, 5, -16, 6, 3, 7, 0, + 2, 3, 5, -5, 6, 4, + 3, 1, 5, -6, 6, 3, 7, 0, + 3, 5, 5, -11, 6, 3, 7, 0, + 1, 1, 5, 5, + 3, 3, 5, -11, 6, 3, 7, 0, + 3, 3, 5, -6, 6, 3, 7, 0, + 2, 2, 5, -7, 7, 0, + 2, 1, 5, -5, 6, 3, + 3, 1, 5, -1, 6, 3, 7, 0, + 2, 3, 5, -10, 6, 3, + 3, 2, 5, -3, 6, 2, 7, 0, + 2, 1, 5, 1, 7, 0, + 3, 2, 5, -1, 6, -3, 7, 0, + 2, 4, 5, -7, 6, 3, + 2, 4, 6, -3, 7, 0, + 2, 2, 5, -2, 6, 4, + 3, 4, 5, -8, 6, 3, 7, 0, + 1, 3, 6, 3, + 3, 2, 5, -3, 6, 3, 7, 0, + 2, 5, 5, -9, 6, 3, + 2, 3, 5, -4, 6, 2, + 2, 1, 5, 1, 6, 2, + 2, 2, 5, -4, 7, 0, + 2, 6, 5, -11, 6, 2, + 2, 2, 5, -3, 7, 0, + 2, 4, 5, -6, 6, 2, + 2, 2, 5, -1, 6, 2, + 1, 4, 6, 1, + 2, 2, 5, -2, 7, 0, + 2, 5, 5, -8, 6, 2, + 2, 3, 5, -3, 6, 2, + 2, 1, 5, 2, 6, 2, + 2, 2, 5, -2, 8, 0, + 2, 2, 5, -1, 7, 0, + 2, 6, 5, -10, 6, 3, + 2, 4, 5, -5, 6, 3, + 2, 6, 6, -3, 7, 0, + 1, 2, 5, 5, + 3, 4, 5, -6, 6, 3, 7, 0, + 1, 5, 6, 4, + 2, 2, 5, -10, 6, 1, + 2, 5, 5, -7, 6, 1, + 2, 3, 5, -2, 6, 2, + 2, 1, 5, 3, 6, 2, + 2, 6, 5, -9, 6, 2, + 2, 4, 5, -4, 6, 2, + 2, 2, 5, 1, 6, 2, + 2, 7, 5, -11, 6, 0, + 2, 3, 5, -3, 7, 0, + 2, 5, 5, -6, 6, 2, + 2, 3, 5, -1, 6, 1, + 2, 3, 5, -2, 7, 0, + 2, 6, 5, -8, 6, 1, + 2, 4, 5, -3, 6, 1, + 2, 2, 5, 2, 6, 0, + 2, 7, 5, -10, 6, 1, + 2, 5, 5, -5, 6, 2, + 1, 3, 5, 3, + 2, 1, 5, 5, 6, 2, + 2, 6, 5, -7, 6, 1, + 2, 4, 5, -2, 6, 1, + 2, 7, 5, -9, 6, 1, + 2, 5, 5, -4, 6, 0, + 2, 6, 5, -6, 6, 0, + 2, 4, 5, -1, 6, 0, + 2, 7, 5, -8, 6, 1, + 2, 5, 5, -3, 6, 0, + 2, 8, 5, -10, 6, 0, + 2, 6, 5, -5, 6, 0, + 1, 4, 5, 2, + 2, 7, 5, -7, 6, 0, + 2, 5, 5, -2, 6, 0, + 2, 8, 5, -9, 6, 0, + 2, 7, 5, -6, 6, 0, + 2, 8, 5, -8, 6, 0, + 2, 9, 5, -10, 6, 0, + 1, 5, 5, 0, + 2, 9, 5, -9, 6, 0, + 2, 1, 3, -1, 5, 0, + -1 }; + /* Total terms = 142, small = 140 */ static struct plantbl FAR jup404 = { - { 0, 0, 1, 0, 9, 16, 7, 5, 0,}, - 6, - jupargs, - juptabl, - juptabb, - juptabr, - 5.2026032092000003e+00, + {0, 0, 1, 0, 9, 16, 7, 5, 0,}, + 6, + jupargs, + juptabl, + juptabb, + juptabr, + 5.2026032092000003e+00, }; /* @@ -5743,1700 +5760,1703 @@ Days per record = 131.0 3000.0 to 3000.4: 0.047 0.073 0.086 */ static double FAR sattabl[] = { - 1788381.26240, 2460423.68044, 1370113.15868, 415406.99187, - 72040.39885, 12669.58806, 439960754.85333, 180256.80433, + 1788381.26240, 2460423.68044, 1370113.15868, 415406.99187, + 72040.39885, 12669.58806, 439960754.85333, 180256.80433, - 18.71177, -40.37092, + 18.71177, -40.37092, - 66531.01889, -195702.70142, 57188.02694, -179110.60982, - -19803.06520, -58084.15705, -9055.13344, -31146.10779, - 11245.43286, -3247.59575, 459.48670, 2912.82402, + 66531.01889, -195702.70142, 57188.02694, -179110.60982, + -19803.06520, -58084.15705, -9055.13344, -31146.10779, + 11245.43286, -3247.59575, 459.48670, 2912.82402, - -4.06749, -13.53763, + -4.06749, -13.53763, - -30.55598, -4.51172, + -30.55598, -4.51172, - 1.48832, 0.37139, + 1.48832, 0.37139, - 597.35433, 1193.44545, -297.50957, 976.38608, - -263.26842, 34.84354, -6.77785, -29.92106, + 597.35433, 1193.44545, -297.50957, 976.38608, + -263.26842, 34.84354, -6.77785, -29.92106, - -0.16325, -0.18346, + -0.16325, -0.18346, - -0.15364, -0.08227, + -0.15364, -0.08227, - 0.20180, 0.02244, + 0.20180, 0.02244, - 0.04672, -0.29867, + 0.04672, -0.29867, - -0.04143, -0.00760, + -0.04143, -0.00760, - -0.17046, -0.00778, + -0.17046, -0.00778, - 0.04200, 0.23937, -0.00098, -0.05236, + 0.04200, 0.23937, -0.00098, -0.05236, - -0.02749, -0.01813, + -0.02749, -0.01813, - 0.00637, 0.01256, + 0.00637, 0.01256, - -0.04506, 0.04448, + -0.04506, 0.04448, - -0.00105, 0.06224, + -0.00105, 0.06224, - 0.01157, 0.17057, -0.03214, 0.18178, + 0.01157, 0.17057, -0.03214, 0.18178, - -0.22059, -0.01472, + -0.22059, -0.01472, - -0.24213, 0.04309, 0.03436, 0.44873, + -0.24213, 0.04309, 0.03436, 0.44873, - 0.01350, -0.01931, + 0.01350, -0.01931, - -0.80618, -0.56864, 0.29223, -0.03101, + -0.80618, -0.56864, 0.29223, -0.03101, - 0.04171, 0.02264, + 0.04171, 0.02264, - -0.01264, -0.01645, + -0.01264, -0.01645, - 0.01774, 0.06374, + 0.01774, 0.06374, - -0.01925, -0.03552, + -0.01925, -0.03552, - 0.10473, -0.04119, + 0.10473, -0.04119, - 0.08045, 0.04635, + 0.08045, 0.04635, - -3.01112, -9.26158, 8.13745, 1.88838, + -3.01112, -9.26158, 8.13745, 1.88838, - -0.15184, 0.16898, + -0.15184, 0.16898, - -0.22091, 0.29070, -0.03259, 0.06938, + -0.22091, 0.29070, -0.03259, 0.06938, - -0.08499, -0.21688, 0.01848, -0.05594, + -0.08499, -0.21688, 0.01848, -0.05594, - 0.50100, -0.00027, 0.13300, 0.12055, + 0.50100, -0.00027, 0.13300, 0.12055, - 0.03039, 0.03854, + 0.03039, 0.03854, - -1.55287, 2.55618, -0.45497, -0.29895, - -0.93268, 0.83518, + -1.55287, 2.55618, -0.45497, -0.29895, + -0.93268, 0.83518, - -0.32785, 7.03878, -1.66649, 2.75564, - -0.29459, 0.01050, + -0.32785, 7.03878, -1.66649, 2.75564, + -0.29459, 0.01050, - 0.08293, -0.03161, + 0.08293, -0.03161, - -0.12750, -0.04359, + -0.12750, -0.04359, - 0.04217, 0.07480, + 0.04217, 0.07480, - -114.43467, 49.47867, -66.52340, -26.27841, - 15.48190, -13.06589, 3.28365, 5.02286, + -114.43467, 49.47867, -66.52340, -26.27841, + 15.48190, -13.06589, 3.28365, 5.02286, - -0.17155, -0.07404, + -0.17155, -0.07404, - 0.00924, -0.07407, + 0.00924, -0.07407, - -0.02922, 0.06184, + -0.02922, 0.06184, - 108.04882, 86.09791, -155.12793, 208.10044, - -311.72810, -268.92703, 74.57561, -420.03057, + 108.04882, 86.09791, -155.12793, 208.10044, + -311.72810, -268.92703, 74.57561, -420.03057, - -0.07893, 0.09246, + -0.07893, 0.09246, - -0.66033, -0.39026, -0.13816, -0.08490, + -0.66033, -0.39026, -0.13816, -0.08490, - -36.79241, -78.88254, 71.88167, -68.05297, - 51.71616, 65.77970, -43.59328, 23.51076, + -36.79241, -78.88254, 71.88167, -68.05297, + 51.71616, 65.77970, -43.59328, 23.51076, - -0.02029, -0.32943, + -0.02029, -0.32943, - -8.82754, 1.48646, -3.12794, 2.12866, - -0.06926, 0.44979, + -8.82754, 1.48646, -3.12794, 2.12866, + -0.06926, 0.44979, - 0.00621, -0.51720, + 0.00621, -0.51720, - -3.82964, -1.48596, -0.11277, -3.21677, - 0.81705, -0.19487, + -3.82964, -1.48596, -0.11277, -3.21677, + 0.81705, -0.19487, - -0.06195, 0.10005, -0.02208, 0.00108, + -0.06195, 0.10005, -0.02208, 0.00108, - 0.00455, -0.03825, + 0.00455, -0.03825, - 0.01217, -0.00599, + 0.01217, -0.00599, - -0.17479, -0.47290, 0.85469, 1.12548, - -0.80648, -0.44134, + -0.17479, -0.47290, 0.85469, 1.12548, + -0.80648, -0.44134, - -0.01559, -0.07061, + -0.01559, -0.07061, - 0.01268, -0.01773, + 0.01268, -0.01773, - 0.01308, -0.03461, + 0.01308, -0.03461, - -0.71114, 1.97680, -0.78306, -0.23052, - 0.94475, -0.10743, + -0.71114, 1.97680, -0.78306, -0.23052, + 0.94475, -0.10743, - 0.18252, -8.03174, + 0.18252, -8.03174, - 0.00734, 0.04779, + 0.00734, 0.04779, - 0.12334, -0.03513, + 0.12334, -0.03513, - 0.01341, 0.02461, + 0.01341, 0.02461, - 0.02047, -0.03454, + 0.02047, -0.03454, - 0.02169, -0.01921, + 0.02169, -0.01921, - -1.12789, 0.09304, 0.14585, 0.36365, + -1.12789, 0.09304, 0.14585, 0.36365, - 0.03702, 0.10661, -0.00464, -1.72706, + 0.03702, 0.10661, -0.00464, -1.72706, - -0.00769, -0.04635, + -0.00769, -0.04635, - -0.01157, 0.00099, + -0.01157, 0.00099, - 10.92646, 1.96174, 2.91142, 4.74585, - -0.29832, 0.75543, + 10.92646, 1.96174, 2.91142, 4.74585, + -0.29832, 0.75543, - 0.05411, 1.05850, + 0.05411, 1.05850, - 0.38846, -0.16265, + 0.38846, -0.16265, - 1.52209, 0.12185, 0.18650, 0.35535, + 1.52209, 0.12185, 0.18650, 0.35535, - -278.33587, -82.58648, -160.00093, -225.55776, - 35.17458, -77.56672, 10.61975, 3.33907, + -278.33587, -82.58648, -160.00093, -225.55776, + 35.17458, -77.56672, 10.61975, 3.33907, - 0.06090, 2.17429, + 0.06090, 2.17429, - -4.32981, -5.84246, 11.43116, 20.61395, + -4.32981, -5.84246, 11.43116, 20.61395, - -0.65772, 1.28796, + -0.65772, 1.28796, - 1224.46687, -3113.15508, 3798.33409, -137.28735, - -256.89302, 2227.35649, -779.78215, -260.37372, + 1224.46687, -3113.15508, 3798.33409, -137.28735, + -256.89302, 2227.35649, -779.78215, -260.37372, - 11.73617, -13.25050, -0.75248, -2.87527, + 11.73617, -13.25050, -0.75248, -2.87527, - -8.38102, 17.21321, + -8.38102, 17.21321, - -61784.69616, 39475.02257, -54086.68308, 54550.85490, - -16403.69351, 29602.70098, 14672.06363, 16234.17489, - 15702.37109, -22086.30300, -22889.89844, -1245.88352, + -61784.69616, 39475.02257, -54086.68308, 54550.85490, + -16403.69351, 29602.70098, 14672.06363, 16234.17489, + 15702.37109, -22086.30300, -22889.89844, -1245.88352, - 1.48864, 19.75000, 0.78646, 3.29343, + 1.48864, 19.75000, 0.78646, 3.29343, - -1058.13125, 4095.02368, -2793.78506, 1381.93282, - -409.19381, -772.54270, 161.67509, -34.15910, + -1058.13125, 4095.02368, -2793.78506, 1381.93282, + -409.19381, -772.54270, 161.67509, -34.15910, - -514.27437, 27.34222, -311.04046, 48.01030, - -43.36486, 16.19535, -0.73816, -0.81422, + -514.27437, 27.34222, -311.04046, 48.01030, + -43.36486, 16.19535, -0.73816, -0.81422, - 287.32231, -110.44135, 200.43610, 37.98170, - 17.73719, 34.40023, -2.46337, 1.48125, + 287.32231, -110.44135, 200.43610, 37.98170, + 17.73719, 34.40023, -2.46337, 1.48125, - 0.09042, -0.11788, + 0.09042, -0.11788, - 0.37284, 0.51725, 0.00597, 0.14590, + 0.37284, 0.51725, 0.00597, 0.14590, - -0.01536, 0.00980, + -0.01536, 0.00980, - 0.00721, 0.02023, + 0.00721, 0.02023, - 0.00027, 0.02451, + 0.00027, 0.02451, - -0.72448, -0.71371, 0.29322, 0.18359, + -0.72448, -0.71371, 0.29322, 0.18359, - 0.72719, -0.37154, 0.14854, -0.02530, + 0.72719, -0.37154, 0.14854, -0.02530, - 0.23052, 0.04258, + 0.23052, 0.04258, - 4.82082, 0.01885, 3.11279, -0.63338, - 0.10559, -0.02146, + 4.82082, 0.01885, 3.11279, -0.63338, + 0.10559, -0.02146, - -0.01672, 0.03412, + -0.01672, 0.03412, - 0.00605, 0.06415, + 0.00605, 0.06415, - -0.89085, 1.51929, -0.36571, 0.39317, + -0.89085, 1.51929, -0.36571, 0.39317, - 12.05250, -3.79392, 3.96557, -3.51272, - -0.17953, 12.30669, + 12.05250, -3.79392, 3.96557, -3.51272, + -0.17953, 12.30669, - -0.05083, -0.11442, + -0.05083, -0.11442, - 0.02013, -0.02837, + 0.02013, -0.02837, - -0.02087, -0.01599, + -0.02087, -0.01599, - 0.49190, 0.30360, 0.01316, 0.17649, + 0.49190, 0.30360, 0.01316, 0.17649, - 0.21193, -0.09149, -0.07173, -0.05707, + 0.21193, -0.09149, -0.07173, -0.05707, - 4.24196, -1.25155, 1.81336, 0.68887, - -0.01675, 0.20772, + 4.24196, -1.25155, 1.81336, 0.68887, + -0.01675, 0.20772, - -0.04117, -0.03531, + -0.04117, -0.03531, - -0.02690, -0.02766, + -0.02690, -0.02766, - 37.54264, 10.95327, 8.05610, 30.58210, - -12.68257, 1.72831, 0.13466, -3.27007, + 37.54264, 10.95327, 8.05610, 30.58210, + -12.68257, 1.72831, 0.13466, -3.27007, - 0.01864, -0.00595, + 0.01864, -0.00595, - 0.03676, 0.14857, -0.07223, 0.06179, + 0.03676, 0.14857, -0.07223, 0.06179, - 0.44878, -1.64901, -20.06001, 0.63384, - -4.97849, 4.78627, 29.87370, 7.29899, + 0.44878, -1.64901, -20.06001, 0.63384, + -4.97849, 4.78627, 29.87370, 7.29899, - 0.00047, -0.00155, + 0.00047, -0.00155, - 0.00314, 0.01425, + 0.00314, 0.01425, - -0.17842, -0.08461, + -0.17842, -0.08461, - -1.61020, -8.47710, 6.85048, -4.38196, - 1.05809, 2.68088, + -1.61020, -8.47710, 6.85048, -4.38196, + 1.05809, 2.68088, - -0.01027, -0.00833, + -0.01027, -0.00833, - 0.06834, -0.04205, + 0.06834, -0.04205, - 0.03330, -0.01271, + 0.03330, -0.01271, - 0.01301, -0.01358, + 0.01301, -0.01358, - 0.03537, 0.03612, 0.02962, 0.62471, - -0.30400, -0.64857, + 0.03537, 0.03612, 0.02962, 0.62471, + -0.30400, -0.64857, - 0.01773, 0.01890, + 0.01773, 0.01890, - 0.01426, -0.00226, + 0.01426, -0.00226, - -0.50957, -0.01955, -0.09702, 1.09983, + -0.50957, -0.01955, -0.09702, 1.09983, - 0.64387, -0.02755, + 0.64387, -0.02755, - 0.26604, 0.30684, 0.06354, 0.05114, + 0.26604, 0.30684, 0.06354, 0.05114, - -0.00058, -0.04672, + -0.00058, -0.04672, - -0.00828, 0.00712, + -0.00828, 0.00712, - -0.00440, 0.00029, + -0.00440, 0.00029, - -0.01601, 0.03566, + -0.01601, 0.03566, - 0.13398, -0.02666, + 0.13398, -0.02666, - -0.06752, -0.43044, 0.07172, -0.01999, + -0.06752, -0.43044, 0.07172, -0.01999, - -0.01761, -0.05357, + -0.01761, -0.05357, - 0.06104, 0.29742, -0.08785, 0.05241, + 0.06104, 0.29742, -0.08785, 0.05241, - -6.57162, -4.20103, 0.03199, -6.46187, - 1.32846, -0.51137, + -6.57162, -4.20103, 0.03199, -6.46187, + 1.32846, -0.51137, - 0.06358, 0.37309, + 0.06358, 0.37309, - -1.46946, 2.34981, + -1.46946, 2.34981, - -0.18712, 0.11618, + -0.18712, 0.11618, - 240.62965, -107.21962, 219.81977, 84.04246, - -62.22931, 68.35902, -9.48460, -32.62906, + 240.62965, -107.21962, 219.81977, 84.04246, + -62.22931, 68.35902, -9.48460, -32.62906, - 5.57483, -1.82396, 1.00095, -0.39774, + 5.57483, -1.82396, 1.00095, -0.39774, - 7.87054, 11.45449, + 7.87054, 11.45449, - -432.67155, 55064.72398, 12444.62359, 54215.28871, - 8486.03749, 12297.48243, -333.27968, 1147.93192, - 1403.73797, 990.40885, -3.84938, -722.43963, + -432.67155, 55064.72398, 12444.62359, 54215.28871, + 8486.03749, 12297.48243, -333.27968, 1147.93192, + 1403.73797, 990.40885, -3.84938, -722.43963, - 16.83276, 96.48787, 7.04834, 38.22208, - 0.63843, 2.61007, + 16.83276, 96.48787, 7.04834, 38.22208, + 0.63843, 2.61007, - 230.73221, 171.64166, 1.96751, 287.80846, - -85.21762, 31.33649, -2.25739, -11.28441, + 230.73221, 171.64166, 1.96751, 287.80846, + -85.21762, 31.33649, -2.25739, -11.28441, - 0.04699, 0.06555, + 0.04699, 0.06555, - -0.08887, 1.70919, 0.09477, 0.26291, + -0.08887, 1.70919, 0.09477, 0.26291, - -0.15490, 0.16009, + -0.15490, 0.16009, - 1.93274, 1.01953, 0.36380, 1.29582, - -0.13911, 0.14169, + 1.93274, 1.01953, 0.36380, 1.29582, + -0.13911, 0.14169, - -0.00491, -0.00030, + -0.00491, -0.00030, - -0.08908, -0.10216, + -0.08908, -0.10216, - -0.03265, -0.03889, + -0.03265, -0.03889, - 0.40413, -1.12715, -0.94687, -0.04514, + 0.40413, -1.12715, -0.94687, -0.04514, - 0.02487, -0.01048, + 0.02487, -0.01048, - 0.39729, 2.82305, -0.61100, 1.11728, - -0.13083, -0.04965, + 0.39729, 2.82305, -0.61100, 1.11728, + -0.13083, -0.04965, - -0.00602, -0.02952, + -0.00602, -0.02952, - -6.13507, 13.73998, -15.70559, -1.28059, - 2.64422, -9.33798, 3.26470, 1.56984, + -6.13507, 13.73998, -15.70559, -1.28059, + 2.64422, -9.33798, 3.26470, 1.56984, - -0.00572, 0.09992, + -0.00572, 0.09992, - -8.80458, -8.23890, -11.51628, 9.47904, - 11.31646, 4.29587, + -8.80458, -8.23890, -11.51628, 9.47904, + 11.31646, 4.29587, - -2.41367, -0.05883, -0.80022, -1.02706, - 0.21461, -0.06864, + -2.41367, -0.05883, -0.80022, -1.02706, + 0.21461, -0.06864, - 0.01882, 0.01798, + 0.01882, 0.01798, - 0.27614, -0.01007, 0.04362, 0.07560, - 0.05519, 0.23435, + 0.27614, -0.01007, 0.04362, 0.07560, + 0.05519, 0.23435, - -0.09389, 0.01613, + -0.09389, 0.01613, - 0.01298, 0.04691, + 0.01298, 0.04691, - -0.02665, -0.03582, + -0.02665, -0.03582, - 0.60080, -4.28673, 1.87316, -1.05840, - 0.13248, 0.40887, + 0.60080, -4.28673, 1.87316, -1.05840, + 0.13248, 0.40887, - -0.67657, 0.67732, 0.05522, 0.07812, - -0.17707, -0.07510, + -0.67657, 0.67732, 0.05522, 0.07812, + -0.17707, -0.07510, - 0.24885, 10.63974, -7.40226, -2.33827, - 2.75463, -32.51518, + 0.24885, 10.63974, -7.40226, -2.33827, + 2.75463, -32.51518, - 0.05140, 0.01555, + 0.05140, 0.01555, - 180.43808, 263.28252, 384.50646, -76.53434, - -93.50706, -220.50123, -81.91610, 103.92061, - 30.90305, -2.89292, + 180.43808, 263.28252, 384.50646, -76.53434, + -93.50706, -220.50123, -81.91610, 103.92061, + 30.90305, -2.89292, - -0.06634, -0.37717, -0.01945, -0.05936, + -0.06634, -0.37717, -0.01945, -0.05936, - 29.27877, -59.73705, 35.86569, -18.36556, - 3.88812, 4.82090, -0.70903, 0.06615, + 29.27877, -59.73705, 35.86569, -18.36556, + 3.88812, 4.82090, -0.70903, 0.06615, - 0.01558, -0.01854, + 0.01558, -0.01854, - 0.16209, 0.12682, 0.02508, 0.02406, + 0.16209, 0.12682, 0.02508, 0.02406, - -0.03078, -0.01737, -0.00033, -0.00020, + -0.03078, -0.01737, -0.00033, -0.00020, - 0.01023, 0.05972, + 0.01023, 0.05972, - -0.03373, -0.07289, + -0.03373, -0.07289, - -2.08162, -0.14717, -0.64233, -0.75397, - 0.11752, -0.09202, + -2.08162, -0.14717, -0.64233, -0.75397, + 0.11752, -0.09202, - 4.42981, -4.19241, 5.02542, 5.03467, - -4.22983, 2.80794, + 4.42981, -4.19241, 5.02542, 5.03467, + -4.22983, 2.80794, - 3.03016, -2.74373, -1.11490, -2.72378, - -0.63131, 0.74864, + 3.03016, -2.74373, -1.11490, -2.72378, + -0.63131, 0.74864, - -0.00759, -0.00675, + -0.00759, -0.00675, - 0.03615, -0.01806, + 0.03615, -0.01806, - -2.71920, -1.50954, 0.54479, -1.92088, - 0.66427, 0.32228, + -2.71920, -1.50954, 0.54479, -1.92088, + 0.66427, 0.32228, - -2.55188, -0.65332, -2.73798, 2.10182, - 1.54407, 3.01357, + -2.55188, -0.65332, -2.73798, 2.10182, + 1.54407, 3.01357, - 38.76777, 23.54578, 27.29884, -14.93005, - -7.50931, -5.66773, 0.30142, 1.52416, + 38.76777, 23.54578, 27.29884, -14.93005, + -7.50931, -5.66773, 0.30142, 1.52416, - 0.00634, 0.09697, -0.00748, 0.01433, + 0.00634, 0.09697, -0.00748, 0.01433, - 0.02936, 0.53228, -0.03603, 0.06345, + 0.02936, 0.53228, -0.03603, 0.06345, - 0.30816, -1.07925, 0.46709, -0.21568, - 0.01663, 0.10810, + 0.30816, -1.07925, 0.46709, -0.21568, + 0.01663, 0.10810, - -0.42511, 0.35872, -0.19662, -6.74031, + -0.42511, 0.35872, -0.19662, -6.74031, - 1.05776, 1.86205, 1.08919, 0.10483, - -0.03368, -0.21535, + 1.05776, 1.86205, 1.08919, 0.10483, + -0.03368, -0.21535, - 0.07556, -0.27104, 0.05142, -0.03812, + 0.07556, -0.27104, 0.05142, -0.03812, - 1.20189, -1.36782, 1.35764, 1.39387, - -1.19124, 0.77347, + 1.20189, -1.36782, 1.35764, 1.39387, + -1.19124, 0.77347, - -0.54760, -0.26295, -0.07473, 0.23043, + -0.54760, -0.26295, -0.07473, 0.23043, - 2.82621, -0.23524, 0.47352, -0.81672, - -0.08515, 0.04700, + 2.82621, -0.23524, 0.47352, -0.81672, + -0.08515, 0.04700, - 0.55355, -0.40138, 0.22255, 0.12236, + 0.55355, -0.40138, 0.22255, 0.12236, - -0.09110, 0.31982, 0.39404, -0.17898, + -0.09110, 0.31982, 0.39404, -0.17898, - -0.00056, 0.00014, + -0.00056, 0.00014, - -0.02012, 0.03102, + -0.02012, 0.03102, - 0.43236, -0.10037, -0.00961, 0.07440, - -0.07076, -1.97272, + 0.43236, -0.10037, -0.00961, 0.07440, + -0.07076, -1.97272, - 0.25555, -0.21832, -0.00837, -0.08393, + 0.25555, -0.21832, -0.00837, -0.08393, - 0.01531, 0.00627, + 0.01531, 0.00627, - 0.33193, 0.70765, -0.43556, 0.28542, + 0.33193, 0.70765, -0.43556, 0.28542, - -0.23190, -0.04293, -0.08062, 0.13427, + -0.23190, -0.04293, -0.08062, 0.13427, - 0.23763, -0.17092, 0.09259, 0.05155, + 0.23763, -0.17092, 0.09259, 0.05155, - 0.08065, -0.11943, + 0.08065, -0.11943, - -0.02174, -0.68899, + -0.02174, -0.68899, - -0.01875, -0.01746, + -0.01875, -0.01746, - 0.13604, 0.29280, -0.17871, 0.11799, + 0.13604, 0.29280, -0.17871, 0.11799, - 0.02003, 0.04065, + 0.02003, 0.04065, - 0.01343, -0.06060, + 0.01343, -0.06060, - -0.01290, -0.26068, + -0.01290, -0.26068, - -0.09033, 0.02649, + -0.09033, 0.02649, - -0.00092, -0.03094, + -0.00092, -0.03094, - -0.00770, -0.10447, + -0.00770, -0.10447, - -0.04113, 0.01259, + -0.04113, 0.01259, - -0.00469, -0.04346, + -0.00469, -0.04346, - -0.00010, 0.06547, + -0.00010, 0.06547, }; + static double FAR sattabb[] = { - -567865.62548, -796277.29029, -410804.00791, -91793.12562, - -6268.13975, 398.64391, -710.67442, 175.29456, + -567865.62548, -796277.29029, -410804.00791, -91793.12562, + -6268.13975, 398.64391, -710.67442, 175.29456, - -0.87260, 0.18444, + -0.87260, 0.18444, - -1314.88121, 20709.97394, -1850.41481, 20670.34255, - -896.96283, 6597.16433, -179.80702, 613.45468, - 17.37823, -13.62177, -0.36348, 12.34740, + -1314.88121, 20709.97394, -1850.41481, 20670.34255, + -896.96283, 6597.16433, -179.80702, 613.45468, + 17.37823, -13.62177, -0.36348, 12.34740, - 0.47532, 0.48189, + 0.47532, 0.48189, - 0.27162, -0.20655, + 0.27162, -0.20655, - -0.23268, 0.05992, + -0.23268, 0.05992, - 46.94511, 15.78836, 21.57439, 23.11342, - -0.25862, 5.21410, -0.22612, -0.05822, + 46.94511, 15.78836, 21.57439, 23.11342, + -0.25862, 5.21410, -0.22612, -0.05822, - -0.00439, -0.01641, + -0.00439, -0.01641, - -0.01108, -0.00608, + -0.01108, -0.00608, - 0.00957, 0.00272, + 0.00957, 0.00272, - -0.00217, 0.00001, + -0.00217, 0.00001, - -0.00534, -0.00545, + -0.00534, -0.00545, - 0.00277, -0.00843, + 0.00277, -0.00843, - 0.00167, -0.00794, 0.00032, -0.00242, + 0.00167, -0.00794, 0.00032, -0.00242, - -0.00002, -0.00041, + -0.00002, -0.00041, - -0.00025, 0.00031, + -0.00025, 0.00031, - 0.00062, -0.00060, + 0.00062, -0.00060, - 0.00083, 0.00032, + 0.00083, 0.00032, - 0.00527, -0.00211, 0.00054, 0.00004, + 0.00527, -0.00211, 0.00054, 0.00004, - -0.02769, -0.01777, + -0.02769, -0.01777, - 0.00247, 0.00097, 0.00020, -0.00232, + 0.00247, 0.00097, 0.00020, -0.00232, - 0.00044, -0.00035, + 0.00044, -0.00035, - -0.00072, 0.01341, 0.00325, -0.01159, + -0.00072, 0.01341, 0.00325, -0.01159, - 0.00079, -0.00078, + 0.00079, -0.00078, - -0.00009, 0.00066, + -0.00009, 0.00066, - 0.00222, 0.00002, + 0.00222, 0.00002, - 0.00013, -0.00161, + 0.00013, -0.00161, - 0.01374, -0.05305, + 0.01374, -0.05305, - 0.00478, -0.00283, + 0.00478, -0.00283, - 0.16033, 0.13859, 0.33288, -0.16932, + 0.16033, 0.13859, 0.33288, -0.16932, - -0.00316, 0.00625, + -0.00316, 0.00625, - -0.00309, 0.01687, 0.00001, 0.00486, + -0.00309, 0.01687, 0.00001, 0.00486, - 0.00401, -0.01805, -0.00048, -0.00407, + 0.00401, -0.01805, -0.00048, -0.00407, - -0.01329, 0.01311, -0.00591, 0.00166, + -0.01329, 0.01311, -0.00591, 0.00166, - 0.00830, 0.00665, + 0.00830, 0.00665, - -0.80207, 0.22994, -0.34687, 0.08460, - -0.11499, -0.01449, + -0.80207, 0.22994, -0.34687, 0.08460, + -0.11499, -0.01449, - -0.01574, 0.78813, -0.03063, 0.28872, - -0.00337, 0.01801, + -0.01574, 0.78813, -0.03063, 0.28872, + -0.00337, 0.01801, - -0.01703, -0.00929, + -0.01703, -0.00929, - -0.00738, 0.03938, + -0.00738, 0.03938, - 0.05616, -0.00516, + 0.05616, -0.00516, - -3.09497, 30.13091, -3.14968, 17.62201, - -0.73728, 2.46962, -0.11233, 0.03450, + -3.09497, 30.13091, -3.14968, 17.62201, + -0.73728, 2.46962, -0.11233, 0.03450, - -0.07837, -0.01573, + -0.07837, -0.01573, - -0.01595, 0.00394, + -0.01595, 0.00394, - 0.00174, 0.01470, + 0.00174, 0.01470, - 6.83560, -2.37594, 4.95125, 3.24711, - 2.44781, 5.17159, 1.99820, -2.38419, + 6.83560, -2.37594, 4.95125, 3.24711, + 2.44781, 5.17159, 1.99820, -2.38419, - 0.00840, 0.03614, + 0.00840, 0.03614, - -0.00209, -0.30407, -0.02681, -0.06128, + -0.00209, -0.30407, -0.02681, -0.06128, - 1.50134, 11.82856, 4.39644, 6.98850, - -4.17679, 5.73436, -9.66087, 1.98221, + 1.50134, 11.82856, 4.39644, 6.98850, + -4.17679, 5.73436, -9.66087, 1.98221, - -0.29755, 0.08019, + -0.29755, 0.08019, - -0.24766, -8.54956, -1.74494, -3.36794, - -0.32661, -0.00722, + -0.24766, -8.54956, -1.74494, -3.36794, + -0.32661, -0.00722, - 0.14141, 0.01023, + 0.14141, 0.01023, - -1.21541, -2.58470, 0.38983, -1.70307, - 0.31209, -0.10345, + -1.21541, -2.58470, 0.38983, -1.70307, + 0.31209, -0.10345, - 0.02593, 0.02178, 0.00289, 0.00393, + 0.02593, 0.02178, 0.00289, 0.00393, - -0.00236, -0.00373, + -0.00236, -0.00373, - -0.00270, -0.00049, + -0.00270, -0.00049, - -0.06282, -0.00443, -0.02439, -0.02254, - -0.02220, 0.03532, + -0.06282, -0.00443, -0.02439, -0.02254, + -0.02220, 0.03532, - -0.00072, 0.00010, + -0.00072, 0.00010, - -0.00049, -0.00112, + -0.00049, -0.00112, - 0.00086, 0.00112, + 0.00086, 0.00112, - 0.10135, -0.10972, 0.08357, 0.00155, - 0.04363, -0.00201, + 0.10135, -0.10972, 0.08357, 0.00155, + 0.04363, -0.00201, - -0.01996, -0.01341, + -0.01996, -0.01341, - -0.00039, -0.00042, + -0.00039, -0.00042, - -0.00294, 0.00070, + -0.00294, 0.00070, - 0.00005, -0.00027, + 0.00005, -0.00027, - 0.00070, -0.00076, + 0.00070, -0.00076, - 0.00234, -0.00239, + 0.00234, -0.00239, - -0.08365, -0.08531, -0.03531, 0.15012, + -0.08365, -0.08531, -0.03531, 0.15012, - -0.01995, -0.01731, -0.00370, -0.00745, + -0.01995, -0.01731, -0.00370, -0.00745, - -0.00315, -0.00079, + -0.00315, -0.00079, - -0.00120, -0.00145, + -0.00120, -0.00145, - -0.99404, -1.31859, 0.03584, -0.83421, - 0.10720, -0.05768, + -0.99404, -1.31859, 0.03584, -0.83421, + 0.10720, -0.05768, - 0.06664, -0.09338, + 0.06664, -0.09338, - -0.01814, -0.00003, + -0.01814, -0.00003, - -0.05371, -0.06458, -0.00100, -0.01298, + -0.05371, -0.06458, -0.00100, -0.01298, - -7.08710, -23.13374, 4.18669, -19.94756, - 4.85584, -3.37187, 0.58851, 0.31363, + -7.08710, -23.13374, 4.18669, -19.94756, + 4.85584, -3.37187, 0.58851, 0.31363, - 0.01994, 0.27494, + 0.01994, 0.27494, - -1.37112, 2.61742, 0.52477, -0.46520, + -1.37112, 2.61742, 0.52477, -0.46520, - -0.13183, 0.26777, + -0.13183, 0.26777, - 836.90400, -484.65861, 815.99098, 236.54649, - -32.38814, 288.95705, -68.17178, -18.87875, + 836.90400, -484.65861, 815.99098, 236.54649, + -32.38814, 288.95705, -68.17178, -18.87875, - -1.79782, -3.68662, -1.27310, -0.65697, + -1.79782, -3.68662, -1.27310, -0.65697, - -3.67530, 2.10471, + -3.67530, 2.10471, - -13758.97795, 4807.62301, -14582.14552, 9019.73021, - -3202.60105, 4570.16895, 2078.68911, 2892.62326, - -2399.35382, 3253.16198, -8182.38152, -3588.77680, + -13758.97795, 4807.62301, -14582.14552, 9019.73021, + -3202.60105, 4570.16895, 2078.68911, 2892.62326, + -2399.35382, 3253.16198, -8182.38152, -3588.77680, - -0.16505, 1.08603, 0.53388, 0.87152, + -0.16505, 1.08603, 0.53388, 0.87152, - 61.53677, 538.43813, -407.32927, 322.27446, - -148.71585, -179.37765, 54.07268, -34.12281, + 61.53677, 538.43813, -407.32927, 322.27446, + -148.71585, -179.37765, 54.07268, -34.12281, - -14.76569, -17.95681, -10.82061, -6.39954, - -2.10954, 0.67063, 0.22607, -0.43648, + -14.76569, -17.95681, -10.82061, -6.39954, + -2.10954, 0.67063, 0.22607, -0.43648, - 20.90476, -45.48667, 30.39436, -14.20077, - 5.17385, 5.12726, -0.66319, 0.55668, + 20.90476, -45.48667, 30.39436, -14.20077, + 5.17385, 5.12726, -0.66319, 0.55668, - 0.02269, -0.00016, + 0.02269, -0.00016, - 0.07811, 0.00111, 0.01603, 0.01020, + 0.07811, 0.00111, 0.01603, 0.01020, - -0.00107, 0.00494, + -0.00107, 0.00494, - -0.00077, -0.00084, + -0.00077, -0.00084, - -0.00196, 0.00081, + -0.00196, 0.00081, - -0.03776, 0.01286, -0.00652, -0.01450, + -0.03776, 0.01286, -0.00652, -0.01450, - 0.05942, -0.08612, 0.01093, -0.01644, + 0.05942, -0.08612, 0.01093, -0.01644, - 0.02147, -0.00592, + 0.02147, -0.00592, - 0.36350, -0.00201, 0.14419, -0.10070, - -0.00491, -0.01771, + 0.36350, -0.00201, 0.14419, -0.10070, + -0.00491, -0.01771, - -0.00053, -0.00033, + -0.00053, -0.00033, - 0.00146, 0.00048, + 0.00146, 0.00048, - 0.00582, 0.04423, -0.00549, 0.00983, + 0.00582, 0.04423, -0.00549, 0.00983, - 0.27355, -0.38057, 0.24001, -0.05441, - -0.07706, 0.14269, + 0.27355, -0.38057, 0.24001, -0.05441, + -0.07706, 0.14269, - -0.00059, -0.00154, + -0.00059, -0.00154, - -0.00013, -0.00088, + -0.00013, -0.00088, - -0.00046, 0.00029, + -0.00046, 0.00029, - -0.00276, -0.00507, 0.00075, -0.00076, + -0.00276, -0.00507, 0.00075, -0.00076, - 0.01806, 0.00862, -0.00510, -0.01364, + 0.01806, 0.00862, -0.00510, -0.01364, - -0.00029, -0.12664, 0.03899, -0.03562, - 0.00318, 0.00514, + -0.00029, -0.12664, 0.03899, -0.03562, + 0.00318, 0.00514, - 0.00057, 0.00201, + 0.00057, 0.00201, - 0.00028, 0.00014, + 0.00028, 0.00014, - -0.47022, -0.74561, 0.40155, -0.16471, - -0.18445, 0.34425, -0.07464, -0.13709, + -0.47022, -0.74561, 0.40155, -0.16471, + -0.18445, 0.34425, -0.07464, -0.13709, - -0.01018, -0.00748, + -0.01018, -0.00748, - -0.01210, -0.04274, -0.00579, -0.00692, + -0.01210, -0.04274, -0.00579, -0.00692, - -11.09188, -1.67755, -6.62063, -13.84023, - 12.75563, -6.73501, 8.31662, 5.40196, + -11.09188, -1.67755, -6.62063, -13.84023, + 12.75563, -6.73501, 8.31662, 5.40196, - 0.00052, 0.00034, + 0.00052, 0.00034, - 0.00128, 0.00085, + 0.00128, 0.00085, - -0.02202, -0.00599, + -0.02202, -0.00599, - -0.33458, -1.65852, 1.47003, -1.02434, - 0.87885, 1.15334, + -0.33458, -1.65852, 1.47003, -1.02434, + 0.87885, 1.15334, - -0.00241, -0.00721, + -0.00241, -0.00721, - 0.03154, 0.00612, + 0.03154, 0.00612, - 0.00318, -0.02521, + 0.00318, -0.02521, - 0.00042, 0.00213, + 0.00042, 0.00213, - -0.01094, 0.05417, -0.03989, -0.00567, - 0.00123, -0.00244, + -0.01094, 0.05417, -0.03989, -0.00567, + 0.00123, -0.00244, - 0.00108, 0.00242, + 0.00108, 0.00242, - -0.00138, -0.00099, + -0.00138, -0.00099, - 0.04967, 0.01643, -0.00133, 0.02296, + 0.04967, 0.01643, -0.00133, 0.02296, - 0.12207, 0.05584, + 0.12207, 0.05584, - 0.00437, -0.04432, -0.00176, -0.00922, + 0.00437, -0.04432, -0.00176, -0.00922, - -0.00252, 0.00326, + -0.00252, 0.00326, - -0.00020, -0.00050, + -0.00020, -0.00050, - -0.00263, -0.00084, + -0.00263, -0.00084, - -0.01971, 0.00297, + -0.01971, 0.00297, - 0.03076, 0.01736, + 0.03076, 0.01736, - -0.01331, 0.01121, -0.00675, 0.00340, + -0.01331, 0.01121, -0.00675, 0.00340, - -0.00256, 0.00327, + -0.00256, 0.00327, - -0.00946, 0.03377, -0.00770, 0.00337, + -0.00946, 0.03377, -0.00770, 0.00337, - 0.61383, 0.71128, -0.02018, 0.62097, - -0.07247, 0.04418, + 0.61383, 0.71128, -0.02018, 0.62097, + -0.07247, 0.04418, - -0.02886, -0.03848, + -0.02886, -0.03848, - -0.44062, 0.03973, + -0.44062, 0.03973, - -0.00999, -0.04382, + -0.00999, -0.04382, - 57.94459, 117.45112, -71.22893, 126.39415, - -62.33152, -31.90754, 12.17738, -16.46809, + 57.94459, 117.45112, -71.22893, 126.39415, + -62.33152, -31.90754, 12.17738, -16.46809, - -1.13298, 0.08962, -0.20532, 0.16320, + -1.13298, 0.08962, -0.20532, 0.16320, - -1.55110, -1.44757, + -1.55110, -1.44757, - -3102.08749, -7452.61957, -5009.53858, -7216.29165, - -2476.87148, -1880.58197, -574.49433, 227.45615, - 144.50228, 379.15791, 225.36130, -443.47371, + -3102.08749, -7452.61957, -5009.53858, -7216.29165, + -2476.87148, -1880.58197, -574.49433, 227.45615, + 144.50228, 379.15791, 225.36130, -443.47371, - -8.51989, -3.75208, -4.25415, -1.59741, - -0.43946, -0.06595, + -8.51989, -3.75208, -4.25415, -1.59741, + -0.43946, -0.06595, - 150.42986, 6.54937, 87.67736, 92.32332, - -21.97187, 29.87097, -4.21636, -5.72955, + 150.42986, 6.54937, 87.67736, 92.32332, + -21.97187, 29.87097, -4.21636, -5.72955, - -0.03879, -0.01071, + -0.03879, -0.01071, - -0.45985, 0.02679, -0.02448, 0.02397, + -0.45985, 0.02679, -0.02448, 0.02397, - -0.06551, -0.01154, + -0.06551, -0.01154, - 1.97905, -0.82292, 1.10140, 0.30924, - 0.03389, 0.14230, + 1.97905, -0.82292, 1.10140, 0.30924, + 0.03389, 0.14230, - 0.00003, 0.00119, + 0.00003, 0.00119, - -0.01117, 0.00665, + -0.01117, 0.00665, - -0.00132, -0.00576, + -0.00132, -0.00576, - -0.08356, 0.08556, -0.26362, -0.12450, + -0.08356, 0.08556, -0.26362, -0.12450, - 0.00509, 0.00165, + 0.00509, 0.00165, - 0.02591, 0.16200, -0.03318, 0.06463, - -0.00899, -0.00462, + 0.02591, 0.16200, -0.03318, 0.06463, + -0.00899, -0.00462, - 0.00102, 0.00004, + 0.00102, 0.00004, - -0.73102, 0.08299, -0.52957, -0.35744, - 0.14119, -0.24903, 0.20843, 0.14143, + -0.73102, 0.08299, -0.52957, -0.35744, + 0.14119, -0.24903, 0.20843, 0.14143, - 0.00031, -0.00234, + 0.00031, -0.00234, - -0.42643, -2.02084, 1.58848, -1.57963, - 0.68418, 2.07749, + -0.42643, -2.02084, 1.58848, -1.57963, + 0.68418, 2.07749, - -0.45888, 0.19859, -0.30277, -0.22591, - 0.11607, -0.09705, + -0.45888, 0.19859, -0.30277, -0.22591, + 0.11607, -0.09705, - 0.00040, 0.00431, + 0.00040, 0.00431, - -0.02683, 0.03158, -0.01302, -0.00541, - 0.01742, -0.00006, + -0.02683, 0.03158, -0.01302, -0.00541, + 0.01742, -0.00006, - -0.02231, -0.01128, + -0.02231, -0.01128, - -0.00800, 0.02055, + -0.00800, 0.02055, - -0.00346, 0.00151, + -0.00346, 0.00151, - 0.56732, -0.68995, 0.27701, -0.16748, - 0.01002, 0.00043, + 0.56732, -0.68995, 0.27701, -0.16748, + 0.01002, 0.00043, - 0.26916, -0.57751, 0.15547, -0.15825, - -0.02074, -0.07722, + 0.26916, -0.57751, 0.15547, -0.15825, + -0.02074, -0.07722, - -8.23483, -4.02022, 0.69327, -5.91543, - 1.72440, 1.02090, + -8.23483, -4.02022, 0.69327, -5.91543, + 1.72440, 1.02090, - 0.00024, -0.00053, + 0.00024, -0.00053, - 20.03959, 14.79136, 76.43531, -14.42019, - -7.82608, -69.96121, -54.94229, 23.55140, - 26.60767, 14.68275, + 20.03959, 14.79136, 76.43531, -14.42019, + -7.82608, -69.96121, -54.94229, 23.55140, + 26.60767, 14.68275, - 0.05118, -0.10401, -0.00075, -0.01942, + 0.05118, -0.10401, -0.00075, -0.01942, - -3.84266, -26.23442, 10.20395, -14.77139, - 3.40853, 2.07297, -0.53348, 0.40635, + -3.84266, -26.23442, 10.20395, -14.77139, + 3.40853, 2.07297, -0.53348, 0.40635, - 0.00716, -0.00189, + 0.00716, -0.00189, - 0.12472, -0.02903, 0.02254, -0.00183, + 0.12472, -0.02903, 0.02254, -0.00183, - -0.00175, -0.01522, 0.00003, -0.00339, + -0.00175, -0.01522, 0.00003, -0.00339, - 0.00383, -0.00168, + 0.00383, -0.00168, - 0.01327, -0.03657, + 0.01327, -0.03657, - -0.08458, -0.00115, -0.03991, -0.02629, - 0.00243, -0.00505, + -0.08458, -0.00115, -0.03991, -0.02629, + 0.00243, -0.00505, - 0.33875, -0.16744, 0.05183, 0.01744, - -0.24427, 0.15271, + 0.33875, -0.16744, 0.05183, 0.01744, + -0.24427, 0.15271, - 0.37550, -0.17378, 0.09198, -0.27966, - -0.22160, 0.16426, + 0.37550, -0.17378, 0.09198, -0.27966, + -0.22160, 0.16426, - 0.00032, -0.00310, + 0.00032, -0.00310, - -0.00022, -0.00144, + -0.00022, -0.00144, - -0.06170, -0.01195, -0.00918, 0.02538, - 0.03602, 0.03414, + -0.06170, -0.01195, -0.00918, 0.02538, + 0.03602, 0.03414, - -0.14998, -0.44351, 0.45512, -0.11766, - 0.35638, 0.27539, + -0.14998, -0.44351, 0.45512, -0.11766, + 0.35638, 0.27539, - 5.93405, 10.55777, 12.42596, -1.82530, - -2.36124, -6.04176, -0.98609, 1.67652, + 5.93405, 10.55777, 12.42596, -1.82530, + -2.36124, -6.04176, -0.98609, 1.67652, - -0.09271, 0.03448, -0.01951, 0.00108, + -0.09271, 0.03448, -0.01951, 0.00108, - 0.33862, 0.21461, 0.02564, 0.06924, + 0.33862, 0.21461, 0.02564, 0.06924, - 0.01126, -0.01168, -0.00829, -0.00740, - 0.00106, -0.00854, + 0.01126, -0.01168, -0.00829, -0.00740, + 0.00106, -0.00854, - -0.08404, 0.02508, -0.02722, -0.06537, + -0.08404, 0.02508, -0.02722, -0.06537, - 0.01662, 0.11454, 0.06747, 0.00742, - -0.01975, -0.02597, + 0.01662, 0.11454, 0.06747, 0.00742, + -0.01975, -0.02597, - -0.00097, -0.01154, 0.00164, -0.00274, + -0.00097, -0.01154, 0.00164, -0.00274, - 0.02954, -0.05161, -0.02162, -0.02069, - -0.06369, 0.03846, + 0.02954, -0.05161, -0.02162, -0.02069, + -0.06369, 0.03846, - 0.00219, -0.01634, -0.04518, 0.06696, + 0.00219, -0.01634, -0.04518, 0.06696, - 1.21537, 0.99500, 0.68376, -0.28709, - -0.11397, -0.06468, + 1.21537, 0.99500, 0.68376, -0.28709, + -0.11397, -0.06468, - 0.00607, -0.00744, 0.01531, 0.00975, + 0.00607, -0.00744, 0.01531, 0.00975, - -0.03983, 0.02405, 0.07563, 0.00356, + -0.03983, 0.02405, 0.07563, 0.00356, - -0.00018, -0.00009, + -0.00018, -0.00009, - 0.00172, -0.00331, + 0.00172, -0.00331, - 0.01565, -0.03466, -0.00230, 0.00142, - -0.00788, -0.01019, + 0.01565, -0.03466, -0.00230, 0.00142, + -0.00788, -0.01019, - 0.01411, -0.01456, -0.00672, -0.00543, + 0.01411, -0.01456, -0.00672, -0.00543, - 0.00059, -0.00011, + 0.00059, -0.00011, - -0.00661, -0.00496, -0.01986, 0.01271, + -0.00661, -0.00496, -0.01986, 0.01271, - -0.01323, -0.00764, 0.00041, 0.01145, + -0.01323, -0.00764, 0.00041, 0.01145, - 0.00378, -0.00137, 0.00652, 0.00412, + 0.00378, -0.00137, 0.00652, 0.00412, - 0.01946, -0.00573, + 0.01946, -0.00573, - -0.00326, -0.00257, + -0.00326, -0.00257, - -0.00225, 0.00090, + -0.00225, 0.00090, - -0.00292, -0.00317, -0.00719, 0.00468, + -0.00292, -0.00317, -0.00719, 0.00468, - 0.00245, 0.00189, + 0.00245, 0.00189, - 0.00565, -0.00330, + 0.00565, -0.00330, - -0.00168, -0.00047, + -0.00168, -0.00047, - -0.00256, 0.00220, + -0.00256, 0.00220, - 0.00180, -0.00162, + 0.00180, -0.00162, - -0.00085, -0.00003, + -0.00085, -0.00003, - -0.00100, 0.00098, + -0.00100, 0.00098, - -0.00043, 0.00007, + -0.00043, 0.00007, - -0.00003, -0.00013, + -0.00003, -0.00013, }; + static double FAR sattabr[] = { - -38127.94034, -48221.08524, -20986.93487, -3422.75861, - -8.97362, 53.34259, -404.15708, -0.05434, + -38127.94034, -48221.08524, -20986.93487, -3422.75861, + -8.97362, 53.34259, -404.15708, -0.05434, - 0.46327, 0.16968, + 0.46327, 0.16968, - -387.16771, -146.07622, 103.77956, 19.11054, - -40.21762, 996.16803, -702.22737, 246.36496, - -63.89626, -304.82756, 78.23653, -2.58314, + -387.16771, -146.07622, 103.77956, 19.11054, + -40.21762, 996.16803, -702.22737, 246.36496, + -63.89626, -304.82756, 78.23653, -2.58314, - -0.11368, -0.06541, + -0.11368, -0.06541, - -0.34321, 0.33039, + -0.34321, 0.33039, - 0.05652, -0.16493, + 0.05652, -0.16493, - 67.44536, -29.43578, 50.85074, 18.68861, - 0.39742, 13.64587, -1.61284, 0.11482, + 67.44536, -29.43578, 50.85074, 18.68861, + 0.39742, 13.64587, -1.61284, 0.11482, - 0.01668, -0.01182, + 0.01668, -0.01182, - -0.00386, 0.01025, + -0.00386, 0.01025, - 0.00234, -0.01530, + 0.00234, -0.01530, - -0.02569, -0.00799, + -0.02569, -0.00799, - -0.00429, -0.00217, + -0.00429, -0.00217, - -0.00672, 0.00650, + -0.00672, 0.00650, - 0.01154, 0.00120, -0.00515, 0.00125, + 0.01154, 0.00120, -0.00515, 0.00125, - 0.00236, -0.00216, + 0.00236, -0.00216, - -0.00098, 0.00009, + -0.00098, 0.00009, - -0.00460, -0.00518, + -0.00460, -0.00518, - 0.00600, 0.00003, + 0.00600, 0.00003, - 0.00834, 0.00095, 0.01967, 0.00637, + 0.00834, 0.00095, 0.01967, 0.00637, - -0.00558, -0.06911, + -0.00558, -0.06911, - -0.01344, -0.06589, -0.05425, -0.00607, + -0.01344, -0.06589, -0.05425, -0.00607, - -0.00247, -0.00266, + -0.00247, -0.00266, - 0.08790, -0.08537, -0.00647, 0.04028, + 0.08790, -0.08537, -0.00647, 0.04028, - -0.00325, 0.00488, + -0.00325, 0.00488, - 0.00111, -0.00044, + 0.00111, -0.00044, - -0.00731, 0.00127, + -0.00731, 0.00127, - -0.00417, 0.00303, + -0.00417, 0.00303, - 0.05261, 0.01858, + 0.05261, 0.01858, - -0.00807, 0.01195, + -0.00807, 0.01195, - 1.26352, -0.38591, -0.34825, 1.10733, + 1.26352, -0.38591, -0.34825, 1.10733, - -0.02815, -0.02148, + -0.02815, -0.02148, - -0.05083, -0.04377, -0.01206, -0.00586, + -0.05083, -0.04377, -0.01206, -0.00586, - 0.03158, -0.01117, 0.00643, 0.00306, + 0.03158, -0.01117, 0.00643, 0.00306, - -0.01186, -0.05161, 0.01136, -0.00976, + -0.01186, -0.05161, 0.01136, -0.00976, - -0.00536, 0.01949, + -0.00536, 0.01949, - -1.41680, -0.81290, -0.09254, -0.24347, - -0.14831, -0.34381, + -1.41680, -0.81290, -0.09254, -0.24347, + -0.14831, -0.34381, - -2.44464, 0.41202, -0.99240, -0.33707, - -0.01930, -0.08473, + -2.44464, 0.41202, -0.99240, -0.33707, + -0.01930, -0.08473, - 0.00830, 0.01165, + 0.00830, 0.01165, - -0.01604, -0.02439, + -0.01604, -0.02439, - 0.00227, 0.04493, + 0.00227, 0.04493, - -42.75310, -22.65155, -9.93679, -18.36179, - 2.73773, 3.24126, -1.20698, 1.07731, + -42.75310, -22.65155, -9.93679, -18.36179, + 2.73773, 3.24126, -1.20698, 1.07731, - 0.00434, -0.10360, + 0.00434, -0.10360, - -0.02359, 0.00054, + -0.02359, 0.00054, - -0.02664, -0.00122, + -0.02664, -0.00122, - -19.79520, 33.11770, -53.56452, -35.41902, - 67.95039, -82.46551, 117.31843, 14.08609, + -19.79520, 33.11770, -53.56452, -35.41902, + 67.95039, -82.46551, 117.31843, 14.08609, - 0.06447, 0.03289, + 0.06447, 0.03289, - 0.40365, -0.33397, 0.07079, -0.09504, + 0.40365, -0.33397, 0.07079, -0.09504, - -30.36873, 6.23538, -14.25988, -44.91408, - 38.53146, -16.31919, 6.99584, 22.47169, + -30.36873, 6.23538, -14.25988, -44.91408, + 38.53146, -16.31919, 6.99584, 22.47169, - -0.13313, 0.28016, + -0.13313, 0.28016, - 6.83715, -6.01384, 1.68531, -3.62443, - -0.22469, -0.29718, + 6.83715, -6.01384, 1.68531, -3.62443, + -0.22469, -0.29718, - 0.25169, 0.13780, + 0.25169, 0.13780, - -3.64824, 1.22420, -2.48963, -1.12515, - -0.01510, -0.56180, + -3.64824, 1.22420, -2.48963, -1.12515, + -0.01510, -0.56180, - -0.03306, 0.01848, -0.00103, -0.00077, + -0.03306, 0.01848, -0.00103, -0.00077, - -0.01681, -0.00227, + -0.01681, -0.00227, - -0.00402, -0.00287, + -0.00402, -0.00287, - 0.04965, -0.16190, -0.40025, 0.20734, - 0.15819, -0.25451, + 0.04965, -0.16190, -0.40025, 0.20734, + 0.15819, -0.25451, - 0.02467, -0.00495, + 0.02467, -0.00495, - 0.00597, 0.00490, + 0.00597, 0.00490, - -0.01085, -0.00460, + -0.01085, -0.00460, - -0.71564, -0.26624, 0.03797, -0.28263, - 0.03510, 0.30014, + -0.71564, -0.26624, 0.03797, -0.28263, + 0.03510, 0.30014, - 2.79810, 0.07258, + 2.79810, 0.07258, - -0.01618, 0.00337, + -0.01618, 0.00337, - 0.00876, 0.04438, + 0.00876, 0.04438, - 0.00742, -0.00455, + 0.00742, -0.00455, - -0.01163, -0.00683, + -0.01163, -0.00683, - 0.00950, 0.01275, + 0.00950, 0.01275, - -0.02124, -0.67527, -0.23635, 0.06298, + -0.02124, -0.67527, -0.23635, 0.06298, - -0.03844, 0.01010, 0.73588, -0.00271, + -0.03844, 0.01010, 0.73588, -0.00271, - 0.01742, -0.00467, + 0.01742, -0.00467, - 0.00017, -0.00505, + 0.00017, -0.00505, - -0.27482, 5.00521, -1.92099, 1.55295, - -0.35919, -0.09314, + -0.27482, 5.00521, -1.92099, 1.55295, + -0.35919, -0.09314, - -0.47002, 0.06826, + -0.47002, 0.06826, - 0.07924, 0.16838, + 0.07924, 0.16838, - -0.04221, 0.71510, -0.16482, 0.08809, + -0.04221, 0.71510, -0.16482, 0.08809, - 41.76829, -125.79427, 106.65271, -71.30642, - 36.18112, 17.36143, -1.63846, 5.02215, + 41.76829, -125.79427, 106.65271, -71.30642, + 36.18112, 17.36143, -1.63846, 5.02215, - -1.08404, 0.00061, + -1.08404, 0.00061, - 2.45567, -2.42818, -9.88756, 5.36587, + 2.45567, -2.42818, -9.88756, 5.36587, - -0.61253, -0.35003, + -0.61253, -0.35003, - 1523.54790, 602.82184, 68.66902, 1878.26100, - -1098.78095, -120.72600, 127.30918, -383.96064, + 1523.54790, 602.82184, 68.66902, 1878.26100, + -1098.78095, -120.72600, 127.30918, -383.96064, - -7.00838, -6.09942, -1.54187, 0.34883, + -7.00838, -6.09942, -1.54187, 0.34883, - -9.47561, -4.35408, + -9.47561, -4.35408, - -21541.63676, -32542.09807, -29720.82604, -28072.21231, - -15755.56255, -8084.58657, -8148.87315, 7434.89857, - 11033.30133, 7827.94658, 610.18256, -11411.93624, + -21541.63676, -32542.09807, -29720.82604, -28072.21231, + -15755.56255, -8084.58657, -8148.87315, 7434.89857, + 11033.30133, 7827.94658, 610.18256, -11411.93624, - -9.87426, 0.94865, -1.63656, 0.41275, + -9.87426, 0.94865, -1.63656, 0.41275, - 1996.57150, 511.48468, 669.78228, 1363.67610, - -379.72037, 198.84438, -16.63126, -79.37624, + 1996.57150, 511.48468, 669.78228, 1363.67610, + -379.72037, 198.84438, -16.63126, -79.37624, - -2.30776, -246.07820, -16.85846, -148.18168, - -6.89632, -20.49587, 0.39892, -0.34627, + -2.30776, -246.07820, -16.85846, -148.18168, + -6.89632, -20.49587, 0.39892, -0.34627, - -57.81309, -136.96971, 15.25671, -96.61153, - 16.09785, -8.79091, 0.70515, 1.16197, + -57.81309, -136.96971, 15.25671, -96.61153, + 16.09785, -8.79091, 0.70515, 1.16197, - 0.05647, 0.04684, + 0.05647, 0.04684, - 0.25032, -0.19951, 0.07282, -0.00696, + 0.25032, -0.19951, 0.07282, -0.00696, - 0.00493, 0.00733, + 0.00493, 0.00733, - -0.01085, 0.00422, + -0.01085, 0.00422, - -0.01309, 0.00262, + -0.01309, 0.00262, - 0.37616, -0.36203, -0.11154, 0.18213, + 0.37616, -0.36203, -0.11154, 0.18213, - 0.15691, 0.29343, 0.00485, 0.06106, + 0.15691, 0.29343, 0.00485, 0.06106, - -0.01492, 0.09954, + -0.01492, 0.09954, - 0.28486, 2.27190, 0.33102, 1.50696, - -0.01926, 0.04901, + 0.28486, 2.27190, 0.33102, 1.50696, + -0.01926, 0.04901, - 0.01827, 0.00863, + 0.01827, 0.00863, - -0.03315, 0.00178, + -0.03315, 0.00178, - -0.77600, -0.48576, -0.21111, -0.19485, + -0.77600, -0.48576, -0.21111, -0.19485, - 1.90295, 6.44856, 1.71638, 2.12980, - -7.19585, -0.08043, + 1.90295, 6.44856, 1.71638, 2.12980, + -7.19585, -0.08043, - 0.07004, -0.02764, + 0.07004, -0.02764, - 0.01604, 0.01158, + 0.01604, 0.01158, - 0.00936, -0.01199, + 0.00936, -0.01199, - 0.18396, -0.29234, 0.10422, -0.00720, + 0.18396, -0.29234, 0.10422, -0.00720, - 0.05196, 0.10753, 0.02859, -0.03602, + 0.05196, 0.10753, 0.02859, -0.03602, - 0.63828, 1.96280, -0.31919, 0.85859, - -0.10218, -0.00673, + 0.63828, 1.96280, -0.31919, 0.85859, + -0.10218, -0.00673, - 0.01748, -0.02190, + 0.01748, -0.02190, - 0.01266, -0.02729, + 0.01266, -0.02729, - -4.80220, 8.90557, -5.94059, 2.28577, - -0.19687, -1.28666, 0.32398, 0.14879, + -4.80220, 8.90557, -5.94059, 2.28577, + -0.19687, -1.28666, 0.32398, 0.14879, - -0.02619, -0.02056, + -0.02619, -0.02056, - -0.04872, -0.07011, -0.04082, -0.04740, + -0.04872, -0.07011, -0.04082, -0.04740, - 0.60167, -2.20365, -0.27919, -0.45957, - -1.31664, -2.22682, 176.89871, 13.03918, + 0.60167, -2.20365, -0.27919, -0.45957, + -1.31664, -2.22682, 176.89871, 13.03918, - 0.00568, 0.00560, + 0.00568, 0.00560, - 0.01093, 0.00486, + 0.01093, 0.00486, - -0.00948, -0.31272, + -0.00948, -0.31272, - -11.87638, -3.68471, -1.74977, -9.60468, - 2.94988, -0.57118, + -11.87638, -3.68471, -1.74977, -9.60468, + 2.94988, -0.57118, - 0.00307, -0.01636, + 0.00307, -0.01636, - 0.02624, 0.03032, + 0.02624, 0.03032, - -0.00464, -0.01338, + -0.00464, -0.01338, - 0.00935, 0.00530, + 0.00935, 0.00530, - -0.11822, 0.03328, -0.41854, 0.04331, - 0.41340, -0.21657, + -0.11822, 0.03328, -0.41854, 0.04331, + 0.41340, -0.21657, - -0.00865, 0.00849, + -0.00865, 0.00849, - -0.00374, -0.00899, + -0.00374, -0.00899, - 0.01227, -0.23462, -0.71894, -0.04515, + 0.01227, -0.23462, -0.71894, -0.04515, - 0.00047, 0.28112, + 0.00047, 0.28112, - -0.12788, 0.11698, -0.02030, 0.02759, + -0.12788, 0.11698, -0.02030, 0.02759, - 0.02967, -0.00092, + 0.02967, -0.00092, - 0.00454, 0.00565, + 0.00454, 0.00565, - -0.00026, 0.00164, + -0.00026, 0.00164, - -0.01405, -0.00862, + -0.01405, -0.00862, - 0.01088, 0.05589, + 0.01088, 0.05589, - 0.18248, -0.06931, -0.00011, 0.03713, + 0.18248, -0.06931, -0.00011, 0.03713, - 0.01932, -0.00982, + 0.01932, -0.00982, - -0.13861, 0.09853, -0.03441, -0.02492, + -0.13861, 0.09853, -0.03441, -0.02492, - 2.26163, -5.94453, 4.14361, -0.94105, - 0.39561, 0.75414, + 2.26163, -5.94453, 4.14361, -0.94105, + 0.39561, 0.75414, - -0.17642, 0.03724, + -0.17642, 0.03724, - -1.32978, -0.56610, + -1.32978, -0.56610, - -0.03259, -0.06752, + -0.03259, -0.06752, - 39.07495, 80.25429, -28.15558, 82.69851, - -37.53894, -17.88963, 6.98299, -13.04691, + 39.07495, 80.25429, -28.15558, 82.69851, + -37.53894, -17.88963, 6.98299, -13.04691, - -0.48675, -1.84530, -0.07985, -0.33004, + -0.48675, -1.84530, -0.07985, -0.33004, - -3.39292, 2.73153, + -3.39292, 2.73153, - -17268.46134, 1144.22336, -16658.48585, 5252.94094, - -3461.47865, 2910.56452, -433.49442, -305.74268, - -383.45023, 545.16136, 313.83376, 27.00533, + -17268.46134, 1144.22336, -16658.48585, 5252.94094, + -3461.47865, 2910.56452, -433.49442, -305.74268, + -383.45023, 545.16136, 313.83376, 27.00533, - -31.41075, 7.90570, -12.40592, 3.01833, - -0.83334, 0.23404, + -31.41075, 7.90570, -12.40592, 3.01833, + -0.83334, 0.23404, - 59.26487, -112.74279, 113.29402, -15.37579, - 14.03282, 32.74482, -4.73299, 1.30224, + 59.26487, -112.74279, 113.29402, -15.37579, + 14.03282, 32.74482, -4.73299, 1.30224, - -0.00866, 0.01232, + -0.00866, 0.01232, - -0.53797, 0.00238, -0.07979, 0.04443, + -0.53797, 0.00238, -0.07979, 0.04443, - -0.05617, -0.05396, + -0.05617, -0.05396, - 0.10185, -1.05476, 0.43791, -0.32302, - 0.06465, 0.03815, + 0.10185, -1.05476, 0.43791, -0.32302, + 0.06465, 0.03815, - 0.00028, -0.00446, + 0.00028, -0.00446, - 0.09289, -0.06389, + 0.09289, -0.06389, - 0.01701, -0.01409, + 0.01701, -0.01409, - 0.47101, 0.16158, 0.01036, -0.39836, + 0.47101, 0.16158, 0.01036, -0.39836, - 0.00477, 0.01101, + 0.00477, 0.01101, - -2.06535, 0.33197, -0.82468, -0.41414, - 0.03209, -0.09348, + -2.06535, 0.33197, -0.82468, -0.41414, + 0.03209, -0.09348, - 0.00843, -0.00030, + 0.00843, -0.00030, - -9.49517, -3.82206, 0.66899, -10.28786, - 6.33435, 1.73684, -0.98164, 2.25164, + -9.49517, -3.82206, 0.66899, -10.28786, + 6.33435, 1.73684, -0.98164, 2.25164, - -0.07577, -0.00277, + -0.07577, -0.00277, - 1.02122, 0.75747, 1.79155, -0.77789, - -2.56780, -2.07807, + 1.02122, 0.75747, 1.79155, -0.77789, + -2.56780, -2.07807, - 0.19528, 0.77118, -0.28083, 0.32130, - -0.04350, -0.07428, + 0.19528, 0.77118, -0.28083, 0.32130, + -0.04350, -0.07428, - -0.01161, 0.01387, + -0.01161, 0.01387, - 0.02074, 0.19802, -0.03600, 0.04922, - -0.19837, 0.02572, + 0.02074, 0.19802, -0.03600, 0.04922, + -0.19837, 0.02572, - -0.00682, -0.04277, + -0.00682, -0.04277, - -0.01805, 0.00299, + -0.01805, 0.00299, - 0.03283, -0.02099, + 0.03283, -0.02099, - 3.57307, 1.17468, 0.65769, 1.88181, - -0.39215, 0.08415, + 3.57307, 1.17468, 0.65769, 1.88181, + -0.39215, 0.08415, - -0.53635, -0.19087, -0.12456, 0.02176, - 0.01182, -0.07941, + -0.53635, -0.19087, -0.12456, 0.02176, + 0.01182, -0.07941, - -2.43731, 2.44464, 1.03961, -1.81936, - 30.33140, 0.92645, + -2.43731, 2.44464, 1.03961, -1.81936, + 30.33140, 0.92645, - 0.00508, -0.01771, + 0.00508, -0.01771, - -81.06338, 66.43957, 33.16729, 131.44697, - 76.63344, -34.34324, -35.33012, -28.04413, - -1.47440, 13.09015, + -81.06338, 66.43957, 33.16729, 131.44697, + 76.63344, -34.34324, -35.33012, -28.04413, + -1.47440, 13.09015, - 0.13253, -0.01629, 0.02187, -0.00963, + 0.13253, -0.01629, 0.02187, -0.00963, - -21.47470, -9.44332, -7.21711, -12.59472, - 1.76195, -1.63911, 0.09060, 0.28656, + -21.47470, -9.44332, -7.21711, -12.59472, + 1.76195, -1.63911, 0.09060, 0.28656, - 0.00635, 0.00536, + 0.00635, 0.00536, - 0.03470, -0.06493, 0.00666, -0.01084, + 0.03470, -0.06493, 0.00666, -0.01084, - 0.01116, -0.01612, -0.00102, 0.00208, + 0.01116, -0.01612, -0.00102, 0.00208, - -0.05568, 0.00628, + -0.05568, 0.00628, - 0.02665, -0.01032, + 0.02665, -0.01032, - 0.21261, -1.90651, 0.72728, -0.57788, - 0.08662, 0.10918, + 0.21261, -1.90651, 0.72728, -0.57788, + 0.08662, 0.10918, - 3.39133, 3.97302, -4.63381, 4.26670, - -2.50873, -3.76064, + 3.39133, 3.97302, -4.63381, 4.26670, + -2.50873, -3.76064, - 1.28114, 1.81919, 1.48064, -0.37578, - -0.26209, -0.47187, + 1.28114, 1.81919, 1.48064, -0.37578, + -0.26209, -0.47187, - 0.00282, -0.00499, + 0.00282, -0.00499, - 0.01749, 0.03222, + 0.01749, 0.03222, - 1.60521, -1.79705, 1.61453, 0.68886, - -0.29909, 0.55025, + 1.60521, -1.79705, 1.61453, 0.68886, + -0.29909, 0.55025, - -0.07894, 0.19880, -0.15635, 0.46159, - 2.09769, 1.52742, + -0.07894, 0.19880, -0.15635, 0.46159, + 2.09769, 1.52742, - -7.60312, 11.34886, 4.35640, 8.61048, - 2.15001, -2.15303, -0.61587, -0.11950, + -7.60312, 11.34886, 4.35640, 8.61048, + 2.15001, -2.15303, -0.61587, -0.11950, - -0.03289, -0.00520, -0.00501, -0.00445, + -0.03289, -0.00520, -0.00501, -0.00445, - 0.15294, -0.05277, 0.02455, 0.00408, + 0.15294, -0.05277, 0.02455, 0.00408, - 1.19601, 0.43479, 0.20422, 0.57125, - -0.12790, 0.01318, + 1.19601, 0.43479, 0.20422, 0.57125, + -0.12790, 0.01318, - -0.15275, -0.43856, 6.99144, -0.08794, + -0.15275, -0.43856, 6.99144, -0.08794, - -1.69865, 0.82589, -0.20235, 0.97040, - 0.20903, 0.00675, + -1.69865, 0.82589, -0.20235, 0.97040, + 0.20903, 0.00675, - 0.26943, 0.08281, 0.03686, 0.05311, + 0.26943, 0.08281, 0.03686, 0.05311, - 1.28468, 1.21735, -1.38174, 1.29570, - -0.75899, -1.17168, + 1.28468, 1.21735, -1.38174, 1.29570, + -0.75899, -1.17168, - 0.44696, -0.32341, -0.06378, -0.27573, + 0.44696, -0.32341, -0.06378, -0.27573, - -0.06406, 0.87186, 0.21069, 0.19724, - 0.00119, -0.04147, + -0.06406, 0.87186, 0.21069, 0.19724, + 0.00119, -0.04147, - 0.39279, 0.51437, -0.11035, 0.21450, + 0.39279, 0.51437, -0.11035, 0.21450, - -0.04309, 0.02359, 0.20490, 0.14210, + -0.04309, 0.02359, 0.20490, 0.14210, - 0.00007, -0.00017, + 0.00007, -0.00017, - -0.03529, -0.02644, + -0.03529, -0.02644, - 0.10710, 0.44476, -0.02632, -0.01817, - 2.11335, -0.04432, + 0.10710, 0.44476, -0.02632, -0.01817, + 2.11335, -0.04432, - 0.18206, 0.27335, 0.08867, 0.00313, + 0.18206, 0.27335, 0.08867, 0.00313, - -0.00692, 0.01595, + -0.00692, 0.01595, - -0.72957, 0.32080, -0.29291, -0.44764, + -0.72957, 0.32080, -0.29291, -0.44764, - 0.12767, -0.05778, 0.04797, -0.00223, + 0.12767, -0.05778, 0.04797, -0.00223, - 0.17661, 0.22427, -0.04914, 0.09114, + 0.17661, 0.22427, -0.04914, 0.09114, - 0.12236, 0.00708, + 0.12236, 0.00708, - 0.74315, -0.01346, + 0.74315, -0.01346, - 0.02245, -0.02555, + 0.02245, -0.02555, - -0.30446, 0.13947, -0.12340, -0.18498, + -0.30446, 0.13947, -0.12340, -0.18498, - -0.04099, 0.02103, + -0.04099, 0.02103, - 0.06337, -0.01224, + 0.06337, -0.01224, - 0.28181, -0.01019, + 0.28181, -0.01019, - -0.02794, -0.09412, + -0.02794, -0.09412, - 0.03272, -0.01095, + 0.03272, -0.01095, - 0.11247, -0.00650, + 0.11247, -0.00650, - -0.01319, -0.04296, + -0.01319, -0.04296, - 0.04653, -0.00423, + 0.04653, -0.00423, - 0.06535, 0.00014, + 0.06535, 0.00014, }; static signed char FAR satargs[] = { - 0, 7, - 3, 2, 5, -6, 6, 3, 7, 0, - 2, 2, 5, -5, 6, 5, - 3, 1, 6, -4, 7, 2, 8, 0, - 2, 1, 6, -3, 7, 0, - 3, 1, 6, -2, 7, -2, 8, 0, - 2, 4, 5,-10, 6, 3, - 3, 1, 5, -1, 6, -4, 7, 0, - 3, 2, 5, -4, 6, -3, 7, 0, - 3, 2, 6, -8, 7, 4, 8, 0, - 3, 3, 5,-10, 6, 7, 7, 0, - 2, 6, 5,-15, 6, 0, - 2, 2, 6, -6, 7, 0, - 3, 1, 5, -4, 6, 4, 7, 1, - 3, 1, 5, -2, 6, -1, 7, 0, - 3, 2, 5, -5, 6, 1, 8, 0, - 3, 3, 5, -8, 6, 2, 7, 0, - 3, 1, 5, -3, 6, 2, 8, 0, - 3, 1, 5, -3, 6, 1, 7, 1, - 1, 1, 8, 0, - 3, 1, 5, -3, 6, 2, 7, 1, - 3, 1, 5, -2, 6, -2, 7, 0, - 2, 2, 6, -5, 7, 1, - 3, 2, 6, -6, 7, 2, 8, 0, - 3, 2, 6, -7, 7, 4, 8, 0, - 3, 2, 5, -4, 6, -2, 7, 0, - 3, 1, 5, -1, 6, -5, 7, 0, - 3, 2, 6, -7, 7, 5, 8, 0, - 3, 1, 6, -1, 7, -2, 8, 0, - 2, 1, 6, -2, 7, 1, - 3, 1, 6, -3, 7, 2, 8, 0, - 3, 1, 6, -4, 7, 4, 8, 1, - 3, 2, 5, -5, 6, 2, 8, 1, - 3, 2, 5, -6, 6, 2, 7, 1, - 2, 2, 7, -2, 8, 0, - 1, 1, 7, 2, - 2, 5, 5,-12, 6, 2, - 3, 2, 6, -5, 7, 1, 8, 0, - 3, 1, 5, -1, 6, -3, 7, 0, - 3, 7, 5,-18, 6, 3, 7, 0, - 2, 3, 5, -7, 6, 3, - 3, 1, 6, 1, 7, -5, 8, 0, - 3, 1, 5, -4, 6, 3, 7, 0, - 3, 5, 5,-13, 6, 3, 7, 0, - 2, 1, 5, -2, 6, 3, - 3, 3, 5, -9, 6, 3, 7, 0, - 3, 3, 5, -8, 6, 3, 7, 1, - 2, 1, 5, -3, 6, 3, - 3, 5, 5,-14, 6, 3, 7, 0, - 3, 1, 5, -3, 6, 3, 7, 2, - 2, 3, 6, -7, 7, 0, - 2, 3, 5, -8, 6, 2, - 3, 2, 5, -3, 6, -4, 7, 1, - 3, 2, 5, -8, 6, 7, 7, 0, - 2, 5, 5,-13, 6, 0, - 2, 2, 6, -4, 7, 2, - 3, 2, 6, -5, 7, 2, 8, 0, - 3, 2, 5, -4, 6, -1, 7, 0, - 3, 2, 5, -7, 6, 4, 7, 0, - 2, 1, 6, -2, 8, 2, - 2, 1, 6, -1, 7, 0, - 3, 1, 6, -2, 7, 2, 8, 0, - 3, 2, 5, -5, 6, 2, 7, 0, - 3, 2, 5, -6, 6, 2, 8, 0, - 3, 2, 5, -6, 6, 1, 7, 0, - 2, 3, 7, -2, 8, 0, - 1, 2, 7, 1, - 2, 1, 6, -1, 8, 1, - 3, 1, 5, -2, 6, 1, 7, 0, - 3, 1, 5, -2, 6, 2, 8, 0, - 2, 3, 6, -6, 7, 2, - 2, 6, 5,-14, 6, 0, - 3, 3, 6, -7, 7, 2, 8, 0, - 3, 2, 5, -3, 6, -3, 7, 1, - 2, 4, 5, -9, 6, 3, - 3, 2, 6, -2, 7, -2, 8, 0, - 2, 2, 6, -3, 7, 1, - 3, 2, 6, -4, 7, 2, 8, 0, - 2, 2, 5, -4, 6, 3, - 3, 2, 5, -7, 6, 3, 7, 1, - 3, 1, 6, 1, 7, -2, 8, 0, - 1, 1, 6, 5, - 3, 2, 5, -5, 6, 3, 7, 1, - 2, 2, 5, -6, 6, 3, - 1, 3, 7, 3, - 2, 4, 5,-11, 6, 3, - 2, 1, 5, -4, 7, 0, - 3, 2, 5, -5, 6, -3, 7, 1, - 2, 6, 5,-16, 6, 0, - 3, 3, 5, -7, 6, 2, 7, 0, - 3, 3, 6, -4, 7, -2, 8, 0, - 2, 3, 6, -5, 7, 1, - 3, 3, 6, -6, 7, 2, 8, 1, - 3, 3, 6, -7, 7, 4, 8, 0, - 3, 2, 5, -3, 6, -2, 7, 2, - 3, 2, 5, -8, 6, 5, 7, 0, - 2, 2, 6, -4, 8, 0, - 3, 2, 6, -1, 7, -2, 8, 1, - 2, 2, 6, -2, 7, 2, - 3, 2, 6, -3, 7, 2, 8, 0, - 3, 2, 5, -4, 6, 1, 7, 0, - 3, 2, 5, -4, 6, 2, 8, 0, - 3, 2, 5, -7, 6, 2, 7, 1, - 2, 1, 6, 1, 7, 1, - 2, 5, 5,-11, 6, 2, - 3, 1, 5, -2, 7, -2, 8, 0, - 2, 1, 5, -3, 7, 0, - 2, 3, 5, -6, 6, 3, - 3, 2, 6, 1, 7, -5, 8, 0, - 2, 2, 6, -3, 8, 1, - 2, 1, 5, -1, 6, 3, - 3, 2, 5, -7, 6, 3, 8, 0, - 3, 3, 5, -7, 6, 3, 7, 0, - 3, 2, 5, -1, 6, -7, 7, 0, - 2, 1, 5, -4, 6, 2, - 3, 1, 5, -2, 6, 3, 7, 0, - 2, 4, 6, -7, 7, 0, - 2, 3, 5, -9, 6, 0, - 3, 2, 5, -2, 6, -4, 7, 0, - 2, 3, 6, -4, 7, 2, - 3, 2, 5, -3, 6, -1, 7, 0, - 3, 2, 5, -8, 6, 4, 7, 0, - 2, 2, 6, -2, 8, 1, - 2, 2, 6, -1, 7, 0, - 3, 2, 6, -2, 7, 2, 8, 1, - 3, 2, 5, -4, 6, 2, 7, 0, - 3, 2, 5, -7, 6, 2, 8, 0, - 3, 2, 5, -7, 6, 1, 7, 0, - 2, 1, 6, 2, 7, 0, - 2, 2, 6, -1, 8, 0, - 2, 4, 6, -6, 7, 1, - 2, 6, 5,-13, 6, 0, - 3, 2, 5, -2, 6, -3, 7, 1, - 2, 4, 5, -8, 6, 2, - 3, 3, 6, -2, 7, -2, 8, 0, - 2, 3, 6, -3, 7, 0, - 3, 3, 6, -4, 7, 2, 8, 0, - 2, 2, 5, -3, 6, 3, - 3, 2, 5, -8, 6, 3, 7, 1, - 3, 2, 6, 1, 7, -2, 8, 0, - 1, 2, 6, 5, - 3, 2, 5, -4, 6, 3, 7, 2, - 2, 2, 5, -7, 6, 3, - 3, 1, 6, 4, 7, -2, 8, 0, - 2, 1, 6, 3, 7, 1, - 3, 1, 6, 2, 7, 2, 8, 0, - 2, 4, 5,-12, 6, 2, - 2, 5, 6, -8, 7, 0, - 2, 4, 6, -5, 7, 0, - 3, 2, 5, -2, 6, -2, 7, 0, - 2, 3, 6, -2, 7, 1, - 3, 3, 6, -3, 7, 2, 8, 0, - 2, 5, 5,-10, 6, 2, - 3, 1, 5, 1, 6, -3, 7, 0, - 2, 3, 5, -5, 6, 3, - 2, 3, 6, -3, 8, 0, - 1, 1, 5, 2, - 2, 1, 5, -5, 6, 2, - 2, 5, 6, -7, 7, 0, - 2, 4, 6, -4, 7, 2, - 2, 3, 6, -2, 8, 0, - 2, 3, 6, -1, 7, 0, - 2, 5, 6, -6, 7, 0, - 2, 4, 5, -7, 6, 2, - 2, 4, 6, -3, 7, 2, - 2, 2, 5, -2, 6, 2, - 3, 2, 6, -9, 7, 3, 8, 0, - 1, 3, 6, 4, - 3, 2, 5, -3, 6, 3, 7, 1, - 2, 2, 5, -8, 6, 3, - 3, 2, 6, 4, 7, -2, 8, 0, - 2, 4, 5,-13, 6, 1, - 2, 6, 6, -8, 7, 1, - 2, 5, 6, -5, 7, 0, - 2, 4, 6, -2, 7, 0, - 2, 5, 5, -9, 6, 2, - 2, 3, 5, -4, 6, 2, - 2, 1, 5, 1, 6, 2, - 2, 6, 5,-11, 6, 0, - 3, 6, 6, -7, 7, 2, 8, 0, - 2, 4, 5, -6, 6, 2, - 2, 2, 5, -1, 6, 2, - 1, 4, 6, 3, - 3, 2, 5, -2, 6, 3, 7, 1, - 2, 2, 5, -9, 6, 1, - 2, 5, 5, -8, 6, 2, - 2, 3, 5, -3, 6, 1, - 2, 1, 5, 2, 6, 2, - 2, 6, 5,-10, 6, 1, - 2, 4, 5, -5, 6, 2, - 1, 2, 5, 1, - 1, 5, 6, 2, - 2, 5, 5, -7, 6, 1, - 2, 3, 5, -2, 6, 1, - 3, 1, 5, 2, 6, 3, 7, 0, - 2, 6, 5, -9, 6, 0, - 2, 4, 5, -4, 6, 2, - 2, 2, 5, 1, 6, 1, - 2, 7, 5,-11, 6, 0, - 2, 5, 5, -6, 6, 1, - 2, 3, 5, -1, 6, 1, - 2, 6, 5, -8, 6, 1, - 2, 4, 5, -3, 6, 0, - 2, 5, 5, -5, 6, 0, - 1, 3, 5, 0, - 2, 6, 5, -7, 6, 1, - 2, 7, 5, -9, 6, 0, - 2, 5, 5, -4, 6, 0, - 2, 6, 5, -6, 6, 0, - 2, 7, 5, -8, 6, 0, - 2, 6, 5, -5, 6, 0, - 2, 7, 5, -7, 6, 0, - 2, 8, 5, -9, 6, 0, - 2, 8, 5, -8, 6, 0, - 2, 1, 3, -1, 6, 0, - -1 + 0, 7, + 3, 2, 5, -6, 6, 3, 7, 0, + 2, 2, 5, -5, 6, 5, + 3, 1, 6, -4, 7, 2, 8, 0, + 2, 1, 6, -3, 7, 0, + 3, 1, 6, -2, 7, -2, 8, 0, + 2, 4, 5, -10, 6, 3, + 3, 1, 5, -1, 6, -4, 7, 0, + 3, 2, 5, -4, 6, -3, 7, 0, + 3, 2, 6, -8, 7, 4, 8, 0, + 3, 3, 5, -10, 6, 7, 7, 0, + 2, 6, 5, -15, 6, 0, + 2, 2, 6, -6, 7, 0, + 3, 1, 5, -4, 6, 4, 7, 1, + 3, 1, 5, -2, 6, -1, 7, 0, + 3, 2, 5, -5, 6, 1, 8, 0, + 3, 3, 5, -8, 6, 2, 7, 0, + 3, 1, 5, -3, 6, 2, 8, 0, + 3, 1, 5, -3, 6, 1, 7, 1, + 1, 1, 8, 0, + 3, 1, 5, -3, 6, 2, 7, 1, + 3, 1, 5, -2, 6, -2, 7, 0, + 2, 2, 6, -5, 7, 1, + 3, 2, 6, -6, 7, 2, 8, 0, + 3, 2, 6, -7, 7, 4, 8, 0, + 3, 2, 5, -4, 6, -2, 7, 0, + 3, 1, 5, -1, 6, -5, 7, 0, + 3, 2, 6, -7, 7, 5, 8, 0, + 3, 1, 6, -1, 7, -2, 8, 0, + 2, 1, 6, -2, 7, 1, + 3, 1, 6, -3, 7, 2, 8, 0, + 3, 1, 6, -4, 7, 4, 8, 1, + 3, 2, 5, -5, 6, 2, 8, 1, + 3, 2, 5, -6, 6, 2, 7, 1, + 2, 2, 7, -2, 8, 0, + 1, 1, 7, 2, + 2, 5, 5, -12, 6, 2, + 3, 2, 6, -5, 7, 1, 8, 0, + 3, 1, 5, -1, 6, -3, 7, 0, + 3, 7, 5, -18, 6, 3, 7, 0, + 2, 3, 5, -7, 6, 3, + 3, 1, 6, 1, 7, -5, 8, 0, + 3, 1, 5, -4, 6, 3, 7, 0, + 3, 5, 5, -13, 6, 3, 7, 0, + 2, 1, 5, -2, 6, 3, + 3, 3, 5, -9, 6, 3, 7, 0, + 3, 3, 5, -8, 6, 3, 7, 1, + 2, 1, 5, -3, 6, 3, + 3, 5, 5, -14, 6, 3, 7, 0, + 3, 1, 5, -3, 6, 3, 7, 2, + 2, 3, 6, -7, 7, 0, + 2, 3, 5, -8, 6, 2, + 3, 2, 5, -3, 6, -4, 7, 1, + 3, 2, 5, -8, 6, 7, 7, 0, + 2, 5, 5, -13, 6, 0, + 2, 2, 6, -4, 7, 2, + 3, 2, 6, -5, 7, 2, 8, 0, + 3, 2, 5, -4, 6, -1, 7, 0, + 3, 2, 5, -7, 6, 4, 7, 0, + 2, 1, 6, -2, 8, 2, + 2, 1, 6, -1, 7, 0, + 3, 1, 6, -2, 7, 2, 8, 0, + 3, 2, 5, -5, 6, 2, 7, 0, + 3, 2, 5, -6, 6, 2, 8, 0, + 3, 2, 5, -6, 6, 1, 7, 0, + 2, 3, 7, -2, 8, 0, + 1, 2, 7, 1, + 2, 1, 6, -1, 8, 1, + 3, 1, 5, -2, 6, 1, 7, 0, + 3, 1, 5, -2, 6, 2, 8, 0, + 2, 3, 6, -6, 7, 2, + 2, 6, 5, -14, 6, 0, + 3, 3, 6, -7, 7, 2, 8, 0, + 3, 2, 5, -3, 6, -3, 7, 1, + 2, 4, 5, -9, 6, 3, + 3, 2, 6, -2, 7, -2, 8, 0, + 2, 2, 6, -3, 7, 1, + 3, 2, 6, -4, 7, 2, 8, 0, + 2, 2, 5, -4, 6, 3, + 3, 2, 5, -7, 6, 3, 7, 1, + 3, 1, 6, 1, 7, -2, 8, 0, + 1, 1, 6, 5, + 3, 2, 5, -5, 6, 3, 7, 1, + 2, 2, 5, -6, 6, 3, + 1, 3, 7, 3, + 2, 4, 5, -11, 6, 3, + 2, 1, 5, -4, 7, 0, + 3, 2, 5, -5, 6, -3, 7, 1, + 2, 6, 5, -16, 6, 0, + 3, 3, 5, -7, 6, 2, 7, 0, + 3, 3, 6, -4, 7, -2, 8, 0, + 2, 3, 6, -5, 7, 1, + 3, 3, 6, -6, 7, 2, 8, 1, + 3, 3, 6, -7, 7, 4, 8, 0, + 3, 2, 5, -3, 6, -2, 7, 2, + 3, 2, 5, -8, 6, 5, 7, 0, + 2, 2, 6, -4, 8, 0, + 3, 2, 6, -1, 7, -2, 8, 1, + 2, 2, 6, -2, 7, 2, + 3, 2, 6, -3, 7, 2, 8, 0, + 3, 2, 5, -4, 6, 1, 7, 0, + 3, 2, 5, -4, 6, 2, 8, 0, + 3, 2, 5, -7, 6, 2, 7, 1, + 2, 1, 6, 1, 7, 1, + 2, 5, 5, -11, 6, 2, + 3, 1, 5, -2, 7, -2, 8, 0, + 2, 1, 5, -3, 7, 0, + 2, 3, 5, -6, 6, 3, + 3, 2, 6, 1, 7, -5, 8, 0, + 2, 2, 6, -3, 8, 1, + 2, 1, 5, -1, 6, 3, + 3, 2, 5, -7, 6, 3, 8, 0, + 3, 3, 5, -7, 6, 3, 7, 0, + 3, 2, 5, -1, 6, -7, 7, 0, + 2, 1, 5, -4, 6, 2, + 3, 1, 5, -2, 6, 3, 7, 0, + 2, 4, 6, -7, 7, 0, + 2, 3, 5, -9, 6, 0, + 3, 2, 5, -2, 6, -4, 7, 0, + 2, 3, 6, -4, 7, 2, + 3, 2, 5, -3, 6, -1, 7, 0, + 3, 2, 5, -8, 6, 4, 7, 0, + 2, 2, 6, -2, 8, 1, + 2, 2, 6, -1, 7, 0, + 3, 2, 6, -2, 7, 2, 8, 1, + 3, 2, 5, -4, 6, 2, 7, 0, + 3, 2, 5, -7, 6, 2, 8, 0, + 3, 2, 5, -7, 6, 1, 7, 0, + 2, 1, 6, 2, 7, 0, + 2, 2, 6, -1, 8, 0, + 2, 4, 6, -6, 7, 1, + 2, 6, 5, -13, 6, 0, + 3, 2, 5, -2, 6, -3, 7, 1, + 2, 4, 5, -8, 6, 2, + 3, 3, 6, -2, 7, -2, 8, 0, + 2, 3, 6, -3, 7, 0, + 3, 3, 6, -4, 7, 2, 8, 0, + 2, 2, 5, -3, 6, 3, + 3, 2, 5, -8, 6, 3, 7, 1, + 3, 2, 6, 1, 7, -2, 8, 0, + 1, 2, 6, 5, + 3, 2, 5, -4, 6, 3, 7, 2, + 2, 2, 5, -7, 6, 3, + 3, 1, 6, 4, 7, -2, 8, 0, + 2, 1, 6, 3, 7, 1, + 3, 1, 6, 2, 7, 2, 8, 0, + 2, 4, 5, -12, 6, 2, + 2, 5, 6, -8, 7, 0, + 2, 4, 6, -5, 7, 0, + 3, 2, 5, -2, 6, -2, 7, 0, + 2, 3, 6, -2, 7, 1, + 3, 3, 6, -3, 7, 2, 8, 0, + 2, 5, 5, -10, 6, 2, + 3, 1, 5, 1, 6, -3, 7, 0, + 2, 3, 5, -5, 6, 3, + 2, 3, 6, -3, 8, 0, + 1, 1, 5, 2, + 2, 1, 5, -5, 6, 2, + 2, 5, 6, -7, 7, 0, + 2, 4, 6, -4, 7, 2, + 2, 3, 6, -2, 8, 0, + 2, 3, 6, -1, 7, 0, + 2, 5, 6, -6, 7, 0, + 2, 4, 5, -7, 6, 2, + 2, 4, 6, -3, 7, 2, + 2, 2, 5, -2, 6, 2, + 3, 2, 6, -9, 7, 3, 8, 0, + 1, 3, 6, 4, + 3, 2, 5, -3, 6, 3, 7, 1, + 2, 2, 5, -8, 6, 3, + 3, 2, 6, 4, 7, -2, 8, 0, + 2, 4, 5, -13, 6, 1, + 2, 6, 6, -8, 7, 1, + 2, 5, 6, -5, 7, 0, + 2, 4, 6, -2, 7, 0, + 2, 5, 5, -9, 6, 2, + 2, 3, 5, -4, 6, 2, + 2, 1, 5, 1, 6, 2, + 2, 6, 5, -11, 6, 0, + 3, 6, 6, -7, 7, 2, 8, 0, + 2, 4, 5, -6, 6, 2, + 2, 2, 5, -1, 6, 2, + 1, 4, 6, 3, + 3, 2, 5, -2, 6, 3, 7, 1, + 2, 2, 5, -9, 6, 1, + 2, 5, 5, -8, 6, 2, + 2, 3, 5, -3, 6, 1, + 2, 1, 5, 2, 6, 2, + 2, 6, 5, -10, 6, 1, + 2, 4, 5, -5, 6, 2, + 1, 2, 5, 1, + 1, 5, 6, 2, + 2, 5, 5, -7, 6, 1, + 2, 3, 5, -2, 6, 1, + 3, 1, 5, 2, 6, 3, 7, 0, + 2, 6, 5, -9, 6, 0, + 2, 4, 5, -4, 6, 2, + 2, 2, 5, 1, 6, 1, + 2, 7, 5, -11, 6, 0, + 2, 5, 5, -6, 6, 1, + 2, 3, 5, -1, 6, 1, + 2, 6, 5, -8, 6, 1, + 2, 4, 5, -3, 6, 0, + 2, 5, 5, -5, 6, 0, + 1, 3, 5, 0, + 2, 6, 5, -7, 6, 1, + 2, 7, 5, -9, 6, 0, + 2, 5, 5, -4, 6, 0, + 2, 6, 5, -6, 6, 0, + 2, 7, 5, -8, 6, 0, + 2, 6, 5, -5, 6, 0, + 2, 7, 5, -7, 6, 0, + 2, 8, 5, -9, 6, 0, + 2, 8, 5, -8, 6, 0, + 2, 1, 3, -1, 6, 0, + -1 }; + /* Total terms = 215, small = 211 */ static struct plantbl FAR sat404 = { - { 0, 0, 1, 0, 8, 18, 9, 5, 0,}, - 7, - satargs, - sattabl, - sattabb, - sattabr, - 9.5575813548599999e+00, + {0, 0, 1, 0, 8, 18, 9, 5, 0,}, + 7, + satargs, + sattabl, + sattabb, + sattabr, + 9.5575813548599999e+00, }; /* @@ -7459,1347 +7479,1350 @@ Days per record = 131.0 3000.0 to 3000.4: 0.406 0.035 0.172 */ static double FAR uratabl[] = { - 21.56000, -4652.06828, 154246324.90417, 1130486.05080, + 21.56000, -4652.06828, 154246324.90417, 1130486.05080, - 330.11531, -3020.20235, + 330.11531, -3020.20235, - -8.03769, -122.02019, + -8.03769, -122.02019, - 212.45130, 254.23866, 25.39758, 60.08296, + 212.45130, 254.23866, 25.39758, 60.08296, - 6949.85053, 51951.42606, -1834.66531, 44481.91144, - -3267.45825, 10776.65972, -628.05388, 532.83011, - -16.80583, -30.05544, + 6949.85053, 51951.42606, -1834.66531, 44481.91144, + -3267.45825, 10776.65972, -628.05388, 532.83011, + -16.80583, -30.05544, - 1420.33767, 2007.21040, 592.32842, 1541.61732, - -163.55984, 121.14134, 114.74969, -16.04944, + 1420.33767, 2007.21040, 592.32842, 1541.61732, + -163.55984, 121.14134, 114.74969, -16.04944, - 0.06069, 0.00725, + 0.06069, 0.00725, - -0.16861, 0.28785, + -0.16861, 0.28785, - 0.07399, -0.09680, + 0.07399, -0.09680, - 0.19936, -0.41620, + 0.19936, -0.41620, - 0.02922, 0.07398, + 0.02922, 0.07398, - 0.17272, 0.05602, + 0.17272, 0.05602, - 1.65461, -0.68278, -2.18745, -0.85327, - 0.52467, -0.30863, + 1.65461, -0.68278, -2.18745, -0.85327, + 0.52467, -0.30863, - 0.01598, 0.30017, + 0.01598, 0.30017, - -0.04190, -0.03288, + -0.04190, -0.03288, - -0.02013, 0.02257, + -0.02013, 0.02257, - -0.54883, -0.22701, -0.09257, -0.03921, + -0.54883, -0.22701, -0.09257, -0.03921, - 0.02644, 0.04667, + 0.02644, 0.04667, - 0.24773, -0.16562, + 0.24773, -0.16562, - 44242.85814, -223163.54065, 123776.84417, -206375.74884, - 70472.73820, -27456.55173, 4065.74401, 13202.39154, - -3260.72648, 802.50579, -153.13236, -503.81026, - 30.17812, -31.91893, + 44242.85814, -223163.54065, 123776.84417, -206375.74884, + 70472.73820, -27456.55173, 4065.74401, 13202.39154, + -3260.72648, 802.50579, -153.13236, -503.81026, + 30.17812, -31.91893, - -65.14719, 77.78417, -37.38185, 19.13337, - -3.14043, -0.21147, + -65.14719, 77.78417, -37.38185, 19.13337, + -3.14043, -0.21147, - 0.27143, 0.17424, + 0.27143, 0.17424, - 0.04458, 0.10976, + 0.04458, 0.10976, - -0.41841, -0.21887, -0.09194, -0.02303, + -0.41841, -0.21887, -0.09194, -0.02303, - 0.02896, 0.10044, + 0.02896, 0.10044, - 0.01385, 0.01723, + 0.01385, 0.01723, - -0.01126, -0.09318, + -0.01126, -0.09318, - -57.95890, 29.69059, -46.41390, 3.07177, - 0.42494, 2.33678, -3.09621, 0.05256, + -57.95890, 29.69059, -46.41390, 3.07177, + 0.42494, 2.33678, -3.09621, 0.05256, - -0.02134, -0.35202, + -0.02134, -0.35202, - -0.44475, -0.83135, + -0.44475, -0.83135, - 1318.18265, 25605.86848, -9168.38371, 18917.31507, - -5145.74480, 2130.77612, -485.25920, -438.44867, - 19.97802, -33.14800, + 1318.18265, 25605.86848, -9168.38371, 18917.31507, + -5145.74480, 2130.77612, -485.25920, -438.44867, + 19.97802, -33.14800, - -23383.91826, -45133.19122, -18520.80729, -26549.95198, - -2276.70124, -2974.01604, 603.23665, 306.87616, - -87.73070, -32.49134, + -23383.91826, -45133.19122, -18520.80729, -26549.95198, + -2276.70124, -2974.01604, 603.23665, 306.87616, + -87.73070, -32.49134, - 549975.14525, 261920.31896, 526261.09735, 362619.26839, - 150616.68873, 164643.90808, 9550.02662, 27381.83042, - -1065.89047, 1024.20231, -66.63822, -44.75169, + 549975.14525, 261920.31896, 526261.09735, 362619.26839, + 150616.68873, 164643.90808, 9550.02662, 27381.83042, + -1065.89047, 1024.20231, -66.63822, -44.75169, - -92.10532, -20.26930, + -92.10532, -20.26930, - -313205.95341, 1462242.64616, 112982.53079, 1865690.41965, - 308844.30901, 639864.93227, 89716.32843, 10378.80773, - 4395.08428, -14565.35913, -3016.07754, -19348.64612, + -313205.95341, 1462242.64616, 112982.53079, 1865690.41965, + 308844.30901, 639864.93227, 89716.32843, 10378.80773, + 4395.08428, -14565.35913, -3016.07754, -19348.64612, - 3838.36899, -9813.42713, 6883.58821, -6064.92588, - 2740.47455, -176.29547, 241.91895, 268.44181, - -6.13397, 17.92503, + 3838.36899, -9813.42713, 6883.58821, -6064.92588, + 2740.47455, -176.29547, 241.91895, 268.44181, + -6.13397, 17.92503, - -0.01377, -0.08742, + -0.01377, -0.08742, - 387.51915, 257.03872, 152.81792, 221.56197, - -22.94836, 29.56640, -2.27801, 4.72805, - -6.03420, -0.36763, + 387.51915, 257.03872, 152.81792, 221.56197, + -22.94836, 29.56640, -2.27801, 4.72805, + -6.03420, -0.36763, - 0.00667, 0.00443, + 0.00667, 0.00443, - -0.01405, 0.04658, + -0.01405, 0.04658, - -0.06533, -0.01966, + -0.06533, -0.01966, - 0.10738, 0.00443, + 0.10738, 0.00443, - 0.02889, 0.01056, + 0.02889, 0.01056, - 0.00900, -0.02206, + 0.00900, -0.02206, - 0.00013, 0.05281, + 0.00013, 0.05281, - 0.03035, 0.34793, + 0.03035, 0.34793, - 0.19460, 2.47360, + 0.19460, 2.47360, - 0.18189, -0.83895, 0.24983, 15.32050, + 0.18189, -0.83895, 0.24983, 15.32050, - 0.46010, 2.79643, + 0.46010, 2.79643, - -0.45793, 0.96707, -0.31226, 0.51911, - 0.04071, 0.39399, + -0.45793, 0.96707, -0.31226, 0.51911, + 0.04071, 0.39399, - 0.00038, 0.03854, + 0.00038, 0.03854, - 0.22446, 0.13630, -0.04357, 0.03635, + 0.22446, 0.13630, -0.04357, 0.03635, - 0.00202, -0.04502, + 0.00202, -0.04502, - -0.00458, -0.03884, + -0.00458, -0.03884, - 1.32597, 3.40849, -1.67839, -0.95411, + 1.32597, 3.40849, -1.67839, -0.95411, - -1.00116, -0.72744, -0.22484, -0.27682, + -1.00116, -0.72744, -0.22484, -0.27682, - -0.18069, 0.00405, + -0.18069, 0.00405, - -0.01000, 0.27523, + -0.01000, 0.27523, - -0.07038, -0.01051, + -0.07038, -0.01051, - -0.09064, 0.08518, + -0.09064, 0.08518, - 0.02083, -0.25406, + 0.02083, -0.25406, - 0.17745, -0.00944, + 0.17745, -0.00944, - 0.21326, 0.20454, + 0.21326, 0.20454, - 18.84894, -7.64400, 0.62670, -11.02728, - 8.91329, 20.67190, + 18.84894, -7.64400, 0.62670, -11.02728, + 8.91329, 20.67190, - 0.17757, -0.15471, + 0.17757, -0.15471, - -0.11385, -0.46057, + -0.11385, -0.46057, - 6.23014, -14.46025, 2.30012, -2.22677, + 6.23014, -14.46025, 2.30012, -2.22677, - 5.16823, -1.64235, + 5.16823, -1.64235, - -274.58413, 833.33247, -191.26241, 269.90157, - -17.25965, 9.11368, + -274.58413, 833.33247, -191.26241, 269.90157, + -17.25965, 9.11368, - -261.65136, -18274.45858, -2553.83872, -10039.10490, - -508.52567, 336.18172, 14.88587, 421.35954, - 162.43462, 544.92580, + -261.65136, -18274.45858, -2553.83872, -10039.10490, + -508.52567, 336.18172, 14.88587, 421.35954, + 162.43462, 544.92580, - -0.44246, 0.23216, + -0.44246, 0.23216, - -0.29024, -0.13057, + -0.29024, -0.13057, - -1.58438, 0.34032, -0.31604, -0.01166, + -1.58438, 0.34032, -0.31604, -0.01166, - -0.07112, 0.05721, + -0.07112, 0.05721, - -0.10813, 0.01064, + -0.10813, 0.01064, - -0.05413, 0.06705, + -0.05413, 0.06705, - -0.41582, -0.47725, 0.31031, 0.08605, + -0.41582, -0.47725, 0.31031, 0.08605, - 0.00409, 0.02373, + 0.00409, 0.02373, - 0.08092, 0.06247, -0.01026, 0.05863, + 0.08092, 0.06247, -0.01026, 0.05863, - -0.00238, 0.02948, + -0.00238, 0.02948, - 0.00117, 0.02714, + 0.00117, 0.02714, - 0.01720, 0.18261, + 0.01720, 0.18261, - -0.04067, 0.88639, + -0.04067, 0.88639, - -0.15502, -0.96383, + -0.15502, -0.96383, - -0.05307, -0.17319, + -0.05307, -0.17319, - -0.00486, -0.02373, + -0.00486, -0.02373, - -0.14748, -0.11884, 0.07798, -0.00358, + -0.14748, -0.11884, 0.07798, -0.00358, - 0.01104, 0.00805, + 0.01104, 0.00805, - 0.15099, -0.03453, 0.01846, 0.03459, + 0.15099, -0.03453, 0.01846, 0.03459, - 0.02197, 0.07012, + 0.02197, 0.07012, - -0.43677, -1.87445, 1.35202, 2.28294, + -0.43677, -1.87445, 1.35202, 2.28294, - -0.03592, 0.07679, + -0.03592, 0.07679, - 0.16427, 0.03014, 0.02472, 0.05549, + 0.16427, 0.03014, 0.02472, 0.05549, - -0.04985, 0.05874, + -0.04985, 0.05874, - 0.35361, 0.01144, -0.57400, 1.34898, + 0.35361, 0.01144, -0.57400, 1.34898, - 0.00265, 0.01540, + 0.00265, 0.01540, - 0.00951, 0.08159, + 0.00951, 0.08159, - -0.00435, 0.34759, + -0.00435, 0.34759, - -0.12413, -0.49848, + -0.12413, -0.49848, - -0.77075, -2.73810, + -0.77075, -2.73810, - -31.77702, 12.16042, -14.87605, 11.98287, - 12.69358, 1.31307, -8.22911, -21.47437, + -31.77702, 12.16042, -14.87605, 11.98287, + 12.69358, 1.31307, -8.22911, -21.47437, - -0.24051, -0.38332, + -0.24051, -0.38332, - -0.01162, -0.03175, + -0.01162, -0.03175, - 0.00556, 0.02454, + 0.00556, 0.02454, - -0.02297, -0.01654, + -0.02297, -0.01654, - 0.00707, 0.04828, + 0.00707, 0.04828, - -0.00309, 0.17381, + -0.00309, 0.17381, - -0.00500, -0.07579, + -0.00500, -0.07579, - 0.02008, 0.05356, + 0.02008, 0.05356, - 0.00702, 0.01133, + 0.00702, 0.01133, - -0.00237, -0.00612, + -0.00237, -0.00612, - 0.18551, 0.22799, -0.14194, -0.08593, + 0.18551, 0.22799, -0.14194, -0.08593, - 0.00002, -0.01049, + 0.00002, -0.01049, - -0.17363, -0.13986, 0.00078, -0.06993, + -0.17363, -0.13986, 0.00078, -0.06993, - -0.00430, -0.07795, + -0.00430, -0.07795, - -0.03232, -4.13170, + -0.03232, -4.13170, - 0.00311, 0.05356, + 0.00311, 0.05356, - -0.17324, -0.15505, -0.00590, -0.06608, + -0.17324, -0.15505, -0.00590, -0.06608, - 0.04257, -0.04571, + 0.04257, -0.04571, - 0.00501, 0.02141, + 0.00501, 0.02141, - -0.00037, 0.07845, + -0.00037, 0.07845, - -0.00381, -0.03417, + -0.00381, -0.03417, - 0.01834, 0.03349, + 0.01834, 0.03349, - 0.07994, 0.15297, + 0.07994, 0.15297, - -0.82299, 0.24672, 0.51764, 0.96379, + -0.82299, 0.24672, 0.51764, 0.96379, - 0.01729, 0.02489, + 0.01729, 0.02489, - -0.08581, 0.13252, + -0.08581, 0.13252, - 0.00538, 0.01995, + 0.00538, 0.01995, - -0.00148, -0.02261, + -0.00148, -0.02261, - 0.00534, 0.01565, + 0.00534, 0.01565, - -0.07518, -0.28114, 0.22386, 0.39023, + -0.07518, -0.28114, 0.22386, 0.39023, - -0.00864, 0.00964, + -0.00864, 0.00964, - -0.01923, -0.02426, + -0.01923, -0.02426, - -0.00112, 0.00923, + -0.00112, 0.00923, - -0.00685, 0.02450, + -0.00685, 0.02450, - 0.26733, -0.99972, -0.82005, 0.13725, + 0.26733, -0.99972, -0.82005, 0.13725, - 0.01520, -0.00790, + 0.01520, -0.00790, - 0.00358, 0.00751, + 0.00358, 0.00751, - -0.00648, -0.00605, + -0.00648, -0.00605, - -0.04966, -0.04633, + -0.04966, -0.04633, - 0.06394, -0.01965, + 0.06394, -0.01965, - 0.50185, 0.40553, -0.25809, 0.28853, - 0.52545, -3.41675, + 0.50185, 0.40553, -0.25809, 0.28853, + 0.52545, -3.41675, - -0.00347, -0.11848, + -0.00347, -0.11848, - 0.02945, -0.01061, + 0.02945, -0.01061, - -0.04160, -0.03519, + -0.04160, -0.03519, - -0.03234, -0.81852, + -0.03234, -0.81852, - -0.02156, -0.00841, + -0.02156, -0.00841, - 0.00029, 0.00020, + 0.00029, 0.00020, - -0.02281, -0.00364, + -0.02281, -0.00364, - 0.04738, -0.04504, + 0.04738, -0.04504, - -0.19161, 0.37225, 0.05765, 0.11987, + -0.19161, 0.37225, 0.05765, 0.11987, - 0.00050, 0.02012, + 0.00050, 0.02012, - -0.03806, 0.39498, + -0.03806, 0.39498, - 0.29982, 0.00886, 0.01671, 53.04042, + 0.29982, 0.00886, 0.01671, 53.04042, - -0.04160, -0.38856, + -0.04160, -0.38856, - -0.00174, -0.01773, + -0.00174, -0.01773, - -0.47661, -0.32010, -0.01088, -0.16231, + -0.47661, -0.32010, -0.01088, -0.16231, - -0.01584, -0.00144, + -0.01584, -0.00144, - 0.06659, 0.12734, + 0.06659, 0.12734, - 0.04884, 0.02236, + 0.04884, 0.02236, - 0.00146, 0.06030, + 0.00146, 0.06030, - -0.20660, -0.03982, 0.15091, 1.24562, + -0.20660, -0.03982, 0.15091, 1.24562, - -0.01303, -0.22426, + -0.01303, -0.22426, - -0.01518, -0.03922, + -0.01518, -0.03922, - -0.00043, -0.00047, + -0.00043, -0.00047, - 0.02451, 0.04437, + 0.02451, 0.04437, - 0.02380, -0.00189, + 0.02380, -0.00189, - -0.00640, -0.07114, + -0.00640, -0.07114, - -0.00320, -0.02491, + -0.00320, -0.02491, - -0.00829, 0.07284, + -0.00829, 0.07284, - 0.02846, -0.28034, + 0.02846, -0.28034, - -0.00268, 0.00256, + -0.00268, 0.00256, - -0.43420, 0.39645, -0.31053, 1.25916, + -0.43420, 0.39645, -0.31053, 1.25916, - -0.00371, -0.00651, + -0.00371, -0.00651, - -0.00096, 0.02762, + -0.00096, 0.02762, - -0.00067, -0.02503, + -0.00067, -0.02503, - -0.01517, 0.03748, + -0.01517, 0.03748, }; + static double FAR uratabb[] = { - 0.00000, 107.91527, 83.39404, -124.29804, + 0.00000, 107.91527, 83.39404, -124.29804, - -7.73277, -3.99442, + -7.73277, -3.99442, - -0.08328, -1.74251, + -0.08328, -1.74251, - -9.05659, -22.88559, -2.30655, -4.40259, + -9.05659, -22.88559, -2.30655, -4.40259, - -470.94604, -3648.43408, 326.28960, -2972.91303, - 337.37285, -650.33570, 57.18479, -18.29130, - 1.13897, 2.70158, + -470.94604, -3648.43408, 326.28960, -2972.91303, + 337.37285, -650.33570, 57.18479, -18.29130, + 1.13897, 2.70158, - -13.64388, -71.88619, 7.36408, -43.79994, - 6.57463, -5.81111, -0.06451, 0.73379, + -13.64388, -71.88619, 7.36408, -43.79994, + 6.57463, -5.81111, -0.06451, 0.73379, - 0.00574, -0.01635, + 0.00574, -0.01635, - 0.00074, -0.01496, + 0.00074, -0.01496, - -0.00418, 0.00647, + -0.00418, 0.00647, - -0.00407, 0.00548, + -0.00407, 0.00548, - 0.00002, 0.00187, + 0.00002, 0.00187, - -0.00591, 0.00557, + -0.00591, 0.00557, - 0.32568, -0.01574, 0.19347, -0.01705, - 0.00173, 0.02384, + 0.32568, -0.01574, 0.19347, -0.01705, + 0.00173, 0.02384, - -0.00248, -0.00103, + -0.00248, -0.00103, - 0.00227, 0.00146, + 0.00227, 0.00146, - 0.00307, -0.00040, + 0.00307, -0.00040, - 0.03886, 0.01987, 0.00546, 0.00345, + 0.03886, 0.01987, 0.00546, 0.00345, - 0.00134, -0.00609, + 0.00134, -0.00609, - -0.01502, -0.01569, + -0.01502, -0.01569, - -10080.59325, 10806.67752, -14013.76861, 9928.38683, - -6540.83480, 2084.91597, -1093.05006, -305.34266, - -9.04558, -110.32310, 9.26094, -3.93195, - 0.25552, 0.50327, + -10080.59325, 10806.67752, -14013.76861, 9928.38683, + -6540.83480, 2084.91597, -1093.05006, -305.34266, + -9.04558, -110.32310, 9.26094, -3.93195, + 0.25552, 0.50327, - -13.12170, -4.19317, -4.50857, -3.37626, - -0.26850, -0.36028, + -13.12170, -4.19317, -4.50857, -3.37626, + -0.26850, -0.36028, - -0.00357, 0.05862, + -0.00357, 0.05862, - -0.00828, 0.00926, + -0.00828, 0.00926, - -0.01515, -0.03687, -0.00224, -0.00802, + -0.01515, -0.03687, -0.00224, -0.00802, - -0.00225, -0.00158, + -0.00225, -0.00158, - -0.00022, -0.00044, + -0.00022, -0.00044, - -0.00281, 0.00371, + -0.00281, 0.00371, - 2.28259, -4.29888, 1.74622, -2.13604, - 0.37023, -0.37022, 0.00886, 0.07081, + 2.28259, -4.29888, 1.74622, -2.13604, + 0.37023, -0.37022, 0.00886, 0.07081, - 0.01669, 0.00056, + 0.01669, 0.00056, - -0.02020, 0.01586, + -0.02020, 0.01586, - -4255.31929, 5978.03267, -7264.48027, 1884.12585, - -2353.93882, -1593.23001, 17.57205, -498.54139, - 33.28704, -13.79498, + -4255.31929, 5978.03267, -7264.48027, 1884.12585, + -2353.93882, -1593.23001, 17.57205, -498.54139, + 33.28704, -13.79498, - -38416.64883, -13774.09664, -32822.03952, -3983.42726, - -7538.09822, 1906.66915, -221.24439, 512.77046, - 32.26101, 12.46483, + -38416.64883, -13774.09664, -32822.03952, -3983.42726, + -7538.09822, 1906.66915, -221.24439, 512.77046, + 32.26101, 12.46483, - 142710.47871, -96584.83892, 145395.05981, -86630.96423, - 48202.96749, -23596.77676, 5286.16967, -1626.44031, - -16.53568, 95.15428, -15.19472, 5.69207, + 142710.47871, -96584.83892, 145395.05981, -86630.96423, + 48202.96749, -23596.77676, 5286.16967, -1626.44031, + -16.53568, 95.15428, -15.19472, 5.69207, - -6.72181, 7.28683, + -6.72181, 7.28683, - 9515.16142, -166495.49381, 5588.84271, -146260.29445, - 2023.55881, -30687.22422, 243.64741, 971.58076, - 390.73247, -236.13754, -2684.56349, 739.81087, + 9515.16142, -166495.49381, 5588.84271, -146260.29445, + 2023.55881, -30687.22422, 243.64741, 971.58076, + 390.73247, -236.13754, -2684.56349, 739.81087, - -597.39429, 474.89313, -631.69166, 213.04947, - -204.89515, -33.09139, -17.78004, -22.21866, - 0.61083, -1.41177, + -597.39429, 474.89313, -631.69166, 213.04947, + -204.89515, -33.09139, -17.78004, -22.21866, + 0.61083, -1.41177, - -0.00070, -0.00501, + -0.00070, -0.00501, - -58.24552, 25.27978, -36.39386, 0.36376, - -2.21030, -6.46685, -0.58473, -0.09357, - 0.12829, -0.94855, + -58.24552, 25.27978, -36.39386, 0.36376, + -2.21030, -6.46685, -0.58473, -0.09357, + 0.12829, -0.94855, - 0.00042, 0.00048, + 0.00042, 0.00048, - 0.00411, 0.00101, + 0.00411, 0.00101, - 0.00249, -0.00865, + 0.00249, -0.00865, - 0.00223, 0.00293, + 0.00223, 0.00293, - 0.00041, -0.00042, + 0.00041, -0.00042, - 0.00104, -0.00086, + 0.00104, -0.00086, - 0.00126, -0.00380, + 0.00126, -0.00380, - 0.00906, -0.02253, + 0.00906, -0.02253, - 0.05998, -0.10318, + 0.05998, -0.10318, - 0.00004, -0.03225, 0.14303, -0.05273, + 0.00004, -0.03225, 0.14303, -0.05273, - 0.32683, 0.09386, + 0.32683, 0.09386, - -0.17053, 0.60847, -0.06190, 0.28166, - 0.06411, 0.05289, + -0.17053, 0.60847, -0.06190, 0.28166, + 0.06411, 0.05289, - 0.01138, 0.00128, + 0.01138, 0.00128, - -0.00930, 0.00272, 0.00037, 0.00215, + -0.00930, 0.00272, 0.00037, 0.00215, - 0.00004, 0.00050, + 0.00004, 0.00050, - 0.00114, -0.00217, + 0.00114, -0.00217, - 0.05358, -0.06413, -0.00124, 0.03842, + 0.05358, -0.06413, -0.00124, 0.03842, - 0.01006, 0.22479, 0.00412, 0.04040, + 0.01006, 0.22479, 0.00412, 0.04040, - 0.01708, 0.02164, + 0.01708, 0.02164, - 0.02484, -0.02463, + 0.02484, -0.02463, - -0.00103, 0.02633, + -0.00103, 0.02633, - -0.01303, -0.03214, + -0.01303, -0.03214, - 0.03613, 0.02205, + 0.03613, 0.02205, - -0.02677, -0.02522, + -0.02677, -0.02522, - -0.00293, 0.03130, + -0.00293, 0.03130, - -1.87255, -2.50308, -1.53715, 0.36859, - -0.17829, -1.12095, + -1.87255, -2.50308, -1.53715, 0.36859, + -0.17829, -1.12095, - -0.05652, -0.00786, + -0.05652, -0.00786, - -0.06992, 0.07279, + -0.06992, 0.07279, - -2.95896, 0.55138, -0.61498, -0.11008, + -2.95896, 0.55138, -0.61498, -0.11008, - -0.87790, -0.50965, + -0.87790, -0.50965, - 119.73553, -35.18217, 44.78683, -4.22438, - 1.95723, 0.58033, + 119.73553, -35.18217, 44.78683, -4.22438, + 1.95723, 0.58033, - -4077.02379, -353.39110, -2781.63273, -75.23318, - -312.50478, -23.86495, 24.59887, 32.56837, - 120.09593, -51.00495, + -4077.02379, -353.39110, -2781.63273, -75.23318, + -312.50478, -23.86495, 24.59887, 32.56837, + 120.09593, -51.00495, - 0.09737, 0.09111, + 0.09737, 0.09111, - 0.04799, -0.05029, + 0.04799, -0.05029, - 0.08351, -0.33726, 0.03158, -0.06435, + 0.08351, -0.33726, 0.03158, -0.06435, - -0.00523, -0.01736, + -0.00523, -0.01736, - 0.00751, -0.01757, + 0.00751, -0.01757, - -0.00406, -0.01198, + -0.00406, -0.01198, - 0.16402, -0.10986, -0.02024, 0.07205, + 0.16402, -0.10986, -0.02024, 0.07205, - -0.00440, -0.00072, + -0.00440, -0.00072, - -0.00465, 0.00310, -0.00121, -0.00121, + -0.00465, 0.00310, -0.00121, -0.00121, - 0.00083, 0.00020, + 0.00083, 0.00020, - 0.00140, -0.00176, + 0.00140, -0.00176, - 0.00381, -0.00731, + 0.00381, -0.00731, - -0.01618, 0.01570, + -0.01618, 0.01570, - -0.10201, 0.05809, + -0.10201, 0.05809, - -0.03359, 0.01024, + -0.03359, 0.01024, - -0.00535, 0.00018, + -0.00535, 0.00018, - 0.00024, 0.00509, -0.00158, -0.00466, + 0.00024, 0.00509, -0.00158, -0.00466, - 0.00009, -0.00083, + 0.00009, -0.00083, - -0.00700, -0.00090, -0.00011, -0.00079, + -0.00700, -0.00090, -0.00011, -0.00079, - 0.00133, -0.00126, + 0.00133, -0.00126, - 0.01416, 0.05553, 0.04283, -0.06719, + 0.01416, 0.05553, 0.04283, -0.06719, - 0.00119, 0.00291, + 0.00119, 0.00291, - -0.00263, 0.01282, -0.00040, 0.00188, + -0.00263, 0.01282, -0.00040, 0.00188, - -0.00237, 0.00973, + -0.00237, 0.00973, - -0.39533, 0.18773, -0.79821, -0.40168, + -0.39533, 0.18773, -0.79821, -0.40168, - 0.00151, -0.00161, + 0.00151, -0.00161, - 0.00123, -0.00516, + 0.00123, -0.00516, - -0.01432, -0.00293, + -0.01432, -0.00293, - -0.05477, 0.04130, + -0.05477, 0.04130, - -0.48837, 0.18944, + -0.48837, 0.18944, - -0.12552, 9.37098, 1.02045, 5.11382, - 0.72098, -3.70049, -5.80982, 3.30105, + -0.12552, 9.37098, 1.02045, 5.11382, + 0.72098, -3.70049, -5.80982, 3.30105, - -0.09682, 0.09696, + -0.09682, 0.09696, - -0.00876, 0.00504, + -0.00876, 0.00504, - 0.00318, 0.00245, + 0.00318, 0.00245, - 0.00563, -0.00665, + 0.00563, -0.00665, - 0.00108, -0.00233, + 0.00108, -0.00233, - -0.00117, 0.00177, + -0.00117, 0.00177, - -0.00343, 0.00503, + -0.00343, 0.00503, - 0.01044, -0.00651, + 0.01044, -0.00651, - 0.00296, -0.00162, + 0.00296, -0.00162, - 0.00037, 0.00028, + 0.00037, 0.00028, - -0.00020, -0.00786, 0.00029, 0.00836, + -0.00020, -0.00786, 0.00029, 0.00836, - 0.00004, 0.00033, + 0.00004, 0.00033, - -0.00309, -0.00086, -0.00157, -0.00086, + -0.00309, -0.00086, -0.00157, -0.00086, - -0.00058, 0.00105, + -0.00058, 0.00105, - -0.04557, 0.01794, + -0.04557, 0.01794, - -0.00122, -0.00086, + -0.00122, -0.00086, - 0.00420, -0.00285, 0.00118, -0.00020, + 0.00420, -0.00285, 0.00118, -0.00020, - 0.00743, -0.01217, + 0.00743, -0.01217, - 0.00053, -0.00084, + 0.00053, -0.00084, - -0.00075, 0.00097, + -0.00075, 0.00097, - -0.00107, 0.00314, + -0.00107, 0.00314, - 0.00576, -0.00505, + 0.00576, -0.00505, - 0.03624, -0.02546, + 0.03624, -0.02546, - 0.05379, 0.30081, 0.29870, -0.22106, + 0.05379, 0.30081, 0.29870, -0.22106, - 0.00696, -0.00801, + 0.00696, -0.00801, - -0.03995, -0.01808, + -0.03995, -0.01808, - -0.00139, 0.00102, + -0.00139, 0.00102, - -0.00059, 0.00138, + -0.00059, 0.00138, - 0.00019, -0.00037, + 0.00019, -0.00037, - 0.00274, 0.00658, 0.00672, -0.01132, + 0.00274, 0.00658, 0.00672, -0.01132, - 0.00023, 0.00051, + 0.00023, 0.00051, - 0.00031, 0.00090, + 0.00031, 0.00090, - -0.00017, -0.00001, + -0.00017, -0.00001, - 0.00085, 0.00004, + 0.00085, 0.00004, - 0.02221, -0.01977, 0.07498, 0.03025, + 0.02221, -0.01977, 0.07498, 0.03025, - -0.00082, -0.00022, + -0.00082, -0.00022, - -0.00073, -0.00028, + -0.00073, -0.00028, - -0.00253, 0.00259, + -0.00253, 0.00259, - -0.01329, 0.01805, + -0.01329, 0.01805, - 0.00096, 0.00833, + 0.00096, 0.00833, - -0.11836, 0.04277, -0.10820, -0.03018, - 0.34504, 0.09834, + -0.11836, 0.04277, -0.10820, -0.03018, + 0.34504, 0.09834, - -0.00538, -0.00231, + -0.00538, -0.00231, - 0.00036, 0.00042, + 0.00036, 0.00042, - -0.00023, 0.00260, + -0.00023, 0.00260, - -0.01137, 0.00036, + -0.01137, 0.00036, - 0.01081, -0.03271, + 0.01081, -0.03271, - -0.00029, -0.00028, + -0.00029, -0.00028, - 0.00018, -0.00003, + 0.00018, -0.00003, - 0.00009, 0.00012, + 0.00009, 0.00012, - 0.00127, 0.00343, 0.00100, -0.00064, + 0.00127, 0.00343, 0.00100, -0.00064, - 0.00014, 0.00004, + 0.00014, 0.00004, - 0.00150, 0.00069, + 0.00150, 0.00069, - -0.01484, 0.00135, 0.03930, 0.01405, + -0.01484, 0.00135, 0.03930, 0.01405, - 0.00064, 0.00029, + 0.00064, 0.00029, - 0.00009, 0.00009, + 0.00009, 0.00009, - 0.00054, -0.00048, 0.00019, 0.00005, + 0.00054, -0.00048, 0.00019, 0.00005, - -0.00009, 0.00018, + -0.00009, 0.00018, - 0.00192, -0.00333, + 0.00192, -0.00333, - 0.01824, 0.01071, + 0.01824, 0.01071, - 0.00107, -0.00341, + 0.00107, -0.00341, - 0.25530, -0.18414, -0.84151, -0.31475, + 0.25530, -0.18414, -0.84151, -0.31475, - -0.00400, -0.00010, + -0.00400, -0.00010, - -0.00174, 0.00019, + -0.00174, 0.00019, - 0.00006, -0.00079, + 0.00006, -0.00079, - 0.00066, -0.00070, + 0.00066, -0.00070, - 0.00599, 0.00330, + 0.00599, 0.00330, - -0.00160, -0.00013, + -0.00160, -0.00013, - -0.00067, -0.00006, + -0.00067, -0.00006, - -0.00176, -0.00111, + -0.00176, -0.00111, - 0.00652, 0.00368, + 0.00652, 0.00368, - 0.00004, 0.00001, + 0.00004, 0.00001, - -0.00081, 0.00089, 0.00366, 0.00139, + -0.00081, 0.00089, 0.00366, 0.00139, - 0.00002, 0.00001, + 0.00002, 0.00001, - -0.01870, -0.00998, + -0.01870, -0.00998, - -0.00020, -0.00007, + -0.00020, -0.00007, - 0.00005, 0.00003, + 0.00005, 0.00003, }; -static double FAR uratabr[] = { - 0.00000, -53.23277, -44.70609, -62.54432, - -19.15218, 0.10867, +static double FAR uratabr[] = { + 0.00000, -53.23277, -44.70609, -62.54432, - -1.91911, 1.47517, + -19.15218, 0.10867, - 16.51994, 5.00458, 3.88980, 1.55740, + -1.91911, 1.47517, - 3598.17109, 1831.07574, 2633.34851, 1775.69482, - 497.10486, 488.77343, 6.03892, 31.08365, - -2.06585, -1.12599, + 16.51994, 5.00458, 3.88980, 1.55740, - 230.37762, -113.95449, 162.40244, -46.57185, - 6.70207, 17.27241, -0.66092, -14.42065, + 3598.17109, 1831.07574, 2633.34851, 1775.69482, + 497.10486, 488.77343, 6.03892, 31.08365, + -2.06585, -1.12599, - -0.01044, -0.00287, + 230.37762, -113.95449, 162.40244, -46.57185, + 6.70207, 17.27241, -0.66092, -14.42065, - -0.03894, -0.01663, + -0.01044, -0.00287, - 0.01629, 0.00496, + -0.03894, -0.01663, - 0.08411, 0.02855, + 0.01629, 0.00496, - 0.01795, -0.00695, + 0.08411, 0.02855, - 0.02426, -0.03921, + 0.01795, -0.00695, - -0.24495, -0.77369, -0.31404, 0.38668, - -0.05682, -0.17197, + 0.02426, -0.03921, - 0.06145, -0.00510, + -0.24495, -0.77369, -0.31404, 0.38668, + -0.05682, -0.17197, - 0.00606, -0.00886, + 0.06145, -0.00510, - -0.00370, -0.00588, + 0.00606, -0.00886, - 0.02173, -0.11909, 0.00302, -0.01796, + -0.00370, -0.00588, - -0.01067, 0.00990, + 0.02173, -0.11909, 0.00302, -0.01796, - 0.05283, 0.06517, + -0.01067, 0.00990, - 59710.89716, -491.12783, 58672.38609, 19564.41947, - 10597.99050, 14313.02561, -2585.52040, 766.78396, - -138.39893, -802.43403, 131.35006, -31.97561, - 7.95978, 8.16075, + 0.05283, 0.06517, - 28.72669, 31.72473, 6.45792, 16.50701, - 0.01066, 1.29718, + 59710.89716, -491.12783, 58672.38609, 19564.41947, + 10597.99050, 14313.02561, -2585.52040, 766.78396, + -138.39893, -802.43403, 131.35006, -31.97561, + 7.95978, 8.16075, - 0.11565, -0.13240, + 28.72669, 31.72473, 6.45792, 16.50701, + 0.01066, 1.29718, - 0.05110, -0.01543, + 0.11565, -0.13240, - -0.09994, 0.18864, -0.01330, 0.04148, + 0.05110, -0.01543, - 0.03510, -0.00366, + -0.09994, 0.18864, -0.01330, 0.04148, - 0.00604, -0.00604, + 0.03510, -0.00366, - 0.03752, -0.00256, + 0.00604, -0.00604, - -7.00488, -21.63748, 1.43064, -17.10914, - -0.62987, 0.48719, 0.00697, -1.22665, + 0.03752, -0.00256, - -0.14435, -0.00550, + -7.00488, -21.63748, 1.43064, -17.10914, + -0.62987, 0.48719, 0.00697, -1.22665, - 0.32008, -0.19855, + -0.14435, -0.00550, - -13976.73731, -3559.49432, -7709.90803, -9310.80334, - 749.31835, -3491.50696, 540.94979, -84.57550, - 16.96663, 35.53930, + 0.32008, -0.19855, - 37214.64771, -36361.15845, 21093.74492, -31855.33076, - 1500.84653, -7031.97901, -453.40865, -18.36692, - -2.07726, -17.92336, + -13976.73731, -3559.49432, -7709.90803, -9310.80334, + 749.31835, -3491.50696, 540.94979, -84.57550, + 16.96663, 35.53930, - -56348.30507, 378512.71483, -111444.43340, 370543.95160, - -61893.70301, 112131.05507, -11977.44617, 9156.15245, - -567.61838, -495.25760, 16.96202, -44.06279, + 37214.64771, -36361.15845, 21093.74492, -31855.33076, + 1500.84653, -7031.97901, -453.40865, -18.36692, + -2.07726, -17.92336, - 4.24760, -48.83674, + -56348.30507, 378512.71483, -111444.43340, 370543.95160, + -61893.70301, 112131.05507, -11977.44617, 9156.15245, + -567.61838, -495.25760, 16.96202, -44.06279, - -643705.49516, -131013.09649, -838580.02217, 67627.11556, - -288441.70339, 150227.25291, -2500.57537, 42676.19888, - 7084.60505, 2043.65642, 9639.56835, -1502.03390, + 4.24760, -48.83674, - -4126.00409, -828.73564, -2801.35204, -2293.77751, - -209.23365, -1045.31476, 95.57334, -102.74623, - 7.19216, 1.89593, + -643705.49516, -131013.09649, -838580.02217, 67627.11556, + -288441.70339, 150227.25291, -2500.57537, 42676.19888, + 7084.60505, 2043.65642, 9639.56835, -1502.03390, - -0.05661, 0.02166, + -4126.00409, -828.73564, -2801.35204, -2293.77751, + -209.23365, -1045.31476, 95.57334, -102.74623, + 7.19216, 1.89593, - 120.38332, -141.16507, 98.31386, -40.23448, - 10.84269, 17.57713, 1.69239, 1.45065, - -0.19626, 2.76108, + -0.05661, 0.02166, - -0.00270, 0.00360, + 120.38332, -141.16507, 98.31386, -40.23448, + 10.84269, 17.57713, 1.69239, 1.45065, + -0.19626, 2.76108, - -0.02333, -0.00710, + -0.00270, 0.00360, - -0.01035, 0.02950, + -0.02333, -0.00710, - 0.00737, -0.06311, + -0.01035, 0.02950, - -0.00613, 0.01407, + 0.00737, -0.06311, - 0.01377, 0.00879, + -0.00613, 0.01407, - -0.03287, 0.00012, + 0.01377, 0.00879, - -0.21667, 0.01793, + -0.03287, 0.00012, - -1.54865, 0.10953, + -0.21667, 0.01793, - 0.54543, 0.12102, -9.48047, 0.11477, + -1.54865, 0.10953, - -1.34966, 0.23199, + 0.54543, 0.12102, -9.48047, 0.11477, - -1.50834, 0.26567, -0.64503, 0.10742, - -0.21452, 0.04428, + -1.34966, 0.23199, - -0.01920, -0.00906, + -1.50834, 0.26567, -0.64503, 0.10742, + -0.21452, 0.04428, - -0.09378, 0.12773, -0.02787, -0.03090, + -0.01920, -0.00906, - 0.03111, 0.00140, + -0.09378, 0.12773, -0.02787, -0.03090, - 0.03771, -0.01269, + 0.03111, 0.00140, - -1.94794, 1.22823, 0.64183, -1.11467, + 0.03771, -0.01269, - -0.19301, -0.27357, 0.05710, -0.08115, + -1.94794, 1.22823, 0.64183, -1.11467, - -0.07318, 0.00806, + -0.19301, -0.27357, 0.05710, -0.08115, - 0.14286, 0.20297, + -0.07318, 0.00806, - 0.14920, -0.07897, + 0.14286, 0.20297, - 0.09682, 0.02379, + 0.14920, -0.07897, - -0.13928, 0.01679, + 0.09682, 0.02379, - -0.00774, 0.10060, + -0.13928, 0.01679, - 0.24433, 0.16760, + -0.00774, 0.10060, - -2.88905, -1.61439, 2.83052, -3.41031, - 36.37048, 3.37867, + 0.24433, 0.16760, - 0.29321, 0.09687, + -2.88905, -1.61439, 2.83052, -3.41031, + 36.37048, 3.37867, - 0.29324, -0.14651, + 0.29321, 0.09687, - 8.11116, 1.79211, 1.36421, 0.88111, + 0.29324, -0.14651, - 1.21683, 2.37950, + 8.11116, 1.79211, 1.36421, 0.88111, - -357.76211, -87.84636, -117.55745, -67.18338, - -5.26029, -6.27559, + 1.21683, 2.37950, - 7509.94562, 3.68942, 4223.62097, -1041.13557, - -74.64464, -251.41613, -166.22180, -1.68190, - -214.55340, 62.79593, + -357.76211, -87.84636, -117.55745, -67.18338, + -5.26029, -6.27559, - -0.08250, -0.15936, + 7509.94562, 3.68942, 4223.62097, -1041.13557, + -74.64464, -251.41613, -166.22180, -1.68190, + -214.55340, 62.79593, - -0.03830, 0.10857, + -0.08250, -0.15936, - 0.21368, 0.50812, 0.00869, 0.09832, + -0.03830, 0.10857, - 0.02158, 0.02045, + 0.21368, 0.50812, 0.00869, 0.09832, - 0.01407, 0.03591, + 0.02158, 0.02045, - 0.03460, 0.01171, + 0.01407, 0.03591, - -0.16400, 0.09751, 0.03521, -0.12858, + 0.03460, 0.01171, - 0.00700, -0.00524, + -0.16400, 0.09751, 0.03521, -0.12858, - 0.01698, -0.04796, 0.04006, 0.00565, + 0.00700, -0.00524, - -0.02783, -0.00205, + 0.01698, -0.04796, 0.04006, 0.00565, - -0.02296, 0.00153, + -0.02783, -0.00205, - -0.16139, 0.01514, + -0.02296, 0.00153, - -0.78136, -0.01546, + -0.16139, 0.01514, - 0.40374, -0.06014, + -0.78136, -0.01546, - 0.06212, -0.01828, + 0.40374, -0.06014, - 0.00831, -0.00173, + 0.06212, -0.01828, - 0.06857, -0.11677, 0.00028, 0.05765, + 0.00831, -0.00173, - -0.00796, 0.00691, + 0.06857, -0.11677, 0.00028, 0.05765, - 0.03764, 0.14902, -0.02653, 0.02122, + -0.00796, 0.00691, - -0.05503, 0.01549, + 0.03764, 0.14902, -0.02653, 0.02122, - 1.56630, -0.35551, -1.87960, 1.14303, + -0.05503, 0.01549, - -0.06063, -0.03425, + 1.56630, -0.35551, -1.87960, 1.14303, - 0.03367, -0.11969, 0.04485, -0.01651, + -0.06063, -0.03425, - 0.04647, -0.02097, + 0.03367, -0.11969, 0.04485, -0.01651, - 0.22841, 0.47362, 0.99226, -0.60660, + 0.04647, -0.02097, - -0.01249, 0.00134, + 0.22841, 0.47362, 0.99226, -0.60660, - -0.07435, 0.00722, + -0.01249, 0.00134, - -0.31796, -0.00015, + -0.07435, 0.00722, - 0.20533, -0.04398, + -0.31796, -0.00015, - 0.93944, -0.26710, + 0.20533, -0.04398, - -5.60051, -9.32918, -5.13538, -4.05130, - -0.56529, 4.34112, 7.18308, -2.66103, + 0.93944, -0.26710, - 0.13241, -0.07999, + -5.60051, -9.32918, -5.13538, -4.05130, + -0.56529, 4.34112, 7.18308, -2.66103, - 0.01046, -0.00535, + 0.13241, -0.07999, - -0.04037, -0.00455, + 0.01046, -0.00535, - -0.00510, 0.00731, + -0.04037, -0.00455, - -0.04576, 0.00513, + -0.00510, 0.00731, - -0.15846, -0.00236, + -0.04576, 0.00513, - 0.04628, -0.00463, + -0.15846, -0.00236, - -0.01585, 0.00585, + 0.04628, -0.00463, - -0.00213, 0.00283, + -0.01585, 0.00585, - 0.00778, -0.00198, + -0.00213, 0.00283, - -0.17803, 0.18321, 0.07702, -0.12325, + 0.00778, -0.00198, - 0.01091, 0.00349, + -0.17803, 0.18321, 0.07702, -0.12325, - 0.14211, -0.21830, 0.07289, -0.00994, + 0.01091, 0.00349, - 0.07090, -0.00079, + 0.14211, -0.21830, 0.07289, -0.00994, - 4.18441, -0.07413, + 0.07090, -0.00079, - -0.06247, -0.00011, + 4.18441, -0.07413, - -0.15453, 0.14499, -0.06557, -0.00098, + -0.06247, -0.00011, - 0.00290, 0.02921, + -0.15453, 0.14499, -0.06557, -0.00098, - -0.01923, 0.00457, + 0.00290, 0.02921, - -0.07538, -0.00120, + -0.01923, 0.00457, - 0.02263, -0.00037, + -0.07538, -0.00120, - -0.01061, 0.00591, + 0.02263, -0.00037, - -0.04725, 0.02364, + -0.01061, 0.00591, - -0.07460, -0.24108, -0.28310, 0.14643, + -0.04725, 0.02364, - -0.00700, 0.00427, + -0.07460, -0.24108, -0.28310, 0.14643, - 0.22963, 0.03713, + -0.00700, 0.00427, - -0.02062, 0.00478, + 0.22963, 0.03713, - 0.01434, 0.00095, + -0.02062, 0.00478, - -0.01425, 0.00376, + 0.01434, 0.00095, - 0.29611, -0.08038, -0.37811, 0.21703, + -0.01425, 0.00376, - -0.00723, -0.00924, + 0.29611, -0.08038, -0.37811, 0.21703, - -0.02736, 0.01814, + -0.00723, -0.00924, - 0.00934, 0.00731, + -0.02736, 0.01814, - 0.00613, 0.00686, + 0.00934, 0.00731, - -0.91503, -0.32009, -0.15505, 0.79589, + 0.00613, 0.00686, - -0.00555, -0.01536, + -0.91503, -0.32009, -0.15505, 0.79589, - -0.00698, 0.00480, + -0.00555, -0.01536, - 0.00373, -0.00046, + -0.00698, 0.00480, - 0.00715, -0.00470, + 0.00373, -0.00046, - -0.01970, -0.05238, + 0.00715, -0.00470, - 0.60649, -0.32669, 0.17790, 0.33383, - -2.74922, -0.25827, + -0.01970, -0.05238, - -0.07862, 0.00406, + 0.60649, -0.32669, 0.17790, 0.33383, + -2.74922, -0.25827, - -0.00948, -0.02117, + -0.07862, 0.00406, - 0.03127, -0.04199, + -0.00948, -0.02117, - 0.89670, -0.02413, + 0.03127, -0.04199, - 0.01954, 0.03990, + 0.89670, -0.02413, - 0.00063, -0.00071, + 0.01954, 0.03990, - -0.00226, 0.02009, + 0.00063, -0.00071, - -0.04407, -0.05069, + -0.00226, 0.02009, - 0.38230, 0.16101, 0.11893, -0.06125, + -0.04407, -0.05069, - 0.02051, -0.00046, + 0.38230, 0.16101, 0.11893, -0.06125, - 0.39211, 0.03679, + 0.02051, -0.00046, - 0.01666, -0.31336, 53.28735, -0.01791, + 0.39211, 0.03679, - -0.39414, 0.04181, + 0.01666, -0.31336, 53.28735, -0.01791, - -0.01885, 0.00165, + -0.39414, 0.04181, - 0.31349, -0.47359, 0.16133, -0.01023, + -0.01885, 0.00165, - 0.00007, 0.01758, + 0.31349, -0.47359, 0.16133, -0.01023, - -0.13351, 0.07249, + 0.00007, 0.01758, - 0.00977, 0.05445, + -0.13351, 0.07249, - 0.11650, -0.00191, + 0.00977, 0.05445, - -0.09824, 0.40106, 2.41155, -0.30655, + 0.11650, -0.00191, - 0.24975, -0.01248, + -0.09824, 0.40106, 2.41155, -0.30655, - -0.03688, 0.01097, + 0.24975, -0.01248, - 0.00038, -0.00051, + -0.03688, 0.01097, - -0.04736, 0.02610, + 0.00038, -0.00051, - 0.00968, 0.02634, + -0.04736, 0.02610, - 0.07918, -0.00606, + 0.00968, 0.02634, - 0.02735, -0.00320, + 0.07918, -0.00606, - -0.07544, -0.00468, + 0.02735, -0.00320, - 0.19996, -0.01964, + -0.07544, -0.00468, - 0.00201, 0.00267, + 0.19996, -0.01964, - 0.39562, 0.43289, 1.24743, 0.31084, + 0.00201, 0.00267, - -0.00666, 0.00377, + 0.39562, 0.43289, 1.24743, 0.31084, - 0.05668, 0.00148, + -0.00666, 0.00377, - 0.03220, -0.00026, + 0.05668, 0.00148, - 0.03717, 0.01509, + 0.03220, -0.00026, + + 0.03717, 0.01509, }; static signed char FAR uraargs[] = { - 0, 3, - 2, 1, 7, -2, 8, 0, - 2, 2, 7, -4, 8, 0, - 2, 3, 7, -6, 8, 1, - 2, 2, 5, -5, 6, 4, - 2, 1, 6, -3, 7, 3, - 3, 1, 6, -1, 7, -4, 8, 0, - 3, 2, 5, -7, 6, 6, 7, 0, - 3, 2, 6, -6, 7, 1, 8, 0, - 3, 2, 6, -7, 7, 3, 8, 0, - 3, 2, 6, -8, 7, 4, 8, 0, - 3, 2, 6, -7, 7, 2, 8, 0, - 2, 2, 6, -6, 7, 2, - 3, 1, 5, -4, 6, 4, 7, 0, - 3, 1, 6, -2, 7, -1, 8, 0, - 3, 1, 6, -3, 7, 1, 8, 0, - 3, 1, 6, -4, 7, 3, 8, 1, - 2, 5, 7, -9, 8, 0, - 2, 4, 7, -7, 8, 0, - 2, 2, 7, -3, 8, 6, - 2, 1, 7, -3, 8, 2, - 2, 2, 7, -5, 8, 0, - 2, 3, 7, -7, 8, 0, - 3, 1, 6, -6, 7, 5, 8, 1, - 3, 1, 6, -5, 7, 3, 8, 0, - 3, 2, 5, -8, 6, 8, 7, 0, - 3, 1, 5, -4, 6, 5, 7, 0, - 2, 2, 6, -5, 7, 3, - 3, 1, 6, 1, 7, -9, 8, 0, - 3, 2, 5, -4, 6, -2, 7, 0, - 2, 1, 6, -4, 8, 4, - 2, 1, 6, -2, 7, 4, - 2, 5, 7, -8, 8, 5, - 2, 3, 7, -4, 8, 0, - 1, 1, 7, 5, - 2, 2, 7, -6, 8, 4, - 3, 1, 6, -6, 7, 4, 8, 0, - 2, 1, 6, -4, 7, 4, - 3, 2, 6, -5, 7, 1, 8, 0, - 3, 2, 6, -6, 7, 3, 8, 0, - 2, 2, 6, -7, 7, 0, - 3, 1, 5, -4, 6, 3, 7, 0, - 3, 1, 6, -1, 7, -1, 8, 0, - 2, 1, 5, -2, 6, 0, - 2, 6, 7, -9, 8, 0, - 2, 5, 7, -7, 8, 0, - 2, 4, 7, -5, 8, 0, - 2, 3, 7, -3, 8, 1, - 2, 2, 7, -1, 8, 0, - 2, 1, 7, 1, 8, 2, - 1, 3, 8, 0, - 2, 3, 6, -7, 7, 1, - 3, 2, 5, -3, 6, -4, 7, 0, - 3, 2, 6, -3, 7, -2, 8, 0, - 2, 2, 6, -4, 7, 1, - 3, 2, 6, -5, 7, 2, 8, 1, - 3, 5, 5, -9, 6, -8, 7, 0, - 3, 2, 5, -4, 6, -1, 7, 0, - 3, 1, 6, 3, 7, -8, 8, 0, - 3, 2, 6, -8, 7, 1, 8, 0, - 3, 2, 5, -7, 6, 4, 7, 0, - 3, 4, 5,-10, 6, 2, 7, 0, - 2, 1, 6, -2, 8, 0, - 2, 1, 6, -1, 7, 2, - 2, 8, 7,-12, 8, 0, - 2, 7, 7,-10, 8, 0, - 2, 6, 7, -8, 8, 1, - 2, 5, 7, -6, 8, 0, - 2, 4, 7, -4, 8, 2, - 1, 2, 7, 4, - 1, 4, 8, 0, - 2, 1, 7, -6, 8, 0, - 2, 2, 7, -8, 8, 1, - 2, 3, 7,-10, 8, 0, - 2, 4, 7,-12, 8, 0, - 3, 1, 6, -6, 7, 2, 8, 0, - 2, 1, 6, -5, 7, 1, - 3, 1, 6, -4, 7, -2, 8, 0, - 3, 1, 5, -4, 6, 2, 7, 1, - 3, 1, 5, -2, 6, 1, 7, 0, - 2, 7, 7, -9, 8, 0, - 2, 6, 7, -7, 8, 0, - 2, 5, 7, -5, 8, 0, - 2, 4, 7, -3, 8, 0, - 2, 3, 7, -1, 8, 0, - 2, 2, 7, 1, 8, 0, - 2, 3, 6, -6, 7, 1, - 3, 3, 6, -7, 7, 2, 8, 0, - 3, 2, 5, -3, 6, -3, 7, 1, - 3, 2, 6, -2, 7, -2, 8, 0, - 2, 2, 6, -3, 7, 1, - 3, 2, 6, -4, 7, 2, 8, 0, - 3, 2, 5, -7, 6, 3, 7, 1, - 3, 1, 6, 1, 7, -2, 8, 0, - 1, 1, 6, 1, - 2, 8, 7,-10, 8, 0, - 2, 7, 7, -8, 8, 0, - 2, 6, 7, -6, 8, 0, - 2, 5, 7, -4, 8, 0, - 2, 4, 7, -2, 8, 0, - 1, 3, 7, 3, - 2, 2, 7, 2, 8, 0, - 2, 1, 7, 4, 8, 0, - 2, 1, 5, -4, 7, 0, - 2, 1, 6, -6, 7, 0, - 2, 8, 7, -9, 8, 0, - 2, 7, 7, -7, 8, 0, - 2, 6, 7, -5, 8, 0, - 2, 5, 7, -3, 8, 0, - 2, 4, 7, -1, 8, 0, - 3, 3, 6, -4, 7, -2, 8, 0, - 2, 3, 6, -5, 7, 1, - 3, 3, 6, -6, 7, 2, 8, 0, - 3, 2, 5, -3, 6, -2, 7, 1, - 3, 2, 6, -1, 7, -2, 8, 0, - 2, 2, 6, -2, 7, 0, - 3, 2, 6, -3, 7, 2, 8, 0, - 3, 2, 5, -7, 6, 2, 7, 1, - 2, 1, 6, 1, 7, 0, - 2, 9, 7,-10, 8, 0, - 2, 8, 7, -8, 8, 0, - 2, 7, 7, -6, 8, 0, - 2, 6, 7, -4, 8, 0, - 2, 5, 7, -2, 8, 0, - 1, 4, 7, 1, - 2, 3, 7, 2, 8, 0, - 2, 1, 5, -3, 7, 0, - 2, 9, 7, -9, 8, 0, - 2, 8, 7, -7, 8, 0, - 3, 3, 6, -3, 7, -2, 8, 0, - 2, 3, 6, -4, 7, 1, - 3, 3, 6, -5, 7, 2, 8, 0, - 3, 2, 5, -3, 6, -1, 7, 0, - 3, 2, 5, -8, 6, 4, 7, 0, - 2, 2, 6, -2, 8, 0, - 2, 2, 6, -1, 7, 1, - 3, 2, 6, -2, 7, 2, 8, 0, - 3, 2, 5, -7, 6, 1, 7, 0, - 2, 6, 7, -2, 8, 0, - 1, 5, 7, 0, - 3, 3, 6, -4, 7, 1, 8, 0, - 2, 1, 5, -2, 7, 2, - 3, 1, 5, -3, 7, 2, 8, 0, - 3, 1, 5, -1, 6, 1, 7, 0, - 2, 4, 6, -6, 7, 0, - 2, 3, 6, -3, 7, 0, - 1, 2, 6, 0, - 3, 2, 5, -4, 6, 3, 7, 0, - 3, 1, 5, 1, 6, -4, 7, 0, - 3, 3, 5, -5, 6, -1, 7, 0, - 1, 6, 7, 1, - 3, 1, 5, 1, 7, -4, 8, 0, - 2, 1, 5, -2, 8, 0, - 2, 1, 5, -1, 7, 1, - 3, 1, 5, -2, 7, 2, 8, 0, - 3, 1, 5, -3, 7, 4, 8, 0, - 3, 1, 5, -5, 6, 1, 7, 1, - 3, 1, 5, -1, 6, 2, 7, 0, - 2, 4, 6, -5, 7, 0, - 2, 3, 6, -2, 7, 0, - 3, 1, 5, 1, 7, -2, 8, 0, - 1, 1, 5, 1, - 2, 4, 6, -4, 7, 0, - 2, 3, 6, -1, 7, 0, - 3, 3, 5, -5, 6, 1, 7, 0, - 2, 5, 6, -6, 7, 0, - 2, 4, 6, -3, 7, 0, - 2, 5, 6, -5, 7, 0, - 2, 6, 6, -6, 7, 0, - 2, 2, 5, -3, 7, 0, - 2, 2, 5, -2, 7, 0, - 2, 2, 5, -2, 8, 0, - 2, 2, 5, -1, 7, 1, - 3, 2, 5, -2, 7, 2, 8, 0, - 1, 2, 5, 0, - 2, 3, 5, -3, 7, 0, - 2, 3, 5, -1, 7, 0, - -1 + 0, 3, + 2, 1, 7, -2, 8, 0, + 2, 2, 7, -4, 8, 0, + 2, 3, 7, -6, 8, 1, + 2, 2, 5, -5, 6, 4, + 2, 1, 6, -3, 7, 3, + 3, 1, 6, -1, 7, -4, 8, 0, + 3, 2, 5, -7, 6, 6, 7, 0, + 3, 2, 6, -6, 7, 1, 8, 0, + 3, 2, 6, -7, 7, 3, 8, 0, + 3, 2, 6, -8, 7, 4, 8, 0, + 3, 2, 6, -7, 7, 2, 8, 0, + 2, 2, 6, -6, 7, 2, + 3, 1, 5, -4, 6, 4, 7, 0, + 3, 1, 6, -2, 7, -1, 8, 0, + 3, 1, 6, -3, 7, 1, 8, 0, + 3, 1, 6, -4, 7, 3, 8, 1, + 2, 5, 7, -9, 8, 0, + 2, 4, 7, -7, 8, 0, + 2, 2, 7, -3, 8, 6, + 2, 1, 7, -3, 8, 2, + 2, 2, 7, -5, 8, 0, + 2, 3, 7, -7, 8, 0, + 3, 1, 6, -6, 7, 5, 8, 1, + 3, 1, 6, -5, 7, 3, 8, 0, + 3, 2, 5, -8, 6, 8, 7, 0, + 3, 1, 5, -4, 6, 5, 7, 0, + 2, 2, 6, -5, 7, 3, + 3, 1, 6, 1, 7, -9, 8, 0, + 3, 2, 5, -4, 6, -2, 7, 0, + 2, 1, 6, -4, 8, 4, + 2, 1, 6, -2, 7, 4, + 2, 5, 7, -8, 8, 5, + 2, 3, 7, -4, 8, 0, + 1, 1, 7, 5, + 2, 2, 7, -6, 8, 4, + 3, 1, 6, -6, 7, 4, 8, 0, + 2, 1, 6, -4, 7, 4, + 3, 2, 6, -5, 7, 1, 8, 0, + 3, 2, 6, -6, 7, 3, 8, 0, + 2, 2, 6, -7, 7, 0, + 3, 1, 5, -4, 6, 3, 7, 0, + 3, 1, 6, -1, 7, -1, 8, 0, + 2, 1, 5, -2, 6, 0, + 2, 6, 7, -9, 8, 0, + 2, 5, 7, -7, 8, 0, + 2, 4, 7, -5, 8, 0, + 2, 3, 7, -3, 8, 1, + 2, 2, 7, -1, 8, 0, + 2, 1, 7, 1, 8, 2, + 1, 3, 8, 0, + 2, 3, 6, -7, 7, 1, + 3, 2, 5, -3, 6, -4, 7, 0, + 3, 2, 6, -3, 7, -2, 8, 0, + 2, 2, 6, -4, 7, 1, + 3, 2, 6, -5, 7, 2, 8, 1, + 3, 5, 5, -9, 6, -8, 7, 0, + 3, 2, 5, -4, 6, -1, 7, 0, + 3, 1, 6, 3, 7, -8, 8, 0, + 3, 2, 6, -8, 7, 1, 8, 0, + 3, 2, 5, -7, 6, 4, 7, 0, + 3, 4, 5, -10, 6, 2, 7, 0, + 2, 1, 6, -2, 8, 0, + 2, 1, 6, -1, 7, 2, + 2, 8, 7, -12, 8, 0, + 2, 7, 7, -10, 8, 0, + 2, 6, 7, -8, 8, 1, + 2, 5, 7, -6, 8, 0, + 2, 4, 7, -4, 8, 2, + 1, 2, 7, 4, + 1, 4, 8, 0, + 2, 1, 7, -6, 8, 0, + 2, 2, 7, -8, 8, 1, + 2, 3, 7, -10, 8, 0, + 2, 4, 7, -12, 8, 0, + 3, 1, 6, -6, 7, 2, 8, 0, + 2, 1, 6, -5, 7, 1, + 3, 1, 6, -4, 7, -2, 8, 0, + 3, 1, 5, -4, 6, 2, 7, 1, + 3, 1, 5, -2, 6, 1, 7, 0, + 2, 7, 7, -9, 8, 0, + 2, 6, 7, -7, 8, 0, + 2, 5, 7, -5, 8, 0, + 2, 4, 7, -3, 8, 0, + 2, 3, 7, -1, 8, 0, + 2, 2, 7, 1, 8, 0, + 2, 3, 6, -6, 7, 1, + 3, 3, 6, -7, 7, 2, 8, 0, + 3, 2, 5, -3, 6, -3, 7, 1, + 3, 2, 6, -2, 7, -2, 8, 0, + 2, 2, 6, -3, 7, 1, + 3, 2, 6, -4, 7, 2, 8, 0, + 3, 2, 5, -7, 6, 3, 7, 1, + 3, 1, 6, 1, 7, -2, 8, 0, + 1, 1, 6, 1, + 2, 8, 7, -10, 8, 0, + 2, 7, 7, -8, 8, 0, + 2, 6, 7, -6, 8, 0, + 2, 5, 7, -4, 8, 0, + 2, 4, 7, -2, 8, 0, + 1, 3, 7, 3, + 2, 2, 7, 2, 8, 0, + 2, 1, 7, 4, 8, 0, + 2, 1, 5, -4, 7, 0, + 2, 1, 6, -6, 7, 0, + 2, 8, 7, -9, 8, 0, + 2, 7, 7, -7, 8, 0, + 2, 6, 7, -5, 8, 0, + 2, 5, 7, -3, 8, 0, + 2, 4, 7, -1, 8, 0, + 3, 3, 6, -4, 7, -2, 8, 0, + 2, 3, 6, -5, 7, 1, + 3, 3, 6, -6, 7, 2, 8, 0, + 3, 2, 5, -3, 6, -2, 7, 1, + 3, 2, 6, -1, 7, -2, 8, 0, + 2, 2, 6, -2, 7, 0, + 3, 2, 6, -3, 7, 2, 8, 0, + 3, 2, 5, -7, 6, 2, 7, 1, + 2, 1, 6, 1, 7, 0, + 2, 9, 7, -10, 8, 0, + 2, 8, 7, -8, 8, 0, + 2, 7, 7, -6, 8, 0, + 2, 6, 7, -4, 8, 0, + 2, 5, 7, -2, 8, 0, + 1, 4, 7, 1, + 2, 3, 7, 2, 8, 0, + 2, 1, 5, -3, 7, 0, + 2, 9, 7, -9, 8, 0, + 2, 8, 7, -7, 8, 0, + 3, 3, 6, -3, 7, -2, 8, 0, + 2, 3, 6, -4, 7, 1, + 3, 3, 6, -5, 7, 2, 8, 0, + 3, 2, 5, -3, 6, -1, 7, 0, + 3, 2, 5, -8, 6, 4, 7, 0, + 2, 2, 6, -2, 8, 0, + 2, 2, 6, -1, 7, 1, + 3, 2, 6, -2, 7, 2, 8, 0, + 3, 2, 5, -7, 6, 1, 7, 0, + 2, 6, 7, -2, 8, 0, + 1, 5, 7, 0, + 3, 3, 6, -4, 7, 1, 8, 0, + 2, 1, 5, -2, 7, 2, + 3, 1, 5, -3, 7, 2, 8, 0, + 3, 1, 5, -1, 6, 1, 7, 0, + 2, 4, 6, -6, 7, 0, + 2, 3, 6, -3, 7, 0, + 1, 2, 6, 0, + 3, 2, 5, -4, 6, 3, 7, 0, + 3, 1, 5, 1, 6, -4, 7, 0, + 3, 3, 5, -5, 6, -1, 7, 0, + 1, 6, 7, 1, + 3, 1, 5, 1, 7, -4, 8, 0, + 2, 1, 5, -2, 8, 0, + 2, 1, 5, -1, 7, 1, + 3, 1, 5, -2, 7, 2, 8, 0, + 3, 1, 5, -3, 7, 4, 8, 0, + 3, 1, 5, -5, 6, 1, 7, 1, + 3, 1, 5, -1, 6, 2, 7, 0, + 2, 4, 6, -5, 7, 0, + 2, 3, 6, -2, 7, 0, + 3, 1, 5, 1, 7, -2, 8, 0, + 1, 1, 5, 1, + 2, 4, 6, -4, 7, 0, + 2, 3, 6, -1, 7, 0, + 3, 3, 5, -5, 6, 1, 7, 0, + 2, 5, 6, -6, 7, 0, + 2, 4, 6, -3, 7, 0, + 2, 5, 6, -5, 7, 0, + 2, 6, 6, -6, 7, 0, + 2, 2, 5, -3, 7, 0, + 2, 2, 5, -2, 7, 0, + 2, 2, 5, -2, 8, 0, + 2, 2, 5, -1, 7, 1, + 3, 2, 5, -2, 7, 2, 8, 0, + 1, 2, 5, 0, + 2, 3, 5, -3, 7, 0, + 2, 3, 5, -1, 7, 0, + -1 }; + /* Total terms = 177, small = 171 */ static struct plantbl FAR ura404 = { - { 0, 0, 0, 0, 5, 10, 9, 12, 0,}, - 6, - uraargs, - uratabl, - uratabb, - uratabr, - 1.9218446061800002e+01, + {0, 0, 0, 0, 5, 10, 9, 12, 0,}, + 6, + uraargs, + uratabl, + uratabb, + uratabr, + 1.9218446061800002e+01, }; /* @@ -8822,443 +8845,446 @@ Days per record = 131.0 3000.0 to 3000.4: 0.122 0.071 0.260 */ static double FAR neptabl[] = { - -1376.86480, 730.38970, 78655362.50948, 1095691.38676, + -1376.86480, 730.38970, 78655362.50948, 1095691.38676, - -196.19023, 2086.77782, + -196.19023, 2086.77782, - -122.04650, -276.81592, + -122.04650, -276.81592, - 184.56164, -148.08924, + 184.56164, -148.08924, - 3.39142, -14.75027, + 3.39142, -14.75027, - -9.22741, 0.87688, + -9.22741, 0.87688, - -0.13903, -0.44707, + -0.13903, -0.44707, - -0.17668, -0.36299, + -0.17668, -0.36299, - -0.12682, -0.26636, + -0.12682, -0.26636, - -0.51426, -0.24667, + -0.51426, -0.24667, - -0.04965, -0.03177, + -0.04965, -0.03177, - 0.05050, -0.00249, + 0.05050, -0.00249, - -0.80362, -0.07363, -0.15436, -0.07180, + -0.80362, -0.07363, -0.15436, -0.07180, - 2.45034, -3.50145, 0.86698, 0.09777, + 2.45034, -3.50145, 0.86698, 0.09777, - 7.72386, 7.16565, 2.10273, 8.86682, + 7.72386, 7.16565, 2.10273, 8.86682, - 2.44705, 77.90155, + 2.44705, 77.90155, - 0.28323, -11.87157, -13.64083, 252.70556, + 0.28323, -11.87157, -13.64083, 252.70556, - -4.94214, -6.17988, -305.60504, 51.23962, - -2759.81719, 2476.20912, + -4.94214, -6.17988, -305.60504, 51.23962, + -2759.81719, 2476.20912, - 12.65762, 13.31543, + 12.65762, 13.31543, - 0.36996, -0.19077, 0.67363, 0.36737, + 0.36996, -0.19077, 0.67363, 0.36737, - 0.02312, 0.02216, + 0.02312, 0.02216, - 0.09953, 0.04777, + 0.09953, 0.04777, - -0.00572, -0.02772, + -0.00572, -0.02772, - -0.02478, -0.21920, + -0.02478, -0.21920, - -0.15289, -1.50784, + -0.15289, -1.50784, - -0.17822, 0.34638, -0.70473, -8.61559, + -0.17822, 0.34638, -0.70473, -8.61559, - -2.65756, 1.25632, + -2.65756, 1.25632, - -0.31453, -1.40348, -4.02571, -1.50467, - -69.62308, 3.21315, + -0.31453, -1.40348, -4.02571, -1.50467, + -69.62308, 3.21315, - 0.69973, 0.08832, + 0.69973, 0.08832, - -0.00551, -0.04964, + -0.00551, -0.04964, - -0.02264, -0.34881, + -0.02264, -0.34881, - 0.00762, -1.85072, + 0.00762, -1.85072, - 0.01407, -0.30457, + 0.01407, -0.30457, - -0.09851, -0.02372, + -0.09851, -0.02372, - -0.07729, -0.11602, -0.75995, -0.71884, + -0.07729, -0.11602, -0.75995, -0.71884, - -0.08585, -0.30406, 0.45818, 0.14921, + -0.08585, -0.30406, 0.45818, 0.14921, - -0.01033, -0.11776, + -0.01033, -0.11776, - 0.00640, -0.57717, + 0.00640, -0.57717, - -0.01014, -0.01357, -0.00544, -0.02168, + -0.01014, -0.01357, -0.00544, -0.02168, - 0.40468, 0.28195, 0.00668, 0.14448, + 0.40468, 0.28195, 0.00668, 0.14448, - 0.01245, -0.08956, + 0.01245, -0.08956, - -0.26283, 0.01864, -0.00641, 18.55347, + -0.26283, 0.01864, -0.00641, 18.55347, - 0.01460, 0.08284, + 0.01460, 0.08284, - -0.04785, 0.11360, + -0.04785, 0.11360, - -0.33861, 0.01327, -0.06392, -0.18758, + -0.33861, 0.01327, -0.06392, -0.18758, - 0.05449, -0.05583, + 0.05449, -0.05583, - -0.00435, -0.09869, + -0.00435, -0.09869, - -0.00286, -0.04613, + -0.00286, -0.04613, - -0.00395, -0.14564, + -0.00395, -0.14564, - -0.01385, -0.01762, + -0.01385, -0.01762, - 0.21160, -0.61631, -0.52100, -0.04583, + 0.21160, -0.61631, -0.52100, -0.04583, - 0.32812, 0.32138, + 0.32812, 0.32138, - 0.04749, -0.05724, + 0.04749, -0.05724, - 0.11239, 0.13216, + 0.11239, 0.13216, - -0.01203, 0.40084, -0.05207, 34.07903, + -0.01203, 0.40084, -0.05207, 34.07903, - -0.21457, -0.34938, -0.04594, 0.11198, + -0.21457, -0.34938, -0.04594, 0.11198, - -0.30662, -0.20776, -0.01076, -0.10959, + -0.30662, -0.20776, -0.01076, -0.10959, - 0.10891, -0.10304, + 0.10891, -0.10304, - -0.28141, 0.25061, -0.20293, 0.79930, + -0.28141, 0.25061, -0.20293, 0.79930, }; + static double FAR neptabb[] = { - -391.05987, -243.95958, -23.83558, 58.13857, + -391.05987, -243.95958, -23.83558, 58.13857, - 5.04859, -3.93183, + 5.04859, -3.93183, - -14.21914, 7.14247, + -14.21914, 7.14247, - -12.09415, -9.70132, + -12.09415, -9.70132, - 1.04307, 0.47323, + 1.04307, 0.47323, - -0.07504, 0.70575, + -0.07504, 0.70575, - -0.05239, 0.00482, + -0.05239, 0.00482, - -0.02916, 0.00877, + -0.02916, 0.00877, - -0.00528, -0.00286, + -0.00528, -0.00286, - 0.00028, -0.00228, + 0.00028, -0.00228, - -0.00056, -0.00149, + -0.00056, -0.00149, - 0.00049, 0.00047, + 0.00049, 0.00047, - -0.18765, -0.59571, 0.03742, -0.14653, + -0.18765, -0.59571, 0.03742, -0.14653, - 2.30535, 0.65092, 0.42216, 0.24521, + 2.30535, 0.65092, 0.42216, 0.24521, - -2.86932, 2.37808, -0.58456, 0.27446, + -2.86932, 2.37808, -0.58456, 0.27446, - -1.12264, -2.04413, + -1.12264, -2.04413, - -11.71318, -1.41554, -23.30671, -24.70499, + -11.71318, -1.41554, -23.30671, -24.70499, - 8.82738, 85.64657, -90.02223, 22.42604, - -4749.41359, -4244.46820, + 8.82738, 85.64657, -90.02223, 22.42604, + -4749.41359, -4244.46820, - 25.20811, -18.51469, + 25.20811, -18.51469, - -1.19892, -0.61067, 0.67734, -1.08912, + -1.19892, -0.61067, 0.67734, -1.08912, - -0.01607, 0.00626, + -0.01607, 0.00626, - -0.00008, 0.00126, + -0.00008, 0.00126, - -0.00330, -0.00078, + -0.00330, -0.00078, - -0.01503, 0.00758, + -0.01503, 0.00758, - -0.13208, -0.00218, + -0.13208, -0.00218, - -0.04522, 0.20297, -0.94708, -0.77897, + -0.04522, 0.20297, -0.94708, -0.77897, - -2.74075, -3.01122, + -2.74075, -3.01122, - -1.03394, 0.00886, 1.55485, -4.68416, - -0.13244, -57.26983, + -1.03394, 0.00886, 1.55485, -4.68416, + -0.13244, -57.26983, - 0.05589, -0.55396, + 0.05589, -0.55396, - -0.00130, 0.00526, + -0.00130, 0.00526, - -0.01028, 0.02086, + -0.01028, 0.02086, - 0.01334, 0.00699, + 0.01334, 0.00699, - 0.08565, 0.02020, + 0.08565, 0.02020, - 0.01001, -0.08402, + 0.01001, -0.08402, - 0.08558, -0.04488, 0.57268, -0.59574, + 0.08558, -0.04488, 0.57268, -0.59574, - 0.00807, 0.00492, 0.21993, -0.18949, + 0.00807, 0.00492, 0.21993, -0.18949, - -0.00396, 0.00735, + -0.00396, 0.00735, - 0.00487, 0.00230, + 0.00487, 0.00230, - 0.00699, -0.00473, 0.01406, -0.00139, + 0.00699, -0.00473, 0.01406, -0.00139, - 0.00738, 0.00099, 0.00161, 0.00019, + 0.00738, 0.00099, 0.00161, 0.00019, - -0.00067, -0.00047, + -0.00067, -0.00047, - 0.00572, -0.00486, -0.00842, 0.00322, + 0.00572, -0.00486, -0.00842, 0.00322, - 0.00018, -0.00109, + 0.00018, -0.00109, - -0.00272, 0.00112, + -0.00272, 0.00112, - -0.00041, 0.00763, 0.00211, 0.00118, + -0.00041, 0.00763, 0.00211, 0.00118, - -0.46842, -0.17877, + -0.46842, -0.17877, - 0.00209, -0.00179, + 0.00209, -0.00179, - 0.00090, -0.00075, + 0.00090, -0.00075, - 0.00618, 0.00610, + 0.00618, 0.00610, - 0.00015, 0.00032, + 0.00015, 0.00032, - -0.00123, 0.00026, 0.00332, 0.00135, + -0.00123, 0.00026, 0.00332, 0.00135, - 0.39130, -0.34727, + 0.39130, -0.34727, - 0.00015, -0.00027, + 0.00015, -0.00027, - -0.00026, -0.00052, + -0.00026, -0.00052, - 0.00162, 0.00913, -0.00697, 0.00308, + 0.00162, 0.00913, -0.00697, 0.00308, - -0.00333, -0.00258, -0.00117, 0.00035, + -0.00333, -0.00258, -0.00117, 0.00035, - 0.00766, 0.00194, 0.00135, 0.00067, + 0.00766, 0.00194, 0.00135, 0.00067, - -0.41171, 0.24241, + -0.41171, 0.24241, - 0.00106, 0.00025, 0.00013, -0.00019, + 0.00106, 0.00025, 0.00013, -0.00019, }; + static double FAR neptabr[] = { - -767.68936, -460.59576, -52.41861, -273.85897, + -767.68936, -460.59576, -52.41861, -273.85897, - 59.52489, 1.85006, + 59.52489, 1.85006, - -39.64750, 23.63348, + -39.64750, 23.63348, - -34.60399, -23.41681, + -34.60399, -23.41681, - 2.74937, 1.55389, + 2.74937, 1.55389, - 0.20343, 2.15502, + 0.20343, 2.15502, - -0.12846, 0.07199, + -0.12846, 0.07199, - -0.07555, 0.05582, + -0.07555, 0.05582, - -0.04354, 0.01546, + -0.04354, 0.01546, - -0.03931, 0.07623, + -0.03931, 0.07623, - -0.00491, 0.00661, + -0.00491, 0.00661, - 0.00322, 0.01540, + 0.00322, 0.01540, - -0.06741, -0.35343, 0.00469, -0.08073, + -0.06741, -0.35343, 0.00469, -0.08073, - 1.94975, 0.66376, 0.06137, 0.31426, + 1.94975, 0.66376, 0.06137, 0.31426, - -2.93841, 4.27732, -4.00342, 1.11157, + -2.93841, 4.27732, -4.00342, 1.11157, - -36.87785, 1.24960, + -36.87785, 1.24960, - 4.69573, 2.15164, -114.24899, -6.69320, + 4.69573, 2.15164, -114.24899, -6.69320, - 12.99919, -9.47795, -21.82350, -156.88624, - -1237.19769, -1379.88864, + 12.99919, -9.47795, -21.82350, -156.88624, + -1237.19769, -1379.88864, - 6.54369, -6.20873, + 6.54369, -6.20873, - -0.14163, -0.32700, 0.17937, -0.34864, + -0.14163, -0.32700, 0.17937, -0.34864, - 0.01393, -0.01286, + 0.01393, -0.01286, - 0.02876, -0.05767, + 0.02876, -0.05767, - 0.02210, -0.00128, + 0.02210, -0.00128, - 0.16495, -0.01242, + 0.16495, -0.01242, - 1.15915, -0.10365, + 1.15915, -0.10365, - -0.33224, -0.10045, 6.83719, -0.27499, + -0.33224, -0.10045, 6.83719, -0.27499, - -0.31284, -0.94332, + -0.31284, -0.94332, - 1.63704, -0.33318, 1.48134, -1.32257, - 0.96498, -8.31047, + 1.63704, -0.33318, 1.48134, -1.32257, + 0.96498, -8.31047, - -0.00402, -0.09441, + -0.00402, -0.09441, - 0.04292, -0.00444, + 0.04292, -0.00444, - 0.30325, -0.02012, + 0.30325, -0.02012, - 1.67999, 0.00353, + 1.67999, 0.00353, - 0.00467, 0.03556, + 0.00467, 0.03556, - 0.01393, -0.01229, + 0.01393, -0.01229, - 0.01188, -0.01390, 0.04615, -0.03509, + 0.01188, -0.01390, 0.04615, -0.03509, - 0.32423, -0.12491, 0.13682, 0.15131, + 0.32423, -0.12491, 0.13682, 0.15131, - 0.11221, -0.01201, + 0.11221, -0.01201, - 0.57239, 0.00093, + 0.57239, 0.00093, - 0.02068, -0.01162, 0.00647, -0.00325, + 0.02068, -0.01162, 0.00647, -0.00325, - 0.27010, -0.42993, 0.14314, -0.01353, + 0.27010, -0.42993, 0.14314, -0.01353, - -0.08757, -0.00699, + -0.08757, -0.00699, - 0.00199, 0.31873, 18.80329, 0.01681, + 0.00199, 0.31873, 18.80329, 0.01681, - 0.08009, -0.00998, + 0.08009, -0.00998, - -0.14421, -0.15912, + -0.14421, -0.15912, - 0.37208, 0.49744, 0.35144, 0.06582, + 0.37208, 0.49744, 0.35144, 0.06582, - -0.11501, -0.14037, + -0.11501, -0.14037, - 0.10352, -0.00768, + 0.10352, -0.00768, - 0.04826, -0.00423, + 0.04826, -0.00423, - 0.19850, 0.00310, + 0.19850, 0.00310, - -0.01780, 0.01350, + -0.01780, 0.01350, - -0.61106, -0.20525, -0.04388, 0.52143, + -0.61106, -0.20525, -0.04388, 0.52143, - 0.19300, -0.21446, + 0.19300, -0.21446, - -0.05749, -0.04776, + -0.05749, -0.04776, - 0.12877, -0.10908, + 0.12877, -0.10908, - 0.39821, 0.00627, 34.03956, 0.04392, + 0.39821, 0.00627, 34.03956, 0.04392, - -0.34455, 0.22015, 0.11743, 0.04638, + -0.34455, 0.22015, 0.11743, 0.04638, - 0.20723, -0.30447, 0.10976, -0.01008, + 0.20723, -0.30447, 0.10976, -0.01008, - -0.20778, -0.21822, + -0.20778, -0.21822, - 0.24939, 0.27976, 0.79790, 0.20200, + 0.24939, 0.27976, 0.79790, 0.20200, }; static signed char FAR nepargs[] = { - 0, 3, - 2, 1, 7, -2, 8, 0, - 3, 3, 5, -8, 6, 3, 8, 0, - 2, 2, 7, -4, 8, 0, - 3, 1, 5, -3, 6, 3, 8, 0, - 2, 3, 7, -6, 8, 0, - 2, 4, 7, -8, 8, 0, - 3, 1, 6, -6, 7, 6, 8, 0, - 3, 1, 6, -5, 7, 4, 8, 0, - 3, 1, 6, -4, 7, 2, 8, 0, - 2, 1, 6, -3, 7, 0, - 3, 1, 6, -2, 7, -1, 8, 0, - 2, 5, 7, -9, 8, 1, - 2, 4, 7, -7, 8, 1, - 2, 3, 7, -5, 8, 1, - 2, 2, 7, -3, 8, 0, - 2, 1, 7, -1, 8, 1, - 1, 1, 8, 2, - 2, 1, 7, -3, 8, 0, - 2, 2, 7, -5, 8, 1, - 3, 1, 6, -6, 7, 5, 8, 0, - 3, 1, 6, -5, 7, 3, 8, 0, - 2, 5, 7, -8, 8, 0, - 2, 4, 7, -6, 8, 0, - 2, 3, 7, -4, 8, 0, - 2, 2, 7, -2, 8, 1, - 1, 1, 7, 0, - 1, 2, 8, 2, - 2, 1, 7, -4, 8, 0, - 2, 5, 7, -7, 8, 0, - 2, 4, 7, -5, 8, 0, - 2, 3, 7, -3, 8, 0, - 2, 2, 7, -1, 8, 0, - 2, 1, 7, 1, 8, 0, - 1, 3, 8, 1, - 2, 1, 6, -2, 8, 1, - 2, 5, 7, -6, 8, 0, - 2, 4, 7, -4, 8, 0, - 1, 4, 8, 1, - 3, 2, 5, -4, 6, -1, 8, 1, - 3, 1, 6, 1, 7, -3, 8, 0, - 2, 1, 6, -1, 8, 1, - 3, 1, 6, -1, 7, 1, 8, 0, - 3, 2, 5, -6, 6, 1, 8, 0, - 2, 5, 7, -5, 8, 1, - 1, 1, 6, 0, - 2, 6, 7, -6, 8, 0, - 2, 7, 7, -7, 8, 0, - 2, 2, 6, -2, 8, 0, - 3, 2, 5, -3, 6, -1, 8, 0, - 2, 2, 6, -1, 8, 1, - 2, 1, 5, -2, 8, 0, - 3, 3, 5, -5, 6, -1, 8, 0, - 2, 4, 7, 5, 8, 0, - 2, 1, 5, -1, 8, 1, - 3, 1, 5, -1, 7, 1, 8, 1, - 3, 1, 5, -5, 6, 1, 8, 1, - 1, 1, 5, 0, - 2, 2, 5, -1, 8, 1, - -1 + 0, 3, + 2, 1, 7, -2, 8, 0, + 3, 3, 5, -8, 6, 3, 8, 0, + 2, 2, 7, -4, 8, 0, + 3, 1, 5, -3, 6, 3, 8, 0, + 2, 3, 7, -6, 8, 0, + 2, 4, 7, -8, 8, 0, + 3, 1, 6, -6, 7, 6, 8, 0, + 3, 1, 6, -5, 7, 4, 8, 0, + 3, 1, 6, -4, 7, 2, 8, 0, + 2, 1, 6, -3, 7, 0, + 3, 1, 6, -2, 7, -1, 8, 0, + 2, 5, 7, -9, 8, 1, + 2, 4, 7, -7, 8, 1, + 2, 3, 7, -5, 8, 1, + 2, 2, 7, -3, 8, 0, + 2, 1, 7, -1, 8, 1, + 1, 1, 8, 2, + 2, 1, 7, -3, 8, 0, + 2, 2, 7, -5, 8, 1, + 3, 1, 6, -6, 7, 5, 8, 0, + 3, 1, 6, -5, 7, 3, 8, 0, + 2, 5, 7, -8, 8, 0, + 2, 4, 7, -6, 8, 0, + 2, 3, 7, -4, 8, 0, + 2, 2, 7, -2, 8, 1, + 1, 1, 7, 0, + 1, 2, 8, 2, + 2, 1, 7, -4, 8, 0, + 2, 5, 7, -7, 8, 0, + 2, 4, 7, -5, 8, 0, + 2, 3, 7, -3, 8, 0, + 2, 2, 7, -1, 8, 0, + 2, 1, 7, 1, 8, 0, + 1, 3, 8, 1, + 2, 1, 6, -2, 8, 1, + 2, 5, 7, -6, 8, 0, + 2, 4, 7, -4, 8, 0, + 1, 4, 8, 1, + 3, 2, 5, -4, 6, -1, 8, 1, + 3, 1, 6, 1, 7, -3, 8, 0, + 2, 1, 6, -1, 8, 1, + 3, 1, 6, -1, 7, 1, 8, 0, + 3, 2, 5, -6, 6, 1, 8, 0, + 2, 5, 7, -5, 8, 1, + 1, 1, 6, 0, + 2, 6, 7, -6, 8, 0, + 2, 7, 7, -7, 8, 0, + 2, 2, 6, -2, 8, 0, + 3, 2, 5, -3, 6, -1, 8, 0, + 2, 2, 6, -1, 8, 1, + 2, 1, 5, -2, 8, 0, + 3, 3, 5, -5, 6, -1, 8, 0, + 2, 4, 7, 5, 8, 0, + 2, 1, 5, -1, 8, 1, + 3, 1, 5, -1, 7, 1, 8, 1, + 3, 1, 5, -5, 6, 1, 8, 1, + 1, 1, 5, 0, + 2, 2, 5, -1, 8, 1, + -1 }; + /* Total terms = 59, small = 58 */ static struct plantbl FAR nep404 = { - { 0, 0, 0, 0, 3, 8, 7, 9, 0,}, - 3, - nepargs, - neptabl, - neptabb, - neptabr, - 3.0110386869399999e+01, + {0, 0, 0, 0, 3, 8, 7, 9, 0,}, + 3, + nepargs, + neptabl, + neptabb, + neptabr, + 3.0110386869399999e+01, }; /* @@ -9281,1362 +9307,1365 @@ Days per record = 131.0 3000.0 to 3000.4: 0.871 0.395 0.051 */ static double FAR plutabl[] = { - 74986469.33577, 100898343.73690, 48199471.54076, 9520076.03177, - 690431.67340, -427355.12716, 52266623.77862, 860190.70714, + 74986469.33577, 100898343.73690, 48199471.54076, 9520076.03177, + 690431.67340, -427355.12716, 52266623.77862, 860190.70714, - -21.08511, -143.39295, + -21.08511, -143.39295, - -126.71124, 48.18528, + -126.71124, 48.18528, - -88.74508, 40.50942, + -88.74508, 40.50942, - 51.29367, -10.24075, + 51.29367, -10.24075, - 0.63094, 32.03258, + 0.63094, 32.03258, - -410.00781, 399.90234, -116.54319, 51.50329, + -410.00781, 399.90234, -116.54319, 51.50329, - 116.84565, 687.76781, -13.38605, 182.70107, + 116.84565, 687.76781, -13.38605, 182.70107, - -1668.12226, -5162.22648, -585.68297, -2247.56041, - -20.95875, -193.13703, + -1668.12226, -5162.22648, -585.68297, -2247.56041, + -20.95875, -193.13703, - -57.12097, -10.35058, + -57.12097, -10.35058, - -1778.01442, -6463.73779, -657.86093, -2713.44436, - -41.32560, -211.82042, + -1778.01442, -6463.73779, -657.86093, -2713.44436, + -41.32560, -211.82042, - -107.16513, -36.58628, + -107.16513, -36.58628, - 97929588.08231, -33582903.63417, 143382679.31770, -47411568.92345, - 79428827.73581, -24658834.87499, 19861233.17488, -5755585.62084, - 1995060.95931, -693507.08147, 135176.31467, 109360.38672, - -8188.00598, -1680.95072, 71020.19608, -70785.39049, + 97929588.08231, -33582903.63417, 143382679.31770, -47411568.92345, + 79428827.73581, -24658834.87499, 19861233.17488, -5755585.62084, + 1995060.95931, -693507.08147, 135176.31467, 109360.38672, + -8188.00598, -1680.95072, 71020.19608, -70785.39049, - -24.56034, -20.34919, + -24.56034, -20.34919, - 1618.45976, -2079.48538, 635.62954, -850.87068, - 44.95257, -64.04459, + 1618.45976, -2079.48538, 635.62954, -850.87068, + 44.95257, -64.04459, - -18.61475, -1.77734, + -18.61475, -1.77734, - 9.38079, 5.19958, + 9.38079, 5.19958, - 17422.08783, -4872.53852, 10985.76629, -1137.68569, - 1771.28893, 288.93745, 40.22664, 37.90027, + 17422.08783, -4872.53852, 10985.76629, -1137.68569, + 1771.28893, 288.93745, 40.22664, 37.90027, - 6.81361, -32.65868, + 6.81361, -32.65868, - 16.97268, 11.76152, + 16.97268, 11.76152, - 29.33024, -12.92289, + 29.33024, -12.92289, - -55.13187, -14.73791, + -55.13187, -14.73791, - 7.52474, -102.05060, + 7.52474, -102.05060, - 182.53144, -20.18960, + 182.53144, -20.18960, - -490237997.49400, 486646248.63360, -781277018.26430, 602300460.57290, - -463787999.46420, 249529525.96100, -123964746.86420, 31353019.97807, - -13353800.92159, -3463382.63269, -35469.17654, -1035343.45385, - 65076.64025, -38181.61312, -16473.33813, 3928.44674, + -490237997.49400, 486646248.63360, -781277018.26430, 602300460.57290, + -463787999.46420, 249529525.96100, -123964746.86420, 31353019.97807, + -13353800.92159, -3463382.63269, -35469.17654, -1035343.45385, + 65076.64025, -38181.61312, -16473.33813, 3928.44674, - 188.60263, 1000.42530, + 188.60263, 1000.42530, - -208376.39376, -700566.62363, 114839.84613, -342407.71113, - 39467.04812, -14553.84849, + -208376.39376, -700566.62363, 114839.84613, -342407.71113, + 39467.04812, -14553.84849, - 581895.26100, 1012499.16715, 406317.22416, 310804.78515, - 43625.07033, -4157.26545, + 581895.26100, 1012499.16715, 406317.22416, 310804.78515, + 43625.07033, -4157.26545, - -5930.13795, -2070.62413, + -5930.13795, -2070.62413, - 3348.17582, -10871.23729, + 3348.17582, -10871.23729, - 144609.18550, 60383.63650, 27912.02226, 15254.61228, + 144609.18550, 60383.63650, 27912.02226, 15254.61228, - -98561.37758, -67442.28158, -15573.63338, -19931.99773, + -98561.37758, -67442.28158, -15573.63338, -19931.99773, - 24323.06905, -37473.32558, 2840.64042, -8911.23694, + 24323.06905, -37473.32558, 2840.64042, -8911.23694, - -19636.31898, 71725.21946, -12280.54554, 12251.00101, + -19636.31898, 71725.21946, -12280.54554, 12251.00101, - 88626.52260, 5513.68450, 18506.41546, -6513.87434, + 88626.52260, 5513.68450, 18506.41546, -6513.87434, - -83350.14621, 44300.00743, -22075.37353, 3731.57531, + -83350.14621, 44300.00743, -22075.37353, 3731.57531, - -29167.76020, -21642.67384, + -29167.76020, -21642.67384, - 56602666.72177, -22225578.01823, 50576897.80669, -50319847.79086, - 5689259.25622, -29585299.79697, -4249711.27661, -4490830.29568, - -727678.08724, 366050.85631, 19183.62792, 55647.98226, + 56602666.72177, -22225578.01823, 50576897.80669, -50319847.79086, + 5689259.25622, -29585299.79697, -4249711.27661, -4490830.29568, + -727678.08724, 366050.85631, 19183.62792, 55647.98226, - 1897.78091, -1091.03988, 432.38158, -138.62556, + 1897.78091, -1091.03988, 432.38158, -138.62556, - 101.38743, 25.67379, + 101.38743, 25.67379, - 320.20735, 362.16615, 85.06067, 54.02616, + 320.20735, 362.16615, 85.06067, 54.02616, - 2.39460, 18.70004, + 2.39460, 18.70004, - -8.43353, 2.72100, + -8.43353, 2.72100, - -3.11205, -3.06201, + -3.11205, -3.06201, - 136.31503, -28.33620, 48.68781, -18.45285, - 1.15302, -1.52360, + 136.31503, -28.33620, 48.68781, -18.45285, + 1.15302, -1.52360, - -0.13706, -0.37489, + -0.13706, -0.37489, - 0.08750, -0.14579, + 0.08750, -0.14579, - -0.07051, -0.06518, + -0.07051, -0.06518, - 0.30237, -0.00448, + 0.30237, -0.00448, - 4.83172, 6.83684, + 4.83172, 6.83684, - 1752447.78043, -945086.75857, 2340978.12819, -1963675.42559, - 1254147.25257, -1274861.91191, 279459.60237, -263954.01378, - 11835.62290, -16344.44434, 9119.98960, -2390.44218, - -23.67909, 86.73916, -642.78635, -1290.12208, + 1752447.78043, -945086.75857, 2340978.12819, -1963675.42559, + 1254147.25257, -1274861.91191, 279459.60237, -263954.01378, + 11835.62290, -16344.44434, 9119.98960, -2390.44218, + -23.67909, 86.73916, -642.78635, -1290.12208, - -0.43345, -1.85348, + -0.43345, -1.85348, - 0.03094, -0.01655, + 0.03094, -0.01655, - 0.12380, 0.31834, + 0.12380, 0.31834, - 5.54756, -1.63109, 1.10598, -0.17578, + 5.54756, -1.63109, 1.10598, -0.17578, - 2.66994, -2.17573, 0.97360, -0.92226, + 2.66994, -2.17573, 0.97360, -0.92226, - -0.18533, -0.39747, + -0.18533, -0.39747, - 0.45809, -0.65286, + 0.45809, -0.65286, - 0.26129, 0.91922, + 0.26129, 0.91922, - 0.81068, 0.11183, + 0.81068, 0.11183, - 6.32182, 14.16786, 0.20872, 3.28489, + 6.32182, 14.16786, 0.20872, 3.28489, - -1.47458, -2.11724, + -1.47458, -2.11724, - 1.70020, -1.99889, + 1.70020, -1.99889, - 3.13003, 1.90638, + 3.13003, 1.90638, - -4483669.52795, -446454.90158, -6586256.67478, -671890.16779, - -3620444.55554, -499672.41074, -855998.32655, -191073.94266, - -73186.69110, -22649.38582, -2414.81729, -1294.40542, - 436.80907, 125.48109, -81.16877, 458.86508, + -4483669.52795, -446454.90158, -6586256.67478, -671890.16779, + -3620444.55554, -499672.41074, -855998.32655, -191073.94266, + -73186.69110, -22649.38582, -2414.81729, -1294.40542, + 436.80907, 125.48109, -81.16877, 458.86508, - -11.57414, -26.39114, -4.00801, -5.01054, + -11.57414, -26.39114, -4.00801, -5.01054, - -18.17569, 20.86879, -4.80965, 3.10535, + -18.17569, 20.86879, -4.80965, 3.10535, - -4.71122, 1.18169, + -4.71122, 1.18169, - 74.75544, 649.21464, -26.55060, 272.35592, - -8.06982, 16.86110, + 74.75544, 649.21464, -26.55060, 272.35592, + -8.06982, 16.86110, - -26.54868, 26.75711, + -26.54868, 26.75711, - -35.82910, 38.51063, + -35.82910, 38.51063, - 22.22814, 19.38336, + 22.22814, 19.38336, - -6.30462, 0.90602, + -6.30462, 0.90602, - 0.62856, -0.34981, + 0.62856, -0.34981, - -0.10232, -0.00939, + -0.10232, -0.00939, - 0.04439, -0.18875, + 0.04439, -0.18875, - 0.16025, 0.11306, + 0.16025, 0.11306, - -0.06803, 0.06004, + -0.06803, 0.06004, - -91305.66728, 262370.61704, -194633.44577, 304838.17733, - -124505.90904, 94111.75602, -22317.18255, 1575.23438, - 748.66316, -349.78711, 166.64450, -89.05045, - 120.76207, -100.26715, + -91305.66728, 262370.61704, -194633.44577, 304838.17733, + -124505.90904, 94111.75602, -22317.18255, 1575.23438, + 748.66316, -349.78711, 166.64450, -89.05045, + 120.76207, -100.26715, - 3.13806, 3.71747, + 3.13806, 3.71747, - -1.44731, -0.35235, + -1.44731, -0.35235, - -0.51660, -1.50621, + -0.51660, -1.50621, - 2.81310, -3.93573, 1.20292, -0.36412, + 2.81310, -3.93573, 1.20292, -0.36412, - -0.03340, -0.00561, + -0.03340, -0.00561, - -5.29764, 26.02941, 1.91382, 3.30686, - -3.35265, -3.20868, + -5.29764, 26.02941, 1.91382, 3.30686, + -3.35265, -3.20868, - 0.05807, -0.11885, + 0.05807, -0.11885, - -0.78588, 0.34807, -0.19038, 0.11295, + -0.78588, 0.34807, -0.19038, 0.11295, - -0.03642, -0.03794, + -0.03642, -0.03794, - 0.00251, 0.03449, + 0.00251, 0.03449, - -0.08426, -0.00310, + -0.08426, -0.00310, - 0.05297, -0.09278, + 0.05297, -0.09278, - 0.10941, 0.00099, + 0.10941, 0.00099, - -228688.56632, 312567.73069, -331458.31119, 328200.19460, - -143760.57524, 104182.01134, -17313.30132, 12591.15513, - -440.32735, -105.67674, 104.35854, -852.84590, - 0.95527, 0.30212, -54.63983, 4.06948, + -228688.56632, 312567.73069, -331458.31119, 328200.19460, + -143760.57524, 104182.01134, -17313.30132, 12591.15513, + -440.32735, -105.67674, 104.35854, -852.84590, + 0.95527, 0.30212, -54.63983, 4.06948, - 0.07545, -0.13429, + 0.07545, -0.13429, - 16.21005, 29.24658, 9.23410, 50.48867, - 30.55641, 12.76809, 0.11781, 0.70929, - -0.04100, 13.60859, + 16.21005, 29.24658, 9.23410, 50.48867, + 30.55641, 12.76809, 0.11781, 0.70929, + -0.04100, 13.60859, - 0.04976, -0.02083, + 0.04976, -0.02083, - 0.36279, 0.30130, -0.02129, 0.09363, + 0.36279, 0.30130, -0.02129, 0.09363, - -0.07812, 0.01570, + -0.07812, 0.01570, - -0.06217, -0.37181, + -0.06217, -0.37181, - -29348.55031, 43889.87672, -35765.41577, 33855.90070, - -10128.69894, 4535.32148, 281.75353, -218.49194, - -7.55224, 134.28640, 2.11319, -2.13109, - 15.71244, 11.07183, + -29348.55031, 43889.87672, -35765.41577, 33855.90070, + -10128.69894, 4535.32148, 281.75353, -218.49194, + -7.55224, 134.28640, 2.11319, -2.13109, + 15.71244, 11.07183, - -0.05406, -0.23337, + -0.05406, -0.23337, - -1.28949, 1.34281, + -1.28949, 1.34281, - 0.04212, -0.02080, + 0.04212, -0.02080, - 0.08109, 0.14820, + 0.08109, 0.14820, - -6010.46564, 3639.41780, -5973.16000, 1381.66999, - -1177.36865, -501.06937, 166.14792, -103.36431, - 14.92766, 4.12877, -2.20893, -6.32033, + -6010.46564, 3639.41780, -5973.16000, 1381.66999, + -1177.36865, -501.06937, 166.14792, -103.36431, + 14.92766, 4.12877, -2.20893, -6.32033, - -0.29038, -0.43172, + -0.29038, -0.43172, - -0.59341, 0.20477, -0.13143, -0.03150, + -0.59341, 0.20477, -0.13143, -0.03150, - 0.10992, 0.01976, + 0.10992, 0.01976, - -0.00254, 0.02028, + -0.00254, 0.02028, - -0.30044, -0.44658, -0.03409, -0.10758, + -0.30044, -0.44658, -0.03409, -0.10758, - 0.08349, 0.06153, + 0.08349, 0.06153, - -0.06055, 0.18249, + -0.06055, 0.18249, - -1.15341, -8.68699, -0.11348, -3.30688, + -1.15341, -8.68699, -0.11348, -3.30688, - 1.08604, 1.04018, + 1.08604, 1.04018, - -0.46892, -0.69765, 0.21504, 0.01968, + -0.46892, -0.69765, 0.21504, 0.01968, - -0.00455, -0.01678, + -0.00455, -0.01678, - 3.95643, -3.17191, 3.95220, -2.12670, - 0.99305, -0.16651, + 3.95643, -3.17191, 3.95220, -2.12670, + 0.99305, -0.16651, - 0.34839, -0.49162, + 0.34839, -0.49162, - 0.85744, 0.20173, -0.00975, 0.20225, + 0.85744, 0.20173, -0.00975, 0.20225, - -0.02627, -0.02281, + -0.02627, -0.02281, - -0.18002, -0.01803, + -0.18002, -0.01803, - -0.06144, -0.21510, + -0.06144, -0.21510, - 0.15935, -0.01251, + 0.15935, -0.01251, - -0.21378, 0.44806, -0.01174, 0.05779, + -0.21378, 0.44806, -0.01174, 0.05779, - 0.07646, -0.19656, -0.04044, -0.02521, + 0.07646, -0.19656, -0.04044, -0.02521, - 0.02996, 0.06169, + 0.02996, 0.06169, - 0.16698, -0.04710, -0.06506, -0.02114, + 0.16698, -0.04710, -0.06506, -0.02114, - 0.05500, 0.00276, + 0.05500, 0.00276, - 0.08433, 0.03160, + 0.08433, 0.03160, - 0.08193, 0.35773, 0.05454, 0.10718, + 0.08193, 0.35773, 0.05454, 0.10718, - -0.02823, -0.00839, + -0.02823, -0.00839, - 0.54078, 0.49347, 0.09609, 0.11825, + 0.54078, 0.49347, 0.09609, 0.11825, - -0.16092, -0.11897, + -0.16092, -0.11897, - 0.09059, 0.08254, + 0.09059, 0.08254, - 0.16712, 0.05860, + 0.16712, 0.05860, - -0.09547, -0.03206, + -0.09547, -0.03206, - 0.03876, 0.04719, + 0.03876, 0.04719, - -0.02345, 0.02240, + -0.02345, 0.02240, - -0.00609, -0.00649, + -0.00609, -0.00649, - 0.03859, 0.00077, + 0.03859, 0.00077, - 0.47819, 0.26196, 0.09780, 0.08104, + 0.47819, 0.26196, 0.09780, 0.08104, - -0.16919, 0.05042, + -0.16919, 0.05042, - -0.42652, 0.30810, + -0.42652, 0.30810, - -0.03409, -0.51452, + -0.03409, -0.51452, - -0.23120, -0.01380, + -0.23120, -0.01380, - -0.01157, -0.00143, + -0.01157, -0.00143, - -0.00512, -0.01628, + -0.00512, -0.01628, - -0.00189, 0.00183, + -0.00189, 0.00183, - -0.01427, -0.02861, + -0.01427, -0.02861, - 0.00618, -0.00015, + 0.00618, -0.00015, - 0.13087, 0.13870, + 0.13087, 0.13870, - 0.15158, -0.21056, + 0.15158, -0.21056, - -3.94829, -1.06028, -1.36602, 0.77954, + -3.94829, -1.06028, -1.36602, 0.77954, - 0.08709, -0.03118, + 0.08709, -0.03118, - -44.74949, 91.17393, 8.78173, 45.84010, - 1.97560, -15.02849, -0.10755, -0.02884, - 3.38670, 0.30615, + -44.74949, 91.17393, 8.78173, 45.84010, + 1.97560, -15.02849, -0.10755, -0.02884, + 3.38670, 0.30615, - 130.92778, -24.33209, 43.01636, -40.81327, - -19.43900, 22.18162, -0.12691, 0.33795, - -6.44790, -6.23145, + 130.92778, -24.33209, 43.01636, -40.81327, + -19.43900, 22.18162, -0.12691, 0.33795, + -6.44790, -6.23145, - 0.00319, 0.01141, + 0.00319, 0.01141, - -0.03252, 0.03872, + -0.03252, 0.03872, - 0.04467, 0.01614, + 0.04467, 0.01614, - -0.00382, -0.00019, + -0.00382, -0.00019, - 0.05955, 0.01533, + 0.05955, 0.01533, - 16.11371, 41.37565, 61.44963, 6.90615, - 1.41326, -0.73920, -0.03871, 24.81978, + 16.11371, 41.37565, 61.44963, 6.90615, + 1.41326, -0.73920, -0.03871, 24.81978, - -0.10229, -0.32775, -0.05188, -0.05628, + -0.10229, -0.32775, -0.05188, -0.05628, - -2.33618, 2.39053, + -2.33618, 2.39053, - -0.00584, 0.00436, + -0.00584, 0.00436, - 0.20903, 0.02220, + 0.20903, 0.02220, - -0.01738, -0.02765, + -0.01738, -0.02765, - -0.00217, 0.00613, + -0.00217, 0.00613, - -0.01772, 0.01903, + -0.01772, 0.01903, - 0.07075, -0.00530, + 0.07075, -0.00530, - 0.15234, -0.37760, -0.11641, -0.20102, + 0.15234, -0.37760, -0.11641, -0.20102, - -0.63675, 0.20525, -0.15783, 0.58945, + -0.63675, 0.20525, -0.15783, 0.58945, - -0.06243, 0.04306, + -0.06243, 0.04306, }; + static double FAR plutabb[] = { - -35042727.30412, -49049197.81293, -25374963.60995, -5761406.03035, - -467370.57540, 14040.11453, 2329.15763, -13978.69390, + -35042727.30412, -49049197.81293, -25374963.60995, -5761406.03035, + -467370.57540, 14040.11453, 2329.15763, -13978.69390, - 45.43441, 29.70305, + 45.43441, 29.70305, - 32.33772, -38.34012, + 32.33772, -38.34012, - 26.43575, -28.76136, + 26.43575, -28.76136, - -18.59040, 12.64837, + -18.59040, 12.64837, - 5.56569, -12.51581, + 5.56569, -12.51581, - 248.37350, -64.44466, 54.02618, 4.39466, + 248.37350, -64.44466, 54.02618, 4.39466, - -269.35114, -290.63134, -48.03841, -52.83576, + -269.35114, -290.63134, -48.03841, -52.83576, - 1508.94995, 1682.78967, 554.02336, 715.65819, - 34.37602, 58.44397, + 1508.94995, 1682.78967, 554.02336, 715.65819, + 34.37602, 58.44397, - 16.63685, 16.10176, + 16.63685, 16.10176, - -1069.51609, 2300.89166, -437.16796, 927.89245, - -33.17679, 68.74495, + -1069.51609, 2300.89166, -437.16796, 927.89245, + -33.17679, 68.74495, - 18.72022, 32.97640, + 18.72022, 32.97640, - -34004958.12619, -17758805.77098, -48416073.75788, -24973405.03542, - -25374996.23732, -13351084.97340, -5738294.54942, -3082092.63350, - -519989.39256, -206440.89101, 44186.23548, -87639.22630, - 2506.47602, 2327.01164, -53878.47903, -19670.13471, + -34004958.12619, -17758805.77098, -48416073.75788, -24973405.03542, + -25374996.23732, -13351084.97340, -5738294.54942, -3082092.63350, + -519989.39256, -206440.89101, 44186.23548, -87639.22630, + 2506.47602, 2327.01164, -53878.47903, -19670.13471, - 2.66934, -3.86086, + 2.66934, -3.86086, - 106.32427, 576.47944, 46.56388, 218.28339, - 4.35402, 15.04642, + 106.32427, 576.47944, 46.56388, 218.28339, + 4.35402, 15.04642, - 2.68717, -2.86835, + 2.68717, -2.86835, - 0.81728, -2.34417, + 0.81728, -2.34417, - -1604.85823, -1999.24986, -631.47343, -1382.19156, - -15.74075, -256.97077, 6.99648, -4.54257, + -1604.85823, -1999.24986, -631.47343, -1382.19156, + -15.74075, -256.97077, 6.99648, -4.54257, - 2.63478, 1.88838, + 2.63478, 1.88838, - 0.17628, -2.11518, + 0.17628, -2.11518, - -2.46735, -1.48743, + -2.46735, -1.48743, - 1.83456, 4.68487, + 1.83456, 4.68487, - -7.10919, 3.57046, + -7.10919, 3.57046, - -5.36342, -7.70367, + -5.36342, -7.70367, - 28395956.20816, -37176795.74372, 48969952.83034, -48145798.96248, - 31155823.23557, -21163596.14822, 9057634.38260, -3167688.51696, - 1167488.70078, 219103.97591, -19017.97335, 107849.61195, - -3814.43474, 4405.92120, 5800.13959, 12619.88708, + 28395956.20816, -37176795.74372, 48969952.83034, -48145798.96248, + 31155823.23557, -21163596.14822, 9057634.38260, -3167688.51696, + 1167488.70078, 219103.97591, -19017.97335, 107849.61195, + -3814.43474, 4405.92120, 5800.13959, 12619.88708, - 22.18168, -89.47801, + 22.18168, -89.47801, - 52202.81929, 55119.44083, 5082.58907, 37955.06062, - -3165.24355, 3316.67588, + 52202.81929, 55119.44083, 5082.58907, 37955.06062, + -3165.24355, 3316.67588, - -113906.43970, -69279.41495, -57358.07767, -10176.17329, - -4179.79867, 2495.99374, + -113906.43970, -69279.41495, -57358.07767, -10176.17329, + -4179.79867, 2495.99374, - 787.87180, -154.35591, + 787.87180, -154.35591, - -1148.62509, 1034.58199, + -1148.62509, 1034.58199, - -22194.95235, 3341.97949, -4578.53994, 108.30832, + -22194.95235, 3341.97949, -4578.53994, 108.30832, - 7444.39789, 16646.40725, 509.75430, 3808.92686, + 7444.39789, 16646.40725, 509.75430, 3808.92686, - -179.85869, 7408.76716, 340.65366, 1504.64227, + -179.85869, 7408.76716, 340.65366, 1504.64227, - -3783.09873, -13505.60867, 875.74489, -3181.27898, + -3783.09873, -13505.60867, 875.74489, -3181.27898, - -16220.93983, 8041.37347, -2631.07448, 2899.50781, + -16220.93983, 8041.37347, -2631.07448, 2899.50781, - 18894.92095, -20072.81471, 5925.05701, -1947.91902, + 18894.92095, -20072.81471, 5925.05701, -1947.91902, - -6731.56601, 8014.52403, + -6731.56601, 8014.52403, - -987793.49463, 6491762.34471, -279205.73643, 6117135.96868, - -140925.91402, 2259422.06929, 114028.61646, 605600.90358, - 91858.00186, 56506.65187, 8949.15777, -9782.67413, + -987793.49463, 6491762.34471, -279205.73643, 6117135.96868, + -140925.91402, 2259422.06929, 114028.61646, 605600.90358, + 91858.00186, 56506.65187, 8949.15777, -9782.67413, - -394.66541, -105.19208, -76.54752, -32.59411, + -394.66541, -105.19208, -76.54752, -32.59411, - -19.28741, 10.40013, + -19.28741, 10.40013, - -107.64003, -7.36229, -22.25126, 4.05952, + -107.64003, -7.36229, -22.25126, 4.05952, - -3.74402, -2.79308, + -3.74402, -2.79308, - 1.03337, -2.13968, + 1.03337, -2.13968, - 1.53794, -0.02617, + 1.53794, -0.02617, - 35.70756, 12.97733, 14.46213, 6.20518, - 1.79381, 1.65422, + 35.70756, 12.97733, 14.46213, 6.20518, + 1.79381, 1.65422, - -0.31216, 0.29053, + -0.31216, 0.29053, - -0.03538, -0.01584, + -0.03538, -0.01584, - -0.08934, 0.00079, + -0.08934, 0.00079, - 0.05539, -0.21591, + 0.05539, -0.21591, - 2.86929, -2.24724, + 2.86929, -2.24724, - 320797.07455, 93342.16556, -20903.39115, 79523.22083, - -226588.37473, -121017.23944, -48472.25935, -74195.36778, - -7962.48081, -4607.76339, -4597.33274, -7983.12541, - -20.34500, 56.82999, -1038.19507, 619.69624, + 320797.07455, 93342.16556, -20903.39115, 79523.22083, + -226588.37473, -121017.23944, -48472.25935, -74195.36778, + -7962.48081, -4607.76339, -4597.33274, -7983.12541, + -20.34500, 56.82999, -1038.19507, 619.69624, - 1.08907, -0.91278, + 1.08907, -0.91278, - -0.13391, 0.34956, + -0.13391, 0.34956, - -0.19982, -0.18296, + -0.19982, -0.18296, - -0.97688, 2.36806, -0.30127, 0.50980, + -0.97688, 2.36806, -0.30127, 0.50980, - 0.96103, 1.96432, 0.43338, 0.87317, + 0.96103, 1.96432, 0.43338, 0.87317, - 0.36997, -0.01583, + 0.36997, -0.01583, - -0.44692, -0.25159, + -0.44692, -0.25159, - -0.53525, 0.01154, + -0.53525, 0.01154, - -0.13231, 0.35562, + -0.13231, 0.35562, - 3.88928, -4.02882, 1.06967, -0.56305, + 3.88928, -4.02882, 1.06967, -0.56305, - -0.45204, 0.77213, + -0.45204, 0.77213, - -0.82873, -0.25854, + -0.82873, -0.25854, - 0.21136, -1.06696, + 0.21136, -1.06696, - 458529.05491, 616790.47568, 698431.01349, 1124501.41713, - 300226.10339, 766533.33698, 26896.22954, 207880.75720, - 1116.29607, 21793.26153, -850.64044, 3528.95568, - 29.61278, -120.13367, 376.95131, 66.45758, + 458529.05491, 616790.47568, 698431.01349, 1124501.41713, + 300226.10339, 766533.33698, 26896.22954, 207880.75720, + 1116.29607, 21793.26153, -850.64044, 3528.95568, + 29.61278, -120.13367, 376.95131, 66.45758, - -3.64868, 2.76062, -0.85352, 0.95115, + -3.64868, 2.76062, -0.85352, 0.95115, - 5.35056, 2.52803, 0.90026, 0.76403, + 5.35056, 2.52803, 0.90026, 0.76403, - 0.43191, 0.83605, + 0.43191, 0.83605, - 125.81792, -39.65364, 50.14425, -5.75891, - 2.78555, 2.05055, + 125.81792, -39.65364, 50.14425, -5.75891, + 2.78555, 2.05055, - -4.27266, -4.92428, + -4.27266, -4.92428, - 6.78868, 5.73537, + 6.78868, 5.73537, - 3.35229, -3.70143, + 3.35229, -3.70143, - 0.08488, 1.07465, + 0.08488, 1.07465, - 0.10227, 0.06074, + 0.10227, 0.06074, - 0.00291, 0.01522, + 0.00291, 0.01522, - -0.02274, 0.00297, + -0.02274, 0.00297, - 0.01095, -0.01856, + 0.01095, -0.01856, - -0.02862, 0.00178, + -0.02862, 0.00178, - 143640.07486, 707.21331, 177163.08586, 53386.52697, - 56856.89297, 48268.74645, 1764.52814, 7711.76224, - 352.34159, -968.03169, -45.16568, -81.60481, - -76.35993, -98.06932, + 143640.07486, 707.21331, 177163.08586, 53386.52697, + 56856.89297, 48268.74645, 1764.52814, 7711.76224, + 352.34159, -968.03169, -45.16568, -81.60481, + -76.35993, -98.06932, - -1.42185, 1.81425, + -1.42185, 1.81425, - -0.23427, 0.59023, + -0.23427, 0.59023, - 0.57127, -0.36335, + 0.57127, -0.36335, - 1.89975, 0.66890, 0.28797, 0.43592, + 1.89975, 0.66890, 0.28797, 0.43592, - -0.03769, 0.03273, + -0.03769, 0.03273, - -6.06571, -2.68515, -0.55315, 0.86977, - 1.53840, -0.59422, + -6.06571, -2.68515, -0.55315, 0.86977, + 1.53840, -0.59422, - -0.05453, 0.02447, + -0.05453, 0.02447, - -0.12658, 0.22814, -0.01715, 0.08497, + -0.12658, 0.22814, -0.01715, 0.08497, - -0.01288, -0.00606, + -0.01288, -0.00606, - 0.01547, -0.00692, + 0.01547, -0.00692, - 0.01157, 0.02407, + 0.01157, 0.02407, - -0.03883, 0.00835, + -0.03883, 0.00835, - -0.01542, -0.04761, + -0.01542, -0.04761, - 174386.39024, 158048.26273, 159192.81681, 220154.55148, - 33716.11953, 87537.86597, -116.90381, 7535.83928, - -962.06994, -132.28837, -644.90482, -110.52332, - 3.42499, 3.74660, -0.94008, 41.55548, + 174386.39024, 158048.26273, 159192.81681, 220154.55148, + 33716.11953, 87537.86597, -116.90381, 7535.83928, + -962.06994, -132.28837, -644.90482, -110.52332, + 3.42499, 3.74660, -0.94008, 41.55548, - -0.03824, -0.05607, + -0.03824, -0.05607, - 28.74787, -37.31399, 30.87853, -26.11940, - 10.79742, -5.97905, 1.01237, -0.04429, - 0.54402, 0.41905, + 28.74787, -37.31399, 30.87853, -26.11940, + 10.79742, -5.97905, 1.01237, -0.04429, + 0.54402, 0.41905, - -0.02440, -0.03991, + -0.02440, -0.03991, - -0.00347, -0.04362, -0.00347, -0.00469, + -0.00347, -0.04362, -0.00347, -0.00469, - -0.02707, 0.02761, + -0.02707, 0.02761, - -0.17773, -0.11789, + -0.17773, -0.11789, - 26475.02580, 35363.04345, 19877.11475, 41430.35940, - 2948.09998, 12983.41406, 281.93744, 570.70054, - 147.83157, 16.00090, -1.62814, -8.30846, - 9.29131, -10.16496, + 26475.02580, 35363.04345, 19877.11475, 41430.35940, + 2948.09998, 12983.41406, 281.93744, 570.70054, + 147.83157, 16.00090, -1.62814, -8.30846, + 9.29131, -10.16496, - -0.15799, 0.03843, + -0.15799, 0.03843, - 1.44716, 0.46953, + 1.44716, 0.46953, - -0.02150, -0.02502, + -0.02150, -0.02502, - 0.08861, -0.06690, + 0.08861, -0.06690, - 2237.41551, 3739.08722, 753.74867, 3460.41553, - -298.69226, 520.47031, -33.62615, -138.12767, - 3.61843, -8.29860, -4.56656, 0.79553, + 2237.41551, 3739.08722, 753.74867, 3460.41553, + -298.69226, 520.47031, -33.62615, -138.12767, + 3.61843, -8.29860, -4.56656, 0.79553, - 0.20041, -0.25771, + 0.20041, -0.25771, - -0.35233, -0.27913, -0.02799, -0.08328, + -0.35233, -0.27913, -0.02799, -0.08328, - -0.06889, -0.16853, + -0.06889, -0.16853, - 0.01701, -0.00964, + 0.01701, -0.00964, - -0.37737, 0.18030, -0.08525, 0.01906, + -0.37737, 0.18030, -0.08525, 0.01906, - 0.05236, -0.05155, + 0.05236, -0.05155, - 0.11320, 0.05991, + 0.11320, 0.05991, - -5.66926, -0.54402, -2.08508, -0.39407, + -5.66926, -0.54402, -2.08508, -0.39407, - 0.82155, -0.55975, + 0.82155, -0.55975, - 0.39168, -0.25551, 0.00623, 0.16162, + 0.39168, -0.25551, 0.00623, 0.16162, - -0.02519, 0.02420, + -0.02519, 0.02420, - -1.23293, -3.19649, -0.60519, -2.79729, - 0.05362, -0.61569, + -1.23293, -3.19649, -0.60519, -2.79729, + 0.05362, -0.61569, - -0.25638, -0.27033, + -0.25638, -0.27033, - -0.03987, 0.46623, -0.12070, 0.00643, + -0.03987, 0.46623, -0.12070, 0.00643, - 0.00849, -0.00768, + 0.00849, -0.00768, - -0.03687, 0.10445, + -0.03687, 0.10445, - -0.13544, -0.00592, + -0.13544, -0.00592, - 0.02078, 0.09172, + 0.02078, 0.09172, - 0.15824, 0.15815, 0.02020, 0.00747, + 0.15824, 0.15815, 0.02020, 0.00747, - 0.10919, 0.09553, 0.01953, -0.00135, + 0.10919, 0.09553, 0.01953, -0.00135, - 0.04266, -0.00218, + 0.04266, -0.00218, - 0.02182, -0.13742, -0.01249, 0.01724, + 0.02182, -0.13742, -0.01249, 0.01724, - -0.02200, 0.02975, + -0.02200, 0.02975, - -0.01401, 0.03416, + -0.01401, 0.03416, - -0.28873, 0.04235, -0.08137, 0.04223, + -0.28873, 0.04235, -0.08137, 0.04223, - -0.00326, 0.02144, + -0.00326, 0.02144, - -0.40423, 0.14281, -0.08256, 0.02142, + -0.40423, 0.14281, -0.08256, 0.02142, - 0.08116, -0.03680, + 0.08116, -0.03680, - -0.02324, 0.07260, + -0.02324, 0.07260, - -0.06746, 0.11645, + -0.06746, 0.11645, - 0.03233, -0.05997, + 0.03233, -0.05997, - -0.03101, 0.02197, + -0.03101, 0.02197, - -0.00896, -0.00491, + -0.00896, -0.00491, - 0.00574, 0.00855, + 0.00574, 0.00855, - 0.00052, 0.01209, + 0.00052, 0.01209, - -0.31828, 0.29955, -0.08133, 0.04318, + -0.31828, 0.29955, -0.08133, 0.04318, - 0.06787, -0.08865, + 0.06787, -0.08865, - -0.13228, -0.06507, + -0.13228, -0.06507, - 0.34008, 0.06417, + 0.34008, 0.06417, - -0.00177, -0.15116, + -0.00177, -0.15116, - -0.00553, -0.01950, + -0.00553, -0.01950, - 0.01144, -0.00309, + 0.01144, -0.00309, - -0.00115, -0.00153, + -0.00115, -0.00153, - 0.02063, -0.00791, + 0.02063, -0.00791, - -0.00314, 0.00493, + -0.00314, 0.00493, - -0.10614, 0.08338, + -0.10614, 0.08338, - 0.08845, 0.20168, + 0.08845, 0.20168, - 1.38955, -2.52285, -0.30475, -1.05787, + 1.38955, -2.52285, -0.30475, -1.05787, - 0.00580, 0.06623, + 0.00580, 0.06623, - -44.33263, -47.70073, -29.80583, -8.77838, - 7.02948, 2.77221, 0.05248, -0.13702, - -0.78176, 1.77489, + -44.33263, -47.70073, -29.80583, -8.77838, + 7.02948, 2.77221, 0.05248, -0.13702, + -0.78176, 1.77489, - -16.32831, 46.68457, 2.54516, 21.78145, - -5.09080, -8.42611, -0.24419, -0.03315, - 2.80629, -1.12755, + -16.32831, 46.68457, 2.54516, 21.78145, + -5.09080, -8.42611, -0.24419, -0.03315, + 2.80629, -1.12755, - -0.00402, 0.00053, + -0.00402, 0.00053, - 0.00024, -0.00043, + 0.00024, -0.00043, - 0.00403, -0.00210, + 0.00403, -0.00210, - 0.00603, 0.00411, + 0.00603, 0.00411, - -0.00260, 0.00416, + -0.00260, 0.00416, - 2.29235, 3.05992, 2.36465, -0.58750, - 0.14030, 0.13523, 0.89998, 0.70156, + 2.29235, 3.05992, 2.36465, -0.58750, + 0.14030, 0.13523, 0.89998, 0.70156, - -0.02188, 0.02003, -0.00533, 0.00447, + -0.02188, 0.02003, -0.00533, 0.00447, - 2.96411, 1.30183, + 2.96411, 1.30183, - 0.01422, 0.00624, + 0.01422, 0.00624, - -0.10737, -0.38316, + -0.10737, -0.38316, - -0.05968, 0.04379, + -0.05968, 0.04379, - 0.01171, 0.01180, + 0.01171, 0.01180, - -0.00989, -0.01375, + -0.00989, -0.01375, - -0.00845, 0.03782, + -0.00845, 0.03782, - 0.09484, 0.09909, 0.07640, -0.00898, + 0.09484, 0.09909, 0.07640, -0.00898, - -0.01076, 0.02760, 0.01630, 0.02198, + -0.01076, 0.02760, 0.01630, 0.02198, - 0.05985, 0.04130, + 0.05985, 0.04130, }; + static double FAR plutabr[] = { - 17990649.12487, 24806479.30874, 12690953.00645, 2892671.69562, - 249947.71316, -5138.71425, 1142.68629, 6075.25751, + 17990649.12487, 24806479.30874, 12690953.00645, 2892671.69562, + 249947.71316, -5138.71425, 1142.68629, 6075.25751, - -34.76785, -19.72399, + -34.76785, -19.72399, - -15.81516, 30.47718, + -15.81516, 30.47718, - -11.73638, 21.87955, + -11.73638, 21.87955, - 9.42107, -10.40957, + 9.42107, -10.40957, - -5.59670, 6.85778, + -5.59670, 6.85778, - -167.06735, -2.31999, -32.42575, -13.72714, + -167.06735, -2.31999, -32.42575, -13.72714, - 130.16635, 117.97555, 31.33915, 39.64331, + 130.16635, 117.97555, 31.33915, 39.64331, - -1378.54934, -395.83244, -562.79856, -167.74359, - -45.12476, -17.08986, + -1378.54934, -395.83244, -562.79856, -167.74359, + -45.12476, -17.08986, - -4.20576, -16.56724, + -4.20576, -16.56724, - 1762.12089, -1148.86987, 736.55320, -423.09108, - 56.13621, -26.26674, + 1762.12089, -1148.86987, 736.55320, -423.09108, + 56.13621, -26.26674, - 9.77810, -38.05151, + 9.77810, -38.05151, - 4702224.98754, 27254904.94363, 5306232.25993, 39518429.29982, - 1725110.05669, 21833263.27069, 46010.62605, 5425411.66252, - 17238.09865, 536771.62156, -61263.36051, 66270.70142, - 2084.66296, -1936.71208, 35898.49503, 34885.28549, + 4702224.98754, 27254904.94363, 5306232.25993, 39518429.29982, + 1725110.05669, 21833263.27069, 46010.62605, 5425411.66252, + 17238.09865, 536771.62156, -61263.36051, 66270.70142, + 2084.66296, -1936.71208, 35898.49503, 34885.28549, - 1.93276, 10.66292, + 1.93276, 10.66292, - -665.11445, 3.70467, -265.68478, 16.16272, - -19.45954, 2.32738, + -665.11445, 3.70467, -265.68478, 16.16272, + -19.45954, 2.32738, - 3.04237, 3.97339, + 3.04237, 3.97339, - -2.64312, 0.66308, + -2.64312, 0.66308, - -3207.68754, 3418.03720, -2342.62310, 1729.15030, - -450.84643, 179.00943, -13.20367, -1.86087, + -3207.68754, 3418.03720, -2342.62310, 1729.15030, + -450.84643, 179.00943, -13.20367, -1.86087, - -4.95659, 7.22347, + -4.95659, 7.22347, - -5.08890, -1.28891, + -5.08890, -1.28891, - -6.21713, 5.10551, + -6.21713, 5.10551, - 13.97276, 0.44529, + 13.97276, 0.44529, - 3.25177, 25.02775, + 3.25177, 25.02775, - -45.56672, 11.58470, + -45.56672, 11.58470, - 124443355.55450, -100018293.41775, 190506421.77863, -118262753.40162, - 108199328.45091, -45247957.63323, 27272084.41143, -4125106.01144, - 2583469.66051, 1024678.12935, -22702.55109, 199269.51481, - -15783.14789, 5564.52481, -427.22231, -6330.86079, + 124443355.55450, -100018293.41775, 190506421.77863, -118262753.40162, + 108199328.45091, -45247957.63323, 27272084.41143, -4125106.01144, + 2583469.66051, 1024678.12935, -22702.55109, 199269.51481, + -15783.14789, 5564.52481, -427.22231, -6330.86079, - -97.50757, -204.32241, + -97.50757, -204.32241, - -9060.54822, 156661.77631, -47791.83678, 59725.58975, - -8807.74881, -92.38886, + -9060.54822, 156661.77631, -47791.83678, 59725.58975, + -8807.74881, -92.38886, - -28886.11572, -244419.59744, -53336.36915, -92232.16479, - -8724.89354, -2446.76739, + -28886.11572, -244419.59744, -53336.36915, -92232.16479, + -8724.89354, -2446.76739, - 889.71335, 936.51108, + 889.71335, 936.51108, - 494.80305, 2252.83602, + 494.80305, 2252.83602, - -18326.60823, -25443.13554, -3130.86382, -5426.29135, + -18326.60823, -25443.13554, -3130.86382, -5426.29135, - 23494.08846, 91.28882, 4664.14726, 1552.06143, + 23494.08846, 91.28882, 4664.14726, 1552.06143, - -8090.43357, 2843.48366, -1445.73506, 1023.11482, + -8090.43357, 2843.48366, -1445.73506, 1023.11482, - 11664.20863, -7020.08612, 3100.21504, -64.16577, + 11664.20863, -7020.08612, 3100.21504, -64.16577, - -9724.97938, -12261.47155, -3008.08276, -1523.06301, + -9724.97938, -12261.47155, -3008.08276, -1523.06301, - 6788.74046, 10708.27853, 343.09434, 1701.52760, + 6788.74046, 10708.27853, 343.09434, 1701.52760, - 14743.99857, -4781.96586, + 14743.99857, -4781.96586, - -15922236.41469, 1825172.51825, -14006084.36972, 10363332.64447, - -979550.91360, 6542446.18797, 1160614.26915, 570804.88172, - 89912.68112, -171247.08757, -13899.52899, -6182.25841, + -15922236.41469, 1825172.51825, -14006084.36972, 10363332.64447, + -979550.91360, 6542446.18797, 1160614.26915, 570804.88172, + 89912.68112, -171247.08757, -13899.52899, -6182.25841, - -240.64725, 412.42581, -66.24510, 71.30726, + -240.64725, 412.42581, -66.24510, 71.30726, - -15.81125, -15.76899, + -15.81125, -15.76899, - -21.85515, -102.12717, -10.18287, -19.38527, + -21.85515, -102.12717, -10.18287, -19.38527, - 1.43749, -3.87533, + 1.43749, -3.87533, - 1.97109, 0.20138, + 1.97109, 0.20138, - 0.32012, 1.02928, + 0.32012, 1.02928, - -40.22077, 20.80684, -15.69766, 9.63663, - -1.26010, 0.56197, + -40.22077, 20.80684, -15.69766, 9.63663, + -1.26010, 0.56197, - 0.08592, 0.18540, + 0.08592, 0.18540, - -0.07303, 0.03897, + -0.07303, 0.03897, - 0.01438, -0.08809, + 0.01438, -0.08809, - 0.15479, 0.10354, + 0.15479, 0.10354, - 0.19052, 2.08790, + 0.19052, 2.08790, - 405480.24475, -607986.83623, 582811.58843, -915111.10396, - 258696.21023, -493391.09443, 23403.62628, -119503.67282, - -4036.86957, -9766.17805, -663.93268, 2544.07799, - 40.36638, 76.26390, 246.67716, -13.93440, + 405480.24475, -607986.83623, 582811.58843, -915111.10396, + 258696.21023, -493391.09443, 23403.62628, -119503.67282, + -4036.86957, -9766.17805, -663.93268, 2544.07799, + 40.36638, 76.26390, 246.67716, -13.93440, - 0.12403, 0.25378, + 0.12403, 0.25378, - 0.14004, -0.08501, + 0.14004, -0.08501, - 0.07904, 0.12731, + 0.07904, 0.12731, - 1.02117, -1.34663, 0.25142, -0.26903, + 1.02117, -1.34663, 0.25142, -0.26903, - 0.18135, -0.57683, -0.30092, -0.36121, + 0.18135, -0.57683, -0.30092, -0.36121, - -0.09623, 0.05873, + -0.09623, 0.05873, - -0.05803, 0.02869, + -0.05803, 0.02869, - -0.01194, 0.04983, + -0.01194, 0.04983, - 0.04250, 0.04894, + 0.04250, 0.04894, - 1.34245, 0.70137, 0.24217, 0.25912, + 1.34245, 0.70137, 0.24217, 0.25912, - -0.32759, -0.03575, + -0.32759, -0.03575, - 0.06780, -0.41277, + 0.06780, -0.41277, - 0.43865, 0.17857, + 0.43865, 0.17857, - -763933.02226, 465658.17048, -1082753.91241, 593319.68634, - -553911.89340, 274748.95145, -122250.71547, 56608.95768, - -9914.17300, 2988.43709, 707.94605, -765.01470, - 52.73260, -34.22263, -43.58300, -38.43647, + -763933.02226, 465658.17048, -1082753.91241, 593319.68634, + -553911.89340, 274748.95145, -122250.71547, 56608.95768, + -9914.17300, 2988.43709, 707.94605, -765.01470, + 52.73260, -34.22263, -43.58300, -38.43647, - -4.95939, -1.97173, -1.04406, -0.13072, + -4.95939, -1.97173, -1.04406, -0.13072, - -0.34281, 4.75202, -0.35513, 0.93597, + -0.34281, 4.75202, -0.35513, 0.93597, - -0.54380, 0.70536, + -0.54380, 0.70536, - 84.83116, 102.93003, 26.34884, 48.57746, - 0.02853, 2.91676, + 84.83116, 102.93003, 26.34884, 48.57746, + 0.02853, 2.91676, - -8.07116, 1.66613, + -8.07116, 1.66613, - -2.07908, 11.62592, + -2.07908, 11.62592, - 6.64704, 0.98291, + 6.64704, 0.98291, - -1.19192, 0.93791, + -1.19192, 0.93791, - 0.18822, 0.00900, + 0.18822, 0.00900, - -0.03181, -0.02000, + -0.03181, -0.02000, - 0.02755, -0.01398, + 0.02755, -0.01398, - -0.03971, -0.03756, + -0.03971, -0.03756, - 0.13454, -0.04193, + 0.13454, -0.04193, - -18672.98484, 28230.75834, -28371.58823, 26448.45214, - -13352.09393, 7461.71279, -2609.33578, 726.50321, - -309.72942, -86.71982, 12.48589, -9.69726, - 1.82185, 14.92220, + -18672.98484, 28230.75834, -28371.58823, 26448.45214, + -13352.09393, 7461.71279, -2609.33578, 726.50321, + -309.72942, -86.71982, 12.48589, -9.69726, + 1.82185, 14.92220, - -0.04748, 0.42510, + -0.04748, 0.42510, - -0.20047, 0.00154, + -0.20047, 0.00154, - 0.00176, -0.26262, + 0.00176, -0.26262, - 0.78218, -0.73243, 0.23694, -0.03132, + 0.78218, -0.73243, 0.23694, -0.03132, - -0.00290, -0.03678, + -0.00290, -0.03678, - 14.03094, 4.25948, 0.79368, -0.78489, - -2.30962, 2.31946, + 14.03094, 4.25948, 0.79368, -0.78489, + -2.30962, 2.31946, - 0.00158, -0.04125, + 0.00158, -0.04125, - -0.01387, 0.28503, 0.00892, 0.05154, + -0.01387, 0.28503, 0.00892, 0.05154, - 0.00184, -0.01727, + 0.00184, -0.01727, - -0.00889, 0.03526, + -0.00889, 0.03526, - -0.00521, -0.02093, + -0.00521, -0.02093, - 0.00200, 0.04872, + 0.00200, 0.04872, - -0.02163, 0.00578, + -0.02163, 0.00578, - 20699.27413, -2175.57827, 31177.33085, 4572.02063, - 15486.28190, 8747.74091, 2455.51737, 3839.83609, - 51.31433, 507.91086, 15.90082, 44.75942, - -0.98374, -2.64477, 2.52336, -3.09203, + 20699.27413, -2175.57827, 31177.33085, 4572.02063, + 15486.28190, 8747.74091, 2455.51737, 3839.83609, + 51.31433, 507.91086, 15.90082, 44.75942, + -0.98374, -2.64477, 2.52336, -3.09203, - -0.08897, -0.00083, + -0.08897, -0.00083, - -15.91892, 0.72597, 14.04523, -3.16525, - 4.33379, -30.82980, 0.40462, -0.75845, - 13.14831, -0.02721, + -15.91892, 0.72597, 14.04523, -3.16525, + 4.33379, -30.82980, 0.40462, -0.75845, + 13.14831, -0.02721, - -0.01779, 0.00481, + -0.01779, 0.00481, - 0.42365, -0.09048, 0.08653, 0.04391, + 0.42365, -0.09048, 0.08653, 0.04391, - 0.00846, 0.01082, + 0.00846, 0.01082, - -0.04736, 0.02308, + -0.04736, 0.02308, - 6282.21778, -4952.70286, 7886.57505, -5328.36122, - 3113.76826, -1696.84590, 330.70011, -155.51989, - -18.31559, -3.90798, -3.11242, 1.87818, - -1.05578, 0.11198, + 6282.21778, -4952.70286, 7886.57505, -5328.36122, + 3113.76826, -1696.84590, 330.70011, -155.51989, + -18.31559, -3.90798, -3.11242, 1.87818, + -1.05578, 0.11198, - 0.05077, -0.01571, + 0.05077, -0.01571, - 2.41291, 2.40568, + 2.41291, 2.40568, - -0.01136, -0.00076, + -0.01136, -0.00076, - -0.00392, -0.02774, + -0.00392, -0.02774, - 634.85065, -352.21937, 674.31665, -260.73473, - 199.16422, -28.44198, 6.54187, 6.44960, - -1.55155, 0.29755, 0.16977, 0.17540, + 634.85065, -352.21937, 674.31665, -260.73473, + 199.16422, -28.44198, 6.54187, 6.44960, + -1.55155, 0.29755, 0.16977, 0.17540, - -0.02652, 0.03726, + -0.02652, 0.03726, - -0.00623, 0.11777, -0.00933, 0.02602, + -0.00623, 0.11777, -0.00933, 0.02602, - -0.13943, -0.24818, + -0.13943, -0.24818, - 0.02876, -0.01463, + 0.02876, -0.01463, - -0.07166, 0.06747, -0.01578, 0.01628, + -0.07166, 0.06747, -0.01578, 0.01628, - 0.00233, -0.00686, + 0.00233, -0.00686, - 0.00431, -0.00276, + 0.00431, -0.00276, - 0.21774, 0.09735, 0.07894, 0.07279, + 0.21774, 0.09735, 0.07894, 0.07279, - -0.01300, -0.00268, + -0.01300, -0.00268, - 0.10824, 0.09435, 0.00720, 0.02111, + 0.10824, 0.09435, 0.00720, 0.02111, - -0.01960, 0.06154, + -0.01960, 0.06154, - 0.56867, -0.07544, 0.18210, 0.06343, - -0.00906, 0.01942, + 0.56867, -0.07544, 0.18210, 0.06343, + -0.00906, 0.01942, - -0.00850, -0.00351, + -0.00850, -0.00351, - -0.06988, 0.01713, -0.01110, -0.00663, + -0.06988, 0.01713, -0.01110, -0.00663, - 0.00196, -0.02064, + 0.00196, -0.02064, - -0.00008, 0.00043, + -0.00008, 0.00043, - 0.00375, 0.00084, + 0.00375, 0.00084, - -0.00279, 0.00100, + -0.00279, 0.00100, - 0.00271, -0.02017, -0.00074, -0.00357, + 0.00271, -0.02017, -0.00074, -0.00357, - 0.03793, -0.10108, -0.01083, -0.03952, + 0.03793, -0.10108, -0.01083, -0.03952, - 0.00030, 0.00012, + 0.00030, 0.00012, - 0.01576, 0.01142, 0.00351, 0.00277, + 0.01576, 0.01142, 0.00351, 0.00277, - 0.01409, -0.00774, + 0.01409, -0.00774, - -0.00065, 0.01895, + -0.00065, 0.01895, - 0.07350, -0.02519, 0.01528, -0.01057, + 0.07350, -0.02519, 0.01528, -0.01057, - -0.00099, -0.00295, + -0.00099, -0.00295, - 0.21347, -0.17458, 0.04940, -0.02757, + 0.21347, -0.17458, 0.04940, -0.02757, - -0.06243, 0.05203, + -0.06243, 0.05203, - 0.01055, -0.00109, + 0.01055, -0.00109, - 0.00003, -0.04201, + 0.00003, -0.04201, - -0.00263, 0.02387, + -0.00263, 0.02387, - 0.00886, -0.01168, + 0.00886, -0.01168, - 0.00479, 0.00204, + 0.00479, 0.00204, - -0.00239, 0.00022, + -0.00239, 0.00022, - -0.00223, -0.02029, + -0.00223, -0.02029, - -0.14130, -0.15237, -0.01827, -0.04877, + -0.14130, -0.15237, -0.01827, -0.04877, - 0.12104, 0.06796, + 0.12104, 0.06796, - 0.16379, 0.31892, + 0.16379, 0.31892, - -0.15605, 0.07048, + -0.15605, 0.07048, - -0.00700, 0.07481, + -0.00700, 0.07481, - -0.00370, -0.00142, + -0.00370, -0.00142, - -0.00446, 0.00329, + -0.00446, 0.00329, - -0.00018, 0.00117, + -0.00018, 0.00117, - -0.00910, 0.00510, + -0.00910, 0.00510, - -0.00055, -0.00114, + -0.00055, -0.00114, - 0.04131, -0.04013, + 0.04131, -0.04013, - -0.13238, 0.02680, + -0.13238, 0.02680, - -0.10369, 1.38709, 0.35515, 0.41437, + -0.10369, 1.38709, 0.35515, 0.41437, - -0.01327, -0.02692, + -0.01327, -0.02692, - 38.02603, 13.38166, 15.33389, -7.40145, - -8.55293, -0.13185, -0.03316, 0.13016, - 0.04428, -1.60953, + 38.02603, 13.38166, 15.33389, -7.40145, + -8.55293, -0.13185, -0.03316, 0.13016, + 0.04428, -1.60953, - -12.87829, -76.97922, -23.96039, -22.45636, - 14.83309, 14.09854, 0.24252, 0.13850, - -4.16582, 4.08846, + -12.87829, -76.97922, -23.96039, -22.45636, + 14.83309, 14.09854, 0.24252, 0.13850, + -4.16582, 4.08846, - 0.00751, -0.00051, + 0.00751, -0.00051, - 0.03456, 0.02900, + 0.03456, 0.02900, - 0.01625, -0.04660, + 0.01625, -0.04660, - 0.01390, -0.00530, + 0.01390, -0.00530, - 0.01665, -0.04571, + 0.01665, -0.04571, - 40.90768, -14.11641, 7.46071, -58.07356, - -0.27859, -1.33816, 23.76074, -0.03124, + 40.90768, -14.11641, 7.46071, -58.07356, + -0.27859, -1.33816, 23.76074, -0.03124, - -0.27860, 0.13654, -0.04800, 0.05375, + -0.27860, 0.13654, -0.04800, 0.05375, - 4.38091, 4.39337, + 4.38091, 4.39337, - 0.02233, 0.00514, + 0.02233, 0.00514, - -0.25616, -0.54439, + -0.25616, -0.54439, - -0.05155, 0.11553, + -0.05155, 0.11553, - 0.02944, -0.00818, + 0.02944, -0.00818, - 0.00570, 0.00119, + 0.00570, 0.00119, - -0.00733, -0.02700, + -0.00733, -0.02700, - -0.23759, -0.08712, -0.12433, 0.07397, + -0.23759, -0.08712, -0.12433, 0.07397, - 0.20629, 0.60251, 0.56512, 0.14790, + 0.20629, 0.60251, 0.56512, 0.14790, - 0.07778, 0.11614, + 0.07778, 0.11614, }; static signed char FAR pluargs[] = { - 0, 7, - 2, 3, 7, -9, 9, 0, - 2, 4, 7,-12, 9, 0, - 2, 4, 7, -8, 8, 0, - 3, -4, 7, 5, 8, 4, 9, 0, - 3, 3, 7, -5, 8, -1, 9, 0, - 2, 1, 6, -8, 9, 1, - 2, 3, 8, -5, 9, 1, - 2, 1, 6, -9, 9, 2, - 3, 6, 7, -6, 8, -8, 9, 0, - 3, 4, 7,-10, 8, 4, 9, 2, - 2, 3, 7, -8, 9, 0, - 1, 1, 9, 7, - 2, 3, 7,-10, 9, 0, - 3, 4, 7,-10, 8, 2, 9, 2, - 3, 5, 7,-12, 8, 2, 9, 0, - 2, 1, 6, -7, 9, 0, - 1, 1, 8, 3, - 2, 1, 6,-10, 9, 0, - 3, 6, 7,-12, 8, 2, 9, 0, - 3, 5, 7,-10, 8, 2, 9, 0, - 2, 5, 7,-13, 9, 0, - 2, 4, 7,-10, 9, 0, - 2, 3, 7, -7, 9, 0, - 1, 2, 9, 7, - 2, 3, 7,-11, 9, 0, - 3, 4, 7, -9, 8, 4, 9, 2, - 3, 3, 7, -5, 8, 1, 9, 2, - 2, 1, 6, -6, 9, 0, - 2, 7, 8,-13, 9, 0, - 2, 3, 8, -2, 9, 1, - 3, 1, 7, -5, 8, 2, 9, 1, - 3, 6, 7,-12, 8, 3, 9, 1, - 2, 5, 7,-12, 9, 1, - 2, 4, 7, -9, 9, 1, - 2, 2, 7, -3, 9, 1, - 1, 1, 7, 0, - 1, 3, 9, 5, - 2, 3, 7,-12, 9, 1, - 3, 5, 7, -9, 8, 2, 9, 0, - 3, 4, 7, -7, 8, 2, 9, 1, - 3, 3, 7, -5, 8, 2, 9, 0, - 3, 2, 7, -5, 8, 5, 9, 0, - 2, 1, 6, -5, 9, 0, - 2, 3, 8, -1, 9, 2, - 2, 1, 6,-12, 9, 0, - 3, 2, 7, -7, 8, 1, 9, 0, - 2, 5, 7,-11, 9, 0, - 2, 4, 7, -8, 9, 0, - 2, 2, 7, -2, 9, 0, - 1, 4, 9, 7, - 3, 2, 7, -8, 8, 2, 9, 0, - 3, 5, 7, -9, 8, 3, 9, 0, - 3, 4, 7, -9, 8, 6, 9, 0, - 3, 3, 7, -5, 8, 3, 9, 1, - 2, 2, 7, -1, 8, 1, - 2, 3, 8, -9, 9, 0, - 2, 9, 8, -9, 9, 0, - 2, 1, 6,-13, 9, 0, - 3, 2, 7, -5, 8, -3, 9, 0, - 2, 6, 7,-13, 9, 1, - 2, 5, 7,-10, 9, 0, - 2, 4, 7, -7, 9, 0, - 2, 3, 7, -4, 9, 0, - 1, 5, 9, 7, - 3, 6, 7, -9, 8, 1, 9, 1, - 3, 4, 7, -5, 8, 1, 9, 1, - 3, 3, 7, -3, 8, 1, 9, 0, - 2, 1, 6, -3, 9, 2, - 2, 3, 8,-10, 9, 0, - 2, 1, 8, 4, 9, 0, - 2, 5, 8, -2, 9, 0, - 2, 11, 8,-11, 9, 0, - 3, 1, 7, -9, 8, 5, 9, 0, - 2, 6, 7,-12, 9, 0, - 2, 5, 7, -9, 9, 0, - 2, 4, 7, -6, 9, 0, - 2, 3, 7, -3, 9, 0, - 1, 6, 9, 6, - 2, 2, 7,-12, 9, 0, - 3, 6, 7, -9, 8, 2, 9, 0, - 3, 3, 7,-12, 8, 3, 9, 0, - 3, 4, 7,-10, 8, -3, 9, 1, - 3, 3, 7, -3, 8, 2, 9, 0, - 2, 1, 6, -2, 9, 2, - 2, 1, 8, 5, 9, 0, - 2, 13, 8,-13, 9, 1, - 3, 2, 7, -9, 8, 1, 9, 0, - 2, 6, 7,-11, 9, 0, - 2, 5, 7, -8, 9, 0, - 2, 4, 7, -5, 9, 0, - 2, 3, 7, -2, 9, 0, - 1, 7, 9, 7, - 3, 6, 7, -9, 8, 3, 9, 0, - 2, 1, 6, -1, 9, 4, - 2, 3, 8, 3, 9, 0, - 2, 7, 7,-13, 9, 1, - 2, 3, 7, -1, 9, 0, - 2, 2, 7, 2, 9, 0, - 1, 8, 9, 6, - 3, 7, 7, -9, 8, 1, 9, 0, - 1, 1, 6, 0, - 1, 3, 7, 0, - 2, 2, 7, 3, 9, 0, - 1, 9, 9, 5, - 3, 1, 7,-10, 8, 3, 9, 0, - 3, 2, 7,-12, 8, 3, 9, 1, - 2, 1, 6, 1, 9, 0, - 3, 1, 7, -1, 8, 8, 9, 0, - 2, 3, 7, 1, 9, 1, - 2, 2, 7, 4, 9, 0, - 2, 1, 7, 7, 9, 0, - 2, 4, 8, 4, 9, 1, - 2, 12, 8, -8, 9, 0, - 3, 1, 7,-10, 8, 2, 9, 1, - 2, 1, 6, 2, 9, 0, - 1, 11, 9, 2, - 2, 12, 8, -7, 9, 0, - 3, 1, 7,-10, 8, 1, 9, 1, - 1, 4, 7, 0, - 1, 12, 9, 0, - 2, 6, 8, 3, 9, 0, - 3, 1, 7, -2, 8,-12, 9, 0, - 3, 7, 7, -7, 8, 2, 9, 1, - 2, 2, 6, -4, 9, 1, - 1, 13, 9, 0, - 2, 10, 8, -2, 9, 1, - 2, 4, 7, 2, 9, 0, - 2, 2, 6, -3, 9, 0, - 2, 2, 7, 8, 9, 1, - 2, 8, 8, 2, 9, 0, - 1, 5, 7, 1, - 2, 4, 7, 3, 9, 0, - 2, 3, 7, 6, 9, 0, - 2, 1, 5, -6, 9, 0, - 3, 2, 7, 8, 8, -3, 9, 0, - 3, 1, 7, 6, 8, 3, 9, 0, - 2, 6, 8, 6, 9, 0, - 3, 8, 7, -7, 8, 2, 9, 0, - 2, 9, 7,-11, 9, 0, - 2, 5, 7, 1, 9, 1, - 2, 4, 7, 4, 9, 0, - 2, 2, 6, -1, 9, 0, - 3, 2, 6, -1, 7, 2, 9, 0, - 2, 2, 7, 10, 9, 0, - 2, 1, 7, 13, 9, 0, - 2, 8, 7, -7, 9, 0, - 2, 7, 7, -4, 9, 0, - 2, 6, 7, -1, 9, 0, - 2, 5, 7, 3, 9, 0, - 2, 4, 7, 5, 9, 0, - 1, 2, 6, 0, - 2, 1, 5, -4, 9, 1, - 3, 1, 6, 9, 8, -5, 9, 0, - 2, 1, 5, -3, 9, 4, - 2, 1, 5, -2, 9, 4, - 3, 9, 7, -9, 8, 6, 9, 0, - 2, 8, 7, -4, 9, 0, - 2, 7, 7, -1, 9, 0, - 2, 1, 6, 3, 9, 0, - 2, 2, 6, 3, 9, 0, - 2, 1, 5, -1, 9, 3, - 3, 6, 7, -3, 8, 7, 9, 1, - 1, 1, 5, 0, - 2, 2, 6, 5, 9, 0, - 2, 1, 5, 1, 9, 0, - 2, 1, 5, 2, 9, 0, - 2, 1, 5, 3, 9, 0, - 2, 2, 5, -4, 9, 0, - 2, 2, 5, -3, 9, 0, - 2, 2, 5, -2, 9, 1, - 2, 2, 5, -1, 9, 1, - 1, 2, 5, 0, - -1 + 0, 7, + 2, 3, 7, -9, 9, 0, + 2, 4, 7, -12, 9, 0, + 2, 4, 7, -8, 8, 0, + 3, -4, 7, 5, 8, 4, 9, 0, + 3, 3, 7, -5, 8, -1, 9, 0, + 2, 1, 6, -8, 9, 1, + 2, 3, 8, -5, 9, 1, + 2, 1, 6, -9, 9, 2, + 3, 6, 7, -6, 8, -8, 9, 0, + 3, 4, 7, -10, 8, 4, 9, 2, + 2, 3, 7, -8, 9, 0, + 1, 1, 9, 7, + 2, 3, 7, -10, 9, 0, + 3, 4, 7, -10, 8, 2, 9, 2, + 3, 5, 7, -12, 8, 2, 9, 0, + 2, 1, 6, -7, 9, 0, + 1, 1, 8, 3, + 2, 1, 6, -10, 9, 0, + 3, 6, 7, -12, 8, 2, 9, 0, + 3, 5, 7, -10, 8, 2, 9, 0, + 2, 5, 7, -13, 9, 0, + 2, 4, 7, -10, 9, 0, + 2, 3, 7, -7, 9, 0, + 1, 2, 9, 7, + 2, 3, 7, -11, 9, 0, + 3, 4, 7, -9, 8, 4, 9, 2, + 3, 3, 7, -5, 8, 1, 9, 2, + 2, 1, 6, -6, 9, 0, + 2, 7, 8, -13, 9, 0, + 2, 3, 8, -2, 9, 1, + 3, 1, 7, -5, 8, 2, 9, 1, + 3, 6, 7, -12, 8, 3, 9, 1, + 2, 5, 7, -12, 9, 1, + 2, 4, 7, -9, 9, 1, + 2, 2, 7, -3, 9, 1, + 1, 1, 7, 0, + 1, 3, 9, 5, + 2, 3, 7, -12, 9, 1, + 3, 5, 7, -9, 8, 2, 9, 0, + 3, 4, 7, -7, 8, 2, 9, 1, + 3, 3, 7, -5, 8, 2, 9, 0, + 3, 2, 7, -5, 8, 5, 9, 0, + 2, 1, 6, -5, 9, 0, + 2, 3, 8, -1, 9, 2, + 2, 1, 6, -12, 9, 0, + 3, 2, 7, -7, 8, 1, 9, 0, + 2, 5, 7, -11, 9, 0, + 2, 4, 7, -8, 9, 0, + 2, 2, 7, -2, 9, 0, + 1, 4, 9, 7, + 3, 2, 7, -8, 8, 2, 9, 0, + 3, 5, 7, -9, 8, 3, 9, 0, + 3, 4, 7, -9, 8, 6, 9, 0, + 3, 3, 7, -5, 8, 3, 9, 1, + 2, 2, 7, -1, 8, 1, + 2, 3, 8, -9, 9, 0, + 2, 9, 8, -9, 9, 0, + 2, 1, 6, -13, 9, 0, + 3, 2, 7, -5, 8, -3, 9, 0, + 2, 6, 7, -13, 9, 1, + 2, 5, 7, -10, 9, 0, + 2, 4, 7, -7, 9, 0, + 2, 3, 7, -4, 9, 0, + 1, 5, 9, 7, + 3, 6, 7, -9, 8, 1, 9, 1, + 3, 4, 7, -5, 8, 1, 9, 1, + 3, 3, 7, -3, 8, 1, 9, 0, + 2, 1, 6, -3, 9, 2, + 2, 3, 8, -10, 9, 0, + 2, 1, 8, 4, 9, 0, + 2, 5, 8, -2, 9, 0, + 2, 11, 8, -11, 9, 0, + 3, 1, 7, -9, 8, 5, 9, 0, + 2, 6, 7, -12, 9, 0, + 2, 5, 7, -9, 9, 0, + 2, 4, 7, -6, 9, 0, + 2, 3, 7, -3, 9, 0, + 1, 6, 9, 6, + 2, 2, 7, -12, 9, 0, + 3, 6, 7, -9, 8, 2, 9, 0, + 3, 3, 7, -12, 8, 3, 9, 0, + 3, 4, 7, -10, 8, -3, 9, 1, + 3, 3, 7, -3, 8, 2, 9, 0, + 2, 1, 6, -2, 9, 2, + 2, 1, 8, 5, 9, 0, + 2, 13, 8, -13, 9, 1, + 3, 2, 7, -9, 8, 1, 9, 0, + 2, 6, 7, -11, 9, 0, + 2, 5, 7, -8, 9, 0, + 2, 4, 7, -5, 9, 0, + 2, 3, 7, -2, 9, 0, + 1, 7, 9, 7, + 3, 6, 7, -9, 8, 3, 9, 0, + 2, 1, 6, -1, 9, 4, + 2, 3, 8, 3, 9, 0, + 2, 7, 7, -13, 9, 1, + 2, 3, 7, -1, 9, 0, + 2, 2, 7, 2, 9, 0, + 1, 8, 9, 6, + 3, 7, 7, -9, 8, 1, 9, 0, + 1, 1, 6, 0, + 1, 3, 7, 0, + 2, 2, 7, 3, 9, 0, + 1, 9, 9, 5, + 3, 1, 7, -10, 8, 3, 9, 0, + 3, 2, 7, -12, 8, 3, 9, 1, + 2, 1, 6, 1, 9, 0, + 3, 1, 7, -1, 8, 8, 9, 0, + 2, 3, 7, 1, 9, 1, + 2, 2, 7, 4, 9, 0, + 2, 1, 7, 7, 9, 0, + 2, 4, 8, 4, 9, 1, + 2, 12, 8, -8, 9, 0, + 3, 1, 7, -10, 8, 2, 9, 1, + 2, 1, 6, 2, 9, 0, + 1, 11, 9, 2, + 2, 12, 8, -7, 9, 0, + 3, 1, 7, -10, 8, 1, 9, 1, + 1, 4, 7, 0, + 1, 12, 9, 0, + 2, 6, 8, 3, 9, 0, + 3, 1, 7, -2, 8, -12, 9, 0, + 3, 7, 7, -7, 8, 2, 9, 1, + 2, 2, 6, -4, 9, 1, + 1, 13, 9, 0, + 2, 10, 8, -2, 9, 1, + 2, 4, 7, 2, 9, 0, + 2, 2, 6, -3, 9, 0, + 2, 2, 7, 8, 9, 1, + 2, 8, 8, 2, 9, 0, + 1, 5, 7, 1, + 2, 4, 7, 3, 9, 0, + 2, 3, 7, 6, 9, 0, + 2, 1, 5, -6, 9, 0, + 3, 2, 7, 8, 8, -3, 9, 0, + 3, 1, 7, 6, 8, 3, 9, 0, + 2, 6, 8, 6, 9, 0, + 3, 8, 7, -7, 8, 2, 9, 0, + 2, 9, 7, -11, 9, 0, + 2, 5, 7, 1, 9, 1, + 2, 4, 7, 4, 9, 0, + 2, 2, 6, -1, 9, 0, + 3, 2, 6, -1, 7, 2, 9, 0, + 2, 2, 7, 10, 9, 0, + 2, 1, 7, 13, 9, 0, + 2, 8, 7, -7, 9, 0, + 2, 7, 7, -4, 9, 0, + 2, 6, 7, -1, 9, 0, + 2, 5, 7, 3, 9, 0, + 2, 4, 7, 5, 9, 0, + 1, 2, 6, 0, + 2, 1, 5, -4, 9, 1, + 3, 1, 6, 9, 8, -5, 9, 0, + 2, 1, 5, -3, 9, 4, + 2, 1, 5, -2, 9, 4, + 3, 9, 7, -9, 8, 6, 9, 0, + 2, 8, 7, -4, 9, 0, + 2, 7, 7, -1, 9, 0, + 2, 1, 6, 3, 9, 0, + 2, 2, 6, 3, 9, 0, + 2, 1, 5, -1, 9, 3, + 3, 6, 7, -3, 8, 7, 9, 1, + 1, 1, 5, 0, + 2, 2, 6, 5, 9, 0, + 2, 1, 5, 1, 9, 0, + 2, 1, 5, 2, 9, 0, + 2, 1, 5, 3, 9, 0, + 2, 2, 5, -4, 9, 0, + 2, 2, 5, -3, 9, 0, + 2, 2, 5, -2, 9, 1, + 2, 2, 5, -1, 9, 1, + 1, 2, 5, 0, + -1 }; + /* Total terms = 173, small = 156 */ static struct plantbl FAR plu404 = { - { 0, 0, 0, 0, 2, 2, 9, 13, 13,}, - 7, - pluargs, - plutabl, - plutabb, - plutabr, - 3.9539999999999999e+01, + {0, 0, 0, 0, 2, 2, 9, 13, 13,}, + 7, + pluargs, + plutabl, + plutabb, + plutabr, + 3.9539999999999999e+01, }; diff --git a/swe/src/swenut2000a.h b/swe/src/swenut2000a.h index 69fddf8..460a493 100644 --- a/swe/src/swenut2000a.h +++ b/swe/src/swenut2000a.h @@ -1,3 +1,4 @@ + /************************************************************ $Header: /home/dieter/sweph/RCS/swenut2000a.h,v 1.74 2008/06/16 10:07:20 dieter Exp $ definitions for nutation theory IAU 2000a @@ -6,6 +7,7 @@ Compilation Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich ************************************************************/ + /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -62,2759 +64,2763 @@ /* 0.1 microarcsecond to degrees */ #define O1MAS2DEG (1 / 3600.0 / 10000000.0) + /* Number of terms in the luni-solar nutation model */ #define NLS 678 #define NLS_2000B 77 + /* Number of terms in the planetary nutation model */ #define NPL 687 + /* Luni-Solar argument multipliers L L' F D Om */ static int16 nls[] = { -0, 0, 0, 0, 1, -0, 0, 2, -2, 2, -0, 0, 2, 0, 2, -0, 0, 0, 0, 2, -0, 1, 0, 0, 0, -0, 1, 2, -2, 2, -1, 0, 0, 0, 0, -0, 0, 2, 0, 1, -1, 0, 2, 0, 2, -0, -1, 2, -2, 2, -0, 0, 2, -2, 1, --1, 0, 2, 0, 2, --1, 0, 0, 2, 0, -1, 0, 0, 0, 1, --1, 0, 0, 0, 1, --1, 0, 2, 2, 2, -1, 0, 2, 0, 1, --2, 0, 2, 0, 1, -0, 0, 0, 2, 0, -0, 0, 2, 2, 2, -0, -2, 2, -2, 2, --2, 0, 0, 2, 0, -2, 0, 2, 0, 2, -1, 0, 2, -2, 2, --1, 0, 2, 0, 1, -2, 0, 0, 0, 0, -0, 0, 2, 0, 0, -0, 1, 0, 0, 1, --1, 0, 0, 2, 1, -0, 2, 2, -2, 2, -0, 0, -2, 2, 0, -1, 0, 0, -2, 1, -0, -1, 0, 0, 1, --1, 0, 2, 2, 1, -0, 2, 0, 0, 0, -1, 0, 2, 2, 2, --2, 0, 2, 0, 0, -0, 1, 2, 0, 2, -0, 0, 2, 2, 1, -0, -1, 2, 0, 2, -0, 0, 0, 2, 1, -1, 0, 2, -2, 1, -2, 0, 2, -2, 2, --2, 0, 0, 2, 1, -2, 0, 2, 0, 1, -0, -1, 2, -2, 1, -0, 0, 0, -2, 1, --1, -1, 0, 2, 0, -2, 0, 0, -2, 1, -1, 0, 0, 2, 0, -0, 1, 2, -2, 1, -1, -1, 0, 0, 0, --2, 0, 2, 0, 2, -3, 0, 2, 0, 2, -0, -1, 0, 2, 0, -1, -1, 2, 0, 2, -0, 0, 0, 1, 0, --1, -1, 2, 2, 2, --1, 0, 2, 0, 0, -0, -1, 2, 2, 2, --2, 0, 0, 0, 1, -1, 1, 2, 0, 2, -2, 0, 0, 0, 1, --1, 1, 0, 1, 0, -1, 1, 0, 0, 0, -1, 0, 2, 0, 0, --1, 0, 2, -2, 1, -1, 0, 0, 0, 2, --1, 0, 0, 1, 0, -0, 0, 2, 1, 2, --1, 0, 2, 4, 2, --1, 1, 0, 1, 1, -0, -2, 2, -2, 1, -1, 0, 2, 2, 1, --2, 0, 2, 2, 2, --1, 0, 0, 0, 2, -1, 1, 2, -2, 2, --2, 0, 2, 4, 2, --1, 0, 4, 0, 2, -2, 0, 2, -2, 1, -2, 0, 2, 2, 2, -1, 0, 0, 2, 1, -3, 0, 0, 0, 0, -3, 0, 2, -2, 2, -0, 0, 4, -2, 2, -0, 1, 2, 0, 1, -0, 0, -2, 2, 1, -0, 0, 2, -2, 3, --1, 0, 0, 4, 0, -2, 0, -2, 0, 1, --2, 0, 0, 4, 0, --1, -1, 0, 2, 1, --1, 0, 0, 1, 1, -0, 1, 0, 0, 2, -0, 0, -2, 0, 1, -0, -1, 2, 0, 1, -0, 0, 2, -1, 2, -0, 0, 2, 4, 2, --2, -1, 0, 2, 0, -1, 1, 0, -2, 1, --1, 1, 0, 2, 0, --1, 1, 0, 1, 2, -1, -1, 0, 0, 1, -1, -1, 2, 2, 2, --1, 1, 2, 2, 2, -3, 0, 2, 0, 1, -0, 1, -2, 2, 0, --1, 0, 0, -2, 1, -0, 1, 2, 2, 2, --1, -1, 2, 2, 1, -0, -1, 0, 0, 2, -1, 0, 2, -4, 1, --1, 0, -2, 2, 0, -0, -1, 2, 2, 1, -2, -1, 2, 0, 2, -0, 0, 0, 2, 2, -1, -1, 2, 0, 1, --1, 1, 2, 0, 2, -0, 1, 0, 2, 0, -0, -1, -2, 2, 0, -0, 3, 2, -2, 2, -0, 0, 0, 1, 1, --1, 0, 2, 2, 0, -2, 1, 2, 0, 2, -1, 1, 0, 0, 1, -1, 1, 2, 0, 1, -2, 0, 0, 2, 0, -1, 0, -2, 2, 0, --1, 0, 0, 2, 2, -0, 1, 0, 1, 0, -0, 1, 0, -2, 1, --1, 0, 2, -2, 2, -0, 0, 0, -1, 1, --1, 1, 0, 0, 1, -1, 0, 2, -1, 2, -1, -1, 0, 2, 0, -0, 0, 0, 4, 0, -1, 0, 2, 1, 2, -0, 0, 2, 1, 1, -1, 0, 0, -2, 2, --1, 0, 2, 4, 1, -1, 0, -2, 0, 1, -1, 1, 2, -2, 1, -0, 0, 2, 2, 0, --1, 0, 2, -1, 1, --2, 0, 2, 2, 1, -4, 0, 2, 0, 2, -2, -1, 0, 0, 0, -2, 1, 2, -2, 2, -0, 1, 2, 1, 2, -1, 0, 4, -2, 2, --1, -1, 0, 0, 1, -0, 1, 0, 2, 1, --2, 0, 2, 4, 1, -2, 0, 2, 0, 0, -1, 0, 0, 1, 0, --1, 0, 0, 4, 1, --1, 0, 4, 0, 1, -2, 0, 2, 2, 1, -0, 0, 2, -3, 2, --1, -2, 0, 2, 0, -2, 1, 0, 0, 0, -0, 0, 4, 0, 2, -0, 0, 0, 0, 3, -0, 3, 0, 0, 0, -0, 0, 2, -4, 1, -0, -1, 0, 2, 1, -0, 0, 0, 4, 1, --1, -1, 2, 4, 2, -1, 0, 2, 4, 2, --2, 2, 0, 2, 0, --2, -1, 2, 0, 1, --2, 0, 0, 2, 2, --1, -1, 2, 0, 2, -0, 0, 4, -2, 1, -3, 0, 2, -2, 1, --2, -1, 0, 2, 1, -1, 0, 0, -1, 1, -0, -2, 0, 2, 0, --2, 0, 0, 4, 1, --3, 0, 0, 0, 1, -1, 1, 2, 2, 2, -0, 0, 2, 4, 1, -3, 0, 2, 2, 2, --1, 1, 2, -2, 1, -2, 0, 0, -4, 1, -0, 0, 0, -2, 2, -2, 0, 2, -4, 1, --1, 1, 0, 2, 1, -0, 0, 2, -1, 1, -0, -2, 2, 2, 2, -2, 0, 0, 2, 1, -4, 0, 2, -2, 2, -2, 0, 0, -2, 2, -0, 2, 0, 0, 1, -1, 0, 0, -4, 1, -0, 2, 2, -2, 1, --3, 0, 0, 4, 0, --1, 1, 2, 0, 1, --1, -1, 0, 4, 0, --1, -2, 2, 2, 2, --2, -1, 2, 4, 2, -1, -1, 2, 2, 1, --2, 1, 0, 2, 0, --2, 1, 2, 0, 1, -2, 1, 0, -2, 1, --3, 0, 2, 0, 1, --2, 0, 2, -2, 1, --1, 1, 0, 2, 2, -0, -1, 2, -1, 2, --1, 0, 4, -2, 2, -0, -2, 2, 0, 2, --1, 0, 2, 1, 2, -2, 0, 0, 0, 2, -0, 0, 2, 0, 3, --2, 0, 4, 0, 2, --1, 0, -2, 0, 1, --1, 1, 2, 2, 1, -3, 0, 0, 0, 1, --1, 0, 2, 3, 2, -2, -1, 2, 0, 1, -0, 1, 2, 2, 1, -0, -1, 2, 4, 2, -2, -1, 2, 2, 2, -0, 2, -2, 2, 0, --1, -1, 2, -1, 1, -0, -2, 0, 0, 1, -1, 0, 2, -4, 2, -1, -1, 0, -2, 1, --1, -1, 2, 0, 1, -1, -1, 2, -2, 2, --2, -1, 0, 4, 0, --1, 0, 0, 3, 0, --2, -1, 2, 2, 2, -0, 2, 2, 0, 2, -1, 1, 0, 2, 0, -2, 0, 2, -1, 2, -1, 0, 2, 1, 1, -4, 0, 0, 0, 0, -2, 1, 2, 0, 1, -3, -1, 2, 0, 2, --2, 2, 0, 2, 1, -1, 0, 2, -3, 1, -1, 1, 2, -4, 1, --1, -1, 2, -2, 1, -0, -1, 0, -1, 1, -0, -1, 0, -2, 1, --2, 0, 0, 0, 2, --2, 0, -2, 2, 0, --1, 0, -2, 4, 0, -1, -2, 0, 0, 0, -0, 1, 0, 1, 1, --1, 2, 0, 2, 0, -1, -1, 2, -2, 1, -1, 2, 2, -2, 2, -2, -1, 2, -2, 2, -1, 0, 2, -1, 1, -2, 1, 2, -2, 1, --2, 0, 0, -2, 1, -1, -2, 2, 0, 2, -0, 1, 2, 1, 1, -1, 0, 4, -2, 1, --2, 0, 4, 2, 2, -1, 1, 2, 1, 2, -1, 0, 0, 4, 0, -1, 0, 2, 2, 0, -2, 0, 2, 1, 2, -3, 1, 2, 0, 2, -4, 0, 2, 0, 1, --2, -1, 2, 0, 0, -0, 1, -2, 2, 1, -1, 0, -2, 1, 0, -0, -1, -2, 2, 1, -2, -1, 0, -2, 1, --1, 0, 2, -1, 2, -1, 0, 2, -3, 2, -0, 1, 2, -2, 3, -0, 0, 2, -3, 1, --1, 0, -2, 2, 1, -0, 0, 2, -4, 2, --2, 1, 0, 0, 1, --1, 0, 0, -1, 1, -2, 0, 2, -4, 2, -0, 0, 4, -4, 4, -0, 0, 4, -4, 2, --1, -2, 0, 2, 1, --2, 0, 0, 3, 0, -1, 0, -2, 2, 1, --3, 0, 2, 2, 2, --3, 0, 2, 2, 1, --2, 0, 2, 2, 0, -2, -1, 0, 0, 1, --2, 1, 2, 2, 2, -1, 1, 0, 1, 0, -0, 1, 4, -2, 2, --1, 1, 0, -2, 1, -0, 0, 0, -4, 1, -1, -1, 0, 2, 1, -1, 1, 0, 2, 1, --1, 2, 2, 2, 2, -3, 1, 2, -2, 2, -0, -1, 0, 4, 0, -2, -1, 0, 2, 0, -0, 0, 4, 0, 1, -2, 0, 4, -2, 2, --1, -1, 2, 4, 1, -1, 0, 0, 4, 1, -1, -2, 2, 2, 2, -0, 0, 2, 3, 2, --1, 1, 2, 4, 2, -3, 0, 0, 2, 0, --1, 0, 4, 2, 2, -1, 1, 2, 2, 1, --2, 0, 2, 6, 2, -2, 1, 2, 2, 2, --1, 0, 2, 6, 2, -1, 0, 2, 4, 1, -2, 0, 2, 4, 2, -1, 1, -2, 1, 0, --3, 1, 2, 1, 2, -2, 0, -2, 0, 2, --1, 0, 0, 1, 2, --4, 0, 2, 2, 1, --1, -1, 0, 1, 0, -0, 0, -2, 2, 2, -1, 0, 0, -1, 2, -0, -1, 2, -2, 3, --2, 1, 2, 0, 0, -0, 0, 2, -2, 4, --2, -2, 0, 2, 0, --2, 0, -2, 4, 0, -0, -2, -2, 2, 0, -1, 2, 0, -2, 1, -3, 0, 0, -4, 1, --1, 1, 2, -2, 2, -1, -1, 2, -4, 1, -1, 1, 0, -2, 2, --3, 0, 2, 0, 0, --3, 0, 2, 0, 2, --2, 0, 0, 1, 0, -0, 0, -2, 1, 0, --3, 0, 0, 2, 1, --1, -1, -2, 2, 0, -0, 1, 2, -4, 1, -2, 1, 0, -4, 1, -0, 2, 0, -2, 1, -1, 0, 0, -3, 1, --2, 0, 2, -2, 2, --2, -1, 0, 0, 1, --4, 0, 0, 2, 0, -1, 1, 0, -4, 1, --1, 0, 2, -4, 1, -0, 0, 4, -4, 1, -0, 3, 2, -2, 2, --3, -1, 0, 4, 0, --3, 0, 0, 4, 1, -1, -1, -2, 2, 0, --1, -1, 0, 2, 2, -1, -2, 0, 0, 1, -1, -1, 0, 0, 2, -0, 0, 0, 1, 2, --1, -1, 2, 0, 0, -1, -2, 2, -2, 2, -0, -1, 2, -1, 1, --1, 0, 2, 0, 3, -1, 1, 0, 0, 2, --1, 1, 2, 0, 0, -1, 2, 0, 0, 0, --1, 2, 2, 0, 2, --1, 0, 4, -2, 1, -3, 0, 2, -4, 2, -1, 2, 2, -2, 1, -1, 0, 4, -4, 2, --2, -1, 0, 4, 1, -0, -1, 0, 2, 2, --2, 1, 0, 4, 0, --2, -1, 2, 2, 1, -2, 0, -2, 2, 0, -1, 0, 0, 1, 1, -0, 1, 0, 2, 2, -1, -1, 2, -1, 2, --2, 0, 4, 0, 1, -2, 1, 0, 0, 1, -0, 1, 2, 0, 0, -0, -1, 4, -2, 2, -0, 0, 4, -2, 4, -0, 2, 2, 0, 1, --3, 0, 0, 6, 0, --1, -1, 0, 4, 1, -1, -2, 0, 2, 0, --1, 0, 0, 4, 2, --1, -2, 2, 2, 1, --1, 0, 0, -2, 2, -1, 0, -2, -2, 1, -0, 0, -2, -2, 1, --2, 0, -2, 0, 1, -0, 0, 0, 3, 1, -0, 0, 0, 3, 0, --1, 1, 0, 4, 0, --1, -1, 2, 2, 0, --2, 0, 2, 3, 2, -1, 0, 0, 2, 2, -0, -1, 2, 1, 2, -3, -1, 0, 0, 0, -2, 0, 0, 1, 0, -1, -1, 2, 0, 0, -0, 0, 2, 1, 0, -1, 0, 2, 0, 3, -3, 1, 0, 0, 0, -3, -1, 2, -2, 2, -2, 0, 2, -1, 1, -1, 1, 2, 0, 0, -0, 0, 4, -1, 2, -1, 2, 2, 0, 2, --2, 0, 0, 6, 0, -0, -1, 0, 4, 1, --2, -1, 2, 4, 1, -0, -2, 2, 2, 1, -0, -1, 2, 2, 0, --1, 0, 2, 3, 1, --2, 1, 2, 4, 2, -2, 0, 0, 2, 2, -2, -2, 2, 0, 2, --1, 1, 2, 3, 2, -3, 0, 2, -1, 2, -4, 0, 2, -2, 1, --1, 0, 0, 6, 0, --1, -2, 2, 4, 2, --3, 0, 2, 6, 2, --1, 0, 2, 4, 0, -3, 0, 0, 2, 1, -3, -1, 2, 0, 1, -3, 0, 2, 0, 0, -1, 0, 4, 0, 2, -5, 0, 2, -2, 2, -0, -1, 2, 4, 1, -2, -1, 2, 2, 1, -0, 1, 2, 4, 2, -1, -1, 2, 4, 2, -3, -1, 2, 2, 2, -3, 0, 2, 2, 1, -5, 0, 2, 0, 2, -0, 0, 2, 6, 2, -4, 0, 2, 2, 2, -0, -1, 1, -1, 1, --1, 0, 1, 0, 3, -0, -2, 2, -2, 3, -1, 0, -1, 0, 1, -2, -2, 0, -2, 1, --1, 0, 1, 0, 2, --1, 0, 1, 0, 1, --1, -1, 2, -1, 2, --2, 2, 0, 2, 2, --1, 0, 1, 0, 0, --4, 1, 2, 2, 2, --3, 0, 2, 1, 1, --2, -1, 2, 0, 2, -1, 0, -2, 1, 1, -2, -1, -2, 0, 1, --4, 0, 2, 2, 0, --3, 1, 0, 3, 0, --1, 0, -1, 2, 0, -0, -2, 0, 0, 2, -0, -2, 0, 0, 2, --3, 0, 0, 3, 0, --2, -1, 0, 2, 2, --1, 0, -2, 3, 0, --4, 0, 0, 4, 0, -2, 1, -2, 0, 1, -2, -1, 0, -2, 2, -0, 0, 1, -1, 0, --1, 2, 0, 1, 0, --2, 1, 2, 0, 2, -1, 1, 0, -1, 1, -1, 0, 1, -2, 1, -0, 2, 0, 0, 2, -1, -1, 2, -3, 1, --1, 1, 2, -1, 1, --2, 0, 4, -2, 2, --2, 0, 4, -2, 1, --2, -2, 0, 2, 1, --2, 0, -2, 4, 0, -1, 2, 2, -4, 1, -1, 1, 2, -4, 2, --1, 2, 2, -2, 1, -2, 0, 0, -3, 1, --1, 2, 0, 0, 1, -0, 0, 0, -2, 0, --1, -1, 2, -2, 2, --1, 1, 0, 0, 2, -0, 0, 0, -1, 2, --2, 1, 0, 1, 0, -1, -2, 0, -2, 1, -1, 0, -2, 0, 2, --3, 1, 0, 2, 0, --1, 1, -2, 2, 0, --1, -1, 0, 0, 2, --3, 0, 0, 2, 0, --3, -1, 0, 2, 0, -2, 0, 2, -6, 1, -0, 1, 2, -4, 2, -2, 0, 0, -4, 2, --2, 1, 2, -2, 1, -0, -1, 2, -4, 1, -0, 1, 0, -2, 2, --1, 0, 0, -2, 0, -2, 0, -2, -2, 1, --4, 0, 2, 0, 1, --1, -1, 0, -1, 1, -0, 0, -2, 0, 2, --3, 0, 0, 1, 0, --1, 0, -2, 1, 0, --2, 0, -2, 2, 1, -0, 0, -4, 2, 0, --2, -1, -2, 2, 0, -1, 0, 2, -6, 1, --1, 0, 2, -4, 2, -1, 0, 0, -4, 2, -2, 1, 2, -4, 2, -2, 1, 2, -4, 1, -0, 1, 4, -4, 4, -0, 1, 4, -4, 2, --1, -1, -2, 4, 0, --1, -3, 0, 2, 0, --1, 0, -2, 4, 1, --2, -1, 0, 3, 0, -0, 0, -2, 3, 0, --2, 0, 0, 3, 1, -0, -1, 0, 1, 0, --3, 0, 2, 2, 0, -1, 1, -2, 2, 0, --1, 1, 0, 2, 2, -1, -2, 2, -2, 1, -0, 0, 1, 0, 2, -0, 0, 1, 0, 1, -0, 0, 1, 0, 0, --1, 2, 0, 2, 1, -0, 0, 2, 0, 2, --2, 0, 2, 0, 2, -2, 0, 0, -1, 1, -3, 0, 0, -2, 1, -1, 0, 2, -2, 3, -1, 2, 0, 0, 1, -2, 0, 2, -3, 2, --1, 1, 4, -2, 2, --2, -2, 0, 4, 0, -0, -3, 0, 2, 0, -0, 0, -2, 4, 0, --1, -1, 0, 3, 0, --2, 0, 0, 4, 2, --1, 0, 0, 3, 1, -2, -2, 0, 0, 0, -1, -1, 0, 1, 0, --1, 0, 0, 2, 0, -0, -2, 2, 0, 1, --1, 0, 1, 2, 1, --1, 1, 0, 3, 0, --1, -1, 2, 1, 2, -0, -1, 2, 0, 0, --2, 1, 2, 2, 1, -2, -2, 2, -2, 2, -1, 1, 0, 1, 1, -1, 0, 1, 0, 1, -1, 0, 1, 0, 0, -0, 2, 0, 2, 0, -2, -1, 2, -2, 1, -0, -1, 4, -2, 1, -0, 0, 4, -2, 3, -0, 1, 4, -2, 1, -4, 0, 2, -4, 2, -2, 2, 2, -2, 2, -2, 0, 4, -4, 2, --1, -2, 0, 4, 0, --1, -3, 2, 2, 2, --3, 0, 2, 4, 2, --3, 0, 2, -2, 1, --1, -1, 0, -2, 1, --3, 0, 0, 0, 2, --3, 0, -2, 2, 0, -0, 1, 0, -4, 1, --2, 1, 0, -2, 1, --4, 0, 0, 0, 1, --1, 0, 0, -4, 1, --3, 0, 0, -2, 1, -0, 0, 0, 3, 2, --1, 1, 0, 4, 1, -1, -2, 2, 0, 1, -0, 1, 0, 3, 0, --1, 0, 2, 2, 3, -0, 0, 2, 2, 2, --2, 0, 2, 2, 2, --1, 1, 2, 2, 0, -3, 0, 0, 0, 2, -2, 1, 0, 1, 0, -2, -1, 2, -1, 2, -0, 0, 2, 0, 1, -0, 0, 3, 0, 3, -0, 0, 3, 0, 2, --1, 2, 2, 2, 1, --1, 0, 4, 0, 0, -1, 2, 2, 0, 1, -3, 1, 2, -2, 1, -1, 1, 4, -2, 2, --2, -1, 0, 6, 0, -0, -2, 0, 4, 0, --2, 0, 0, 6, 1, --2, -2, 2, 4, 2, -0, -3, 2, 2, 2, -0, 0, 0, 4, 2, --1, -1, 2, 3, 2, --2, 0, 2, 4, 0, -2, -1, 0, 2, 1, -1, 0, 0, 3, 0, -0, 1, 0, 4, 1, -0, 1, 0, 4, 0, -1, -1, 2, 1, 2, -0, 0, 2, 2, 3, -1, 0, 2, 2, 2, --1, 0, 2, 2, 2, --2, 0, 4, 2, 1, -2, 1, 0, 2, 1, -2, 1, 0, 2, 0, -2, -1, 2, 0, 0, -1, 0, 2, 1, 0, -0, 1, 2, 2, 0, -2, 0, 2, 0, 3, -3, 0, 2, 0, 2, -1, 0, 2, 0, 2, -1, 0, 3, 0, 3, -1, 1, 2, 1, 1, -0, 2, 2, 2, 2, -2, 1, 2, 0, 0, -2, 0, 4, -2, 1, -4, 1, 2, -2, 2, --1, -1, 0, 6, 0, --3, -1, 2, 6, 2, --1, 0, 0, 6, 1, --3, 0, 2, 6, 1, -1, -1, 0, 4, 1, -1, -1, 0, 4, 0, --2, 0, 2, 5, 2, -1, -2, 2, 2, 1, -3, -1, 0, 2, 0, -1, -1, 2, 2, 0, -0, 0, 2, 3, 1, --1, 1, 2, 4, 1, -0, 1, 2, 3, 2, --1, 0, 4, 2, 1, -2, 0, 2, 1, 1, -5, 0, 0, 0, 0, -2, 1, 2, 1, 2, -1, 0, 4, 0, 1, -3, 1, 2, 0, 1, -3, 0, 4, -2, 2, --2, -1, 2, 6, 2, -0, 0, 0, 6, 0, -0, -2, 2, 4, 2, --2, 0, 2, 6, 1, -2, 0, 0, 4, 1, -2, 0, 0, 4, 0, -2, -2, 2, 2, 2, -0, 0, 2, 4, 0, -1, 0, 2, 3, 2, -4, 0, 0, 2, 0, -2, 0, 2, 2, 0, -0, 0, 4, 2, 2, -4, -1, 2, 0, 2, -3, 0, 2, 1, 2, -2, 1, 2, 2, 1, -4, 1, 2, 0, 2, --1, -1, 2, 6, 2, --1, 0, 2, 6, 1, -1, -1, 2, 4, 1, -1, 1, 2, 4, 2, -3, 1, 2, 2, 2, -5, 0, 2, 0, 1, -2, -1, 2, 4, 2, -2, 0, 2, 4, 1, + 0, 0, 0, 0, 1, + 0, 0, 2, -2, 2, + 0, 0, 2, 0, 2, + 0, 0, 0, 0, 2, + 0, 1, 0, 0, 0, + 0, 1, 2, -2, 2, + 1, 0, 0, 0, 0, + 0, 0, 2, 0, 1, + 1, 0, 2, 0, 2, + 0, -1, 2, -2, 2, + 0, 0, 2, -2, 1, + -1, 0, 2, 0, 2, + -1, 0, 0, 2, 0, + 1, 0, 0, 0, 1, + -1, 0, 0, 0, 1, + -1, 0, 2, 2, 2, + 1, 0, 2, 0, 1, + -2, 0, 2, 0, 1, + 0, 0, 0, 2, 0, + 0, 0, 2, 2, 2, + 0, -2, 2, -2, 2, + -2, 0, 0, 2, 0, + 2, 0, 2, 0, 2, + 1, 0, 2, -2, 2, + -1, 0, 2, 0, 1, + 2, 0, 0, 0, 0, + 0, 0, 2, 0, 0, + 0, 1, 0, 0, 1, + -1, 0, 0, 2, 1, + 0, 2, 2, -2, 2, + 0, 0, -2, 2, 0, + 1, 0, 0, -2, 1, + 0, -1, 0, 0, 1, + -1, 0, 2, 2, 1, + 0, 2, 0, 0, 0, + 1, 0, 2, 2, 2, + -2, 0, 2, 0, 0, + 0, 1, 2, 0, 2, + 0, 0, 2, 2, 1, + 0, -1, 2, 0, 2, + 0, 0, 0, 2, 1, + 1, 0, 2, -2, 1, + 2, 0, 2, -2, 2, + -2, 0, 0, 2, 1, + 2, 0, 2, 0, 1, + 0, -1, 2, -2, 1, + 0, 0, 0, -2, 1, + -1, -1, 0, 2, 0, + 2, 0, 0, -2, 1, + 1, 0, 0, 2, 0, + 0, 1, 2, -2, 1, + 1, -1, 0, 0, 0, + -2, 0, 2, 0, 2, + 3, 0, 2, 0, 2, + 0, -1, 0, 2, 0, + 1, -1, 2, 0, 2, + 0, 0, 0, 1, 0, + -1, -1, 2, 2, 2, + -1, 0, 2, 0, 0, + 0, -1, 2, 2, 2, + -2, 0, 0, 0, 1, + 1, 1, 2, 0, 2, + 2, 0, 0, 0, 1, + -1, 1, 0, 1, 0, + 1, 1, 0, 0, 0, + 1, 0, 2, 0, 0, + -1, 0, 2, -2, 1, + 1, 0, 0, 0, 2, + -1, 0, 0, 1, 0, + 0, 0, 2, 1, 2, + -1, 0, 2, 4, 2, + -1, 1, 0, 1, 1, + 0, -2, 2, -2, 1, + 1, 0, 2, 2, 1, + -2, 0, 2, 2, 2, + -1, 0, 0, 0, 2, + 1, 1, 2, -2, 2, + -2, 0, 2, 4, 2, + -1, 0, 4, 0, 2, + 2, 0, 2, -2, 1, + 2, 0, 2, 2, 2, + 1, 0, 0, 2, 1, + 3, 0, 0, 0, 0, + 3, 0, 2, -2, 2, + 0, 0, 4, -2, 2, + 0, 1, 2, 0, 1, + 0, 0, -2, 2, 1, + 0, 0, 2, -2, 3, + -1, 0, 0, 4, 0, + 2, 0, -2, 0, 1, + -2, 0, 0, 4, 0, + -1, -1, 0, 2, 1, + -1, 0, 0, 1, 1, + 0, 1, 0, 0, 2, + 0, 0, -2, 0, 1, + 0, -1, 2, 0, 1, + 0, 0, 2, -1, 2, + 0, 0, 2, 4, 2, + -2, -1, 0, 2, 0, + 1, 1, 0, -2, 1, + -1, 1, 0, 2, 0, + -1, 1, 0, 1, 2, + 1, -1, 0, 0, 1, + 1, -1, 2, 2, 2, + -1, 1, 2, 2, 2, + 3, 0, 2, 0, 1, + 0, 1, -2, 2, 0, + -1, 0, 0, -2, 1, + 0, 1, 2, 2, 2, + -1, -1, 2, 2, 1, + 0, -1, 0, 0, 2, + 1, 0, 2, -4, 1, + -1, 0, -2, 2, 0, + 0, -1, 2, 2, 1, + 2, -1, 2, 0, 2, + 0, 0, 0, 2, 2, + 1, -1, 2, 0, 1, + -1, 1, 2, 0, 2, + 0, 1, 0, 2, 0, + 0, -1, -2, 2, 0, + 0, 3, 2, -2, 2, + 0, 0, 0, 1, 1, + -1, 0, 2, 2, 0, + 2, 1, 2, 0, 2, + 1, 1, 0, 0, 1, + 1, 1, 2, 0, 1, + 2, 0, 0, 2, 0, + 1, 0, -2, 2, 0, + -1, 0, 0, 2, 2, + 0, 1, 0, 1, 0, + 0, 1, 0, -2, 1, + -1, 0, 2, -2, 2, + 0, 0, 0, -1, 1, + -1, 1, 0, 0, 1, + 1, 0, 2, -1, 2, + 1, -1, 0, 2, 0, + 0, 0, 0, 4, 0, + 1, 0, 2, 1, 2, + 0, 0, 2, 1, 1, + 1, 0, 0, -2, 2, + -1, 0, 2, 4, 1, + 1, 0, -2, 0, 1, + 1, 1, 2, -2, 1, + 0, 0, 2, 2, 0, + -1, 0, 2, -1, 1, + -2, 0, 2, 2, 1, + 4, 0, 2, 0, 2, + 2, -1, 0, 0, 0, + 2, 1, 2, -2, 2, + 0, 1, 2, 1, 2, + 1, 0, 4, -2, 2, + -1, -1, 0, 0, 1, + 0, 1, 0, 2, 1, + -2, 0, 2, 4, 1, + 2, 0, 2, 0, 0, + 1, 0, 0, 1, 0, + -1, 0, 0, 4, 1, + -1, 0, 4, 0, 1, + 2, 0, 2, 2, 1, + 0, 0, 2, -3, 2, + -1, -2, 0, 2, 0, + 2, 1, 0, 0, 0, + 0, 0, 4, 0, 2, + 0, 0, 0, 0, 3, + 0, 3, 0, 0, 0, + 0, 0, 2, -4, 1, + 0, -1, 0, 2, 1, + 0, 0, 0, 4, 1, + -1, -1, 2, 4, 2, + 1, 0, 2, 4, 2, + -2, 2, 0, 2, 0, + -2, -1, 2, 0, 1, + -2, 0, 0, 2, 2, + -1, -1, 2, 0, 2, + 0, 0, 4, -2, 1, + 3, 0, 2, -2, 1, + -2, -1, 0, 2, 1, + 1, 0, 0, -1, 1, + 0, -2, 0, 2, 0, + -2, 0, 0, 4, 1, + -3, 0, 0, 0, 1, + 1, 1, 2, 2, 2, + 0, 0, 2, 4, 1, + 3, 0, 2, 2, 2, + -1, 1, 2, -2, 1, + 2, 0, 0, -4, 1, + 0, 0, 0, -2, 2, + 2, 0, 2, -4, 1, + -1, 1, 0, 2, 1, + 0, 0, 2, -1, 1, + 0, -2, 2, 2, 2, + 2, 0, 0, 2, 1, + 4, 0, 2, -2, 2, + 2, 0, 0, -2, 2, + 0, 2, 0, 0, 1, + 1, 0, 0, -4, 1, + 0, 2, 2, -2, 1, + -3, 0, 0, 4, 0, + -1, 1, 2, 0, 1, + -1, -1, 0, 4, 0, + -1, -2, 2, 2, 2, + -2, -1, 2, 4, 2, + 1, -1, 2, 2, 1, + -2, 1, 0, 2, 0, + -2, 1, 2, 0, 1, + 2, 1, 0, -2, 1, + -3, 0, 2, 0, 1, + -2, 0, 2, -2, 1, + -1, 1, 0, 2, 2, + 0, -1, 2, -1, 2, + -1, 0, 4, -2, 2, + 0, -2, 2, 0, 2, + -1, 0, 2, 1, 2, + 2, 0, 0, 0, 2, + 0, 0, 2, 0, 3, + -2, 0, 4, 0, 2, + -1, 0, -2, 0, 1, + -1, 1, 2, 2, 1, + 3, 0, 0, 0, 1, + -1, 0, 2, 3, 2, + 2, -1, 2, 0, 1, + 0, 1, 2, 2, 1, + 0, -1, 2, 4, 2, + 2, -1, 2, 2, 2, + 0, 2, -2, 2, 0, + -1, -1, 2, -1, 1, + 0, -2, 0, 0, 1, + 1, 0, 2, -4, 2, + 1, -1, 0, -2, 1, + -1, -1, 2, 0, 1, + 1, -1, 2, -2, 2, + -2, -1, 0, 4, 0, + -1, 0, 0, 3, 0, + -2, -1, 2, 2, 2, + 0, 2, 2, 0, 2, + 1, 1, 0, 2, 0, + 2, 0, 2, -1, 2, + 1, 0, 2, 1, 1, + 4, 0, 0, 0, 0, + 2, 1, 2, 0, 1, + 3, -1, 2, 0, 2, + -2, 2, 0, 2, 1, + 1, 0, 2, -3, 1, + 1, 1, 2, -4, 1, + -1, -1, 2, -2, 1, + 0, -1, 0, -1, 1, + 0, -1, 0, -2, 1, + -2, 0, 0, 0, 2, + -2, 0, -2, 2, 0, + -1, 0, -2, 4, 0, + 1, -2, 0, 0, 0, + 0, 1, 0, 1, 1, + -1, 2, 0, 2, 0, + 1, -1, 2, -2, 1, + 1, 2, 2, -2, 2, + 2, -1, 2, -2, 2, + 1, 0, 2, -1, 1, + 2, 1, 2, -2, 1, + -2, 0, 0, -2, 1, + 1, -2, 2, 0, 2, + 0, 1, 2, 1, 1, + 1, 0, 4, -2, 1, + -2, 0, 4, 2, 2, + 1, 1, 2, 1, 2, + 1, 0, 0, 4, 0, + 1, 0, 2, 2, 0, + 2, 0, 2, 1, 2, + 3, 1, 2, 0, 2, + 4, 0, 2, 0, 1, + -2, -1, 2, 0, 0, + 0, 1, -2, 2, 1, + 1, 0, -2, 1, 0, + 0, -1, -2, 2, 1, + 2, -1, 0, -2, 1, + -1, 0, 2, -1, 2, + 1, 0, 2, -3, 2, + 0, 1, 2, -2, 3, + 0, 0, 2, -3, 1, + -1, 0, -2, 2, 1, + 0, 0, 2, -4, 2, + -2, 1, 0, 0, 1, + -1, 0, 0, -1, 1, + 2, 0, 2, -4, 2, + 0, 0, 4, -4, 4, + 0, 0, 4, -4, 2, + -1, -2, 0, 2, 1, + -2, 0, 0, 3, 0, + 1, 0, -2, 2, 1, + -3, 0, 2, 2, 2, + -3, 0, 2, 2, 1, + -2, 0, 2, 2, 0, + 2, -1, 0, 0, 1, + -2, 1, 2, 2, 2, + 1, 1, 0, 1, 0, + 0, 1, 4, -2, 2, + -1, 1, 0, -2, 1, + 0, 0, 0, -4, 1, + 1, -1, 0, 2, 1, + 1, 1, 0, 2, 1, + -1, 2, 2, 2, 2, + 3, 1, 2, -2, 2, + 0, -1, 0, 4, 0, + 2, -1, 0, 2, 0, + 0, 0, 4, 0, 1, + 2, 0, 4, -2, 2, + -1, -1, 2, 4, 1, + 1, 0, 0, 4, 1, + 1, -2, 2, 2, 2, + 0, 0, 2, 3, 2, + -1, 1, 2, 4, 2, + 3, 0, 0, 2, 0, + -1, 0, 4, 2, 2, + 1, 1, 2, 2, 1, + -2, 0, 2, 6, 2, + 2, 1, 2, 2, 2, + -1, 0, 2, 6, 2, + 1, 0, 2, 4, 1, + 2, 0, 2, 4, 2, + 1, 1, -2, 1, 0, + -3, 1, 2, 1, 2, + 2, 0, -2, 0, 2, + -1, 0, 0, 1, 2, + -4, 0, 2, 2, 1, + -1, -1, 0, 1, 0, + 0, 0, -2, 2, 2, + 1, 0, 0, -1, 2, + 0, -1, 2, -2, 3, + -2, 1, 2, 0, 0, + 0, 0, 2, -2, 4, + -2, -2, 0, 2, 0, + -2, 0, -2, 4, 0, + 0, -2, -2, 2, 0, + 1, 2, 0, -2, 1, + 3, 0, 0, -4, 1, + -1, 1, 2, -2, 2, + 1, -1, 2, -4, 1, + 1, 1, 0, -2, 2, + -3, 0, 2, 0, 0, + -3, 0, 2, 0, 2, + -2, 0, 0, 1, 0, + 0, 0, -2, 1, 0, + -3, 0, 0, 2, 1, + -1, -1, -2, 2, 0, + 0, 1, 2, -4, 1, + 2, 1, 0, -4, 1, + 0, 2, 0, -2, 1, + 1, 0, 0, -3, 1, + -2, 0, 2, -2, 2, + -2, -1, 0, 0, 1, + -4, 0, 0, 2, 0, + 1, 1, 0, -4, 1, + -1, 0, 2, -4, 1, + 0, 0, 4, -4, 1, + 0, 3, 2, -2, 2, + -3, -1, 0, 4, 0, + -3, 0, 0, 4, 1, + 1, -1, -2, 2, 0, + -1, -1, 0, 2, 2, + 1, -2, 0, 0, 1, + 1, -1, 0, 0, 2, + 0, 0, 0, 1, 2, + -1, -1, 2, 0, 0, + 1, -2, 2, -2, 2, + 0, -1, 2, -1, 1, + -1, 0, 2, 0, 3, + 1, 1, 0, 0, 2, + -1, 1, 2, 0, 0, + 1, 2, 0, 0, 0, + -1, 2, 2, 0, 2, + -1, 0, 4, -2, 1, + 3, 0, 2, -4, 2, + 1, 2, 2, -2, 1, + 1, 0, 4, -4, 2, + -2, -1, 0, 4, 1, + 0, -1, 0, 2, 2, + -2, 1, 0, 4, 0, + -2, -1, 2, 2, 1, + 2, 0, -2, 2, 0, + 1, 0, 0, 1, 1, + 0, 1, 0, 2, 2, + 1, -1, 2, -1, 2, + -2, 0, 4, 0, 1, + 2, 1, 0, 0, 1, + 0, 1, 2, 0, 0, + 0, -1, 4, -2, 2, + 0, 0, 4, -2, 4, + 0, 2, 2, 0, 1, + -3, 0, 0, 6, 0, + -1, -1, 0, 4, 1, + 1, -2, 0, 2, 0, + -1, 0, 0, 4, 2, + -1, -2, 2, 2, 1, + -1, 0, 0, -2, 2, + 1, 0, -2, -2, 1, + 0, 0, -2, -2, 1, + -2, 0, -2, 0, 1, + 0, 0, 0, 3, 1, + 0, 0, 0, 3, 0, + -1, 1, 0, 4, 0, + -1, -1, 2, 2, 0, + -2, 0, 2, 3, 2, + 1, 0, 0, 2, 2, + 0, -1, 2, 1, 2, + 3, -1, 0, 0, 0, + 2, 0, 0, 1, 0, + 1, -1, 2, 0, 0, + 0, 0, 2, 1, 0, + 1, 0, 2, 0, 3, + 3, 1, 0, 0, 0, + 3, -1, 2, -2, 2, + 2, 0, 2, -1, 1, + 1, 1, 2, 0, 0, + 0, 0, 4, -1, 2, + 1, 2, 2, 0, 2, + -2, 0, 0, 6, 0, + 0, -1, 0, 4, 1, + -2, -1, 2, 4, 1, + 0, -2, 2, 2, 1, + 0, -1, 2, 2, 0, + -1, 0, 2, 3, 1, + -2, 1, 2, 4, 2, + 2, 0, 0, 2, 2, + 2, -2, 2, 0, 2, + -1, 1, 2, 3, 2, + 3, 0, 2, -1, 2, + 4, 0, 2, -2, 1, + -1, 0, 0, 6, 0, + -1, -2, 2, 4, 2, + -3, 0, 2, 6, 2, + -1, 0, 2, 4, 0, + 3, 0, 0, 2, 1, + 3, -1, 2, 0, 1, + 3, 0, 2, 0, 0, + 1, 0, 4, 0, 2, + 5, 0, 2, -2, 2, + 0, -1, 2, 4, 1, + 2, -1, 2, 2, 1, + 0, 1, 2, 4, 2, + 1, -1, 2, 4, 2, + 3, -1, 2, 2, 2, + 3, 0, 2, 2, 1, + 5, 0, 2, 0, 2, + 0, 0, 2, 6, 2, + 4, 0, 2, 2, 2, + 0, -1, 1, -1, 1, + -1, 0, 1, 0, 3, + 0, -2, 2, -2, 3, + 1, 0, -1, 0, 1, + 2, -2, 0, -2, 1, + -1, 0, 1, 0, 2, + -1, 0, 1, 0, 1, + -1, -1, 2, -1, 2, + -2, 2, 0, 2, 2, + -1, 0, 1, 0, 0, + -4, 1, 2, 2, 2, + -3, 0, 2, 1, 1, + -2, -1, 2, 0, 2, + 1, 0, -2, 1, 1, + 2, -1, -2, 0, 1, + -4, 0, 2, 2, 0, + -3, 1, 0, 3, 0, + -1, 0, -1, 2, 0, + 0, -2, 0, 0, 2, + 0, -2, 0, 0, 2, + -3, 0, 0, 3, 0, + -2, -1, 0, 2, 2, + -1, 0, -2, 3, 0, + -4, 0, 0, 4, 0, + 2, 1, -2, 0, 1, + 2, -1, 0, -2, 2, + 0, 0, 1, -1, 0, + -1, 2, 0, 1, 0, + -2, 1, 2, 0, 2, + 1, 1, 0, -1, 1, + 1, 0, 1, -2, 1, + 0, 2, 0, 0, 2, + 1, -1, 2, -3, 1, + -1, 1, 2, -1, 1, + -2, 0, 4, -2, 2, + -2, 0, 4, -2, 1, + -2, -2, 0, 2, 1, + -2, 0, -2, 4, 0, + 1, 2, 2, -4, 1, + 1, 1, 2, -4, 2, + -1, 2, 2, -2, 1, + 2, 0, 0, -3, 1, + -1, 2, 0, 0, 1, + 0, 0, 0, -2, 0, + -1, -1, 2, -2, 2, + -1, 1, 0, 0, 2, + 0, 0, 0, -1, 2, + -2, 1, 0, 1, 0, + 1, -2, 0, -2, 1, + 1, 0, -2, 0, 2, + -3, 1, 0, 2, 0, + -1, 1, -2, 2, 0, + -1, -1, 0, 0, 2, + -3, 0, 0, 2, 0, + -3, -1, 0, 2, 0, + 2, 0, 2, -6, 1, + 0, 1, 2, -4, 2, + 2, 0, 0, -4, 2, + -2, 1, 2, -2, 1, + 0, -1, 2, -4, 1, + 0, 1, 0, -2, 2, + -1, 0, 0, -2, 0, + 2, 0, -2, -2, 1, + -4, 0, 2, 0, 1, + -1, -1, 0, -1, 1, + 0, 0, -2, 0, 2, + -3, 0, 0, 1, 0, + -1, 0, -2, 1, 0, + -2, 0, -2, 2, 1, + 0, 0, -4, 2, 0, + -2, -1, -2, 2, 0, + 1, 0, 2, -6, 1, + -1, 0, 2, -4, 2, + 1, 0, 0, -4, 2, + 2, 1, 2, -4, 2, + 2, 1, 2, -4, 1, + 0, 1, 4, -4, 4, + 0, 1, 4, -4, 2, + -1, -1, -2, 4, 0, + -1, -3, 0, 2, 0, + -1, 0, -2, 4, 1, + -2, -1, 0, 3, 0, + 0, 0, -2, 3, 0, + -2, 0, 0, 3, 1, + 0, -1, 0, 1, 0, + -3, 0, 2, 2, 0, + 1, 1, -2, 2, 0, + -1, 1, 0, 2, 2, + 1, -2, 2, -2, 1, + 0, 0, 1, 0, 2, + 0, 0, 1, 0, 1, + 0, 0, 1, 0, 0, + -1, 2, 0, 2, 1, + 0, 0, 2, 0, 2, + -2, 0, 2, 0, 2, + 2, 0, 0, -1, 1, + 3, 0, 0, -2, 1, + 1, 0, 2, -2, 3, + 1, 2, 0, 0, 1, + 2, 0, 2, -3, 2, + -1, 1, 4, -2, 2, + -2, -2, 0, 4, 0, + 0, -3, 0, 2, 0, + 0, 0, -2, 4, 0, + -1, -1, 0, 3, 0, + -2, 0, 0, 4, 2, + -1, 0, 0, 3, 1, + 2, -2, 0, 0, 0, + 1, -1, 0, 1, 0, + -1, 0, 0, 2, 0, + 0, -2, 2, 0, 1, + -1, 0, 1, 2, 1, + -1, 1, 0, 3, 0, + -1, -1, 2, 1, 2, + 0, -1, 2, 0, 0, + -2, 1, 2, 2, 1, + 2, -2, 2, -2, 2, + 1, 1, 0, 1, 1, + 1, 0, 1, 0, 1, + 1, 0, 1, 0, 0, + 0, 2, 0, 2, 0, + 2, -1, 2, -2, 1, + 0, -1, 4, -2, 1, + 0, 0, 4, -2, 3, + 0, 1, 4, -2, 1, + 4, 0, 2, -4, 2, + 2, 2, 2, -2, 2, + 2, 0, 4, -4, 2, + -1, -2, 0, 4, 0, + -1, -3, 2, 2, 2, + -3, 0, 2, 4, 2, + -3, 0, 2, -2, 1, + -1, -1, 0, -2, 1, + -3, 0, 0, 0, 2, + -3, 0, -2, 2, 0, + 0, 1, 0, -4, 1, + -2, 1, 0, -2, 1, + -4, 0, 0, 0, 1, + -1, 0, 0, -4, 1, + -3, 0, 0, -2, 1, + 0, 0, 0, 3, 2, + -1, 1, 0, 4, 1, + 1, -2, 2, 0, 1, + 0, 1, 0, 3, 0, + -1, 0, 2, 2, 3, + 0, 0, 2, 2, 2, + -2, 0, 2, 2, 2, + -1, 1, 2, 2, 0, + 3, 0, 0, 0, 2, + 2, 1, 0, 1, 0, + 2, -1, 2, -1, 2, + 0, 0, 2, 0, 1, + 0, 0, 3, 0, 3, + 0, 0, 3, 0, 2, + -1, 2, 2, 2, 1, + -1, 0, 4, 0, 0, + 1, 2, 2, 0, 1, + 3, 1, 2, -2, 1, + 1, 1, 4, -2, 2, + -2, -1, 0, 6, 0, + 0, -2, 0, 4, 0, + -2, 0, 0, 6, 1, + -2, -2, 2, 4, 2, + 0, -3, 2, 2, 2, + 0, 0, 0, 4, 2, + -1, -1, 2, 3, 2, + -2, 0, 2, 4, 0, + 2, -1, 0, 2, 1, + 1, 0, 0, 3, 0, + 0, 1, 0, 4, 1, + 0, 1, 0, 4, 0, + 1, -1, 2, 1, 2, + 0, 0, 2, 2, 3, + 1, 0, 2, 2, 2, + -1, 0, 2, 2, 2, + -2, 0, 4, 2, 1, + 2, 1, 0, 2, 1, + 2, 1, 0, 2, 0, + 2, -1, 2, 0, 0, + 1, 0, 2, 1, 0, + 0, 1, 2, 2, 0, + 2, 0, 2, 0, 3, + 3, 0, 2, 0, 2, + 1, 0, 2, 0, 2, + 1, 0, 3, 0, 3, + 1, 1, 2, 1, 1, + 0, 2, 2, 2, 2, + 2, 1, 2, 0, 0, + 2, 0, 4, -2, 1, + 4, 1, 2, -2, 2, + -1, -1, 0, 6, 0, + -3, -1, 2, 6, 2, + -1, 0, 0, 6, 1, + -3, 0, 2, 6, 1, + 1, -1, 0, 4, 1, + 1, -1, 0, 4, 0, + -2, 0, 2, 5, 2, + 1, -2, 2, 2, 1, + 3, -1, 0, 2, 0, + 1, -1, 2, 2, 0, + 0, 0, 2, 3, 1, + -1, 1, 2, 4, 1, + 0, 1, 2, 3, 2, + -1, 0, 4, 2, 1, + 2, 0, 2, 1, 1, + 5, 0, 0, 0, 0, + 2, 1, 2, 1, 2, + 1, 0, 4, 0, 1, + 3, 1, 2, 0, 1, + 3, 0, 4, -2, 2, + -2, -1, 2, 6, 2, + 0, 0, 0, 6, 0, + 0, -2, 2, 4, 2, + -2, 0, 2, 6, 1, + 2, 0, 0, 4, 1, + 2, 0, 0, 4, 0, + 2, -2, 2, 2, 2, + 0, 0, 2, 4, 0, + 1, 0, 2, 3, 2, + 4, 0, 0, 2, 0, + 2, 0, 2, 2, 0, + 0, 0, 4, 2, 2, + 4, -1, 2, 0, 2, + 3, 0, 2, 1, 2, + 2, 1, 2, 2, 1, + 4, 1, 2, 0, 2, + -1, -1, 2, 6, 2, + -1, 0, 2, 6, 1, + 1, -1, 2, 4, 1, + 1, 1, 2, 4, 2, + 3, 1, 2, 2, 2, + 5, 0, 2, 0, 1, + 2, -1, 2, 4, 2, + 2, 0, 2, 4, 1, }; /* Luni-Solar nutation coefficients, unit 1e-7 arcsec * longitude (sin, t*sin, cos), obliquity (cos, t*cos, sin) */ static int32 cls[] = { --172064161, -174666, 33386, 92052331, 9086, 15377, --13170906, -1675, -13696, 5730336, -3015, -4587, --2276413, -234, 2796, 978459, -485, 1374, -2074554, 207, -698, -897492, 470, -291, -1475877, -3633, 11817, 73871, -184, -1924, --516821, 1226, -524, 224386, -677, -174, -711159, 73, -872, -6750, 0, 358, --387298, -367, 380, 200728, 18, 318, --301461, -36, 816, 129025, -63, 367, -215829, -494, 111, -95929, 299, 132, -128227, 137, 181, -68982, -9, 39, -123457, 11, 19, -53311, 32, -4, -156994, 10, -168, -1235, 0, 82, -63110, 63, 27, -33228, 0, -9, --57976, -63, -189, 31429, 0, -75, --59641, -11, 149, 25543, -11, 66, --51613, -42, 129, 26366, 0, 78, -45893, 50, 31, -24236, -10, 20, -63384, 11, -150, -1220, 0, 29, --38571, -1, 158, 16452, -11, 68, -32481, 0, 0, -13870, 0, 0, --47722, 0, -18, 477, 0, -25, --31046, -1, 131, 13238, -11, 59, -28593, 0, -1, -12338, 10, -3, -20441, 21, 10, -10758, 0, -3, -29243, 0, -74, -609, 0, 13, -25887, 0, -66, -550, 0, 11, --14053, -25, 79, 8551, -2, -45, -15164, 10, 11, -8001, 0, -1, --15794, 72, -16, 6850, -42, -5, -21783, 0, 13, -167, 0, 13, --12873, -10, -37, 6953, 0, -14, --12654, 11, 63, 6415, 0, 26, --10204, 0, 25, 5222, 0, 15, -16707, -85, -10, 168, -1, 10, --7691, 0, 44, 3268, 0, 19, --11024, 0, -14, 104, 0, 2, -7566, -21, -11, -3250, 0, -5, --6637, -11, 25, 3353, 0, 14, --7141, 21, 8, 3070, 0, 4, --6302, -11, 2, 3272, 0, 4, -5800, 10, 2, -3045, 0, -1, -6443, 0, -7, -2768, 0, -4, --5774, -11, -15, 3041, 0, -5, --5350, 0, 21, 2695, 0, 12, --4752, -11, -3, 2719, 0, -3, --4940, -11, -21, 2720, 0, -9, -7350, 0, -8, -51, 0, 4, -4065, 0, 6, -2206, 0, 1, -6579, 0, -24, -199, 0, 2, -3579, 0, 5, -1900, 0, 1, -4725, 0, -6, -41, 0, 3, --3075, 0, -2, 1313, 0, -1, --2904, 0, 15, 1233, 0, 7, -4348, 0, -10, -81, 0, 2, --2878, 0, 8, 1232, 0, 4, --4230, 0, 5, -20, 0, -2, --2819, 0, 7, 1207, 0, 3, --4056, 0, 5, 40, 0, -2, --2647, 0, 11, 1129, 0, 5, --2294, 0, -10, 1266, 0, -4, -2481, 0, -7, -1062, 0, -3, -2179, 0, -2, -1129, 0, -2, -3276, 0, 1, -9, 0, 0, --3389, 0, 5, 35, 0, -2, -3339, 0, -13, -107, 0, 1, --1987, 0, -6, 1073, 0, -2, --1981, 0, 0, 854, 0, 0, -4026, 0, -353, -553, 0, -139, -1660, 0, -5, -710, 0, -2, --1521, 0, 9, 647, 0, 4, -1314, 0, 0, -700, 0, 0, --1283, 0, 0, 672, 0, 0, --1331, 0, 8, 663, 0, 4, -1383, 0, -2, -594, 0, -2, -1405, 0, 4, -610, 0, 2, -1290, 0, 0, -556, 0, 0, --1214, 0, 5, 518, 0, 2, -1146, 0, -3, -490, 0, -1, -1019, 0, -1, -527, 0, -1, --1100, 0, 9, 465, 0, 4, --970, 0, 2, 496, 0, 1, -1575, 0, -6, -50, 0, 0, -934, 0, -3, -399, 0, -1, -922, 0, -1, -395, 0, -1, -815, 0, -1, -422, 0, -1, -834, 0, 2, -440, 0, 1, -1248, 0, 0, -170, 0, 1, -1338, 0, -5, -39, 0, 0, -716, 0, -2, -389, 0, -1, -1282, 0, -3, -23, 0, 1, -742, 0, 1, -391, 0, 0, -1020, 0, -25, -495, 0, -10, -715, 0, -4, -326, 0, 2, --666, 0, -3, 369, 0, -1, --667, 0, 1, 346, 0, 1, --704, 0, 0, 304, 0, 0, --694, 0, 5, 294, 0, 2, --1014, 0, -1, 4, 0, -1, --585, 0, -2, 316, 0, -1, --949, 0, 1, 8, 0, -1, --595, 0, 0, 258, 0, 0, -528, 0, 0, -279, 0, 0, --590, 0, 4, 252, 0, 2, -570, 0, -2, -244, 0, -1, --502, 0, 3, 250, 0, 2, --875, 0, 1, 29, 0, 0, --492, 0, -3, 275, 0, -1, -535, 0, -2, -228, 0, -1, --467, 0, 1, 240, 0, 1, -591, 0, 0, -253, 0, 0, --453, 0, -1, 244, 0, -1, -766, 0, 1, 9, 0, 0, --446, 0, 2, 225, 0, 1, --488, 0, 2, 207, 0, 1, --468, 0, 0, 201, 0, 0, --421, 0, 1, 216, 0, 1, -463, 0, 0, -200, 0, 0, --673, 0, 2, 14, 0, 0, -658, 0, 0, -2, 0, 0, --438, 0, 0, 188, 0, 0, --390, 0, 0, 205, 0, 0, -639, -11, -2, -19, 0, 0, -412, 0, -2, -176, 0, -1, --361, 0, 0, 189, 0, 0, -360, 0, -1, -185, 0, -1, -588, 0, -3, -24, 0, 0, --578, 0, 1, 5, 0, 0, --396, 0, 0, 171, 0, 0, -565, 0, -1, -6, 0, 0, --335, 0, -1, 184, 0, -1, -357, 0, 1, -154, 0, 0, -321, 0, 1, -174, 0, 0, --301, 0, -1, 162, 0, 0, --334, 0, 0, 144, 0, 0, -493, 0, -2, -15, 0, 0, -494, 0, -2, -19, 0, 0, -337, 0, -1, -143, 0, -1, -280, 0, -1, -144, 0, 0, -309, 0, 1, -134, 0, 0, --263, 0, 2, 131, 0, 1, -253, 0, 1, -138, 0, 0, -245, 0, 0, -128, 0, 0, -416, 0, -2, -17, 0, 0, --229, 0, 0, 128, 0, 0, -231, 0, 0, -120, 0, 0, --259, 0, 2, 109, 0, 1, -375, 0, -1, -8, 0, 0, -252, 0, 0, -108, 0, 0, --245, 0, 1, 104, 0, 0, -243, 0, -1, -104, 0, 0, -208, 0, 1, -112, 0, 0, -199, 0, 0, -102, 0, 0, --208, 0, 1, 105, 0, 0, -335, 0, -2, -14, 0, 0, --325, 0, 1, 7, 0, 0, --187, 0, 0, 96, 0, 0, -197, 0, -1, -100, 0, 0, --192, 0, 2, 94, 0, 1, --188, 0, 0, 83, 0, 0, -276, 0, 0, -2, 0, 0, --286, 0, 1, 6, 0, 0, -186, 0, -1, -79, 0, 0, --219, 0, 0, 43, 0, 0, -276, 0, 0, 2, 0, 0, --153, 0, -1, 84, 0, 0, --156, 0, 0, 81, 0, 0, --154, 0, 1, 78, 0, 0, --174, 0, 1, 75, 0, 0, --163, 0, 2, 69, 0, 1, --228, 0, 0, 1, 0, 0, -91, 0, -4, -54, 0, -2, -175, 0, 0, -75, 0, 0, --159, 0, 0, 69, 0, 0, -141, 0, 0, -72, 0, 0, -147, 0, 0, -75, 0, 0, --132, 0, 0, 69, 0, 0, -159, 0, -28, -54, 0, 11, -213, 0, 0, -4, 0, 0, -123, 0, 0, -64, 0, 0, --118, 0, -1, 66, 0, 0, -144, 0, -1, -61, 0, 0, --121, 0, 1, 60, 0, 0, --134, 0, 1, 56, 0, 1, --105, 0, 0, 57, 0, 0, --102, 0, 0, 56, 0, 0, -120, 0, 0, -52, 0, 0, -101, 0, 0, -54, 0, 0, --113, 0, 0, 59, 0, 0, --106, 0, 0, 61, 0, 0, --129, 0, 1, 55, 0, 0, --114, 0, 0, 57, 0, 0, -113, 0, -1, -49, 0, 0, --102, 0, 0, 44, 0, 0, --94, 0, 0, 51, 0, 0, --100, 0, -1, 56, 0, 0, -87, 0, 0, -47, 0, 0, -161, 0, 0, -1, 0, 0, -96, 0, 0, -50, 0, 0, -151, 0, -1, -5, 0, 0, --104, 0, 0, 44, 0, 0, --110, 0, 0, 48, 0, 0, --100, 0, 1, 50, 0, 0, -92, 0, -5, 12, 0, -2, -82, 0, 0, -45, 0, 0, -82, 0, 0, -45, 0, 0, --78, 0, 0, 41, 0, 0, --77, 0, 0, 43, 0, 0, -2, 0, 0, 54, 0, 0, -94, 0, 0, -40, 0, 0, --93, 0, 0, 40, 0, 0, --83, 0, 10, 40, 0, -2, -83, 0, 0, -36, 0, 0, --91, 0, 0, 39, 0, 0, -128, 0, 0, -1, 0, 0, --79, 0, 0, 34, 0, 0, --83, 0, 0, 47, 0, 0, -84, 0, 0, -44, 0, 0, -83, 0, 0, -43, 0, 0, -91, 0, 0, -39, 0, 0, --77, 0, 0, 39, 0, 0, -84, 0, 0, -43, 0, 0, --92, 0, 1, 39, 0, 0, --92, 0, 1, 39, 0, 0, --94, 0, 0, 0, 0, 0, -68, 0, 0, -36, 0, 0, --61, 0, 0, 32, 0, 0, -71, 0, 0, -31, 0, 0, -62, 0, 0, -34, 0, 0, --63, 0, 0, 33, 0, 0, --73, 0, 0, 32, 0, 0, -115, 0, 0, -2, 0, 0, --103, 0, 0, 2, 0, 0, -63, 0, 0, -28, 0, 0, -74, 0, 0, -32, 0, 0, --103, 0, -3, 3, 0, -1, --69, 0, 0, 30, 0, 0, -57, 0, 0, -29, 0, 0, -94, 0, 0, -4, 0, 0, -64, 0, 0, -33, 0, 0, --63, 0, 0, 26, 0, 0, --38, 0, 0, 20, 0, 0, --43, 0, 0, 24, 0, 0, --45, 0, 0, 23, 0, 0, -47, 0, 0, -24, 0, 0, --48, 0, 0, 25, 0, 0, -45, 0, 0, -26, 0, 0, -56, 0, 0, -25, 0, 0, -88, 0, 0, 2, 0, 0, --75, 0, 0, 0, 0, 0, -85, 0, 0, 0, 0, 0, -49, 0, 0, -26, 0, 0, --74, 0, -3, -1, 0, -1, --39, 0, 0, 21, 0, 0, -45, 0, 0, -20, 0, 0, -51, 0, 0, -22, 0, 0, --40, 0, 0, 21, 0, 0, -41, 0, 0, -21, 0, 0, --42, 0, 0, 24, 0, 0, --51, 0, 0, 22, 0, 0, --42, 0, 0, 22, 0, 0, -39, 0, 0, -21, 0, 0, -46, 0, 0, -18, 0, 0, --53, 0, 0, 22, 0, 0, -82, 0, 0, -4, 0, 0, -81, 0, -1, -4, 0, 0, -47, 0, 0, -19, 0, 0, -53, 0, 0, -23, 0, 0, --45, 0, 0, 22, 0, 0, --44, 0, 0, -2, 0, 0, --33, 0, 0, 16, 0, 0, --61, 0, 0, 1, 0, 0, -28, 0, 0, -15, 0, 0, --38, 0, 0, 19, 0, 0, --33, 0, 0, 21, 0, 0, --60, 0, 0, 0, 0, 0, -48, 0, 0, -10, 0, 0, -27, 0, 0, -14, 0, 0, -38, 0, 0, -20, 0, 0, -31, 0, 0, -13, 0, 0, --29, 0, 0, 15, 0, 0, -28, 0, 0, -15, 0, 0, --32, 0, 0, 15, 0, 0, -45, 0, 0, -8, 0, 0, --44, 0, 0, 19, 0, 0, -28, 0, 0, -15, 0, 0, --51, 0, 0, 0, 0, 0, --36, 0, 0, 20, 0, 0, -44, 0, 0, -19, 0, 0, -26, 0, 0, -14, 0, 0, --60, 0, 0, 2, 0, 0, -35, 0, 0, -18, 0, 0, --27, 0, 0, 11, 0, 0, -47, 0, 0, -1, 0, 0, -36, 0, 0, -15, 0, 0, --36, 0, 0, 20, 0, 0, --35, 0, 0, 19, 0, 0, --37, 0, 0, 19, 0, 0, -32, 0, 0, -16, 0, 0, -35, 0, 0, -14, 0, 0, -32, 0, 0, -13, 0, 0, -65, 0, 0, -2, 0, 0, -47, 0, 0, -1, 0, 0, -32, 0, 0, -16, 0, 0, -37, 0, 0, -16, 0, 0, --30, 0, 0, 15, 0, 0, --32, 0, 0, 16, 0, 0, --31, 0, 0, 13, 0, 0, -37, 0, 0, -16, 0, 0, -31, 0, 0, -13, 0, 0, -49, 0, 0, -2, 0, 0, -32, 0, 0, -13, 0, 0, -23, 0, 0, -12, 0, 0, --43, 0, 0, 18, 0, 0, -26, 0, 0, -11, 0, 0, --32, 0, 0, 14, 0, 0, --29, 0, 0, 14, 0, 0, --27, 0, 0, 12, 0, 0, -30, 0, 0, 0, 0, 0, --11, 0, 0, 5, 0, 0, --21, 0, 0, 10, 0, 0, --34, 0, 0, 15, 0, 0, --10, 0, 0, 6, 0, 0, --36, 0, 0, 0, 0, 0, --9, 0, 0, 4, 0, 0, --12, 0, 0, 5, 0, 0, --21, 0, 0, 5, 0, 0, --29, 0, 0, -1, 0, 0, --15, 0, 0, 3, 0, 0, --20, 0, 0, 0, 0, 0, -28, 0, 0, 0, 0, -2, -17, 0, 0, 0, 0, 0, --22, 0, 0, 12, 0, 0, --14, 0, 0, 7, 0, 0, -24, 0, 0, -11, 0, 0, -11, 0, 0, -6, 0, 0, -14, 0, 0, -6, 0, 0, -24, 0, 0, 0, 0, 0, -18, 0, 0, -8, 0, 0, --38, 0, 0, 0, 0, 0, --31, 0, 0, 0, 0, 0, --16, 0, 0, 8, 0, 0, -29, 0, 0, 0, 0, 0, --18, 0, 0, 10, 0, 0, --10, 0, 0, 5, 0, 0, --17, 0, 0, 10, 0, 0, -9, 0, 0, -4, 0, 0, -16, 0, 0, -6, 0, 0, -22, 0, 0, -12, 0, 0, -20, 0, 0, 0, 0, 0, --13, 0, 0, 6, 0, 0, --17, 0, 0, 9, 0, 0, --14, 0, 0, 8, 0, 0, -0, 0, 0, -7, 0, 0, -14, 0, 0, 0, 0, 0, -19, 0, 0, -10, 0, 0, --34, 0, 0, 0, 0, 0, --20, 0, 0, 8, 0, 0, -9, 0, 0, -5, 0, 0, --18, 0, 0, 7, 0, 0, -13, 0, 0, -6, 0, 0, -17, 0, 0, 0, 0, 0, --12, 0, 0, 5, 0, 0, -15, 0, 0, -8, 0, 0, --11, 0, 0, 3, 0, 0, -13, 0, 0, -5, 0, 0, --18, 0, 0, 0, 0, 0, --35, 0, 0, 0, 0, 0, -9, 0, 0, -4, 0, 0, --19, 0, 0, 10, 0, 0, --26, 0, 0, 11, 0, 0, -8, 0, 0, -4, 0, 0, --10, 0, 0, 4, 0, 0, -10, 0, 0, -6, 0, 0, --21, 0, 0, 9, 0, 0, --15, 0, 0, 0, 0, 0, -9, 0, 0, -5, 0, 0, --29, 0, 0, 0, 0, 0, --19, 0, 0, 10, 0, 0, -12, 0, 0, -5, 0, 0, -22, 0, 0, -9, 0, 0, --10, 0, 0, 5, 0, 0, --20, 0, 0, 11, 0, 0, --20, 0, 0, 0, 0, 0, --17, 0, 0, 7, 0, 0, -15, 0, 0, -3, 0, 0, -8, 0, 0, -4, 0, 0, -14, 0, 0, 0, 0, 0, --12, 0, 0, 6, 0, 0, -25, 0, 0, 0, 0, 0, --13, 0, 0, 6, 0, 0, --14, 0, 0, 8, 0, 0, -13, 0, 0, -5, 0, 0, --17, 0, 0, 9, 0, 0, --12, 0, 0, 6, 0, 0, --10, 0, 0, 5, 0, 0, -10, 0, 0, -6, 0, 0, --15, 0, 0, 0, 0, 0, --22, 0, 0, 0, 0, 0, -28, 0, 0, -1, 0, 0, -15, 0, 0, -7, 0, 0, -23, 0, 0, -10, 0, 0, -12, 0, 0, -5, 0, 0, -29, 0, 0, -1, 0, 0, --25, 0, 0, 1, 0, 0, -22, 0, 0, 0, 0, 0, --18, 0, 0, 0, 0, 0, -15, 0, 0, 3, 0, 0, --23, 0, 0, 0, 0, 0, -12, 0, 0, -5, 0, 0, --8, 0, 0, 4, 0, 0, --19, 0, 0, 0, 0, 0, --10, 0, 0, 4, 0, 0, -21, 0, 0, -9, 0, 0, -23, 0, 0, -1, 0, 0, --16, 0, 0, 8, 0, 0, --19, 0, 0, 9, 0, 0, --22, 0, 0, 10, 0, 0, -27, 0, 0, -1, 0, 0, -16, 0, 0, -8, 0, 0, -19, 0, 0, -8, 0, 0, -9, 0, 0, -4, 0, 0, --9, 0, 0, 4, 0, 0, --9, 0, 0, 4, 0, 0, --8, 0, 0, 4, 0, 0, -18, 0, 0, -9, 0, 0, -16, 0, 0, -1, 0, 0, --10, 0, 0, 4, 0, 0, --23, 0, 0, 9, 0, 0, -16, 0, 0, -1, 0, 0, --12, 0, 0, 6, 0, 0, --8, 0, 0, 4, 0, 0, -30, 0, 0, -2, 0, 0, -24, 0, 0, -10, 0, 0, -10, 0, 0, -4, 0, 0, --16, 0, 0, 7, 0, 0, --16, 0, 0, 7, 0, 0, -17, 0, 0, -7, 0, 0, --24, 0, 0, 10, 0, 0, --12, 0, 0, 5, 0, 0, --24, 0, 0, 11, 0, 0, --23, 0, 0, 9, 0, 0, --13, 0, 0, 5, 0, 0, --15, 0, 0, 7, 0, 0, -0, 0, -1988, 0, 0, -1679, -0, 0, -63, 0, 0, -27, --4, 0, 0, 0, 0, 0, -0, 0, 5, 0, 0, 4, -5, 0, 0, -3, 0, 0, -0, 0, 364, 0, 0, 176, -0, 0, -1044, 0, 0, -891, --3, 0, 0, 1, 0, 0, -4, 0, 0, -2, 0, 0, -0, 0, 330, 0, 0, 0, -5, 0, 0, -2, 0, 0, -3, 0, 0, -2, 0, 0, --3, 0, 0, 1, 0, 0, --5, 0, 0, 2, 0, 0, -3, 0, 0, -1, 0, 0, -3, 0, 0, 0, 0, 0, -3, 0, 0, 0, 0, 0, -0, 0, 5, 0, 0, 0, -0, 0, 0, 1, 0, 0, -4, 0, 0, -2, 0, 0, -6, 0, 0, 0, 0, 0, -5, 0, 0, -2, 0, 0, --7, 0, 0, 0, 0, 0, --12, 0, 0, 0, 0, 0, -5, 0, 0, -3, 0, 0, -3, 0, 0, -1, 0, 0, --5, 0, 0, 0, 0, 0, -3, 0, 0, 0, 0, 0, --7, 0, 0, 3, 0, 0, -7, 0, 0, -4, 0, 0, -0, 0, -12, 0, 0, -10, -4, 0, 0, -2, 0, 0, -3, 0, 0, -2, 0, 0, --3, 0, 0, 2, 0, 0, --7, 0, 0, 3, 0, 0, --4, 0, 0, 2, 0, 0, --3, 0, 0, 1, 0, 0, -0, 0, 0, 0, 0, 0, --3, 0, 0, 1, 0, 0, -7, 0, 0, -3, 0, 0, --4, 0, 0, 2, 0, 0, -4, 0, 0, -2, 0, 0, --5, 0, 0, 3, 0, 0, -5, 0, 0, 0, 0, 0, --5, 0, 0, 2, 0, 0, -5, 0, 0, -2, 0, 0, --8, 0, 0, 3, 0, 0, -9, 0, 0, 0, 0, 0, -6, 0, 0, -3, 0, 0, --5, 0, 0, 2, 0, 0, -3, 0, 0, 0, 0, 0, --7, 0, 0, 0, 0, 0, --3, 0, 0, 1, 0, 0, -5, 0, 0, 0, 0, 0, -3, 0, 0, 0, 0, 0, --3, 0, 0, 2, 0, 0, -4, 0, 0, -2, 0, 0, -3, 0, 0, -1, 0, 0, --5, 0, 0, 2, 0, 0, -4, 0, 0, -2, 0, 0, -9, 0, 0, -3, 0, 0, -4, 0, 0, 0, 0, 0, -4, 0, 0, -2, 0, 0, --3, 0, 0, 2, 0, 0, --4, 0, 0, 2, 0, 0, -9, 0, 0, -3, 0, 0, --4, 0, 0, 0, 0, 0, --4, 0, 0, 0, 0, 0, -3, 0, 0, -2, 0, 0, -8, 0, 0, 0, 0, 0, -3, 0, 0, 0, 0, 0, --3, 0, 0, 2, 0, 0, -3, 0, 0, -1, 0, 0, -3, 0, 0, -1, 0, 0, --3, 0, 0, 1, 0, 0, -6, 0, 0, -3, 0, 0, -3, 0, 0, 0, 0, 0, --3, 0, 0, 1, 0, 0, --7, 0, 0, 0, 0, 0, -9, 0, 0, 0, 0, 0, --3, 0, 0, 2, 0, 0, --3, 0, 0, 0, 0, 0, --4, 0, 0, 0, 0, 0, --5, 0, 0, 3, 0, 0, --13, 0, 0, 0, 0, 0, --7, 0, 0, 0, 0, 0, -10, 0, 0, 0, 0, 0, -3, 0, 0, -1, 0, 0, -10, 0, 13, 6, 0, -5, -0, 0, 30, 0, 0, 14, -0, 0, -162, 0, 0, -138, -0, 0, 75, 0, 0, 0, --7, 0, 0, 4, 0, 0, --4, 0, 0, 2, 0, 0, -4, 0, 0, -2, 0, 0, -5, 0, 0, -2, 0, 0, -5, 0, 0, -3, 0, 0, --3, 0, 0, 0, 0, 0, --3, 0, 0, 2, 0, 0, --4, 0, 0, 2, 0, 0, --5, 0, 0, 2, 0, 0, -6, 0, 0, 0, 0, 0, -9, 0, 0, 0, 0, 0, -5, 0, 0, 0, 0, 0, --7, 0, 0, 0, 0, 0, --3, 0, 0, 1, 0, 0, --4, 0, 0, 2, 0, 0, -7, 0, 0, 0, 0, 0, --4, 0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, --6, 0, -3, 3, 0, 1, -0, 0, -3, 0, 0, -2, -11, 0, 0, 0, 0, 0, -3, 0, 0, -1, 0, 0, -11, 0, 0, 0, 0, 0, --3, 0, 0, 2, 0, 0, --1, 0, 3, 3, 0, -1, -4, 0, 0, -2, 0, 0, -0, 0, -13, 0, 0, -11, -3, 0, 6, 0, 0, 0, --7, 0, 0, 0, 0, 0, -5, 0, 0, -3, 0, 0, --3, 0, 0, 1, 0, 0, -3, 0, 0, 0, 0, 0, -5, 0, 0, -3, 0, 0, --7, 0, 0, 3, 0, 0, -8, 0, 0, -3, 0, 0, --4, 0, 0, 2, 0, 0, -11, 0, 0, 0, 0, 0, --3, 0, 0, 1, 0, 0, -3, 0, 0, -1, 0, 0, --4, 0, 0, 2, 0, 0, -8, 0, 0, -4, 0, 0, -3, 0, 0, -1, 0, 0, -11, 0, 0, 0, 0, 0, --6, 0, 0, 3, 0, 0, --4, 0, 0, 2, 0, 0, --8, 0, 0, 4, 0, 0, --7, 0, 0, 3, 0, 0, --4, 0, 0, 2, 0, 0, -3, 0, 0, -1, 0, 0, -6, 0, 0, -3, 0, 0, --6, 0, 0, 3, 0, 0, -6, 0, 0, 0, 0, 0, -6, 0, 0, -1, 0, 0, -5, 0, 0, -2, 0, 0, --5, 0, 0, 2, 0, 0, --4, 0, 0, 0, 0, 0, --4, 0, 0, 2, 0, 0, -4, 0, 0, 0, 0, 0, -6, 0, 0, -3, 0, 0, --4, 0, 0, 2, 0, 0, -0, 0, -26, 0, 0, -11, -0, 0, -10, 0, 0, -5, -5, 0, 0, -3, 0, 0, --13, 0, 0, 0, 0, 0, -3, 0, 0, -2, 0, 0, -4, 0, 0, -2, 0, 0, -7, 0, 0, -3, 0, 0, -4, 0, 0, 0, 0, 0, -5, 0, 0, 0, 0, 0, --3, 0, 0, 2, 0, 0, --6, 0, 0, 2, 0, 0, --5, 0, 0, 2, 0, 0, --7, 0, 0, 3, 0, 0, -5, 0, 0, -2, 0, 0, -13, 0, 0, 0, 0, 0, --4, 0, 0, 2, 0, 0, --3, 0, 0, 0, 0, 0, -5, 0, 0, -2, 0, 0, --11, 0, 0, 0, 0, 0, -5, 0, 0, -2, 0, 0, -4, 0, 0, 0, 0, 0, -4, 0, 0, -2, 0, 0, --4, 0, 0, 2, 0, 0, -6, 0, 0, -3, 0, 0, -3, 0, 0, -2, 0, 0, --12, 0, 0, 0, 0, 0, -4, 0, 0, 0, 0, 0, --3, 0, 0, 0, 0, 0, --4, 0, 0, 0, 0, 0, -3, 0, 0, 0, 0, 0, -3, 0, 0, -1, 0, 0, --3, 0, 0, 1, 0, 0, -0, 0, -5, 0, 0, -2, --7, 0, 0, 4, 0, 0, -6, 0, 0, -3, 0, 0, --3, 0, 0, 0, 0, 0, -5, 0, 0, -3, 0, 0, -3, 0, 0, -1, 0, 0, -3, 0, 0, 0, 0, 0, --3, 0, 0, 1, 0, 0, --5, 0, 0, 3, 0, 0, --3, 0, 0, 2, 0, 0, --3, 0, 0, 2, 0, 0, -12, 0, 0, 0, 0, 0, -3, 0, 0, -1, 0, 0, --4, 0, 0, 2, 0, 0, -4, 0, 0, 0, 0, 0, -6, 0, 0, 0, 0, 0, -5, 0, 0, -3, 0, 0, -4, 0, 0, -2, 0, 0, --6, 0, 0, 3, 0, 0, -4, 0, 0, -2, 0, 0, -6, 0, 0, -3, 0, 0, -6, 0, 0, 0, 0, 0, --6, 0, 0, 3, 0, 0, -3, 0, 0, -2, 0, 0, -7, 0, 0, -4, 0, 0, -4, 0, 0, -2, 0, 0, --5, 0, 0, 2, 0, 0, -5, 0, 0, 0, 0, 0, --6, 0, 0, 3, 0, 0, --6, 0, 0, 3, 0, 0, --4, 0, 0, 2, 0, 0, -10, 0, 0, 0, 0, 0, --4, 0, 0, 2, 0, 0, -7, 0, 0, 0, 0, 0, -7, 0, 0, -3, 0, 0, -4, 0, 0, 0, 0, 0, -11, 0, 0, 0, 0, 0, -5, 0, 0, -2, 0, 0, --6, 0, 0, 2, 0, 0, -4, 0, 0, -2, 0, 0, -3, 0, 0, -2, 0, 0, -5, 0, 0, -2, 0, 0, --4, 0, 0, 2, 0, 0, --4, 0, 0, 2, 0, 0, --3, 0, 0, 2, 0, 0, -4, 0, 0, -2, 0, 0, -3, 0, 0, -1, 0, 0, --3, 0, 0, 1, 0, 0, --3, 0, 0, 1, 0, 0, --3, 0, 0, 2, 0, 0, + -172064161, -174666, 33386, 92052331, 9086, 15377, + -13170906, -1675, -13696, 5730336, -3015, -4587, + -2276413, -234, 2796, 978459, -485, 1374, + 2074554, 207, -698, -897492, 470, -291, + 1475877, -3633, 11817, 73871, -184, -1924, + -516821, 1226, -524, 224386, -677, -174, + 711159, 73, -872, -6750, 0, 358, + -387298, -367, 380, 200728, 18, 318, + -301461, -36, 816, 129025, -63, 367, + 215829, -494, 111, -95929, 299, 132, + 128227, 137, 181, -68982, -9, 39, + 123457, 11, 19, -53311, 32, -4, + 156994, 10, -168, -1235, 0, 82, + 63110, 63, 27, -33228, 0, -9, + -57976, -63, -189, 31429, 0, -75, + -59641, -11, 149, 25543, -11, 66, + -51613, -42, 129, 26366, 0, 78, + 45893, 50, 31, -24236, -10, 20, + 63384, 11, -150, -1220, 0, 29, + -38571, -1, 158, 16452, -11, 68, + 32481, 0, 0, -13870, 0, 0, + -47722, 0, -18, 477, 0, -25, + -31046, -1, 131, 13238, -11, 59, + 28593, 0, -1, -12338, 10, -3, + 20441, 21, 10, -10758, 0, -3, + 29243, 0, -74, -609, 0, 13, + 25887, 0, -66, -550, 0, 11, + -14053, -25, 79, 8551, -2, -45, + 15164, 10, 11, -8001, 0, -1, + -15794, 72, -16, 6850, -42, -5, + 21783, 0, 13, -167, 0, 13, + -12873, -10, -37, 6953, 0, -14, + -12654, 11, 63, 6415, 0, 26, + -10204, 0, 25, 5222, 0, 15, + 16707, -85, -10, 168, -1, 10, + -7691, 0, 44, 3268, 0, 19, + -11024, 0, -14, 104, 0, 2, + 7566, -21, -11, -3250, 0, -5, + -6637, -11, 25, 3353, 0, 14, + -7141, 21, 8, 3070, 0, 4, + -6302, -11, 2, 3272, 0, 4, + 5800, 10, 2, -3045, 0, -1, + 6443, 0, -7, -2768, 0, -4, + -5774, -11, -15, 3041, 0, -5, + -5350, 0, 21, 2695, 0, 12, + -4752, -11, -3, 2719, 0, -3, + -4940, -11, -21, 2720, 0, -9, + 7350, 0, -8, -51, 0, 4, + 4065, 0, 6, -2206, 0, 1, + 6579, 0, -24, -199, 0, 2, + 3579, 0, 5, -1900, 0, 1, + 4725, 0, -6, -41, 0, 3, + -3075, 0, -2, 1313, 0, -1, + -2904, 0, 15, 1233, 0, 7, + 4348, 0, -10, -81, 0, 2, + -2878, 0, 8, 1232, 0, 4, + -4230, 0, 5, -20, 0, -2, + -2819, 0, 7, 1207, 0, 3, + -4056, 0, 5, 40, 0, -2, + -2647, 0, 11, 1129, 0, 5, + -2294, 0, -10, 1266, 0, -4, + 2481, 0, -7, -1062, 0, -3, + 2179, 0, -2, -1129, 0, -2, + 3276, 0, 1, -9, 0, 0, + -3389, 0, 5, 35, 0, -2, + 3339, 0, -13, -107, 0, 1, + -1987, 0, -6, 1073, 0, -2, + -1981, 0, 0, 854, 0, 0, + 4026, 0, -353, -553, 0, -139, + 1660, 0, -5, -710, 0, -2, + -1521, 0, 9, 647, 0, 4, + 1314, 0, 0, -700, 0, 0, + -1283, 0, 0, 672, 0, 0, + -1331, 0, 8, 663, 0, 4, + 1383, 0, -2, -594, 0, -2, + 1405, 0, 4, -610, 0, 2, + 1290, 0, 0, -556, 0, 0, + -1214, 0, 5, 518, 0, 2, + 1146, 0, -3, -490, 0, -1, + 1019, 0, -1, -527, 0, -1, + -1100, 0, 9, 465, 0, 4, + -970, 0, 2, 496, 0, 1, + 1575, 0, -6, -50, 0, 0, + 934, 0, -3, -399, 0, -1, + 922, 0, -1, -395, 0, -1, + 815, 0, -1, -422, 0, -1, + 834, 0, 2, -440, 0, 1, + 1248, 0, 0, -170, 0, 1, + 1338, 0, -5, -39, 0, 0, + 716, 0, -2, -389, 0, -1, + 1282, 0, -3, -23, 0, 1, + 742, 0, 1, -391, 0, 0, + 1020, 0, -25, -495, 0, -10, + 715, 0, -4, -326, 0, 2, + -666, 0, -3, 369, 0, -1, + -667, 0, 1, 346, 0, 1, + -704, 0, 0, 304, 0, 0, + -694, 0, 5, 294, 0, 2, + -1014, 0, -1, 4, 0, -1, + -585, 0, -2, 316, 0, -1, + -949, 0, 1, 8, 0, -1, + -595, 0, 0, 258, 0, 0, + 528, 0, 0, -279, 0, 0, + -590, 0, 4, 252, 0, 2, + 570, 0, -2, -244, 0, -1, + -502, 0, 3, 250, 0, 2, + -875, 0, 1, 29, 0, 0, + -492, 0, -3, 275, 0, -1, + 535, 0, -2, -228, 0, -1, + -467, 0, 1, 240, 0, 1, + 591, 0, 0, -253, 0, 0, + -453, 0, -1, 244, 0, -1, + 766, 0, 1, 9, 0, 0, + -446, 0, 2, 225, 0, 1, + -488, 0, 2, 207, 0, 1, + -468, 0, 0, 201, 0, 0, + -421, 0, 1, 216, 0, 1, + 463, 0, 0, -200, 0, 0, + -673, 0, 2, 14, 0, 0, + 658, 0, 0, -2, 0, 0, + -438, 0, 0, 188, 0, 0, + -390, 0, 0, 205, 0, 0, + 639, -11, -2, -19, 0, 0, + 412, 0, -2, -176, 0, -1, + -361, 0, 0, 189, 0, 0, + 360, 0, -1, -185, 0, -1, + 588, 0, -3, -24, 0, 0, + -578, 0, 1, 5, 0, 0, + -396, 0, 0, 171, 0, 0, + 565, 0, -1, -6, 0, 0, + -335, 0, -1, 184, 0, -1, + 357, 0, 1, -154, 0, 0, + 321, 0, 1, -174, 0, 0, + -301, 0, -1, 162, 0, 0, + -334, 0, 0, 144, 0, 0, + 493, 0, -2, -15, 0, 0, + 494, 0, -2, -19, 0, 0, + 337, 0, -1, -143, 0, -1, + 280, 0, -1, -144, 0, 0, + 309, 0, 1, -134, 0, 0, + -263, 0, 2, 131, 0, 1, + 253, 0, 1, -138, 0, 0, + 245, 0, 0, -128, 0, 0, + 416, 0, -2, -17, 0, 0, + -229, 0, 0, 128, 0, 0, + 231, 0, 0, -120, 0, 0, + -259, 0, 2, 109, 0, 1, + 375, 0, -1, -8, 0, 0, + 252, 0, 0, -108, 0, 0, + -245, 0, 1, 104, 0, 0, + 243, 0, -1, -104, 0, 0, + 208, 0, 1, -112, 0, 0, + 199, 0, 0, -102, 0, 0, + -208, 0, 1, 105, 0, 0, + 335, 0, -2, -14, 0, 0, + -325, 0, 1, 7, 0, 0, + -187, 0, 0, 96, 0, 0, + 197, 0, -1, -100, 0, 0, + -192, 0, 2, 94, 0, 1, + -188, 0, 0, 83, 0, 0, + 276, 0, 0, -2, 0, 0, + -286, 0, 1, 6, 0, 0, + 186, 0, -1, -79, 0, 0, + -219, 0, 0, 43, 0, 0, + 276, 0, 0, 2, 0, 0, + -153, 0, -1, 84, 0, 0, + -156, 0, 0, 81, 0, 0, + -154, 0, 1, 78, 0, 0, + -174, 0, 1, 75, 0, 0, + -163, 0, 2, 69, 0, 1, + -228, 0, 0, 1, 0, 0, + 91, 0, -4, -54, 0, -2, + 175, 0, 0, -75, 0, 0, + -159, 0, 0, 69, 0, 0, + 141, 0, 0, -72, 0, 0, + 147, 0, 0, -75, 0, 0, + -132, 0, 0, 69, 0, 0, + 159, 0, -28, -54, 0, 11, + 213, 0, 0, -4, 0, 0, + 123, 0, 0, -64, 0, 0, + -118, 0, -1, 66, 0, 0, + 144, 0, -1, -61, 0, 0, + -121, 0, 1, 60, 0, 0, + -134, 0, 1, 56, 0, 1, + -105, 0, 0, 57, 0, 0, + -102, 0, 0, 56, 0, 0, + 120, 0, 0, -52, 0, 0, + 101, 0, 0, -54, 0, 0, + -113, 0, 0, 59, 0, 0, + -106, 0, 0, 61, 0, 0, + -129, 0, 1, 55, 0, 0, + -114, 0, 0, 57, 0, 0, + 113, 0, -1, -49, 0, 0, + -102, 0, 0, 44, 0, 0, + -94, 0, 0, 51, 0, 0, + -100, 0, -1, 56, 0, 0, + 87, 0, 0, -47, 0, 0, + 161, 0, 0, -1, 0, 0, + 96, 0, 0, -50, 0, 0, + 151, 0, -1, -5, 0, 0, + -104, 0, 0, 44, 0, 0, + -110, 0, 0, 48, 0, 0, + -100, 0, 1, 50, 0, 0, + 92, 0, -5, 12, 0, -2, + 82, 0, 0, -45, 0, 0, + 82, 0, 0, -45, 0, 0, + -78, 0, 0, 41, 0, 0, + -77, 0, 0, 43, 0, 0, + 2, 0, 0, 54, 0, 0, + 94, 0, 0, -40, 0, 0, + -93, 0, 0, 40, 0, 0, + -83, 0, 10, 40, 0, -2, + 83, 0, 0, -36, 0, 0, + -91, 0, 0, 39, 0, 0, + 128, 0, 0, -1, 0, 0, + -79, 0, 0, 34, 0, 0, + -83, 0, 0, 47, 0, 0, + 84, 0, 0, -44, 0, 0, + 83, 0, 0, -43, 0, 0, + 91, 0, 0, -39, 0, 0, + -77, 0, 0, 39, 0, 0, + 84, 0, 0, -43, 0, 0, + -92, 0, 1, 39, 0, 0, + -92, 0, 1, 39, 0, 0, + -94, 0, 0, 0, 0, 0, + 68, 0, 0, -36, 0, 0, + -61, 0, 0, 32, 0, 0, + 71, 0, 0, -31, 0, 0, + 62, 0, 0, -34, 0, 0, + -63, 0, 0, 33, 0, 0, + -73, 0, 0, 32, 0, 0, + 115, 0, 0, -2, 0, 0, + -103, 0, 0, 2, 0, 0, + 63, 0, 0, -28, 0, 0, + 74, 0, 0, -32, 0, 0, + -103, 0, -3, 3, 0, -1, + -69, 0, 0, 30, 0, 0, + 57, 0, 0, -29, 0, 0, + 94, 0, 0, -4, 0, 0, + 64, 0, 0, -33, 0, 0, + -63, 0, 0, 26, 0, 0, + -38, 0, 0, 20, 0, 0, + -43, 0, 0, 24, 0, 0, + -45, 0, 0, 23, 0, 0, + 47, 0, 0, -24, 0, 0, + -48, 0, 0, 25, 0, 0, + 45, 0, 0, -26, 0, 0, + 56, 0, 0, -25, 0, 0, + 88, 0, 0, 2, 0, 0, + -75, 0, 0, 0, 0, 0, + 85, 0, 0, 0, 0, 0, + 49, 0, 0, -26, 0, 0, + -74, 0, -3, -1, 0, -1, + -39, 0, 0, 21, 0, 0, + 45, 0, 0, -20, 0, 0, + 51, 0, 0, -22, 0, 0, + -40, 0, 0, 21, 0, 0, + 41, 0, 0, -21, 0, 0, + -42, 0, 0, 24, 0, 0, + -51, 0, 0, 22, 0, 0, + -42, 0, 0, 22, 0, 0, + 39, 0, 0, -21, 0, 0, + 46, 0, 0, -18, 0, 0, + -53, 0, 0, 22, 0, 0, + 82, 0, 0, -4, 0, 0, + 81, 0, -1, -4, 0, 0, + 47, 0, 0, -19, 0, 0, + 53, 0, 0, -23, 0, 0, + -45, 0, 0, 22, 0, 0, + -44, 0, 0, -2, 0, 0, + -33, 0, 0, 16, 0, 0, + -61, 0, 0, 1, 0, 0, + 28, 0, 0, -15, 0, 0, + -38, 0, 0, 19, 0, 0, + -33, 0, 0, 21, 0, 0, + -60, 0, 0, 0, 0, 0, + 48, 0, 0, -10, 0, 0, + 27, 0, 0, -14, 0, 0, + 38, 0, 0, -20, 0, 0, + 31, 0, 0, -13, 0, 0, + -29, 0, 0, 15, 0, 0, + 28, 0, 0, -15, 0, 0, + -32, 0, 0, 15, 0, 0, + 45, 0, 0, -8, 0, 0, + -44, 0, 0, 19, 0, 0, + 28, 0, 0, -15, 0, 0, + -51, 0, 0, 0, 0, 0, + -36, 0, 0, 20, 0, 0, + 44, 0, 0, -19, 0, 0, + 26, 0, 0, -14, 0, 0, + -60, 0, 0, 2, 0, 0, + 35, 0, 0, -18, 0, 0, + -27, 0, 0, 11, 0, 0, + 47, 0, 0, -1, 0, 0, + 36, 0, 0, -15, 0, 0, + -36, 0, 0, 20, 0, 0, + -35, 0, 0, 19, 0, 0, + -37, 0, 0, 19, 0, 0, + 32, 0, 0, -16, 0, 0, + 35, 0, 0, -14, 0, 0, + 32, 0, 0, -13, 0, 0, + 65, 0, 0, -2, 0, 0, + 47, 0, 0, -1, 0, 0, + 32, 0, 0, -16, 0, 0, + 37, 0, 0, -16, 0, 0, + -30, 0, 0, 15, 0, 0, + -32, 0, 0, 16, 0, 0, + -31, 0, 0, 13, 0, 0, + 37, 0, 0, -16, 0, 0, + 31, 0, 0, -13, 0, 0, + 49, 0, 0, -2, 0, 0, + 32, 0, 0, -13, 0, 0, + 23, 0, 0, -12, 0, 0, + -43, 0, 0, 18, 0, 0, + 26, 0, 0, -11, 0, 0, + -32, 0, 0, 14, 0, 0, + -29, 0, 0, 14, 0, 0, + -27, 0, 0, 12, 0, 0, + 30, 0, 0, 0, 0, 0, + -11, 0, 0, 5, 0, 0, + -21, 0, 0, 10, 0, 0, + -34, 0, 0, 15, 0, 0, + -10, 0, 0, 6, 0, 0, + -36, 0, 0, 0, 0, 0, + -9, 0, 0, 4, 0, 0, + -12, 0, 0, 5, 0, 0, + -21, 0, 0, 5, 0, 0, + -29, 0, 0, -1, 0, 0, + -15, 0, 0, 3, 0, 0, + -20, 0, 0, 0, 0, 0, + 28, 0, 0, 0, 0, -2, + 17, 0, 0, 0, 0, 0, + -22, 0, 0, 12, 0, 0, + -14, 0, 0, 7, 0, 0, + 24, 0, 0, -11, 0, 0, + 11, 0, 0, -6, 0, 0, + 14, 0, 0, -6, 0, 0, + 24, 0, 0, 0, 0, 0, + 18, 0, 0, -8, 0, 0, + -38, 0, 0, 0, 0, 0, + -31, 0, 0, 0, 0, 0, + -16, 0, 0, 8, 0, 0, + 29, 0, 0, 0, 0, 0, + -18, 0, 0, 10, 0, 0, + -10, 0, 0, 5, 0, 0, + -17, 0, 0, 10, 0, 0, + 9, 0, 0, -4, 0, 0, + 16, 0, 0, -6, 0, 0, + 22, 0, 0, -12, 0, 0, + 20, 0, 0, 0, 0, 0, + -13, 0, 0, 6, 0, 0, + -17, 0, 0, 9, 0, 0, + -14, 0, 0, 8, 0, 0, + 0, 0, 0, -7, 0, 0, + 14, 0, 0, 0, 0, 0, + 19, 0, 0, -10, 0, 0, + -34, 0, 0, 0, 0, 0, + -20, 0, 0, 8, 0, 0, + 9, 0, 0, -5, 0, 0, + -18, 0, 0, 7, 0, 0, + 13, 0, 0, -6, 0, 0, + 17, 0, 0, 0, 0, 0, + -12, 0, 0, 5, 0, 0, + 15, 0, 0, -8, 0, 0, + -11, 0, 0, 3, 0, 0, + 13, 0, 0, -5, 0, 0, + -18, 0, 0, 0, 0, 0, + -35, 0, 0, 0, 0, 0, + 9, 0, 0, -4, 0, 0, + -19, 0, 0, 10, 0, 0, + -26, 0, 0, 11, 0, 0, + 8, 0, 0, -4, 0, 0, + -10, 0, 0, 4, 0, 0, + 10, 0, 0, -6, 0, 0, + -21, 0, 0, 9, 0, 0, + -15, 0, 0, 0, 0, 0, + 9, 0, 0, -5, 0, 0, + -29, 0, 0, 0, 0, 0, + -19, 0, 0, 10, 0, 0, + 12, 0, 0, -5, 0, 0, + 22, 0, 0, -9, 0, 0, + -10, 0, 0, 5, 0, 0, + -20, 0, 0, 11, 0, 0, + -20, 0, 0, 0, 0, 0, + -17, 0, 0, 7, 0, 0, + 15, 0, 0, -3, 0, 0, + 8, 0, 0, -4, 0, 0, + 14, 0, 0, 0, 0, 0, + -12, 0, 0, 6, 0, 0, + 25, 0, 0, 0, 0, 0, + -13, 0, 0, 6, 0, 0, + -14, 0, 0, 8, 0, 0, + 13, 0, 0, -5, 0, 0, + -17, 0, 0, 9, 0, 0, + -12, 0, 0, 6, 0, 0, + -10, 0, 0, 5, 0, 0, + 10, 0, 0, -6, 0, 0, + -15, 0, 0, 0, 0, 0, + -22, 0, 0, 0, 0, 0, + 28, 0, 0, -1, 0, 0, + 15, 0, 0, -7, 0, 0, + 23, 0, 0, -10, 0, 0, + 12, 0, 0, -5, 0, 0, + 29, 0, 0, -1, 0, 0, + -25, 0, 0, 1, 0, 0, + 22, 0, 0, 0, 0, 0, + -18, 0, 0, 0, 0, 0, + 15, 0, 0, 3, 0, 0, + -23, 0, 0, 0, 0, 0, + 12, 0, 0, -5, 0, 0, + -8, 0, 0, 4, 0, 0, + -19, 0, 0, 0, 0, 0, + -10, 0, 0, 4, 0, 0, + 21, 0, 0, -9, 0, 0, + 23, 0, 0, -1, 0, 0, + -16, 0, 0, 8, 0, 0, + -19, 0, 0, 9, 0, 0, + -22, 0, 0, 10, 0, 0, + 27, 0, 0, -1, 0, 0, + 16, 0, 0, -8, 0, 0, + 19, 0, 0, -8, 0, 0, + 9, 0, 0, -4, 0, 0, + -9, 0, 0, 4, 0, 0, + -9, 0, 0, 4, 0, 0, + -8, 0, 0, 4, 0, 0, + 18, 0, 0, -9, 0, 0, + 16, 0, 0, -1, 0, 0, + -10, 0, 0, 4, 0, 0, + -23, 0, 0, 9, 0, 0, + 16, 0, 0, -1, 0, 0, + -12, 0, 0, 6, 0, 0, + -8, 0, 0, 4, 0, 0, + 30, 0, 0, -2, 0, 0, + 24, 0, 0, -10, 0, 0, + 10, 0, 0, -4, 0, 0, + -16, 0, 0, 7, 0, 0, + -16, 0, 0, 7, 0, 0, + 17, 0, 0, -7, 0, 0, + -24, 0, 0, 10, 0, 0, + -12, 0, 0, 5, 0, 0, + -24, 0, 0, 11, 0, 0, + -23, 0, 0, 9, 0, 0, + -13, 0, 0, 5, 0, 0, + -15, 0, 0, 7, 0, 0, + 0, 0, -1988, 0, 0, -1679, + 0, 0, -63, 0, 0, -27, + -4, 0, 0, 0, 0, 0, + 0, 0, 5, 0, 0, 4, + 5, 0, 0, -3, 0, 0, + 0, 0, 364, 0, 0, 176, + 0, 0, -1044, 0, 0, -891, + -3, 0, 0, 1, 0, 0, + 4, 0, 0, -2, 0, 0, + 0, 0, 330, 0, 0, 0, + 5, 0, 0, -2, 0, 0, + 3, 0, 0, -2, 0, 0, + -3, 0, 0, 1, 0, 0, + -5, 0, 0, 2, 0, 0, + 3, 0, 0, -1, 0, 0, + 3, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 5, 0, 0, 0, + 0, 0, 0, 1, 0, 0, + 4, 0, 0, -2, 0, 0, + 6, 0, 0, 0, 0, 0, + 5, 0, 0, -2, 0, 0, + -7, 0, 0, 0, 0, 0, + -12, 0, 0, 0, 0, 0, + 5, 0, 0, -3, 0, 0, + 3, 0, 0, -1, 0, 0, + -5, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + -7, 0, 0, 3, 0, 0, + 7, 0, 0, -4, 0, 0, + 0, 0, -12, 0, 0, -10, + 4, 0, 0, -2, 0, 0, + 3, 0, 0, -2, 0, 0, + -3, 0, 0, 2, 0, 0, + -7, 0, 0, 3, 0, 0, + -4, 0, 0, 2, 0, 0, + -3, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 0, + -3, 0, 0, 1, 0, 0, + 7, 0, 0, -3, 0, 0, + -4, 0, 0, 2, 0, 0, + 4, 0, 0, -2, 0, 0, + -5, 0, 0, 3, 0, 0, + 5, 0, 0, 0, 0, 0, + -5, 0, 0, 2, 0, 0, + 5, 0, 0, -2, 0, 0, + -8, 0, 0, 3, 0, 0, + 9, 0, 0, 0, 0, 0, + 6, 0, 0, -3, 0, 0, + -5, 0, 0, 2, 0, 0, + 3, 0, 0, 0, 0, 0, + -7, 0, 0, 0, 0, 0, + -3, 0, 0, 1, 0, 0, + 5, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + -3, 0, 0, 2, 0, 0, + 4, 0, 0, -2, 0, 0, + 3, 0, 0, -1, 0, 0, + -5, 0, 0, 2, 0, 0, + 4, 0, 0, -2, 0, 0, + 9, 0, 0, -3, 0, 0, + 4, 0, 0, 0, 0, 0, + 4, 0, 0, -2, 0, 0, + -3, 0, 0, 2, 0, 0, + -4, 0, 0, 2, 0, 0, + 9, 0, 0, -3, 0, 0, + -4, 0, 0, 0, 0, 0, + -4, 0, 0, 0, 0, 0, + 3, 0, 0, -2, 0, 0, + 8, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + -3, 0, 0, 2, 0, 0, + 3, 0, 0, -1, 0, 0, + 3, 0, 0, -1, 0, 0, + -3, 0, 0, 1, 0, 0, + 6, 0, 0, -3, 0, 0, + 3, 0, 0, 0, 0, 0, + -3, 0, 0, 1, 0, 0, + -7, 0, 0, 0, 0, 0, + 9, 0, 0, 0, 0, 0, + -3, 0, 0, 2, 0, 0, + -3, 0, 0, 0, 0, 0, + -4, 0, 0, 0, 0, 0, + -5, 0, 0, 3, 0, 0, + -13, 0, 0, 0, 0, 0, + -7, 0, 0, 0, 0, 0, + 10, 0, 0, 0, 0, 0, + 3, 0, 0, -1, 0, 0, + 10, 0, 13, 6, 0, -5, + 0, 0, 30, 0, 0, 14, + 0, 0, -162, 0, 0, -138, + 0, 0, 75, 0, 0, 0, + -7, 0, 0, 4, 0, 0, + -4, 0, 0, 2, 0, 0, + 4, 0, 0, -2, 0, 0, + 5, 0, 0, -2, 0, 0, + 5, 0, 0, -3, 0, 0, + -3, 0, 0, 0, 0, 0, + -3, 0, 0, 2, 0, 0, + -4, 0, 0, 2, 0, 0, + -5, 0, 0, 2, 0, 0, + 6, 0, 0, 0, 0, 0, + 9, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + -7, 0, 0, 0, 0, 0, + -3, 0, 0, 1, 0, 0, + -4, 0, 0, 2, 0, 0, + 7, 0, 0, 0, 0, 0, + -4, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + -6, 0, -3, 3, 0, 1, + 0, 0, -3, 0, 0, -2, + 11, 0, 0, 0, 0, 0, + 3, 0, 0, -1, 0, 0, + 11, 0, 0, 0, 0, 0, + -3, 0, 0, 2, 0, 0, + -1, 0, 3, 3, 0, -1, + 4, 0, 0, -2, 0, 0, + 0, 0, -13, 0, 0, -11, + 3, 0, 6, 0, 0, 0, + -7, 0, 0, 0, 0, 0, + 5, 0, 0, -3, 0, 0, + -3, 0, 0, 1, 0, 0, + 3, 0, 0, 0, 0, 0, + 5, 0, 0, -3, 0, 0, + -7, 0, 0, 3, 0, 0, + 8, 0, 0, -3, 0, 0, + -4, 0, 0, 2, 0, 0, + 11, 0, 0, 0, 0, 0, + -3, 0, 0, 1, 0, 0, + 3, 0, 0, -1, 0, 0, + -4, 0, 0, 2, 0, 0, + 8, 0, 0, -4, 0, 0, + 3, 0, 0, -1, 0, 0, + 11, 0, 0, 0, 0, 0, + -6, 0, 0, 3, 0, 0, + -4, 0, 0, 2, 0, 0, + -8, 0, 0, 4, 0, 0, + -7, 0, 0, 3, 0, 0, + -4, 0, 0, 2, 0, 0, + 3, 0, 0, -1, 0, 0, + 6, 0, 0, -3, 0, 0, + -6, 0, 0, 3, 0, 0, + 6, 0, 0, 0, 0, 0, + 6, 0, 0, -1, 0, 0, + 5, 0, 0, -2, 0, 0, + -5, 0, 0, 2, 0, 0, + -4, 0, 0, 0, 0, 0, + -4, 0, 0, 2, 0, 0, + 4, 0, 0, 0, 0, 0, + 6, 0, 0, -3, 0, 0, + -4, 0, 0, 2, 0, 0, + 0, 0, -26, 0, 0, -11, + 0, 0, -10, 0, 0, -5, + 5, 0, 0, -3, 0, 0, + -13, 0, 0, 0, 0, 0, + 3, 0, 0, -2, 0, 0, + 4, 0, 0, -2, 0, 0, + 7, 0, 0, -3, 0, 0, + 4, 0, 0, 0, 0, 0, + 5, 0, 0, 0, 0, 0, + -3, 0, 0, 2, 0, 0, + -6, 0, 0, 2, 0, 0, + -5, 0, 0, 2, 0, 0, + -7, 0, 0, 3, 0, 0, + 5, 0, 0, -2, 0, 0, + 13, 0, 0, 0, 0, 0, + -4, 0, 0, 2, 0, 0, + -3, 0, 0, 0, 0, 0, + 5, 0, 0, -2, 0, 0, + -11, 0, 0, 0, 0, 0, + 5, 0, 0, -2, 0, 0, + 4, 0, 0, 0, 0, 0, + 4, 0, 0, -2, 0, 0, + -4, 0, 0, 2, 0, 0, + 6, 0, 0, -3, 0, 0, + 3, 0, 0, -2, 0, 0, + -12, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 0, 0, + -3, 0, 0, 0, 0, 0, + -4, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 3, 0, 0, -1, 0, 0, + -3, 0, 0, 1, 0, 0, + 0, 0, -5, 0, 0, -2, + -7, 0, 0, 4, 0, 0, + 6, 0, 0, -3, 0, 0, + -3, 0, 0, 0, 0, 0, + 5, 0, 0, -3, 0, 0, + 3, 0, 0, -1, 0, 0, + 3, 0, 0, 0, 0, 0, + -3, 0, 0, 1, 0, 0, + -5, 0, 0, 3, 0, 0, + -3, 0, 0, 2, 0, 0, + -3, 0, 0, 2, 0, 0, + 12, 0, 0, 0, 0, 0, + 3, 0, 0, -1, 0, 0, + -4, 0, 0, 2, 0, 0, + 4, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 0, 0, + 5, 0, 0, -3, 0, 0, + 4, 0, 0, -2, 0, 0, + -6, 0, 0, 3, 0, 0, + 4, 0, 0, -2, 0, 0, + 6, 0, 0, -3, 0, 0, + 6, 0, 0, 0, 0, 0, + -6, 0, 0, 3, 0, 0, + 3, 0, 0, -2, 0, 0, + 7, 0, 0, -4, 0, 0, + 4, 0, 0, -2, 0, 0, + -5, 0, 0, 2, 0, 0, + 5, 0, 0, 0, 0, 0, + -6, 0, 0, 3, 0, 0, + -6, 0, 0, 3, 0, 0, + -4, 0, 0, 2, 0, 0, + 10, 0, 0, 0, 0, 0, + -4, 0, 0, 2, 0, 0, + 7, 0, 0, 0, 0, 0, + 7, 0, 0, -3, 0, 0, + 4, 0, 0, 0, 0, 0, + 11, 0, 0, 0, 0, 0, + 5, 0, 0, -2, 0, 0, + -6, 0, 0, 2, 0, 0, + 4, 0, 0, -2, 0, 0, + 3, 0, 0, -2, 0, 0, + 5, 0, 0, -2, 0, 0, + -4, 0, 0, 2, 0, 0, + -4, 0, 0, 2, 0, 0, + -3, 0, 0, 2, 0, 0, + 4, 0, 0, -2, 0, 0, + 3, 0, 0, -1, 0, 0, + -3, 0, 0, 1, 0, 0, + -3, 0, 0, 1, 0, 0, + -3, 0, 0, 2, 0, 0, }; #if NUT_IAU_2000A + /* Planetary argument multipliers * L L' F D Om Me Ve E Ma Ju Sa Ur Ne pre */ static int16 npl[] = { -0, 0, 0, 0, 0, 0, 0, 8,-16, 4, 5, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -8, 16, -4, -5, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 8,-16, 4, 5, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 2, 2, -0, 0, 0, 0, 0, 0, 0, -4, 8, -1, -5, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 4, -8, 3, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, 0, 3, -8, 3, 0, 0, 0, 0, --1, 0, 0, 0, 0, 0, 10, -3, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 6, -3, 0, 2, -0, 0, 0, 0, 0, 0, 0, 4, -8, 3, 0, 0, 0, 0, -0, 0, 1, -1, 1, 0, 0, -5, 8, -3, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -4, 8, -3, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 4, -8, 1, 5, 0, 0, 2, -0, 0, 0, 0, 0, 0, -5, 6, 4, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -5, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -5, 0, 0, 1, -0, 0, 1, -1, 1, 0, 0, -1, 0, 2, -5, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -5, 0, 0, 0, -0, 0, 1, -1, 1, 0, 0, -1, 0, -2, 5, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 5, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 5, 0, 0, 2, -2, 0, -1, -1, 0, 0, 0, 3, -7, 0, 0, 0, 0, 0, -1, 0, 0, -2, 0, 0, 19,-21, 3, 0, 0, 0, 0, 0, -0, 0, 1, -1, 1, 0, 2, -4, 0, -3, 0, 0, 0, 0, -1, 0, 0, -1, 1, 0, 0, -1, 0, 2, 0, 0, 0, 0, -0, 0, 1, -1, 1, 0, 0, -1, 0, -4, 10, 0, 0, 0, --2, 0, 0, 2, 1, 0, 0, 2, 0, 0, -5, 0, 0, 0, -0, 0, 0, 0, 0, 0, 3, -7, 4, 0, 0, 0, 0, 0, -0, 0, -1, 1, 0, 0, 0, 1, 0, 1, -1, 0, 0, 0, --2, 0, 0, 2, 1, 0, 0, 2, 0, -2, 0, 0, 0, 0, --1, 0, 0, 0, 0, 0, 18,-16, 0, 0, 0, 0, 0, 0, --2, 0, 1, 1, 2, 0, 0, 1, 0, -2, 0, 0, 0, 0, --1, 0, 1, -1, 1, 0, 18,-17, 0, 0, 0, 0, 0, 0, --1, 0, 0, 1, 1, 0, 0, 2, -2, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -8, 13, 0, 0, 0, 0, 0, 2, -0, 0, 2, -2, 2, 0, -8, 11, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -8, 13, 0, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, -8, 12, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 8,-13, 0, 0, 0, 0, 0, 0, -0, 0, 1, -1, 1, 0, 8,-14, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 8,-13, 0, 0, 0, 0, 0, 1, --2, 0, 0, 2, 1, 0, 0, 2, 0, -4, 5, 0, 0, 0, --2, 0, 0, 2, 2, 0, 3, -3, 0, 0, 0, 0, 0, 0, --2, 0, 0, 2, 0, 0, 0, 2, 0, -3, 1, 0, 0, 0, -0, 0, 0, 0, 1, 0, 3, -5, 0, 2, 0, 0, 0, 0, --2, 0, 0, 2, 0, 0, 0, 2, 0, -4, 3, 0, 0, 0, -0, 0, -1, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, -1, 2, 0, 0, 0, 0, 0, -0, 0, 1, -1, 2, 0, 0, -2, 2, 0, 0, 0, 0, 0, --1, 0, 1, 0, 1, 0, 3, -5, 0, 0, 0, 0, 0, 0, --1, 0, 0, 1, 0, 0, 3, -4, 0, 0, 0, 0, 0, 0, --2, 0, 0, 2, 0, 0, 0, 2, 0, -2, -2, 0, 0, 0, --2, 0, 2, 0, 2, 0, 0, -5, 9, 0, 0, 0, 0, 0, -0, 0, 1, -1, 1, 0, 0, -1, 0, 0, 0, -1, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -0, 0, 1, -1, 1, 0, 0, -1, 0, 0, 0, 0, 2, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, --1, 0, 0, 1, 0, 0, 0, 3, -4, 0, 0, 0, 0, 0, -0, 0, -1, 1, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, -0, 0, 1, -1, 2, 0, 0, -1, 0, 0, 2, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, -9, 17, 0, 0, 0, 0, 0, -0, 0, 0, 0, 2, 0, -3, 5, 0, 0, 0, 0, 0, 0, -0, 0, 1, -1, 1, 0, 0, -1, 0, -1, 2, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -2, 0, 0, 0, -1, 0, 0, -2, 0, 0, 17,-16, 0, -2, 0, 0, 0, 0, -0, 0, 1, -1, 1, 0, 0, -1, 0, 1, -3, 0, 0, 0, --2, 0, 0, 2, 1, 0, 0, 5, -6, 0, 0, 0, 0, 0, -0, 0, -2, 2, 0, 0, 0, 9,-13, 0, 0, 0, 0, 0, -0, 0, 1, -1, 2, 0, 0, -1, 0, 0, 1, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, -0, 0, -1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, -0, 0, -2, 2, 0, 0, 5, -6, 0, 0, 0, 0, 0, 0, -0, 0, -1, 1, 1, 0, 5, -7, 0, 0, 0, 0, 0, 0, --2, 0, 0, 2, 0, 0, 6, -8, 0, 0, 0, 0, 0, 0, -2, 0, 1, -3, 1, 0, -6, 7, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, -0, 0, -1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, -0, 0, 1, -1, 1, 0, 0, -1, 0, 0, 0, 2, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, -0, 0, 0, 0, 0, 0, 0, -8, 15, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -8, 15, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, 0, -9, 15, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 8,-15, 0, 0, 0, 0, 0, -1, 0, -1, -1, 0, 0, 0, 8,-15, 0, 0, 0, 0, 0, -2, 0, 0, -2, 0, 0, 2, -5, 0, 0, 0, 0, 0, 0, --2, 0, 0, 2, 0, 0, 0, 2, 0, -5, 5, 0, 0, 0, -2, 0, 0, -2, 1, 0, 0, -6, 8, 0, 0, 0, 0, 0, -2, 0, 0, -2, 1, 0, 0, -2, 0, 3, 0, 0, 0, 0, --2, 0, 1, 1, 0, 0, 0, 1, 0, -3, 0, 0, 0, 0, --2, 0, 1, 1, 1, 0, 0, 1, 0, -3, 0, 0, 0, 0, --2, 0, 0, 2, 0, 0, 0, 2, 0, -3, 0, 0, 0, 0, --2, 0, 0, 2, 0, 0, 0, 6, -8, 0, 0, 0, 0, 0, --2, 0, 0, 2, 0, 0, 0, 2, 0, -1, -5, 0, 0, 0, --1, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, --1, 0, 1, 1, 1, 0,-20, 20, 0, 0, 0, 0, 0, 0, -1, 0, 0, -2, 0, 0, 20,-21, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, 8,-15, 0, 0, 0, 0, 0, -0, 0, 2, -2, 1, 0, 0,-10, 15, 0, 0, 0, 0, 0, -0, 0, -1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -0, 0, 1, -1, 2, 0, 0, -1, 0, 1, 0, 0, 0, 0, -0, 0, 1, -1, 1, 0, 0, -1, 0, -2, 4, 0, 0, 0, -2, 0, 0, -2, 1, 0, -6, 8, 0, 0, 0, 0, 0, 0, -0, 0, -2, 2, 1, 0, 5, -6, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1, -0, 0, 1, -1, 1, 0, 0, -1, 0, 0, -1, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, -0, 0, 1, -1, 1, 0, 0, -1, 0, 0, 1, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, -0, 0, 2, -2, 1, 0, 0, -9, 13, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, 7,-13, 0, 0, 0, 0, 0, --2, 0, 0, 2, 0, 0, 0, 5, -6, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 9,-17, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -9, 17, 0, 0, 0, 0, 2, -1, 0, 0, -1, 1, 0, 0, -3, 4, 0, 0, 0, 0, 0, -1, 0, 0, -1, 1, 0, -3, 4, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 2, 0, 0, -1, 2, 0, 0, 0, 0, 0, -0, 0, -1, 1, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, -0, 0, -2, 2, 0, 1, 0, -2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 3, -5, 0, 2, 0, 0, 0, 0, --2, 0, 0, 2, 1, 0, 0, 2, 0, -3, 1, 0, 0, 0, --2, 0, 0, 2, 1, 0, 3, -3, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 8,-13, 0, 0, 0, 0, 0, 0, -0, 0, -1, 1, 0, 0, 8,-12, 0, 0, 0, 0, 0, 0, -0, 0, 2, -2, 1, 0, -8, 11, 0, 0, 0, 0, 0, 0, --1, 0, 0, 1, 0, 0, 0, 2, -2, 0, 0, 0, 0, 0, --1, 0, 0, 0, 1, 0, 18,-16, 0, 0, 0, 0, 0, 0, -0, 0, 1, -1, 1, 0, 0, -1, 0, -1, 1, 0, 0, 0, -0, 0, 0, 0, 1, 0, 3, -7, 4, 0, 0, 0, 0, 0, --2, 0, 1, 1, 1, 0, 0, -3, 7, 0, 0, 0, 0, 0, -0, 0, 1, -1, 2, 0, 0, -1, 0, -2, 5, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, 0, 0, -2, 5, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, -4, 8, -3, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0,-10, 3, 0, 0, 0, 0, 0, 0, -0, 0, 2, -2, 1, 0, 0, -2, 0, 0, 0, 0, 0, 0, --1, 0, 0, 0, 1, 0, 10, -3, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, 4, -8, 3, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, 0, 0, 2, -5, 0, 0, 0, -0, 0, -1, 1, 0, 0, 0, 1, 0, 2, -5, 0, 0, 0, -2, 0, -1, -1, 1, 0, 0, 3, -7, 0, 0, 0, 0, 0, --2, 0, 0, 2, 0, 0, 0, 2, 0, 0, -5, 0, 0, 0, -0, 0, 0, 0, 1, 0, -3, 7, -4, 0, 0, 0, 0, 0, --2, 0, 0, 2, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0,-18, 16, 0, 0, 0, 0, 0, 0, --2, 0, 1, 1, 1, 0, 0, 1, 0, -2, 0, 0, 0, 0, -0, 0, 1, -1, 2, 0, -8, 12, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, -8, 13, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 1, -2, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, 0, 0, -2, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 1, -2, 0, 0, 0, 0, 0, -0, 0, 1, -1, 1, 0, 0, -2, 2, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -1, 2, 0, 0, 0, 0, 1, --1, 0, 0, 1, 1, 0, 3, -4, 0, 0, 0, 0, 0, 0, --1, 0, 0, 1, 1, 0, 0, 3, -4, 0, 0, 0, 0, 0, -0, 0, 1, -1, 1, 0, 0, -1, 0, 0, -2, 0, 0, 0, -0, 0, 1, -1, 1, 0, 0, -1, 0, 0, 2, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, -0, 0, 1, -1, 0, 0, 3, -6, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, -3, 5, 0, 0, 0, 0, 0, 0, -0, 0, 1, -1, 2, 0, -3, 4, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, -2, 4, 0, 0, 0, 0, 0, -0, 0, 2, -2, 1, 0, -5, 6, 0, 0, 0, 0, 0, 0, -0, 0, -1, 1, 0, 0, 5, -7, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 5, -8, 0, 0, 0, 0, 0, 0, --2, 0, 0, 2, 1, 0, 6, -8, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, -8, 15, 0, 0, 0, 0, 0, --2, 0, 0, 2, 1, 0, 0, 2, 0, -3, 0, 0, 0, 0, --2, 0, 0, 2, 1, 0, 0, 6, -8, 0, 0, 0, 0, 0, -1, 0, 0, -1, 1, 0, 0, -1, 0, 1, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 3, -5, 0, 0, 0, -0, 0, 1, -1, 1, 0, 0, -1, 0, -1, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, 0, -1, 0, 1, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, -0, 0, 1, -1, 2, 0, 0, -1, 0, 0, -1, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, -0, 0, -1, 1, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -7, 13, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 7,-13, 0, 0, 0, 0, 0, -2, 0, 0, -2, 1, 0, 0, -5, 6, 0, 0, 0, 0, 0, -0, 0, 2, -2, 1, 0, 0, -8, 11, 0, 0, 0, 0, 0, -0, 0, 2, -2, 1, -1, 0, 2, 0, 0, 0, 0, 0, 0, --2, 0, 0, 2, 0, 0, 0, 4, -4, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -2, 0, 0, 0, -0, 0, 1, -1, 1, 0, 0, -1, 0, 0, 3, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 2, --2, 0, 0, 2, 0, 0, 3, -3, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 2, 0, 0, -4, 8, -3, 0, 0, 0, 0, -0, 0, 0, 0, 2, 0, 0, 4, -8, 3, 0, 0, 0, 0, -2, 0, 0, -2, 1, 0, 0, -2, 0, 2, 0, 0, 0, 0, -0, 0, 1, -1, 2, 0, 0, -1, 0, 2, 0, 0, 0, 0, -0, 0, 1, -1, 2, 0, 0, 0, -2, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, 1, -2, 0, 0, 0, 0, 0, -0, 0, -1, 1, 0, 0, 0, 2, -2, 0, 0, 0, 0, 0, -0, 0, -1, 1, 0, 0, 0, 1, 0, 0, -2, 0, 0, 0, -0, 0, 2, -2, 1, 0, 0, -2, 0, 0, 2, 0, 0, 0, -0, 0, 1, -1, 1, 0, 3, -6, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 3, -5, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 3, -5, 0, 0, 0, 0, 0, 0, -0, 0, 1, -1, 1, 0, -3, 4, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -3, 5, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, -3, 5, 0, 0, 0, 0, 0, 2, -0, 0, 2, -2, 2, 0, -3, 3, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -3, 5, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 2, -4, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, 0, 1, -4, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 2, -4, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -2, 4, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, 0, -3, 4, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -2, 4, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, -2, 4, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -5, 8, 0, 0, 0, 0, 0, 2, -0, 0, 2, -2, 2, 0, -5, 6, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -5, 8, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -5, 8, 0, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, -5, 7, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -5, 8, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 5, -8, 0, 0, 0, 0, 0, 0, -0, 0, 1, -1, 2, 0, 0, -1, 0, -1, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -0, 0, -1, 1, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, -0, 0, 2, -2, 1, 0, 0, -2, 0, 1, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -6, 11, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 6,-11, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, -1, 0, 4, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 1, 0, -4, 0, 0, 0, 0, 0, 0, -2, 0, 0, -2, 1, 0, -3, 3, 0, 0, 0, 0, 0, 0, --2, 0, 0, 2, 0, 0, 0, 2, 0, 0, -2, 0, 0, 0, -0, 0, 2, -2, 1, 0, 0, -7, 9, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 4, -5, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, 0, -1, 0, 2, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, -0, 0, 2, -2, 2, 0, 0, -2, 0, 2, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 2, -0, 0, 0, 0, 1, 0, 3, -5, 0, 0, 0, 0, 0, 0, -0, 0, -1, 1, 0, 0, 3, -4, 0, 0, 0, 0, 0, 0, -0, 0, 2, -2, 1, 0, -3, 3, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, 2, -4, 0, 0, 0, 0, 0, -0, 0, 2, -2, 1, 0, 0, -4, 4, 0, 0, 0, 0, 0, -0, 0, 1, -1, 2, 0, -5, 7, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 3, -6, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -3, 6, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, 0, -4, 6, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -3, 6, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, -3, 6, 0, 0, 0, 0, 2, -0, 0, -1, 1, 0, 0, 2, -2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 2, -3, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -5, 9, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -5, 9, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 5, -9, 0, 0, 0, 0, 0, -0, 0, -1, 1, 0, 0, 0, 1, 0, -2, 0, 0, 0, 0, -0, 0, 2, -2, 1, 0, 0, -2, 0, 2, 0, 0, 0, 0, --2, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, -0, 0, -2, 2, 0, 0, 3, -3, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -6, 10, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, -6, 10, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -2, 3, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -2, 3, 0, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, -2, 2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 2, -3, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 2, -3, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, 0, -1, 0, 3, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 4, -8, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -4, 8, 0, 0, 0, 0, 2, -0, 0, -2, 2, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -4, 7, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -4, 7, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 4, -7, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, -2, 3, 0, 0, 0, 0, 0, 0, -0, 0, 2, -2, 1, 0, 0, -2, 0, 3, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -5, 10, 0, 0, 0, 0, 2, -0, 0, 0, 0, 1, 0, -1, 2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -3, 5, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -3, 5, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 3, -5, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 1, -2, 0, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, 1, -3, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 1, -2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -1, 2, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, -1, 2, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -7, 11, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -7, 11, 0, 0, 0, 0, 0, 1, -0, 0, -2, 2, 0, 0, 4, -4, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 2, -3, 0, 0, 0, 0, 0, -0, 0, 2, -2, 1, 0, -4, 4, 0, 0, 0, 0, 0, 0, -0, 0, -1, 1, 0, 0, 4, -5, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -4, 7, 0, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, -4, 6, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -4, 7, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -4, 6, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -4, 6, 0, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, -4, 5, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -4, 6, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 4, -6, 0, 0, 0, 0, 0, 0, --2, 0, 0, 2, 0, 0, 2, -2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -0, 0, -1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 1, -1, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -1, 0, 5, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 1, -3, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -1, 3, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -7, 12, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, -1, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, 1, -2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -2, 5, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -1, 0, 4, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 1, 0, -4, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, -1, 1, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -6, 10, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -6, 10, 0, 0, 0, 0, 0, -0, 0, 2, -2, 1, 0, 0, -3, 0, 3, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -3, 7, 0, 0, 0, 0, 2, --2, 0, 0, 2, 0, 0, 4, -4, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -5, 8, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 5, -8, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -1, 0, 3, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -1, 0, 3, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 1, 0, -3, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 2, -4, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -2, 4, 0, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, -2, 3, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -2, 4, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -6, 9, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -6, 9, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 6, -9, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, 1, 0, -2, 0, 0, 0, 0, -0, 0, 2, -2, 1, 0, -2, 2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -4, 6, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 4, -6, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 3, -4, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -1, 0, 2, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 1, 0, -2, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, 1, 0, -1, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -5, 9, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 3, -4, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -3, 4, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -3, 4, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 3, -4, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 3, -4, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 1, 0, 0, 2, -2, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, -1, 0, 2, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -3, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 1, 0, 1, -5, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 1, 0, -3, 5, 0, 0, 0, -0, 0, 0, 0, 1, 0, -3, 4, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -2, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 2, -2, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, -1, 0, 1, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, -2, 2, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -8, 14, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 1, 0, 2, -5, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 5, -8, 3, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 5, -8, 3, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 3, -8, 3, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -3, 8, -3, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 1, 0, -2, 5, 0, 0, 2, -0, 0, 0, 0, 0, 0, -8, 12, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -8, 12, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 1, 0, 1, -2, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 2, -0, 0, 2, -2, 1, 0, -5, 5, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 3, -6, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -3, 6, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, -3, 6, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -1, 4, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -5, 7, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -5, 7, 0, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, -5, 6, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 5, -7, 0, 0, 0, 0, 0, 0, -0, 0, 2, -2, 1, 0, 0, -1, 0, 1, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0, -0, 0, 0, 0, 0, -1, 0, 3, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -2, 6, 0, 0, 0, 0, 2, -0, 0, 0, 0, 1, 0, 2, -2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -6, 9, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 6, -9, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -2, 2, 0, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, -2, 1, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 2, -2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 2, -2, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -5, 7, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 5, -7, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, -2, 2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 4, -5, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 1, -3, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -1, 3, 0, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, -1, 2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -1, 3, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -7, 10, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -7, 10, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 3, -3, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -4, 8, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -4, 5, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -4, 5, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 4, -5, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -2, 0, 5, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -9, 13, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -1, 5, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -2, 0, 4, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 2, 0, -4, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -2, 7, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 2, 0, -3, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -2, 5, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, -2, 5, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -6, 8, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -6, 8, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 6, -8, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 1, 0, 0, 2, 0, -2, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -3, 9, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 5, -6, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 5, -6, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 2, 0, -2, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 2, 0, -2, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -5, 10, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 4, -4, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 4, -4, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -3, 3, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 3, -3, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 3, -3, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 3, -3, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 2, 0, 0, -3, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, -5, 13, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 2, 0, -1, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 2, 0, -1, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 2, 0, 0, -2, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 2, 0, 0, -2, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 3, -2, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 3, -2, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 2, 0, 0, -1, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -6, 15, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -8, 15, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -3, 9, -4, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 2, 0, 2, -5, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -2, 8, -1, -5, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 6, -8, 3, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1, -0, 0, 1, -1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -6, 16, -4, -5, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -2, 8, -3, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -2, 8, -3, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 6, -8, 1, 5, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 2, 0, -2, 5, 0, 0, 2, -0, 0, 0, 0, 0, 0, 3, -5, 4, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -8, 11, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -8, 11, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, -8, 11, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 0, 2, -0, 0, 0, 0, 0, 0, 3, -3, 0, 2, 0, 0, 0, 2, -0, 0, 2, -2, 1, 0, 0, 4, -8, 3, 0, 0, 0, 0, -0, 0, 1, -1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -0, 0, 2, -2, 1, 0, 0, -4, 8, -3, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -3, 7, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -5, 6, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -5, 6, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 5, -6, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 5, -6, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -1, 6, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 7, -9, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 2, -1, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 2, -1, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 6, -7, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 5, -5, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -1, 4, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, -1, 4, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -7, 9, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -7, 9, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 4, -3, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 3, -1, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -4, 4, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 4, -4, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 4, -4, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 4, -4, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -3, 0, 5, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -9, 12, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 3, 0, -4, 0, 0, 0, 0, -0, 0, 2, -2, 1, 0, 1, -1, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 7, -8, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 3, 0, -3, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 3, 0, -3, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -2, 6, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -6, 7, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 6, -7, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 6, -6, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 3, 0, -2, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 3, 0, -2, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 5, -4, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 3, -2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 3, -2, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 3, 0, -1, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 3, 0, -1, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 3, 0, 0, -2, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 4, -2, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 3, 0, 0, -1, 0, 0, 2, -0, 0, 2, -2, 1, 0, 0, 1, 0, -1, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, -8, 16, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 3, 0, 2, -5, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 7, -8, 3, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -5, 16, -4, -5, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, -1, 8, -3, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -8, 10, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -8, 10, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, -8, 10, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -3, 8, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -5, 5, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 5, -5, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 5, -5, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 5, -5, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 7, -7, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 7, -7, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 6, -5, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 7, -8, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 5, -3, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 4, -3, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -9, 11, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -9, 11, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 4, 0, -4, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 4, 0, -3, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -6, 6, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 6, -6, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 6, -6, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 4, 0, -2, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 6, -4, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 3, -1, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 3, -1, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 3, -1, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 4, 0, -1, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 4, 0, 0, -2, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 5, -2, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 8, -9, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 5, -4, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, -7, 7, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 7, -7, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 4, -2, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 4, -2, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 4, -2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 4, -2, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 5, 0, -4, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 5, 0, -3, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 5, 0, -2, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -8, 8, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 8, -8, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 5, -3, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 5, -3, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, -9, 9, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, -9, 9, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, -9, 9, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 9, -9, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 6, -4, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 1, -0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 2, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -1, 0, 0, -2, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, -1, 0, 0, -2, 0, 0, 2, -2, 0, 0, 0, 0, 0, 0, -1, 0, 0, -2, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, -1, 0, 0, -2, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, --1, 0, 0, 0, 0, 0, 3, -3, 0, 0, 0, 0, 0, 0, --1, 0, 0, 0, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, --1, 0, 0, 2, 0, 0, 0, 4, -8, 3, 0, 0, 0, 0, -1, 0, 0, -2, 0, 0, 0, 4, -8, 3, 0, 0, 0, 0, --2, 0, 0, 2, 0, 0, 0, 4, -8, 3, 0, 0, 0, 0, --1, 0, 0, 0, 0, 0, 0, 2, 0, -3, 0, 0, 0, 0, --1, 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, --1, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, --1, 0, 0, 2, 0, 0, 2, -2, 0, 0, 0, 0, 0, 0, -1, 0, -1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, --1, 0, 0, 2, 0, 0, 0, 2, 0, -3, 0, 0, 0, 0, --2, 0, 0, 0, 0, 0, 0, 2, 0, -3, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 4, -8, 3, 0, 0, 0, 0, --1, 0, 1, -1, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 0, 1, -1, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, --1, 0, 0, 0, 0, 0, 0, 4, -8, 3, 0, 0, 0, 0, --1, 0, 0, 2, 1, 0, 0, 2, 0, -2, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, --1, 0, 0, 2, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, --1, 0, 0, 2, 0, 0, 3, -3, 0, 0, 0, 0, 0, 0, -1, 0, 0, -2, 1, 0, 0, -2, 0, 2, 0, 0, 0, 0, -1, 0, 2, -2, 2, 0, -3, 3, 0, 0, 0, 0, 0, 0, -1, 0, 2, -2, 2, 0, 0, -2, 0, 2, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, -0, 0, 0, -2, 0, 0, 2, -2, 0, 0, 0, 0, 0, 0, -0, 0, 0, -2, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, -0, 0, 2, 0, 2, 0, -2, 2, 0, 0, 0, 0, 0, 0, -0, 0, 2, 0, 2, 0, 0, -1, 0, 1, 0, 0, 0, 0, -0, 0, 2, 0, 2, 0, -1, 1, 0, 0, 0, 0, 0, 0, -0, 0, 2, 0, 2, 0, -2, 3, 0, 0, 0, 0, 0, 0, -0, 0, 0, 2, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, -0, 0, 1, 1, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, 2, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, --1, 0, 2, 0, 2, 0, 10, -3, 0, 0, 0, 0, 0, 0, -0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, 2, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, -0, 0, 2, 0, 2, 0, 0, 4, -8, 3, 0, 0, 0, 0, -0, 0, 2, 0, 2, 0, 0, -4, 8, -3, 0, 0, 0, 0, --1, 0, 2, 0, 2, 0, 0, -4, 8, -3, 0, 0, 0, 0, -2, 0, 2, -2, 2, 0, 0, -2, 0, 3, 0, 0, 0, 0, -1, 0, 2, 0, 1, 0, 0, -2, 0, 3, 0, 0, 0, 0, -0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, --1, 0, 2, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, --2, 0, 2, 2, 2, 0, 0, 2, 0, -2, 0, 0, 0, 0, -0, 0, 2, 0, 2, 0, 2, -3, 0, 0, 0, 0, 0, 0, -0, 0, 2, 0, 2, 0, 1, -1, 0, 0, 0, 0, 0, 0, -0, 0, 2, 0, 2, 0, 0, 1, 0, -1, 0, 0, 0, 0, -0, 0, 2, 0, 2, 0, 2, -2, 0, 0, 0, 0, 0, 0, --1, 0, 2, 2, 2, 0, 0, -1, 0, 1, 0, 0, 0, 0, -1, 0, 2, 0, 2, 0, -1, 1, 0, 0, 0, 0, 0, 0, --1, 0, 2, 2, 2, 0, 0, 2, 0, -3, 0, 0, 0, 0, -2, 0, 2, 0, 2, 0, 0, 2, 0, -3, 0, 0, 0, 0, -1, 0, 2, 0, 2, 0, 0, -4, 8, -3, 0, 0, 0, 0, -1, 0, 2, 0, 2, 0, 0, 4, -8, 3, 0, 0, 0, 0, -1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, -0, 0, 2, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, -2, 0, 2, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, --1, 0, 2, 2, 2, 0, 0, 2, 0, -2, 0, 0, 0, 0, --1, 0, 2, 2, 2, 0, 3, -3, 0, 0, 0, 0, 0, 0, -1, 0, 2, 0, 2, 0, 1, -1, 0, 0, 0, 0, 0, 0, -0, 0, 2, 2, 2, 0, 0, 2, 0, -2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 8, -16, 4, 5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -8, 16, -4, -5, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 8, -16, 4, 5, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 2, 2, + 0, 0, 0, 0, 0, 0, 0, -4, 8, -1, -5, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 4, -8, 3, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, 0, 3, -8, 3, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, 10, -3, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 6, -3, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 4, -8, 3, 0, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 0, -5, 8, -3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -4, 8, -3, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 4, -8, 1, 5, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -5, 6, 4, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -5, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -5, 0, 0, 1, + 0, 0, 1, -1, 1, 0, 0, -1, 0, 2, -5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -5, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 0, -1, 0, -2, 5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 5, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, 5, 0, 0, 2, + 2, 0, -1, -1, 0, 0, 0, 3, -7, 0, 0, 0, 0, 0, + 1, 0, 0, -2, 0, 0, 19, -21, 3, 0, 0, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 2, -4, 0, -3, 0, 0, 0, 0, + 1, 0, 0, -1, 1, 0, 0, -1, 0, 2, 0, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 0, -1, 0, -4, 10, 0, 0, 0, + -2, 0, 0, 2, 1, 0, 0, 2, 0, 0, -5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 3, -7, 4, 0, 0, 0, 0, 0, + 0, 0, -1, 1, 0, 0, 0, 1, 0, 1, -1, 0, 0, 0, + -2, 0, 0, 2, 1, 0, 0, 2, 0, -2, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, 18, -16, 0, 0, 0, 0, 0, 0, + -2, 0, 1, 1, 2, 0, 0, 1, 0, -2, 0, 0, 0, 0, + -1, 0, 1, -1, 1, 0, 18, -17, 0, 0, 0, 0, 0, 0, + -1, 0, 0, 1, 1, 0, 0, 2, -2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -8, 13, 0, 0, 0, 0, 0, 2, + 0, 0, 2, -2, 2, 0, -8, 11, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -8, 13, 0, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, -8, 12, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 8, -13, 0, 0, 0, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 8, -14, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 8, -13, 0, 0, 0, 0, 0, 1, + -2, 0, 0, 2, 1, 0, 0, 2, 0, -4, 5, 0, 0, 0, + -2, 0, 0, 2, 2, 0, 3, -3, 0, 0, 0, 0, 0, 0, + -2, 0, 0, 2, 0, 0, 0, 2, 0, -3, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 3, -5, 0, 2, 0, 0, 0, 0, + -2, 0, 0, 2, 0, 0, 0, 2, 0, -4, 3, 0, 0, 0, + 0, 0, -1, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, -1, 2, 0, 0, 0, 0, 0, + 0, 0, 1, -1, 2, 0, 0, -2, 2, 0, 0, 0, 0, 0, + -1, 0, 1, 0, 1, 0, 3, -5, 0, 0, 0, 0, 0, 0, + -1, 0, 0, 1, 0, 0, 3, -4, 0, 0, 0, 0, 0, 0, + -2, 0, 0, 2, 0, 0, 0, 2, 0, -2, -2, 0, 0, 0, + -2, 0, 2, 0, 2, 0, 0, -5, 9, 0, 0, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 0, -1, 0, 0, 0, -1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 1, -1, 1, 0, 0, -1, 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, + -1, 0, 0, 1, 0, 0, 0, 3, -4, 0, 0, 0, 0, 0, + 0, 0, -1, 1, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, + 0, 0, 1, -1, 2, 0, 0, -1, 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, -9, 17, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, -3, 5, 0, 0, 0, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 0, -1, 0, -1, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -2, 0, 0, 0, + 1, 0, 0, -2, 0, 0, 17, -16, 0, -2, 0, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 0, -1, 0, 1, -3, 0, 0, 0, + -2, 0, 0, 2, 1, 0, 0, 5, -6, 0, 0, 0, 0, 0, + 0, 0, -2, 2, 0, 0, 0, 9, -13, 0, 0, 0, 0, 0, + 0, 0, 1, -1, 2, 0, 0, -1, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, -1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, + 0, 0, -2, 2, 0, 0, 5, -6, 0, 0, 0, 0, 0, 0, + 0, 0, -1, 1, 1, 0, 5, -7, 0, 0, 0, 0, 0, 0, + -2, 0, 0, 2, 0, 0, 6, -8, 0, 0, 0, 0, 0, 0, + 2, 0, 1, -3, 1, 0, -6, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, -1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 0, -1, 0, 0, 0, 2, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -8, 15, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -8, 15, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, 0, -9, 15, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 8, -15, 0, 0, 0, 0, 0, + 1, 0, -1, -1, 0, 0, 0, 8, -15, 0, 0, 0, 0, 0, + 2, 0, 0, -2, 0, 0, 2, -5, 0, 0, 0, 0, 0, 0, + -2, 0, 0, 2, 0, 0, 0, 2, 0, -5, 5, 0, 0, 0, + 2, 0, 0, -2, 1, 0, 0, -6, 8, 0, 0, 0, 0, 0, + 2, 0, 0, -2, 1, 0, 0, -2, 0, 3, 0, 0, 0, 0, + -2, 0, 1, 1, 0, 0, 0, 1, 0, -3, 0, 0, 0, 0, + -2, 0, 1, 1, 1, 0, 0, 1, 0, -3, 0, 0, 0, 0, + -2, 0, 0, 2, 0, 0, 0, 2, 0, -3, 0, 0, 0, 0, + -2, 0, 0, 2, 0, 0, 0, 6, -8, 0, 0, 0, 0, 0, + -2, 0, 0, 2, 0, 0, 0, 2, 0, -1, -5, 0, 0, 0, + -1, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, + -1, 0, 1, 1, 1, 0, -20, 20, 0, 0, 0, 0, 0, 0, + 1, 0, 0, -2, 0, 0, 20, -21, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 8, -15, 0, 0, 0, 0, 0, + 0, 0, 2, -2, 1, 0, 0, -10, 15, 0, 0, 0, 0, 0, + 0, 0, -1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 1, -1, 2, 0, 0, -1, 0, 1, 0, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 0, -1, 0, -2, 4, 0, 0, 0, + 2, 0, 0, -2, 1, 0, -6, 8, 0, 0, 0, 0, 0, 0, + 0, 0, -2, 2, 1, 0, 5, -6, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 1, + 0, 0, 1, -1, 1, 0, 0, -1, 0, 0, -1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 0, -1, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, + 0, 0, 2, -2, 1, 0, 0, -9, 13, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 7, -13, 0, 0, 0, 0, 0, + -2, 0, 0, 2, 0, 0, 0, 5, -6, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 9, -17, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -9, 17, 0, 0, 0, 0, 2, + 1, 0, 0, -1, 1, 0, 0, -3, 4, 0, 0, 0, 0, 0, + 1, 0, 0, -1, 1, 0, -3, 4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, 0, -1, 2, 0, 0, 0, 0, 0, + 0, 0, -1, 1, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, -2, 2, 0, 1, 0, -2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 3, -5, 0, 2, 0, 0, 0, 0, + -2, 0, 0, 2, 1, 0, 0, 2, 0, -3, 1, 0, 0, 0, + -2, 0, 0, 2, 1, 0, 3, -3, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 8, -13, 0, 0, 0, 0, 0, 0, + 0, 0, -1, 1, 0, 0, 8, -12, 0, 0, 0, 0, 0, 0, + 0, 0, 2, -2, 1, 0, -8, 11, 0, 0, 0, 0, 0, 0, + -1, 0, 0, 1, 0, 0, 0, 2, -2, 0, 0, 0, 0, 0, + -1, 0, 0, 0, 1, 0, 18, -16, 0, 0, 0, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 0, -1, 0, -1, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 3, -7, 4, 0, 0, 0, 0, 0, + -2, 0, 1, 1, 1, 0, 0, -3, 7, 0, 0, 0, 0, 0, + 0, 0, 1, -1, 2, 0, 0, -1, 0, -2, 5, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, -2, 5, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, -4, 8, -3, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, -10, 3, 0, 0, 0, 0, 0, 0, + 0, 0, 2, -2, 1, 0, 0, -2, 0, 0, 0, 0, 0, 0, + -1, 0, 0, 0, 1, 0, 10, -3, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 4, -8, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, -5, 0, 0, 0, + 0, 0, -1, 1, 0, 0, 0, 1, 0, 2, -5, 0, 0, 0, + 2, 0, -1, -1, 1, 0, 0, 3, -7, 0, 0, 0, 0, 0, + -2, 0, 0, 2, 0, 0, 0, 2, 0, 0, -5, 0, 0, 0, + 0, 0, 0, 0, 1, 0, -3, 7, -4, 0, 0, 0, 0, 0, + -2, 0, 0, 2, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, + 1, 0, 0, 0, 1, 0, -18, 16, 0, 0, 0, 0, 0, 0, + -2, 0, 1, 1, 1, 0, 0, 1, 0, -2, 0, 0, 0, 0, + 0, 0, 1, -1, 2, 0, -8, 12, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, -8, 13, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, -2, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, 0, 0, -2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, -2, 0, 0, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 0, -2, 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -1, 2, 0, 0, 0, 0, 1, + -1, 0, 0, 1, 1, 0, 3, -4, 0, 0, 0, 0, 0, 0, + -1, 0, 0, 1, 1, 0, 0, 3, -4, 0, 0, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 0, -1, 0, 0, -2, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 0, -1, 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, + 0, 0, 1, -1, 0, 0, 3, -6, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, -3, 5, 0, 0, 0, 0, 0, 0, + 0, 0, 1, -1, 2, 0, -3, 4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, -2, 4, 0, 0, 0, 0, 0, + 0, 0, 2, -2, 1, 0, -5, 6, 0, 0, 0, 0, 0, 0, + 0, 0, -1, 1, 0, 0, 5, -7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 5, -8, 0, 0, 0, 0, 0, 0, + -2, 0, 0, 2, 1, 0, 6, -8, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, -8, 15, 0, 0, 0, 0, 0, + -2, 0, 0, 2, 1, 0, 0, 2, 0, -3, 0, 0, 0, 0, + -2, 0, 0, 2, 1, 0, 0, 6, -8, 0, 0, 0, 0, 0, + 1, 0, 0, -1, 1, 0, 0, -1, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, -5, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 0, -1, 0, -1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, 0, -1, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, + 0, 0, 1, -1, 2, 0, 0, -1, 0, 0, -1, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, + 0, 0, -1, 1, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -7, 13, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 7, -13, 0, 0, 0, 0, 0, + 2, 0, 0, -2, 1, 0, 0, -5, 6, 0, 0, 0, 0, 0, + 0, 0, 2, -2, 1, 0, 0, -8, 11, 0, 0, 0, 0, 0, + 0, 0, 2, -2, 1, -1, 0, 2, 0, 0, 0, 0, 0, 0, + -2, 0, 0, 2, 0, 0, 0, 4, -4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -2, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 0, -1, 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 2, + -2, 0, 0, 2, 0, 0, 3, -3, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, 0, -4, 8, -3, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, 0, 4, -8, 3, 0, 0, 0, 0, + 2, 0, 0, -2, 1, 0, 0, -2, 0, 2, 0, 0, 0, 0, + 0, 0, 1, -1, 2, 0, 0, -1, 0, 2, 0, 0, 0, 0, + 0, 0, 1, -1, 2, 0, 0, 0, -2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 1, -2, 0, 0, 0, 0, 0, + 0, 0, -1, 1, 0, 0, 0, 2, -2, 0, 0, 0, 0, 0, + 0, 0, -1, 1, 0, 0, 0, 1, 0, 0, -2, 0, 0, 0, + 0, 0, 2, -2, 1, 0, 0, -2, 0, 0, 2, 0, 0, 0, + 0, 0, 1, -1, 1, 0, 3, -6, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 3, -5, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 3, -5, 0, 0, 0, 0, 0, 0, + 0, 0, 1, -1, 1, 0, -3, 4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -3, 5, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, -3, 5, 0, 0, 0, 0, 0, 2, + 0, 0, 2, -2, 2, 0, -3, 3, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -3, 5, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, -4, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, 0, 1, -4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, -4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -2, 4, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, 0, -3, 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -2, 4, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, -2, 4, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -5, 8, 0, 0, 0, 0, 0, 2, + 0, 0, 2, -2, 2, 0, -5, 6, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -5, 8, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -5, 8, 0, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, -5, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -5, 8, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 5, -8, 0, 0, 0, 0, 0, 0, + 0, 0, 1, -1, 2, 0, 0, -1, 0, -1, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, + 0, 0, -1, 1, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, + 0, 0, 2, -2, 1, 0, 0, -2, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -6, 11, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 6, -11, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, -1, 0, 4, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 1, 0, -4, 0, 0, 0, 0, 0, 0, + 2, 0, 0, -2, 1, 0, -3, 3, 0, 0, 0, 0, 0, 0, + -2, 0, 0, 2, 0, 0, 0, 2, 0, 0, -2, 0, 0, 0, + 0, 0, 2, -2, 1, 0, 0, -7, 9, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, -5, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, 0, -1, 0, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, + 0, 0, 2, -2, 2, 0, 0, -2, 0, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 2, + 0, 0, 0, 0, 1, 0, 3, -5, 0, 0, 0, 0, 0, 0, + 0, 0, -1, 1, 0, 0, 3, -4, 0, 0, 0, 0, 0, 0, + 0, 0, 2, -2, 1, 0, -3, 3, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 2, -4, 0, 0, 0, 0, 0, + 0, 0, 2, -2, 1, 0, 0, -4, 4, 0, 0, 0, 0, 0, + 0, 0, 1, -1, 2, 0, -5, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, -6, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -3, 6, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, 0, -4, 6, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -3, 6, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, -3, 6, 0, 0, 0, 0, 2, + 0, 0, -1, 1, 0, 0, 2, -2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 2, -3, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -5, 9, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -5, 9, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 5, -9, 0, 0, 0, 0, 0, + 0, 0, -1, 1, 0, 0, 0, 1, 0, -2, 0, 0, 0, 0, + 0, 0, 2, -2, 1, 0, 0, -2, 0, 2, 0, 0, 0, 0, + -2, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, -2, 2, 0, 0, 3, -3, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -6, 10, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, -6, 10, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -2, 3, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -2, 3, 0, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, -2, 2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2, -3, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2, -3, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, 0, -1, 0, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 4, -8, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -4, 8, 0, 0, 0, 0, 2, + 0, 0, -2, 2, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -4, 7, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -4, 7, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 4, -7, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, -2, 3, 0, 0, 0, 0, 0, 0, + 0, 0, 2, -2, 1, 0, 0, -2, 0, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -5, 10, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 1, 0, -1, 2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -3, 5, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -3, 5, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 3, -5, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, -2, 0, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, 1, -3, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, -2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -1, 2, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, -1, 2, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -7, 11, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -7, 11, 0, 0, 0, 0, 0, 1, + 0, 0, -2, 2, 0, 0, 4, -4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, -3, 0, 0, 0, 0, 0, + 0, 0, 2, -2, 1, 0, -4, 4, 0, 0, 0, 0, 0, 0, + 0, 0, -1, 1, 0, 0, 4, -5, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -4, 7, 0, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, -4, 6, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -4, 7, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -4, 6, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -4, 6, 0, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, -4, 5, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -4, 6, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 4, -6, 0, 0, 0, 0, 0, 0, + -2, 0, 0, 2, 0, 0, 2, -2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, -1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 1, -1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -1, 0, 5, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 1, -3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -1, 3, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -7, 12, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, -1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, 1, -2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -2, 5, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -1, 0, 4, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 1, 0, -4, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, -1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -6, 10, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -6, 10, 0, 0, 0, 0, 0, + 0, 0, 2, -2, 1, 0, 0, -3, 0, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -3, 7, 0, 0, 0, 0, 2, + -2, 0, 0, 2, 0, 0, 4, -4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -5, 8, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 5, -8, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -1, 0, 3, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -1, 0, 3, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 1, 0, -3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2, -4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -2, 4, 0, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, -2, 3, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -2, 4, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -6, 9, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -6, 9, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 6, -9, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 1, 0, -2, 0, 0, 0, 0, + 0, 0, 2, -2, 1, 0, -2, 2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -4, 6, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 4, -6, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 3, -4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -1, 0, 2, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 1, 0, -2, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 1, 0, -1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -5, 9, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 3, -4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -3, 4, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -3, 4, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 3, -4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 3, -4, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 1, 0, 0, 2, -2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, -1, 0, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, -5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 1, 0, -3, 5, 0, 0, 0, + 0, 0, 0, 0, 1, 0, -3, 4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, -2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, -1, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, -2, 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -8, 14, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, -5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 5, -8, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 5, -8, 3, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, -8, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -3, 8, -3, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 1, 0, -2, 5, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -8, 12, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -8, 12, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, -2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 2, + 0, 0, 2, -2, 1, 0, -5, 5, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 3, -6, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -3, 6, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, -3, 6, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -1, 4, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -5, 7, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -5, 7, 0, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, -5, 6, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 5, -7, 0, 0, 0, 0, 0, 0, + 0, 0, 2, -2, 1, 0, 0, -1, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, -1, 0, 3, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -2, 6, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 1, 0, 2, -2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -6, 9, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 6, -9, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -2, 2, 0, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, -2, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2, -2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2, -2, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -5, 7, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 5, -7, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, -2, 2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 4, -5, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, -3, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -1, 3, 0, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, -1, 2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -1, 3, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -7, 10, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -7, 10, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 3, -3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -4, 8, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -4, 5, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -4, 5, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 4, -5, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -2, 0, 5, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -9, 13, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -1, 5, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -2, 0, 4, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, 0, -4, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -2, 7, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, 0, -3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -2, 5, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, -2, 5, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -6, 8, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -6, 8, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 6, -8, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 2, 0, -2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -3, 9, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 5, -6, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 5, -6, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, 0, -2, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 2, 0, -2, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -5, 10, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 4, -4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 4, -4, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -3, 3, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 3, -3, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 3, -3, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 3, -3, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, -3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -5, 13, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, 0, -1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, 0, -1, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, -2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, -2, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 3, -2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, -2, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, -1, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -6, 15, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -8, 15, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -3, 9, -4, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, -5, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -2, 8, -1, -5, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 6, -8, 3, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1, + 0, 0, 1, -1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -6, 16, -4, -5, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -2, 8, -3, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -2, 8, -3, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 6, -8, 1, 5, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, 0, -2, 5, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 3, -5, 4, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -8, 11, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -8, 11, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, -8, 11, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 3, -3, 0, 2, 0, 0, 0, 2, + 0, 0, 2, -2, 1, 0, 0, 4, -8, 3, 0, 0, 0, 0, + 0, 0, 1, -1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 2, -2, 1, 0, 0, -4, 8, -3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -3, 7, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -5, 6, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -5, 6, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 5, -6, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 5, -6, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -1, 6, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 7, -9, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 2, -1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2, -1, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 6, -7, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 5, -5, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -1, 4, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, -1, 4, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -7, 9, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -7, 9, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 4, -3, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 3, -1, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -4, 4, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 4, -4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 4, -4, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 4, -4, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -3, 0, 5, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -9, 12, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 3, 0, -4, 0, 0, 0, 0, + 0, 0, 2, -2, 1, 0, 1, -1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 7, -8, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 3, 0, -3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, -3, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -2, 6, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -6, 7, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 6, -7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 6, -6, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 3, 0, -2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, -2, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 5, -4, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 3, -2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 3, -2, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 3, 0, -1, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 3, 0, -1, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, -2, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 4, -2, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, -1, 0, 0, 2, + 0, 0, 2, -2, 1, 0, 0, 1, 0, -1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -8, 16, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 2, -5, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 7, -8, 3, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -5, 16, -4, -5, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, -1, 8, -3, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -8, 10, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -8, 10, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, -8, 10, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -3, 8, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -5, 5, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 5, -5, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 5, -5, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 5, -5, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 7, -7, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 7, -7, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 6, -5, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 7, -8, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 5, -3, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 4, -3, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -9, 11, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -9, 11, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 4, 0, -4, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 4, 0, -3, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -6, 6, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 6, -6, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 6, -6, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 4, 0, -2, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 6, -4, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 3, -1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 3, -1, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 3, -1, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 4, 0, -1, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, -2, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 5, -2, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 8, -9, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 5, -4, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, -7, 7, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 7, -7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 4, -2, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 4, -2, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 4, -2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 4, -2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 5, 0, -4, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 5, 0, -3, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 5, 0, -2, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -8, 8, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 8, -8, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 5, -3, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 5, -3, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, -9, 9, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, -9, 9, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, -9, 9, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 9, -9, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 6, -4, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 1, 0, 0, -2, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, + 1, 0, 0, -2, 0, 0, 2, -2, 0, 0, 0, 0, 0, 0, + 1, 0, 0, -2, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, + 1, 0, 0, -2, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, 3, -3, 0, 0, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, + -1, 0, 0, 2, 0, 0, 0, 4, -8, 3, 0, 0, 0, 0, + 1, 0, 0, -2, 0, 0, 0, 4, -8, 3, 0, 0, 0, 0, + -2, 0, 0, 2, 0, 0, 0, 4, -8, 3, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, 0, 2, 0, -3, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, + -1, 0, 0, 2, 0, 0, 2, -2, 0, 0, 0, 0, 0, 0, + 1, 0, -1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + -1, 0, 0, 2, 0, 0, 0, 2, 0, -3, 0, 0, 0, 0, + -2, 0, 0, 0, 0, 0, 0, 2, 0, -3, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 4, -8, 3, 0, 0, 0, 0, + -1, 0, 1, -1, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, + 1, 0, 1, -1, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, + -1, 0, 0, 0, 0, 0, 0, 4, -8, 3, 0, 0, 0, 0, + -1, 0, 0, 2, 1, 0, 0, 2, 0, -2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, + -1, 0, 0, 2, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, + -1, 0, 0, 2, 0, 0, 3, -3, 0, 0, 0, 0, 0, 0, + 1, 0, 0, -2, 1, 0, 0, -2, 0, 2, 0, 0, 0, 0, + 1, 0, 2, -2, 2, 0, -3, 3, 0, 0, 0, 0, 0, 0, + 1, 0, 2, -2, 2, 0, 0, -2, 0, 2, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, + 0, 0, 0, -2, 0, 0, 2, -2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, -2, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, + 0, 0, 2, 0, 2, 0, -2, 2, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 2, 0, 0, -1, 0, 1, 0, 0, 0, 0, + 0, 0, 2, 0, 2, 0, -1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 2, 0, -2, 3, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2, 0, 0, 0, 2, 0, -2, 0, 0, 0, 0, + 0, 0, 1, 1, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 1, 0, 2, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, + -1, 0, 2, 0, 2, 0, 10, -3, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 1, 0, 2, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 2, 0, 0, 4, -8, 3, 0, 0, 0, 0, + 0, 0, 2, 0, 2, 0, 0, -4, 8, -3, 0, 0, 0, 0, + -1, 0, 2, 0, 2, 0, 0, -4, 8, -3, 0, 0, 0, 0, + 2, 0, 2, -2, 2, 0, 0, -2, 0, 3, 0, 0, 0, 0, + 1, 0, 2, 0, 1, 0, 0, -2, 0, 3, 0, 0, 0, 0, + 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + -1, 0, 2, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, + -2, 0, 2, 2, 2, 0, 0, 2, 0, -2, 0, 0, 0, 0, + 0, 0, 2, 0, 2, 0, 2, -3, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 2, 0, 1, -1, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 2, 0, 0, 1, 0, -1, 0, 0, 0, 0, + 0, 0, 2, 0, 2, 0, 2, -2, 0, 0, 0, 0, 0, 0, + -1, 0, 2, 2, 2, 0, 0, -1, 0, 1, 0, 0, 0, 0, + 1, 0, 2, 0, 2, 0, -1, 1, 0, 0, 0, 0, 0, 0, + -1, 0, 2, 2, 2, 0, 0, 2, 0, -3, 0, 0, 0, 0, + 2, 0, 2, 0, 2, 0, 0, 2, 0, -3, 0, 0, 0, 0, + 1, 0, 2, 0, 2, 0, 0, -4, 8, -3, 0, 0, 0, 0, + 1, 0, 2, 0, 2, 0, 0, 4, -8, 3, 0, 0, 0, 0, + 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 2, 0, 2, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, + -1, 0, 2, 2, 2, 0, 0, 2, 0, -2, 0, 0, 0, 0, + -1, 0, 2, 2, 2, 0, 3, -3, 0, 0, 0, 0, 0, 0, + 1, 0, 2, 0, 2, 0, 1, -1, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 2, 2, 0, 0, 2, 0, -2, 0, 0, 0, 0, }; /* Planetary nutation coefficients, unit 1e-7 arcsec * longitude (sin, cos), obliquity (sin, cos) */ static int16 icpl[] = { -1440, 0, 0, 0, -56, -117, -42, -40, -125, -43, 0, -54, -0, 5, 0, 0, -3, -7, -3, 0, -3, 0, 0, -2, --114, 0, 0, 61, --219, 89, 0, 0, --3, 0, 0, 0, --462, 1604, 0, 0, -99, 0, 0, -53, --3, 0, 0, 2, -0, 6, 2, 0, -3, 0, 0, 0, --12, 0, 0, 0, -14, -218, 117, 8, -31, -481, -257, -17, --491, 128, 0, 0, --3084, 5123, 2735, 1647, --1444, 2409, -1286, -771, -11, -24, -11, -9, -26, -9, 0, 0, -103, -60, 0, 0, -0, -13, -7, 0, --26, -29, -16, 14, -9, -27, -14, -5, -12, 0, 0, -6, --7, 0, 0, 0, -0, 24, 0, 0, -284, 0, 0, -151, -226, 101, 0, 0, -0, -8, -2, 0, -0, -6, -3, 0, -5, 0, 0, -3, --41, 175, 76, 17, -0, 15, 6, 0, -425, 212, -133, 269, -1200, 598, 319, -641, -235, 334, 0, 0, -11, -12, -7, -6, -5, -6, 3, 3, --5, 0, 0, 3, -6, 0, 0, -3, -15, 0, 0, 0, -13, 0, 0, -7, --6, -9, 0, 0, -266, -78, 0, 0, --460, -435, -232, 246, -0, 15, 7, 0, --3, 0, 0, 2, -0, 131, 0, 0, -4, 0, 0, 0, -0, 3, 0, 0, -0, 4, 2, 0, -0, 3, 0, 0, --17, -19, -10, 9, --9, -11, 6, -5, --6, 0, 0, 3, --16, 8, 0, 0, -0, 3, 0, 0, -11, 24, 11, -5, --3, -4, -2, 1, -3, 0, 0, -1, -0, -8, -4, 0, -0, 3, 0, 0, -0, 5, 0, 0, -0, 3, 2, 0, --6, 4, 2, 3, --3, -5, 0, 0, --5, 0, 0, 2, -4, 24, 13, -2, --42, 20, 0, 0, --10, 233, 0, 0, --3, 0, 0, 1, -78, -18, 0, 0, -0, 3, 1, 0, -0, -3, -1, 0, -0, -4, -2, 1, -0, -8, -4, -1, -0, -5, 3, 0, --7, 0, 0, 3, --14, 8, 3, 6, -0, 8, -4, 0, -0, 19, 10, 0, -45, -22, 0, 0, --3, 0, 0, 0, -0, -3, 0, 0, -0, 3, 0, 0, -3, 5, 3, -2, -89, -16, -9, -48, -0, 3, 0, 0, --3, 7, 4, 2, --349, -62, 0, 0, --15, 22, 0, 0, --3, 0, 0, 0, --53, 0, 0, 0, -5, 0, 0, -3, -0, -8, 0, 0, -15, -7, -4, -8, --3, 0, 0, 1, --21, -78, 0, 0, -20, -70, -37, -11, -0, 6, 3, 0, -5, 3, 2, -2, --17, -4, -2, 9, -0, 6, 3, 0, -32, 15, -8, 17, -174, 84, 45, -93, -11, 56, 0, 0, --66, -12, -6, 35, -47, 8, 4, -25, -0, 8, 4, 0, -10, -22, -12, -5, --3, 0, 0, 2, --24, 12, 0, 0, -5, -6, 0, 0, -3, 0, 0, -2, -4, 3, 1, -2, -0, 29, 15, 0, --5, -4, -2, 2, -8, -3, -1, -5, -0, -3, 0, 0, -10, 0, 0, 0, -3, 0, 0, -2, --5, 0, 0, 3, -46, 66, 35, -25, --14, 7, 0, 0, -0, 3, 2, 0, --5, 0, 0, 0, --68, -34, -18, 36, -0, 14, 7, 0, -10, -6, -3, -5, --5, -4, -2, 3, --3, 5, 2, 1, -76, 17, 9, -41, -84, 298, 159, -45, -3, 0, 0, -1, --3, 0, 0, 2, --3, 0, 0, 1, --82, 292, 156, 44, --73, 17, 9, 39, --9, -16, 0, 0, -3, 0, -1, -2, --3, 0, 0, 0, --9, -5, -3, 5, --439, 0, 0, 0, -57, -28, -15, -30, -0, -6, -3, 0, --4, 0, 0, 2, --40, 57, 30, 21, -23, 7, 3, -13, -273, 80, 43, -146, --449, 430, 0, 0, --8, -47, -25, 4, -6, 47, 25, -3, -0, 23, 13, 0, --3, 0, 0, 2, -3, -4, -2, -2, --48, -110, -59, 26, -51, 114, 61, -27, --133, 0, 0, 57, -0, 4, 0, 0, --21, -6, -3, 11, -0, -3, -1, 0, --11, -21, -11, 6, --18, -436, -233, 9, -35, -7, 0, 0, -0, 5, 3, 0, -11, -3, -1, -6, --5, -3, -1, 3, --53, -9, -5, 28, -0, 3, 2, 1, -4, 0, 0, -2, -0, -4, 0, 0, --50, 194, 103, 27, --13, 52, 28, 7, --91, 248, 0, 0, -6, 49, 26, -3, --6, -47, -25, 3, -0, 5, 3, 0, -52, 23, 10, -23, --3, 0, 0, 1, -0, 5, 3, 0, --4, 0, 0, 0, --4, 8, 3, 2, -10, 0, 0, 0, -3, 0, 0, -2, -0, 8, 4, 0, -0, 8, 4, 1, --4, 0, 0, 0, --4, 0, 0, 0, --8, 4, 2, 4, -8, -4, -2, -4, -0, 15, 7, 0, --138, 0, 0, 0, -0, -7, -3, 0, -0, -7, -3, 0, -54, 0, 0, -29, -0, 10, 4, 0, --7, 0, 0, 3, --37, 35, 19, 20, -0, 4, 0, 0, --4, 9, 0, 0, -8, 0, 0, -4, --9, -14, -8, 5, --3, -9, -5, 3, --145, 47, 0, 0, --10, 40, 21, 5, -11, -49, -26, -7, --2150, 0, 0, 932, --12, 0, 0, 5, -85, 0, 0, -37, -4, 0, 0, -2, -3, 0, 0, -2, --86, 153, 0, 0, --6, 9, 5, 3, -9, -13, -7, -5, --8, 12, 6, 4, --51, 0, 0, 22, --11, -268, -116, 5, -0, 12, 5, 0, -0, 7, 3, 0, -31, 6, 3, -17, -140, 27, 14, -75, -57, 11, 6, -30, --14, -39, 0, 0, -0, -6, -2, 0, -4, 15, 8, -2, -0, 4, 0, 0, --3, 0, 0, 1, -0, 11, 5, 0, -9, 6, 0, 0, --4, 10, 4, 2, -5, 3, 0, 0, -16, 0, 0, -9, --3, 0, 0, 0, -0, 3, 2, -1, -7, 0, 0, -3, --25, 22, 0, 0, -42, 223, 119, -22, --27, -143, -77, 14, -9, 49, 26, -5, --1166, 0, 0, 505, --5, 0, 0, 2, --6, 0, 0, 3, --8, 0, 1, 4, -0, -4, 0, 0, -117, 0, 0, -63, --4, 8, 4, 2, -3, 0, 0, -2, --5, 0, 0, 2, -0, 31, 0, 0, --5, 0, 1, 3, -4, 0, 0, -2, --4, 0, 0, 2, --24, -13, -6, 10, -3, 0, 0, 0, -0, -32, -17, 0, -8, 12, 5, -3, -3, 0, 0, -1, -7, 13, 0, 0, --3, 16, 0, 0, -50, 0, 0, -27, -0, -5, -3, 0, -13, 0, 0, 0, -0, 5, 3, 1, -24, 5, 2, -11, -5, -11, -5, -2, -30, -3, -2, -16, -18, 0, 0, -9, -8, 614, 0, 0, -3, -3, -1, -2, -6, 17, 9, -3, --3, -9, -5, 2, -0, 6, 3, -1, --127, 21, 9, 55, -3, 5, 0, 0, --6, -10, -4, 3, -5, 0, 0, 0, -16, 9, 4, -7, -3, 0, 0, -2, -0, 22, 0, 0, -0, 19, 10, 0, -7, 0, 0, -4, -0, -5, -2, 0, -0, 3, 1, 0, --9, 3, 1, 4, -17, 0, 0, -7, -0, -3, -2, -1, --20, 34, 0, 0, --10, 0, 1, 5, --4, 0, 0, 2, -22, -87, 0, 0, --4, 0, 0, 2, --3, -6, -2, 1, --16, -3, -1, 7, -0, -3, -2, 0, -4, 0, 0, 0, --68, 39, 0, 0, -27, 0, 0, -14, -0, -4, 0, 0, --25, 0, 0, 0, --12, -3, -2, 6, -3, 0, 0, -1, -3, 66, 29, -1, -490, 0, 0, -213, --22, 93, 49, 12, --7, 28, 15, 4, --3, 13, 7, 2, --46, 14, 0, 0, --5, 0, 0, 0, -2, 1, 0, 0, -0, -3, 0, 0, --28, 0, 0, 15, -5, 0, 0, -2, -0, 3, 0, 0, --11, 0, 0, 5, -0, 3, 1, 0, --3, 0, 0, 1, -25, 106, 57, -13, -5, 21, 11, -3, -1485, 0, 0, 0, --7, -32, -17, 4, -0, 5, 3, 0, --6, -3, -2, 3, -30, -6, -2, -13, --4, 4, 0, 0, --19, 0, 0, 10, -0, 4, 2, -1, -0, 3, 0, 0, -4, 0, 0, -2, -0, -3, -1, 0, --3, 0, 0, 0, -5, 3, 1, -2, -0, 11, 0, 0, -118, 0, 0, -52, -0, -5, -3, 0, --28, 36, 0, 0, -5, -5, 0, 0, -14, -59, -31, -8, -0, 9, 5, 1, --458, 0, 0, 198, -0, -45, -20, 0, -9, 0, 0, -5, -0, -3, 0, 0, -0, -4, -2, -1, -11, 0, 0, -6, -6, 0, 0, -2, --16, 23, 0, 0, -0, -4, -2, 0, --5, 0, 0, 2, --166, 269, 0, 0, -15, 0, 0, -8, -10, 0, 0, -4, --78, 45, 0, 0, -0, -5, -2, 0, -7, 0, 0, -4, --5, 328, 0, 0, -3, 0, 0, -2, -5, 0, 0, -2, -0, 3, 1, 0, --3, 0, 0, 0, --3, 0, 0, 0, -0, -4, -2, 0, --1223, -26, 0, 0, -0, 7, 3, 0, -3, 0, 0, 0, -0, 3, 2, 0, --6, 20, 0, 0, --368, 0, 0, 0, --75, 0, 0, 0, -11, 0, 0, -6, -3, 0, 0, -2, --3, 0, 0, 1, --13, -30, 0, 0, -21, 3, 0, 0, --3, 0, 0, 1, --4, 0, 0, 2, -8, -27, 0, 0, --19, -11, 0, 0, --4, 0, 0, 2, -0, 5, 2, 0, --6, 0, 0, 2, --8, 0, 0, 0, --1, 0, 0, 0, --14, 0, 0, 6, -6, 0, 0, 0, --74, 0, 0, 32, -0, -3, -1, 0, -4, 0, 0, -2, -8, 11, 0, 0, -0, 3, 2, 0, --262, 0, 0, 114, -0, -4, 0, 0, --7, 0, 0, 4, -0, -27, -12, 0, --19, -8, -4, 8, -202, 0, 0, -87, --8, 35, 19, 5, -0, 4, 2, 0, -16, -5, 0, 0, -5, 0, 0, -3, -0, -3, 0, 0, -1, 0, 0, 0, --35, -48, -21, 15, --3, -5, -2, 1, -6, 0, 0, -3, -3, 0, 0, -1, -0, -5, 0, 0, -12, 55, 29, -6, -0, 5, 3, 0, --598, 0, 0, 0, --3, -13, -7, 1, --5, -7, -3, 2, -3, 0, 0, -1, -5, -7, 0, 0, -4, 0, 0, -2, -16, -6, 0, 0, -8, -3, 0, 0, -8, -31, -16, -4, -0, 3, 1, 0, -113, 0, 0, -49, -0, -24, -10, 0, -4, 0, 0, -2, -27, 0, 0, 0, --3, 0, 0, 1, -0, -4, -2, 0, -5, 0, 0, -2, -0, -3, 0, 0, --13, 0, 0, 6, -5, 0, 0, -2, --18, -10, -4, 8, --4, -28, 0, 0, --5, 6, 3, 2, --3, 0, 0, 1, --5, -9, -4, 2, -17, 0, 0, -7, -11, 4, 0, 0, -0, -6, -2, 0, -83, 15, 0, 0, --4, 0, 0, 2, -0, -114, -49, 0, -117, 0, 0, -51, --5, 19, 10, 2, --3, 0, 0, 0, --3, 0, 0, 2, -0, -3, -1, 0, -3, 0, 0, 0, -0, -6, -2, 0, -393, 3, 0, 0, --4, 21, 11, 2, --6, 0, -1, 3, --3, 8, 4, 1, -8, 0, 0, 0, -18, -29, -13, -8, -8, 34, 18, -4, -89, 0, 0, 0, -3, 12, 6, -1, -54, -15, -7, -24, -0, 3, 0, 0, -3, 0, 0, -1, -0, 35, 0, 0, --154, -30, -13, 67, -15, 0, 0, 0, -0, 4, 2, 0, -0, 9, 0, 0, -80, -71, -31, -35, -0, -20, -9, 0, -11, 5, 2, -5, -61, -96, -42, -27, -14, 9, 4, -6, --11, -6, -3, 5, -0, -3, -1, 0, -123, -415, -180, -53, -0, 0, 0, -35, --5, 0, 0, 0, -7, -32, -17, -4, -0, -9, -5, 0, -0, -4, 2, 0, --89, 0, 0, 38, -0, -86, -19, -6, -0, 0, -19, 6, --123, -416, -180, 53, -0, -3, -1, 0, -12, -6, -3, -5, --13, 9, 4, 6, -0, -15, -7, 0, -3, 0, 0, -1, --62, -97, -42, 27, --11, 5, 2, 5, -0, -19, -8, 0, --3, 0, 0, 1, -0, 4, 2, 0, -0, 3, 0, 0, -0, 4, 2, 0, --85, -70, -31, 37, -163, -12, -5, -72, --63, -16, -7, 28, --21, -32, -14, 9, -0, -3, -1, 0, -3, 0, 0, -2, -0, 8, 0, 0, -3, 10, 4, -1, -3, 0, 0, -1, -0, -7, -3, 0, -0, -4, -2, 0, -6, 19, 0, 0, -5, -173, -75, -2, -0, -7, -3, 0, -7, -12, -5, -3, --3, 0, 0, 2, -3, -4, -2, -1, -74, 0, 0, -32, --3, 12, 6, 2, -26, -14, -6, -11, -19, 0, 0, -8, -6, 24, 13, -3, -83, 0, 0, 0, -0, -10, -5, 0, -11, -3, -1, -5, -3, 0, 1, -1, -3, 0, 0, -1, --4, 0, 0, 0, -5, -23, -12, -3, --339, 0, 0, 147, -0, -10, -5, 0, -5, 0, 0, 0, -3, 0, 0, -1, -0, -4, -2, 0, -18, -3, 0, 0, -9, -11, -5, -4, --8, 0, 0, 4, -3, 0, 0, -1, -0, 9, 0, 0, -6, -9, -4, -2, --4, -12, 0, 0, -67, -91, -39, -29, -30, -18, -8, -13, -0, 0, 0, 0, -0, -114, -50, 0, -0, 0, 0, 23, -517, 16, 7, -224, -0, -7, -3, 0, -143, -3, -1, -62, -29, 0, 0, -13, --4, 0, 0, 2, --6, 0, 0, 3, -5, 12, 5, -2, --25, 0, 0, 11, --3, 0, 0, 1, -0, 4, 2, 0, --22, 12, 5, 10, -50, 0, 0, -22, -0, 7, 4, 0, -0, 3, 1, 0, --4, 4, 2, 2, --5, -11, -5, 2, -0, 4, 2, 0, -4, 17, 9, -2, -59, 0, 0, 0, -0, -4, -2, 0, --8, 0, 0, 4, --3, 0, 0, 0, -4, -15, -8, -2, -370, -8, 0, -160, -0, 0, -3, 0, -0, 3, 1, 0, --6, 3, 1, 3, -0, 6, 0, 0, --10, 0, 0, 4, -0, 9, 4, 0, -4, 17, 7, -2, -34, 0, 0, -15, -0, 5, 3, 0, --5, 0, 0, 2, --37, -7, -3, 16, -3, 13, 7, -2, -40, 0, 0, 0, -0, -3, -2, 0, --184, -3, -1, 80, --3, 0, 0, 1, --3, 0, 0, 0, -0, -10, -6, -1, -31, -6, 0, -13, --3, -32, -14, 1, --7, 0, 0, 3, -0, -8, -4, 0, -3, -4, 0, 0, -0, 4, 0, 0, -0, 3, 1, 0, -19, -23, -10, 2, -0, 0, 0, -10, -0, 3, 2, 0, -0, 9, 5, -1, -28, 0, 0, 0, -0, -7, -4, 0, -8, -4, 0, -4, -0, 0, -2, 0, -0, 3, 0, 0, --3, 0, 0, 1, --9, 0, 1, 4, -3, 12, 5, -1, -17, -3, -1, 0, -0, 7, 4, 0, -19, 0, 0, 0, -0, -5, -3, 0, -14, -3, 0, -1, -0, 0, -1, 0, -0, 0, 0, -5, -0, 5, 3, 0, -13, 0, 0, 0, -0, -3, -2, 0, -2, 9, 4, 3, -0, 0, 0, -4, -8, 0, 0, 0, -0, 4, 2, 0, -6, 0, 0, -3, -6, 0, 0, 0, -0, 3, 1, 0, -5, 0, 0, -2, -3, 0, 0, -1, --3, 0, 0, 0, -6, 0, 0, 0, -7, 0, 0, 0, --4, 0, 0, 0, -4, 0, 0, 0, -6, 0, 0, 0, -0, -4, 0, 0, -0, -4, 0, 0, -5, 0, 0, 0, --3, 0, 0, 0, -4, 0, 0, 0, --5, 0, 0, 0, -4, 0, 0, 0, -0, 3, 0, 0, -13, 0, 0, 0, -21, 11, 0, 0, -0, -5, 0, 0, -0, -5, -2, 0, -0, 5, 3, 0, -0, -5, 0, 0, --3, 0, 0, 2, -20, 10, 0, 0, --34, 0, 0, 0, --19, 0, 0, 0, -3, 0, 0, -2, --3, 0, 0, 1, --6, 0, 0, 3, --4, 0, 0, 0, -3, 0, 0, 0, -3, 0, 0, 0, -4, 0, 0, 0, -3, 0, 0, -1, -6, 0, 0, -3, --8, 0, 0, 3, -0, 3, 1, 0, --3, 0, 0, 0, -0, -3, -2, 0, -126, -63, -27, -55, --5, 0, 1, 2, --3, 28, 15, 2, -5, 0, 1, -2, -0, 9, 4, 1, -0, 9, 4, -1, --126, -63, -27, 55, -3, 0, 0, -1, -21, -11, -6, -11, -0, -4, 0, 0, --21, -11, -6, 11, --3, 0, 0, 1, -0, 3, 1, 0, -8, 0, 0, -4, --6, 0, 0, 3, --3, 0, 0, 1, -3, 0, 0, -1, --3, 0, 0, 1, --5, 0, 0, 2, -24, -12, -5, -11, -0, 3, 1, 0, -0, 3, 1, 0, -0, 3, 2, 0, --24, -12, -5, 10, -4, 0, -1, -2, -13, 0, 0, -6, -7, 0, 0, -3, -3, 0, 0, -1, -3, 0, 0, -1, + 1440, 0, 0, 0, + 56, -117, -42, -40, + 125, -43, 0, -54, + 0, 5, 0, 0, + 3, -7, -3, 0, + 3, 0, 0, -2, + -114, 0, 0, 61, + -219, 89, 0, 0, + -3, 0, 0, 0, + -462, 1604, 0, 0, + 99, 0, 0, -53, + -3, 0, 0, 2, + 0, 6, 2, 0, + 3, 0, 0, 0, + -12, 0, 0, 0, + 14, -218, 117, 8, + 31, -481, -257, -17, + -491, 128, 0, 0, + -3084, 5123, 2735, 1647, + -1444, 2409, -1286, -771, + 11, -24, -11, -9, + 26, -9, 0, 0, + 103, -60, 0, 0, + 0, -13, -7, 0, + -26, -29, -16, 14, + 9, -27, -14, -5, + 12, 0, 0, -6, + -7, 0, 0, 0, + 0, 24, 0, 0, + 284, 0, 0, -151, + 226, 101, 0, 0, + 0, -8, -2, 0, + 0, -6, -3, 0, + 5, 0, 0, -3, + -41, 175, 76, 17, + 0, 15, 6, 0, + 425, 212, -133, 269, + 1200, 598, 319, -641, + 235, 334, 0, 0, + 11, -12, -7, -6, + 5, -6, 3, 3, + -5, 0, 0, 3, + 6, 0, 0, -3, + 15, 0, 0, 0, + 13, 0, 0, -7, + -6, -9, 0, 0, + 266, -78, 0, 0, + -460, -435, -232, 246, + 0, 15, 7, 0, + -3, 0, 0, 2, + 0, 131, 0, 0, + 4, 0, 0, 0, + 0, 3, 0, 0, + 0, 4, 2, 0, + 0, 3, 0, 0, + -17, -19, -10, 9, + -9, -11, 6, -5, + -6, 0, 0, 3, + -16, 8, 0, 0, + 0, 3, 0, 0, + 11, 24, 11, -5, + -3, -4, -2, 1, + 3, 0, 0, -1, + 0, -8, -4, 0, + 0, 3, 0, 0, + 0, 5, 0, 0, + 0, 3, 2, 0, + -6, 4, 2, 3, + -3, -5, 0, 0, + -5, 0, 0, 2, + 4, 24, 13, -2, + -42, 20, 0, 0, + -10, 233, 0, 0, + -3, 0, 0, 1, + 78, -18, 0, 0, + 0, 3, 1, 0, + 0, -3, -1, 0, + 0, -4, -2, 1, + 0, -8, -4, -1, + 0, -5, 3, 0, + -7, 0, 0, 3, + -14, 8, 3, 6, + 0, 8, -4, 0, + 0, 19, 10, 0, + 45, -22, 0, 0, + -3, 0, 0, 0, + 0, -3, 0, 0, + 0, 3, 0, 0, + 3, 5, 3, -2, + 89, -16, -9, -48, + 0, 3, 0, 0, + -3, 7, 4, 2, + -349, -62, 0, 0, + -15, 22, 0, 0, + -3, 0, 0, 0, + -53, 0, 0, 0, + 5, 0, 0, -3, + 0, -8, 0, 0, + 15, -7, -4, -8, + -3, 0, 0, 1, + -21, -78, 0, 0, + 20, -70, -37, -11, + 0, 6, 3, 0, + 5, 3, 2, -2, + -17, -4, -2, 9, + 0, 6, 3, 0, + 32, 15, -8, 17, + 174, 84, 45, -93, + 11, 56, 0, 0, + -66, -12, -6, 35, + 47, 8, 4, -25, + 0, 8, 4, 0, + 10, -22, -12, -5, + -3, 0, 0, 2, + -24, 12, 0, 0, + 5, -6, 0, 0, + 3, 0, 0, -2, + 4, 3, 1, -2, + 0, 29, 15, 0, + -5, -4, -2, 2, + 8, -3, -1, -5, + 0, -3, 0, 0, + 10, 0, 0, 0, + 3, 0, 0, -2, + -5, 0, 0, 3, + 46, 66, 35, -25, + -14, 7, 0, 0, + 0, 3, 2, 0, + -5, 0, 0, 0, + -68, -34, -18, 36, + 0, 14, 7, 0, + 10, -6, -3, -5, + -5, -4, -2, 3, + -3, 5, 2, 1, + 76, 17, 9, -41, + 84, 298, 159, -45, + 3, 0, 0, -1, + -3, 0, 0, 2, + -3, 0, 0, 1, + -82, 292, 156, 44, + -73, 17, 9, 39, + -9, -16, 0, 0, + 3, 0, -1, -2, + -3, 0, 0, 0, + -9, -5, -3, 5, + -439, 0, 0, 0, + 57, -28, -15, -30, + 0, -6, -3, 0, + -4, 0, 0, 2, + -40, 57, 30, 21, + 23, 7, 3, -13, + 273, 80, 43, -146, + -449, 430, 0, 0, + -8, -47, -25, 4, + 6, 47, 25, -3, + 0, 23, 13, 0, + -3, 0, 0, 2, + 3, -4, -2, -2, + -48, -110, -59, 26, + 51, 114, 61, -27, + -133, 0, 0, 57, + 0, 4, 0, 0, + -21, -6, -3, 11, + 0, -3, -1, 0, + -11, -21, -11, 6, + -18, -436, -233, 9, + 35, -7, 0, 0, + 0, 5, 3, 0, + 11, -3, -1, -6, + -5, -3, -1, 3, + -53, -9, -5, 28, + 0, 3, 2, 1, + 4, 0, 0, -2, + 0, -4, 0, 0, + -50, 194, 103, 27, + -13, 52, 28, 7, + -91, 248, 0, 0, + 6, 49, 26, -3, + -6, -47, -25, 3, + 0, 5, 3, 0, + 52, 23, 10, -23, + -3, 0, 0, 1, + 0, 5, 3, 0, + -4, 0, 0, 0, + -4, 8, 3, 2, + 10, 0, 0, 0, + 3, 0, 0, -2, + 0, 8, 4, 0, + 0, 8, 4, 1, + -4, 0, 0, 0, + -4, 0, 0, 0, + -8, 4, 2, 4, + 8, -4, -2, -4, + 0, 15, 7, 0, + -138, 0, 0, 0, + 0, -7, -3, 0, + 0, -7, -3, 0, + 54, 0, 0, -29, + 0, 10, 4, 0, + -7, 0, 0, 3, + -37, 35, 19, 20, + 0, 4, 0, 0, + -4, 9, 0, 0, + 8, 0, 0, -4, + -9, -14, -8, 5, + -3, -9, -5, 3, + -145, 47, 0, 0, + -10, 40, 21, 5, + 11, -49, -26, -7, + -2150, 0, 0, 932, + -12, 0, 0, 5, + 85, 0, 0, -37, + 4, 0, 0, -2, + 3, 0, 0, -2, + -86, 153, 0, 0, + -6, 9, 5, 3, + 9, -13, -7, -5, + -8, 12, 6, 4, + -51, 0, 0, 22, + -11, -268, -116, 5, + 0, 12, 5, 0, + 0, 7, 3, 0, + 31, 6, 3, -17, + 140, 27, 14, -75, + 57, 11, 6, -30, + -14, -39, 0, 0, + 0, -6, -2, 0, + 4, 15, 8, -2, + 0, 4, 0, 0, + -3, 0, 0, 1, + 0, 11, 5, 0, + 9, 6, 0, 0, + -4, 10, 4, 2, + 5, 3, 0, 0, + 16, 0, 0, -9, + -3, 0, 0, 0, + 0, 3, 2, -1, + 7, 0, 0, -3, + -25, 22, 0, 0, + 42, 223, 119, -22, + -27, -143, -77, 14, + 9, 49, 26, -5, + -1166, 0, 0, 505, + -5, 0, 0, 2, + -6, 0, 0, 3, + -8, 0, 1, 4, + 0, -4, 0, 0, + 117, 0, 0, -63, + -4, 8, 4, 2, + 3, 0, 0, -2, + -5, 0, 0, 2, + 0, 31, 0, 0, + -5, 0, 1, 3, + 4, 0, 0, -2, + -4, 0, 0, 2, + -24, -13, -6, 10, + 3, 0, 0, 0, + 0, -32, -17, 0, + 8, 12, 5, -3, + 3, 0, 0, -1, + 7, 13, 0, 0, + -3, 16, 0, 0, + 50, 0, 0, -27, + 0, -5, -3, 0, + 13, 0, 0, 0, + 0, 5, 3, 1, + 24, 5, 2, -11, + 5, -11, -5, -2, + 30, -3, -2, -16, + 18, 0, 0, -9, + 8, 614, 0, 0, + 3, -3, -1, -2, + 6, 17, 9, -3, + -3, -9, -5, 2, + 0, 6, 3, -1, + -127, 21, 9, 55, + 3, 5, 0, 0, + -6, -10, -4, 3, + 5, 0, 0, 0, + 16, 9, 4, -7, + 3, 0, 0, -2, + 0, 22, 0, 0, + 0, 19, 10, 0, + 7, 0, 0, -4, + 0, -5, -2, 0, + 0, 3, 1, 0, + -9, 3, 1, 4, + 17, 0, 0, -7, + 0, -3, -2, -1, + -20, 34, 0, 0, + -10, 0, 1, 5, + -4, 0, 0, 2, + 22, -87, 0, 0, + -4, 0, 0, 2, + -3, -6, -2, 1, + -16, -3, -1, 7, + 0, -3, -2, 0, + 4, 0, 0, 0, + -68, 39, 0, 0, + 27, 0, 0, -14, + 0, -4, 0, 0, + -25, 0, 0, 0, + -12, -3, -2, 6, + 3, 0, 0, -1, + 3, 66, 29, -1, + 490, 0, 0, -213, + -22, 93, 49, 12, + -7, 28, 15, 4, + -3, 13, 7, 2, + -46, 14, 0, 0, + -5, 0, 0, 0, + 2, 1, 0, 0, + 0, -3, 0, 0, + -28, 0, 0, 15, + 5, 0, 0, -2, + 0, 3, 0, 0, + -11, 0, 0, 5, + 0, 3, 1, 0, + -3, 0, 0, 1, + 25, 106, 57, -13, + 5, 21, 11, -3, + 1485, 0, 0, 0, + -7, -32, -17, 4, + 0, 5, 3, 0, + -6, -3, -2, 3, + 30, -6, -2, -13, + -4, 4, 0, 0, + -19, 0, 0, 10, + 0, 4, 2, -1, + 0, 3, 0, 0, + 4, 0, 0, -2, + 0, -3, -1, 0, + -3, 0, 0, 0, + 5, 3, 1, -2, + 0, 11, 0, 0, + 118, 0, 0, -52, + 0, -5, -3, 0, + -28, 36, 0, 0, + 5, -5, 0, 0, + 14, -59, -31, -8, + 0, 9, 5, 1, + -458, 0, 0, 198, + 0, -45, -20, 0, + 9, 0, 0, -5, + 0, -3, 0, 0, + 0, -4, -2, -1, + 11, 0, 0, -6, + 6, 0, 0, -2, + -16, 23, 0, 0, + 0, -4, -2, 0, + -5, 0, 0, 2, + -166, 269, 0, 0, + 15, 0, 0, -8, + 10, 0, 0, -4, + -78, 45, 0, 0, + 0, -5, -2, 0, + 7, 0, 0, -4, + -5, 328, 0, 0, + 3, 0, 0, -2, + 5, 0, 0, -2, + 0, 3, 1, 0, + -3, 0, 0, 0, + -3, 0, 0, 0, + 0, -4, -2, 0, + -1223, -26, 0, 0, + 0, 7, 3, 0, + 3, 0, 0, 0, + 0, 3, 2, 0, + -6, 20, 0, 0, + -368, 0, 0, 0, + -75, 0, 0, 0, + 11, 0, 0, -6, + 3, 0, 0, -2, + -3, 0, 0, 1, + -13, -30, 0, 0, + 21, 3, 0, 0, + -3, 0, 0, 1, + -4, 0, 0, 2, + 8, -27, 0, 0, + -19, -11, 0, 0, + -4, 0, 0, 2, + 0, 5, 2, 0, + -6, 0, 0, 2, + -8, 0, 0, 0, + -1, 0, 0, 0, + -14, 0, 0, 6, + 6, 0, 0, 0, + -74, 0, 0, 32, + 0, -3, -1, 0, + 4, 0, 0, -2, + 8, 11, 0, 0, + 0, 3, 2, 0, + -262, 0, 0, 114, + 0, -4, 0, 0, + -7, 0, 0, 4, + 0, -27, -12, 0, + -19, -8, -4, 8, + 202, 0, 0, -87, + -8, 35, 19, 5, + 0, 4, 2, 0, + 16, -5, 0, 0, + 5, 0, 0, -3, + 0, -3, 0, 0, + 1, 0, 0, 0, + -35, -48, -21, 15, + -3, -5, -2, 1, + 6, 0, 0, -3, + 3, 0, 0, -1, + 0, -5, 0, 0, + 12, 55, 29, -6, + 0, 5, 3, 0, + -598, 0, 0, 0, + -3, -13, -7, 1, + -5, -7, -3, 2, + 3, 0, 0, -1, + 5, -7, 0, 0, + 4, 0, 0, -2, + 16, -6, 0, 0, + 8, -3, 0, 0, + 8, -31, -16, -4, + 0, 3, 1, 0, + 113, 0, 0, -49, + 0, -24, -10, 0, + 4, 0, 0, -2, + 27, 0, 0, 0, + -3, 0, 0, 1, + 0, -4, -2, 0, + 5, 0, 0, -2, + 0, -3, 0, 0, + -13, 0, 0, 6, + 5, 0, 0, -2, + -18, -10, -4, 8, + -4, -28, 0, 0, + -5, 6, 3, 2, + -3, 0, 0, 1, + -5, -9, -4, 2, + 17, 0, 0, -7, + 11, 4, 0, 0, + 0, -6, -2, 0, + 83, 15, 0, 0, + -4, 0, 0, 2, + 0, -114, -49, 0, + 117, 0, 0, -51, + -5, 19, 10, 2, + -3, 0, 0, 0, + -3, 0, 0, 2, + 0, -3, -1, 0, + 3, 0, 0, 0, + 0, -6, -2, 0, + 393, 3, 0, 0, + -4, 21, 11, 2, + -6, 0, -1, 3, + -3, 8, 4, 1, + 8, 0, 0, 0, + 18, -29, -13, -8, + 8, 34, 18, -4, + 89, 0, 0, 0, + 3, 12, 6, -1, + 54, -15, -7, -24, + 0, 3, 0, 0, + 3, 0, 0, -1, + 0, 35, 0, 0, + -154, -30, -13, 67, + 15, 0, 0, 0, + 0, 4, 2, 0, + 0, 9, 0, 0, + 80, -71, -31, -35, + 0, -20, -9, 0, + 11, 5, 2, -5, + 61, -96, -42, -27, + 14, 9, 4, -6, + -11, -6, -3, 5, + 0, -3, -1, 0, + 123, -415, -180, -53, + 0, 0, 0, -35, + -5, 0, 0, 0, + 7, -32, -17, -4, + 0, -9, -5, 0, + 0, -4, 2, 0, + -89, 0, 0, 38, + 0, -86, -19, -6, + 0, 0, -19, 6, + -123, -416, -180, 53, + 0, -3, -1, 0, + 12, -6, -3, -5, + -13, 9, 4, 6, + 0, -15, -7, 0, + 3, 0, 0, -1, + -62, -97, -42, 27, + -11, 5, 2, 5, + 0, -19, -8, 0, + -3, 0, 0, 1, + 0, 4, 2, 0, + 0, 3, 0, 0, + 0, 4, 2, 0, + -85, -70, -31, 37, + 163, -12, -5, -72, + -63, -16, -7, 28, + -21, -32, -14, 9, + 0, -3, -1, 0, + 3, 0, 0, -2, + 0, 8, 0, 0, + 3, 10, 4, -1, + 3, 0, 0, -1, + 0, -7, -3, 0, + 0, -4, -2, 0, + 6, 19, 0, 0, + 5, -173, -75, -2, + 0, -7, -3, 0, + 7, -12, -5, -3, + -3, 0, 0, 2, + 3, -4, -2, -1, + 74, 0, 0, -32, + -3, 12, 6, 2, + 26, -14, -6, -11, + 19, 0, 0, -8, + 6, 24, 13, -3, + 83, 0, 0, 0, + 0, -10, -5, 0, + 11, -3, -1, -5, + 3, 0, 1, -1, + 3, 0, 0, -1, + -4, 0, 0, 0, + 5, -23, -12, -3, + -339, 0, 0, 147, + 0, -10, -5, 0, + 5, 0, 0, 0, + 3, 0, 0, -1, + 0, -4, -2, 0, + 18, -3, 0, 0, + 9, -11, -5, -4, + -8, 0, 0, 4, + 3, 0, 0, -1, + 0, 9, 0, 0, + 6, -9, -4, -2, + -4, -12, 0, 0, + 67, -91, -39, -29, + 30, -18, -8, -13, + 0, 0, 0, 0, + 0, -114, -50, 0, + 0, 0, 0, 23, + 517, 16, 7, -224, + 0, -7, -3, 0, + 143, -3, -1, -62, + 29, 0, 0, -13, + -4, 0, 0, 2, + -6, 0, 0, 3, + 5, 12, 5, -2, + -25, 0, 0, 11, + -3, 0, 0, 1, + 0, 4, 2, 0, + -22, 12, 5, 10, + 50, 0, 0, -22, + 0, 7, 4, 0, + 0, 3, 1, 0, + -4, 4, 2, 2, + -5, -11, -5, 2, + 0, 4, 2, 0, + 4, 17, 9, -2, + 59, 0, 0, 0, + 0, -4, -2, 0, + -8, 0, 0, 4, + -3, 0, 0, 0, + 4, -15, -8, -2, + 370, -8, 0, -160, + 0, 0, -3, 0, + 0, 3, 1, 0, + -6, 3, 1, 3, + 0, 6, 0, 0, + -10, 0, 0, 4, + 0, 9, 4, 0, + 4, 17, 7, -2, + 34, 0, 0, -15, + 0, 5, 3, 0, + -5, 0, 0, 2, + -37, -7, -3, 16, + 3, 13, 7, -2, + 40, 0, 0, 0, + 0, -3, -2, 0, + -184, -3, -1, 80, + -3, 0, 0, 1, + -3, 0, 0, 0, + 0, -10, -6, -1, + 31, -6, 0, -13, + -3, -32, -14, 1, + -7, 0, 0, 3, + 0, -8, -4, 0, + 3, -4, 0, 0, + 0, 4, 0, 0, + 0, 3, 1, 0, + 19, -23, -10, 2, + 0, 0, 0, -10, + 0, 3, 2, 0, + 0, 9, 5, -1, + 28, 0, 0, 0, + 0, -7, -4, 0, + 8, -4, 0, -4, + 0, 0, -2, 0, + 0, 3, 0, 0, + -3, 0, 0, 1, + -9, 0, 1, 4, + 3, 12, 5, -1, + 17, -3, -1, 0, + 0, 7, 4, 0, + 19, 0, 0, 0, + 0, -5, -3, 0, + 14, -3, 0, -1, + 0, 0, -1, 0, + 0, 0, 0, -5, + 0, 5, 3, 0, + 13, 0, 0, 0, + 0, -3, -2, 0, + 2, 9, 4, 3, + 0, 0, 0, -4, + 8, 0, 0, 0, + 0, 4, 2, 0, + 6, 0, 0, -3, + 6, 0, 0, 0, + 0, 3, 1, 0, + 5, 0, 0, -2, + 3, 0, 0, -1, + -3, 0, 0, 0, + 6, 0, 0, 0, + 7, 0, 0, 0, + -4, 0, 0, 0, + 4, 0, 0, 0, + 6, 0, 0, 0, + 0, -4, 0, 0, + 0, -4, 0, 0, + 5, 0, 0, 0, + -3, 0, 0, 0, + 4, 0, 0, 0, + -5, 0, 0, 0, + 4, 0, 0, 0, + 0, 3, 0, 0, + 13, 0, 0, 0, + 21, 11, 0, 0, + 0, -5, 0, 0, + 0, -5, -2, 0, + 0, 5, 3, 0, + 0, -5, 0, 0, + -3, 0, 0, 2, + 20, 10, 0, 0, + -34, 0, 0, 0, + -19, 0, 0, 0, + 3, 0, 0, -2, + -3, 0, 0, 1, + -6, 0, 0, 3, + -4, 0, 0, 0, + 3, 0, 0, 0, + 3, 0, 0, 0, + 4, 0, 0, 0, + 3, 0, 0, -1, + 6, 0, 0, -3, + -8, 0, 0, 3, + 0, 3, 1, 0, + -3, 0, 0, 0, + 0, -3, -2, 0, + 126, -63, -27, -55, + -5, 0, 1, 2, + -3, 28, 15, 2, + 5, 0, 1, -2, + 0, 9, 4, 1, + 0, 9, 4, -1, + -126, -63, -27, 55, + 3, 0, 0, -1, + 21, -11, -6, -11, + 0, -4, 0, 0, + -21, -11, -6, 11, + -3, 0, 0, 1, + 0, 3, 1, 0, + 8, 0, 0, -4, + -6, 0, 0, 3, + -3, 0, 0, 1, + 3, 0, 0, -1, + -3, 0, 0, 1, + -5, 0, 0, 2, + 24, -12, -5, -11, + 0, 3, 1, 0, + 0, 3, 1, 0, + 0, 3, 2, 0, + -24, -12, -5, 10, + 4, 0, -1, -2, + 13, 0, 0, -6, + 7, 0, 0, -3, + 3, 0, 0, -1, + 3, 0, 0, -1, }; #endif /* NUT_IAU_2000A */ diff --git a/swe/src/sweodef.h b/swe/src/sweodef.h index c56606b..8369814 100644 --- a/swe/src/sweodef.h +++ b/swe/src/sweodef.h @@ -1,3 +1,4 @@ + /************************************************************ $Header: /home/dieter/sweph/RCS/sweodef.h,v 1.74 2008/06/16 10:07:20 dieter Exp $ definitions and constants for all Swiss Ephemeris source files, @@ -68,99 +69,99 @@ for promoting such software, products or services. */ -#ifndef _OURDEF_INCLUDED /* ourdef.h is a superset of sweodef.h */ -#ifndef _SWEODEF_INCLUDED /* allow multiple #includes */ +#ifndef _OURDEF_INCLUDED /* ourdef.h is a superset of sweodef.h */ +#ifndef _SWEODEF_INCLUDED /* allow multiple #includes */ #define _SWEODEF_INCLUDED - -# define MY_TRUE 1 /* for use in other defines, before TRUE is defined */ -# define MY_FALSE 0 /* for use in other defines, before TRUE is defined */ + +#define MY_TRUE 1 /* for use in other defines, before TRUE is defined */ +#define MY_FALSE 0 /* for use in other defines, before TRUE is defined */ -#ifdef _WIN32 /* Microsoft VC 5.0 does not define MSDOS anymore */ -# undef MSDOS -# define MSDOS MY_TRUE +#ifdef _WIN32 /* Microsoft VC 5.0 does not define MSDOS anymore */ +#undef MSDOS +#define MSDOS MY_TRUE #include #include #include #include #include #include -# define sleep(x) Sleep((x) * 1000) +#define sleep(x) Sleep((x) * 1000) #endif #ifdef _MSC_VER -# define MS_VC +#define MS_VC #endif -#ifdef WIN32 /* Microsoft VC 5.0 does not define MSDOS anymore */ -# define MSDOS MY_TRUE +#ifdef WIN32 /* Microsoft VC 5.0 does not define MSDOS anymore */ +#define MSDOS MY_TRUE #endif -#ifdef MSDOS /* already defined by some DOS compilers */ -# undef MSDOS -# define MSDOS MY_TRUE +#ifdef MSDOS /* already defined by some DOS compilers */ +#undef MSDOS +#define MSDOS MY_TRUE #endif -#ifdef __TURBOC__ /* defined by turboc */ -# ifndef MSDOS -# define MSDOS MY_TRUE -# endif -# define TURBO_C +#ifdef __TURBOC__ /* defined by turboc */ +#ifndef MSDOS +#define MSDOS MY_TRUE +#endif +#define TURBO_C #endif -#ifdef __SC__ /* defined by Symantec C */ -# ifndef MSDOS -# define MSDOS MY_TRUE -# endif -# define SYMANTEC_C +#ifdef __SC__ /* defined by Symantec C */ +#ifndef MSDOS +#define MSDOS MY_TRUE +#endif +#define SYMANTEC_C #endif -#ifdef __WATCOMC__ /* defined by WatcomC */ -# ifndef MSDOS -# define MSDOS MY_TRUE -# endif -# define WATCOMC +#ifdef __WATCOMC__ /* defined by WatcomC */ +#ifndef MSDOS +#define MSDOS MY_TRUE +#endif +#define WATCOMC #endif -#ifdef __MWERKS__ /* defined on Macintosh CodeWarrior */ -# if macintosh && powerc -# define MACOS MY_TRUE /* let it undefined otherwise */ -# define MSDOS MY_FALSE /* in case one above fired falsely */ -# endif +#ifdef __MWERKS__ /* defined on Macintosh CodeWarrior */ +#if macintosh && powerc +#define MACOS MY_TRUE /* let it undefined otherwise */ +#define MSDOS MY_FALSE /* in case one above fired falsely */ +#endif #endif #ifdef MSDOS -# define HPUNIX MY_FALSE -# define INTEL_BYTE_ORDER 1 -# ifndef TURBO_C -# define MS_C /* assume Microsoft C compiler */ -# endif -# define MYFAR far -# define UNIX_FS MY_FALSE +#define HPUNIX MY_FALSE +#define INTEL_BYTE_ORDER 1 +#ifndef TURBO_C +#define MS_C /* assume Microsoft C compiler */ +#endif +#define MYFAR far +#define UNIX_FS MY_FALSE #else -# ifdef MACOS -# define HPUNIX MY_FALSE -# define MYFAR -# define UNIX_FS MY_FALSE -# else -# define MSDOS MY_FALSE -# define HPUNIX MY_TRUE -# ifndef _HPUX_SOURCE -# define _HPUX_SOURCE -# endif -# define MYFAR -# define UNIX_FS MY_TRUE -# endif +#ifdef MACOS +#define HPUNIX MY_FALSE +#define MYFAR +#define UNIX_FS MY_FALSE +#else +#define MSDOS MY_FALSE +#define HPUNIX MY_TRUE +#ifndef _HPUX_SOURCE +#define _HPUX_SOURCE +#endif +#define MYFAR +#define UNIX_FS MY_TRUE +#endif #endif #include #include #ifndef FILE -# include +#include #endif #if HPUNIX -# include +#include #endif /* @@ -170,63 +171,63 @@ */ #include #if INT_MAX < 40000 -# define INT_16 +#define INT_16 #else -# if LONG_MAX > INT_MAX -# define LONG_64 -# endif +#if LONG_MAX > INT_MAX +#define LONG_64 +#endif #endif #ifdef BYTE_ORDER #ifdef LITTLE_ENDIAN -# if BYTE_ORDER == LITTLE_ENDIAN -# define INTEL_BYTE_ORDER -# endif +#if BYTE_ORDER == LITTLE_ENDIAN +#define INTEL_BYTE_ORDER +#endif #endif #endif #ifdef INT_16 - typedef long int32; - typedef unsigned long uint32; - typedef int int16; - typedef double REAL8; /* real with at least 64 bit precision */ - typedef long INT4; /* signed integer with at least 32 bit precision */ - typedef unsigned long UINT4; +typedef long int32; +typedef unsigned long uint32; +typedef int int16; +typedef double REAL8; /* real with at least 64 bit precision */ +typedef long INT4; /* signed integer with at least 32 bit precision */ +typedef unsigned long UINT4; /* unsigned integer with at least 32 bit precision */ - typedef int AS_BOOL; - typedef unsigned int UINT2; /* unsigned 16 bits */ -# define ABS4 labs /* abs function for long */ +typedef int AS_BOOL; +typedef unsigned int UINT2; /* unsigned 16 bits */ +#define ABS4 labs /* abs function for long */ #else - typedef int int32; - typedef long long int64; - typedef unsigned int uint32; - typedef short int16; - typedef double REAL8; /* real with at least 64 bit precision */ - typedef int INT4; /* signed integer with at least 32 bit precision */ - typedef unsigned int UINT4; - /* unsigned integer with at least 32 bit precision */ - typedef int AS_BOOL; - typedef unsigned short UINT2; /* unsigned 16 bits */ - # define ABS4 abs /* abs function for long */ +typedef int int32; +typedef long long int64; +typedef unsigned int uint32; +typedef short int16; +typedef double REAL8; /* real with at least 64 bit precision */ +typedef int INT4; /* signed integer with at least 32 bit precision */ +typedef unsigned int UINT4; + /* unsigned integer with at least 32 bit precision */ +typedef int AS_BOOL; +typedef unsigned short UINT2; /* unsigned 16 bits */ +#define ABS4 abs /* abs function for long */ #endif -#if MSDOS -# ifdef TURBO_C -# include /* MSC needs malloc ! */ -# else -# include -# endif -# define SIGALRM SIGINT +#if MSDOS +#ifdef TURBO_C +#include /* MSC needs malloc ! */ +#else +#include +#endif +#define SIGALRM SIGINT #endif -#ifndef TRUE -# define TRUE 1 -# define FALSE 0 +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 #endif -#ifndef OK -# define OK (0) -# define ERR (-1) +#ifndef OK +#define OK (0) +#define ERR (-1) #endif /* hack because UCHAR is already used by mingw gcc */ @@ -240,30 +241,30 @@ typedef unsigned char UCHAR; #define UCP (UCHAR*) #define SCP (char*) -# define ODEGREE_STRING "°" /* degree as string, utf8 encoding */ - +#define ODEGREE_STRING "°" /* degree as string, utf8 encoding */ + #ifndef HUGE -# define HUGE 1.7E+308 /* biggest value for REAL8 */ +#define HUGE 1.7E+308 /* biggest value for REAL8 */ #endif #ifndef M_PI -# define M_PI 3.14159265358979323846 +#define M_PI 3.14159265358979323846 #endif - + #define forward static -#define AS_MAXCH 256 /* used for string declarations, allowing 255 char+\0 */ - +#define AS_MAXCH 256 /* used for string declarations, allowing 255 char+\0 */ + #define DEGTORAD 0.0174532925199433 #define RADTODEG 57.2957795130823 - -typedef int32 centisec; /* centiseconds used for angles and times */ -#define CS (centisec) /* use for casting */ -#define CSEC centisec /* use for typing */ -#define DEG 360000 /* degree expressed in centiseconds */ -#define DEG7_30 (2700000) /* 7.5 degrees */ +typedef int32 centisec; /* centiseconds used for angles and times */ +#define CS (centisec) /* use for casting */ +#define CSEC centisec /* use for typing */ + +#define DEG 360000 /* degree expressed in centiseconds */ +#define DEG7_30 (2700000) /* 7.5 degrees */ #define DEG15 (15 * DEG) #define DEG24 (24 * DEG) #define DEG30 (30 * DEG) @@ -274,48 +275,49 @@ typedef int32 centisec; /* centiseconds used for angles and times */ #define DEG180 (180 * DEG) #define DEG270 (270 * DEG) #define DEG360 (360 * DEG) - -#define CSTORAD 4.84813681109536E-08 /* centisec to rad: pi / 180 /3600/100 */ -#define RADTOCS 2.06264806247096E+07 /* rad to centisec 180*3600*100/pi */ - -#define CS2DEG (1.0/360000.0) /* centisec to degree */ + +#define CSTORAD 4.84813681109536E-08 /* centisec to rad: pi / 180 /3600/100 */ +#define RADTOCS 2.06264806247096E+07 /* rad to centisec 180*3600*100/pi */ + +#define CS2DEG (1.0/360000.0) /* centisec to degree */ /* control strings for fopen() */ #if UNIX_FS -# define BFILE_R_ACCESS "r" /* open binary file for reading */ -# define BFILE_RW_ACCESS "r+" /* open binary file for writing and reading */ -# define BFILE_W_CREATE "w" /* create/open binary file for write*/ -# define BFILE_A_ACCESS "a+" /* create/open binary file for append*/ -# define FILE_R_ACCESS "r" /* open text file for reading */ -# define FILE_RW_ACCESS "r+" /* open text file for writing and reading */ -# define FILE_W_CREATE "w" /* create/open text file for write*/ -# define FILE_A_ACCESS "a+" /* create/open text file for append*/ -# define O_BINARY 0 /* for open(), not defined in Unix */ -# define OPEN_MODE 0666 /* default file creation mode */ -# define DIR_GLUE "/" /* glue string for directory/file */ -# define PATH_SEPARATOR ";:" /* semicolon or colon may be used */ +#define BFILE_R_ACCESS "r" /* open binary file for reading */ +#define BFILE_RW_ACCESS "r+" /* open binary file for writing and reading */ +#define BFILE_W_CREATE "w" /* create/open binary file for write */ +#define BFILE_A_ACCESS "a+" /* create/open binary file for append */ +#define FILE_R_ACCESS "r" /* open text file for reading */ +#define FILE_RW_ACCESS "r+" /* open text file for writing and reading */ +#define FILE_W_CREATE "w" /* create/open text file for write */ +#define FILE_A_ACCESS "a+" /* create/open text file for append */ +#define O_BINARY 0 /* for open(), not defined in Unix */ +#define OPEN_MODE 0666 /* default file creation mode */ +#define DIR_GLUE "/" /* glue string for directory/file */ +#define PATH_SEPARATOR ";:" /* semicolon or colon may be used */ #else -# define BFILE_R_ACCESS "rb" /* open binary file for reading */ -# define BFILE_RW_ACCESS "r+b" /* open binary file for writing and reading */ -# define BFILE_W_CREATE "wb" /* create/open binary file for write*/ -# define BFILE_A_ACCESS "a+b" /* create/open binary file for append*/ -# define PATH_SEPARATOR ";" /* semicolon as PATH separator */ -# define OPEN_MODE 0666 /* default file creation mode */ -# ifdef MACOS -# define FILE_R_ACCESS "r" /* open text file for reading */ -# define FILE_RW_ACCESS "r+" /* open text file for writing and reading */ -# define FILE_W_CREATE "w" /* create/open text file for write*/ -# define FILE_A_ACCESS "a+" /* create/open text file for append*/ -# define DIR_GLUE ":" /* glue string for directory/file */ -# else -# define FILE_R_ACCESS "rt" /* open text file for reading */ -# define FILE_RW_ACCESS "r+t" /* open text file for writing and reading */ -# define FILE_W_CREATE "wt" /* create/open text file for write*/ -# define FILE_A_ACCESS "a+t" /* create/open text file for append*/ +#define BFILE_R_ACCESS "rb" /* open binary file for reading */ +#define BFILE_RW_ACCESS "r+b" /* open binary file for writing and reading */ +#define BFILE_W_CREATE "wb" /* create/open binary file for write */ +#define BFILE_A_ACCESS "a+b" /* create/open binary file for append */ +#define PATH_SEPARATOR ";" /* semicolon as PATH separator */ +#define OPEN_MODE 0666 /* default file creation mode */ +#ifdef MACOS +#define FILE_R_ACCESS "r" /* open text file for reading */ +#define FILE_RW_ACCESS "r+" /* open text file for writing and reading */ +#define FILE_W_CREATE "w" /* create/open text file for write */ +#define FILE_A_ACCESS "a+" /* create/open text file for append */ +#define DIR_GLUE ":" /* glue string for directory/file */ +#else +#define FILE_R_ACCESS "rt" /* open text file for reading */ +#define FILE_RW_ACCESS "r+t" /* open text file for writing and reading */ +#define FILE_W_CREATE "wt" /* create/open text file for write */ +#define FILE_A_ACCESS "a+t" /* create/open text file for append */ + /* attention, all backslashes for msdos directry names must be written as \\, because it is the C escape character */ -# define DIR_GLUE "\\" /* glue string for directory/file */ -# endif +#define DIR_GLUE "\\" /* glue string for directory/file */ +#endif #endif #include diff --git a/swe/src/swepcalc.c b/swe/src/swepcalc.c index 7011312..1ec551c 100644 --- a/swe/src/swepcalc.c +++ b/swe/src/swepcalc.c @@ -1,8 +1,10 @@ + /***************************************************** $Header: /home/dieter/sweph/RCS/swepcalc.c,v 1.74 2008/06/16 10:07:20 dieter Exp $ Placalc compatibility interface for Swiss Ephemeris. *******************************************************/ + /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -80,7 +82,12 @@ Placalc compatibility interface for Swiss Ephemeris. local globals, not exported ************************************************************/ -static int plac2swe[] = {SE_SUN, SE_MOON, SE_MERCURY, SE_VENUS, SE_MARS, SE_JUPITER, SE_SATURN, SE_URANUS, SE_NEPTUNE, SE_PLUTO, SE_MEAN_NODE, SE_TRUE_NODE, SE_CHIRON, SE_MEAN_APOG, SE_CERES, SE_PALLAS, SE_JUNO, SE_VESTA,}; +static int plac2swe[] = + { SE_SUN, SE_MOON, SE_MERCURY, SE_VENUS, SE_MARS, SE_JUPITER, SE_SATURN, + SE_URANUS, SE_NEPTUNE, SE_PLUTO, SE_MEAN_NODE, SE_TRUE_NODE, SE_CHIRON, + SE_MEAN_APOG, + SE_CERES, SE_PALLAS, SE_JUNO, SE_VESTA, +}; /* If there occurs an internal error in placalc, a message is * written into the string variable perrtx. @@ -94,20 +101,21 @@ static double ekl, nut; * required for relative distances rgeo, where the distance is given * as 100 when a planet is closest and as 0 when farthest from earth. */ -static double rmima[CALC_N][2] = { - { 0.98296342, 1.01704665}, - { 0.00238267, 0.00271861}, - { 0.54900496, 1.45169607}, - { 0.26411287, 1.73597885}, - { 0.37289847, 2.67626927}, - { 3.94877993, 6.45627627}, - { 7.99362824, 11.09276636}, - {17.28622633, 21.10714104}, - {28.81374786, 31.33507284}, - {28.67716748, 50.29208774}, - { 0.00, 0.00259553}, /* nodes don't get a real value*/ - { 0.00, 0.00259553}, - { 7.36277475, 19.86585062}}; +static double rmima[CALC_N][2] = { + {0.98296342, 1.01704665}, + {0.00238267, 0.00271861}, + {0.54900496, 1.45169607}, + {0.26411287, 1.73597885}, + {0.37289847, 2.67626927}, + {3.94877993, 6.45627627}, + {7.99362824, 11.09276636}, + {17.28622633, 21.10714104}, + {28.81374786, 31.33507284}, + {28.67716748, 50.29208774}, + {0.00, 0.00259553}, /* nodes don't get a real value */ + {0.00, 0.00259553}, + {7.36277475, 19.86585062} +}; /********************************************************** function nacalc () @@ -124,34 +132,38 @@ coordinate format for fast mathematics with planetary positions. This function is just a template of how the calc() package can be used. **********************************************************/ -int nacalc (double jd_ad, /* universal time relative julian date */ - centisec *plon, /* returned longitudes */ - centisec *pspe /* returned speeds, if not NULL pointer */ - ) +int +nacalc(double jd_ad, /* universal time relative julian date */ + centisec * plon, /* returned longitudes */ + centisec * pspe /* returned speeds, if not NULL pointer */ + ) { - char err[AS_MAXCH]; - int planet, flag; - double rlng, rrad, rlat, rspeed; - int result = OK; - flag = CALC_BIT_SPEED; /* same, with speed */ - jd_ad += deltat( jd_ad ); /* ET = UT + Delta_T */ - for (planet = SUN; planet <= MAXPL_NACALC; planet++) { - if (calc (planet, jd_ad, flag, &rlng, &rrad, &rlat, &rspeed) == OK) { - plon [planet] = swe_csnorm(swe_d2l (rlng * DEG)); - if (pspe != NULL) pspe [planet] = swe_d2l (rspeed * DEG); - } else { - plon [planet] = -1; - if (pspe != NULL) pspe [planet] = 0; - if (result != ERR) { /* save first error message */ - strcpy(err, placalc_get_errtext()); - } - result = ERR; + char err[AS_MAXCH]; + int planet, flag; + double rlng, rrad, rlat, rspeed; + int result = OK; + flag = CALC_BIT_SPEED; /* same, with speed */ + jd_ad += deltat(jd_ad); /* ET = UT + Delta_T */ + for (planet = SUN; planet <= MAXPL_NACALC; planet++) { + if (calc(planet, jd_ad, flag, &rlng, &rrad, &rlat, &rspeed) == OK) { + plon[planet] = swe_csnorm(swe_d2l(rlng * DEG)); + if (pspe != NULL) + pspe[planet] = swe_d2l(rspeed * DEG); + } + else { + plon[planet] = -1; + if (pspe != NULL) + pspe[planet] = 0; + if (result != ERR) { /* save first error message */ + strcpy(err, placalc_get_errtext()); + } + result = ERR; + } } - } - if (result == ERR) - strcpy(perrtx, err); - return result; -} /* end nacalc */ + if (result == ERR) + strcpy(perrtx, err); + return result; +} /* end nacalc */ /****************************************************************** * calculation server @@ -159,90 +171,99 @@ int nacalc (double jd_ad, /* universal time relative julian date */ * over a communication line to the calculation client. * if plalist = 0, only SUN .. CHIRON are delivered, no LILITH ******************************************************************/ -int calcserv(int id, /* request id, random number to prevent phase err */ - double jd_ad, /* time as relative Astrodienst julian date */ - int flag, /* a set of CALC_BIT_ bitflags */ - int plalist,/* bit list of planets to be computed, 0 = all */ - char *so) /* output string, MUST BE LONG ENOUGH (800 bytes)*/ -{ - int p, planet, so_len; - double rlng, rrad, rlat, rspeed, rau[CALC_N]; - centisec lcs[CALC_N], lpcs[CALC_N], betcs[CALC_N]; - char s[AS_MAXCH]; - if (plalist == 0) plalist = (1 << 13) - 1; /* sun .. chiron */; - /* - * flag determines whether deltat is added to t; - * if CALC_BIT_EPHE is set, jd_ad is considered as ephemeris time, - * otherwise as universal time. - */ - if ((flag & CALC_BIT_EPHE) == 0) { - jd_ad += deltat (jd_ad); - } - for (p = SUN; p < CALC_N; p++) { - if (! check_bit(plalist, p)) continue; - if (calc (p, jd_ad, flag, &rlng, &rrad, &rlat, &rspeed) == OK) { - lcs [p] = swe_d2l (rlng * DEG); - lpcs [p] = swe_d2l (rspeed * DEG); - betcs [p] = swe_d2l (rlat * DEG); - rau [p] = rrad; - } else { - sprintf(so,"error at planet %d", p); - return ( ERR); +int +calcserv(int id, /* request id, random number to prevent phase err */ + double jd_ad, /* time as relative Astrodienst julian date */ + int flag, /* a set of CALC_BIT_ bitflags */ + int plalist, /* bit list of planets to be computed, 0 = all */ + char *so) +{ /* output string, MUST BE LONG ENOUGH (800 bytes) */ + int p, planet, so_len; + double rlng, rrad, rlat, rspeed, rau[CALC_N]; + centisec lcs[CALC_N], lpcs[CALC_N], betcs[CALC_N]; + char s[AS_MAXCH]; + if (plalist == 0) + plalist = (1 << 13) - 1; /* sun .. chiron */ ; + /* + * flag determines whether deltat is added to t; + * if CALC_BIT_EPHE is set, jd_ad is considered as ephemeris time, + * otherwise as universal time. + */ + if ((flag & CALC_BIT_EPHE) == 0) { + jd_ad += deltat(jd_ad); } - } - /* - * format comma separated list: id,teph,flag,plalist,ekl,nut - * double is given with 8 digits precision after decimal point, - * all angles are given in centiseconds. - * then for each requested planet: longitude (csec) - * then for each requested planet, if wanted: speed (csec/day) - * then for each requested planet, if wanted: latitude (csec) - * then for each requested planet, if wanted: rgeo (units 0..999) - * then for each requested planet, if wanted: rau (A.U.) - */ - sprintf (so, "%d,%.8f,%d,%d,%d,%d", id, jd_ad, flag, plalist, - swe_d2l(ekl * DEG), swe_d2l (nut * DEG) ); - so_len = strlen (so); - for (planet = SUN; planet < CALC_N; planet++) { - if (! check_bit(plalist, planet)) continue; - sprintf (s ,",%d", lcs[planet]); - strcat (so + so_len, s); - so_len += strlen (s); - } - if (flag & CALC_BIT_SPEED) { - for (planet = SUN; planet < CALC_N; planet++) { - if (! check_bit(plalist, planet)) continue; - sprintf (s ,",%d", lpcs[planet]); - strcat (so + so_len, s); - so_len += strlen (s); + for (p = SUN; p < CALC_N; p++) { + if (!check_bit(plalist, p)) + continue; + if (calc(p, jd_ad, flag, &rlng, &rrad, &rlat, &rspeed) == OK) { + lcs[p] = swe_d2l(rlng * DEG); + lpcs[p] = swe_d2l(rspeed * DEG); + betcs[p] = swe_d2l(rlat * DEG); + rau[p] = rrad; + } + else { + sprintf(so, "error at planet %d", p); + return (ERR); + } } - } - if (flag & CALC_BIT_BETA) { - for (planet = SUN; planet < CALC_N; planet++) { - if (! check_bit(plalist, planet)) continue; - sprintf (s ,",%d", betcs[planet]); - strcat (so + so_len, s); - so_len += strlen (s); + /* + * format comma separated list: id,teph,flag,plalist,ekl,nut + * double is given with 8 digits precision after decimal point, + * all angles are given in centiseconds. + * then for each requested planet: longitude (csec) + * then for each requested planet, if wanted: speed (csec/day) + * then for each requested planet, if wanted: latitude (csec) + * then for each requested planet, if wanted: rgeo (units 0..999) + * then for each requested planet, if wanted: rau (A.U.) + */ + sprintf(so, "%d,%.8f,%d,%d,%d,%d", id, jd_ad, flag, plalist, + swe_d2l(ekl * DEG), swe_d2l(nut * DEG)); + so_len = strlen(so); + for (planet = SUN; planet < CALC_N; planet++) { + if (!check_bit(plalist, planet)) + continue; + sprintf(s, ",%d", lcs[planet]); + strcat(so + so_len, s); + so_len += strlen(s); } - } - if (flag & CALC_BIT_RGEO) { - for (planet = SUN; planet < CALC_N; planet++) { - if (! check_bit(plalist, planet)) continue; - sprintf (s ,",%d", rel_geo(planet,rau[planet])); - strcat (so + so_len, s); - so_len += strlen (s); + if (flag & CALC_BIT_SPEED) { + for (planet = SUN; planet < CALC_N; planet++) { + if (!check_bit(plalist, planet)) + continue; + sprintf(s, ",%d", lpcs[planet]); + strcat(so + so_len, s); + so_len += strlen(s); + } } - } - if (flag & CALC_BIT_RAU) { - for (planet = SUN; planet < CALC_N; planet++) { - if (! check_bit(plalist, planet)) continue; - sprintf (s ,",%.8f", rau[planet]); - strcat (so + so_len, s); - so_len += strlen (s); + if (flag & CALC_BIT_BETA) { + for (planet = SUN; planet < CALC_N; planet++) { + if (!check_bit(plalist, planet)) + continue; + sprintf(s, ",%d", betcs[planet]); + strcat(so + so_len, s); + so_len += strlen(s); + } } - } - return (OK); -} /* end calcserv */ + if (flag & CALC_BIT_RGEO) { + for (planet = SUN; planet < CALC_N; planet++) { + if (!check_bit(plalist, planet)) + continue; + sprintf(s, ",%d", rel_geo(planet, rau[planet])); + strcat(so + so_len, s); + so_len += strlen(s); + } + } + if (flag & CALC_BIT_RAU) { + for (planet = SUN; planet < CALC_N; planet++) { + if (!check_bit(plalist, planet)) + continue; + sprintf(s, ",%.8f", rau[planet]); + strcat(so + so_len, s); + so_len += strlen(s); + } + } + return (OK); +} /* end calcserv */ /****************************************************************** function calc(): @@ -276,247 +297,361 @@ int calcserv(int id, /* request id, random number to prevent phase err */ will return the values for time teph. ******************************************************************/ -int calc(int planet, /* planet index as defined in placalc.h, - SUN = 0, MOON = 1 etc. - planet == -1 calc calculates only nut, ekl, meanekl */ - double jd_ad, /* relative Astrodienst Juldate, ephemeris time. - Astrodienst Juldate is relative 31 Dec 1949, noon. */ - int flag, /* See definition of flag bits above */ - double *alng, - double *arad, - double *alat, - double *alngspeed) +int +calc(int planet, /* planet index as defined in placalc.h, + * SUN = 0, MOON = 1 etc. + * planet == -1 calc calculates only nut, ekl, meanekl */ + double jd_ad, /* relative Astrodienst Juldate, ephemeris time. + * Astrodienst Juldate is relative 31 Dec 1949, noon. */ + int flag, /* See definition of flag bits above */ + double *alng, double *arad, double *alat, double *alngspeed) /* pointers to the return variables: - alng = ecliptic longitude in degrees - arad = radius vector in AU (astronomic units) - alat = ecliptic latitude in degrees - alngspeed = speed of planet in degrees per day + * alng = ecliptic longitude in degrees + * arad = radius vector in AU (astronomic units) + * alat = ecliptic latitude in degrees + * alngspeed = speed of planet in degrees per day */ { - double tjd = jd_ad + JUL_OFFSET; - double x[6]; - int32 iflagret = 0, iflag = 0; - int ipl; - /* planet number - */ - /* ecliptic and nutation */ - if (planet == CALC_ONLY_ECL_NUT) - ipl = SE_ECL_NUT; - /* earth: placalc makes no difference between sun and earth, - * swisseph does */ - else if (planet == SUN && (flag & CALC_BIT_HELIO)) - ipl = SE_EARTH; - else if (planet >= SUN && planet <= VESTA) - ipl = plac2swe[planet]; - else { - sprintf(perrtx, "invalid planet number %d. ", planet); - return ERR; - } - /* flag */ - if (flag & CALC_BIT_HELIO) - if (ipl != SE_MEAN_NODE && ipl != SE_TRUE_NODE && ipl != SE_MEAN_APOG) - iflag |= SEFLG_HELCTR; /* lunar node and apogee is always geocentric */ - if (flag & CALC_BIT_NOAPP) - iflag |= SEFLG_TRUEPOS; - if (flag & CALC_BIT_NONUT) - iflag |= SEFLG_NONUT; - if (flag & CALC_BIT_SPEED) - iflag |= SEFLG_SPEED; - /* ecliptic and nutation */ - if ((iflagret = swe_calc(tjd, ipl, iflag, x, perrtx)) == ERR) - return iflagret; - if (ipl == SE_ECL_NUT) { - *alng = nut = x[2]; - *arad = x[1]; - *alat = ekl = x[0]; - } else { - *alng = x[0]; - *arad = x[2]; - *alat = x[1]; - *alngspeed = x[3]; - } - return (OK); -} /* end calc */ + double tjd = jd_ad + JUL_OFFSET; + double x[6]; + int32 iflagret = 0, iflag = 0; + int ipl; + /* planet number + */ + /* ecliptic and nutation */ + if (planet == CALC_ONLY_ECL_NUT) + ipl = SE_ECL_NUT; + /* earth: placalc makes no difference between sun and earth, + * swisseph does */ + else if (planet == SUN && (flag & CALC_BIT_HELIO)) + ipl = SE_EARTH; + else if (planet >= SUN && planet <= VESTA) + ipl = plac2swe[planet]; + else { + sprintf(perrtx, "invalid planet number %d. ", planet); + return ERR; + } + /* flag */ + if (flag & CALC_BIT_HELIO) + if (ipl != SE_MEAN_NODE && ipl != SE_TRUE_NODE && ipl != SE_MEAN_APOG) + iflag |= SEFLG_HELCTR; /* lunar node and apogee is always geocentric */ + if (flag & CALC_BIT_NOAPP) + iflag |= SEFLG_TRUEPOS; + if (flag & CALC_BIT_NONUT) + iflag |= SEFLG_NONUT; + if (flag & CALC_BIT_SPEED) + iflag |= SEFLG_SPEED; + /* ecliptic and nutation */ + if ((iflagret = swe_calc(tjd, ipl, iflag, x, perrtx)) == ERR) + return iflagret; + if (ipl == SE_ECL_NUT) { + *alng = nut = x[2]; + *arad = x[1]; + *alat = ekl = x[0]; + } + else { + *alng = x[0]; + *arad = x[2]; + *alat = x[1]; + *alngspeed = x[3]; + } + return (OK); +} /* end calc */ -int rel_geo(int planet, double rau) +int +rel_geo(int planet, double rau) { - /* - * get relative earth distance in range 0..1000: - * To compute the relative distance we use fixed values of - * mimimum and maximum distance measured empirically between - * 1300 AD and 2300 AD (see helconst.c). - * This approach is certainly fine for the - * outer planets, but not the best for Sun and Moon, where it - * would be better to look at the mean anomaly, i.e. the progress - * the planet makes on it's Kepler orbit. - * Considering the low importance astrologers give to the relative - * distance, we consider the effort not worthwile. - * Now we compare real radius with longtime-averaged distances. - */ - int rgeo; - if (planet == MEAN_NODE || planet == TRUE_NODE || planet == LILITH) { - return 0; - } else { - rgeo = 1000 * (1.0 - (rau - rmima[planet][0]) / (rmima[planet][1] - rmima[planet][0])); - } - if (rgeo < 0) - rgeo = 0; - else if (rgeo > 999) - rgeo = 999; - return rgeo; + /* + * get relative earth distance in range 0..1000: + * To compute the relative distance we use fixed values of + * mimimum and maximum distance measured empirically between + * 1300 AD and 2300 AD (see helconst.c). + * This approach is certainly fine for the + * outer planets, but not the best for Sun and Moon, where it + * would be better to look at the mean anomaly, i.e. the progress + * the planet makes on it's Kepler orbit. + * Considering the low importance astrologers give to the relative + * distance, we consider the effort not worthwile. + * Now we compare real radius with longtime-averaged distances. + */ + int rgeo; + if (planet == MEAN_NODE || planet == TRUE_NODE || planet == LILITH) { + return 0; + } + else { + rgeo = + 1000 * (1.0 - + (rau - rmima[planet][0]) / (rmima[planet][1] - + rmima[planet][0])); + } + if (rgeo < 0) + rgeo = 0; + else if (rgeo > 999) + rgeo = 999; + return rgeo; } /* * get the planet index for an AFL letter * returns -1 if the letter does not correspond to a planet. */ -int afl2planet(int afl) +int +afl2planet(int afl) { - int p; - switch (afl) { - case AFL_SUN : p = SUN; break; - case AFL_MON : p = MOON; break; - case AFL_MER : p = MERCURY; break; - case AFL_VEN : p = VENUS; break; - case AFL_MAR : p = MARS; break; - case AFL_JUP : p = JUPITER; break; - case AFL_SAT : p = SATURN; break; - case AFL_URA : p = URANUS; break; - case AFL_NEP : p = NEPTUNE; break; - case AFL_PLU : p = PLUTO; break; - case AFL_MNODE : p = MEAN_NODE; break; - case AFL_TNODE : p = TRUE_NODE; break; - case AFL_CHI : p = CHIRON; break; - case AFL_LIL : p = LILITH; break; - case AFL_CER : p = CERES; break; - case AFL_PAL : p = PALLAS; break; - case AFL_JUN : p = JUNO; break; - case AFL_VES : p = VESTA; break; - case AFL_AC : p = AC; break; - case AFL_MC : p = MC; break; - default : p = -1; break; - } - return p; + int p; + switch (afl) { + case AFL_SUN: + p = SUN; + break; + case AFL_MON: + p = MOON; + break; + case AFL_MER: + p = MERCURY; + break; + case AFL_VEN: + p = VENUS; + break; + case AFL_MAR: + p = MARS; + break; + case AFL_JUP: + p = JUPITER; + break; + case AFL_SAT: + p = SATURN; + break; + case AFL_URA: + p = URANUS; + break; + case AFL_NEP: + p = NEPTUNE; + break; + case AFL_PLU: + p = PLUTO; + break; + case AFL_MNODE: + p = MEAN_NODE; + break; + case AFL_TNODE: + p = TRUE_NODE; + break; + case AFL_CHI: + p = CHIRON; + break; + case AFL_LIL: + p = LILITH; + break; + case AFL_CER: + p = CERES; + break; + case AFL_PAL: + p = PALLAS; + break; + case AFL_JUN: + p = JUNO; + break; + case AFL_VES: + p = VESTA; + break; + case AFL_AC: + p = AC; + break; + case AFL_MC: + p = MC; + break; + default: + p = -1; + break; + } + return p; } /* * get the AFL letter for a planet * returns -1 if no letter corresponds to a planet. */ -int planet2afl(int planet) +int +planet2afl(int planet) { - switch (planet) { - case SUN: return AFL_SUN; - case MOON: return AFL_MON; - case MERCURY: return AFL_MER; - case VENUS: return AFL_VEN; - case MARS: return AFL_MAR; - case JUPITER: return AFL_JUP; - case SATURN: return AFL_SAT; - case URANUS: return AFL_URA; - case NEPTUNE: return AFL_NEP; - case PLUTO: return AFL_PLU; - case MEAN_NODE: return AFL_MNODE; - case TRUE_NODE: return AFL_TNODE; - case CHIRON: return AFL_CHI; - case LILITH: return AFL_LIL; - case CERES: return AFL_CER; - case PALLAS: return AFL_PAL; - case JUNO: return AFL_JUN; - case VESTA: return AFL_VES; - case AC: return AFL_AC; - case MC: return AFL_MC; - } - if (planet >= FIRST_HSNR && planet <= LAST_HSNR) - return AFL_HOUSE; - else - return -1; + switch (planet) { + case SUN: + return AFL_SUN; + case MOON: + return AFL_MON; + case MERCURY: + return AFL_MER; + case VENUS: + return AFL_VEN; + case MARS: + return AFL_MAR; + case JUPITER: + return AFL_JUP; + case SATURN: + return AFL_SAT; + case URANUS: + return AFL_URA; + case NEPTUNE: + return AFL_NEP; + case PLUTO: + return AFL_PLU; + case MEAN_NODE: + return AFL_MNODE; + case TRUE_NODE: + return AFL_TNODE; + case CHIRON: + return AFL_CHI; + case LILITH: + return AFL_LIL; + case CERES: + return AFL_CER; + case PALLAS: + return AFL_PAL; + case JUNO: + return AFL_JUN; + case VESTA: + return AFL_VES; + case AC: + return AFL_AC; + case MC: + return AFL_MC; + } + if (planet >= FIRST_HSNR && planet <= LAST_HSNR) + return AFL_HOUSE; + else + return -1; } /* * get the 2-letter abbreviation for a planet * returns ?? if not defined */ -char *planet2abbr2(int planet) +char * +planet2abbr2(int planet) { - switch (planet) { - case SUN: return "su"; - case MOON: return "mo"; - case MERCURY: return "me"; - case VENUS: return "ve"; - case MARS: return "ma"; - case JUPITER: return "ju"; - case SATURN: return "sa"; - case URANUS: return "ur"; - case NEPTUNE: return "ne"; - case PLUTO: return "pl"; - case MEAN_NODE: return "mn"; - case TRUE_NODE: return "tn"; - case CHIRON: return "ch"; - case LILITH: return "li"; - case CERES: return "ce"; - case PALLAS: return "pa"; - case JUNO: return "jn"; - case VESTA: return "vs"; - case AC: return "ac"; - case MC: return "mc"; - } - return "??"; + switch (planet) { + case SUN: + return "su"; + case MOON: + return "mo"; + case MERCURY: + return "me"; + case VENUS: + return "ve"; + case MARS: + return "ma"; + case JUPITER: + return "ju"; + case SATURN: + return "sa"; + case URANUS: + return "ur"; + case NEPTUNE: + return "ne"; + case PLUTO: + return "pl"; + case MEAN_NODE: + return "mn"; + case TRUE_NODE: + return "tn"; + case CHIRON: + return "ch"; + case LILITH: + return "li"; + case CERES: + return "ce"; + case PALLAS: + return "pa"; + case JUNO: + return "jn"; + case VESTA: + return "vs"; + case AC: + return "ac"; + case MC: + return "mc"; + } + return "??"; } /* * get the 3-letter abbreviation for a planet * returns ??? if not defined */ -char *planet2abbr3(int planet) +char * +planet2abbr3(int planet) { - switch (planet) { - case SUN: return "sun"; - case MOON: return "mon"; - case MERCURY: return "mer"; - case VENUS: return "ven"; - case MARS: return "mar"; - case JUPITER: return "jup"; - case SATURN: return "sat"; - case URANUS: return "ura"; - case NEPTUNE: return "nep"; - case PLUTO: return "plu"; - case MEAN_NODE: return "mno"; - case TRUE_NODE: return "tno"; - case CHIRON: return "chi"; - case LILITH: return "lil"; - case CERES: return "cer"; - case PALLAS: return "pal"; - case JUNO: return "jun"; - case VESTA: return "ves"; - case AC: return "asc"; - case MC: return "mc "; - } - return "???"; + switch (planet) { + case SUN: + return "sun"; + case MOON: + return "mon"; + case MERCURY: + return "mer"; + case VENUS: + return "ven"; + case MARS: + return "mar"; + case JUPITER: + return "jup"; + case SATURN: + return "sat"; + case URANUS: + return "ura"; + case NEPTUNE: + return "nep"; + case PLUTO: + return "plu"; + case MEAN_NODE: + return "mno"; + case TRUE_NODE: + return "tno"; + case CHIRON: + return "chi"; + case LILITH: + return "lil"; + case CERES: + return "cer"; + case PALLAS: + return "pal"; + case JUNO: + return "jun"; + case VESTA: + return "ves"; + case AC: + return "asc"; + case MC: + return "mc "; + } + return "???"; } -char *placalc_set_ephepath(char *path) +char * +placalc_set_ephepath(char *path) { - static char *epath; - if (path == NULL) return epath; - if (epath != NULL) - free((void *) epath); - epath = malloc(strlen(path) + 1); - if (epath != NULL) { - strcpy(epath, path); - swe_set_ephe_path(epath); - } - return epath; + static char *epath; + if (path == NULL) + return epath; + if (epath != NULL) + free((void *)epath); + epath = malloc(strlen(path) + 1); + if (epath != NULL) { + strcpy(epath, path); + swe_set_ephe_path(epath); + } + return epath; } -void placalc_close_files() +void +placalc_close_files() { - swe_close(); + swe_close(); } -char *placalc_get_errtext() +char * +placalc_get_errtext() { - return perrtx; + return perrtx; } /***************************************************** @@ -524,9 +659,10 @@ deltat(t): returns delta t (in julian days) from universal time t is included by users ET = UT + deltat ******************************************************/ -double deltat (double jd_ad) /* Astrodienst relative julian date */ -{ - return swe_deltat(jd_ad + JUL_OFFSET); +double +deltat(double jd_ad) +{ /* Astrodienst relative julian date */ + return swe_deltat(jd_ad + JUL_OFFSET); } /********************************************************** @@ -541,33 +677,37 @@ double deltat (double jd_ad) /* Astrodienst relative julian date */ * lon, lat pointer for returning the ecliptic coordinates * (mean ecliptic and equinox of date) **********************************************************/ -int fixstar(char *star, double jd, double *lon, double *lat) +int +fixstar(char *star, double jd, double *lon, double *lat) { - double x[6]; - int i; - int32 retflag; - /* if call by number, fixstar() is 0-based, - * whereas swe_fixstar starts with 1 */ - if (isdigit((int) *star)) { - i = atoi(star); - sprintf(star, "%d", i+1); - } - retflag = swe_fixstar(star, jd, 0, x, perrtx); - *lon = x[0]; - *lat = x[1]; - return((int) retflag); + double x[6]; + int i; + int32 retflag; + /* if call by number, fixstar() is 0-based, + * whereas swe_fixstar starts with 1 */ + if (isdigit((int)*star)) { + i = atoi(star); + sprintf(star, "%d", i + 1); + } + retflag = swe_fixstar(star, jd, 0, x, perrtx); + *lon = x[0]; + *lat = x[1]; + return ((int)retflag); } /******************************************************************/ -double diff8360 (double a, double b) - /* a - b on a 360 degree circle, result -180..180*/ +double +diff8360(double a, double b) + /* a - b on a 360 degree circle, result -180..180 */ { - double d; - d = a - b; - if ( d >= 180.0 ) return( d - 360.0 ); - if ( d < -180.0 ) return( d + 360.0 ); - return( d ); -} /* diff8360 */ + double d; + d = a - b; + if (d >= 180.0) + return (d - 360.0); + if (d < -180.0) + return (d + 360.0); + return (d); +} /* diff8360 */ /* * originally in swephous.c @@ -576,28 +716,33 @@ double diff8360 (double a, double b) /************************************* return in which house pp is; houses are numbered from 1 .. 12 -*************************************/ -int HouseNr(struct houses *hsp, CSEC pp) +*************************************/ +int +HouseNr(struct houses *hsp, CSEC pp) { - CSEC cx; - int i = 2; - cx = swe_difcsn(pp, hsp->cusp [1]); /* distance from cusp 1 */ - while (i < 13 && cx >= difcsn(hsp->cusp [i], hsp->cusp [1])) i++; - return (i - 1); -} + CSEC cx; + int i = 2; + cx = swe_difcsn(pp, hsp->cusp[1]); /* distance from cusp 1 */ + while (i < 13 && cx >= difcsn(hsp->cusp[i], hsp->cusp[1])) + i++; + return (i - 1); +} /************************************ returns the inp-house number, where pp is in houses are numbered from 1 .. 12 ************************************/ -int InpHouseNr (struct houses *hsp, CSEC pp, CSEC *coff) -{ - CSEC cx; - int i = 2; - cx = swe_difcsn(pp, hsp->cusp [1] + coff [1]); - while(i<13 && cx >= swe_difcsn(hsp->cusp[i] + coff[i], hsp->cusp[1] + coff[1])) - i++; - return (i - 1); +int +InpHouseNr(struct houses *hsp, CSEC pp, CSEC * coff) +{ + CSEC cx; + int i = 2; + cx = swe_difcsn(pp, hsp->cusp[1] + coff[1]); + while (i < 13 + && cx >= swe_difcsn(hsp->cusp[i] + coff[i], + hsp->cusp[1] + coff[1])) + i++; + return (i - 1); } /* variation of InpHouseNr(). Able to handle house pre-orbs that are @@ -608,151 +753,181 @@ int InpHouseNr (struct houses *hsp, CSEC pp, CSEC *coff) * We first calculate the absolute offsets for each house of our birth chart, * then call the function InpHouseNr() with those values. */ -int InpHouseNr2 (struct houses *hsp, CSEC pp, CSEC *coff) +int +InpHouseNr2(struct houses *hsp, CSEC pp, CSEC * coff) { - int i, j; - CSEC myoff[13]; - for (i = 0; i < 13; i++) - myoff[i] = coff[i]; - if (myoff[0] == 1) { - for (i = 1; i < 13; i++) { - j = i + 1; - if (j > 12) j = 1; - myoff[j] = swe_degnorm((hsp->cusp[j] - hsp->cusp[i]) / 360000.0) / 30.0 * myoff[j]; + int i, j; + CSEC myoff[13]; + for (i = 0; i < 13; i++) + myoff[i] = coff[i]; + if (myoff[0] == 1) { + for (i = 1; i < 13; i++) { + j = i + 1; + if (j > 12) + j = 1; + myoff[j] = + swe_degnorm((hsp->cusp[j] - + hsp->cusp[i]) / 360000.0) / 30.0 * myoff[j]; + } } - } - return InpHouseNr(hsp, pp, myoff); + return InpHouseNr(hsp, pp, myoff); } /* ********************************************************* */ + /* Houses: */ + /* ********************************************************* */ + /* Koch and Placidus don't work in the polar circle. */ + /* We swap MC/IC so that MC is always before AC in the zodiac */ + /* We than divide the quadrants into 3 equal parts. */ + /* ********************************************************* */ + /* All angles are expressed in centiseconds (1/100th of a */ + /* second of arc) and integer arithmetic is used for these. */ + /* Special trigonometric functions dsin, dcos etc. are im- */ + /* plemented for arguments in centiseconds. */ + /* ********************************************************* */ + /* Arguments: th = sidereal time (angle 0..360 degrees */ + /* hsy = letter code for house system; implemen- */ + /* ted are P,K,C,R,E,V. */ + /* fi = geographic latitude */ + /* ekl = obliquity of the ecliptic */ + /* iteration_count = number of iterations in */ + /* Placidus calculation; can be 1 or 2. */ + /* ********************************************************* */ -void CalcHouses(CSEC th, CSEC fi, CSEC mekl, char hsy, int iteration_count, - struct houses *hsp ) +void +CalcHouses(CSEC th, CSEC fi, CSEC mekl, char hsy, int iteration_count, + struct houses *hsp) { - int retc = 0, i; - double cs2deg = 360000; - double cusps[13]; - double ascmc[10]; - /* iteration_count is always 2 */ - retc = swe_houses_armc(th / cs2deg, fi / cs2deg, mekl / cs2deg, (int) hsy, - cusps, ascmc); - for (i = 0; i < 13; i++) - hsp->cusp[i] = swe_d2l(cusps[i] * cs2deg); - hsp->ac = swe_d2l(ascmc[0] * cs2deg); - hsp->mc = swe_d2l(ascmc[1] * cs2deg); - /* - * this is just to shut up lint - */ - retc += iteration_count; - iteration_count = retc; -} /* procedure houses */ + int retc = 0, i; + double cs2deg = 360000; + double cusps[13]; + double ascmc[10]; + /* iteration_count is always 2 */ + retc = + swe_houses_armc(th / cs2deg, fi / cs2deg, mekl / cs2deg, (int)hsy, + cusps, ascmc); + for (i = 0; i < 13; i++) + hsp->cusp[i] = swe_d2l(cusps[i] * cs2deg); + hsp->ac = swe_d2l(ascmc[0] * cs2deg); + hsp->mc = swe_d2l(ascmc[1] * cs2deg); + /* + * this is just to shut up lint + */ + retc += iteration_count; + iteration_count = retc; +} /* procedure houses */ /******************************/ -void RecalcAspects(struct AspectType *a) +void +RecalcAspects(struct AspectType *a) { - centisec diff,orbis; - int p1, p2, i; - struct aspRec *arp; - if (a->ppos2 == NULL) { /* no set ppos2, no interaspects */ - for (p1 = 0; p1 < a->NrOfPlanets; p1++) { - a->Asp[p1][p1].index = 0; /* ignore p1 conjunct p1 */ - for (p2 = p1 + 1; p2 < a->NrOfPlanets; p2++) { - arp = &(a->Asp[p1][p2]); - diff = a->PlanetPos [p2] - a->PlanetPos [p1]; - if (diff >= DEG180) - diff -= DEG360; - else if (diff < - DEG180) - diff += DEG360; - i = 1; - arp->index = 0; - while (i <= a->NrOfAspects) { - orbis = ABS4 (diff) - a->Angle [i]; - if (ABS4 (orbis) <= a->Maxorb [i]) { - arp->index = i; - arp->orb = orbis; - break; /* out of while */ - } - i++; - } - a->Asp [p2][p1].index = arp->index; - a->Asp [p2][p1].orb = arp->orb; - } /* for p2 */ - } /* for p1 */ - } else { /* interaspects between set 1 and set 2 */ - for (p1 = 0; p1 < a->NrOfPlanets; p1++) { - for (p2 = 0; p2 < a->NrOfPlanets; p2++) { - arp = &(a->Asp[p1][p2]); - diff = a->ppos2 [p2] - a->PlanetPos [p1]; - if (diff >= DEG180) - diff -= DEG360; - else if (diff < - DEG180) - diff += DEG360; - i = 1; - arp->index = 0; - while (i <= a->NrOfAspects) { - orbis = ABS4 (diff) - a->Angle [i]; - if (ABS4 (orbis) <= a->Maxorb [i]) { - arp->index = i; - arp->orb = orbis; - break; /* out of while */ - } - i++; - } - } /* for p2 */ - } /* for p1 */ - } /* else */ - a->dataValid = TRUE; -} + centisec diff, orbis; + int p1, p2, i; + struct aspRec *arp; + if (a->ppos2 == NULL) { /* no set ppos2, no interaspects */ + for (p1 = 0; p1 < a->NrOfPlanets; p1++) { + a->Asp[p1][p1].index = 0; /* ignore p1 conjunct p1 */ + for (p2 = p1 + 1; p2 < a->NrOfPlanets; p2++) { + arp = &(a->Asp[p1][p2]); + diff = a->PlanetPos[p2] - a->PlanetPos[p1]; + if (diff >= DEG180) + diff -= DEG360; + else if (diff < -DEG180) + diff += DEG360; + i = 1; + arp->index = 0; + while (i <= a->NrOfAspects) { + orbis = ABS4(diff) - a->Angle[i]; + if (ABS4(orbis) <= a->Maxorb[i]) { + arp->index = i; + arp->orb = orbis; + break; /* out of while */ + } + i++; + } + a->Asp[p2][p1].index = arp->index; + a->Asp[p2][p1].orb = arp->orb; + } /* for p2 */ + } /* for p1 */ + } + else { /* interaspects between set 1 and set 2 */ + for (p1 = 0; p1 < a->NrOfPlanets; p1++) { + for (p2 = 0; p2 < a->NrOfPlanets; p2++) { + arp = &(a->Asp[p1][p2]); + diff = a->ppos2[p2] - a->PlanetPos[p1]; + if (diff >= DEG180) + diff -= DEG360; + else if (diff < -DEG180) + diff += DEG360; + i = 1; + arp->index = 0; + while (i <= a->NrOfAspects) { + orbis = ABS4(diff) - a->Angle[i]; + if (ABS4(orbis) <= a->Maxorb[i]) { + arp->index = i; + arp->orb = orbis; + break; /* out of while */ + } + i++; + } + } /* for p2 */ + } /* for p1 */ + } /* else */ + a->dataValid = TRUE; +} /*********************************************************** function sidtime (t): returns sidereal time at greenwich; Parameters differ from ASYS version! after AESuppl. 1961, page 75 version 24-oct-87 ***********************************************************/ -double sidtime (double jd_ad, double ecl, double nuta) - /* jd_ad relative julian date */ +double +sidtime(double jd_ad, double ecl, double nuta) + /* jd_ad relative julian date */ /* ecl, nuta ecliptic and nutation of date, in degrees */ { - return swe_sidtime0(jd_ad + JUL_OFFSET, ecl, nuta); + return swe_sidtime0(jd_ad + JUL_OFFSET, ecl, nuta); } -# ifdef INTEL_BYTE_ORDER +#ifdef INTEL_BYTE_ORDER + /********************************************************************/ -void longreorder (UCHAR *p, int n) - /* p points to memory filled with int32 values; for - each of the values the seqeuence of the four bytes - has to be reversed, to translate HP-UX and VAX - ordering to MSDOS/Turboc ordering */ +void +longreorder(UCHAR * p, int n) + /* p points to memory filled with int32 values; for + * each of the values the seqeuence of the four bytes + * has to be reversed, to translate HP-UX and VAX + * ordering to MSDOS/Turboc ordering */ { - int i; - unsigned char c0, c1, c2, c3; - for (i = 0; i < n; i += 4, p += 4) { - c0 = *p; - c1 = *(p + 1); - c2 = *(p + 2); - c3 = *(p + 3); - *p = c3; - *(p + 1) = c2; - *(p + 2) = c1; - *(p + 3) = c0; - } + int i; + unsigned char c0, c1, c2, c3; + for (i = 0; i < n; i += 4, p += 4) { + c0 = *p; + c1 = *(p + 1); + c2 = *(p + 2); + c3 = *(p + 3); + *p = c3; + *(p + 1) = c2; + *(p + 2) = c1; + *(p + 3) = c0; + } } -# endif +#endif diff --git a/swe/src/swepcalc.h b/swe/src/swepcalc.h index 2b0875c..b865fcf 100644 --- a/swe/src/swepcalc.h +++ b/swe/src/swepcalc.h @@ -1,3 +1,4 @@ + /************************************************************ $Header: /home/dieter/sweph/RCS/swepcalc.h,v 1.74 2008/06/16 10:07:20 dieter Exp $ Definitions and constants for Placalc interface to SwissEph @@ -84,15 +85,15 @@ * It is very simple to adapt your code to it. * If you want to adapt your source code, turn the next TRUE into FALSE */ -#if TRUE /* replace by if FALSE to deactivate macros */ -# define d2l(x) swe_d2l(x) -# define difcsn(x,y) swe_difcsn(x,y) -# define difcs2n(x,y) swe_difcs2n(x,y) -# define difdegn(x,y) swe_difdegn(x,y) -# define difdeg2n(x,y) swe_difdeg2n(x,y) -# define csnorm(x) swe_csnorm(x) -# define degnorm(x) swe_degnorm(x) -# define roundsec(x) swe_csroundsec(x) +#if TRUE /* replace by if FALSE to deactivate macros */ +#define d2l(x) swe_d2l(x) +#define difcsn(x,y) swe_difcsn(x,y) +#define difcs2n(x,y) swe_difcs2n(x,y) +#define difdegn(x,y) swe_difdegn(x,y) +#define difdeg2n(x,y) swe_difdeg2n(x,y) +#define csnorm(x) swe_csnorm(x) +#define degnorm(x) swe_degnorm(x) +#define roundsec(x) swe_csroundsec(x) #endif /************************************************************* @@ -102,28 +103,24 @@ Astrodienst relative julian days, and jd the use of absolute julian days. *************************************************************/ -extern int nacalc(double jd_ad, centisec *plon, centisec *pspe); +extern int nacalc(double jd_ad, centisec * plon, centisec * pspe); extern int calcserv(int id, double t, int flag, int plalist, char *so); extern void helup(double jd_ad); -extern void togeo(double le, double re, double l, double r, double z, double *alg, double *arg); -extern int calc(int p, - double jd_ad, - int flag, - double *alng, - double *arad, - double *alat, - double *alngspeed); +extern void togeo(double le, double re, double l, double r, double z, + double *alg, double *arg); +extern int calc(int p, double jd_ad, int flag, double *alng, double *arad, + double *alat, double *alngspeed); extern int rel_geo(int p, double rau); -extern int hel( int p, /* planet index as defined by placalc.h */ - double jd_ad, /* relative juliand date, ephemeris time */ - /* Now come 6 pointers to return values. */ - double *al, /* longitude in degrees */ - double *ar, /* radius in AU */ - double *az, /* distance from ecliptic in AU */ - double *alp, /* speed in longitude, degrees per day */ - double *arp, /* speed in radius, AU per day */ - double *azp); /* speed in z, AU per day */ -extern int moon(double *al, double *ar, double *az); +extern int hel(int p, /* planet index as defined by placalc.h */ + double jd_ad, /* relative juliand date, ephemeris time */ + /* Now come 6 pointers to return values. */ + double *al, /* longitude in degrees */ + double *ar, /* radius in AU */ + double *az, /* distance from ecliptic in AU */ + double *alp, /* speed in longitude, degrees per day */ + double *arp, /* speed in radius, AU per day */ + double *azp); /* speed in z, AU per day */ +extern int moon(double *al, double *ar, double *az); extern double fraction(double t); extern double sidtime(double jd_ad, double ecl, double nuta); extern double smod8360(double x); @@ -131,24 +128,25 @@ extern double mod8360(double x); extern double diff8360(double x, double y); extern double test_near_zero(double x); extern double deltat(double jd_ad); -extern void to_mean_ekl (double jd, double xyz[], double lrz[]); +extern void to_mean_ekl(double jd, double xyz[], double lrz[]); extern void placalc_close_files(); extern int fixstar(char *star, double jd, double *lon, double *lat); extern char *placalc_get_errtext(); -extern char *placalc_set_ephepath(char *new_path); /* sets ephepath; - if called with NULL, returns current path */ +extern char *placalc_set_ephepath(char *new_path); /* sets ephepath; + * if called with NULL, returns current path */ /* * because deltat() required a relative Julian date due to historical reasons, * we define a function deltatjd() with absolute Juliand date argument. */ -# define deltatjd(x) deltat((x) - JUL_OFFSET) +#define deltatjd(x) deltat((x) - JUL_OFFSET) /* * get the planet index for an AFL letter * returns -1 if the letter does not correspond to a planet. */ extern int afl2planet(int afl); + /* * get the AFL letter for a planet * returns -1 if planet has no letter. @@ -162,7 +160,7 @@ extern char *planet2abbr3(int planet); (these cannot be used by DLL clients) *************************************************************/ - + /************************************************************* definitions *************************************************************/ @@ -171,8 +169,8 @@ extern char *planet2abbr3(int planet); * planet index numbers, used to identify a planet in calc() and * other related functions. */ -#define CALC_ONLY_ECL_NUT -1 /* pseudo planet index for calls to calc */ -#define SUN 0 /* used synonymously for earth too */ +#define CALC_ONLY_ECL_NUT -1 /* pseudo planet index for calls to calc */ +#define SUN 0 /* used synonymously for earth too */ #define EARTH 0 #define MOON 1 #define MERCURY 2 @@ -187,16 +185,16 @@ extern char *planet2abbr3(int planet); #define MEAN_NODE 10 #define TRUE_NODE 11 #define CHIRON 12 -#define LILITH 13 -#define CALC_N 14 /* number of planets in placalc module */ +#define LILITH 13 +#define CALC_N 14 /* number of planets in placalc module */ #define CERES 14 #define PALLAS 15 #define JUNO 16 #define VESTA 17 -#define MAXPL_NACALC (LILITH) /* nacalc computes SUN..LILITH */ -# define PROG_PLANET_OFFSET 50 /* progressed sun */ +#define MAXPL_NACALC (LILITH) /* nacalc computes SUN..LILITH */ +#define PROG_PLANET_OFFSET 50 /* progressed sun */ /* * houses and axes get also a 'planet' index number, but they @@ -206,20 +204,21 @@ extern char *planet2abbr3(int planet); * Axes and houses cannot be computed with calls to calc(); they must * be computed with the housasp module functions. */ -# define AC 19 -# define ASC 19 -# define MC 20 -# define CALC_N_MC 21 /* number of normal natal factors */ +#define AC 19 +#define ASC 19 +#define MC 20 +#define CALC_N_MC 21 /* number of normal natal factors */ -# define FIRST_HSNR 21 -# define LAST_HSNR 32 -# define NO_OF_HOUSES 12 +#define FIRST_HSNR 21 +#define LAST_HSNR 32 +#define NO_OF_HOUSES 12 #define MAX_PL_INDEX 32 + /* * in a bitlist flag each planet is represented by a bit; * all 14 defined planets can be called at once with */ -#define CALC_ALL_PLANET_BITS ((1 << CALC_N) - 1) /* bits 0..13 set */ +#define CALC_ALL_PLANET_BITS ((1 << CALC_N) - 1) /* bits 0..13 set */ /* * AFL: Astrological factor letters for use in selections strings. @@ -231,92 +230,93 @@ extern char *planet2abbr3(int planet); * The function planet2afl translates a planext index into the AFL letter. */ -# define AFL_SUN '0' -# define AFL_MON '1' -# define AFL_MER '2' -# define AFL_VEN '3' -# define AFL_MAR '4' -# define AFL_JUP '5' -# define AFL_SAT '6' -# define AFL_URA '7' -# define AFL_NEP '8' -# define AFL_PLU '9' -# define AFL_CHI 'c' -# define AFL_LIL 'i' /* mean Lilith: direction of lunar aphel */ -# define AFL_AC 'A' -# define AFL_MC 'M' -# define AFL_TNODE 'N' /* TRUE_NODE */ -# define AFL_MNODE 'n' /* MEAN_NODE */ -# define AFL_CER 'C' -# define AFL_PAL 'P' -# define AFL_JUN 'J' -# define AFL_VES 'V' +#define AFL_SUN '0' +#define AFL_MON '1' +#define AFL_MER '2' +#define AFL_VEN '3' +#define AFL_MAR '4' +#define AFL_JUP '5' +#define AFL_SAT '6' +#define AFL_URA '7' +#define AFL_NEP '8' +#define AFL_PLU '9' +#define AFL_CHI 'c' +#define AFL_LIL 'i' /* mean Lilith: direction of lunar aphel */ +#define AFL_AC 'A' +#define AFL_MC 'M' +#define AFL_TNODE 'N' /* TRUE_NODE */ +#define AFL_MNODE 'n' /* MEAN_NODE */ +#define AFL_CER 'C' +#define AFL_PAL 'P' +#define AFL_JUN 'J' +#define AFL_VES 'V' /* * other AFL definitions not recognized by afl2planet() */ -# define AFL_SIDT 's' /* sidereal time */ -# define AFL_WDAY 'd' /* day of week column */ -# define AFL_HOUSE 'H' /* any house cusp */ +#define AFL_SIDT 's' /* sidereal time */ +#define AFL_WDAY 'd' /* day of week column */ +#define AFL_HOUSE 'H' /* any house cusp */ -# define apl2planet afl2planet /* change of original name */ +#define apl2planet afl2planet /* change of original name */ -# define J2000 2451545.0 /* Epoch of JPL ephemeris DE200, absolute */ -# define J1950 2433282.423 /* Epoch of JPL ephemeris DE102 */ -# define JUL_OFFSET 2433282.0 /* offset of Astrodienst relative Julian date */ +#define J2000 2451545.0 /* Epoch of JPL ephemeris DE200, absolute */ +#define J1950 2433282.423 /* Epoch of JPL ephemeris DE102 */ +#define JUL_OFFSET 2433282.0 /* offset of Astrodienst relative Julian date */ #ifndef GREG_CAL -# define GREG_CAL SE_GREG_CAL -# define JUL_CAL SE_JUL_CAL +#define GREG_CAL SE_GREG_CAL +#define JUL_CAL SE_JUL_CAL #endif /* * flag bits used in calc and calcserv */ -# define CALC_BIT_HELIO 1 /* geo/helio */ -# define CALC_BIT_NOAPP 2 /* apparent/true positions */ -# define CALC_BIT_NONUT 4 /* true eq. of date/ mean equ. of date */ -# define CALC_BIT_EPHE 8 /* universal/ephemeris time */ -# define CALC_BIT_SPEED 16 /* without/with speed */ -# define CALC_BIT_BETA 32 /* without/with latitude */ -# define CALC_BIT_RGEO 64 /* without/with relative rgeo */ -# define CALC_BIT_RAU 128 /* without/with real radius */ -# define CALC_BIT_MUST_USE_EPHE 256 /* epheserv may not use calc */ -# define CALC_BIT_MAY_USE_EPHE 512 /* calcserv may use ephread */ -# define CALC_BIT_MUST_CALC 1024 /* ephread must calc */ +#define CALC_BIT_HELIO 1 /* geo/helio */ +#define CALC_BIT_NOAPP 2 /* apparent/true positions */ +#define CALC_BIT_NONUT 4 /* true eq. of date/ mean equ. of date */ +#define CALC_BIT_EPHE 8 /* universal/ephemeris time */ +#define CALC_BIT_SPEED 16 /* without/with speed */ +#define CALC_BIT_BETA 32 /* without/with latitude */ +#define CALC_BIT_RGEO 64 /* without/with relative rgeo */ +#define CALC_BIT_RAU 128 /* without/with real radius */ +#define CALC_BIT_MUST_USE_EPHE 256 /* epheserv may not use calc */ +#define CALC_BIT_MAY_USE_EPHE 512 /* calcserv may use ephread */ +#define CALC_BIT_MUST_CALC 1024 /* ephread must calc */ /* * stuff from astrolib.h */ -#ifndef ADATE /* this must be bracketed because users of swepcalc - may also include astrolib.h for other reasons */ +#ifndef ADATE /* this must be bracketed because users of swepcalc + * may also include astrolib.h for other reasons */ #define ADATE struct adate /* makros for bit operations */ -# define clear_bit(v,bit_nr) ((v) & ~(1L << (bit_nr))) -# define set_bit(v,bit_nr) ((v) | (1L << (bit_nr))) -# define bit(bit_nr) (1L << (bit_nr)) -# define check_bit(v,bit_nr) ((v) & (1L << (bit_nr))) +#define clear_bit(v,bit_nr) ((v) & ~(1L << (bit_nr))) +#define set_bit(v,bit_nr) ((v) | (1L << (bit_nr))) +#define bit(bit_nr) (1L << (bit_nr)) +#define check_bit(v,bit_nr) ((v) & (1L << (bit_nr))) -ADATE { /* date structure used by revjuls and juldays */ - int day, month, year; - centisec csec; - }; +ADATE { /* date structure used by revjuls and juldays */ + int day, month, year; + centisec csec; +}; -#endif /* ADATE */ +#endif /* ADATE */ /* * functions exported by swepdate.c */ extern double julday(int month, int day, int year, double hour, int gregflag); -extern double juldays(int gregflag, ADATE *adp); -extern void revjul (double u, int gregflag, - int *jmon, int *jday, int *jyear, double *jut); -extern void revjuls(double u, int gregflag, ADATE *adp); +extern double juldays(int gregflag, ADATE * adp); +extern void revjul(double u, int gregflag, int *jmon, int *jday, int *jyear, + double *jut); +extern void revjuls(double u, int gregflag, ADATE * adp); extern int day_of_week(double t); + /* * end swpdate.c */ @@ -324,7 +324,7 @@ extern int day_of_week(double t); /* * stuff from housasp.h */ -#ifndef ASP_144 /* allow including housasp wihout conflict */ +#ifndef ASP_144 /* allow including housasp wihout conflict */ #define MAXPLANETS 16 /* @@ -333,40 +333,40 @@ extern int day_of_week(double t); * We define three different names for the aspects: * ASP_CONJ (always 4 letters), ASP_0 and CONJ. */ -# define ASP_CONJ 1 -# define ASP_0 1 -# define ASP_OPPO 2 -# define ASP_180 2 -# define ASP_SQUA 3 -# define ASP_90 3 -# define ASP_TRIN 4 -# define ASP_120 4 -# define ASP_SEXT 5 -# define ASP_60 5 -# define ASP_SMSX 6 -# define ASP_30 6 -# define ASP_QCNX 7 -# define ASP_150 7 -# define ASP_SMSQ 8 -# define ASP_45 8 -# define ASP_SQSQ 9 -# define ASP_135 9 -# define ASP_QINT 10 -# define ASP_72 10 -# define ASP_BQIN 11 -# define ASP_144 11 +#define ASP_CONJ 1 +#define ASP_0 1 +#define ASP_OPPO 2 +#define ASP_180 2 +#define ASP_SQUA 3 +#define ASP_90 3 +#define ASP_TRIN 4 +#define ASP_120 4 +#define ASP_SEXT 5 +#define ASP_60 5 +#define ASP_SMSX 6 +#define ASP_30 6 +#define ASP_QCNX 7 +#define ASP_150 7 +#define ASP_SMSQ 8 +#define ASP_45 8 +#define ASP_SQSQ 9 +#define ASP_135 9 +#define ASP_QINT 10 +#define ASP_72 10 +#define ASP_BQIN 11 +#define ASP_144 11 -# define CONJ ASP_CONJ -# define OPPO ASP_OPPO -# define SQUA ASP_SQUA -# define TRIN ASP_TRIN -# define SEXT ASP_SEXT -# define SMSX ASP_SMSX -# define QCNX ASP_QCNX -# define SMSQ ASP_SMSQ -# define SQSQ ASP_SQSQ -# define QINT ASP_QINT -# define BQIN ASP_BQIN +#define CONJ ASP_CONJ +#define OPPO ASP_OPPO +#define SQUA ASP_SQUA +#define TRIN ASP_TRIN +#define SEXT ASP_SEXT +#define SMSX ASP_SMSX +#define QCNX ASP_QCNX +#define SMSQ ASP_SMSQ +#define SQSQ ASP_SQSQ +#define QINT ASP_QINT +#define BQIN ASP_BQIN #define MAXASPECTS ASP_BQIN @@ -374,9 +374,9 @@ extern int day_of_week(double t); * for compact encoding of aspect lists we set bit 1 for CONJ, bit 2 for OPPO * and so on. asp_bit(asp) deleivers the mask. */ -#define ALL_ASP_BITS 1022 /* bit mask with all aspect bits set */ -#define STRONG_ASP_BITS 62 /* bit mask with strong aspect bits set */ -#define HARD_ASP_BITS 14 /* bit mask with hard aspect bits set */ +#define ALL_ASP_BITS 1022 /* bit mask with all aspect bits set */ +#define STRONG_ASP_BITS 62 /* bit mask with strong aspect bits set */ +#define HARD_ASP_BITS 14 /* bit mask with hard aspect bits set */ #define asp_bit(asp) (1 << (asp)) @@ -394,68 +394,71 @@ extern int day_of_week(double t); /* * used to initialize an array centisec angles[MAXASPECTS+1] */ -# define ASP_ANGLES {0, 0*DEG, 180*DEG, 90*DEG, 120*DEG,\ +#define ASP_ANGLES {0, 0*DEG, 180*DEG, 90*DEG, 120*DEG,\ 60*DEG, 30*DEG, 150*DEG, 45*DEG, 135*DEG, 72*DEG, 144*DEG} -struct AspectType { - AS_BOOL dataValid; /* used as boolean */ - int NrOfPlanets, - NrOfAspects; - centisec *PlanetPos; /* pointer to an array of planet positions - [0..NrOfPlanets-1]; the user of the - structure must set this pointer to his - array of planet positions */ - centisec *ppos2; /* second set for mutual aspects only; if - not NULL, interaspects are calculated */ - centisec *Maxorb; /* pointer to an array [0..NrOfAspects] of - maximum orbes; element[0] not used; - the user of the structure must set this - pointer to his array of maxorbs */ - centisec *Angle; /* pointer to Angle[0..NrOfAspects] of the - angles of aspects; [0] not used; the - user must set this pointer to his array - of angles */ - struct aspRec { - int index; /* number of the found aspect */ - centisec orb; - } - Asp [MAXPLANETS] [MAXPLANETS]; - }; +struct AspectType +{ + AS_BOOL dataValid; /* used as boolean */ + int NrOfPlanets, NrOfAspects; + centisec *PlanetPos; /* pointer to an array of planet positions + * [0..NrOfPlanets-1]; the user of the + * structure must set this pointer to his + * array of planet positions */ + centisec *ppos2; /* second set for mutual aspects only; if + * not NULL, interaspects are calculated */ + centisec *Maxorb; /* pointer to an array [0..NrOfAspects] of + * maximum orbes; element[0] not used; + * the user of the structure must set this + * pointer to his array of maxorbs */ + centisec *Angle; /* pointer to Angle[0..NrOfAspects] of the + * angles of aspects; [0] not used; the + * user must set this pointer to his array + * of angles */ + struct aspRec + { + int index; /* number of the found aspect */ + centisec orb; + } + Asp[MAXPLANETS][MAXPLANETS]; +}; -struct houses { - centisec cusp[13]; - centisec ac; - centisec mc; - }; +struct houses +{ + centisec cusp[13]; + centisec ac; + centisec mc; +}; + +#define HOUSES struct houses +#endif /* ifndef ASP_144 */ -# define HOUSES struct houses -#endif /* ifndef ASP_144 */ /********************************** functions exported originally from housasp.c ***********************************/ -extern int HouseNr(HOUSES *h, CSEC p); +extern int HouseNr(HOUSES * h, CSEC p); /* - return in which house pp is, - The caller is responsible for proper initialization of cusps - */ + * return in which house pp is, + * The caller is responsible for proper initialization of cusps + */ -extern int InpHouseNr(HOUSES *h, CSEC p, CSEC *cuspoff); +extern int InpHouseNr(HOUSES * h, CSEC p, CSEC * cuspoff); /* returns the interpretation-house number, where pp is in; * an interpretation house is defined differently from a normal * house: the cusps are offset, so that it begins and ends * a little earlier. * cusp[1..12] and cuspoff[1..12] must be initialized */ -extern int InpHouseNr2(HOUSES *h, CSEC p, CSEC *cuspoff); +extern int InpHouseNr2(HOUSES * h, CSEC p, CSEC * cuspoff); /* variation of InpHouseNr(). Comment in swepcalc.c */ extern void CalcHouses(CSEC th, CSEC fi, CSEC ekl, char hsy, int icnt, - struct houses *h); + struct houses *h); extern void RecalcAspects(struct AspectType *a); -extern void longreorder (UCHAR *p, int n); +extern void longreorder(UCHAR * p, int n); #endif /* _SWEPCALC_INCLUDED */ diff --git a/swe/src/swepdate.c b/swe/src/swepdate.c index 088c0c8..7da6a4b 100644 --- a/swe/src/swepdate.c +++ b/swe/src/swepdate.c @@ -1,9 +1,11 @@ + /***************************************************** $Header: swepdate.c,v 1.65 2003/06/14 13:02:01 alois Exp $ Placalc compatibility interface for Swiss Ephemeris. date functions *******************************************************/ + /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -129,28 +131,32 @@ date functions and notifies errors like 32 January. ****************************************************************/ -double julday(int month, int day, int year, double hour, int gregflag) +double +julday(int month, int day, int year, double hour, int gregflag) { - double jd; - jd = swe_julday(year, month, day, hour, gregflag); - return jd; + double jd; + jd = swe_julday(year, month, day, hour, gregflag); + return jd; } /* * monday = 0, ... sunday = 6 */ -int day_of_week(double jd) +int +day_of_week(double jd) { - return (((int) floor (jd - 2433282 - 1.5) %7) + 7) % 7; + return (((int)floor(jd - 2433282 - 1.5) % 7) + 7) % 7; } /*************** julday ****************** get absolute julian day number (author: Marc Pottenger) with bug fix for year < -4711 15-aug-88 */ -double juldays(int gregflag, ADATE *adp ) +double +juldays(int gregflag, ADATE * adp) { - return swe_julday(adp->year, adp->month, adp->day, adp->csec / 360000.0, gregflag); + return swe_julday(adp->year, adp->month, adp->day, adp->csec / 360000.0, + gregflag); } /*** revjul ****************************************************** @@ -172,10 +178,10 @@ double juldays(int gregflag, ADATE *adp ) Original author Mark Pottenger, Los Angeles. with bug fix for year < -4711 16-aug-88 Alois Treindl *************************************************************************/ -void revjul (double jd, int gregflag, - int *jmon, int *jday, int *jyear, double *jut) +void +revjul(double jd, int gregflag, int *jmon, int *jday, int *jyear, double *jut) { - swe_revjul(jd, gregflag, jyear, jmon, jday, jut); + swe_revjul(jd, gregflag, jyear, jmon, jday, jut); } /************************************* revjul ********* @@ -183,11 +189,12 @@ void revjul (double jd, int gregflag, with bug fix for year < -4711 16-aug-88 arguments are julian day #, calendar flag (0=julian, 1=gregorian) */ -void revjuls(double jd, int gregflag, struct adate *adp) +void +revjuls(double jd, int gregflag, struct adate *adp) { - double jut; - swe_revjul(jd, gregflag, &adp->year, &adp->month, &adp->day, &jut); - adp->csec = jut * 360000.0 + 0.5; + double jut; + swe_revjul(jd, gregflag, &adp->year, &adp->month, &adp->day, &jut); + adp->csec = jut * 360000.0 + 0.5; } /********************************************************* @@ -215,28 +222,28 @@ void revjuls(double jd, int gregflag, struct adate *adp) Return: OK or ERR (for illegal date) *********************************************************/ -int date_conversion (int d , - int m , - int y , /* day, month, year */ - centisec gutime, /* greenwich time in centiseconds */ - char c, /* calendar g[regorian]|j[ulian]|a[stro = greg] */ - double *tgmt - /* julian date relative 0.Jan.1950 12:00 gmt */ - /* shift is 2433282 from absolute Julian date */ - ) -{ - int rday, rmon, ryear; - double rut, jd; - int gregflag = SE_JUL_CAL; - if (c == 'g' || c == 'a') - gregflag = SE_GREG_CAL; - rut = gutime / 360000.0; /* hours GMT */ - jd = julday(m, d, y, rut, gregflag); - revjul(jd, gregflag, &rmon, &rday, &ryear, &rut); - *tgmt = jd - JUL_OFFSET; - if (rmon == m && rday == d && ryear == y) { - return OK; - } else { - return ERR; - } -} /* end date_conversion */ +int +date_conversion(int d, int m, int y, /* day, month, year */ + centisec gutime, /* greenwich time in centiseconds */ + char c, /* calendar g[regorian]|j[ulian]|a[stro = greg] */ + double *tgmt + /* julian date relative 0.Jan.1950 12:00 gmt */ + /* shift is 2433282 from absolute Julian date */ + ) +{ + int rday, rmon, ryear; + double rut, jd; + int gregflag = SE_JUL_CAL; + if (c == 'g' || c == 'a') + gregflag = SE_GREG_CAL; + rut = gutime / 360000.0; /* hours GMT */ + jd = julday(m, d, y, rut, gregflag); + revjul(jd, gregflag, &rmon, &rday, &ryear, &rut); + *tgmt = jd - JUL_OFFSET; + if (rmon == m && rday == d && ryear == y) { + return OK; + } + else { + return ERR; + } +} /* end date_conversion */ diff --git a/swe/src/sweph.c b/swe/src/sweph.c index 48afe4a..d2474ca 100644 --- a/swe/src/sweph.c +++ b/swe/src/sweph.c @@ -1,3 +1,4 @@ + /* SWISSEPH $Header: /home/dieter/sweph/RCS/sweph.c,v 1.76 2009/07/10 14:08:53 dieter Exp $ @@ -6,6 +7,7 @@ Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich **************************************************************/ + /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -16,7 +18,7 @@ Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author or distributor accepts any responsibility for the consequences of using it, or for whether it serves any particular purpose or works at all, unless he - or she says so in writing. + or she says so in writing. Swiss Ephemeris is made available by its authors under a dual licensing system. The software developer, who uses any part of Swiss Ephemeris @@ -35,7 +37,7 @@ See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html If the developer choses the Swiss Ephemeris Professional license, - he must follow the instructions as found in http://www.astro.com/swisseph/ + he must follow the instructions as found in http://www.astro.com/swisseph/ and purchase the Swiss Ephemeris Professional Edition from Astrodienst and sign the corresponding license contract. @@ -60,7 +62,6 @@ for promoting such software, products or services. */ - #include #include #include "swejpl.h" @@ -78,74 +79,83 @@ #define SEFLG_EPHMASK (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH) -struct meff_ele {double r,m;}; +struct meff_ele +{ + double r, m; +}; /**************** * global stuff * ****************/ -struct swe_data FAR swed = {FALSE, /* ephe_path_is_set = FALSE */ - FALSE, /* jpl_file_is_open = FALSE */ - NULL, /* fixed stars file pointer */ - SE_EPHE_PATH, /* ephe path */ - SE_FNAME_DFT, /* JPL file name, default */ - FALSE, /* geopos is set, for topocentric */ - FALSE, /* ayanamsa is set */ - }; +struct swe_data FAR swed = { FALSE, /* ephe_path_is_set = FALSE */ + FALSE, /* jpl_file_is_open = FALSE */ + NULL, /* fixed stars file pointer */ + SE_EPHE_PATH, /* ephe path */ + SE_FNAME_DFT, /* JPL file name, default */ + FALSE, /* geopos is set, for topocentric */ + FALSE, /* ayanamsa is set */ +}; /************* * constants * *************/ static char *ayanamsa_name[] = { - "Fagan/Bradley", - "Lahiri", - "De Luce", - "Raman", - "Ushashashi", - "Krishnamurti", - "Djwhal Khul", - "Yukteshwar", - "J.N. Bhasin", - "Babylonian/Kugler 1", - "Babylonian/Kugler 2", - "Babylonian/Kugler 3", - "Babylonian/Huber", - "Babylonian/Eta Piscium", - "Babylonian/Aldebaran = 15 Tau", - "Hipparchos", - "Sassanian", - "Galact. Center = 0 Sag", - "J2000", - "J1900", - "B1950", - "Suryasiddhanta", - "Suryasiddhanta, mean Sun", - "Aryabhata", - "Aryabhata, mean Sun", + "Fagan/Bradley", + "Lahiri", + "De Luce", + "Raman", + "Ushashashi", + "Krishnamurti", + "Djwhal Khul", + "Yukteshwar", + "J.N. Bhasin", + "Babylonian/Kugler 1", + "Babylonian/Kugler 2", + "Babylonian/Kugler 3", + "Babylonian/Huber", + "Babylonian/Eta Piscium", + "Babylonian/Aldebaran = 15 Tau", + "Hipparchos", + "Sassanian", + "Galact. Center = 0 Sag", + "J2000", + "J1900", + "B1950", + "Suryasiddhanta", + "Suryasiddhanta, mean Sun", + "Aryabhata", + "Aryabhata, mean Sun", }; -static const int FAR pnoint2jpl[] = PNOINT2JPL; -static const int pnoext2int[] = {SEI_SUN, SEI_MOON, SEI_MERCURY, SEI_VENUS, SEI_MARS, SEI_JUPITER, SEI_SATURN, SEI_URANUS, SEI_NEPTUNE, SEI_PLUTO, 0, 0, 0, 0, SEI_EARTH, SEI_CHIRON, SEI_PHOLUS, SEI_CERES, SEI_PALLAS, SEI_JUNO, SEI_VESTA, }; +static const int FAR pnoint2jpl[] = PNOINT2JPL; -static int do_fread(void *targ, int size, int count, int corrsize, - FILE *fp, int32 fpos, int freord, int fendian, int ifno, - char *serr); +static const int pnoext2int[] = + { SEI_SUN, SEI_MOON, SEI_MERCURY, SEI_VENUS, SEI_MARS, SEI_JUPITER, + SEI_SATURN, SEI_URANUS, SEI_NEPTUNE, SEI_PLUTO, 0, 0, 0, 0, SEI_EARTH, + SEI_CHIRON, SEI_PHOLUS, + SEI_CERES, SEI_PALLAS, SEI_JUNO, SEI_VESTA, +}; + +static int do_fread(void *targ, int size, int count, int corrsize, FILE * fp, + int32 fpos, int freord, int fendian, int ifno, + char *serr); static int get_new_segment(double tjd, int ipli, int ifno, char *serr); static int main_planet(double tjd, int ipli, int32 epheflag, int32 iflag, - char *serr); -static int main_planet_bary(double tjd, int ipli, int32 epheflag, int32 iflag, - AS_BOOL do_save, - double *xp, double *xe, double *xs, double *xm, - char *serr); + char *serr); +static int main_planet_bary(double tjd, int ipli, int32 epheflag, int32 iflag, + AS_BOOL do_save, double *xp, double *xe, + double *xs, double *xm, char *serr); static int32 swecalc(double tjd, int ipl, int32 iflag, double *x, char *serr); -static int sweplan(double tjd, int ipli, int ifno, int32 iflag, AS_BOOL do_save, - double *xp, double *xpe, double *xps, double *xpm, - char *serr); -static int swemoon(double tjd, int32 iflag, AS_BOOL do_save, double *xp, char *serr); -static int sweph(double tjd, int ipli, int ifno, int32 iflag, double *xsunb, AS_BOOL do_save, - double *xp, char *serr); +static int sweplan(double tjd, int ipli, int ifno, int32 iflag, + AS_BOOL do_save, double *xp, double *xpe, double *xps, + double *xpm, char *serr); +static int swemoon(double tjd, int32 iflag, AS_BOOL do_save, double *xp, + char *serr); +static int sweph(double tjd, int ipli, int ifno, int32 iflag, double *xsunb, + AS_BOOL do_save, double *xp, char *serr); static int jplplan(double tjd, int ipli, int32 iflag, AS_BOOL do_save, - double *xp, double *xpe, double *xps, char *serr); + double *xp, double *xpe, double *xps, char *serr); static void rot_back(int ipl); static int read_const(int ifno, char *serr); static void embofs(double *xemb, double *xmoon); @@ -156,279 +166,291 @@ static int app_pos_etc_moon(int32 iflag, char *serr); static int app_pos_etc_sbar(int32 iflag, char *serr); extern int swi_plan_for_osc_elem(int32 iflag, double tjd, double *xx); static int app_pos_etc_mean(int ipl, int32 iflag, char *serr); -static void nut_matrix(struct nut *nu, struct epsilon *oec); +static void nut_matrix(struct nut *nu, struct epsilon *oec); static void calc_epsilon(double tjd, struct epsilon *e); static int lunar_osc_elem(double tjd, int ipl, int32 iflag, char *serr); -static int intp_apsides(double tjd, int ipl, int32 iflag, char *serr); +static int intp_apsides(double tjd, int ipl, int32 iflag, char *serr); static double meff(double r); static void denormalize_positions(double *x0, double *x1, double *x2); static void calc_speed(double *x0, double *x1, double *x2, double dt); static int32 plaus_iflag(int32 iflag); -void FAR PASCAL_CONV swe_set_sid_mode(int32 sid_mode, double t0, double ayan_t0); -static int app_pos_rest(struct plan_data *pdp, int32 iflag, - double *xx, double *x2000, struct epsilon *oe, char *serr); +void FAR PASCAL_CONV swe_set_sid_mode(int32 sid_mode, double t0, + double ayan_t0); +static int app_pos_rest(struct plan_data *pdp, int32 iflag, double *xx, + double *x2000, struct epsilon *oe, char *serr); #ifdef TRACE -static void trace_swe_calc(int param, double tjd, int ipl, int32 iflag, double *xx, char *serr); -static void trace_swe_fixstar(int swtch, char *star, double tjd, int32 iflag, double *xx, char *serr); +static void trace_swe_calc(int param, double tjd, int ipl, int32 iflag, + double *xx, char *serr); +static void trace_swe_fixstar(int swtch, char *star, double tjd, int32 iflag, + double *xx, char *serr); static void trace_swe_get_planet_name(int swtch, int ipl, char *s); #endif -char *FAR PASCAL_CONV swe_version(char *s) +char *FAR PASCAL_CONV +swe_version(char *s) { - strcpy(s, SE_VERSION); - return s; + strcpy(s, SE_VERSION); + return s; } /* The routine called by the user. * It checks whether a position for the same planet, the same t, and the - * same flag bits has already been computed. + * same flag bits has already been computed. * If yes, this position is returned. Otherwise it is computed. * -> If the SEFLG_SPEED flag has been specified, the speed will be returned - * at offset 3 of position array x[]. Its precision is probably better + * at offset 3 of position array x[]. Its precision is probably better * than 0.002"/day. * -> If the SEFLG_SPEED3 flag has been specified, the speed will be computed * from three positions. This speed is less accurate than SEFLG_SPEED, - * i.e. better than 0.1"/day. And it is much slower. It is used for + * i.e. better than 0.1"/day. And it is much slower. It is used for * program tests only. * -> If no speed flag has been specified, no speed will be returned. */ -int32 FAR PASCAL_CONV swe_calc(double tjd, int ipl, int32 iflag, - double *xx, char *serr) +int32 FAR PASCAL_CONV +swe_calc(double tjd, int ipl, int32 iflag, double *xx, char *serr) { - int i, j; - int32 iflgcoor; - int32 iflgsave = iflag; - int32 epheflag; - static int32 epheflag_sv = 0; - struct save_positions *sd; - double x[6], *xs, x0[24], x2[24]; - double dt; + int i, j; + int32 iflgcoor; + int32 iflgsave = iflag; + int32 epheflag; + static int32 epheflag_sv = 0; + struct save_positions *sd; + double x[6], *xs, x0[24], x2[24]; + double dt; #ifdef TRACE #ifdef FORCE_IFLAG - /* - * If this source file is compiled with /DFORCE_IFLAG or -DFORCE_IFLAG - * and also with TRACE, then the actual value of iflag used in swe_calc() - * can be manipulated from the outside of an application: - * Create a text file 'force.flg' and put one text line into it - * containing a number, e.g. 1024 - * This number will be or'ed into the iflag used by the caller of swe_calc() - * - * See the code below for the details. - * This is not an important mechanism. We used it to debug an application - * which showed strange behaviour, by compiling a special DLL with TRACE and - * FORCE_IFLAG and then running the application with this DLL (we had no - * source code of the application itself). - */ - static int force_flag = 0; - static int32 iflag_forced = 0; - static int force_flag_checked = 0; - FILE *fp; - char s[AS_MAXCH], *sp; - memset(x, 0, sizeof(double) * 6); - /* if the following file exists, flag is read from it and or'ed into iflag */ - if (!force_flag_checked) { - if ((fp = fopen(fname_force_flg, BFILE_R_ACCESS)) != NULL) { - force_flag = 1; - fgets(s, AS_MAXCH, fp); - if ((sp = strchr(s, '\n')) != NULL) - *sp = '\0'; - iflag_forced = atol(s); - fclose(fp); + /* + * If this source file is compiled with /DFORCE_IFLAG or -DFORCE_IFLAG + * and also with TRACE, then the actual value of iflag used in swe_calc() + * can be manipulated from the outside of an application: + * Create a text file 'force.flg' and put one text line into it + * containing a number, e.g. 1024 + * This number will be or'ed into the iflag used by the caller of swe_calc() + * + * See the code below for the details. + * This is not an important mechanism. We used it to debug an application + * which showed strange behaviour, by compiling a special DLL with TRACE and + * FORCE_IFLAG and then running the application with this DLL (we had no + * source code of the application itself). + */ + static int force_flag = 0; + static int32 iflag_forced = 0; + static int force_flag_checked = 0; + FILE *fp; + char s[AS_MAXCH], *sp; + memset(x, 0, sizeof(double) * 6); + /* if the following file exists, flag is read from it and or'ed into iflag */ + if (!force_flag_checked) { + if ((fp = fopen(fname_force_flg, BFILE_R_ACCESS)) != NULL) { + force_flag = 1; + fgets(s, AS_MAXCH, fp); + if ((sp = strchr(s, '\n')) != NULL) + *sp = '\0'; + iflag_forced = atol(s); + fclose(fp); + } + force_flag_checked = 1; } - force_flag_checked = 1; - } - if (force_flag) - iflag |= iflag_forced; + if (force_flag) + iflag |= iflag_forced; #endif - swi_open_trace(serr); - trace_swe_calc(1, tjd, ipl, iflag, xx, NULL); + swi_open_trace(serr); + trace_swe_calc(1, tjd, ipl, iflag, xx, NULL); #endif /* TRACE */ #ifdef NO_JPL - if (iflag & SEFLG_JPLEPH) { - iflag = iflag & ~SEFLG_EPHMASK; - iflag |= SEFLG_SWIEPH; - } + if (iflag & SEFLG_JPLEPH) { + iflag = iflag & ~SEFLG_EPHMASK; + iflag |= SEFLG_SWIEPH; + } #endif - /* function calls for Pluto with asteroid number 134340 - * are treated as calls for Pluto as main body SE_PLUTO. - * Reason: Our numerical integrator takes into account Pluto - * perturbation and therefore crashes with body 134340 Pluto. */ - if (ipl == SE_AST_OFFSET + 134340) - ipl = SE_PLUTO; - /* if ephemeris flag != ephemeris flag of last call, - * we clear the save area, to prevent swecalc() using - * previously computed data for current calculation. - * except with ipl = SE_ECL_NUT which is not dependent - * on ephemeris, and except if change is from - * ephemeris = 0 to ephemeris = SEFLG_DEFAULTEPH - * or vice-versa. - */ - epheflag = iflag & SEFLG_EPHMASK; - if (epheflag & SEFLG_DEFAULTEPH) - epheflag = 0; - if (epheflag_sv != epheflag && ipl != SE_ECL_NUT) { - swe_close(); - epheflag_sv = epheflag; - } - /* high precision speed prevails fast speed */ - if ((iflag & SEFLG_SPEED3) && (iflag & SEFLG_SPEED)) - iflag = iflag & ~SEFLG_SPEED3; - /* cartesian flag excludes radians flag */ - if ((iflag & SEFLG_XYZ) && (iflag & SEFLG_RADIANS)) - iflag = iflag & ~SEFLG_RADIANS; + /* function calls for Pluto with asteroid number 134340 + * are treated as calls for Pluto as main body SE_PLUTO. + * Reason: Our numerical integrator takes into account Pluto + * perturbation and therefore crashes with body 134340 Pluto. */ + if (ipl == SE_AST_OFFSET + 134340) + ipl = SE_PLUTO; + /* if ephemeris flag != ephemeris flag of last call, + * we clear the save area, to prevent swecalc() using + * previously computed data for current calculation. + * except with ipl = SE_ECL_NUT which is not dependent + * on ephemeris, and except if change is from + * ephemeris = 0 to ephemeris = SEFLG_DEFAULTEPH + * or vice-versa. + */ + epheflag = iflag & SEFLG_EPHMASK; + if (epheflag & SEFLG_DEFAULTEPH) + epheflag = 0; + if (epheflag_sv != epheflag && ipl != SE_ECL_NUT) { + swe_close(); + epheflag_sv = epheflag; + } + /* high precision speed prevails fast speed */ + if ((iflag & SEFLG_SPEED3) && (iflag & SEFLG_SPEED)) + iflag = iflag & ~SEFLG_SPEED3; + /* cartesian flag excludes radians flag */ + if ((iflag & SEFLG_XYZ) && (iflag & SEFLG_RADIANS)) + iflag = iflag & ~SEFLG_RADIANS; + /* if (iflag & SEFLG_ICRS) iflag |= SEFLG_J2000;*/ - /* pointer to save area */ - if (ipl < SE_NPLANETS && ipl >= SE_SUN) - sd = &swed.savedat[ipl]; - else - /* other bodies, e.g. asteroids called with ipl = SE_AST_OFFSET + MPC# */ - sd = &swed.savedat[SE_NPLANETS]; - /* - * if position is available in save area, it is returned. - * this is the case, if tjd = tsave and iflag = iflgsave. - * coordinate flags can be neglected, because save area - * provides all coordinate types. - * if ipl > SE_AST(EROID)_OFFSET, ipl must be checked, - * because all asteroids called by MPC number share the same - * save area. - */ - iflgcoor = SEFLG_EQUATORIAL | SEFLG_XYZ | SEFLG_RADIANS; - if (sd->tsave == tjd && tjd != 0 && ipl == sd->ipl) { - if ((sd->iflgsave & ~iflgcoor) == (iflag & ~iflgcoor)) - goto end_swe_calc; - } - /* - * otherwise, new position must be computed - */ - if ((iflag & SEFLG_SPEED3) == 0) { - /* - * with high precision speed from one call of swecalc() - * (FAST speed) + /* pointer to save area */ + if (ipl < SE_NPLANETS && ipl >= SE_SUN) + sd = &swed.savedat[ipl]; + else + /* other bodies, e.g. asteroids called with ipl = SE_AST_OFFSET + MPC# */ + sd = &swed.savedat[SE_NPLANETS]; + /* + * if position is available in save area, it is returned. + * this is the case, if tjd = tsave and iflag = iflgsave. + * coordinate flags can be neglected, because save area + * provides all coordinate types. + * if ipl > SE_AST(EROID)_OFFSET, ipl must be checked, + * because all asteroids called by MPC number share the same + * save area. */ - sd->tsave = tjd; - sd->ipl = ipl; - if ((sd->iflgsave = swecalc(tjd, ipl, iflag, sd->xsaves, serr)) == ERR) - goto return_error; - } else { - /* - * with speed from three calls of swecalc(), slower and less accurate. - * (SLOW speed, for test only) - */ - sd->tsave = tjd; - sd->ipl = ipl; - switch(ipl) { - case SE_MOON: - dt = MOON_SPEED_INTV; - break; - case SE_OSCU_APOG: - case SE_TRUE_NODE: - /* this is the optimum dt with Moshier ephemeris, but not with - * JPL ephemeris or SWISSEPH. To avoid completely false speed - * in case that JPL is wanted but the program returns Moshier, - * we use Moshier optimum. - * For precise speed, use JPL and FAST speed computation, - */ - dt = NODE_CALC_INTV_MOSH; - break; - default: - dt = PLAN_SPEED_INTV; - break; - } - if ((sd->iflgsave = swecalc(tjd-dt, ipl, iflag, x0, serr)) == ERR) - goto return_error; - if ((sd->iflgsave = swecalc(tjd+dt, ipl, iflag, x2, serr)) == ERR) - goto return_error; - if ((sd->iflgsave = swecalc(tjd, ipl, iflag, sd->xsaves, serr)) == ERR) - goto return_error; - denormalize_positions(x0, sd->xsaves, x2); - calc_speed(x0, sd->xsaves, x2, dt); - } - end_swe_calc: - if (iflag & SEFLG_EQUATORIAL) - xs = sd->xsaves+12; /* equatorial coordinates */ - else - xs = sd->xsaves; /* ecliptic coordinates */ - if (iflag & SEFLG_XYZ) - xs = xs+6; /* cartesian coordinates */ - if (ipl == SE_ECL_NUT) - i = 4; - else - i = 3; - for (j = 0; j < i; j++) - x[j] = *(xs + j); - for (j = i; j < 6; j++) - x[j] = 0; - if (iflag & (SEFLG_SPEED3 | SEFLG_SPEED)) { - for (j = 3; j < 6; j++) - x[j] = *(xs + j); - } -#if 1 - if (iflag & SEFLG_RADIANS) { - if (ipl == SE_ECL_NUT) { - for (j = 0; j < 4; j++) - x[j] *= DEGTORAD; - } else { - for (j = 0; j < 2; j++) - x[j] *= DEGTORAD; - if (iflag & (SEFLG_SPEED3 | SEFLG_SPEED)) { - for (j = 3; j < 5; j++) - x[j] *= DEGTORAD; - } + iflgcoor = SEFLG_EQUATORIAL | SEFLG_XYZ | SEFLG_RADIANS; + if (sd->tsave == tjd && tjd != 0 && ipl == sd->ipl) { + if ((sd->iflgsave & ~iflgcoor) == (iflag & ~iflgcoor)) + goto end_swe_calc; + } + /* + * otherwise, new position must be computed + */ + if ((iflag & SEFLG_SPEED3) == 0) { + /* + * with high precision speed from one call of swecalc() + * (FAST speed) + */ + sd->tsave = tjd; + sd->ipl = ipl; + if ((sd->iflgsave = + swecalc(tjd, ipl, iflag, sd->xsaves, serr)) == ERR) + goto return_error; + } + else { + /* + * with speed from three calls of swecalc(), slower and less accurate. + * (SLOW speed, for test only) + */ + sd->tsave = tjd; + sd->ipl = ipl; + switch (ipl) { + case SE_MOON: + dt = MOON_SPEED_INTV; + break; + case SE_OSCU_APOG: + case SE_TRUE_NODE: + /* this is the optimum dt with Moshier ephemeris, but not with + * JPL ephemeris or SWISSEPH. To avoid completely false speed + * in case that JPL is wanted but the program returns Moshier, + * we use Moshier optimum. + * For precise speed, use JPL and FAST speed computation, + */ + dt = NODE_CALC_INTV_MOSH; + break; + default: + dt = PLAN_SPEED_INTV; + break; + } + if ((sd->iflgsave = swecalc(tjd - dt, ipl, iflag, x0, serr)) == ERR) + goto return_error; + if ((sd->iflgsave = swecalc(tjd + dt, ipl, iflag, x2, serr)) == ERR) + goto return_error; + if ((sd->iflgsave = + swecalc(tjd, ipl, iflag, sd->xsaves, serr)) == ERR) + goto return_error; + denormalize_positions(x0, sd->xsaves, x2); + calc_speed(x0, sd->xsaves, x2, dt); + } +end_swe_calc: + if (iflag & SEFLG_EQUATORIAL) + xs = sd->xsaves + 12; /* equatorial coordinates */ + else + xs = sd->xsaves; /* ecliptic coordinates */ + if (iflag & SEFLG_XYZ) + xs = xs + 6; /* cartesian coordinates */ + if (ipl == SE_ECL_NUT) + i = 4; + else + i = 3; + for (j = 0; j < i; j++) + x[j] = *(xs + j); + for (j = i; j < 6; j++) + x[j] = 0; + if (iflag & (SEFLG_SPEED3 | SEFLG_SPEED)) { + for (j = 3; j < 6; j++) + x[j] = *(xs + j); + } +#if 1 + if (iflag & SEFLG_RADIANS) { + if (ipl == SE_ECL_NUT) { + for (j = 0; j < 4; j++) + x[j] *= DEGTORAD; + } + else { + for (j = 0; j < 2; j++) + x[j] *= DEGTORAD; + if (iflag & (SEFLG_SPEED3 | SEFLG_SPEED)) { + for (j = 3; j < 5; j++) + x[j] *= DEGTORAD; + } + } } - } #endif - for (i = 0; i <= 5; i++) - xx[i] = x[i]; - iflag = sd->iflgsave; - /* if no ephemeris has been specified, do not return chosen ephemeris */ - if ((iflgsave & SEFLG_EPHMASK) == 0) - iflag = iflag & ~SEFLG_DEFAULTEPH; + for (i = 0; i <= 5; i++) + xx[i] = x[i]; + iflag = sd->iflgsave; + /* if no ephemeris has been specified, do not return chosen ephemeris */ + if ((iflgsave & SEFLG_EPHMASK) == 0) + iflag = iflag & ~SEFLG_DEFAULTEPH; #ifdef TRACE - trace_swe_calc(2, tjd, ipl, iflag, xx, serr); + trace_swe_calc(2, tjd, ipl, iflag, xx, serr); #endif - return iflag; + return iflag; return_error: - for (i = 0; i <= 5; i++) - xx[i] = 0; + for (i = 0; i <= 5; i++) + xx[i] = 0; #ifdef TRACE - trace_swe_calc(2, tjd, ipl, iflag, xx, serr); + trace_swe_calc(2, tjd, ipl, iflag, xx, serr); #endif - return ERR; + return ERR; } -int32 FAR PASCAL_CONV swe_calc_ut(double tjd_ut, int32 ipl, int32 iflag, - double *xx, char *serr) +int32 FAR PASCAL_CONV +swe_calc_ut(double tjd_ut, int32 ipl, int32 iflag, double *xx, char *serr) { - return swe_calc(tjd_ut + swe_deltat(tjd_ut), ipl, iflag, xx, serr); + return swe_calc(tjd_ut + swe_deltat(tjd_ut), ipl, iflag, xx, serr); } -static int32 swecalc(double tjd, int ipl, int32 iflag, double *x, char *serr) +static int32 +swecalc(double tjd, int ipl, int32 iflag, double *x, char *serr) { - int i; - int ipli, ipli_ast, ifno; - int retc; - int32 epheflag = SEFLG_DEFAULTEPH; - struct plan_data *pdp; - struct plan_data *pedp = &swed.pldat[SEI_EARTH]; - struct plan_data *psdp = &swed.pldat[SEI_SUNBARY]; + int i; + int ipli, ipli_ast, ifno; + int retc; + int32 epheflag = SEFLG_DEFAULTEPH; + struct plan_data *pdp; + struct plan_data *pedp = &swed.pldat[SEI_EARTH]; + struct plan_data *psdp = &swed.pldat[SEI_SUNBARY]; #if 0 - struct node_data *ndp; + struct node_data *ndp; #else - struct plan_data *ndp; + struct plan_data *ndp; #endif - double *xp, *xp2; - double ss[3]; - char serr2[AS_MAXCH]; - if (serr != NULL) - *serr = '\0'; - serr2[0] = '\0'; - /****************************************** - * iflag plausible? * + double *xp, *xp2; + double ss[3]; + char serr2[AS_MAXCH]; + if (serr != NULL) + *serr = '\0'; + serr2[0] = '\0'; + + /****************************************** + * iflag plausible? * ******************************************/ - iflag = plaus_iflag(iflag); - /****************************************** + iflag = plaus_iflag(iflag); + + /****************************************** * which ephemeris is wanted, which is used? * Three ephemerides are possible: MOSEPH, SWIEPH, JPLEPH. * JPLEPH is best, SWIEPH is nearly as good, MOSEPH is least precise. @@ -437,7 +459,7 @@ static int32 swecalc(double tjd, int ipl, int32 iflag, double *x, char *serr) * any time. * Swisseph should try to fulfil the wish of the user for a specific * ephemeris, but use a less precise one if the desired ephemeris is not - * available for the given date and body. + * available for the given date and body. * If internal ephemeris errors are detected (data error, file length error) * an error is returned. * If the time range is bad but another ephemeris can deliver this range, @@ -448,680 +470,723 @@ static int32 swecalc(double tjd, int ipl, int32 iflag, double *x, char *serr) * ephe_flag is extracted from iflag, but can change later if the * desired ephe is not available. ******************************************/ - if (iflag & SEFLG_MOSEPH) - epheflag = SEFLG_MOSEPH; - if (iflag & SEFLG_SWIEPH) - epheflag = SEFLG_SWIEPH; - if (iflag & SEFLG_JPLEPH) - epheflag = SEFLG_JPLEPH; - /* no barycentric calculations with Moshier ephemeris */ - if ((iflag & SEFLG_BARYCTR) && (iflag & SEFLG_MOSEPH)) { - if (serr != NULL) - strcpy(serr, "barycentric Moshier positions are not supported."); - return ERR; - } - if (epheflag != SEFLG_MOSEPH && !swed.ephe_path_is_set) - swe_set_ephe_path(NULL); - if ((iflag & SEFLG_SIDEREAL) && !swed.ayana_is_set) - swe_set_sid_mode(SE_SIDM_FAGAN_BRADLEY, 0, 0); - /****************************************** - * obliquity of ecliptic 2000 and of date * - ******************************************/ - swi_check_ecliptic(tjd); + if (iflag & SEFLG_MOSEPH) + epheflag = SEFLG_MOSEPH; + if (iflag & SEFLG_SWIEPH) + epheflag = SEFLG_SWIEPH; + if (iflag & SEFLG_JPLEPH) + epheflag = SEFLG_JPLEPH; + /* no barycentric calculations with Moshier ephemeris */ + if ((iflag & SEFLG_BARYCTR) && (iflag & SEFLG_MOSEPH)) { + if (serr != NULL) + strcpy(serr, "barycentric Moshier positions are not supported."); + return ERR; + } + if (epheflag != SEFLG_MOSEPH && !swed.ephe_path_is_set) + swe_set_ephe_path(NULL); + if ((iflag & SEFLG_SIDEREAL) && !swed.ayana_is_set) + swe_set_sid_mode(SE_SIDM_FAGAN_BRADLEY, 0, 0); + /****************************************** - * nutation * + * obliquity of ecliptic 2000 and of date * ******************************************/ - swi_check_nutation(tjd, iflag); - /****************************************** - * select planet and ephemeris * - * * - * ecliptic and nutation * + swi_check_ecliptic(tjd); + + /****************************************** + * nutation * ******************************************/ - if (ipl == SE_ECL_NUT) { - x[0] = swed.oec.eps + swed.nut.nutlo[1]; /* true ecliptic */ - x[1] = swed.oec.eps; /* mean ecliptic */ - x[2] = swed.nut.nutlo[0]; /* nutation in longitude */ - x[3] = swed.nut.nutlo[1]; /* nutation in obliquity */ - /*if ((iflag & SEFLG_RADIANS) == 0)*/ - for (i = 0; i <= 3; i++) - x[i] *= RADTODEG; - return(iflag); - /****************************************** - * moon * + swi_check_nutation(tjd, iflag); + + /****************************************** + * select planet and ephemeris * + * * + * ecliptic and nutation * ******************************************/ - } else if (ipl == SE_MOON) { - /* internal planet number */ - ipli = SEI_MOON; - pdp = &swed.pldat[ipli]; - xp = pdp->xreturn; - switch(epheflag) { + if (ipl == SE_ECL_NUT) { + x[0] = swed.oec.eps + swed.nut.nutlo[1]; /* true ecliptic */ + x[1] = swed.oec.eps; /* mean ecliptic */ + x[2] = swed.nut.nutlo[0]; /* nutation in longitude */ + x[3] = swed.nut.nutlo[1]; /* nutation in obliquity */ + /*if ((iflag & SEFLG_RADIANS) == 0) */ + for (i = 0; i <= 3; i++) + x[i] *= RADTODEG; + return (iflag); + + /****************************************** + * moon * + ******************************************/ + } + else if (ipl == SE_MOON) { + /* internal planet number */ + ipli = SEI_MOON; + pdp = &swed.pldat[ipli]; + xp = pdp->xreturn; + switch (epheflag) { #ifndef NO_JPL - case SEFLG_JPLEPH: - retc = jplplan(tjd, ipli, iflag, DO_SAVE, NULL, NULL, NULL, serr); - /* read error or corrupt file */ - if (retc == ERR) - goto return_error; - /* jpl ephemeris not on disk or date beyond ephemeris range - * or file corrupt */ - if (retc == NOT_AVAILABLE) { - iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_SWIEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, " \ntrying Swiss Eph; "); - goto sweph_moon; - } else if (retc == BEYOND_EPH_LIMITS) { - if (tjd > MOSHLUEPH_START && tjd < MOSHLUEPH_END) { - iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_MOSEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, " \nusing Moshier Eph; "); - goto moshier_moon; - } else - goto return_error; - } - break; + case SEFLG_JPLEPH: + retc = + jplplan(tjd, ipli, iflag, DO_SAVE, NULL, NULL, NULL, + serr); + /* read error or corrupt file */ + if (retc == ERR) + goto return_error; + /* jpl ephemeris not on disk or date beyond ephemeris range + * or file corrupt */ + if (retc == NOT_AVAILABLE) { + iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_SWIEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, " \ntrying Swiss Eph; "); + goto sweph_moon; + } + else if (retc == BEYOND_EPH_LIMITS) { + if (tjd > MOSHLUEPH_START && tjd < MOSHLUEPH_END) { + iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_MOSEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, " \nusing Moshier Eph; "); + goto moshier_moon; + } + else + goto return_error; + } + break; #endif - case SEFLG_SWIEPH: - sweph_moon: + case SEFLG_SWIEPH: +sweph_moon: #if 0 - /* for hel. or bary. position, we need earth and sun as well; - * this is done by sweplan(), but not by swemoon() */ - if (iflag & (SEFLG_HELCTR | SEFLG_BARYCTR | SEFLG_NOABERR)) - retc = sweplan(tjd, ipli, SEI_FILE_MOON, iflag, DO_SAVE, - NULL, NULL, NULL, NULL, serr); - else - retc = swemoon(tjd, iflag, DO_SAVE, pdp->x, serr);/**/ + /* for hel. or bary. position, we need earth and sun as well; + * this is done by sweplan(), but not by swemoon() */ + if (iflag & (SEFLG_HELCTR | SEFLG_BARYCTR | SEFLG_NOABERR)) + retc = + sweplan(tjd, ipli, SEI_FILE_MOON, iflag, DO_SAVE, + NULL, NULL, NULL, NULL, serr); + else + retc = swemoon(tjd, iflag, DO_SAVE, pdp->x, serr); + /**/ #else - retc = sweplan(tjd, ipli, SEI_FILE_MOON, iflag, DO_SAVE, - NULL, NULL, NULL, NULL, serr); + retc = + sweplan(tjd, ipli, SEI_FILE_MOON, iflag, DO_SAVE, NULL, + NULL, NULL, NULL, serr); #endif - if (retc == ERR) - goto return_error; - /* if sweph file not found, switch to moshier */ - if (retc == NOT_AVAILABLE) { - if (tjd > MOSHLUEPH_START && tjd < MOSHLUEPH_END) { - iflag = (iflag & ~SEFLG_SWIEPH) | SEFLG_MOSEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, " \nusing Moshier eph.; "); - goto moshier_moon; - } else - goto return_error; - } - break; - case SEFLG_MOSEPH: - moshier_moon: - retc = swi_moshmoon(tjd, DO_SAVE, NULL, serr);/**/ - if (retc == ERR) - goto return_error; - /* for hel. position, we need earth as well */ - retc = swi_moshplan(tjd, SEI_EARTH, DO_SAVE, NULL, NULL, serr);/**/ - if (retc == ERR) - goto return_error; - break; - default: - break; - } - /* heliocentric, lighttime etc. */ - if ((retc = app_pos_etc_moon(iflag, serr)) != OK) - goto return_error; /* retc may be wrong with sidereal calculation */ - /********************************************** - * barycentric sun * + if (retc == ERR) + goto return_error; + /* if sweph file not found, switch to moshier */ + if (retc == NOT_AVAILABLE) { + if (tjd > MOSHLUEPH_START && tjd < MOSHLUEPH_END) { + iflag = (iflag & ~SEFLG_SWIEPH) | SEFLG_MOSEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, " \nusing Moshier eph.; "); + goto moshier_moon; + } + else + goto return_error; + } + break; + case SEFLG_MOSEPH: +moshier_moon: + retc = swi_moshmoon(tjd, DO_SAVE, NULL, serr); + /**/ if (retc == ERR) + goto return_error; + /* for hel. position, we need earth as well */ + retc = + swi_moshplan(tjd, SEI_EARTH, DO_SAVE, NULL, NULL, serr); + /**/ if (retc == ERR) + goto return_error; + break; + default: + break; + } + /* heliocentric, lighttime etc. */ + if ((retc = app_pos_etc_moon(iflag, serr)) != OK) + goto return_error; /* retc may be wrong with sidereal calculation */ + + /********************************************** + * barycentric sun * * (only JPL and SWISSEPH ephemerises) * **********************************************/ - } else if (ipl == SE_SUN && (iflag & SEFLG_BARYCTR)) { - /* barycentric sun must be handled separately because of - * the following reasons: - * ordinary planetary computations use the function - * main_planet() and its subfunction jplplan(), - * see further below. - * now, these functions need the swisseph internal - * planetary indices, where SEI_EARTH = SEI_SUN = 0. - * therefore they don't know the difference between - * a barycentric sun and a barycentric earth and - * always return barycentric earth. - * to avoid this problem, many functions would have to - * be changed. as an alternative, we choose a more - * separate handling. */ - ipli = SEI_SUN; /* = SEI_EARTH ! */ - xp = pedp->xreturn; - switch(epheflag) { + } + else if (ipl == SE_SUN && (iflag & SEFLG_BARYCTR)) { + /* barycentric sun must be handled separately because of + * the following reasons: + * ordinary planetary computations use the function + * main_planet() and its subfunction jplplan(), + * see further below. + * now, these functions need the swisseph internal + * planetary indices, where SEI_EARTH = SEI_SUN = 0. + * therefore they don't know the difference between + * a barycentric sun and a barycentric earth and + * always return barycentric earth. + * to avoid this problem, many functions would have to + * be changed. as an alternative, we choose a more + * separate handling. */ + ipli = SEI_SUN; /* = SEI_EARTH ! */ + xp = pedp->xreturn; + switch (epheflag) { #ifndef NO_JPL - case SEFLG_JPLEPH: - /* open ephemeris, if still closed */ - if (!swed.jpl_file_is_open) { - retc = swi_open_jpl_file(ss, swed.jplfnam, swed.ephepath, serr); - if (retc != OK) - goto sweph_sbar; - swed.jpldenum = swi_get_jpl_denum(); - swed.jpl_file_is_open = TRUE; - } - retc = swi_pleph(tjd, J_SUN, J_SBARY, psdp->x, serr); - if (retc == ERR || retc == BEYOND_EPH_LIMITS) { - swi_close_jpl_file(); - swed.jpl_file_is_open = FALSE; - goto return_error; - } - /* jpl ephemeris not on disk or date beyond ephemeris range - * or file corrupt */ - if (retc == NOT_AVAILABLE) { - iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_SWIEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, " \ntrying Swiss Eph; "); - goto sweph_sbar; - } - psdp->teval = tjd; - break; + case SEFLG_JPLEPH: + /* open ephemeris, if still closed */ + if (!swed.jpl_file_is_open) { + retc = + swi_open_jpl_file(ss, swed.jplfnam, swed.ephepath, + serr); + if (retc != OK) + goto sweph_sbar; + swed.jpldenum = swi_get_jpl_denum(); + swed.jpl_file_is_open = TRUE; + } + retc = swi_pleph(tjd, J_SUN, J_SBARY, psdp->x, serr); + if (retc == ERR || retc == BEYOND_EPH_LIMITS) { + swi_close_jpl_file(); + swed.jpl_file_is_open = FALSE; + goto return_error; + } + /* jpl ephemeris not on disk or date beyond ephemeris range + * or file corrupt */ + if (retc == NOT_AVAILABLE) { + iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_SWIEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, " \ntrying Swiss Eph; "); + goto sweph_sbar; + } + psdp->teval = tjd; + break; #endif - case SEFLG_SWIEPH: - sweph_sbar: - /* sweplan() provides barycentric sun as a by-product in save area; - * it is saved in swed.pldat[SEI_SUNBARY].x */ - retc = sweplan(tjd, SEI_EARTH, SEI_FILE_PLANET, iflag, DO_SAVE, NULL, NULL, NULL, NULL, serr); + case SEFLG_SWIEPH: +sweph_sbar: + /* sweplan() provides barycentric sun as a by-product in save area; + * it is saved in swed.pldat[SEI_SUNBARY].x */ + retc = + sweplan(tjd, SEI_EARTH, SEI_FILE_PLANET, iflag, DO_SAVE, + NULL, NULL, NULL, NULL, serr); #if 1 - if (retc == ERR || retc == NOT_AVAILABLE) - goto return_error; -#else /* this code would be needed if barycentric moshier calculation - * were implemented */ - if (retc == ERR) - goto return_error; - /* if sweph file not found, switch to moshier */ - if (retc == NOT_AVAILABLE) { - if (tjd > MOSHLUEPH_START && tjd < MOSHLUEPH_END) { - iflag = (iflag & ~SEFLG_SWIEPH) | SEFLG_MOSEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, " \nusing Moshier; "); - goto moshier_sbar; - } else - goto return_error; - } + if (retc == ERR || retc == NOT_AVAILABLE) + goto return_error; +#else /* this code would be needed if barycentric moshier calculation + * were implemented */ + if (retc == ERR) + goto return_error; + /* if sweph file not found, switch to moshier */ + if (retc == NOT_AVAILABLE) { + if (tjd > MOSHLUEPH_START && tjd < MOSHLUEPH_END) { + iflag = (iflag & ~SEFLG_SWIEPH) | SEFLG_MOSEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, " \nusing Moshier; "); + goto moshier_sbar; + } + else + goto return_error; + } #endif - psdp->teval = tjd; - /* pedp->teval = tjd; */ - break; - default: + psdp->teval = tjd; + /* pedp->teval = tjd; */ + break; + default: #if 0 - moshier_sbar: +moshier_sbar: #endif - return ERR; - break; - } - /* flags */ - if ((retc = app_pos_etc_sbar(iflag, serr)) != OK) - goto return_error; - /* iflag has possibly changed */ - iflag = pedp->xflgs; - /* barycentric sun is now in save area of barycentric earth. - * (pedp->xreturn = swed.pldat[SEI_EARTH].xreturn). - * in case a barycentric earth computation follows for the same - * date, the planetary functions will return the barycentric - * SUN unless we force a new computation of pedp->xreturn. - * this can be done by initializing the save of iflag. - */ - pedp->xflgs = -1; - /****************************************** - * mercury - pluto * + return ERR; + break; + } + /* flags */ + if ((retc = app_pos_etc_sbar(iflag, serr)) != OK) + goto return_error; + /* iflag has possibly changed */ + iflag = pedp->xflgs; + /* barycentric sun is now in save area of barycentric earth. + * (pedp->xreturn = swed.pldat[SEI_EARTH].xreturn). + * in case a barycentric earth computation follows for the same + * date, the planetary functions will return the barycentric + * SUN unless we force a new computation of pedp->xreturn. + * this can be done by initializing the save of iflag. + */ + pedp->xflgs = -1; + + /****************************************** + * mercury - pluto * ******************************************/ - } else if (ipl == SE_SUN /* main planet */ - || ipl == SE_MERCURY - || ipl == SE_VENUS - || ipl == SE_MARS - || ipl == SE_JUPITER - || ipl == SE_SATURN - || ipl == SE_URANUS - || ipl == SE_NEPTUNE - || ipl == SE_PLUTO - || ipl == SE_EARTH) { - if (iflag & SEFLG_HELCTR) { - if (ipl == SE_SUN) { - /* heliocentric position of Sun does not exist */ - for (i = 0; i < 24; i++) - x[i] = 0; - return iflag; - } - } else if (iflag & SEFLG_BARYCTR) { - ; - } else { /* geocentric */ - if (ipl == SE_EARTH) { - /* geocentric position of Earth does not exist */ - for (i = 0; i < 24; i++) - x[i] = 0; - return iflag; - } } - /* internal planet number */ - ipli = pnoext2int[ipl]; - pdp = &swed.pldat[ipli]; - xp = pdp->xreturn; - retc = main_planet(tjd, ipli, epheflag, iflag, serr); - if (retc == ERR) - goto return_error; - /* iflag has possibly changed in main_planet() */ - iflag = pdp->xflgs; - /*********************i************************ - * mean lunar node * + else if (ipl == SE_SUN /* main planet */ + || ipl == SE_MERCURY || ipl == SE_VENUS || ipl == SE_MARS + || ipl == SE_JUPITER || ipl == SE_SATURN || ipl == SE_URANUS + || ipl == SE_NEPTUNE || ipl == SE_PLUTO || ipl == SE_EARTH) { + if (iflag & SEFLG_HELCTR) { + if (ipl == SE_SUN) { + /* heliocentric position of Sun does not exist */ + for (i = 0; i < 24; i++) + x[i] = 0; + return iflag; + } + } + else if (iflag & SEFLG_BARYCTR) { + ; + } + else { /* geocentric */ + if (ipl == SE_EARTH) { + /* geocentric position of Earth does not exist */ + for (i = 0; i < 24; i++) + x[i] = 0; + return iflag; + } + } + /* internal planet number */ + ipli = pnoext2int[ipl]; + pdp = &swed.pldat[ipli]; + xp = pdp->xreturn; + retc = main_planet(tjd, ipli, epheflag, iflag, serr); + if (retc == ERR) + goto return_error; + /* iflag has possibly changed in main_planet() */ + iflag = pdp->xflgs; + + /*********************i************************ + * mean lunar node * * for comment s. moshmoon.c, swi_mean_node() * **********************************************/ - } else if (ipl == SE_MEAN_NODE) { - if ((iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) { - /* heliocentric/barycentric lunar node not allowed */ - for (i = 0; i < 24; i++) - x[i] = 0; - return iflag; } - ndp = &swed.nddat[SEI_MEAN_NODE]; - xp = ndp->xreturn; - xp2 = ndp->x; - retc = swi_mean_node(tjd, xp2, serr); - if (retc == ERR) - goto return_error; - /* speed (is almost constant; variation < 0.001 arcsec) */ - retc = swi_mean_node(tjd - MEAN_NODE_SPEED_INTV, xp2+3, serr); - if (retc == ERR) - goto return_error; - xp2[3] = swe_difrad2n(xp2[0], xp2[3]) / MEAN_NODE_SPEED_INTV; - xp2[4] = xp2[5] = 0; - ndp->teval = tjd; - ndp->xflgs = -1; - /* lighttime etc. */ - if ((retc = app_pos_etc_mean(SEI_MEAN_NODE, iflag, serr)) != OK) - goto return_error; - /* to avoid infinitesimal deviations from latitude = 0 - * that result from conversions */ - if (!(iflag & SEFLG_SIDEREAL) && !(iflag & SEFLG_J2000)) { - ndp->xreturn[1] = 0.0; /* ecl. latitude */ - ndp->xreturn[4] = 0.0; /* speed */ - ndp->xreturn[5] = 0.0; /* radial speed */ - ndp->xreturn[8] = 0.0; /* z coordinate */ - ndp->xreturn[11] = 0.0; /* speed */ - } - if (retc == ERR) - goto return_error; - /********************************************** + else if (ipl == SE_MEAN_NODE) { + if ((iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) { + /* heliocentric/barycentric lunar node not allowed */ + for (i = 0; i < 24; i++) + x[i] = 0; + return iflag; + } + ndp = &swed.nddat[SEI_MEAN_NODE]; + xp = ndp->xreturn; + xp2 = ndp->x; + retc = swi_mean_node(tjd, xp2, serr); + if (retc == ERR) + goto return_error; + /* speed (is almost constant; variation < 0.001 arcsec) */ + retc = swi_mean_node(tjd - MEAN_NODE_SPEED_INTV, xp2 + 3, serr); + if (retc == ERR) + goto return_error; + xp2[3] = swe_difrad2n(xp2[0], xp2[3]) / MEAN_NODE_SPEED_INTV; + xp2[4] = xp2[5] = 0; + ndp->teval = tjd; + ndp->xflgs = -1; + /* lighttime etc. */ + if ((retc = app_pos_etc_mean(SEI_MEAN_NODE, iflag, serr)) != OK) + goto return_error; + /* to avoid infinitesimal deviations from latitude = 0 + * that result from conversions */ + if (!(iflag & SEFLG_SIDEREAL) && !(iflag & SEFLG_J2000)) { + ndp->xreturn[1] = 0.0; /* ecl. latitude */ + ndp->xreturn[4] = 0.0; /* speed */ + ndp->xreturn[5] = 0.0; /* radial speed */ + ndp->xreturn[8] = 0.0; /* z coordinate */ + ndp->xreturn[11] = 0.0; /* speed */ + } + if (retc == ERR) + goto return_error; + + /********************************************** * mean lunar apogee ('dark moon', 'lilith') * * for comment s. moshmoon.c, swi_mean_apog() * **********************************************/ - } else if (ipl == SE_MEAN_APOG) { - if ((iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) { - /* heliocentric/barycentric lunar apogee not allowed */ - for (i = 0; i < 24; i++) - x[i] = 0; - return iflag; } - ndp = &swed.nddat[SEI_MEAN_APOG]; - xp = ndp->xreturn; - xp2 = ndp->x; - retc = swi_mean_apog(tjd, xp2, serr); - if (retc == ERR) - goto return_error; - /* speed (is not constant! variation ~= several arcsec) */ - retc = swi_mean_apog(tjd - MEAN_NODE_SPEED_INTV, xp2+3, serr); - if (retc == ERR) - goto return_error; - for(i = 0; i <= 1; i++) - xp2[3+i] = swe_difrad2n(xp2[i], xp2[3+i]) / MEAN_NODE_SPEED_INTV; - xp2[5] = 0; - ndp->teval = tjd; - ndp->xflgs = -1; - /* lighttime etc. */ - if ((retc = app_pos_etc_mean(SEI_MEAN_APOG, iflag, serr)) != OK) - goto return_error; - /* to avoid infinitesimal deviations from r-speed = 0 - * that result from conversions */ - ndp->xreturn[5] = 0.0; /* speed */ - if (retc == ERR) - goto return_error; - /*********************************************** - * osculating lunar node ('true node') * + else if (ipl == SE_MEAN_APOG) { + if ((iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) { + /* heliocentric/barycentric lunar apogee not allowed */ + for (i = 0; i < 24; i++) + x[i] = 0; + return iflag; + } + ndp = &swed.nddat[SEI_MEAN_APOG]; + xp = ndp->xreturn; + xp2 = ndp->x; + retc = swi_mean_apog(tjd, xp2, serr); + if (retc == ERR) + goto return_error; + /* speed (is not constant! variation ~= several arcsec) */ + retc = swi_mean_apog(tjd - MEAN_NODE_SPEED_INTV, xp2 + 3, serr); + if (retc == ERR) + goto return_error; + for (i = 0; i <= 1; i++) + xp2[3 + i] = + swe_difrad2n(xp2[i], xp2[3 + i]) / MEAN_NODE_SPEED_INTV; + xp2[5] = 0; + ndp->teval = tjd; + ndp->xflgs = -1; + /* lighttime etc. */ + if ((retc = app_pos_etc_mean(SEI_MEAN_APOG, iflag, serr)) != OK) + goto return_error; + /* to avoid infinitesimal deviations from r-speed = 0 + * that result from conversions */ + ndp->xreturn[5] = 0.0; /* speed */ + if (retc == ERR) + goto return_error; + + /*********************************************** + * osculating lunar node ('true node') * ***********************************************/ - } else if (ipl == SE_TRUE_NODE) { - if ((iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) { - /* heliocentric/barycentric lunar node not allowed */ - for (i = 0; i < 24; i++) - x[i] = 0; - return iflag; } - ndp = &swed.nddat[SEI_TRUE_NODE]; - xp = ndp->xreturn; - retc = lunar_osc_elem(tjd, SEI_TRUE_NODE, iflag, serr); - iflag = ndp->xflgs; - /* to avoid infinitesimal deviations from latitude = 0 - * that result from conversions */ - if (!(iflag & SEFLG_SIDEREAL) && !(iflag & SEFLG_J2000)) { - ndp->xreturn[1] = 0.0; /* ecl. latitude */ - ndp->xreturn[4] = 0.0; /* speed */ - ndp->xreturn[8] = 0.0; /* z coordinate */ - ndp->xreturn[11] = 0.0; /* speed */ - } - if (retc == ERR) - goto return_error; - /*********************************************** - * osculating lunar apogee * + else if (ipl == SE_TRUE_NODE) { + if ((iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) { + /* heliocentric/barycentric lunar node not allowed */ + for (i = 0; i < 24; i++) + x[i] = 0; + return iflag; + } + ndp = &swed.nddat[SEI_TRUE_NODE]; + xp = ndp->xreturn; + retc = lunar_osc_elem(tjd, SEI_TRUE_NODE, iflag, serr); + iflag = ndp->xflgs; + /* to avoid infinitesimal deviations from latitude = 0 + * that result from conversions */ + if (!(iflag & SEFLG_SIDEREAL) && !(iflag & SEFLG_J2000)) { + ndp->xreturn[1] = 0.0; /* ecl. latitude */ + ndp->xreturn[4] = 0.0; /* speed */ + ndp->xreturn[8] = 0.0; /* z coordinate */ + ndp->xreturn[11] = 0.0; /* speed */ + } + if (retc == ERR) + goto return_error; + + /*********************************************** + * osculating lunar apogee * ***********************************************/ - } else if (ipl == SE_OSCU_APOG) { - if ((iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) { - /* heliocentric/barycentric lunar apogee not allowed */ - for (i = 0; i < 24; i++) - x[i] = 0; - return iflag; } - ndp = &swed.nddat[SEI_OSCU_APOG]; - xp = ndp->xreturn; - retc = lunar_osc_elem(tjd, SEI_OSCU_APOG, iflag, serr); - iflag = ndp->xflgs; - if (retc == ERR) - goto return_error; - /*********************************************** - * interpolated lunar apogee * + else if (ipl == SE_OSCU_APOG) { + if ((iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) { + /* heliocentric/barycentric lunar apogee not allowed */ + for (i = 0; i < 24; i++) + x[i] = 0; + return iflag; + } + ndp = &swed.nddat[SEI_OSCU_APOG]; + xp = ndp->xreturn; + retc = lunar_osc_elem(tjd, SEI_OSCU_APOG, iflag, serr); + iflag = ndp->xflgs; + if (retc == ERR) + goto return_error; + + /*********************************************** + * interpolated lunar apogee * ***********************************************/ - } else if (ipl == SE_INTP_APOG) { - if ((iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) { - /* heliocentric/barycentric lunar apogee not allowed */ - for (i = 0; i < 24; i++) - x[i] = 0; - return iflag; } - ndp = &swed.nddat[SEI_INTP_APOG]; - xp = ndp->xreturn; - retc = intp_apsides(tjd, SEI_INTP_APOG, iflag, serr); - iflag = ndp->xflgs; - if (retc == ERR) - goto return_error; - /*********************************************** - * interpolated lunar perigee * + else if (ipl == SE_INTP_APOG) { + if ((iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) { + /* heliocentric/barycentric lunar apogee not allowed */ + for (i = 0; i < 24; i++) + x[i] = 0; + return iflag; + } + ndp = &swed.nddat[SEI_INTP_APOG]; + xp = ndp->xreturn; + retc = intp_apsides(tjd, SEI_INTP_APOG, iflag, serr); + iflag = ndp->xflgs; + if (retc == ERR) + goto return_error; + + /*********************************************** + * interpolated lunar perigee * ***********************************************/ - } else if (ipl == SE_INTP_PERG) { - if ((iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) { - /* heliocentric/barycentric lunar apogee not allowed */ - for (i = 0; i < 24; i++) - x[i] = 0; - return iflag; } - ndp = &swed.nddat[SEI_INTP_PERG]; - xp = ndp->xreturn; - retc = intp_apsides(tjd, SEI_INTP_PERG, iflag, serr); - iflag = ndp->xflgs; - if (retc == ERR) - goto return_error; - /*********************************************** - * minor planets * + else if (ipl == SE_INTP_PERG) { + if ((iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) { + /* heliocentric/barycentric lunar apogee not allowed */ + for (i = 0; i < 24; i++) + x[i] = 0; + return iflag; + } + ndp = &swed.nddat[SEI_INTP_PERG]; + xp = ndp->xreturn; + retc = intp_apsides(tjd, SEI_INTP_PERG, iflag, serr); + iflag = ndp->xflgs; + if (retc == ERR) + goto return_error; + + /*********************************************** + * minor planets * ***********************************************/ - } else if (ipl == SE_CHIRON - || ipl == SE_PHOLUS - || ipl == SE_CERES /* Ceres - Vesta */ - || ipl == SE_PALLAS - || ipl == SE_JUNO - || ipl == SE_VESTA - || ipl > SE_AST_OFFSET) { - /* internal planet number */ - if (ipl < SE_NPLANETS) - ipli = pnoext2int[ipl]; - else if (ipl <= SE_AST_OFFSET + MPC_VESTA) { - ipli = SEI_CERES + ipl - SE_AST_OFFSET - 1; - ipl = SE_CERES + ipl - SE_AST_OFFSET - 1; + } + else if (ipl == SE_CHIRON || ipl == SE_PHOLUS || ipl == SE_CERES /* Ceres - Vesta */ + || ipl == SE_PALLAS || ipl == SE_JUNO || ipl == SE_VESTA + || ipl > SE_AST_OFFSET) { + /* internal planet number */ + if (ipl < SE_NPLANETS) + ipli = pnoext2int[ipl]; + else if (ipl <= SE_AST_OFFSET + MPC_VESTA) { + ipli = SEI_CERES + ipl - SE_AST_OFFSET - 1; + ipl = SE_CERES + ipl - SE_AST_OFFSET - 1; #if 0 - } else if (ipl == SE_AST_OFFSET + MPC_CHIRON) { - ipli = SEI_CHIRON; - ipl = SE_CHIRON; - } else if (ipl == SE_AST_OFFSET + MPC_PHOLUS) { - ipli = SEI_PHOLUS; - ipl = SE_PHOLUS; + } + else if (ipl == SE_AST_OFFSET + MPC_CHIRON) { + ipli = SEI_CHIRON; + ipl = SE_CHIRON; + } + else if (ipl == SE_AST_OFFSET + MPC_PHOLUS) { + ipli = SEI_PHOLUS; + ipl = SE_PHOLUS; #endif - } else /* any asteroid except*/ - ipli = SEI_ANYBODY; - if (ipli == SEI_ANYBODY) - ipli_ast = ipl; - else - ipli_ast = ipli; - pdp = &swed.pldat[ipli]; - xp = pdp->xreturn; - if (ipli_ast > SE_AST_OFFSET) - ifno = SEI_FILE_ANY_AST; - else - ifno = SEI_FILE_MAIN_AST; - if (ipli == SEI_CHIRON && (tjd < CHIRON_START || tjd > CHIRON_END)) { - if (serr != NULL) - sprintf(serr, "Chiron's ephemeris is restricted to JD %8.1f - JD %8.1f", - CHIRON_START, CHIRON_END); - return ERR; - } - if (ipli == SEI_PHOLUS && tjd < PHOLUS_START) { - if (serr != NULL) - sprintf(serr, - "Pholus's ephemeris is restricted to the time after JD %8.1f", - PHOLUS_START); - return ERR; - } - do_asteroid: - /* earth and sun are also needed */ - retc = main_planet(tjd, SEI_EARTH, epheflag, iflag, serr); - if (retc == ERR) - goto return_error; - /* iflag (ephemeris bit) has possibly changed in main_planet() */ - iflag = swed.pldat[SEI_EARTH].xflgs; - /* asteroid */ - if (serr != NULL) { - strcpy(serr2, serr); - *serr = '\0'; - } - /* asteroid */ - retc = sweph(tjd, ipli_ast, ifno, iflag, psdp->x, DO_SAVE, NULL, serr); - if (retc == ERR || retc == NOT_AVAILABLE) - goto return_error; - retc = app_pos_etc_plan(ipli_ast, iflag, serr); - if (retc == ERR) - goto return_error; - /* app_pos_etc_plan() might have failed, if t(light-time) - * is beyond ephemeris range. in this case redo with Moshier - */ - if (retc == NOT_AVAILABLE || retc == BEYOND_EPH_LIMITS) { - if (epheflag != SEFLG_MOSEPH) { - iflag = (iflag & ~SEFLG_EPHMASK) | SEFLG_MOSEPH; - epheflag = SEFLG_MOSEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, "\nusing Moshier eph.; "); - goto do_asteroid; - } else - goto return_error; - } - /* add warnings from earth/sun computation */ - if (serr != NULL && *serr == '\0' && *serr2 != '\0') { - strcpy(serr, "sun: "); - serr2[AS_MAXCH-5] = '\0'; - strcat(serr, serr2); - } - /*********************************************** - * fictitious planets * + } + else /* any asteroid except */ + ipli = SEI_ANYBODY; + if (ipli == SEI_ANYBODY) + ipli_ast = ipl; + else + ipli_ast = ipli; + pdp = &swed.pldat[ipli]; + xp = pdp->xreturn; + if (ipli_ast > SE_AST_OFFSET) + ifno = SEI_FILE_ANY_AST; + else + ifno = SEI_FILE_MAIN_AST; + if (ipli == SEI_CHIRON && (tjd < CHIRON_START || tjd > CHIRON_END)) { + if (serr != NULL) + sprintf(serr, + "Chiron's ephemeris is restricted to JD %8.1f - JD %8.1f", + CHIRON_START, CHIRON_END); + return ERR; + } + if (ipli == SEI_PHOLUS && tjd < PHOLUS_START) { + if (serr != NULL) + sprintf(serr, + "Pholus's ephemeris is restricted to the time after JD %8.1f", + PHOLUS_START); + return ERR; + } +do_asteroid: + /* earth and sun are also needed */ + retc = main_planet(tjd, SEI_EARTH, epheflag, iflag, serr); + if (retc == ERR) + goto return_error; + /* iflag (ephemeris bit) has possibly changed in main_planet() */ + iflag = swed.pldat[SEI_EARTH].xflgs; + /* asteroid */ + if (serr != NULL) { + strcpy(serr2, serr); + *serr = '\0'; + } + /* asteroid */ + retc = + sweph(tjd, ipli_ast, ifno, iflag, psdp->x, DO_SAVE, NULL, serr); + if (retc == ERR || retc == NOT_AVAILABLE) + goto return_error; + retc = app_pos_etc_plan(ipli_ast, iflag, serr); + if (retc == ERR) + goto return_error; + /* app_pos_etc_plan() might have failed, if t(light-time) + * is beyond ephemeris range. in this case redo with Moshier + */ + if (retc == NOT_AVAILABLE || retc == BEYOND_EPH_LIMITS) { + if (epheflag != SEFLG_MOSEPH) { + iflag = (iflag & ~SEFLG_EPHMASK) | SEFLG_MOSEPH; + epheflag = SEFLG_MOSEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, "\nusing Moshier eph.; "); + goto do_asteroid; + } + else + goto return_error; + } + /* add warnings from earth/sun computation */ + if (serr != NULL && *serr == '\0' && *serr2 != '\0') { + strcpy(serr, "sun: "); + serr2[AS_MAXCH - 5] = '\0'; + strcat(serr, serr2); + } + + /*********************************************** + * fictitious planets * * (Isis-Transpluto and Uranian planets) * ***********************************************/ - } else if (ipl >= SE_FICT_OFFSET && ipl <= SE_FICT_MAX) { + } + else if (ipl >= SE_FICT_OFFSET && ipl <= SE_FICT_MAX) { #if 0 - ipl == SE_CUPIDO - || ipl == SE_HADES - || ipl == SE_ZEUS - || ipl == SE_KRONOS - || ipl == SE_APOLLON - || ipl == SE_ADMETOS - || ipl == SE_VULKANUS - || ipl == SE_POSEIDON - || ipl == SE_ISIS - || ipl == SE_NEPTUNE_LEVERRIER - || ipl == SE_NEPTUNE_ADAMS) + ipl == SE_CUPIDO || ipl == SE_HADES || ipl == SE_ZEUS + || ipl == SE_KRONOS || ipl == SE_APOLLON || ipl == SE_ADMETOS + || ipl == SE_VULKANUS || ipl == SE_POSEIDON || ipl == SE_ISIS + || ipl == SE_NEPTUNE_LEVERRIER || ipl == SE_NEPTUNE_ADAMS #endif - /* internal planet number */ - ipli = SEI_ANYBODY; - pdp = &swed.pldat[ipli]; - xp = pdp->xreturn; - do_fict_plan: - /* the earth for geocentric position */ - retc = main_planet(tjd, SEI_EARTH, epheflag, iflag, serr); - /* iflag (ephemeris bit) has possibly changed in main_planet() */ - iflag = swed.pldat[SEI_EARTH].xflgs; - /* planet from osculating elements */ - if (swi_osc_el_plan(tjd, pdp->x, ipl-SE_FICT_OFFSET, ipli, pedp->x, psdp->x, serr) != OK) - goto return_error; - if (retc == ERR) - goto return_error; - retc = app_pos_etc_plan_osc(ipl, ipli, iflag, serr); - if (retc == ERR) - goto return_error; - /* app_pos_etc_plan_osc() might have failed, if t(light-time) - * is beyond ephemeris range. in this case redo with Moshier - */ - if (retc == NOT_AVAILABLE || retc == BEYOND_EPH_LIMITS) { - if (epheflag != SEFLG_MOSEPH) { - iflag = (iflag & ~SEFLG_EPHMASK) | SEFLG_MOSEPH; - epheflag = SEFLG_MOSEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, "\nusing Moshier eph.; "); - goto do_fict_plan; - } else - goto return_error; - } - /*********************************************** - * invalid body number * + /* internal planet number */ + ipli = SEI_ANYBODY; + pdp = &swed.pldat[ipli]; + xp = pdp->xreturn; +do_fict_plan: + /* the earth for geocentric position */ + retc = main_planet(tjd, SEI_EARTH, epheflag, iflag, serr); + /* iflag (ephemeris bit) has possibly changed in main_planet() */ + iflag = swed.pldat[SEI_EARTH].xflgs; + /* planet from osculating elements */ + if (swi_osc_el_plan + (tjd, pdp->x, ipl - SE_FICT_OFFSET, ipli, pedp->x, psdp->x, + serr) != OK) + goto return_error; + if (retc == ERR) + goto return_error; + retc = app_pos_etc_plan_osc(ipl, ipli, iflag, serr); + if (retc == ERR) + goto return_error; + /* app_pos_etc_plan_osc() might have failed, if t(light-time) + * is beyond ephemeris range. in this case redo with Moshier + */ + if (retc == NOT_AVAILABLE || retc == BEYOND_EPH_LIMITS) { + if (epheflag != SEFLG_MOSEPH) { + iflag = (iflag & ~SEFLG_EPHMASK) | SEFLG_MOSEPH; + epheflag = SEFLG_MOSEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, "\nusing Moshier eph.; "); + goto do_fict_plan; + } + else + goto return_error; + } + + /*********************************************** + * invalid body number * ***********************************************/ - } else { - if (serr != NULL) { - sprintf(serr, "illegal planet number %d.", ipl); } - goto return_error; - } - for (i = 0; i < 24; i++) - x[i] = xp[i]; - return(iflag); - /*********************************************** - * return error * + else { + if (serr != NULL) { + sprintf(serr, "illegal planet number %d.", ipl); + } + goto return_error; + } + for (i = 0; i < 24; i++) + x[i] = xp[i]; + return (iflag); + + /*********************************************** + * return error * ***********************************************/ - return_error:; - for (i = 0; i < 24; i++) - x[i] = 0; - return ERR; +return_error:; + for (i = 0; i < 24; i++) + x[i] = 0; + return ERR; } -/* closes all open files, frees space of planetary data, - * deletes memory of all computed positions +/* closes all open files, frees space of planetary data, + * deletes memory of all computed positions */ -void FAR PASCAL_CONV swe_close(void) +void FAR PASCAL_CONV +swe_close(void) { - int i; - /* close SWISSEPH files */ - for (i = 0; i < SEI_NEPHFILES; i ++) { - if (swed.fidat[i].fptr != NULL) - fclose(swed.fidat[i].fptr); - memset((void *) &swed.fidat[i], 0, sizeof(struct file_data)); - } - /* free planets data space */ - for (i = 0; i < SEI_NPLANETS; i++) { - if (swed.pldat[i].segp != NULL) { - free((void *) swed.pldat[i].segp); + int i; + /* close SWISSEPH files */ + for (i = 0; i < SEI_NEPHFILES; i++) { + if (swed.fidat[i].fptr != NULL) + fclose(swed.fidat[i].fptr); + memset((void *)&swed.fidat[i], 0, sizeof(struct file_data)); } - if (swed.pldat[i].refep != NULL) { - free((void *) swed.pldat[i].refep); + /* free planets data space */ + for (i = 0; i < SEI_NPLANETS; i++) { + if (swed.pldat[i].segp != NULL) { + free((void *)swed.pldat[i].segp); + } + if (swed.pldat[i].refep != NULL) { + free((void *)swed.pldat[i].refep); + } + memset((void *)&swed.pldat[i], 0, sizeof(struct plan_data)); } - memset((void *) &swed.pldat[i], 0, sizeof(struct plan_data)); - } - for (i = 0; i <= SE_NPLANETS; i++) /* "<=" is correct! see decl. */ - memset((void *) &swed.savedat[i], 0, sizeof(struct save_positions)); - /* clear node data space */ - for (i = 0; i < SEI_NNODE_ETC; i++) { + for (i = 0; i <= SE_NPLANETS; i++) /* "<=" is correct! see decl. */ + memset((void *)&swed.savedat[i], 0, sizeof(struct save_positions)); + /* clear node data space */ + for (i = 0; i < SEI_NNODE_ETC; i++) { #if 0 - memset((void *) &swed.nddat[i], 0, sizeof(struct node_data)); + memset((void *)&swed.nddat[i], 0, sizeof(struct node_data)); #else - memset((void *) &swed.nddat[i], 0, sizeof(struct plan_data)); + memset((void *)&swed.nddat[i], 0, sizeof(struct plan_data)); #endif - } - memset((void *) &swed.oec, 0, sizeof(struct epsilon)); - memset((void *) &swed.oec2000, 0, sizeof(struct epsilon)); - memset((void *) &swed.nut, 0, sizeof(struct nut)); - memset((void *) &swed.nut2000, 0, sizeof(struct nut)); - memset((void *) &swed.nutv, 0, sizeof(struct nut)); - /* close JPL file */ + } + memset((void *)&swed.oec, 0, sizeof(struct epsilon)); + memset((void *)&swed.oec2000, 0, sizeof(struct epsilon)); + memset((void *)&swed.nut, 0, sizeof(struct nut)); + memset((void *)&swed.nut2000, 0, sizeof(struct nut)); + memset((void *)&swed.nutv, 0, sizeof(struct nut)); + /* close JPL file */ #ifndef NO_JPL - swi_close_jpl_file(); + swi_close_jpl_file(); #endif - swed.jpl_file_is_open = FALSE; - swed.jpldenum = 0; - /* close fixed stars */ - if (swed.fixfp != NULL) { - fclose(swed.fixfp); - swed.fixfp = NULL; - } + swed.jpl_file_is_open = FALSE; + swed.jpldenum = 0; + /* close fixed stars */ + if (swed.fixfp != NULL) { + fclose(swed.fixfp); + swed.fixfp = NULL; + } #ifdef TRACE #define TRACE_CLOSE FALSE - swi_open_trace(NULL); - if (swi_fp_trace_c != NULL) { - if (swi_trace_count < TRACE_COUNT_MAX) { - fputs("\n/*SWE_CLOSE*/\n", swi_fp_trace_c); - fputs(" swe_close();\n", swi_fp_trace_c); + swi_open_trace(NULL); + if (swi_fp_trace_c != NULL) { + if (swi_trace_count < TRACE_COUNT_MAX) { + fputs("\n/*SWE_CLOSE*/\n", swi_fp_trace_c); + fputs(" swe_close();\n", swi_fp_trace_c); #if TRACE_CLOSE - fputs("}\n", swi_fp_trace_c); + fputs("}\n", swi_fp_trace_c); +#endif + fflush(swi_fp_trace_c); + } +#if TRACE_CLOSE + fclose(swi_fp_trace_c); #endif - fflush(swi_fp_trace_c); } #if TRACE_CLOSE - fclose(swi_fp_trace_c); + if (swi_fp_trace_out != NULL) + fclose(swi_fp_trace_out); + swi_fp_trace_c = NULL; + swi_fp_trace_out = NULL; #endif - } -#if TRACE_CLOSE - if (swi_fp_trace_out != NULL) - fclose(swi_fp_trace_out); - swi_fp_trace_c = NULL; - swi_fp_trace_out = NULL; -#endif -#endif /* TRACE */ +#endif /* TRACE */ } -/* sets ephemeris file path. +/* sets ephemeris file path. * also calls swe_close(). this makes sure that swe_calc() * won't return planet positions previously computed from other * ephemerides */ -void FAR PASCAL_CONV swe_set_ephe_path(char *path) +void FAR PASCAL_CONV +swe_set_ephe_path(char *path) { - int i; - char s[AS_MAXCH]; - char *sp; - swed.ephe_path_is_set = TRUE; - /* close all open files and delete all planetary data */ - swe_close(); - /* environment variable SE_EPHE_PATH has priority */ - if ((sp = getenv("SE_EPHE_PATH")) != NULL - && strlen(sp) != 0 - && strlen(sp) <= AS_MAXCH-1-13) { - strcpy(s, sp); - } else if (path == NULL) { - strcpy(s, SE_EPHE_PATH); - } else if (strlen(path) <= AS_MAXCH-1-13) - strcpy(s, path); - else - strcpy(s, SE_EPHE_PATH); - i = strlen(s); - if (*(s + i - 1) != *DIR_GLUE && *s != '\0') - strcat(s, DIR_GLUE); - strcpy(swed.ephepath, s); + int i; + char s[AS_MAXCH]; + char *sp; + swed.ephe_path_is_set = TRUE; + /* close all open files and delete all planetary data */ + swe_close(); + /* environment variable SE_EPHE_PATH has priority */ + if ((sp = getenv("SE_EPHE_PATH")) != NULL && strlen(sp) != 0 + && strlen(sp) <= AS_MAXCH - 1 - 13) { + strcpy(s, sp); + } + else if (path == NULL) { + strcpy(s, SE_EPHE_PATH); + } + else if (strlen(path) <= AS_MAXCH - 1 - 13) + strcpy(s, path); + else + strcpy(s, SE_EPHE_PATH); + i = strlen(s); + if (*(s + i - 1) != *DIR_GLUE && *s != '\0') + strcat(s, DIR_GLUE); + strcpy(swed.ephepath, s); #ifdef TRACE - swi_open_trace(NULL); - if (swi_trace_count < TRACE_COUNT_MAX) { - if (swi_fp_trace_c != NULL) { - fputs("\n/*SWE_SET_EPHE_PATH*/\n", swi_fp_trace_c); - if (path == NULL) - fputs(" *s = '\\0';\n", swi_fp_trace_c); - else - fprintf(swi_fp_trace_c, " strcpy(s, \"%s\");\n", path); - fputs(" swe_set_ephe_path(s);\n", swi_fp_trace_c); - fputs(" printf(\"swe_set_ephe_path: path_in = \");", swi_fp_trace_c); - fputs(" printf(s);\n", swi_fp_trace_c); - fputs(" \tprintf(\"\\tpath_set = unknown to swetrace\\n\"); /* unknown to swetrace */\n", swi_fp_trace_c); - fflush(swi_fp_trace_c); + swi_open_trace(NULL); + if (swi_trace_count < TRACE_COUNT_MAX) { + if (swi_fp_trace_c != NULL) { + fputs("\n/*SWE_SET_EPHE_PATH*/\n", swi_fp_trace_c); + if (path == NULL) + fputs(" *s = '\\0';\n", swi_fp_trace_c); + else + fprintf(swi_fp_trace_c, " strcpy(s, \"%s\");\n", path); + fputs(" swe_set_ephe_path(s);\n", swi_fp_trace_c); + fputs(" printf(\"swe_set_ephe_path: path_in = \");", + swi_fp_trace_c); + fputs(" printf(s);\n", swi_fp_trace_c); + fputs + (" \tprintf(\"\\tpath_set = unknown to swetrace\\n\"); /* unknown to swetrace */\n", + swi_fp_trace_c); + fflush(swi_fp_trace_c); + } + if (swi_fp_trace_out != NULL) { + fputs("swe_set_ephe_path: path_in = ", swi_fp_trace_out); + if (path != NULL) + fputs(path, swi_fp_trace_out); + fputs("\tpath_set = ", swi_fp_trace_out); + fputs(s, swi_fp_trace_out); + fputs("\n", swi_fp_trace_out); + fflush(swi_fp_trace_out); + } } - if (swi_fp_trace_out != NULL) { - fputs("swe_set_ephe_path: path_in = ", swi_fp_trace_out); - if (path != NULL) - fputs(path, swi_fp_trace_out); - fputs("\tpath_set = ", swi_fp_trace_out); - fputs(s, swi_fp_trace_out); - fputs("\n", swi_fp_trace_out); - fflush(swi_fp_trace_out); - } - } #endif } @@ -1130,48 +1195,53 @@ void FAR PASCAL_CONV swe_set_ephe_path(char *path) * won't return planet positions previously computed from other * ephemerides */ -void FAR PASCAL_CONV swe_set_jpl_file(char *fname) +void FAR PASCAL_CONV +swe_set_jpl_file(char *fname) { - char *sp; - /* close all open files and delete all planetary data */ - swe_close(); - /* if path is contained in fnam, it is filled into the path variable */ - sp = strrchr(fname, (int) *DIR_GLUE); - if (sp == NULL) - sp = fname; - else - sp = sp + 1; - if (strlen(sp) >= AS_MAXCH) - sp[AS_MAXCH] = '\0'; - strcpy(swed.jplfnam, sp); + char *sp; + /* close all open files and delete all planetary data */ + swe_close(); + /* if path is contained in fnam, it is filled into the path variable */ + sp = strrchr(fname, (int)*DIR_GLUE); + if (sp == NULL) + sp = fname; + else + sp = sp + 1; + if (strlen(sp) >= AS_MAXCH) + sp[AS_MAXCH] = '\0'; + strcpy(swed.jplfnam, sp); #ifdef TRACE - swi_open_trace(NULL); - if (swi_trace_count < TRACE_COUNT_MAX) { - if (swi_fp_trace_c != NULL) { - fputs("\n/*SWE_SET_JPL_FILE*/\n", swi_fp_trace_c); - fprintf(swi_fp_trace_c, " strcpy(s, \"%s\");\n", fname); - fputs(" swe_set_jpl_file(s);\n", swi_fp_trace_c); - fputs(" printf(\"swe_set_jpl_file: fname_in = \");", swi_fp_trace_c); - fputs(" printf(s);\n", swi_fp_trace_c); - fputs(" printf(\"\\tfname_set = unknown to swetrace\\n\"); /* unknown to swetrace */\n", swi_fp_trace_c); - fflush(swi_fp_trace_c); + swi_open_trace(NULL); + if (swi_trace_count < TRACE_COUNT_MAX) { + if (swi_fp_trace_c != NULL) { + fputs("\n/*SWE_SET_JPL_FILE*/\n", swi_fp_trace_c); + fprintf(swi_fp_trace_c, " strcpy(s, \"%s\");\n", fname); + fputs(" swe_set_jpl_file(s);\n", swi_fp_trace_c); + fputs(" printf(\"swe_set_jpl_file: fname_in = \");", + swi_fp_trace_c); + fputs(" printf(s);\n", swi_fp_trace_c); + fputs + (" printf(\"\\tfname_set = unknown to swetrace\\n\"); /* unknown to swetrace */\n", + swi_fp_trace_c); + fflush(swi_fp_trace_c); + } + if (swi_fp_trace_out != NULL) { + fputs("swe_set_jpl_file: fname_in = ", swi_fp_trace_out); + fputs(fname, swi_fp_trace_out); + fputs("\tfname_set = ", swi_fp_trace_out); + fputs(sp, swi_fp_trace_out); + fputs("\n", swi_fp_trace_out); + fflush(swi_fp_trace_out); + } } - if (swi_fp_trace_out != NULL) { - fputs("swe_set_jpl_file: fname_in = ", swi_fp_trace_out); - fputs(fname, swi_fp_trace_out); - fputs("\tfname_set = ", swi_fp_trace_out); - fputs(sp, swi_fp_trace_out); - fputs("\n", swi_fp_trace_out); - fflush(swi_fp_trace_out); - } - } #endif } /* calculates obliquity of ecliptic and stores it together * with its date, sine, and cosine */ -static void calc_epsilon(double tjd, struct epsilon *e) +static void +calc_epsilon(double tjd, struct epsilon *e) { e->teps = tjd; e->eps = swi_epsiln(tjd); @@ -1179,7 +1249,7 @@ static void calc_epsilon(double tjd, struct epsilon *e) e->ceps = cos(e->eps); } -/* computes a main planet from any ephemeris, if it +/* computes a main planet from any ephemeris, if it * has not yet been computed for this date. * since a geocentric position requires the earth, the * earth's position will be computed as well. With SWISSEPH @@ -1196,110 +1266,118 @@ static void calc_epsilon(double tjd, struct epsilon *e) * &swed.pldat[ipli].xreturn[]; * * the barycentric (heliocentric with Moshier) position J2000 - * will be kept in + * will be kept in * &swed.pldat[ipli].x[]; */ -static int main_planet(double tjd, int ipli, int32 epheflag, int32 iflag, - char *serr) +static int +main_planet(double tjd, int ipli, int32 epheflag, int32 iflag, char *serr) { - int retc; - switch(epheflag) { + int retc; + switch (epheflag) { #ifndef NO_JPL - case SEFLG_JPLEPH: - retc = jplplan(tjd, ipli, iflag, DO_SAVE, NULL, NULL, NULL, serr); - /* read error or corrupt file */ - if (retc == ERR) - return ERR; - /* jpl ephemeris not on disk or date beyond ephemeris range */ - if (retc == NOT_AVAILABLE) { - iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_SWIEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, " \ntrying Swiss Eph; "); - goto sweph_planet; - } else if (retc == BEYOND_EPH_LIMITS) { - if (tjd > MOSHPLEPH_START && tjd < MOSHPLEPH_END) { - iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_MOSEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, " \nusing Moshier Eph; "); - goto moshier_planet; - } else - return ERR; - } - /* geocentric, lighttime etc. */ - if (ipli == SEI_SUN) - retc = app_pos_etc_sun(iflag, serr)/**/; - else - retc = app_pos_etc_plan(ipli, iflag, serr); - if (retc == ERR) - return ERR; - /* t for light-time beyond ephemeris range */ - if (retc == NOT_AVAILABLE) { - iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_SWIEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, " \ntrying Swiss Eph; "); - goto sweph_planet; - } else if (retc == BEYOND_EPH_LIMITS) { - if (tjd > MOSHPLEPH_START && tjd < MOSHPLEPH_END) { - iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_MOSEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, " \nusing Moshier Eph; "); - goto moshier_planet; - } else - return ERR; - } - break; + case SEFLG_JPLEPH: + retc = jplplan(tjd, ipli, iflag, DO_SAVE, NULL, NULL, NULL, serr); + /* read error or corrupt file */ + if (retc == ERR) + return ERR; + /* jpl ephemeris not on disk or date beyond ephemeris range */ + if (retc == NOT_AVAILABLE) { + iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_SWIEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, " \ntrying Swiss Eph; "); + goto sweph_planet; + } + else if (retc == BEYOND_EPH_LIMITS) { + if (tjd > MOSHPLEPH_START && tjd < MOSHPLEPH_END) { + iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_MOSEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, " \nusing Moshier Eph; "); + goto moshier_planet; + } + else + return ERR; + } + /* geocentric, lighttime etc. */ + if (ipli == SEI_SUN) + retc = app_pos_etc_sun(iflag, serr) /**/; + else + retc = app_pos_etc_plan(ipli, iflag, serr); + if (retc == ERR) + return ERR; + /* t for light-time beyond ephemeris range */ + if (retc == NOT_AVAILABLE) { + iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_SWIEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, " \ntrying Swiss Eph; "); + goto sweph_planet; + } + else if (retc == BEYOND_EPH_LIMITS) { + if (tjd > MOSHPLEPH_START && tjd < MOSHPLEPH_END) { + iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_MOSEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, " \nusing Moshier Eph; "); + goto moshier_planet; + } + else + return ERR; + } + break; #endif - case SEFLG_SWIEPH: - sweph_planet: - /* compute barycentric planet (+ earth, sun, moon) */ - retc = sweplan(tjd, ipli, SEI_FILE_PLANET, iflag, DO_SAVE, NULL, NULL, NULL, NULL, serr); - if (retc == ERR) - return ERR; - /* if sweph file not found, switch to moshier */ - if (retc == NOT_AVAILABLE) { - if (tjd > MOSHPLEPH_START && tjd < MOSHPLEPH_END) { - iflag = (iflag & ~SEFLG_SWIEPH) | SEFLG_MOSEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, " \nusing Moshier eph.; "); - goto moshier_planet; - } else - return ERR; - } - /* geocentric, lighttime etc. */ - if (ipli == SEI_SUN) - retc = app_pos_etc_sun(iflag, serr)/**/; - else - retc = app_pos_etc_plan(ipli, iflag, serr); - if (retc == ERR) - return ERR; - /* if sweph file for t(lighttime) not found, switch to moshier */ - if (retc == NOT_AVAILABLE) { - if (tjd > MOSHPLEPH_START && tjd < MOSHPLEPH_END) { - iflag = (iflag & ~SEFLG_SWIEPH) | SEFLG_MOSEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, " \nusing Moshier eph.; "); - goto moshier_planet; - } else - return ERR; - } - break; - case SEFLG_MOSEPH: - moshier_planet: - retc = swi_moshplan(tjd, ipli, DO_SAVE, NULL, NULL, serr);/**/ - if (retc == ERR) - return ERR; - /* geocentric, lighttime etc. */ - if (ipli == SEI_SUN) - retc = app_pos_etc_sun(iflag, serr)/**/; - else - retc = app_pos_etc_plan(ipli, iflag, serr); - if (retc == ERR) - return ERR; - break; - default: - break; - } - return OK; + case SEFLG_SWIEPH: +sweph_planet: + /* compute barycentric planet (+ earth, sun, moon) */ + retc = + sweplan(tjd, ipli, SEI_FILE_PLANET, iflag, DO_SAVE, NULL, + NULL, NULL, NULL, serr); + if (retc == ERR) + return ERR; + /* if sweph file not found, switch to moshier */ + if (retc == NOT_AVAILABLE) { + if (tjd > MOSHPLEPH_START && tjd < MOSHPLEPH_END) { + iflag = (iflag & ~SEFLG_SWIEPH) | SEFLG_MOSEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, " \nusing Moshier eph.; "); + goto moshier_planet; + } + else + return ERR; + } + /* geocentric, lighttime etc. */ + if (ipli == SEI_SUN) + retc = app_pos_etc_sun(iflag, serr) /**/; + else + retc = app_pos_etc_plan(ipli, iflag, serr); + if (retc == ERR) + return ERR; + /* if sweph file for t(lighttime) not found, switch to moshier */ + if (retc == NOT_AVAILABLE) { + if (tjd > MOSHPLEPH_START && tjd < MOSHPLEPH_END) { + iflag = (iflag & ~SEFLG_SWIEPH) | SEFLG_MOSEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, " \nusing Moshier eph.; "); + goto moshier_planet; + } + else + return ERR; + } + break; + case SEFLG_MOSEPH: +moshier_planet: + retc = swi_moshplan(tjd, ipli, DO_SAVE, NULL, NULL, serr); + /**/ if (retc == ERR) + return ERR; + /* geocentric, lighttime etc. */ + if (ipli == SEI_SUN) + retc = app_pos_etc_sun(iflag, serr) /**/; + else + retc = app_pos_etc_plan(ipli, iflag, serr); + if (retc == ERR) + return ERR; + break; + default: + break; + } + return OK; } /* Computes a main planet from any ephemeris or returns @@ -1314,127 +1392,134 @@ static int main_planet(double tjd, int ipli, int32 epheflag, int32 iflag, * epheflag = which ephemeris? JPL, SWISSEPH, Moshier? * iflag = other flags * xp, xe, xs, and xm are the pointers, where the program - * either finds or stores (if not found) the barycentric - * (heliocentric with Moshier) positions of the following + * either finds or stores (if not found) the barycentric + * (heliocentric with Moshier) positions of the following * bodies: * xp planet * xe earth * xs sun * xm moon - * - * xm is used with Moshier only + * + * xm is used with Moshier only */ -static int main_planet_bary(double tjd, int ipli, int32 epheflag, int32 iflag, AS_BOOL do_save, - double *xp, double *xe, double *xs, double *xm, - char *serr) +static int +main_planet_bary(double tjd, int ipli, int32 epheflag, int32 iflag, + AS_BOOL do_save, double *xp, double *xe, double *xs, + double *xm, char *serr) { - int i, retc; - switch(epheflag) { + int i, retc; + switch (epheflag) { #ifndef NO_JPL - case SEFLG_JPLEPH: - retc = jplplan(tjd, ipli, iflag, do_save, xp, xe, xs, serr); - /* read error or corrupt file */ - if (retc == ERR || retc == BEYOND_EPH_LIMITS) - return retc; - /* jpl ephemeris not on disk or date beyond ephemeris range */ - if (retc == NOT_AVAILABLE) { - iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_SWIEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, " \ntrying Swiss Eph; "); - goto sweph_planet; - } - break; + case SEFLG_JPLEPH: + retc = jplplan(tjd, ipli, iflag, do_save, xp, xe, xs, serr); + /* read error or corrupt file */ + if (retc == ERR || retc == BEYOND_EPH_LIMITS) + return retc; + /* jpl ephemeris not on disk or date beyond ephemeris range */ + if (retc == NOT_AVAILABLE) { + iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_SWIEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, " \ntrying Swiss Eph; "); + goto sweph_planet; + } + break; #endif - case SEFLG_SWIEPH: - sweph_planet: - /* compute barycentric planet (+ earth, sun, moon) */ - retc = sweplan(tjd, ipli, SEI_FILE_PLANET, iflag, do_save, xp, xe, xs, xm, serr); + case SEFLG_SWIEPH: +sweph_planet: + /* compute barycentric planet (+ earth, sun, moon) */ + retc = + sweplan(tjd, ipli, SEI_FILE_PLANET, iflag, do_save, xp, xe, + xs, xm, serr); #if 1 - if (retc == ERR || retc == NOT_AVAILABLE) - return retc; + if (retc == ERR || retc == NOT_AVAILABLE) + return retc; #else /* if barycentric moshier calculation were implemented */ - if (retc == ERR) - return ERR; - /* if sweph file not found, switch to moshier */ - if (retc == NOT_AVAILABLE) { - if (tjd > MOSHPLEPH_START && tjd < MOSHPLEPH_END) { - iflag = (iflag & ~SEFLG_SWIEPH) | SEFLG_MOSEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, " \nusing Moshier eph.; "); - goto moshier_planet; - } else - goto return_error; - } + if (retc == ERR) + return ERR; + /* if sweph file not found, switch to moshier */ + if (retc == NOT_AVAILABLE) { + if (tjd > MOSHPLEPH_START && tjd < MOSHPLEPH_END) { + iflag = (iflag & ~SEFLG_SWIEPH) | SEFLG_MOSEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, " \nusing Moshier eph.; "); + goto moshier_planet; + } + else + goto return_error; + } #endif - break; - case SEFLG_MOSEPH: + break; + case SEFLG_MOSEPH: #if 0 - moshier_planet: +moshier_planet: #endif - retc = swi_moshplan(tjd, ipli, do_save, xp, xe, serr);/**/ - if (retc == ERR) - return ERR; - for (i = 0; i <= 5; i++) - xs[i] = 0; - break; - default: - break; - } - return OK; + retc = swi_moshplan(tjd, ipli, do_save, xp, xe, serr); + /**/ if (retc == ERR) + return ERR; + for (i = 0; i <= 5; i++) + xs[i] = 0; + break; + default: + break; + } + return OK; } -/* SWISSEPH +/* SWISSEPH * this routine computes heliocentric cartesian equatorial coordinates * of equinox 2000 of * geocentric moon - * + * * tjd julian date * iflag flag * do_save save J2000 position in save area pdp->x ? * xp array of 6 doubles for lunar position and speed * serr error string */ -static int swemoon(double tjd, int32 iflag, AS_BOOL do_save, double *xpret, char *serr) +static int +swemoon(double tjd, int32 iflag, AS_BOOL do_save, double *xpret, char *serr) { - int i, retc; - struct plan_data *pdp = &swed.pldat[SEI_MOON]; - int32 speedf1, speedf2; - double xx[6], *xp; - if (do_save) - xp = pdp->x; - else - xp = xx; - /* if planet has already been computed for this date, return - * if speed flag has been turned on, recompute planet */ - speedf1 = pdp->xflgs & SEFLG_SPEED; - speedf2 = iflag & SEFLG_SPEED; - if (tjd == pdp->teval - && pdp->iephe == SEFLG_SWIEPH - && (!speedf2 || speedf1)) { - xp = pdp->x; - } else { - /* call sweph for moon */ - retc = sweph(tjd, SEI_MOON, SEI_FILE_MOON, iflag, NULL, do_save, xp, serr); - if (retc != OK) - return(retc); - if (do_save) { - pdp->teval = tjd; - pdp->xflgs = -1; - pdp->iephe = SEFLG_SWIEPH; + int i, retc; + struct plan_data *pdp = &swed.pldat[SEI_MOON]; + int32 speedf1, speedf2; + double xx[6], *xp; + if (do_save) + xp = pdp->x; + else + xp = xx; + /* if planet has already been computed for this date, return + * if speed flag has been turned on, recompute planet */ + speedf1 = pdp->xflgs & SEFLG_SPEED; + speedf2 = iflag & SEFLG_SPEED; + if (tjd == pdp->teval && pdp->iephe == SEFLG_SWIEPH + && (!speedf2 || speedf1)) { + xp = pdp->x; } - } - if (xpret != NULL) - for (i = 0; i <= 5; i++) - xpret[i] = xp[i]; - return(OK); + else { + /* call sweph for moon */ + retc = + sweph(tjd, SEI_MOON, SEI_FILE_MOON, iflag, NULL, do_save, xp, + serr); + if (retc != OK) + return (retc); + if (do_save) { + pdp->teval = tjd; + pdp->xflgs = -1; + pdp->iephe = SEFLG_SWIEPH; + } + } + if (xpret != NULL) + for (i = 0; i <= 5; i++) + xpret[i] = xp[i]; + return (OK); } -/* SWISSEPH - * this function computes - * 1. a barycentric planet - * plus, under certain conditions, - * 2. the barycentric sun, - * 3. the barycentric earth, and +/* SWISSEPH + * this function computes + * 1. a barycentric planet + * plus, under certain conditions, + * 2. the barycentric sun, + * 3. the barycentric earth, and * 4. the geocentric moon, * in barycentric cartesian equatorial coordinates J2000. * @@ -1445,7 +1530,7 @@ static int swemoon(double tjd, int32 iflag, AS_BOOL do_save, double *xpret, char * ifno ephemeris file number * do_save write new positions in save area * xp array of 6 doubles for planet's position and velocity - * xpe earth's + * xpe earth's * xps sun's * xpm moon's * serr error string @@ -1453,169 +1538,182 @@ static int swemoon(double tjd, int32 iflag, AS_BOOL do_save, double *xpret, char * xp - xpm can be NULL. if do_save is TRUE, all of them can be NULL. * the positions will be written into the save area (swed.pldat[ipli].x) */ -static int sweplan(double tjd, int ipli, int ifno, int32 iflag, AS_BOOL do_save, - double *xpret, double *xperet, double *xpsret, double *xpmret, - char *serr) +static int +sweplan(double tjd, int ipli, int ifno, int32 iflag, AS_BOOL do_save, + double *xpret, double *xperet, double *xpsret, double *xpmret, + char *serr) { - int i, retc; - int do_earth = FALSE, do_moon = FALSE, do_sunbary = FALSE; - struct plan_data *pdp = &swed.pldat[ipli]; - struct plan_data *pebdp = &swed.pldat[SEI_EMB]; - struct plan_data *psbdp = &swed.pldat[SEI_SUNBARY]; - struct plan_data *pmdp = &swed.pldat[SEI_MOON]; - double xxp[6], xxm[6], xxs[6], xxe[6]; - double *xp, *xpe, *xpm, *xps; - int32 speedf1, speedf2; - /* xps (barycentric sun) may be necessary because some planets on sweph - * file are heliocentric, other ones are barycentric. without xps, - * the heliocentric ones cannot be returned barycentrically. - */ - if (do_save || ipli == SEI_SUNBARY || (pdp->iflg & SEI_FLG_HELIO) - || xpsret != NULL || (iflag & SEFLG_HELCTR)) - do_sunbary = TRUE; - if (do_save || ipli == SEI_EARTH || xperet != NULL) - do_earth = TRUE; - if (ipli == SEI_MOON) { + int i, retc; + int do_earth = FALSE, do_moon = FALSE, do_sunbary = FALSE; + struct plan_data *pdp = &swed.pldat[ipli]; + struct plan_data *pebdp = &swed.pldat[SEI_EMB]; + struct plan_data *psbdp = &swed.pldat[SEI_SUNBARY]; + struct plan_data *pmdp = &swed.pldat[SEI_MOON]; + double xxp[6], xxm[6], xxs[6], xxe[6]; + double *xp, *xpe, *xpm, *xps; + int32 speedf1, speedf2; + /* xps (barycentric sun) may be necessary because some planets on sweph + * file are heliocentric, other ones are barycentric. without xps, + * the heliocentric ones cannot be returned barycentrically. + */ + if (do_save || ipli == SEI_SUNBARY || (pdp->iflg & SEI_FLG_HELIO) + || xpsret != NULL || (iflag & SEFLG_HELCTR)) + do_sunbary = TRUE; + if (do_save || ipli == SEI_EARTH || xperet != NULL) + do_earth = TRUE; + if (ipli == SEI_MOON) { #if 0 - if (iflag & (SEFLG_HELCTR | SEFLG_BARYCTR | SEFLG_NOABERR)) - do_earth = TRUE; - if (iflag & (SEFLG_HELCTR | SEFLG_NOABERR)) - do_sunbary = TRUE; + if (iflag & (SEFLG_HELCTR | SEFLG_BARYCTR | SEFLG_NOABERR)) + do_earth = TRUE; + if (iflag & (SEFLG_HELCTR | SEFLG_NOABERR)) + do_sunbary = TRUE; #else - do_earth = TRUE; - do_sunbary = TRUE; + do_earth = TRUE; + do_sunbary = TRUE; #endif - } - if (do_save || ipli == SEI_MOON || ipli == SEI_EARTH || xperet != NULL || xpmret != NULL) - do_moon = TRUE; - if (do_save) { - xp = pdp->x; - xpe = pebdp->x; - xps = psbdp->x; - xpm = pmdp->x; - } else { - xp = xxp; - xpe = xxe; - xps = xxs; - xpm = xxm; - } - speedf2 = iflag & SEFLG_SPEED; - /* barycentric sun */ - if (do_sunbary) { - speedf1 = psbdp->xflgs & SEFLG_SPEED; - /* if planet has already been computed for this date, return - * if speed flag has been turned on, recompute planet */ - if (tjd == psbdp->teval - && psbdp->iephe == SEFLG_SWIEPH - && (!speedf2 || speedf1)) { - for (i = 0; i <= 5; i++) - xps[i] = psbdp->x[i]; - } else { - retc = sweph(tjd, SEI_SUNBARY, SEI_FILE_PLANET, iflag, NULL, do_save, xps, serr);/**/ - if (retc != OK) - return(retc); } - if (xpsret != NULL) - for (i = 0; i <= 5; i++) - xpsret[i] = xps[i]; - } - /* moon */ - if (do_moon) { - speedf1 = pmdp->xflgs & SEFLG_SPEED; - if (tjd == pmdp->teval - && pmdp->iephe == SEFLG_SWIEPH - && (!speedf2 || speedf1)) { - for (i = 0; i <= 5; i++) - xpm[i] = pmdp->x[i]; - } else { - retc = sweph(tjd, SEI_MOON, SEI_FILE_MOON, iflag, NULL, do_save, xpm, serr); - if (retc == ERR) - return(retc); - /* if moon file doesn't exist, take moshier moon */ - if (swed.fidat[SEI_FILE_MOON].fptr == NULL) { - if (serr != NULL && strlen(serr) + 35 < AS_MAXCH) - strcat(serr, " \nusing Moshier eph. for moon; "); - retc = swi_moshmoon(tjd, do_save, xpm, serr); - if (retc != OK) - return(retc); - } + if (do_save || ipli == SEI_MOON || ipli == SEI_EARTH || xperet != NULL + || xpmret != NULL) + do_moon = TRUE; + if (do_save) { + xp = pdp->x; + xpe = pebdp->x; + xps = psbdp->x; + xpm = pmdp->x; } - if (xpmret != NULL) - for (i = 0; i <= 5; i++) - xpmret[i] = xpm[i]; - } - /* barycentric earth */ - if (do_earth) { - speedf1 = pebdp->xflgs & SEFLG_SPEED; - if (tjd == pebdp->teval - && pebdp->iephe == SEFLG_SWIEPH - && (!speedf2 || speedf1)) { - for (i = 0; i <= 5; i++) - xpe[i] = pebdp->x[i]; - } else { - retc = sweph(tjd, SEI_EMB, SEI_FILE_PLANET, iflag, NULL, do_save, xpe, serr); - if (retc != OK) - return(retc); - /* earth from emb and moon */ - embofs(xpe, xpm); - /* speed is needed, if - * 1. true position is being computed before applying light-time etc. - * this is the position saved in pdp->x. - * in this case, speed is needed for light-time correction. - * 2. the speed flag has been specified. - */ - if (xpe == pebdp->x || (iflag & SEFLG_SPEED)) - embofs(xpe+3, xpm+3); - } - if (xperet != NULL) - for (i = 0; i <= 5; i++) - xperet[i] = xpe[i]; - } - if (ipli == SEI_MOON) { - for (i = 0; i <= 5; i++) - xp[i] = xpm[i]; - } else if (ipli == SEI_EARTH) { - for (i = 0; i <= 5; i++) - xp[i] = xpe[i]; - } else if (ipli == SEI_SUN) { - for (i = 0; i <= 5; i++) - xp[i] = xps[i]; - } else { - /* planet */ - speedf1 = pdp->xflgs & SEFLG_SPEED; - if (tjd == pdp->teval - && pdp->iephe == SEFLG_SWIEPH - && (!speedf2 || speedf1)) { - for (i = 0; i <= 5; i++) - xp[i] = pdp->x[i]; - return(OK); - } else { - retc = sweph(tjd, ipli, ifno, iflag, NULL, do_save, xp, serr); - if (retc != OK) - return(retc); - /* if planet is heliocentric, it must be transformed to barycentric */ - if (pdp->iflg & SEI_FLG_HELIO) { - /* now barycentric planet */ - for (i = 0; i <= 2; i++) - xp[i] += xps[i]; - if (do_save || (iflag & SEFLG_SPEED)) - for (i = 3; i <= 5; i++) - xp[i] += xps[i]; - } + else { + xp = xxp; + xpe = xxe; + xps = xxs; + xpm = xxm; } - } - if (xpret != NULL) - for (i = 0; i <= 5; i++) - xpret[i] = xp[i]; - return(OK); + speedf2 = iflag & SEFLG_SPEED; + /* barycentric sun */ + if (do_sunbary) { + speedf1 = psbdp->xflgs & SEFLG_SPEED; + /* if planet has already been computed for this date, return + * if speed flag has been turned on, recompute planet */ + if (tjd == psbdp->teval && psbdp->iephe == SEFLG_SWIEPH + && (!speedf2 || speedf1)) { + for (i = 0; i <= 5; i++) + xps[i] = psbdp->x[i]; + } + else { + retc = + sweph(tjd, SEI_SUNBARY, SEI_FILE_PLANET, iflag, NULL, do_save, + xps, serr); + /**/ if (retc != OK) + return (retc); + } + if (xpsret != NULL) + for (i = 0; i <= 5; i++) + xpsret[i] = xps[i]; + } + /* moon */ + if (do_moon) { + speedf1 = pmdp->xflgs & SEFLG_SPEED; + if (tjd == pmdp->teval && pmdp->iephe == SEFLG_SWIEPH + && (!speedf2 || speedf1)) { + for (i = 0; i <= 5; i++) + xpm[i] = pmdp->x[i]; + } + else { + retc = + sweph(tjd, SEI_MOON, SEI_FILE_MOON, iflag, NULL, do_save, xpm, + serr); + if (retc == ERR) + return (retc); + /* if moon file doesn't exist, take moshier moon */ + if (swed.fidat[SEI_FILE_MOON].fptr == NULL) { + if (serr != NULL && strlen(serr) + 35 < AS_MAXCH) + strcat(serr, " \nusing Moshier eph. for moon; "); + retc = swi_moshmoon(tjd, do_save, xpm, serr); + if (retc != OK) + return (retc); + } + } + if (xpmret != NULL) + for (i = 0; i <= 5; i++) + xpmret[i] = xpm[i]; + } + /* barycentric earth */ + if (do_earth) { + speedf1 = pebdp->xflgs & SEFLG_SPEED; + if (tjd == pebdp->teval && pebdp->iephe == SEFLG_SWIEPH + && (!speedf2 || speedf1)) { + for (i = 0; i <= 5; i++) + xpe[i] = pebdp->x[i]; + } + else { + retc = + sweph(tjd, SEI_EMB, SEI_FILE_PLANET, iflag, NULL, do_save, + xpe, serr); + if (retc != OK) + return (retc); + /* earth from emb and moon */ + embofs(xpe, xpm); + /* speed is needed, if + * 1. true position is being computed before applying light-time etc. + * this is the position saved in pdp->x. + * in this case, speed is needed for light-time correction. + * 2. the speed flag has been specified. + */ + if (xpe == pebdp->x || (iflag & SEFLG_SPEED)) + embofs(xpe + 3, xpm + 3); + } + if (xperet != NULL) + for (i = 0; i <= 5; i++) + xperet[i] = xpe[i]; + } + if (ipli == SEI_MOON) { + for (i = 0; i <= 5; i++) + xp[i] = xpm[i]; + } + else if (ipli == SEI_EARTH) { + for (i = 0; i <= 5; i++) + xp[i] = xpe[i]; + } + else if (ipli == SEI_SUN) { + for (i = 0; i <= 5; i++) + xp[i] = xps[i]; + } + else { + /* planet */ + speedf1 = pdp->xflgs & SEFLG_SPEED; + if (tjd == pdp->teval && pdp->iephe == SEFLG_SWIEPH + && (!speedf2 || speedf1)) { + for (i = 0; i <= 5; i++) + xp[i] = pdp->x[i]; + return (OK); + } + else { + retc = sweph(tjd, ipli, ifno, iflag, NULL, do_save, xp, serr); + if (retc != OK) + return (retc); + /* if planet is heliocentric, it must be transformed to barycentric */ + if (pdp->iflg & SEI_FLG_HELIO) { + /* now barycentric planet */ + for (i = 0; i <= 2; i++) + xp[i] += xps[i]; + if (do_save || (iflag & SEFLG_SPEED)) + for (i = 3; i <= 5; i++) + xp[i] += xps[i]; + } + } + } + if (xpret != NULL) + for (i = 0; i <= 5; i++) + xpret[i] = xp[i]; + return (OK); } #ifndef NO_JPL + /* jpl ephemeris. - * this function computes + * this function computes * 1. a barycentric planet position * plus, under certain conditions, - * 2. the barycentric sun, + * 2. the barycentric sun, * 3. the barycentric earth, * in barycentric cartesian equatorial coordinates J2000. @@ -1630,135 +1728,140 @@ static int sweplan(double tjd, int ipli, int ifno, int32 iflag, AS_BOOL do_save, * xp - xps can be NULL. if do_save is TRUE, all of them can be NULL. * the positions will be written into the save area (swed.pldat[ipli].x) */ -static int jplplan(double tjd, int ipli, int32 iflag, AS_BOOL do_save, - double *xpret, double *xperet, double *xpsret, char *serr) +static int +jplplan(double tjd, int ipli, int32 iflag, AS_BOOL do_save, double *xpret, + double *xperet, double *xpsret, char *serr) { - int i, retc; - AS_BOOL do_earth = FALSE, do_sunbary = FALSE; - double ss[3]; - double xxp[6], xxe[6], xxs[6]; - double *xp, *xpe, *xps; - int ictr = J_SBARY; - struct plan_data *pdp = &swed.pldat[ipli]; - struct plan_data *pedp = &swed.pldat[SEI_EARTH]; - struct plan_data *psdp = &swed.pldat[SEI_SUNBARY]; - /* we assume Teph ~= TDB ~= TT. The maximum error is < 0.002 sec, - * corresponding to an ephemeris error < 0.001 arcsec for the moon */ - /* double tjd_tdb, T; - T = (tjd - 2451545.0)/36525.0; - tjd_tdb = tjd + (0.001657 * sin(628.3076 * T + 6.2401) - + 0.000022 * sin(575.3385 * T + 4.2970) - + 0.000014 * sin(1256.6152 * T + 6.1969)) / 8640.0;*/ - if (do_save) { - xp = pdp->x; - xpe = pedp->x; - xps = psdp->x; - } else { - xp = xxp; - xpe = xxe; - xps = xxs; - } - if (do_save || ipli == SEI_EARTH || xperet != NULL - || (ipli == SEI_MOON)) /* && (iflag & (SEFLG_HELCTR | SEFLG_BARYCTR | SEFLG_NOABERR)))) */ - do_earth = TRUE; - if (do_save || ipli == SEI_SUNBARY || xpsret != NULL - || (ipli == SEI_MOON)) /* && (iflag & (SEFLG_HELCTR | SEFLG_NOABERR)))) */ - do_sunbary = TRUE; - if (ipli == SEI_MOON) - ictr = J_EARTH; - /* open ephemeris, if still closed */ - if (!swed.jpl_file_is_open) { - retc = swi_open_jpl_file(ss, swed.jplfnam, swed.ephepath, serr); - if (retc != OK) - return (retc); - swed.jpldenum = swi_get_jpl_denum(); - swed.jpl_file_is_open = TRUE; - } - if (do_earth) { - /* barycentric earth */ - if (tjd != pedp->teval || tjd == 0) { - retc = swi_pleph(tjd, J_EARTH, J_SBARY, xpe, serr); - if (retc != OK) { - swi_close_jpl_file(); - swed.jpl_file_is_open = FALSE; - return retc; - } - if (do_save) { - pedp->teval = tjd; - pedp->xflgs = -1; /* new light-time etc. required */ - pedp->iephe = SEFLG_JPLEPH; - } - } else { - xpe = pedp->x; + int i, retc; + AS_BOOL do_earth = FALSE, do_sunbary = FALSE; + double ss[3]; + double xxp[6], xxe[6], xxs[6]; + double *xp, *xpe, *xps; + int ictr = J_SBARY; + struct plan_data *pdp = &swed.pldat[ipli]; + struct plan_data *pedp = &swed.pldat[SEI_EARTH]; + struct plan_data *psdp = &swed.pldat[SEI_SUNBARY]; + /* we assume Teph ~= TDB ~= TT. The maximum error is < 0.002 sec, + * corresponding to an ephemeris error < 0.001 arcsec for the moon */ + /* double tjd_tdb, T; + * T = (tjd - 2451545.0)/36525.0; + * tjd_tdb = tjd + (0.001657 * sin(628.3076 * T + 6.2401) + * + 0.000022 * sin(575.3385 * T + 4.2970) + * + 0.000014 * sin(1256.6152 * T + 6.1969)) / 8640.0; */ + if (do_save) { + xp = pdp->x; + xpe = pedp->x; + xps = psdp->x; } - if (xperet != NULL) - for (i = 0; i <= 5; i++) - xperet[i] = xpe[i]; - - } - if (do_sunbary) { - /* barycentric sun */ - if (tjd != psdp->teval || tjd == 0) { - retc = swi_pleph(tjd, J_SUN, J_SBARY, xps, serr); - if (retc != OK) { - swi_close_jpl_file(); - swed.jpl_file_is_open = FALSE; - return retc; - } - if (do_save) { - psdp->teval = tjd; - psdp->xflgs = -1; - psdp->iephe = SEFLG_JPLEPH; - } - } else { - xps = psdp->x; + else { + xp = xxp; + xpe = xxe; + xps = xxs; } - if (xpsret != NULL) - for (i = 0; i <= 5; i++) - xpsret[i] = xps[i]; - } - /* earth is wanted */ - if (ipli == SEI_EARTH) { - for (i = 0; i <= 5; i++) - xp[i] = xpe[i]; - /* sunbary is wanted */ - } if (ipli == SEI_SUNBARY) { - for (i = 0; i <= 5; i++) - xp[i] = xps[i]; - /* other planet */ - } else { - /* if planet already computed */ - if (tjd == pdp->teval && pdp->iephe == SEFLG_JPLEPH) { - xp = pdp->x; - } else { - retc = swi_pleph(tjd, pnoint2jpl[ipli], ictr, xp, serr); - if (retc != OK) { - swi_close_jpl_file(); - swed.jpl_file_is_open = FALSE; - return retc; - } - if (do_save) { - pdp->teval = tjd; - pdp->xflgs = -1; - pdp->iephe = SEFLG_JPLEPH; - } + if (do_save || ipli == SEI_EARTH || xperet != NULL || (ipli == SEI_MOON)) /* && (iflag & (SEFLG_HELCTR | SEFLG_BARYCTR | SEFLG_NOABERR)))) */ + do_earth = TRUE; + if (do_save || ipli == SEI_SUNBARY || xpsret != NULL || (ipli == SEI_MOON)) /* && (iflag & (SEFLG_HELCTR | SEFLG_NOABERR)))) */ + do_sunbary = TRUE; + if (ipli == SEI_MOON) + ictr = J_EARTH; + /* open ephemeris, if still closed */ + if (!swed.jpl_file_is_open) { + retc = swi_open_jpl_file(ss, swed.jplfnam, swed.ephepath, serr); + if (retc != OK) + return (retc); + swed.jpldenum = swi_get_jpl_denum(); + swed.jpl_file_is_open = TRUE; } - } - if (xpret != NULL) - for (i = 0; i <= 5; i++) - xpret[i] = xp[i]; - return (OK); -} -#endif /* NO_JPL */ + if (do_earth) { + /* barycentric earth */ + if (tjd != pedp->teval || tjd == 0) { + retc = swi_pleph(tjd, J_EARTH, J_SBARY, xpe, serr); + if (retc != OK) { + swi_close_jpl_file(); + swed.jpl_file_is_open = FALSE; + return retc; + } + if (do_save) { + pedp->teval = tjd; + pedp->xflgs = -1; /* new light-time etc. required */ + pedp->iephe = SEFLG_JPLEPH; + } + } + else { + xpe = pedp->x; + } + if (xperet != NULL) + for (i = 0; i <= 5; i++) + xperet[i] = xpe[i]; -/* - * this function looks for an ephemeris file, + } + if (do_sunbary) { + /* barycentric sun */ + if (tjd != psdp->teval || tjd == 0) { + retc = swi_pleph(tjd, J_SUN, J_SBARY, xps, serr); + if (retc != OK) { + swi_close_jpl_file(); + swed.jpl_file_is_open = FALSE; + return retc; + } + if (do_save) { + psdp->teval = tjd; + psdp->xflgs = -1; + psdp->iephe = SEFLG_JPLEPH; + } + } + else { + xps = psdp->x; + } + if (xpsret != NULL) + for (i = 0; i <= 5; i++) + xpsret[i] = xps[i]; + } + /* earth is wanted */ + if (ipli == SEI_EARTH) { + for (i = 0; i <= 5; i++) + xp[i] = xpe[i]; + /* sunbary is wanted */ + } + if (ipli == SEI_SUNBARY) { + for (i = 0; i <= 5; i++) + xp[i] = xps[i]; + /* other planet */ + } + else { + /* if planet already computed */ + if (tjd == pdp->teval && pdp->iephe == SEFLG_JPLEPH) { + xp = pdp->x; + } + else { + retc = swi_pleph(tjd, pnoint2jpl[ipli], ictr, xp, serr); + if (retc != OK) { + swi_close_jpl_file(); + swed.jpl_file_is_open = FALSE; + return retc; + } + if (do_save) { + pdp->teval = tjd; + pdp->xflgs = -1; + pdp->iephe = SEFLG_JPLEPH; + } + } + } + if (xpret != NULL) + for (i = 0; i <= 5; i++) + xpret[i] = xp[i]; + return (OK); +} +#endif /* NO_JPL */ + +/* + * this function looks for an ephemeris file, * opens it, if not yet open, * reads constants, if not yet read, - * computes a planet, if not yet computed + * computes a planet, if not yet computed * attention: asteroids are heliocentric * other planets barycentric - * + * * tjd julian date * ipli SEI_ planet number * ifno ephemeris file number @@ -1768,248 +1871,263 @@ static int jplplan(double tjd, int ipli, int32 iflag, AS_BOOL do_save, * xp return array of 6 doubles for planet's position * serr error string */ -static int sweph(double tjd, int ipli, int ifno, int32 iflag, double *xsunb, AS_BOOL do_save, double *xpret, char *serr) +static int +sweph(double tjd, int ipli, int ifno, int32 iflag, double *xsunb, + AS_BOOL do_save, double *xpret, char *serr) { - int i, ipl, retc, subdirlen; - char s[AS_MAXCH], subdirnam[AS_MAXCH], fname[AS_MAXCH], *sp; - double t, tsv; - double xemb[6], xx[6], *xp; - struct plan_data *pdp; - struct plan_data *pedp = &swed.pldat[SEI_EARTH]; - struct plan_data *psdp = &swed.pldat[SEI_SUNBARY]; - struct file_data *fdp = &swed.fidat[ifno]; - int32 speedf1, speedf2; - AS_BOOL need_speed; - ipl = ipli; - if (ipli > SE_AST_OFFSET) - ipl = SEI_ANYBODY; - pdp = &swed.pldat[ipl]; - if (do_save) - xp = pdp->x; - else - xp = xx; - /* if planet has already been computed for this date, return. - * if speed flag has been turned on, recompute planet */ - speedf1 = pdp->xflgs & SEFLG_SPEED; - speedf2 = iflag & SEFLG_SPEED; - if (tjd == pdp->teval - && pdp->iephe == SEFLG_SWIEPH - && (!speedf2 || speedf1) - && ipl < SEI_ANYBODY) { - if (xpret != NULL) - for (i = 0; i <= 5; i++) - xpret[i] = pdp->x[i]; - return(OK); - } - /****************************** - * get correct ephemeris file * - ******************************/ - if (fdp->fptr != NULL) { - /* if tjd is beyond file range, close old file. - * if new asteroid, close old file. */ - if (tjd < fdp->tfstart || tjd > fdp->tfend - || (ipl == SEI_ANYBODY && ipli != pdp->ibdy)) { - fclose(fdp->fptr); - fdp->fptr = NULL; - if (pdp->refep != NULL) - free((void *) pdp->refep); - pdp->refep = NULL; - if (pdp->segp != NULL) - free((void *) pdp->segp); - pdp->segp = NULL; + int i, ipl, retc, subdirlen; + char s[AS_MAXCH], subdirnam[AS_MAXCH], fname[AS_MAXCH], *sp; + double t, tsv; + double xemb[6], xx[6], *xp; + struct plan_data *pdp; + struct plan_data *pedp = &swed.pldat[SEI_EARTH]; + struct plan_data *psdp = &swed.pldat[SEI_SUNBARY]; + struct file_data *fdp = &swed.fidat[ifno]; + int32 speedf1, speedf2; + AS_BOOL need_speed; + ipl = ipli; + if (ipli > SE_AST_OFFSET) + ipl = SEI_ANYBODY; + pdp = &swed.pldat[ipl]; + if (do_save) + xp = pdp->x; + else + xp = xx; + /* if planet has already been computed for this date, return. + * if speed flag has been turned on, recompute planet */ + speedf1 = pdp->xflgs & SEFLG_SPEED; + speedf2 = iflag & SEFLG_SPEED; + if (tjd == pdp->teval && pdp->iephe == SEFLG_SWIEPH + && (!speedf2 || speedf1) && ipl < SEI_ANYBODY) { + if (xpret != NULL) + for (i = 0; i <= 5; i++) + xpret[i] = pdp->x[i]; + return (OK); } - } - /* if sweph file not open, find and open it */ - if (fdp->fptr == NULL) { - swi_gen_filename(tjd, ipli, fname); - strcpy(subdirnam, fname); - sp = strrchr(subdirnam, (int) *DIR_GLUE); - if (sp != NULL) { - *sp = '\0'; - subdirlen = strlen(subdirnam); - } else { - subdirlen = 0; - } - strcpy(s, fname); -again: - fdp->fptr = swi_fopen(ifno, s, swed.ephepath, serr); - if (fdp->fptr == NULL) { - /* - * if it is a numbered asteroid file, try also for short files (..s.se1) - * On the second try, the inserted 's' will be seen and not tried again. - */ - if (ipli > SE_AST_OFFSET) { - char *spp; - spp = strchr(s, '.'); - if (spp > s && *(spp-1) != 's') { /* no 's' before '.' ? */ - sprintf(spp, "s.%s", SE_FILE_SUFFIX); /* insert an 's' */ - goto again; - } - /* - * if we still have 'ast0' etc. in front of the filename, - * we remove it now, remove the 's' also, - * and try in the main ephemeris directory instead of the - * asteroid subdirectory. - */ - spp--; /* point to the character before '.' which must be a 's' */ - swi_strcpy(spp, spp + 1); /* remove the s */ - if (subdirlen > 0 && strncmp(s, subdirnam, (size_t) subdirlen) == 0) { - swi_strcpy(s, s + subdirlen + 1); /* remove "ast0/" etc. */ - goto again; - } - } - return(NOT_AVAILABLE); - } - /* during the search error messages may have been built, delete them */ - if (serr != NULL) *serr = '\0'; - retc = read_const(ifno, serr); - if (retc != OK) - return(retc); - } - /* if first ephemeris file (J-3000), it might start a mars period - * after -3000. if last ephemeris file (J3000), it might end a - * 4000-day-period before 3000. */ - if (tjd < fdp->tfstart || tjd > fdp->tfend) { - if (serr != NULL) { - if (tjd < fdp->tfstart) - sprintf(s, "jd %f < Swiss Eph. lower limit %f;", - tjd, fdp->tfstart); - else - sprintf(s, "jd %f > Swiss Eph. upper limit %f;", - tjd, fdp->tfend); - if (strlen(serr) + strlen(s) < AS_MAXCH) - strcat(serr, s); - } - return(NOT_AVAILABLE); - } + /****************************** - * get planet's position + * get correct ephemeris file * ******************************/ - /* get new segment, if necessary */ - if (pdp->segp == NULL || tjd < pdp->tseg0 || tjd > pdp->tseg1) { - retc = get_new_segment(tjd, ipl, ifno, serr); - if (retc != OK) - return(retc); - /* rotate cheby coeffs back to equatorial system. - * if necessary, add reference orbit. */ - if (pdp->iflg & SEI_FLG_ROTATE) - rot_back(ipl); /**/ - else - pdp->neval = pdp->ncoe; - } - /* evaluate chebyshew polynomial for tjd */ - t = (tjd - pdp->tseg0) / pdp->dseg; - t = t * 2 - 1; - /* speed is needed, if - * 1. true position is being computed before applying light-time etc. - * this is the position saved in pdp->x. - * in this case, speed is needed for light-time correction. - * 2. the speed flag has been specified. - */ - need_speed = (do_save || (iflag & SEFLG_SPEED)); - for (i = 0; i <= 2; i++) { - xp[i] = swi_echeb (t, pdp->segp+(i*pdp->ncoe), pdp->neval); - if (need_speed) - xp[i+3] = swi_edcheb(t, pdp->segp+(i*pdp->ncoe), pdp->neval) / pdp->dseg * 2; - else - xp[i+3] = 0; /* von Alois als billiger fix, evtl. illegal */ - } - /* if planet wanted is barycentric sun and must be computed - * from heliocentric earth and barycentric earth: the - * computation above gives heliocentric earth, therefore we - * have to compute barycentric earth and subtract heliocentric - * earth from it. this may be necessary with calls from - * sweplan() and from app_pos_etc_sun() (light-time). */ - if (ipl == SEI_SUNBARY && (pdp->iflg & SEI_FLG_EMBHEL)) { - /* sweph() calls sweph() !!! for EMB. - * Attention: a new calculation must be forced in any case. - * Otherwise EARTH (instead of EMB) will possibly taken from - * save area. - * to force new computation, set pedp->teval = 0 and restore it - * after call of sweph(EMB). - */ - tsv = pedp->teval; - pedp->teval = 0; - retc = sweph(tjd, SEI_EMB, ifno, iflag | SEFLG_SPEED, NULL, NO_SAVE, xemb, serr); - if (retc != OK) - return(retc); - pedp->teval = tsv; - for (i = 0; i <= 2; i++) - xp[i] = xemb[i] - xp[i]; - if (need_speed) - for (i = 3; i <= 5; i++) - xp[i] = xemb[i] - xp[i]; - } -#if 1 - /* asteroids are heliocentric. - * if JPL or SWISSEPH, convert to barycentric */ - if ((iflag & SEFLG_JPLEPH) || (iflag & SEFLG_SWIEPH)) { - if (ipl >= SEI_ANYBODY) { - for (i = 0; i <= 2; i++) - xp[i] += xsunb[i]; - if (need_speed) - for (i = 3; i <= 5; i++) - xp[i] += xsunb[i]; + if (fdp->fptr != NULL) { + /* if tjd is beyond file range, close old file. + * if new asteroid, close old file. */ + if (tjd < fdp->tfstart || tjd > fdp->tfend + || (ipl == SEI_ANYBODY && ipli != pdp->ibdy)) { + fclose(fdp->fptr); + fdp->fptr = NULL; + if (pdp->refep != NULL) + free((void *)pdp->refep); + pdp->refep = NULL; + if (pdp->segp != NULL) + free((void *)pdp->segp); + pdp->segp = NULL; + } + } + /* if sweph file not open, find and open it */ + if (fdp->fptr == NULL) { + swi_gen_filename(tjd, ipli, fname); + strcpy(subdirnam, fname); + sp = strrchr(subdirnam, (int)*DIR_GLUE); + if (sp != NULL) { + *sp = '\0'; + subdirlen = strlen(subdirnam); + } + else { + subdirlen = 0; + } + strcpy(s, fname); +again: + fdp->fptr = swi_fopen(ifno, s, swed.ephepath, serr); + if (fdp->fptr == NULL) { + /* + * if it is a numbered asteroid file, try also for short files (..s.se1) + * On the second try, the inserted 's' will be seen and not tried again. + */ + if (ipli > SE_AST_OFFSET) { + char *spp; + spp = strchr(s, '.'); + if (spp > s && *(spp - 1) != 's') { /* no 's' before '.' ? */ + sprintf(spp, "s.%s", SE_FILE_SUFFIX); /* insert an 's' */ + goto again; + } + /* + * if we still have 'ast0' etc. in front of the filename, + * we remove it now, remove the 's' also, + * and try in the main ephemeris directory instead of the + * asteroid subdirectory. + */ + spp--; /* point to the character before '.' which must be a 's' */ + swi_strcpy(spp, spp + 1); /* remove the s */ + if (subdirlen > 0 + && strncmp(s, subdirnam, (size_t) subdirlen) == 0) { + swi_strcpy(s, s + subdirlen + 1); /* remove "ast0/" etc. */ + goto again; + } + } + return (NOT_AVAILABLE); + } + /* during the search error messages may have been built, delete them */ + if (serr != NULL) + *serr = '\0'; + retc = read_const(ifno, serr); + if (retc != OK) + return (retc); + } + /* if first ephemeris file (J-3000), it might start a mars period + * after -3000. if last ephemeris file (J3000), it might end a + * 4000-day-period before 3000. */ + if (tjd < fdp->tfstart || tjd > fdp->tfend) { + if (serr != NULL) { + if (tjd < fdp->tfstart) + sprintf(s, "jd %f < Swiss Eph. lower limit %f;", tjd, + fdp->tfstart); + else + sprintf(s, "jd %f > Swiss Eph. upper limit %f;", tjd, + fdp->tfend); + if (strlen(serr) + strlen(s) < AS_MAXCH) + strcat(serr, s); + } + return (NOT_AVAILABLE); + } + + /****************************** + * get planet's position + ******************************/ + /* get new segment, if necessary */ + if (pdp->segp == NULL || tjd < pdp->tseg0 || tjd > pdp->tseg1) { + retc = get_new_segment(tjd, ipl, ifno, serr); + if (retc != OK) + return (retc); + /* rotate cheby coeffs back to equatorial system. + * if necessary, add reference orbit. */ + if (pdp->iflg & SEI_FLG_ROTATE) + rot_back(ipl); + /**/ + else + pdp->neval = pdp->ncoe; + } + /* evaluate chebyshew polynomial for tjd */ + t = (tjd - pdp->tseg0) / pdp->dseg; + t = t * 2 - 1; + /* speed is needed, if + * 1. true position is being computed before applying light-time etc. + * this is the position saved in pdp->x. + * in this case, speed is needed for light-time correction. + * 2. the speed flag has been specified. + */ + need_speed = (do_save || (iflag & SEFLG_SPEED)); + for (i = 0; i <= 2; i++) { + xp[i] = swi_echeb(t, pdp->segp + (i * pdp->ncoe), pdp->neval); + if (need_speed) + xp[i + 3] = + swi_edcheb(t, pdp->segp + (i * pdp->ncoe), + pdp->neval) / pdp->dseg * 2; + else + xp[i + 3] = 0; /* von Alois als billiger fix, evtl. illegal */ + } + /* if planet wanted is barycentric sun and must be computed + * from heliocentric earth and barycentric earth: the + * computation above gives heliocentric earth, therefore we + * have to compute barycentric earth and subtract heliocentric + * earth from it. this may be necessary with calls from + * sweplan() and from app_pos_etc_sun() (light-time). */ + if (ipl == SEI_SUNBARY && (pdp->iflg & SEI_FLG_EMBHEL)) { + /* sweph() calls sweph() !!! for EMB. + * Attention: a new calculation must be forced in any case. + * Otherwise EARTH (instead of EMB) will possibly taken from + * save area. + * to force new computation, set pedp->teval = 0 and restore it + * after call of sweph(EMB). + */ + tsv = pedp->teval; + pedp->teval = 0; + retc = + sweph(tjd, SEI_EMB, ifno, iflag | SEFLG_SPEED, NULL, NO_SAVE, + xemb, serr); + if (retc != OK) + return (retc); + pedp->teval = tsv; + for (i = 0; i <= 2; i++) + xp[i] = xemb[i] - xp[i]; + if (need_speed) + for (i = 3; i <= 5; i++) + xp[i] = xemb[i] - xp[i]; + } +#if 1 + /* asteroids are heliocentric. + * if JPL or SWISSEPH, convert to barycentric */ + if ((iflag & SEFLG_JPLEPH) || (iflag & SEFLG_SWIEPH)) { + if (ipl >= SEI_ANYBODY) { + for (i = 0; i <= 2; i++) + xp[i] += xsunb[i]; + if (need_speed) + for (i = 3; i <= 5; i++) + xp[i] += xsunb[i]; + } } - } #endif - if (do_save) { - pdp->teval = tjd; - pdp->xflgs = -1; /* do new computation of light-time etc. */ - if (ifno == SEI_FILE_PLANET || ifno == SEI_FILE_MOON) - pdp->iephe = SEFLG_SWIEPH;/**/ - else - pdp->iephe = psdp->iephe; - } - if (xpret != NULL) - for (i = 0; i <= 5; i++) - xpret[i] = xp[i]; - return(OK); + if (do_save) { + pdp->teval = tjd; + pdp->xflgs = -1; /* do new computation of light-time etc. */ + if (ifno == SEI_FILE_PLANET || ifno == SEI_FILE_MOON) + pdp->iephe = SEFLG_SWIEPH; + /**/ + else + pdp->iephe = psdp->iephe; + } + if (xpret != NULL) + for (i = 0; i <= 5; i++) + xpret[i] = xp[i]; + return (OK); } /* - * Alois 2.12.98: inserted error message generation for file not found + * Alois 2.12.98: inserted error message generation for file not found */ -FILE *swi_fopen(int ifno, char *fname, char *ephepath, char *serr) +FILE * +swi_fopen(int ifno, char *fname, char *ephepath, char *serr) { - int np, i, j; - FILE *fp = NULL; - char *fnamp, fn[AS_MAXCH]; - char *cpos[20]; - char s[2 * AS_MAXCH], *s1 = s + AS_MAXCH; /* a little trick */ - if (ifno >= 0) { - fnamp = swed.fidat[ifno].fnam; - } else { - fnamp = fn; - } - strcpy(s1, ephepath); - np = swi_cutstr(s1, PATH_SEPARATOR, cpos, 20); - for (i = 0; i < np; i++) { - strcpy(s, cpos[i]); - if (strcmp(s, ".") == 0) /* current directory */ - *s = '\0'; - else { - j = strlen(s); - if (*(s + j - 1) != *DIR_GLUE && *s != '\0') - strcat(s, DIR_GLUE); + int np, i, j; + FILE *fp = NULL; + char *fnamp, fn[AS_MAXCH]; + char *cpos[20]; + char s[2 * AS_MAXCH], *s1 = s + AS_MAXCH; /* a little trick */ + if (ifno >= 0) { + fnamp = swed.fidat[ifno].fnam; } - strcpy(fnamp, s); - if (strlen(fnamp) + strlen(fname) < AS_MAXCH) - strcat(fnamp, fname); else { - if (serr != NULL) - sprintf(serr, "error: file path and name must be shorter than %d.", AS_MAXCH); - return NULL; + fnamp = fn; } - fp = fopen(fnamp, BFILE_R_ACCESS); - if (fp != NULL) - return fp; - } - sprintf(s, "SwissEph file '%s' not found in PATH '%s'", fname, ephepath); - s[AS_MAXCH-1] = '\0'; /* s may be longer then AS_MAXCH */ - if (serr != NULL) - strcpy(serr, s); - return NULL; + strcpy(s1, ephepath); + np = swi_cutstr(s1, PATH_SEPARATOR, cpos, 20); + for (i = 0; i < np; i++) { + strcpy(s, cpos[i]); + if (strcmp(s, ".") == 0) /* current directory */ + *s = '\0'; + else { + j = strlen(s); + if (*(s + j - 1) != *DIR_GLUE && *s != '\0') + strcat(s, DIR_GLUE); + } + strcpy(fnamp, s); + if (strlen(fnamp) + strlen(fname) < AS_MAXCH) + strcat(fnamp, fname); + else { + if (serr != NULL) + sprintf(serr, + "error: file path and name must be shorter than %d.", + AS_MAXCH); + return NULL; + } + fp = fopen(fnamp, BFILE_R_ACCESS); + if (fp != NULL) + return fp; + } + sprintf(s, "SwissEph file '%s' not found in PATH '%s'", fname, ephepath); + s[AS_MAXCH - 1] = '\0'; /* s may be longer then AS_MAXCH */ + if (serr != NULL) + strcpy(serr, s); + return NULL; } /* converts planets from barycentric to geocentric, @@ -2020,523 +2138,566 @@ FILE *swi_fopen(int ifno, char *fname, char *ephepath, char *serr) * iflag flags * serr error string */ -static int app_pos_etc_plan(int ipli, int32 iflag, char *serr) +static int +app_pos_etc_plan(int ipli, int32 iflag, char *serr) { - int i, j, niter, retc = OK; - int ipl, ifno, ibody; - int32 flg1, flg2; - double xx[6], dx[3], dt, t, dtsave_for_defl; - double xobs[6], xobs2[6]; - double xearth[6], xsun[6]; - double xxsp[6], xxsv[6]; - struct plan_data *pedp = &swed.pldat[SEI_EARTH]; - struct plan_data *pdp; - struct epsilon *oe = &swed.oec2000; - int32 epheflag = iflag & SEFLG_EPHMASK; - t = dtsave_for_defl = 0; /* dummy assignment to silence gcc */ - /* ephemeris file */ - if (ipli > SE_AST_OFFSET) { - ifno = SEI_FILE_ANY_AST; - ibody = IS_ANY_BODY; - pdp = &swed.pldat[SEI_ANYBODY]; - } else if (ipli == SEI_CHIRON - || ipli == SEI_PHOLUS - || ipli == SEI_CERES - || ipli == SEI_PALLAS - || ipli == SEI_JUNO - || ipli == SEI_VESTA) { - ifno = SEI_FILE_MAIN_AST; - ibody = IS_MAIN_ASTEROID; - pdp = &swed.pldat[ipli]; - } else { - ifno = SEI_FILE_PLANET; - ibody = IS_PLANET; - pdp = &swed.pldat[ipli]; - } - /* if the same conversions have already been done for the same - * date, then return */ - flg1 = iflag & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; - flg2 = pdp->xflgs & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; - if (flg1 == flg2) { - pdp->xflgs = iflag; - pdp->iephe = iflag & SEFLG_EPHMASK; - return OK; - } - /* the conversions will be done with xx[]. */ - for (i = 0; i <= 5; i++) - xx[i] = pdp->x[i]; - /* if heliocentric position is wanted */ - if (iflag & SEFLG_HELCTR) { - if (pdp->iephe == SEFLG_JPLEPH || pdp->iephe == SEFLG_SWIEPH) - for (i = 0; i <= 5; i++) - xx[i] -= swed.pldat[SEI_SUNBARY].x[i]; - } + int i, j, niter, retc = OK; + int ipl, ifno, ibody; + int32 flg1, flg2; + double xx[6], dx[3], dt, t, dtsave_for_defl; + double xobs[6], xobs2[6]; + double xearth[6], xsun[6]; + double xxsp[6], xxsv[6]; + struct plan_data *pedp = &swed.pldat[SEI_EARTH]; + struct plan_data *pdp; + struct epsilon *oe = &swed.oec2000; + int32 epheflag = iflag & SEFLG_EPHMASK; + t = dtsave_for_defl = 0; /* dummy assignment to silence gcc */ + /* ephemeris file */ + if (ipli > SE_AST_OFFSET) { + ifno = SEI_FILE_ANY_AST; + ibody = IS_ANY_BODY; + pdp = &swed.pldat[SEI_ANYBODY]; + } + else if (ipli == SEI_CHIRON || ipli == SEI_PHOLUS || ipli == SEI_CERES + || ipli == SEI_PALLAS || ipli == SEI_JUNO || ipli == SEI_VESTA) { + ifno = SEI_FILE_MAIN_AST; + ibody = IS_MAIN_ASTEROID; + pdp = &swed.pldat[ipli]; + } + else { + ifno = SEI_FILE_PLANET; + ibody = IS_PLANET; + pdp = &swed.pldat[ipli]; + } + /* if the same conversions have already been done for the same + * date, then return */ + flg1 = iflag & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; + flg2 = pdp->xflgs & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; + if (flg1 == flg2) { + pdp->xflgs = iflag; + pdp->iephe = iflag & SEFLG_EPHMASK; + return OK; + } + /* the conversions will be done with xx[]. */ + for (i = 0; i <= 5; i++) + xx[i] = pdp->x[i]; + /* if heliocentric position is wanted */ + if (iflag & SEFLG_HELCTR) { + if (pdp->iephe == SEFLG_JPLEPH || pdp->iephe == SEFLG_SWIEPH) + for (i = 0; i <= 5; i++) + xx[i] -= swed.pldat[SEI_SUNBARY].x[i]; + } + /************************************ * observer: geocenter or topocenter ************************************/ - /* if topocentric position is wanted */ - if (iflag & SEFLG_TOPOCTR) { - if (swed.topd.teval != pedp->teval - || swed.topd.teval == 0) { - if (swi_get_observer(pedp->teval, iflag, DO_SAVE, xobs, serr) != OK) - return ERR; - } else { - for (i = 0; i <= 5; i++) - xobs[i] = swed.topd.xobs[i]; - } - /* barycentric position of observer */ - for (i = 0; i <= 5; i++) - xobs[i] = xobs[i] + pedp->x[i]; - } else { - /* barycentric position of geocenter */ - for (i = 0; i <= 5; i++) - xobs[i] = pedp->x[i]; - } - /******************************* - * light-time geocentric * - *******************************/ - if (!(iflag & SEFLG_TRUEPOS)) { - /* number of iterations - 1 */ - if (pdp->iephe == SEFLG_JPLEPH || pdp->iephe == SEFLG_SWIEPH) - niter = 1; - else /* SEFLG_MOSEPH or planet from osculating elements */ - niter = 0; - if (iflag & SEFLG_SPEED) { - /* - * Apparent speed is influenced by the fact that dt changes with - * motion. This makes a difference of several hundredths of an - * arc second. To take this into account, we compute - * 1. true position - apparent position at time t - 1. - * 2. true position - apparent position at time t. - * 3. the difference between the two is the part of the daily motion - * that results from the change of dt. - */ - for (i = 0; i <= 2; i++) - xxsv[i] = xxsp[i] = xx[i] - xx[i+3]; - for (j = 0; j <= niter; j++) { - for (i = 0; i <= 2; i++) { - dx[i] = xxsp[i]; - if (!(iflag & SEFLG_HELCTR) && !(iflag & SEFLG_BARYCTR)) - dx[i] -= (xobs[i] - xobs[i+3]); - } - /* new dt */ - dt = sqrt(square_sum(dx)) * AUNIT / CLIGHT / 86400.0; - for (i = 0; i <= 2; i++) /* rough apparent position at t-1 */ - xxsp[i] = xxsv[i] - dt * pdp->x[i+3]; - } - /* true position - apparent position at time t-1 */ - for (i = 0; i <= 2; i++) - xxsp[i] = xxsv[i] - xxsp[i]; - } - /* dt and t(apparent) */ - for (j = 0; j <= niter; j++) { - for (i = 0; i <= 2; i++) { - dx[i] = xx[i]; - if (!(iflag & SEFLG_HELCTR) && !(iflag & SEFLG_BARYCTR)) - dx[i] -= xobs[i]; - } - dt = sqrt(square_sum(dx)) * AUNIT / CLIGHT / 86400.0; - /* new t */ - t = pdp->teval - dt; - dtsave_for_defl = dt; - for (i = 0; i <= 2; i++) /* rough apparent position at t*/ - xx[i] = pdp->x[i] - dt * pdp->x[i+3]; - } - /* part of daily motion resulting from change of dt */ - if (iflag & SEFLG_SPEED) - for (i = 0; i <= 2; i++) - xxsp[i] = pdp->x[i] - xx[i] - xxsp[i]; - /* new position, accounting for light-time (accurate) */ - switch(epheflag) { -#ifndef NO_JPL - case SEFLG_JPLEPH: - if (ibody >= IS_ANY_BODY) - ipl = -1; /* will not be used */ /*pnoint2jpl[SEI_ANYBODY];*/ - else - ipl = pnoint2jpl[ipli]; - if (ibody == IS_PLANET) { - retc = swi_pleph(t, ipl, J_SBARY, xx, serr); - if (retc != OK) { - swi_close_jpl_file(); - swed.jpl_file_is_open = FALSE; - } - } else { /* asteroid */ - /* first sun */ - retc = swi_pleph(t, J_SUN, J_SBARY, xsun, serr); - if (retc != OK) { - swi_close_jpl_file(); - swed.jpl_file_is_open = FALSE; - } - /* asteroid */ - retc = sweph(t, ipli, ifno, iflag, xsun, NO_SAVE, xx, serr); - } - if (retc != OK) - return(retc); - /* for accuracy in speed, we need earth as well */ - if ((iflag & SEFLG_SPEED) - && !(iflag & SEFLG_HELCTR) && !(iflag & SEFLG_BARYCTR)) { - retc = swi_pleph(t, J_EARTH, J_SBARY, xearth, serr); - if (retc != OK) { - swi_close_jpl_file(); - swed.jpl_file_is_open = FALSE; - return(retc); - } - } - break; -#endif - case SEFLG_SWIEPH: - if (ibody == IS_PLANET) - retc = sweplan(t, ipli, ifno, iflag, NO_SAVE, xx, xearth, xsun, NULL, serr); - else { /*asteroid*/ - retc = sweplan(t, SEI_EARTH, SEI_FILE_PLANET, iflag, NO_SAVE, xearth, NULL, xsun, NULL, serr); - if (retc == OK) - retc = sweph(t, ipli, ifno, iflag, xsun, NO_SAVE, xx, serr); - } - if (retc != OK) - return(retc); - break; - case SEFLG_MOSEPH: - default: - /* - * with moshier or other ephemerides, subtraction of dt * speed - * is sufficient (has been done in light-time iteration above) - */ -#if 0 - for (i = 0; i <= 2; i++) { - xx[i] = pdp->x[i] - dt * pdp->x[i+3];/**/ - xx[i+3] = pdp->x[i+3]; - } -#endif - /* if speed flag is true, we call swi_moshplan() for new t. - * this does not increase position precision, - * but speed precision, which becomes better than 0.01"/day. - * for precise speed, we need earth as well. - */ - if (iflag & SEFLG_SPEED - && !(iflag & (SEFLG_HELCTR | SEFLG_BARYCTR))) { - if (ibody == IS_PLANET) - retc = swi_moshplan(t, ipli, NO_SAVE, xxsv, xearth, serr); - else { /* if asteroid */ - retc = sweph(t, ipli, ifno, iflag, NULL, NO_SAVE, xxsv, serr); - if (retc == OK) - retc = swi_moshplan(t, SEI_EARTH, NO_SAVE, xearth, xearth, serr); - } - if (retc != OK) - return(retc); - /* only speed is taken from this computation, otherwise position - * calculations with and without speed would not agree. The difference - * would be about 0.01", which is far below the intrinsic error of the - * moshier ephemeris. - */ - for (i = 3; i <= 5; i++) - xx[i] = xxsv[i]; + /* if topocentric position is wanted */ + if (iflag & SEFLG_TOPOCTR) { + if (swed.topd.teval != pedp->teval || swed.topd.teval == 0) { + if (swi_get_observer(pedp->teval, iflag, DO_SAVE, xobs, serr) + != OK) + return ERR; } - break; - } - if (iflag & SEFLG_HELCTR) { - if (pdp->iephe == SEFLG_JPLEPH || pdp->iephe == SEFLG_SWIEPH) - for (i = 0; i <= 5; i++) - xx[i] -= swed.pldat[SEI_SUNBARY].x[i]; - } - if (iflag & SEFLG_SPEED) { - /* observer position for t(light-time) */ - if (iflag & SEFLG_TOPOCTR) { - if (swi_get_observer(t, iflag, NO_SAVE, xobs2, serr) != OK) - return ERR; + else { + for (i = 0; i <= 5; i++) + xobs[i] = swed.topd.xobs[i]; + } + /* barycentric position of observer */ for (i = 0; i <= 5; i++) - xobs2[i] += xearth[i]; - } else { - for (i = 0; i <= 5; i++) - xobs2[i] = xearth[i]; - } + xobs[i] = xobs[i] + pedp->x[i]; } - } + else { + /* barycentric position of geocenter */ + for (i = 0; i <= 5; i++) + xobs[i] = pedp->x[i]; + } + /******************************* - * conversion to geocenter * + * light-time geocentric * *******************************/ - if (!(iflag & SEFLG_HELCTR) && !(iflag & SEFLG_BARYCTR)) { - /* subtract earth */ - for (i = 0; i <= 5; i++) - xx[i] -= xobs[i]; -#if 0 - /* earth and planets are barycentric with jpl and swisseph, - * but asteroids are heliocentric. therefore, add baryctr. sun */ - if (ibody != IS_PLANET && !(iflag & SEFLG_MOSEPH)) { - for (i = 0; i <= 5; i++) - xx[i] += swed.pldat[SEI_SUNBARY].x[i]; - } + if (!(iflag & SEFLG_TRUEPOS)) { + /* number of iterations - 1 */ + if (pdp->iephe == SEFLG_JPLEPH || pdp->iephe == SEFLG_SWIEPH) + niter = 1; + else /* SEFLG_MOSEPH or planet from osculating elements */ + niter = 0; + if (iflag & SEFLG_SPEED) { + /* + * Apparent speed is influenced by the fact that dt changes with + * motion. This makes a difference of several hundredths of an + * arc second. To take this into account, we compute + * 1. true position - apparent position at time t - 1. + * 2. true position - apparent position at time t. + * 3. the difference between the two is the part of the daily motion + * that results from the change of dt. + */ + for (i = 0; i <= 2; i++) + xxsv[i] = xxsp[i] = xx[i] - xx[i + 3]; + for (j = 0; j <= niter; j++) { + for (i = 0; i <= 2; i++) { + dx[i] = xxsp[i]; + if (!(iflag & SEFLG_HELCTR) + && !(iflag & SEFLG_BARYCTR)) + dx[i] -= (xobs[i] - xobs[i + 3]); + } + /* new dt */ + dt = sqrt(square_sum(dx)) * AUNIT / CLIGHT / 86400.0; + for (i = 0; i <= 2; i++) /* rough apparent position at t-1 */ + xxsp[i] = xxsv[i] - dt * pdp->x[i + 3]; + } + /* true position - apparent position at time t-1 */ + for (i = 0; i <= 2; i++) + xxsp[i] = xxsv[i] - xxsp[i]; + } + /* dt and t(apparent) */ + for (j = 0; j <= niter; j++) { + for (i = 0; i <= 2; i++) { + dx[i] = xx[i]; + if (!(iflag & SEFLG_HELCTR) && !(iflag & SEFLG_BARYCTR)) + dx[i] -= xobs[i]; + } + dt = sqrt(square_sum(dx)) * AUNIT / CLIGHT / 86400.0; + /* new t */ + t = pdp->teval - dt; + dtsave_for_defl = dt; + for (i = 0; i <= 2; i++) /* rough apparent position at t */ + xx[i] = pdp->x[i] - dt * pdp->x[i + 3]; + } + /* part of daily motion resulting from change of dt */ + if (iflag & SEFLG_SPEED) + for (i = 0; i <= 2; i++) + xxsp[i] = pdp->x[i] - xx[i] - xxsp[i]; + /* new position, accounting for light-time (accurate) */ + switch (epheflag) { +#ifndef NO_JPL + case SEFLG_JPLEPH: + if (ibody >= IS_ANY_BODY) + ipl = -1; /* will not be used *//*pnoint2jpl[SEI_ANYBODY]; */ + else + ipl = pnoint2jpl[ipli]; + if (ibody == IS_PLANET) { + retc = swi_pleph(t, ipl, J_SBARY, xx, serr); + if (retc != OK) { + swi_close_jpl_file(); + swed.jpl_file_is_open = FALSE; + } + } + else { /* asteroid */ + /* first sun */ + retc = swi_pleph(t, J_SUN, J_SBARY, xsun, serr); + if (retc != OK) { + swi_close_jpl_file(); + swed.jpl_file_is_open = FALSE; + } + /* asteroid */ + retc = + sweph(t, ipli, ifno, iflag, xsun, NO_SAVE, xx, serr); + } + if (retc != OK) + return (retc); + /* for accuracy in speed, we need earth as well */ + if ((iflag & SEFLG_SPEED) + && !(iflag & SEFLG_HELCTR) && !(iflag & SEFLG_BARYCTR)) { + retc = swi_pleph(t, J_EARTH, J_SBARY, xearth, serr); + if (retc != OK) { + swi_close_jpl_file(); + swed.jpl_file_is_open = FALSE; + return (retc); + } + } + break; #endif - if ((iflag & SEFLG_TRUEPOS) == 0 ) { - /* - * Apparent speed is also influenced by - * the change of dt during motion. - * Neglect of this would result in an error of several 0.01" - */ - if (iflag & SEFLG_SPEED) - for (i = 3; i <= 5; i++) - xx[i] -= xxsp[i-3]; + case SEFLG_SWIEPH: + if (ibody == IS_PLANET) + retc = + sweplan(t, ipli, ifno, iflag, NO_SAVE, xx, xearth, + xsun, NULL, serr); + else { /*asteroid */ + retc = + sweplan(t, SEI_EARTH, SEI_FILE_PLANET, iflag, NO_SAVE, + xearth, NULL, xsun, NULL, serr); + if (retc == OK) + retc = + sweph(t, ipli, ifno, iflag, xsun, NO_SAVE, xx, + serr); + } + if (retc != OK) + return (retc); + break; + case SEFLG_MOSEPH: + default: + /* + * with moshier or other ephemerides, subtraction of dt * speed + * is sufficient (has been done in light-time iteration above) + */ +#if 0 + for (i = 0; i <= 2; i++) { + xx[i] = pdp->x[i] - dt * pdp->x[i + 3]; + /**/ xx[i + 3] = pdp->x[i + 3]; + } +#endif + /* if speed flag is true, we call swi_moshplan() for new t. + * this does not increase position precision, + * but speed precision, which becomes better than 0.01"/day. + * for precise speed, we need earth as well. + */ + if (iflag & SEFLG_SPEED + && !(iflag & (SEFLG_HELCTR | SEFLG_BARYCTR))) { + if (ibody == IS_PLANET) + retc = + swi_moshplan(t, ipli, NO_SAVE, xxsv, xearth, + serr); + else { /* if asteroid */ + retc = + sweph(t, ipli, ifno, iflag, NULL, NO_SAVE, xxsv, + serr); + if (retc == OK) + retc = + swi_moshplan(t, SEI_EARTH, NO_SAVE, xearth, + xearth, serr); + } + if (retc != OK) + return (retc); + /* only speed is taken from this computation, otherwise position + * calculations with and without speed would not agree. The difference + * would be about 0.01", which is far below the intrinsic error of the + * moshier ephemeris. + */ + for (i = 3; i <= 5; i++) + xx[i] = xxsv[i]; + } + break; + } + if (iflag & SEFLG_HELCTR) { + if (pdp->iephe == SEFLG_JPLEPH || pdp->iephe == SEFLG_SWIEPH) + for (i = 0; i <= 5; i++) + xx[i] -= swed.pldat[SEI_SUNBARY].x[i]; + } + if (iflag & SEFLG_SPEED) { + /* observer position for t(light-time) */ + if (iflag & SEFLG_TOPOCTR) { + if (swi_get_observer(t, iflag, NO_SAVE, xobs2, serr) != OK) + return ERR; + for (i = 0; i <= 5; i++) + xobs2[i] += xearth[i]; + } + else { + for (i = 0; i <= 5; i++) + xobs2[i] = xearth[i]; + } + } } - } - if (!(iflag & SEFLG_SPEED)) - for (i = 3; i <= 5; i++) - xx[i] = 0; + + /******************************* + * conversion to geocenter * + *******************************/ + if (!(iflag & SEFLG_HELCTR) && !(iflag & SEFLG_BARYCTR)) { + /* subtract earth */ + for (i = 0; i <= 5; i++) + xx[i] -= xobs[i]; +#if 0 + /* earth and planets are barycentric with jpl and swisseph, + * but asteroids are heliocentric. therefore, add baryctr. sun */ + if (ibody != IS_PLANET && !(iflag & SEFLG_MOSEPH)) { + for (i = 0; i <= 5; i++) + xx[i] += swed.pldat[SEI_SUNBARY].x[i]; + } +#endif + if ((iflag & SEFLG_TRUEPOS) == 0) { + /* + * Apparent speed is also influenced by + * the change of dt during motion. + * Neglect of this would result in an error of several 0.01" + */ + if (iflag & SEFLG_SPEED) + for (i = 3; i <= 5; i++) + xx[i] -= xxsp[i - 3]; + } + } + if (!(iflag & SEFLG_SPEED)) + for (i = 3; i <= 5; i++) + xx[i] = 0; + /************************************ * relativistic deflection of light * ************************************/ - if (!(iflag & SEFLG_TRUEPOS) && !(iflag & SEFLG_NOGDEFL)) - /* SEFLG_NOGDEFL is on, if SEFLG_HELCTR or SEFLG_BARYCTR */ - swi_deflect_light(xx, dtsave_for_defl, iflag); + if (!(iflag & SEFLG_TRUEPOS) && !(iflag & SEFLG_NOGDEFL)) + /* SEFLG_NOGDEFL is on, if SEFLG_HELCTR or SEFLG_BARYCTR */ + swi_deflect_light(xx, dtsave_for_defl, iflag); + /********************************** * 'annual' aberration of light * **********************************/ - if (!(iflag & SEFLG_TRUEPOS) && !(iflag & SEFLG_NOABERR)) { - /* SEFLG_NOABERR is on, if SEFLG_HELCTR or SEFLG_BARYCTR */ - swi_aberr_light(xx, xobs, iflag); - /* - * Apparent speed is also influenced by - * the difference of speed of the earth between t and t-dt. - * Neglecting this would involve an error of several 0.1" - */ - if (iflag & SEFLG_SPEED) - for (i = 3; i <= 5; i++) - xx[i] += xobs[i] - xobs2[i]; - } - if (!(iflag & SEFLG_SPEED)) - for (i = 3; i <= 5; i++) - xx[i] = 0; - /* ICRS to J2000 */ - if (!(iflag & SEFLG_ICRS) && swed.jpldenum >= 403) { - swi_bias(xx, iflag, FALSE); - }/**/ - /* save J2000 coordinates; required for sidereal positions */ - for (i = 0; i <= 5; i++) - xxsv[i] = xx[i]; + if (!(iflag & SEFLG_TRUEPOS) && !(iflag & SEFLG_NOABERR)) { + /* SEFLG_NOABERR is on, if SEFLG_HELCTR or SEFLG_BARYCTR */ + swi_aberr_light(xx, xobs, iflag); + /* + * Apparent speed is also influenced by + * the difference of speed of the earth between t and t-dt. + * Neglecting this would involve an error of several 0.1" + */ + if (iflag & SEFLG_SPEED) + for (i = 3; i <= 5; i++) + xx[i] += xobs[i] - xobs2[i]; + } + if (!(iflag & SEFLG_SPEED)) + for (i = 3; i <= 5; i++) + xx[i] = 0; + /* ICRS to J2000 */ + if (!(iflag & SEFLG_ICRS) && swed.jpldenum >= 403) { + swi_bias(xx, iflag, FALSE); + } + /**/ + /* save J2000 coordinates; required for sidereal positions */ + for (i = 0; i <= 5; i++) + xxsv[i] = xx[i]; + /************************************************ * precession, equator 2000 -> equator of date * ************************************************/ - if (!(iflag & SEFLG_J2000)) { - swi_precess(xx, pdp->teval, J2000_TO_J); - if (iflag & SEFLG_SPEED) - swi_precess_speed(xx, pdp->teval, J2000_TO_J); - oe = &swed.oec; - } else - oe = &swed.oec2000; - return app_pos_rest(pdp, iflag, xx, xxsv, oe, serr); + if (!(iflag & SEFLG_J2000)) { + swi_precess(xx, pdp->teval, J2000_TO_J); + if (iflag & SEFLG_SPEED) + swi_precess_speed(xx, pdp->teval, J2000_TO_J); + oe = &swed.oec; + } + else + oe = &swed.oec2000; + return app_pos_rest(pdp, iflag, xx, xxsv, oe, serr); } -static int app_pos_rest(struct plan_data *pdp, int32 iflag, - double *xx, double *x2000, - struct epsilon *oe, char *serr) +static int +app_pos_rest(struct plan_data *pdp, int32 iflag, double *xx, double *x2000, + struct epsilon *oe, char *serr) { - int i; + int i; + /************************************************ * nutation * ************************************************/ - if (!(iflag & SEFLG_NONUT)) - swi_nutate(xx, iflag, FALSE); - /* now we have equatorial cartesian coordinates; save them */ - for (i = 0; i <= 5; i++) - pdp->xreturn[18+i] = xx[i]; + if (!(iflag & SEFLG_NONUT)) + swi_nutate(xx, iflag, FALSE); + /* now we have equatorial cartesian coordinates; save them */ + for (i = 0; i <= 5; i++) + pdp->xreturn[18 + i] = xx[i]; + /************************************************ * transformation to ecliptic. * * with sidereal calc. this will be overwritten * * afterwards. * ************************************************/ - swi_coortrf2(xx, xx, oe->seps, oe->ceps); - if (iflag & SEFLG_SPEED) - swi_coortrf2(xx+3, xx+3, oe->seps, oe->ceps); - if (!(iflag & SEFLG_NONUT)) { - swi_coortrf2(xx, xx, swed.nut.snut, swed.nut.cnut); + swi_coortrf2(xx, xx, oe->seps, oe->ceps); if (iflag & SEFLG_SPEED) - swi_coortrf2(xx+3, xx+3, swed.nut.snut, swed.nut.cnut); - } - /* now we have ecliptic cartesian coordinates */ - for (i = 0; i <= 5; i++) - pdp->xreturn[6+i] = xx[i]; + swi_coortrf2(xx + 3, xx + 3, oe->seps, oe->ceps); + if (!(iflag & SEFLG_NONUT)) { + swi_coortrf2(xx, xx, swed.nut.snut, swed.nut.cnut); + if (iflag & SEFLG_SPEED) + swi_coortrf2(xx + 3, xx + 3, swed.nut.snut, swed.nut.cnut); + } + /* now we have ecliptic cartesian coordinates */ + for (i = 0; i <= 5; i++) + pdp->xreturn[6 + i] = xx[i]; + /************************************ * sidereal positions * ************************************/ - if (iflag & SEFLG_SIDEREAL) { - /* project onto ecliptic t0 */ - if (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) { - if (swi_trop_ra2sid_lon(x2000, pdp->xreturn+6, pdp->xreturn+18, iflag, serr) != OK) - return ERR; - /* project onto solar system equator */ - } else if (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE) { - if (swi_trop_ra2sid_lon_sosy(x2000, pdp->xreturn+6, pdp->xreturn+18, iflag, serr) != OK) - return ERR; - } else { - /* traditional algorithm */ - swi_cartpol_sp(pdp->xreturn+6, pdp->xreturn); - pdp->xreturn[0] -= swe_get_ayanamsa(pdp->teval) * DEGTORAD; - swi_polcart_sp(pdp->xreturn, pdp->xreturn+6); + if (iflag & SEFLG_SIDEREAL) { + /* project onto ecliptic t0 */ + if (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) { + if (swi_trop_ra2sid_lon + (x2000, pdp->xreturn + 6, pdp->xreturn + 18, iflag, + serr) != OK) + return ERR; + /* project onto solar system equator */ + } + else if (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE) { + if (swi_trop_ra2sid_lon_sosy + (x2000, pdp->xreturn + 6, pdp->xreturn + 18, iflag, + serr) != OK) + return ERR; + } + else { + /* traditional algorithm */ + swi_cartpol_sp(pdp->xreturn + 6, pdp->xreturn); + pdp->xreturn[0] -= swe_get_ayanamsa(pdp->teval) * DEGTORAD; + swi_polcart_sp(pdp->xreturn, pdp->xreturn + 6); + } } - } + /************************************************ * transformation to polar coordinates * ************************************************/ - swi_cartpol_sp(pdp->xreturn+18, pdp->xreturn+12); - swi_cartpol_sp(pdp->xreturn+6, pdp->xreturn); - /********************** + swi_cartpol_sp(pdp->xreturn + 18, pdp->xreturn + 12); + swi_cartpol_sp(pdp->xreturn + 6, pdp->xreturn); + + /********************** * radians to degrees * **********************/ - /*if ((iflag & SEFLG_RADIANS) == 0) {*/ + /*if ((iflag & SEFLG_RADIANS) == 0) { */ for (i = 0; i < 2; i++) { - pdp->xreturn[i] *= RADTODEG; /* ecliptic */ - pdp->xreturn[i+3] *= RADTODEG; - pdp->xreturn[i+12] *= RADTODEG; /* equator */ - pdp->xreturn[i+15] *= RADTODEG; - } - /*}*/ - /* save, what has been done */ - pdp->xflgs = iflag; - pdp->iephe = iflag & SEFLG_EPHMASK; - return OK; + pdp->xreturn[i] *= RADTODEG; /* ecliptic */ + pdp->xreturn[i + 3] *= RADTODEG; + pdp->xreturn[i + 12] *= RADTODEG; /* equator */ + pdp->xreturn[i + 15] *= RADTODEG; + } + /*} */ + /* save, what has been done */ + pdp->xflgs = iflag; + pdp->iephe = iflag & SEFLG_EPHMASK; + return OK; } -void FAR PASCAL_CONV swe_set_sid_mode(int32 sid_mode, double t0, double ayan_t0) +void FAR PASCAL_CONV +swe_set_sid_mode(int32 sid_mode, double t0, double ayan_t0) { - struct sid_data *sip = &swed.sidd; - sip->sid_mode = sid_mode; - if (sid_mode >= SE_SIDBITS) - sid_mode %= SE_SIDBITS; - /* standard equinoxes: positions always referred to ecliptic of t0 */ - if (sid_mode == SE_SIDM_J2000 - || sid_mode == SE_SIDM_J1900 - || sid_mode == SE_SIDM_B1950) { - sip->sid_mode |= SE_SIDBIT_ECL_T0; - } - if (sid_mode >= SE_NSIDM_PREDEF && sid_mode != SE_SIDM_USER) { - sip->sid_mode = sid_mode = SE_SIDM_FAGAN_BRADLEY; - } - swed.ayana_is_set = TRUE; - if (sid_mode == SE_SIDM_USER) { - sip->t0 = t0; - sip->ayan_t0 = ayan_t0; - } else { - sip->t0 = ayanamsa[sid_mode].t0; - sip->ayan_t0 = ayanamsa[sid_mode].ayan_t0; - } - swi_force_app_pos_etc(); + struct sid_data *sip = &swed.sidd; + sip->sid_mode = sid_mode; + if (sid_mode >= SE_SIDBITS) + sid_mode %= SE_SIDBITS; + /* standard equinoxes: positions always referred to ecliptic of t0 */ + if (sid_mode == SE_SIDM_J2000 || sid_mode == SE_SIDM_J1900 + || sid_mode == SE_SIDM_B1950) { + sip->sid_mode |= SE_SIDBIT_ECL_T0; + } + if (sid_mode >= SE_NSIDM_PREDEF && sid_mode != SE_SIDM_USER) { + sip->sid_mode = sid_mode = SE_SIDM_FAGAN_BRADLEY; + } + swed.ayana_is_set = TRUE; + if (sid_mode == SE_SIDM_USER) { + sip->t0 = t0; + sip->ayan_t0 = ayan_t0; + } + else { + sip->t0 = ayanamsa[sid_mode].t0; + sip->ayan_t0 = ayanamsa[sid_mode].ayan_t0; + } + swi_force_app_pos_etc(); } -/* the ayanamsa (precession in longitude) +/* the ayanamsa (precession in longitude) * according to Newcomb's definition: 360 - * longitude of the vernal point of t referred to the * ecliptic of t0. */ -double FAR PASCAL_CONV swe_get_ayanamsa(double tjd_et) +double FAR PASCAL_CONV +swe_get_ayanamsa(double tjd_et) { - double x[6], eps; - struct sid_data *sip = &swed.sidd; - if (!swed.ayana_is_set) - swe_set_sid_mode(SE_SIDM_FAGAN_BRADLEY, 0, 0); - /* vernal point (tjd), cartesian */ - x[0] = 1; - x[1] = x[2] = 0; - /* to J2000 */ - if (tjd_et != J2000) - swi_precess(x, tjd_et, J_TO_J2000); - /* to t0 */ - swi_precess(x, sip->t0, J2000_TO_J); - /* to ecliptic */ - eps = swi_epsiln(sip->t0); - swi_coortrf(x, x, eps); - /* to polar */ - swi_cartpol(x, x); - /* subtract initial value of ayanamsa */ - x[0] = x[0] * RADTODEG - sip->ayan_t0; - /* get ayanamsa */ - return swe_degnorm(-x[0]); -} - -double FAR PASCAL_CONV swe_get_ayanamsa_ut(double tjd_ut) -{ - return swe_get_ayanamsa(tjd_ut + swe_deltat(tjd_ut)); -} - -/* - * input coordinates are J2000, cartesian. - * xout ecliptical sidereal position - * xoutr equatorial sidereal position - */ -int swi_trop_ra2sid_lon(double *xin, double *xout, double *xoutr, int32 iflag, char *serr) -{ - double x[6]; - int i; - struct sid_data *sip = &swed.sidd; - struct epsilon oectmp; - for (i = 0; i <= 5; i++) - x[i] = xin[i]; - if (sip->t0 != J2000) { + double x[6], eps; + struct sid_data *sip = &swed.sidd; + if (!swed.ayana_is_set) + swe_set_sid_mode(SE_SIDM_FAGAN_BRADLEY, 0, 0); + /* vernal point (tjd), cartesian */ + x[0] = 1; + x[1] = x[2] = 0; + /* to J2000 */ + if (tjd_et != J2000) + swi_precess(x, tjd_et, J_TO_J2000); + /* to t0 */ swi_precess(x, sip->t0, J2000_TO_J); - swi_precess(x+3, sip->t0, J2000_TO_J); /* speed */ - } - for (i = 0; i <= 5; i++) - xoutr[i] = x[i]; - calc_epsilon(swed.sidd.t0, &oectmp); - swi_coortrf2(x, x, oectmp.seps, oectmp.ceps); - if (iflag & SEFLG_SPEED) - swi_coortrf2(x+3, x+3, oectmp.seps, oectmp.ceps); - /* to polar coordinates */ - swi_cartpol_sp(x, x); - /* subtract ayan_t0 */ - x[0] -= sip->ayan_t0 * DEGTORAD; - /* back to cartesian */ - swi_polcart_sp(x, xout); - return OK; + /* to ecliptic */ + eps = swi_epsiln(sip->t0); + swi_coortrf(x, x, eps); + /* to polar */ + swi_cartpol(x, x); + /* subtract initial value of ayanamsa */ + x[0] = x[0] * RADTODEG - sip->ayan_t0; + /* get ayanamsa */ + return swe_degnorm(-x[0]); } -/* +double FAR PASCAL_CONV +swe_get_ayanamsa_ut(double tjd_ut) +{ + return swe_get_ayanamsa(tjd_ut + swe_deltat(tjd_ut)); +} + +/* * input coordinates are J2000, cartesian. * xout ecliptical sidereal position * xoutr equatorial sidereal position */ -int swi_trop_ra2sid_lon_sosy(double *xin, double *xout, double *xoutr, int32 iflag, char *serr) +int +swi_trop_ra2sid_lon(double *xin, double *xout, double *xoutr, int32 iflag, + char *serr) { - double x[6], x0[6]; - int i; - struct sid_data *sip = &swed.sidd; - struct epsilon *oe = &swed.oec2000; - double plane_node = SSY_PLANE_NODE_E2000; - double plane_incl = SSY_PLANE_INCL; - for (i = 0; i <= 5; i++) - x[i] = xin[i]; - /* planet to ecliptic 2000 */ - swi_coortrf2(x, x, oe->seps, oe->ceps); - if (iflag & SEFLG_SPEED) - swi_coortrf2(x+3, x+3, oe->seps, oe->ceps); - /* to polar coordinates */ - swi_cartpol_sp(x, x); - /* to solar system equator */ - x[0] -= plane_node; - swi_polcart_sp(x, x); - swi_coortrf(x, x, plane_incl); - swi_coortrf(x+3, x+3, plane_incl); - swi_cartpol_sp(x, x); - /* zero point of t0 in J2000 system */ - x0[0] = 1; - x0[1] = x0[2] = 0; - if (sip->t0 != J2000) - swi_precess(x0, sip->t0, J_TO_J2000); - /* zero point to ecliptic 2000 */ - swi_coortrf2(x0, x0, oe->seps, oe->ceps); - /* to polar coordinates */ - swi_cartpol(x0, x0); - /* to solar system equator */ - x0[0] -= plane_node; - swi_polcart(x0, x0); - swi_coortrf(x0, x0, plane_incl); - swi_cartpol(x0, x0); - /* measure planet from zero point */ - x[0] -= x0[0]; - x[0] *= RADTODEG; - /* subtract ayan_t0 */ - x[0] -= sip->ayan_t0; - x[0] = swe_degnorm(x[0]) * DEGTORAD; - /* back to cartesian */ - swi_polcart_sp(x, xout); - return OK; + double x[6]; + int i; + struct sid_data *sip = &swed.sidd; + struct epsilon oectmp; + for (i = 0; i <= 5; i++) + x[i] = xin[i]; + if (sip->t0 != J2000) { + swi_precess(x, sip->t0, J2000_TO_J); + swi_precess(x + 3, sip->t0, J2000_TO_J); /* speed */ + } + for (i = 0; i <= 5; i++) + xoutr[i] = x[i]; + calc_epsilon(swed.sidd.t0, &oectmp); + swi_coortrf2(x, x, oectmp.seps, oectmp.ceps); + if (iflag & SEFLG_SPEED) + swi_coortrf2(x + 3, x + 3, oectmp.seps, oectmp.ceps); + /* to polar coordinates */ + swi_cartpol_sp(x, x); + /* subtract ayan_t0 */ + x[0] -= sip->ayan_t0 * DEGTORAD; + /* back to cartesian */ + swi_polcart_sp(x, xout); + return OK; +} + +/* + * input coordinates are J2000, cartesian. + * xout ecliptical sidereal position + * xoutr equatorial sidereal position + */ +int +swi_trop_ra2sid_lon_sosy(double *xin, double *xout, double *xoutr, + int32 iflag, char *serr) +{ + double x[6], x0[6]; + int i; + struct sid_data *sip = &swed.sidd; + struct epsilon *oe = &swed.oec2000; + double plane_node = SSY_PLANE_NODE_E2000; + double plane_incl = SSY_PLANE_INCL; + for (i = 0; i <= 5; i++) + x[i] = xin[i]; + /* planet to ecliptic 2000 */ + swi_coortrf2(x, x, oe->seps, oe->ceps); + if (iflag & SEFLG_SPEED) + swi_coortrf2(x + 3, x + 3, oe->seps, oe->ceps); + /* to polar coordinates */ + swi_cartpol_sp(x, x); + /* to solar system equator */ + x[0] -= plane_node; + swi_polcart_sp(x, x); + swi_coortrf(x, x, plane_incl); + swi_coortrf(x + 3, x + 3, plane_incl); + swi_cartpol_sp(x, x); + /* zero point of t0 in J2000 system */ + x0[0] = 1; + x0[1] = x0[2] = 0; + if (sip->t0 != J2000) + swi_precess(x0, sip->t0, J_TO_J2000); + /* zero point to ecliptic 2000 */ + swi_coortrf2(x0, x0, oe->seps, oe->ceps); + /* to polar coordinates */ + swi_cartpol(x0, x0); + /* to solar system equator */ + x0[0] -= plane_node; + swi_polcart(x0, x0); + swi_coortrf(x0, x0, plane_incl); + swi_cartpol(x0, x0); + /* measure planet from zero point */ + x[0] -= x0[0]; + x[0] *= RADTODEG; + /* subtract ayan_t0 */ + x[0] -= sip->ayan_t0; + x[0] = swe_degnorm(x[0]) * DEGTORAD; + /* back to cartesian */ + swi_polcart_sp(x, xout); + return OK; } /* converts planets from barycentric to geocentric, @@ -2546,469 +2707,506 @@ int swi_trop_ra2sid_lon_sosy(double *xin, double *xout, double *xoutr, int32 ifl * ipli planet number * iflag flags */ -static int app_pos_etc_plan_osc(int ipl, int ipli, int32 iflag, char *serr) +static int +app_pos_etc_plan_osc(int ipl, int ipli, int32 iflag, char *serr) { - int i, j, niter, retc; - double xx[6], dx[3], dt, dtsave_for_defl; - double xearth[6], xsun[6], xmoon[6]; - double xxsv[6], xxsp[3]={0}, xobs[6], xobs2[6]; - double t; - struct plan_data *pdp = &swed.pldat[ipli]; - struct plan_data *pedp = &swed.pldat[SEI_EARTH]; - struct plan_data *psdp = &swed.pldat[SEI_SUNBARY]; - struct epsilon *oe = &swed.oec2000; - int32 epheflag = SEFLG_DEFAULTEPH; - dt = dtsave_for_defl = 0; /* dummy assign to silence gcc */ - if (iflag & SEFLG_MOSEPH) - epheflag = SEFLG_MOSEPH; - else if (iflag & SEFLG_SWIEPH) - epheflag = SEFLG_SWIEPH; - else if (iflag & SEFLG_JPLEPH) - epheflag = SEFLG_JPLEPH; - /* the conversions will be done with xx[]. */ - for (i = 0; i <= 5; i++) - xx[i] = pdp->x[i]; + int i, j, niter, retc; + double xx[6], dx[3], dt, dtsave_for_defl; + double xearth[6], xsun[6], xmoon[6]; + double xxsv[6], xxsp[3] = { + 0 + }, xobs[6], xobs2[6]; + double t; + struct plan_data *pdp = &swed.pldat[ipli]; + struct plan_data *pedp = &swed.pldat[SEI_EARTH]; + struct plan_data *psdp = &swed.pldat[SEI_SUNBARY]; + struct epsilon *oe = &swed.oec2000; + int32 epheflag = SEFLG_DEFAULTEPH; + dt = dtsave_for_defl = 0; /* dummy assign to silence gcc */ + if (iflag & SEFLG_MOSEPH) + epheflag = SEFLG_MOSEPH; + else if (iflag & SEFLG_SWIEPH) + epheflag = SEFLG_SWIEPH; + else if (iflag & SEFLG_JPLEPH) + epheflag = SEFLG_JPLEPH; + /* the conversions will be done with xx[]. */ + for (i = 0; i <= 5; i++) + xx[i] = pdp->x[i]; + /************************************ * barycentric position is required * ************************************/ - /* = heliocentric position with Moshier ephemeris */ + /* = heliocentric position with Moshier ephemeris */ + /************************************ * observer: geocenter or topocenter ************************************/ - /* if topocentric position is wanted */ - if (iflag & SEFLG_TOPOCTR) { - if (swed.topd.teval != pedp->teval - || swed.topd.teval == 0) { - if (swi_get_observer(pedp->teval, iflag, DO_SAVE, xobs, serr) != OK) - return ERR; - } else { - for (i = 0; i <= 5; i++) - xobs[i] = swed.topd.xobs[i]; - } - /* barycentric position of observer */ - for (i = 0; i <= 5; i++) - xobs[i] = xobs[i] + pedp->x[i]; - } else if (iflag & SEFLG_BARYCTR) { - for (i = 0; i <= 5; i++) - xobs[i] = 0; - } else if (iflag & SEFLG_HELCTR) { - if (iflag & SEFLG_MOSEPH) { - for (i = 0; i <= 5; i++) - xobs[i] = 0; - } else { - for (i = 0; i <= 5; i++) - xobs[i] = psdp->x[i]; - } - } else { - for (i = 0; i <= 5; i++) - xobs[i] = pedp->x[i]; - } - /******************************* - * light-time * - *******************************/ - if (!(iflag & SEFLG_TRUEPOS)) { - niter = 1; - if (iflag & SEFLG_SPEED) { - /* - * Apparent speed is influenced by the fact that dt changes with - * motion. This makes a difference of several hundredths of an - * arc second. To take this into account, we compute - * 1. true position - apparent position at time t - 1. - * 2. true position - apparent position at time t. - * 3. the difference between the two is the daily motion resulting from - * the change of dt. - */ - for (i = 0; i <= 2; i++) - xxsv[i] = xxsp[i] = xx[i] - xx[i+3]; - for (j = 0; j <= niter; j++) { - for (i = 0; i <= 2; i++) { - dx[i] = xxsp[i]; - if (!(iflag & SEFLG_HELCTR) && !(iflag & SEFLG_BARYCTR)) - dx[i] -= (xobs[i] - xobs[i+3]); - } - /* new dt */ - dt = sqrt(square_sum(dx)) * AUNIT / CLIGHT / 86400.0; - for (i = 0; i <= 2; i++) - xxsp[i] = xxsv[i] - dt * pdp->x[i+3];/* rough apparent position */ - } - /* true position - apparent position at time t-1 */ - for (i = 0; i <= 2; i++) - xxsp[i] = xxsv[i] - xxsp[i]; - } - /* dt and t(apparent) */ - for (j = 0; j <= niter; j++) { - for (i = 0; i <= 2; i++) { - dx[i] = xx[i]; - if (!(iflag & SEFLG_HELCTR) && !(iflag & SEFLG_BARYCTR)) - dx[i] -= xobs[i]; - } - /* new dt */ - dt = sqrt(square_sum(dx)) * AUNIT / CLIGHT / 86400.0; - dtsave_for_defl = dt; - /* new position: subtract t * speed - */ - for (i = 0; i <= 2; i++) { - xx[i] = pdp->x[i] - dt * pdp->x[i+3];/**/ - xx[i+3] = pdp->x[i+3]; - } - } - if (iflag & SEFLG_SPEED) { - /* part of daily motion resulting from change of dt */ - for (i = 0; i <= 2; i++) - xxsp[i] = pdp->x[i] - xx[i] - xxsp[i]; - t = pdp->teval - dt; - /* for accuracy in speed, we will need earth as well */ - retc = main_planet_bary(t, SEI_EARTH, epheflag, iflag, NO_SAVE, xearth, xearth, xsun, xmoon, serr); - if (swi_osc_el_plan(t, xx, ipl-SE_FICT_OFFSET, ipli, xearth, xsun, serr) != OK) - return ERR; - if (retc != OK) - return(retc); - if (iflag & SEFLG_TOPOCTR) { - if (swi_get_observer(t, iflag, NO_SAVE, xobs2, serr) != OK) - return ERR; + /* if topocentric position is wanted */ + if (iflag & SEFLG_TOPOCTR) { + if (swed.topd.teval != pedp->teval || swed.topd.teval == 0) { + if (swi_get_observer(pedp->teval, iflag, DO_SAVE, xobs, serr) + != OK) + return ERR; + } + else { + for (i = 0; i <= 5; i++) + xobs[i] = swed.topd.xobs[i]; + } + /* barycentric position of observer */ for (i = 0; i <= 5; i++) - xobs2[i] += xearth[i]; - } else { - for (i = 0; i <= 5; i++) - xobs2[i] = xearth[i]; - } + xobs[i] = xobs[i] + pedp->x[i]; } - } + else if (iflag & SEFLG_BARYCTR) { + for (i = 0; i <= 5; i++) + xobs[i] = 0; + } + else if (iflag & SEFLG_HELCTR) { + if (iflag & SEFLG_MOSEPH) { + for (i = 0; i <= 5; i++) + xobs[i] = 0; + } + else { + for (i = 0; i <= 5; i++) + xobs[i] = psdp->x[i]; + } + } + else { + for (i = 0; i <= 5; i++) + xobs[i] = pedp->x[i]; + } + /******************************* - * conversion to geocenter * + * light-time * *******************************/ - for (i = 0; i <= 5; i++) - xx[i] -= xobs[i]; - if (!(iflag & SEFLG_TRUEPOS)) { - /* - * Apparent speed is also influenced by - * the change of dt during motion. - * Neglect of this would result in an error of several 0.01" - */ - if (iflag & SEFLG_SPEED) - for (i = 3; i <= 5; i++) - xx[i] -= xxsp[i-3]; - } - if (!(iflag & SEFLG_SPEED)) - for (i = 3; i <= 5; i++) - xx[i] = 0; + if (!(iflag & SEFLG_TRUEPOS)) { + niter = 1; + if (iflag & SEFLG_SPEED) { + /* + * Apparent speed is influenced by the fact that dt changes with + * motion. This makes a difference of several hundredths of an + * arc second. To take this into account, we compute + * 1. true position - apparent position at time t - 1. + * 2. true position - apparent position at time t. + * 3. the difference between the two is the daily motion resulting from + * the change of dt. + */ + for (i = 0; i <= 2; i++) + xxsv[i] = xxsp[i] = xx[i] - xx[i + 3]; + for (j = 0; j <= niter; j++) { + for (i = 0; i <= 2; i++) { + dx[i] = xxsp[i]; + if (!(iflag & SEFLG_HELCTR) + && !(iflag & SEFLG_BARYCTR)) + dx[i] -= (xobs[i] - xobs[i + 3]); + } + /* new dt */ + dt = sqrt(square_sum(dx)) * AUNIT / CLIGHT / 86400.0; + for (i = 0; i <= 2; i++) + xxsp[i] = xxsv[i] - dt * pdp->x[i + 3]; /* rough apparent position */ + } + /* true position - apparent position at time t-1 */ + for (i = 0; i <= 2; i++) + xxsp[i] = xxsv[i] - xxsp[i]; + } + /* dt and t(apparent) */ + for (j = 0; j <= niter; j++) { + for (i = 0; i <= 2; i++) { + dx[i] = xx[i]; + if (!(iflag & SEFLG_HELCTR) && !(iflag & SEFLG_BARYCTR)) + dx[i] -= xobs[i]; + } + /* new dt */ + dt = sqrt(square_sum(dx)) * AUNIT / CLIGHT / 86400.0; + dtsave_for_defl = dt; + /* new position: subtract t * speed + */ + for (i = 0; i <= 2; i++) { + xx[i] = pdp->x[i] - dt * pdp->x[i + 3]; + /**/ xx[i + 3] = pdp->x[i + 3]; + } + } + if (iflag & SEFLG_SPEED) { + /* part of daily motion resulting from change of dt */ + for (i = 0; i <= 2; i++) + xxsp[i] = pdp->x[i] - xx[i] - xxsp[i]; + t = pdp->teval - dt; + /* for accuracy in speed, we will need earth as well */ + retc = + main_planet_bary(t, SEI_EARTH, epheflag, iflag, NO_SAVE, + xearth, xearth, xsun, xmoon, serr); + if (swi_osc_el_plan + (t, xx, ipl - SE_FICT_OFFSET, ipli, xearth, xsun, serr) != OK) + return ERR; + if (retc != OK) + return (retc); + if (iflag & SEFLG_TOPOCTR) { + if (swi_get_observer(t, iflag, NO_SAVE, xobs2, serr) != OK) + return ERR; + for (i = 0; i <= 5; i++) + xobs2[i] += xearth[i]; + } + else { + for (i = 0; i <= 5; i++) + xobs2[i] = xearth[i]; + } + } + } + + /******************************* + * conversion to geocenter * + *******************************/ + for (i = 0; i <= 5; i++) + xx[i] -= xobs[i]; + if (!(iflag & SEFLG_TRUEPOS)) { + /* + * Apparent speed is also influenced by + * the change of dt during motion. + * Neglect of this would result in an error of several 0.01" + */ + if (iflag & SEFLG_SPEED) + for (i = 3; i <= 5; i++) + xx[i] -= xxsp[i - 3]; + } + if (!(iflag & SEFLG_SPEED)) + for (i = 3; i <= 5; i++) + xx[i] = 0; + /************************************ * relativistic deflection of light * ************************************/ - if (!(iflag & SEFLG_TRUEPOS) && !(iflag & SEFLG_NOGDEFL)) - /* SEFLG_NOGDEFL is on, if SEFLG_HELCTR or SEFLG_BARYCTR */ - swi_deflect_light(xx, dtsave_for_defl, iflag); + if (!(iflag & SEFLG_TRUEPOS) && !(iflag & SEFLG_NOGDEFL)) + /* SEFLG_NOGDEFL is on, if SEFLG_HELCTR or SEFLG_BARYCTR */ + swi_deflect_light(xx, dtsave_for_defl, iflag); + /********************************** * 'annual' aberration of light * **********************************/ - if (!(iflag & SEFLG_TRUEPOS) && !(iflag & SEFLG_NOABERR)) { - /* SEFLG_NOABERR is on, if SEFLG_HELCTR or SEFLG_BARYCTR */ - swi_aberr_light(xx, xobs, iflag); - /* - * Apparent speed is also influenced by - * the difference of speed of the earth between t and t-dt. - * Neglecting this would involve an error of several 0.1" - */ - if (iflag & SEFLG_SPEED) - for (i = 3; i <= 5; i++) - xx[i] += xobs[i] - xobs2[i]; - } - /* save J2000 coordinates; required for sidereal positions */ - for (i = 0; i <= 5; i++) - xxsv[i] = xx[i]; + if (!(iflag & SEFLG_TRUEPOS) && !(iflag & SEFLG_NOABERR)) { + /* SEFLG_NOABERR is on, if SEFLG_HELCTR or SEFLG_BARYCTR */ + swi_aberr_light(xx, xobs, iflag); + /* + * Apparent speed is also influenced by + * the difference of speed of the earth between t and t-dt. + * Neglecting this would involve an error of several 0.1" + */ + if (iflag & SEFLG_SPEED) + for (i = 3; i <= 5; i++) + xx[i] += xobs[i] - xobs2[i]; + } + /* save J2000 coordinates; required for sidereal positions */ + for (i = 0; i <= 5; i++) + xxsv[i] = xx[i]; + /************************************************ * precession, equator 2000 -> equator of date * ************************************************/ - if (!(iflag & SEFLG_J2000)) { - swi_precess(xx, pdp->teval, J2000_TO_J); - if (iflag & SEFLG_SPEED) - swi_precess_speed(xx, pdp->teval, J2000_TO_J); - oe = &swed.oec; - } else - oe = &swed.oec2000; - return app_pos_rest(pdp, iflag, xx, xxsv, oe, serr); + if (!(iflag & SEFLG_J2000)) { + swi_precess(xx, pdp->teval, J2000_TO_J); + if (iflag & SEFLG_SPEED) + swi_precess_speed(xx, pdp->teval, J2000_TO_J); + oe = &swed.oec; + } + else + oe = &swed.oec2000; + return app_pos_rest(pdp, iflag, xx, xxsv, oe, serr); } -/* influence of precession on speed +/* influence of precession on speed * xx position and speed of planet in equatorial cartesian * coordinates */ -void swi_precess_speed(double *xx, double t, int direction) +void +swi_precess_speed(double *xx, double t, int direction) { - struct epsilon *oe; - double fac, dpre, dpre2; - double tprec = (t - J2000) / 36525.0; - if (direction == J2000_TO_J) { - fac = 1; - oe = &swed.oec; - } else { - fac = -1; - oe = &swed.oec2000; - } - /* first correct rotation. - * this costs some sines and cosines, but neglect might - * involve an error > 1"/day */ - swi_precess(xx+3, t, direction); - /* then add 0.137"/day */ - swi_coortrf2(xx, xx, oe->seps, oe->ceps); - swi_coortrf2(xx+3, xx+3, oe->seps, oe->ceps); - swi_cartpol_sp(xx, xx); - if (PREC_VONDRAK_2011) { - swi_ldp_peps(t, &dpre, NULL); - swi_ldp_peps(t + 1, &dpre2, NULL); - xx[3] += (dpre2 - dpre) * fac; - } else { - xx[3] += (50.290966 + 0.0222226 * tprec) / 3600 / 365.25 * DEGTORAD * fac; - /* formula from Montenbruck, German 1994, p. 18 */ - } - swi_polcart_sp(xx, xx); - swi_coortrf2(xx, xx, -oe->seps, oe->ceps); - swi_coortrf2(xx+3, xx+3, -oe->seps, oe->ceps); + struct epsilon *oe; + double fac, dpre, dpre2; + double tprec = (t - J2000) / 36525.0; + if (direction == J2000_TO_J) { + fac = 1; + oe = &swed.oec; + } + else { + fac = -1; + oe = &swed.oec2000; + } + /* first correct rotation. + * this costs some sines and cosines, but neglect might + * involve an error > 1"/day */ + swi_precess(xx + 3, t, direction); + /* then add 0.137"/day */ + swi_coortrf2(xx, xx, oe->seps, oe->ceps); + swi_coortrf2(xx + 3, xx + 3, oe->seps, oe->ceps); + swi_cartpol_sp(xx, xx); + if (PREC_VONDRAK_2011) { + swi_ldp_peps(t, &dpre, NULL); + swi_ldp_peps(t + 1, &dpre2, NULL); + xx[3] += (dpre2 - dpre) * fac; + } + else { + xx[3] += + (50.290966 + 0.0222226 * tprec) / 3600 / 365.25 * DEGTORAD * fac; + /* formula from Montenbruck, German 1994, p. 18 */ + } + swi_polcart_sp(xx, xx); + swi_coortrf2(xx, xx, -oe->seps, oe->ceps); + swi_coortrf2(xx + 3, xx + 3, -oe->seps, oe->ceps); } /* multiplies cartesian equatorial coordinates with previously - * calculated nutation matrix. also corrects speed. + * calculated nutation matrix. also corrects speed. */ -void swi_nutate(double *xx, int32 iflag, AS_BOOL backward) +void +swi_nutate(double *xx, int32 iflag, AS_BOOL backward) { - int i; - double x[6], xv[6]; - for (i = 0; i <= 2; i++) { - if (backward) - x[i] = xx[0] * swed.nut.matrix[i][0] + - xx[1] * swed.nut.matrix[i][1] + - xx[2] * swed.nut.matrix[i][2]; - else - x[i] = xx[0] * swed.nut.matrix[0][i] + - xx[1] * swed.nut.matrix[1][i] + - xx[2] * swed.nut.matrix[2][i]; - } - if (iflag & SEFLG_SPEED) { - /* correct speed: - * first correct rotation */ + int i; + double x[6], xv[6]; for (i = 0; i <= 2; i++) { - if (backward) - x[i+3] = xx[3] * swed.nut.matrix[i][0] + - xx[4] * swed.nut.matrix[i][1] + - xx[5] * swed.nut.matrix[i][2]; - else - x[i+3] = xx[3] * swed.nut.matrix[0][i] + - xx[4] * swed.nut.matrix[1][i] + - xx[5] * swed.nut.matrix[2][i]; + if (backward) + x[i] = + xx[0] * swed.nut.matrix[i][0] + + xx[1] * swed.nut.matrix[i][1] + xx[2] * swed.nut.matrix[i][2]; + else + x[i] = + xx[0] * swed.nut.matrix[0][i] + + xx[1] * swed.nut.matrix[1][i] + xx[2] * swed.nut.matrix[2][i]; } - /* then apparent motion due to change of nutation during day. - * this makes a difference of 0.01" */ - for (i = 0; i <= 2; i++) { - if (backward) - xv[i] = xx[0] * swed.nutv.matrix[i][0] + - xx[1] * swed.nutv.matrix[i][1] + - xx[2] * swed.nutv.matrix[i][2]; - else - xv[i] = xx[0] * swed.nutv.matrix[0][i] + - xx[1] * swed.nutv.matrix[1][i] + - xx[2] * swed.nutv.matrix[2][i]; - /* new speed */ - xx[3+i] = x[3+i] + (x[i] - xv[i]) / NUT_SPEED_INTV; + if (iflag & SEFLG_SPEED) { + /* correct speed: + * first correct rotation */ + for (i = 0; i <= 2; i++) { + if (backward) + x[i + 3] = + xx[3] * swed.nut.matrix[i][0] + + xx[4] * swed.nut.matrix[i][1] + + xx[5] * swed.nut.matrix[i][2]; + else + x[i + 3] = + xx[3] * swed.nut.matrix[0][i] + + xx[4] * swed.nut.matrix[1][i] + + xx[5] * swed.nut.matrix[2][i]; + } + /* then apparent motion due to change of nutation during day. + * this makes a difference of 0.01" */ + for (i = 0; i <= 2; i++) { + if (backward) + xv[i] = + xx[0] * swed.nutv.matrix[i][0] + + xx[1] * swed.nutv.matrix[i][1] + + xx[2] * swed.nutv.matrix[i][2]; + else + xv[i] = + xx[0] * swed.nutv.matrix[0][i] + + xx[1] * swed.nutv.matrix[1][i] + + xx[2] * swed.nutv.matrix[2][i]; + /* new speed */ + xx[3 + i] = x[3 + i] + (x[i] - xv[i]) / NUT_SPEED_INTV; + } } - } - /* new position */ - for (i = 0; i <= 2; i++) - xx[i] = x[i]; + /* new position */ + for (i = 0; i <= 2; i++) + xx[i] = x[i]; } /* computes 'annual' aberration - * xx planet's position accounted for light-time + * xx planet's position accounted for light-time * and gravitational light deflection * xe earth's position and speed */ -void swi_aberr_light(double *xx, double *xe, int32 iflag) { - int i; - double xxs[6], v[6], u[6], ru; - double xx2[6], dx1, dx2; - double b_1, f1, f2; - double v2; - double intv = PLAN_SPEED_INTV; - for (i = 0; i <= 5; i++) - u[i] = xxs[i] = xx[i]; - ru = sqrt(square_sum(u)); - for (i = 0; i <= 2; i++) - v[i] = xe[i+3] / 24.0 / 3600.0 / CLIGHT * AUNIT; - v2 = square_sum(v); - b_1 = sqrt(1 - v2); - f1 = dot_prod(u, v) / ru; - f2 = 1.0 + f1 / (1.0 + b_1); - for (i = 0; i <= 2; i++) - xx[i] = (b_1*xx[i] + f2*ru*v[i]) / (1.0 + f1); - if (iflag & SEFLG_SPEED) { - /* correction of speed - * the influence of aberration on apparent velocity can - * reach 0.4"/day - */ - for (i = 0; i <= 2; i++) - u[i] = xxs[i] - intv * xxs[i+3]; +void +swi_aberr_light(double *xx, double *xe, int32 iflag) +{ + int i; + double xxs[6], v[6], u[6], ru; + double xx2[6], dx1, dx2; + double b_1, f1, f2; + double v2; + double intv = PLAN_SPEED_INTV; + for (i = 0; i <= 5; i++) + u[i] = xxs[i] = xx[i]; ru = sqrt(square_sum(u)); + for (i = 0; i <= 2; i++) + v[i] = xe[i + 3] / 24.0 / 3600.0 / CLIGHT * AUNIT; + v2 = square_sum(v); + b_1 = sqrt(1 - v2); f1 = dot_prod(u, v) / ru; f2 = 1.0 + f1 / (1.0 + b_1); - for (i = 0; i <= 2; i++) - xx2[i] = (b_1*u[i] + f2*ru*v[i]) / (1.0 + f1); - for (i = 0; i <= 2; i++) { - dx1 = xx[i] - xxs[i]; - dx2 = xx2[i] - u[i]; - dx1 -= dx2; - xx[i+3] += dx1 / intv; + for (i = 0; i <= 2; i++) + xx[i] = (b_1 * xx[i] + f2 * ru * v[i]) / (1.0 + f1); + if (iflag & SEFLG_SPEED) { + /* correction of speed + * the influence of aberration on apparent velocity can + * reach 0.4"/day + */ + for (i = 0; i <= 2; i++) + u[i] = xxs[i] - intv * xxs[i + 3]; + ru = sqrt(square_sum(u)); + f1 = dot_prod(u, v) / ru; + f2 = 1.0 + f1 / (1.0 + b_1); + for (i = 0; i <= 2; i++) + xx2[i] = (b_1 * u[i] + f2 * ru * v[i]) / (1.0 + f1); + for (i = 0; i <= 2; i++) { + dx1 = xx[i] - xxs[i]; + dx2 = xx2[i] - u[i]; + dx1 -= dx2; + xx[i + 3] += dx1 / intv; + } } - } } /* computes relativistic light deflection by the sun - * ipli sweph internal planet number + * ipli sweph internal planet number * xx planet's position accounted for light-time * dt dt of light-time */ -void swi_deflect_light(double *xx, double dt, int32 iflag) +void +swi_deflect_light(double *xx, double dt, int32 iflag) { - int i; - double xx2[6]; - double u[6], e[6], q[6], ru, re, rq, uq, ue, qe, g1, g2; + int i; + double xx2[6]; + double u[6], e[6], q[6], ru, re, rq, uq, ue, qe, g1, g2; #if 1 - double xx3[6], dx1, dx2, dtsp; + double xx3[6], dx1, dx2, dtsp; #endif - double xsun[6], xearth[6]; - double sina, sin_sunr, meff_fact; - struct plan_data *pedp = &swed.pldat[SEI_EARTH]; - struct plan_data *psdp = &swed.pldat[SEI_SUNBARY]; - int32 iephe = pedp->iephe; - for (i = 0; i <= 5; i++) - xearth[i] = pedp->x[i]; - if (iflag & SEFLG_TOPOCTR) + double xsun[6], xearth[6]; + double sina, sin_sunr, meff_fact; + struct plan_data *pedp = &swed.pldat[SEI_EARTH]; + struct plan_data *psdp = &swed.pldat[SEI_SUNBARY]; + int32 iephe = pedp->iephe; for (i = 0; i <= 5; i++) - xearth[i] += swed.topd.xobs[i]; - /* U = planetbary(t-tau) - earthbary(t) = planetgeo */ - for (i = 0; i <= 2; i++) - u[i] = xx[i]; - /* Eh = earthbary(t) - sunbary(t) = earthhel */ - if (iephe == SEFLG_JPLEPH || iephe == SEFLG_SWIEPH) - for (i = 0; i <= 2; i++) - e[i] = xearth[i] - psdp->x[i]; - else - for (i = 0; i <= 2; i++) - e[i] = xearth[i]; - /* Q = planetbary(t-tau) - sunbary(t-tau) = 'planethel' */ - /* first compute sunbary(t-tau) for */ - if (iephe == SEFLG_JPLEPH || iephe == SEFLG_SWIEPH) { - for (i = 0; i <= 2; i++) - /* this is sufficient precision */ - xsun[i] = psdp->x[i] - dt * psdp->x[i+3]; - for (i = 3; i <= 5; i++) - xsun[i] = psdp->x[i]; - } else { - for (i = 0; i <= 5; i++) - xsun[i] = psdp->x[i]; - } - for (i = 0; i <= 2; i++) - q[i] = xx[i] + xearth[i] - xsun[i]; - ru = sqrt(square_sum(u)); - rq = sqrt(square_sum(q)); - re = sqrt(square_sum(e)); - for (i = 0; i <= 2; i++) { - u[i] /= ru; - q[i] /= rq; - e[i] /= re; - } - uq = dot_prod(u,q); - ue = dot_prod(u,e); - qe = dot_prod(q,e); - /* When a planet approaches the center of the sun in superior - * conjunction, the formula for the deflection angle as given - * in Expl. Suppl. p. 136 cannot be used. The deflection seems - * to increase rapidly towards infinity. The reason is that the - * formula considers the sun as a point mass. AA recommends to - * set deflection = 0 in such a case. - * However, to get a continous motion, we modify the formula - * for a non-point-mass, taking into account the mass distribution - * within the sun. For more info, s. meff(). - */ - sina = sqrt(1 - ue * ue); /* sin(angle) between sun and planet */ - sin_sunr = SUN_RADIUS / re; /* sine of sun radius (= sun radius) */ - if (sina < sin_sunr) - meff_fact = meff(sina / sin_sunr); - else - meff_fact = 1; - g1 = 2.0 * HELGRAVCONST * meff_fact / CLIGHT / CLIGHT / AUNIT / re; - g2 = 1.0 + qe; - /* compute deflected position */ - for (i = 0; i <= 2; i++) - xx2[i] = ru * (u[i] + g1/g2 * (uq * e[i] - ue * q[i])); - if (iflag & SEFLG_SPEED) { - /* correction of speed - * influence of light deflection on a planet's apparent speed: - * for an outer planet at the solar limb with - * |v(planet) - v(sun)| = 1 degree, this makes a difference of 7"/day. - * if the planet is within the solar disc, the difference may increase - * to 30" or more. - * e.g. mercury at j2434871.45: - * distance from sun 45" - * 1. speed without deflection 2d10'10".4034 - * 2. speed with deflection 2d10'42".8460 (-speed flag) - * 3. speed with deflection 2d10'43".4824 (< 3 positions/ - * -speed3 flag) - * 3. is not very precise. Smaller dt would give result closer to 2., - * but will probably never be as good as 2, unless int32 doubles are - * used. (try also j2434871.46!!) - * however, in such a case speed changes rapidly. before being - * passed by the sun, the planet accelerates, and after the sun - * has passed it slows down. some time later it regains 'normal' - * speed. - * to compute speed, we do the same calculation as above with - * slightly different u, e, q, and find out the difference in - * deflection. - */ - dtsp = -DEFL_SPEED_INTV; + xearth[i] = pedp->x[i]; + if (iflag & SEFLG_TOPOCTR) + for (i = 0; i <= 5; i++) + xearth[i] += swed.topd.xobs[i]; /* U = planetbary(t-tau) - earthbary(t) = planetgeo */ - for (i = 0; i <= 2; i++) - u[i] = xx[i] - dtsp * xx[i+3]; - /* Eh = earthbary(t) - sunbary(t) = earthhel */ - if (iephe == SEFLG_JPLEPH || iephe == SEFLG_SWIEPH) { - for (i = 0; i <= 2; i++) - e[i] = xearth[i] - psdp->x[i] - - dtsp * (xearth[i+3] - psdp->x[i+3]); - } else - for (i = 0; i <= 2; i++) - e[i] = xearth[i] - dtsp * xearth[i+3]; - /* Q = planetbary(t-tau) - sunbary(t-tau) = 'planethel' */ for (i = 0; i <= 2; i++) - q[i] = u[i] + xearth[i] - xsun[i] - - dtsp * (xearth[i+3] - xsun[i+3]); + u[i] = xx[i]; + /* Eh = earthbary(t) - sunbary(t) = earthhel */ + if (iephe == SEFLG_JPLEPH || iephe == SEFLG_SWIEPH) + for (i = 0; i <= 2; i++) + e[i] = xearth[i] - psdp->x[i]; + else + for (i = 0; i <= 2; i++) + e[i] = xearth[i]; + /* Q = planetbary(t-tau) - sunbary(t-tau) = 'planethel' */ + /* first compute sunbary(t-tau) for */ + if (iephe == SEFLG_JPLEPH || iephe == SEFLG_SWIEPH) { + for (i = 0; i <= 2; i++) + /* this is sufficient precision */ + xsun[i] = psdp->x[i] - dt * psdp->x[i + 3]; + for (i = 3; i <= 5; i++) + xsun[i] = psdp->x[i]; + } + else { + for (i = 0; i <= 5; i++) + xsun[i] = psdp->x[i]; + } + for (i = 0; i <= 2; i++) + q[i] = xx[i] + xearth[i] - xsun[i]; ru = sqrt(square_sum(u)); rq = sqrt(square_sum(q)); re = sqrt(square_sum(e)); for (i = 0; i <= 2; i++) { - u[i] /= ru; - q[i] /= rq; - e[i] /= re; + u[i] /= ru; + q[i] /= rq; + e[i] /= re; } - uq = dot_prod(u,q); - ue = dot_prod(u,e); - qe = dot_prod(q,e); - sina = sqrt(1 - ue * ue); /* sin(angle) between sun and planet */ - sin_sunr = SUN_RADIUS / re; /* sine of sun radius (= sun radius) */ - if (sina < sin_sunr) - meff_fact = meff(sina / sin_sunr); + uq = dot_prod(u, q); + ue = dot_prod(u, e); + qe = dot_prod(q, e); + /* When a planet approaches the center of the sun in superior + * conjunction, the formula for the deflection angle as given + * in Expl. Suppl. p. 136 cannot be used. The deflection seems + * to increase rapidly towards infinity. The reason is that the + * formula considers the sun as a point mass. AA recommends to + * set deflection = 0 in such a case. + * However, to get a continous motion, we modify the formula + * for a non-point-mass, taking into account the mass distribution + * within the sun. For more info, s. meff(). + */ + sina = sqrt(1 - ue * ue); /* sin(angle) between sun and planet */ + sin_sunr = SUN_RADIUS / re; /* sine of sun radius (= sun radius) */ + if (sina < sin_sunr) + meff_fact = meff(sina / sin_sunr); else - meff_fact = 1; - g1 = 2.0 * HELGRAVCONST * meff_fact / CLIGHT / CLIGHT / AUNIT / re; + meff_fact = 1; + g1 = 2.0 * HELGRAVCONST * meff_fact / CLIGHT / CLIGHT / AUNIT / re; g2 = 1.0 + qe; - for (i = 0; i <= 2; i++) - xx3[i] = ru * (u[i] + g1/g2 * (uq * e[i] - ue * q[i])); - for (i = 0; i <= 2; i++) { - dx1 = xx2[i] - xx[i]; - dx2 = xx3[i] - u[i] * ru; - dx1 -= dx2; - xx[i+3] += dx1 / dtsp; - } - } /* endif speed */ - /* deflected position */ - for (i = 0; i <= 2; i++) - xx[i] = xx2[i]; + /* compute deflected position */ + for (i = 0; i <= 2; i++) + xx2[i] = ru * (u[i] + g1 / g2 * (uq * e[i] - ue * q[i])); + if (iflag & SEFLG_SPEED) { + /* correction of speed + * influence of light deflection on a planet's apparent speed: + * for an outer planet at the solar limb with + * |v(planet) - v(sun)| = 1 degree, this makes a difference of 7"/day. + * if the planet is within the solar disc, the difference may increase + * to 30" or more. + * e.g. mercury at j2434871.45: + * distance from sun 45" + * 1. speed without deflection 2d10'10".4034 + * 2. speed with deflection 2d10'42".8460 (-speed flag) + * 3. speed with deflection 2d10'43".4824 (< 3 positions/ + * -speed3 flag) + * 3. is not very precise. Smaller dt would give result closer to 2., + * but will probably never be as good as 2, unless int32 doubles are + * used. (try also j2434871.46!!) + * however, in such a case speed changes rapidly. before being + * passed by the sun, the planet accelerates, and after the sun + * has passed it slows down. some time later it regains 'normal' + * speed. + * to compute speed, we do the same calculation as above with + * slightly different u, e, q, and find out the difference in + * deflection. + */ + dtsp = -DEFL_SPEED_INTV; + /* U = planetbary(t-tau) - earthbary(t) = planetgeo */ + for (i = 0; i <= 2; i++) + u[i] = xx[i] - dtsp * xx[i + 3]; + /* Eh = earthbary(t) - sunbary(t) = earthhel */ + if (iephe == SEFLG_JPLEPH || iephe == SEFLG_SWIEPH) { + for (i = 0; i <= 2; i++) + e[i] = + xearth[i] - psdp->x[i] - dtsp * (xearth[i + 3] - + psdp->x[i + 3]); + } + else + for (i = 0; i <= 2; i++) + e[i] = xearth[i] - dtsp * xearth[i + 3]; + /* Q = planetbary(t-tau) - sunbary(t-tau) = 'planethel' */ + for (i = 0; i <= 2; i++) + q[i] = + u[i] + xearth[i] - xsun[i] - dtsp * (xearth[i + 3] - + xsun[i + 3]); + ru = sqrt(square_sum(u)); + rq = sqrt(square_sum(q)); + re = sqrt(square_sum(e)); + for (i = 0; i <= 2; i++) { + u[i] /= ru; + q[i] /= rq; + e[i] /= re; + } + uq = dot_prod(u, q); + ue = dot_prod(u, e); + qe = dot_prod(q, e); + sina = sqrt(1 - ue * ue); /* sin(angle) between sun and planet */ + sin_sunr = SUN_RADIUS / re; /* sine of sun radius (= sun radius) */ + if (sina < sin_sunr) + meff_fact = meff(sina / sin_sunr); + else + meff_fact = 1; + g1 = 2.0 * HELGRAVCONST * meff_fact / CLIGHT / CLIGHT / AUNIT / re; + g2 = 1.0 + qe; + for (i = 0; i <= 2; i++) + xx3[i] = ru * (u[i] + g1 / g2 * (uq * e[i] - ue * q[i])); + for (i = 0; i <= 2; i++) { + dx1 = xx2[i] - xx[i]; + dx2 = xx3[i] - u[i] * ru; + dx1 -= dx2; + xx[i + 3] += dx1 / dtsp; + } + } /* endif speed */ + /* deflected position */ + for (i = 0; i <= 2; i++) + xx[i] = xx2[i]; } /* converts the sun from barycentric to geocentric, @@ -3020,174 +3218,196 @@ void swi_deflect_light(double *xx, double dt, int32 iflag) * iflag flags * serr error string */ -static int app_pos_etc_sun(int32 iflag, char *serr) +static int +app_pos_etc_sun(int32 iflag, char *serr) { - int i, j, niter, retc = OK; - int32 flg1, flg2; - double xx[6], xxsv[6], dx[3], dt, t; - double xearth[6], xsun[6], xobs[6]; - struct plan_data *pedp = &swed.pldat[SEI_EARTH]; - struct plan_data *psdp = &swed.pldat[SEI_SUNBARY]; - struct epsilon *oe = &swed.oec2000; - /* if the same conversions have already been done for the same - * date, then return */ - flg1 = iflag & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; - flg2 = pedp->xflgs & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; - if (flg1 == flg2) { - pedp->xflgs = iflag; - pedp->iephe = iflag & SEFLG_EPHMASK; - return OK; - } + int i, j, niter, retc = OK; + int32 flg1, flg2; + double xx[6], xxsv[6], dx[3], dt, t; + double xearth[6], xsun[6], xobs[6]; + struct plan_data *pedp = &swed.pldat[SEI_EARTH]; + struct plan_data *psdp = &swed.pldat[SEI_SUNBARY]; + struct epsilon *oe = &swed.oec2000; + /* if the same conversions have already been done for the same + * date, then return */ + flg1 = iflag & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; + flg2 = pedp->xflgs & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; + if (flg1 == flg2) { + pedp->xflgs = iflag; + pedp->iephe = iflag & SEFLG_EPHMASK; + return OK; + } + /************************************ * observer: geocenter or topocenter ************************************/ - /* if topocentric position is wanted */ - if (iflag & SEFLG_TOPOCTR) { - if (swed.topd.teval != pedp->teval - || swed.topd.teval == 0) { - if (swi_get_observer(pedp->teval, iflag, DO_SAVE, xobs, serr) != OK) - return ERR; - } else { - for (i = 0; i <= 5; i++) - xobs[i] = swed.topd.xobs[i]; + /* if topocentric position is wanted */ + if (iflag & SEFLG_TOPOCTR) { + if (swed.topd.teval != pedp->teval || swed.topd.teval == 0) { + if (swi_get_observer(pedp->teval, iflag, DO_SAVE, xobs, serr) + != OK) + return ERR; + } + else { + for (i = 0; i <= 5; i++) + xobs[i] = swed.topd.xobs[i]; + } + /* barycentric position of observer */ + for (i = 0; i <= 5; i++) + xobs[i] = xobs[i] + pedp->x[i]; } - /* barycentric position of observer */ - for (i = 0; i <= 5; i++) - xobs[i] = xobs[i] + pedp->x[i]; - } else { - /* barycentric position of geocenter */ - for (i = 0; i <= 5; i++) - xobs[i] = pedp->x[i]; - } + else { + /* barycentric position of geocenter */ + for (i = 0; i <= 5; i++) + xobs[i] = pedp->x[i]; + } + /*************************************** * true heliocentric position of earth * ***************************************/ - if (pedp->iephe == SEFLG_MOSEPH || (iflag & SEFLG_BARYCTR)) - for (i = 0; i <= 5; i++) - xx[i] = xobs[i]; - else - for (i = 0; i <= 5; i++) - xx[i] = xobs[i] - psdp->x[i]; + if (pedp->iephe == SEFLG_MOSEPH || (iflag & SEFLG_BARYCTR)) + for (i = 0; i <= 5; i++) + xx[i] = xobs[i]; + else + for (i = 0; i <= 5; i++) + xx[i] = xobs[i] - psdp->x[i]; + /******************************* - * light-time * + * light-time * *******************************/ - if (!(iflag & SEFLG_TRUEPOS)) { - /* number of iterations - 1 - * the following if() does the following: - * with jpl and swiss ephemeris: - * with geocentric computation of sun: - * light-time correction of barycentric sun position. - * with heliocentric or barycentric computation of earth: - * light-time correction of barycentric earth position. - * with moshier ephemeris (heliocentric!!!): - * with geocentric computation of sun: - * nothing! (aberration will be done later) - * with heliocentric or barycentric computation of earth: - * light-time correction of heliocentric earth position. - */ - if (pedp->iephe == SEFLG_JPLEPH || pedp->iephe == SEFLG_SWIEPH - || (iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) { - for (i = 0; i <= 5; i++) { - xearth[i] = xobs[i]; - if (pedp->iephe == SEFLG_MOSEPH) - xsun[i] = 0; - else - xsun[i] = psdp->x[i]; - } - niter = 1; /* # of iterations */ - for (j = 0; j <= niter; j++) { - /* distance earth-sun */ - for (i = 0; i <= 2; i++) { - dx[i] = xearth[i]; - if (!(iflag & SEFLG_BARYCTR)) - dx[i] -= xsun[i]; - } - /* new t */ - dt = sqrt(square_sum(dx)) * AUNIT / CLIGHT / 86400.0; - t = pedp->teval - dt; - /* new position */ - switch(pedp->iephe) { - /* if geocentric sun, new sun at t' - * if heliocentric or barycentric earth, new earth at t' */ + if (!(iflag & SEFLG_TRUEPOS)) { + /* number of iterations - 1 + * the following if() does the following: + * with jpl and swiss ephemeris: + * with geocentric computation of sun: + * light-time correction of barycentric sun position. + * with heliocentric or barycentric computation of earth: + * light-time correction of barycentric earth position. + * with moshier ephemeris (heliocentric!!!): + * with geocentric computation of sun: + * nothing! (aberration will be done later) + * with heliocentric or barycentric computation of earth: + * light-time correction of heliocentric earth position. + */ + if (pedp->iephe == SEFLG_JPLEPH || pedp->iephe == SEFLG_SWIEPH + || (iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) { + for (i = 0; i <= 5; i++) { + xearth[i] = xobs[i]; + if (pedp->iephe == SEFLG_MOSEPH) + xsun[i] = 0; + else + xsun[i] = psdp->x[i]; + } + niter = 1; /* # of iterations */ + for (j = 0; j <= niter; j++) { + /* distance earth-sun */ + for (i = 0; i <= 2; i++) { + dx[i] = xearth[i]; + if (!(iflag & SEFLG_BARYCTR)) + dx[i] -= xsun[i]; + } + /* new t */ + dt = sqrt(square_sum(dx)) * AUNIT / CLIGHT / 86400.0; + t = pedp->teval - dt; + /* new position */ + switch (pedp->iephe) { + /* if geocentric sun, new sun at t' + * if heliocentric or barycentric earth, new earth at t' */ #ifndef NO_JPL - case SEFLG_JPLEPH: - if ((iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) - retc = swi_pleph(t, J_EARTH, J_SBARY, xearth, serr); - else - retc = swi_pleph(t, J_SUN, J_SBARY, xsun, serr); - if (retc != OK) { - swi_close_jpl_file(); - swed.jpl_file_is_open = FALSE; - return(retc); - } - break; + case SEFLG_JPLEPH: + if ((iflag & SEFLG_HELCTR) + || (iflag & SEFLG_BARYCTR)) + retc = + swi_pleph(t, J_EARTH, J_SBARY, xearth, serr); + else + retc = swi_pleph(t, J_SUN, J_SBARY, xsun, serr); + if (retc != OK) { + swi_close_jpl_file(); + swed.jpl_file_is_open = FALSE; + return (retc); + } + break; #endif - case SEFLG_SWIEPH: - /* - retc = sweph(t, SEI_SUN, SEI_FILE_PLANET, iflag, NULL, NO_SAVE, xearth, serr); - */ - if ((iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) - retc = sweplan(t, SEI_EARTH, SEI_FILE_PLANET, iflag, NO_SAVE, xearth, NULL, xsun, NULL, serr); - else - retc = sweph(t, SEI_SUNBARY, SEI_FILE_PLANET, iflag, NULL, NO_SAVE, xsun, serr); - break; - case SEFLG_MOSEPH: - if ((iflag & SEFLG_HELCTR) || (iflag & SEFLG_BARYCTR)) - retc = swi_moshplan(t, SEI_EARTH, NO_SAVE, xearth, xearth, serr); - /* with moshier there is no barycentric sun */ - break; - default: - retc = ERR; - break; - } - if (retc != OK) - return(retc); - } - /* apparent heliocentric earth */ - for (i = 0; i <= 5; i++) { - xx[i] = xearth[i]; - if (!(iflag & SEFLG_BARYCTR)) - xx[i] -= xsun[i]; - } - } - } - if (!(iflag & SEFLG_SPEED)) - for (i = 3; i <= 5; i++) - xx[i] = 0; + case SEFLG_SWIEPH: + /* + * retc = sweph(t, SEI_SUN, SEI_FILE_PLANET, iflag, NULL, NO_SAVE, xearth, serr); + */ + if ((iflag & SEFLG_HELCTR) + || (iflag & SEFLG_BARYCTR)) + retc = + sweplan(t, SEI_EARTH, SEI_FILE_PLANET, iflag, + NO_SAVE, xearth, NULL, xsun, NULL, + serr); + else + retc = + sweph(t, SEI_SUNBARY, SEI_FILE_PLANET, iflag, + NULL, NO_SAVE, xsun, serr); + break; + case SEFLG_MOSEPH: + if ((iflag & SEFLG_HELCTR) + || (iflag & SEFLG_BARYCTR)) + retc = + swi_moshplan(t, SEI_EARTH, NO_SAVE, xearth, + xearth, serr); + /* with moshier there is no barycentric sun */ + break; + default: + retc = ERR; + break; + } + if (retc != OK) + return (retc); + } + /* apparent heliocentric earth */ + for (i = 0; i <= 5; i++) { + xx[i] = xearth[i]; + if (!(iflag & SEFLG_BARYCTR)) + xx[i] -= xsun[i]; + } + } + } + if (!(iflag & SEFLG_SPEED)) + for (i = 3; i <= 5; i++) + xx[i] = 0; + /******************************* - * conversion to geocenter * + * conversion to geocenter * *******************************/ - if (!(iflag & SEFLG_HELCTR) && !(iflag & SEFLG_BARYCTR)) - for (i = 0; i <= 5; i++) - xx[i] = -xx[i]; + if (!(iflag & SEFLG_HELCTR) && !(iflag & SEFLG_BARYCTR)) + for (i = 0; i <= 5; i++) + xx[i] = -xx[i]; + /********************************** * 'annual' aberration of light * **********************************/ - if (!(iflag & SEFLG_TRUEPOS) && !(iflag & SEFLG_NOABERR)) { - /* SEFLG_NOABERR is on, if SEFLG_HELCTR or SEFLG_BARYCTR */ - swi_aberr_light(xx, xobs, iflag); - } - if (!(iflag & SEFLG_SPEED)) - for (i = 3; i <= 5; i++) - xx[i] = 0; - /* ICRS to J2000 */ - if (!(iflag & SEFLG_ICRS) && swed.jpldenum >= 403) { - swi_bias(xx, iflag, FALSE); - }/**/ - /* save J2000 coordinates; required for sidereal positions */ - for (i = 0; i <= 5; i++) - xxsv[i] = xx[i]; + if (!(iflag & SEFLG_TRUEPOS) && !(iflag & SEFLG_NOABERR)) { + /* SEFLG_NOABERR is on, if SEFLG_HELCTR or SEFLG_BARYCTR */ + swi_aberr_light(xx, xobs, iflag); + } + if (!(iflag & SEFLG_SPEED)) + for (i = 3; i <= 5; i++) + xx[i] = 0; + /* ICRS to J2000 */ + if (!(iflag & SEFLG_ICRS) && swed.jpldenum >= 403) { + swi_bias(xx, iflag, FALSE); + } + /**/ + /* save J2000 coordinates; required for sidereal positions */ + for (i = 0; i <= 5; i++) + xxsv[i] = xx[i]; + /************************************************ * precession, equator 2000 -> equator of date * ************************************************/ - if (!(iflag & SEFLG_J2000)) { - swi_precess(xx, pedp->teval, J2000_TO_J);/**/ - if (iflag & SEFLG_SPEED) - swi_precess_speed(xx, pedp->teval, J2000_TO_J);/**/ - oe = &swed.oec; - } else - oe = &swed.oec2000; - return app_pos_rest(pedp, iflag, xx, xxsv, oe, serr); + if (!(iflag & SEFLG_J2000)) { + swi_precess(xx, pedp->teval, J2000_TO_J); + /**/ if (iflag & SEFLG_SPEED) + swi_precess_speed(xx, pedp->teval, J2000_TO_J); + /**/ oe = &swed.oec; + } + else + oe = &swed.oec2000; + return app_pos_rest(pedp, iflag, xx, xxsv, oe, serr); } @@ -3197,172 +3417,190 @@ static int app_pos_etc_sun(int32 iflag, char *serr) * astrometric position * apparent position * precession and nutation - * - * note: + * + * note: * for apparent positions, we consider the earth-moon * system as independant. - * for astrometric positions (SEFLG_NOABERR), we - * consider the motions of the earth and the moon + * for astrometric positions (SEFLG_NOABERR), we + * consider the motions of the earth and the moon * related to the solar system barycenter. */ -static int app_pos_etc_moon(int32 iflag, char *serr) +static int +app_pos_etc_moon(int32 iflag, char *serr) { - int i; - int32 flg1, flg2; - double xx[6], xxsv[6], xobs[6], xxm[6], xs[6], xe[6], xobs2[6], dt; - struct plan_data *pedp = &swed.pldat[SEI_EARTH]; - struct plan_data *psdp = &swed.pldat[SEI_SUNBARY]; - struct plan_data *pdp = &swed.pldat[SEI_MOON]; - struct epsilon *oe = &swed.oec; - double t; - int32 retc; - /* if the same conversions have already been done for the same - * date, then return */ - flg1 = iflag & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; - flg2 = pdp->xflgs & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; - if (flg1 == flg2) { - pdp->xflgs = iflag; - pdp->iephe = iflag & SEFLG_EPHMASK; - return OK; - } - /* the conversions will be done with xx[]. */ - for (i = 0; i <= 5; i++) { - xx[i] = pdp->x[i]; - xxm[i] = xx[i]; - } + int i; + int32 flg1, flg2; + double xx[6], xxsv[6], xobs[6], xxm[6], xs[6], xe[6], xobs2[6], dt; + struct plan_data *pedp = &swed.pldat[SEI_EARTH]; + struct plan_data *psdp = &swed.pldat[SEI_SUNBARY]; + struct plan_data *pdp = &swed.pldat[SEI_MOON]; + struct epsilon *oe = &swed.oec; + double t; + int32 retc; + /* if the same conversions have already been done for the same + * date, then return */ + flg1 = iflag & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; + flg2 = pdp->xflgs & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; + if (flg1 == flg2) { + pdp->xflgs = iflag; + pdp->iephe = iflag & SEFLG_EPHMASK; + return OK; + } + /* the conversions will be done with xx[]. */ + for (i = 0; i <= 5; i++) { + xx[i] = pdp->x[i]; + xxm[i] = xx[i]; + } + /*********************************** * to solar system barycentric ***********************************/ - for (i = 0; i <= 5; i++) - xx[i] += pedp->x[i]; + for (i = 0; i <= 5; i++) + xx[i] += pedp->x[i]; + /******************************* * observer *******************************/ - if (iflag & SEFLG_TOPOCTR) { - if (swed.topd.teval != pdp->teval - || swed.topd.teval == 0) { - if (swi_get_observer(pdp->teval, iflag, DO_SAVE, xobs, NULL) != OK) - return ERR; - } else { - for (i = 0; i <= 5; i++) - xobs[i] = swed.topd.xobs[i]; - } - for (i = 0; i <= 5; i++) - xxm[i] -= xobs[i]; - for (i = 0; i <= 5; i++) - xobs[i] += pedp->x[i]; - } else if (iflag & SEFLG_BARYCTR) { - for (i = 0; i <= 5; i++) - xobs[i] = 0; - for (i = 0; i <= 5; i++) - xxm[i] += pedp->x[i]; - } else if (iflag & SEFLG_HELCTR) { - for (i = 0; i <= 5; i++) - xobs[i] = psdp->x[i]; - for (i = 0; i <= 5; i++) - xxm[i] += pedp->x[i] - psdp->x[i]; - } else { - for (i = 0; i <= 5; i++) - xobs[i] = pedp->x[i]; - } - /******************************* - * light-time * - *******************************/ - if ((iflag & SEFLG_TRUEPOS) == 0) { - dt = sqrt(square_sum(xxm)) * AUNIT / CLIGHT / 86400.0; - t = pdp->teval - dt; - switch(pdp->iephe) { - case SEFLG_JPLEPH: - retc = swi_pleph(t, J_MOON, J_EARTH, xx, serr); - if (retc == OK) - retc = swi_pleph(t, J_EARTH, J_SBARY, xe, serr); - if (retc == OK && (iflag & SEFLG_HELCTR)) - retc = swi_pleph(t, J_SUN, J_SBARY, xs, serr); - if (retc != OK) { - swi_close_jpl_file(); - swed.jpl_file_is_open = FALSE; - } - for (i = 0; i <= 5; i++) - xx[i] += xe[i]; - break; - case SEFLG_SWIEPH: - retc = sweplan(t, SEI_MOON, SEI_FILE_MOON, iflag, NO_SAVE, xx, xe, xs, NULL, serr); - if (retc != OK) - return(retc); - for (i = 0; i <= 5; i++) - xx[i] += xe[i]; - break; - case SEFLG_MOSEPH: - /* this method results in an error of a milliarcsec in speed */ - for (i = 0; i <= 2; i++) { - xx[i] -= dt * xx[i+3]; - xe[i] = pedp->x[i] - dt * pedp->x[i+3]; - xe[i+3] = pedp->x[i+3]; - xs[i] = 0; - xs[i+3] = 0; - } - break; - } if (iflag & SEFLG_TOPOCTR) { - if (swi_get_observer(t, iflag, NO_SAVE, xobs2, NULL) != OK) - return ERR; - for (i = 0; i <= 5; i++) - xobs2[i] += xe[i]; - } else if (iflag & SEFLG_BARYCTR) { - for (i = 0; i <= 5; i++) - xobs2[i] = 0; - } else if (iflag & SEFLG_HELCTR) { - for (i = 0; i <= 5; i++) - xobs2[i] = xs[i]; - } else { - for (i = 0; i <= 5; i++) - xobs2[i] = xe[i]; + if (swed.topd.teval != pdp->teval || swed.topd.teval == 0) { + if (swi_get_observer(pdp->teval, iflag, DO_SAVE, xobs, NULL) + != OK) + return ERR; + } + else { + for (i = 0; i <= 5; i++) + xobs[i] = swed.topd.xobs[i]; + } + for (i = 0; i <= 5; i++) + xxm[i] -= xobs[i]; + for (i = 0; i <= 5; i++) + xobs[i] += pedp->x[i]; } - } + else if (iflag & SEFLG_BARYCTR) { + for (i = 0; i <= 5; i++) + xobs[i] = 0; + for (i = 0; i <= 5; i++) + xxm[i] += pedp->x[i]; + } + else if (iflag & SEFLG_HELCTR) { + for (i = 0; i <= 5; i++) + xobs[i] = psdp->x[i]; + for (i = 0; i <= 5; i++) + xxm[i] += pedp->x[i] - psdp->x[i]; + } + else { + for (i = 0; i <= 5; i++) + xobs[i] = pedp->x[i]; + } + + /******************************* + * light-time * + *******************************/ + if ((iflag & SEFLG_TRUEPOS) == 0) { + dt = sqrt(square_sum(xxm)) * AUNIT / CLIGHT / 86400.0; + t = pdp->teval - dt; + switch (pdp->iephe) { + case SEFLG_JPLEPH: + retc = swi_pleph(t, J_MOON, J_EARTH, xx, serr); + if (retc == OK) + retc = swi_pleph(t, J_EARTH, J_SBARY, xe, serr); + if (retc == OK && (iflag & SEFLG_HELCTR)) + retc = swi_pleph(t, J_SUN, J_SBARY, xs, serr); + if (retc != OK) { + swi_close_jpl_file(); + swed.jpl_file_is_open = FALSE; + } + for (i = 0; i <= 5; i++) + xx[i] += xe[i]; + break; + case SEFLG_SWIEPH: + retc = + sweplan(t, SEI_MOON, SEI_FILE_MOON, iflag, NO_SAVE, xx, + xe, xs, NULL, serr); + if (retc != OK) + return (retc); + for (i = 0; i <= 5; i++) + xx[i] += xe[i]; + break; + case SEFLG_MOSEPH: + /* this method results in an error of a milliarcsec in speed */ + for (i = 0; i <= 2; i++) { + xx[i] -= dt * xx[i + 3]; + xe[i] = pedp->x[i] - dt * pedp->x[i + 3]; + xe[i + 3] = pedp->x[i + 3]; + xs[i] = 0; + xs[i + 3] = 0; + } + break; + } + if (iflag & SEFLG_TOPOCTR) { + if (swi_get_observer(t, iflag, NO_SAVE, xobs2, NULL) != OK) + return ERR; + for (i = 0; i <= 5; i++) + xobs2[i] += xe[i]; + } + else if (iflag & SEFLG_BARYCTR) { + for (i = 0; i <= 5; i++) + xobs2[i] = 0; + } + else if (iflag & SEFLG_HELCTR) { + for (i = 0; i <= 5; i++) + xobs2[i] = xs[i]; + } + else { + for (i = 0; i <= 5; i++) + xobs2[i] = xe[i]; + } + } + /************************* - * to correct center + * to correct center *************************/ - for (i = 0; i <= 5; i++) - xx[i] -= xobs[i]; + for (i = 0; i <= 5; i++) + xx[i] -= xobs[i]; + /********************************** * 'annual' aberration of light * **********************************/ - if (!(iflag & SEFLG_TRUEPOS) && !(iflag & SEFLG_NOABERR)) { - /* SEFLG_NOABERR is on, if SEFLG_HELCTR or SEFLG_BARYCTR */ - swi_aberr_light(xx, xobs, iflag); - /* - * Apparent speed is also influenced by - * the difference of speed of the earth between t and t-dt. - * Neglecting this would lead to an error of several 0.1" - */ + if (!(iflag & SEFLG_TRUEPOS) && !(iflag & SEFLG_NOABERR)) { + /* SEFLG_NOABERR is on, if SEFLG_HELCTR or SEFLG_BARYCTR */ + swi_aberr_light(xx, xobs, iflag); + /* + * Apparent speed is also influenced by + * the difference of speed of the earth between t and t-dt. + * Neglecting this would lead to an error of several 0.1" + */ #if 1 - if (iflag & SEFLG_SPEED) - for (i = 3; i <= 5; i++) - xx[i] += xobs[i] - xobs2[i]; + if (iflag & SEFLG_SPEED) + for (i = 3; i <= 5; i++) + xx[i] += xobs[i] - xobs2[i]; #endif - } - /* if !speedflag, speed = 0 */ - if (!(iflag & SEFLG_SPEED)) - for (i = 3; i <= 5; i++) - xx[i] = 0; - /* ICRS to J2000 */ - if (!(iflag & SEFLG_ICRS) && swed.jpldenum >= 403) { - swi_bias(xx, iflag, FALSE); - }/**/ - /* save J2000 coordinates; required for sidereal positions */ - for (i = 0; i <= 5; i++) - xxsv[i] = xx[i]; + } + /* if !speedflag, speed = 0 */ + if (!(iflag & SEFLG_SPEED)) + for (i = 3; i <= 5; i++) + xx[i] = 0; + /* ICRS to J2000 */ + if (!(iflag & SEFLG_ICRS) && swed.jpldenum >= 403) { + swi_bias(xx, iflag, FALSE); + } + /**/ + /* save J2000 coordinates; required for sidereal positions */ + for (i = 0; i <= 5; i++) + xxsv[i] = xx[i]; + /************************************************ * precession, equator 2000 -> equator of date * ************************************************/ - if (!(iflag & SEFLG_J2000)) { - swi_precess(xx, pdp->teval, J2000_TO_J); - if (iflag & SEFLG_SPEED) - swi_precess_speed(xx, pdp->teval, J2000_TO_J); - oe = &swed.oec; - } else - oe = &swed.oec2000; - return app_pos_rest(pdp, iflag, xx, xxsv, oe, serr); + if (!(iflag & SEFLG_J2000)) { + swi_precess(xx, pdp->teval, J2000_TO_J); + if (iflag & SEFLG_SPEED) + swi_precess_speed(xx, pdp->teval, J2000_TO_J); + oe = &swed.oec; + } + else + oe = &swed.oec2000; + return app_pos_rest(pdp, iflag, xx, xxsv, oe, serr); } /* transforms the position of the barycentric sun: @@ -3371,45 +3609,50 @@ static int app_pos_etc_moon(int32 iflag, char *serr) * iflag flags * serr error string */ -static int app_pos_etc_sbar(int32 iflag, char *serr) +static int +app_pos_etc_sbar(int32 iflag, char *serr) { - int i; - double xx[6], xxsv[6], dt; - struct plan_data *psdp = &swed.pldat[SEI_EARTH]; - struct plan_data *psbdp = &swed.pldat[SEI_SUNBARY]; - struct epsilon *oe = &swed.oec; - /* the conversions will be done with xx[]. */ - for (i = 0; i <= 5; i++) - xx[i] = psbdp->x[i]; + int i; + double xx[6], xxsv[6], dt; + struct plan_data *psdp = &swed.pldat[SEI_EARTH]; + struct plan_data *psbdp = &swed.pldat[SEI_SUNBARY]; + struct epsilon *oe = &swed.oec; + /* the conversions will be done with xx[]. */ + for (i = 0; i <= 5; i++) + xx[i] = psbdp->x[i]; + /************** * light-time * **************/ - if (!(iflag & SEFLG_TRUEPOS)) { - dt = sqrt(square_sum(xx)) * AUNIT / CLIGHT / 86400.0; - for (i = 0; i <= 2; i++) - xx[i] -= dt * xx[i+3]; /* apparent position */ - } - if (!(iflag & SEFLG_SPEED)) - for (i = 3; i <= 5; i++) - xx[i] = 0; - /* ICRS to J2000 */ - if (!(iflag & SEFLG_ICRS) && swed.jpldenum >= 403) { - swi_bias(xx, iflag, FALSE); - }/**/ - /* save J2000 coordinates; required for sidereal positions */ - for (i = 0; i <= 5; i++) - xxsv[i] = xx[i]; + if (!(iflag & SEFLG_TRUEPOS)) { + dt = sqrt(square_sum(xx)) * AUNIT / CLIGHT / 86400.0; + for (i = 0; i <= 2; i++) + xx[i] -= dt * xx[i + 3]; /* apparent position */ + } + if (!(iflag & SEFLG_SPEED)) + for (i = 3; i <= 5; i++) + xx[i] = 0; + /* ICRS to J2000 */ + if (!(iflag & SEFLG_ICRS) && swed.jpldenum >= 403) { + swi_bias(xx, iflag, FALSE); + } + /**/ + /* save J2000 coordinates; required for sidereal positions */ + for (i = 0; i <= 5; i++) + xxsv[i] = xx[i]; + /************************************************ * precession, equator 2000 -> equator of date * ************************************************/ - if (!(iflag & SEFLG_J2000)) { - swi_precess(xx, psbdp->teval, J2000_TO_J); - if (iflag & SEFLG_SPEED) - swi_precess_speed(xx, psbdp->teval, J2000_TO_J); - oe = &swed.oec; - } else - oe = &swed.oec2000; - return app_pos_rest(psdp, iflag, xx, xxsv, oe, serr); + if (!(iflag & SEFLG_J2000)) { + swi_precess(xx, psbdp->teval, J2000_TO_J); + if (iflag & SEFLG_SPEED) + swi_precess_speed(xx, psbdp->teval, J2000_TO_J); + oe = &swed.oec; + } + else + oe = &swed.oec2000; + return app_pos_rest(psdp, iflag, xx, xxsv, oe, serr); } /* transforms position of mean lunar node or apogee: @@ -3417,7 +3660,7 @@ static int app_pos_etc_sbar(int32 iflag, char *serr) * output is, according to iflag: * position accounted for light-time * position referred to J2000 (i.e. precession subtracted) - * position with nutation + * position with nutation * equatorial coordinates * cartesian coordinates * heliocentric position is not allowed ?????????????? @@ -3427,69 +3670,73 @@ static int app_pos_etc_sbar(int32 iflag, char *serr) * iflag flags * serr error string */ -static int app_pos_etc_mean(int ipl, int32 iflag, char *serr) +static int +app_pos_etc_mean(int ipl, int32 iflag, char *serr) { - int i; - int32 flg1, flg2; - double xx[6], xxsv[6]; + int i; + int32 flg1, flg2; + double xx[6], xxsv[6]; #if 0 - struct node_data *pdp = &swed.nddat[ipl]; + struct node_data *pdp = &swed.nddat[ipl]; #else - struct plan_data *pdp = &swed.nddat[ipl]; + struct plan_data *pdp = &swed.nddat[ipl]; #endif - struct epsilon *oe; - /* if the same conversions have already been done for the same - * date, then return */ - flg1 = iflag & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; - flg2 = pdp->xflgs & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; - if (flg1 == flg2) { - pdp->xflgs = iflag; - pdp->iephe = iflag & SEFLG_EPHMASK; - return OK; - } - for (i = 0; i <= 5; i++) - xx[i] = pdp->x[i]; - /* cartesian equatorial coordinates */ - swi_polcart_sp(xx, xx); - swi_coortrf2(xx, xx, -swed.oec.seps, swed.oec.ceps); - swi_coortrf2(xx+3, xx+3, -swed.oec.seps, swed.oec.ceps); -#if 0 - /**************************************************** - * light-time, this is only a few milliarcseconds * - ***************************************************/ - if ((iflag & SEFLG_TRUEPOS) == 0) { - dt = pdp->x[3] * AUNIT / CLIGHT / 86400; - for (i = 0; i <= 2; i++) - xx[i] -= dt * xx[i+3]; - } -#endif - if (!(iflag & SEFLG_SPEED)) - for (i = 3; i <= 5; i++) - xx[i] = 0; - /* J2000 coordinates; required for sidereal positions */ - if (((iflag & SEFLG_SIDEREAL) - && (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0)) - || (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE)) { - for (i = 0; i <= 5; i++) - xxsv[i] = xx[i]; - /* xxsv is not J2000 yet! */ - if (pdp->teval != J2000) { - swi_precess(xxsv, pdp->teval, J_TO_J2000); - if (iflag & SEFLG_SPEED) - swi_precess_speed(xxsv, pdp->teval, J_TO_J2000); + struct epsilon *oe; + /* if the same conversions have already been done for the same + * date, then return */ + flg1 = iflag & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; + flg2 = pdp->xflgs & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; + if (flg1 == flg2) { + pdp->xflgs = iflag; + pdp->iephe = iflag & SEFLG_EPHMASK; + return OK; } - } + for (i = 0; i <= 5; i++) + xx[i] = pdp->x[i]; + /* cartesian equatorial coordinates */ + swi_polcart_sp(xx, xx); + swi_coortrf2(xx, xx, -swed.oec.seps, swed.oec.ceps); + swi_coortrf2(xx + 3, xx + 3, -swed.oec.seps, swed.oec.ceps); +#if 0 + + /**************************************************** + * light-time, this is only a few milliarcseconds * + ***************************************************/ + if ((iflag & SEFLG_TRUEPOS) == 0) { + dt = pdp->x[3] * AUNIT / CLIGHT / 86400; + for (i = 0; i <= 2; i++) + xx[i] -= dt * xx[i + 3]; + } +#endif + if (!(iflag & SEFLG_SPEED)) + for (i = 3; i <= 5; i++) + xx[i] = 0; + /* J2000 coordinates; required for sidereal positions */ + if (((iflag & SEFLG_SIDEREAL) + && (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0)) + || (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE)) { + for (i = 0; i <= 5; i++) + xxsv[i] = xx[i]; + /* xxsv is not J2000 yet! */ + if (pdp->teval != J2000) { + swi_precess(xxsv, pdp->teval, J_TO_J2000); + if (iflag & SEFLG_SPEED) + swi_precess_speed(xxsv, pdp->teval, J_TO_J2000); + } + } + /***************************************************** * if no precession, equator of date -> equator 2000 * *****************************************************/ - if (iflag & SEFLG_J2000) { - swi_precess(xx, pdp->teval, J_TO_J2000); - if (iflag & SEFLG_SPEED) - swi_precess_speed(xx, pdp->teval, J_TO_J2000); - oe = &swed.oec2000; - } else - oe = &swed.oec; - return app_pos_rest(pdp, iflag, xx, xxsv, oe, serr); + if (iflag & SEFLG_J2000) { + swi_precess(xx, pdp->teval, J_TO_J2000); + if (iflag & SEFLG_SPEED) + swi_precess_speed(xx, pdp->teval, J_TO_J2000); + oe = &swed.oec2000; + } + else + oe = &swed.oec; + return app_pos_rest(pdp, iflag, xx, xxsv, oe, serr); } /* fetch chebyshew coefficients from sweph file for @@ -3498,142 +3745,165 @@ static int app_pos_etc_mean(int ipl, int32 iflag, char *serr) * ifno file number * serr error string */ -static int get_new_segment(double tjd, int ipli, int ifno, char *serr) +static int +get_new_segment(double tjd, int ipli, int ifno, char *serr) { - int i, j, k, m, n, o, icoord, retc; - int32 iseg; - int32 fpos; - int nsizes, nsize[6]; - int nco; - int idbl; - unsigned char c[4]; - struct plan_data *pdp = &swed.pldat[ipli]; - struct file_data *fdp = &swed.fidat[ifno]; - FILE *fp = fdp->fptr; - int freord = (int) fdp->iflg & SEI_FILE_REORD; - int fendian = (int) fdp->iflg & SEI_FILE_LITENDIAN; - uint32 longs[MAXORD+1]; - /* compute segment number */ - iseg = (int32) ((tjd - pdp->tfstart) / pdp->dseg); - /*if (tjd - pdp->tfstart < 0) - return(NOT_AVAILABLE);*/ - pdp->tseg0 = pdp->tfstart + iseg * pdp->dseg; - pdp->tseg1 = pdp->tseg0 + pdp->dseg; - /* get file position of coefficients from file */ - fpos = pdp->lndx0 + iseg * 3; - retc = do_fread((void *) &fpos, 3, 1, 4, fp, fpos, freord, fendian, ifno, serr); - if (retc != OK) - return (retc); - fseek(fp, fpos, SEEK_SET); - /* clear space of chebyshew coefficients */ - if (pdp->segp == NULL) - pdp->segp = (double *) malloc((size_t) pdp->ncoe * 3 * 8); - memset((void *) pdp->segp, 0, (size_t) pdp->ncoe * 3 * 8); - /* read coefficients for 3 coordinates */ - for (icoord = 0; icoord < 3; icoord++) { - idbl = icoord * pdp->ncoe; - /* first read header */ - /* first bit indicates number of sizes of packed coefficients */ - retc = do_fread((void *) &c[0], 1, 2, 1, fp, SEI_CURR_FPOS, freord, fendian, ifno, serr); + int i, j, k, m, n, o, icoord, retc; + int32 iseg; + int32 fpos; + int nsizes, nsize[6]; + int nco; + int idbl; + unsigned char c[4]; + struct plan_data *pdp = &swed.pldat[ipli]; + struct file_data *fdp = &swed.fidat[ifno]; + FILE *fp = fdp->fptr; + int freord = (int)fdp->iflg & SEI_FILE_REORD; + int fendian = (int)fdp->iflg & SEI_FILE_LITENDIAN; + uint32 longs[MAXORD + 1]; + /* compute segment number */ + iseg = (int32) ((tjd - pdp->tfstart) / pdp->dseg); + /*if (tjd - pdp->tfstart < 0) + * return(NOT_AVAILABLE); */ + pdp->tseg0 = pdp->tfstart + iseg * pdp->dseg; + pdp->tseg1 = pdp->tseg0 + pdp->dseg; + /* get file position of coefficients from file */ + fpos = pdp->lndx0 + iseg * 3; + retc = + do_fread((void *)&fpos, 3, 1, 4, fp, fpos, freord, fendian, ifno, + serr); if (retc != OK) - return (retc); - if (c[0] & 128) { - nsizes = 6; - retc = do_fread((void *) (c+2), 1, 2, 1, fp, SEI_CURR_FPOS, freord, fendian, ifno, serr); - if (retc != OK) - return (retc); - nsize[0] = (int) c[1] / 16; - nsize[1] = (int) c[1] % 16; - nsize[2] = (int) c[2] / 16; - nsize[3] = (int) c[2] % 16; - nsize[4] = (int) c[3] / 16; - nsize[5] = (int) c[3] % 16; - nco = nsize[0] + nsize[1] + nsize[2] + nsize[3] + nsize[4] + nsize[5]; - } else { - nsizes = 4; - nsize[0] = (int) c[0] / 16; - nsize[1] = (int) c[0] % 16; - nsize[2] = (int) c[1] / 16; - nsize[3] = (int) c[1] % 16; - nco = nsize[0] + nsize[1] + nsize[2] + nsize[3]; + return (retc); + fseek(fp, fpos, SEEK_SET); + /* clear space of chebyshew coefficients */ + if (pdp->segp == NULL) + pdp->segp = (double *)malloc((size_t) pdp->ncoe * 3 * 8); + memset((void *)pdp->segp, 0, (size_t) pdp->ncoe * 3 * 8); + /* read coefficients for 3 coordinates */ + for (icoord = 0; icoord < 3; icoord++) { + idbl = icoord * pdp->ncoe; + /* first read header */ + /* first bit indicates number of sizes of packed coefficients */ + retc = + do_fread((void *)&c[0], 1, 2, 1, fp, SEI_CURR_FPOS, freord, + fendian, ifno, serr); + if (retc != OK) + return (retc); + if (c[0] & 128) { + nsizes = 6; + retc = + do_fread((void *)(c + 2), 1, 2, 1, fp, SEI_CURR_FPOS, freord, + fendian, ifno, serr); + if (retc != OK) + return (retc); + nsize[0] = (int)c[1] / 16; + nsize[1] = (int)c[1] % 16; + nsize[2] = (int)c[2] / 16; + nsize[3] = (int)c[2] % 16; + nsize[4] = (int)c[3] / 16; + nsize[5] = (int)c[3] % 16; + nco = + nsize[0] + nsize[1] + nsize[2] + nsize[3] + nsize[4] + + nsize[5]; + } + else { + nsizes = 4; + nsize[0] = (int)c[0] / 16; + nsize[1] = (int)c[0] % 16; + nsize[2] = (int)c[1] / 16; + nsize[3] = (int)c[1] % 16; + nco = nsize[0] + nsize[1] + nsize[2] + nsize[3]; + } + /* there may not be more coefficients than interpolation + * order + 1 */ + if (nco > pdp->ncoe) { + if (serr != NULL) { + sprintf(serr, + "error in ephemeris file: %d coefficients instead of %d. ", + nco, pdp->ncoe); + if (strlen(serr) + strlen(fdp->fnam) < AS_MAXCH - 1) + sprintf(serr, + "error in ephemeris file %s: %d coefficients instead of %d. ", + fdp->fnam, nco, pdp->ncoe); + } + free(pdp->segp); + pdp->segp = NULL; + return (ERR); + } + /* now unpack */ + for (i = 0; i < nsizes; i++) { + if (nsize[i] == 0) + continue; + if (i < 4) { + j = (4 - i); + k = nsize[i]; + retc = + do_fread((void *)&longs[0], j, k, 4, fp, SEI_CURR_FPOS, + freord, fendian, ifno, serr); + if (retc != OK) + return (retc); + for (m = 0; m < k; m++, idbl++) { + if (longs[m] & 1) /* will be negative */ + pdp->segp[idbl] = + -(((longs[m] + 1) / 2) / 1e+9 * pdp->rmax / 2); + else + pdp->segp[idbl] = + (longs[m] / 2) / 1e+9 * pdp->rmax / 2; + } + } + else if (i == 4) { /* half byte packing */ + j = 1; + k = (nsize[i] + 1) / 2; + retc = + do_fread((void *)longs, j, k, 4, fp, SEI_CURR_FPOS, + freord, fendian, ifno, serr); + if (retc != OK) + return (retc); + for (m = 0, j = 0; m < k && j < nsize[i]; m++) { + for (n = 0, o = 16; n < 2 && j < nsize[i]; + n++, j++, idbl++, longs[m] %= o, o /= 16) { + if (longs[m] & o) + pdp->segp[idbl] = + -(((longs[m] + + o) / o / 2) * pdp->rmax / 2 / 1e+9); + else + pdp->segp[idbl] = + (longs[m] / o / 2) * pdp->rmax / 2 / 1e+9; + } + } + } + else if (i == 5) { /* quarter byte packing */ + j = 1; + k = (nsize[i] + 3) / 4; + retc = + do_fread((void *)longs, j, k, 4, fp, SEI_CURR_FPOS, + freord, fendian, ifno, serr); + if (retc != OK) + return (retc); + for (m = 0, j = 0; m < k && j < nsize[i]; m++) { + for (n = 0, o = 64; n < 4 && j < nsize[i]; + n++, j++, idbl++, longs[m] %= o, o /= 4) { + if (longs[m] & o) + pdp->segp[idbl] = + -(((longs[m] + + o) / o / 2) * pdp->rmax / 2 / 1e+9); + else + pdp->segp[idbl] = + (longs[m] / o / 2) * pdp->rmax / 2 / 1e+9; + } + } + } + } } - /* there may not be more coefficients than interpolation - * order + 1 */ - if (nco > pdp->ncoe) { - if (serr != NULL) { - sprintf(serr, "error in ephemeris file: %d coefficients instead of %d. ", nco, pdp->ncoe); - if (strlen(serr) + strlen(fdp->fnam) < AS_MAXCH - 1) - sprintf(serr, "error in ephemeris file %s: %d coefficients instead of %d. ", fdp->fnam, nco, pdp->ncoe); - } - free(pdp->segp); - pdp->segp = NULL; - return (ERR); - } - /* now unpack */ - for (i = 0; i < nsizes; i++) { - if (nsize[i] == 0) - continue; - if (i < 4) { - j = (4 - i); - k = nsize[i]; - retc = do_fread((void *) &longs[0], j, k, 4, fp, SEI_CURR_FPOS, freord, fendian, ifno, serr); - if (retc != OK) - return (retc); - for (m = 0; m < k; m++, idbl++) { - if (longs[m] & 1) /* will be negative */ - pdp->segp[idbl] = -(((longs[m]+1) / 2) / 1e+9 * pdp->rmax / 2); - else - pdp->segp[idbl] = (longs[m] / 2) / 1e+9 * pdp->rmax / 2; - } - } else if (i == 4) { /* half byte packing */ - j = 1; - k = (nsize[i] + 1) / 2; - retc = do_fread((void *) longs, j, k, 4, fp, SEI_CURR_FPOS, freord, fendian, ifno, serr); - if (retc != OK) - return (retc); - for (m = 0, j = 0; - m < k && j < nsize[i]; - m++) { - for (n = 0, o = 16; - n < 2 && j < nsize[i]; - n++, j++, idbl++, longs[m] %= o, o /= 16) { - if (longs[m] & o) - pdp->segp[idbl] = - -(((longs[m]+o) / o / 2) * pdp->rmax / 2 / 1e+9); - else - pdp->segp[idbl] = (longs[m] / o / 2) * pdp->rmax / 2 / 1e+9; - } - } - } else if (i == 5) { /* quarter byte packing */ - j = 1; - k = (nsize[i] + 3) / 4; - retc = do_fread((void *) longs, j, k, 4, fp, SEI_CURR_FPOS, freord, fendian, ifno, serr); - if (retc != OK) - return (retc); - for (m = 0, j = 0; - m < k && j < nsize[i]; - m++) { - for (n = 0, o = 64; - n < 4 && j < nsize[i]; - n++, j++, idbl++, longs[m] %= o, o /= 4) { - if (longs[m] & o) - pdp->segp[idbl] = - -(((longs[m]+o) / o / 2) * pdp->rmax / 2 / 1e+9); - else - pdp->segp[idbl] = (longs[m] / o / 2) * pdp->rmax / 2 / 1e+9; - } - } - } - } - } #if 0 - if (ipli == SEI_SUNBARY) { - printf("%d, %x\n", fpos, fpos); - for (i = 0; i < pdp->ncoe; i++) - printf("%e, %e, %e\n", pdp->segp[i], pdp->segp[i+pdp->ncoe], pdp->segp[i+2*pdp->ncoe]); - } + if (ipli == SEI_SUNBARY) { + printf("%d, %x\n", fpos, fpos); + for (i = 0; i < pdp->ncoe; i++) + printf("%e, %e, %e\n", pdp->segp[i], pdp->segp[i + pdp->ncoe], + pdp->segp[i + 2 * pdp->ncoe]); + } #endif - return(OK); + return (OK); } /* SWISSEPH @@ -3641,360 +3911,394 @@ static int get_new_segment(double tjd, int ipli, int ifno, char *serr) * ifno file # * serr error string */ -static int read_const(int ifno, char *serr) -{ - char *c, c2, *sp; - char s[AS_MAXCH*2], s2[AS_MAXCH]; - char sastnam[41]; - int i, ipli, kpl; - int retc; - int fendian, freord; - int lastnam = 19; - FILE *fp; - int32 lng; - uint32 ulng; - int32 flen, fpos; - short nplan; - int32 testendian; - double doubles[20]; - struct plan_data *pdp; - struct file_data *fdp = &swed.fidat[ifno]; - char *serr_file_damage = "Ephemeris file %s is damaged. "; - int errmsglen = strlen(serr_file_damage) + strlen(fdp->fnam); - int nbytes_ipl = 2; - fp = fdp->fptr; - /************************************* +static int +read_const(int ifno, char *serr) +{ + char *c, c2, *sp; + char s[AS_MAXCH * 2], s2[AS_MAXCH]; + char sastnam[41]; + int i, ipli, kpl; + int retc; + int fendian, freord; + int lastnam = 19; + FILE *fp; + int32 lng; + uint32 ulng; + int32 flen, fpos; + short nplan; + int32 testendian; + double doubles[20]; + struct plan_data *pdp; + struct file_data *fdp = &swed.fidat[ifno]; + char *serr_file_damage = "Ephemeris file %s is damaged. "; + int errmsglen = strlen(serr_file_damage) + strlen(fdp->fnam); + int nbytes_ipl = 2; + fp = fdp->fptr; + + /************************************* * version number of file * *************************************/ - sp = fgets(s, AS_MAXCH, fp); - if (sp == NULL || strstr(sp, "\r\n") == NULL) - goto file_damage; - sp = strchr(s, '\r'); - *sp = '\0'; - sp = s; - while (isdigit((int) *sp) == 0 && *sp != '\0') - sp++; - if (*sp == '\0') - goto file_damage; - /* version unused so far */ - fdp->fversion = atoi(sp); - /************************************* + sp = fgets(s, AS_MAXCH, fp); + if (sp == NULL || strstr(sp, "\r\n") == NULL) + goto file_damage; + sp = strchr(s, '\r'); + *sp = '\0'; + sp = s; + while (isdigit((int)*sp) == 0 && *sp != '\0') + sp++; + if (*sp == '\0') + goto file_damage; + /* version unused so far */ + fdp->fversion = atoi(sp); + + /************************************* * correct file name? * *************************************/ - sp = fgets(s, AS_MAXCH, fp); - if (sp == NULL || strstr(sp, "\r\n") == NULL) - goto file_damage; - /* file name, without path */ - sp = strrchr(fdp->fnam, (int) *DIR_GLUE); - if (sp == NULL) - sp = fdp->fnam; - else - sp++; - strcpy(s2, sp); - /* to lower case */ - for (sp = s2; *sp != '\0'; sp++) - *sp = tolower((int) *sp); - /* prepare string of should-be file name */ - sp = s + strlen(s) - 1; - while (*sp == '\n' || *sp == '\r' || *sp == ' ') { - *sp = '\0'; - sp--; - } - for (sp = s; *sp != '\0'; sp++) - *sp = tolower((int) *sp); - if (strcmp(s2, s) != 0) { - if (serr != NULL) - sprintf(serr, "Ephemeris file name '%s' wrong; rename '%s' ", s2, s); - goto return_error; - } - /************************************* + sp = fgets(s, AS_MAXCH, fp); + if (sp == NULL || strstr(sp, "\r\n") == NULL) + goto file_damage; + /* file name, without path */ + sp = strrchr(fdp->fnam, (int)*DIR_GLUE); + if (sp == NULL) + sp = fdp->fnam; + else + sp++; + strcpy(s2, sp); + /* to lower case */ + for (sp = s2; *sp != '\0'; sp++) + *sp = tolower((int)*sp); + /* prepare string of should-be file name */ + sp = s + strlen(s) - 1; + while (*sp == '\n' || *sp == '\r' || *sp == ' ') { + *sp = '\0'; + sp--; + } + for (sp = s; *sp != '\0'; sp++) + *sp = tolower((int)*sp); + if (strcmp(s2, s) != 0) { + if (serr != NULL) + sprintf(serr, "Ephemeris file name '%s' wrong; rename '%s' ", s2, + s); + goto return_error; + } + + /************************************* * copyright * *************************************/ - sp = fgets(s, AS_MAXCH, fp); - if (sp == NULL || strstr(sp, "\r\n") == NULL) - goto file_damage; - /**************************************** + sp = fgets(s, AS_MAXCH, fp); + if (sp == NULL || strstr(sp, "\r\n") == NULL) + goto file_damage; + + /**************************************** * orbital elements, if single asteroid * ****************************************/ - if (ifno == SEI_FILE_ANY_AST) { - sp = fgets(s, AS_MAXCH * 2, fp); - if (sp == NULL || strstr(sp, "\r\n") == NULL) - goto file_damage; - /* MPC number and name; will be analyzed below: - * search "asteroid name" */ - while(*sp == ' ') sp++; - while(isdigit(*sp)) sp++; - sp++; - i = sp - s; - strncpy(sastnam, sp, lastnam+i); - *(sastnam+lastnam+i) = '\0'; - /* save elements, they are required for swe_plan_pheno() */ - strcpy(swed.astelem, s); - /* required for magnitude */ - swed.ast_H = atof(s + 35 + i); - swed.ast_G = atof(s + 42 + i); - if (swed.ast_G == 0) swed.ast_G = 0.15; - /* diameter in kilometers, not always given: */ - strncpy(s2, s+51+i, 7); - *(s2 + 7) = '\0'; - swed.ast_diam = atof(s2); - if (swed.ast_diam == 0) { - /* estimate the diameter from magnitude; assume albedo = 0.15 */ - swed.ast_diam = 1329/sqrt(0.15) * pow(10, -0.2 * swed.ast_H); - } -#if 0 - i = 5; - while (*(sp+i) != ' ') - i++; - j = i - 5; - strncpy(sastnam, sp, lastnam+i); - *(sastnam+lastnam+i) = 0; - /* save elements, they are required for swe_plan_pheno() */ - strcpy(swed.astelem, s); - /* required for magnitude */ - swed.ast_G = atof(sp + 40 + j); - swed.ast_H = atof(sp + 46 + j); - /* diameter in kilometers, not always given: */ - strncpy(s2, sp+56+j, 7); - *(s2 + 7) = '\0'; - swed.ast_diam = atof(s2); -#endif - } - /************************************* - * one int32 for test of byte order * - *************************************/ - if (fread((void *) &testendian, 4, 1, fp) != 1) - goto file_damage; - /* is byte order correct? */ - if (testendian == SEI_FILE_TEST_ENDIAN) - freord = SEI_FILE_NOREORD; - else { - freord = SEI_FILE_REORD; - sp = (char *) &lng; - c = (char *) &testendian; - for (i = 0; i < 4; i++) - *(sp+i) = *(c+3-i); - if (lng != SEI_FILE_TEST_ENDIAN) - goto file_damage; - /* printf("%d %x\n", lng, lng);*/ - } - /* is file bigendian or littlendian? - * test first byte of test integer, which is highest if bigendian */ - c = (char *) &testendian; - c2 = SEI_FILE_TEST_ENDIAN / 16777216L; - if (*c == c2) - fendian = SEI_FILE_BIGENDIAN; - else - fendian = SEI_FILE_LITENDIAN; - fdp->iflg = (int32) freord | fendian; - /************************************* - * length of file correct? * - *************************************/ - retc = do_fread((void *) &lng, 4, 1, 4, fp, SEI_CURR_FPOS, freord, -fendian, ifno, serr); - if (retc != OK) - return (retc); - fpos = ftell(fp); - if (fseek(fp, 0L, SEEK_END) != 0) - goto file_damage; - flen = ftell(fp); - if (lng != flen) - goto file_damage; - /********************************************************** - * DE number of JPL ephemeris which this file is based on * - **********************************************************/ - retc = do_fread((void *) &fdp->sweph_denum, 4, 1, 4, fp, fpos, freord, -fendian, ifno, serr); - if (retc != OK) - return (retc); - swed.jpldenum = fdp->sweph_denum; - /************************************* - * start and end epoch of file * - *************************************/ - retc = do_fread((void *) &fdp->tfstart, 8, 1, 8, fp, SEI_CURR_FPOS, -freord, fendian, ifno, serr); - if (retc != OK) - return (retc); - retc = do_fread((void *) &fdp->tfend, 8, 1, 8, fp, SEI_CURR_FPOS, freord, -fendian, ifno, serr); - if (retc != OK) - return (retc); - /************************************* - * how many planets are in file? * - *************************************/ - retc = do_fread((void *) &nplan, 2, 1, 2, fp, SEI_CURR_FPOS, freord, fendian, ifno, serr); - if (retc != OK) - return (retc); - if (nplan > 256) { - nbytes_ipl = 4; - nplan %= 256; - } - if (nplan < 1 || nplan > 20) - goto file_damage; - fdp->npl = nplan; - /* which ones? */ - retc = do_fread((void *) fdp->ipl, nbytes_ipl, (int) nplan, sizeof(int), fp, SEI_CURR_FPOS, -freord, fendian, ifno, serr); - if (retc != OK) - return (retc); - /************************************* - * asteroid name * - *************************************/ - if (ifno == SEI_FILE_ANY_AST) { - char sastno[12]; - int j; - /* name of asteroid is taken from orbital elements record - * read above */ - j = 4; /* old astorb.dat had only 4 characters for MPC# */ - while (sastnam[j] != ' ' && j < 10) /* new astorb.dat has 5 */ - j++; - strncpy(sastno, sastnam, j); - sastno[j] = '\0'; - i = (int) atol(sastno); - if (i == fdp->ipl[0] - SE_AST_OFFSET) { - /* element record is from bowell database */ - strncpy(fdp->astnam, sastnam+j+1, lastnam); - /* overread old ast. name field */ - if (fread((void *) s, 30, 1, fp) != 1) - goto file_damage; - } else { - /* older elements record structure: the name - * is taken from old name field */ - if (fread((void *) fdp->astnam, 30, 1, fp) != 1) - goto file_damage; - } - /* in worst case strlen of not null terminated area! */ - i = strlen(fdp->astnam) - 1; - if (i < 0) - i = 0; - sp = fdp->astnam + i; - while(*sp == ' ') { - sp--; - } - sp[1] = '\0'; - } - /************************************* - * check CRC * - *************************************/ - fpos = ftell(fp); - /* read CRC from file */ - retc = do_fread((void *) &ulng, 4, 1, 4, fp, SEI_CURR_FPOS, freord, -fendian, ifno, serr); - if (retc != OK) - return (retc); - /* read check area from file */ - fseek(fp, 0L, SEEK_SET); - /* must check that defined length of s is less than fpos */ - if (fpos - 1 > 2 * AS_MAXCH) - goto file_damage; - if (fread((void *) s, (size_t) fpos, 1, fp) != 1) - goto file_damage; -#if 1 - if (swi_crc32((unsigned char *) s, (int) fpos) != ulng) - goto file_damage; - /*printf("crc %d %d\n", ulng2, ulng);*/ -#endif - fseek(fp, fpos+4, SEEK_SET); - /************************************* - * read general constants * - *************************************/ - /* clight, aunit, helgravconst, ratme, sunradius - * these constants are currently not in use */ - retc = do_fread((void *) &doubles[0], 8, 5, 8, fp, SEI_CURR_FPOS, freord, -fendian, ifno, serr); - if (retc != OK) - return (retc); - swed.gcdat.clight = doubles[0]; - swed.gcdat.aunit = doubles[1]; - swed.gcdat.helgravconst = doubles[2]; - swed.gcdat.ratme = doubles[3]; - swed.gcdat.sunradius = doubles[4]; - /************************************* - * read constants of planets * - *************************************/ - for (kpl = 0; kpl < fdp->npl; kpl++) { - /* get SEI_ planet number */ - ipli = fdp->ipl[kpl]; - if (ipli >= SE_AST_OFFSET) - pdp = &swed.pldat[SEI_ANYBODY]; - else - pdp = &swed.pldat[ipli]; - pdp->ibdy = ipli; - /* file position of planet's index */ - retc = do_fread((void *) &pdp->lndx0, 4, 1, 4, fp, SEI_CURR_FPOS, -freord, fendian, ifno, serr); - if (retc != OK) - return (retc); - /* flags: helio/geocentric, rotation, reference ellipse */ - retc = do_fread((void *) &pdp->iflg, 1, 1, sizeof(int32), fp, -SEI_CURR_FPOS, freord, fendian, ifno, serr); - if (retc != OK) - return (retc); - /* number of chebyshew coefficients / segment */ - /* = interpolation order +1 */ - retc = do_fread((void *) &pdp->ncoe, 1, 1, sizeof(int), fp, -SEI_CURR_FPOS, freord, fendian, ifno, serr); - if (retc != OK) - return (retc); - /* rmax = normalisation factor */ - retc = do_fread((void *) &lng, 4, 1, 4, fp, SEI_CURR_FPOS, freord, -fendian, ifno, serr); - if (retc != OK) - return (retc); - pdp->rmax = lng / 1000.0; - /* start and end epoch of planetary ephemeris, */ - /* segment length, and orbital elements */ - retc = do_fread((void *) doubles, 8, 10, 8, fp, SEI_CURR_FPOS, freord, -fendian, ifno, serr); - if (retc != OK) - return (retc); - pdp->tfstart = doubles[0]; - pdp->tfend = doubles[1]; - pdp->dseg = doubles[2]; - pdp->nndx = (int32) ((doubles[1] - doubles[0] + 0.1) /doubles[2]); - pdp->telem = doubles[3]; - pdp->prot = doubles[4]; - pdp->dprot = doubles[5]; - pdp->qrot = doubles[6]; - pdp->dqrot = doubles[7]; - pdp->peri = doubles[8]; - pdp->dperi = doubles[9]; - /* alloc space for chebyshew coefficients */ - /* if reference ellipse is used, read its coefficients */ - if (pdp->iflg & SEI_FLG_ELLIPSE) { - if (pdp->refep != NULL) { /* if switch to other eph. file */ - free((void *) pdp->refep); - if (pdp->segp != NULL) { - free((void *) pdp->segp); /* array of coefficients of */ - pdp->segp = NULL; /* ephemeris segment */ + if (ifno == SEI_FILE_ANY_AST) { + sp = fgets(s, AS_MAXCH * 2, fp); + if (sp == NULL || strstr(sp, "\r\n") == NULL) + goto file_damage; + /* MPC number and name; will be analyzed below: + * search "asteroid name" */ + while (*sp == ' ') + sp++; + while (isdigit(*sp)) + sp++; + sp++; + i = sp - s; + strncpy(sastnam, sp, lastnam + i); + *(sastnam + lastnam + i) = '\0'; + /* save elements, they are required for swe_plan_pheno() */ + strcpy(swed.astelem, s); + /* required for magnitude */ + swed.ast_H = atof(s + 35 + i); + swed.ast_G = atof(s + 42 + i); + if (swed.ast_G == 0) + swed.ast_G = 0.15; + /* diameter in kilometers, not always given: */ + strncpy(s2, s + 51 + i, 7); + *(s2 + 7) = '\0'; + swed.ast_diam = atof(s2); + if (swed.ast_diam == 0) { + /* estimate the diameter from magnitude; assume albedo = 0.15 */ + swed.ast_diam = 1329 / sqrt(0.15) * pow(10, -0.2 * swed.ast_H); } - } - pdp->refep = (double *) malloc((size_t) pdp->ncoe * 2 * 8); - retc = do_fread((void *) pdp->refep, 8, 2*pdp->ncoe, 8, fp, -SEI_CURR_FPOS, freord, fendian, ifno, serr); - if (retc != OK) +#if 0 + i = 5; + while (*(sp + i) != ' ') + i++; + j = i - 5; + strncpy(sastnam, sp, lastnam + i); + *(sastnam + lastnam + i) = 0; + /* save elements, they are required for swe_plan_pheno() */ + strcpy(swed.astelem, s); + /* required for magnitude */ + swed.ast_G = atof(sp + 40 + j); + swed.ast_H = atof(sp + 46 + j); + /* diameter in kilometers, not always given: */ + strncpy(s2, sp + 56 + j, 7); + *(s2 + 7) = '\0'; + swed.ast_diam = atof(s2); +#endif + } + + /************************************* + * one int32 for test of byte order * + *************************************/ + if (fread((void *)&testendian, 4, 1, fp) != 1) + goto file_damage; + /* is byte order correct? */ + if (testendian == SEI_FILE_TEST_ENDIAN) + freord = SEI_FILE_NOREORD; + else { + freord = SEI_FILE_REORD; + sp = (char *)&lng; + c = (char *)&testendian; + for (i = 0; i < 4; i++) + *(sp + i) = *(c + 3 - i); + if (lng != SEI_FILE_TEST_ENDIAN) + goto file_damage; + /* printf("%d %x\n", lng, lng); */ + } + /* is file bigendian or littlendian? + * test first byte of test integer, which is highest if bigendian */ + c = (char *)&testendian; + c2 = SEI_FILE_TEST_ENDIAN / 16777216L; + if (*c == c2) + fendian = SEI_FILE_BIGENDIAN; + else + fendian = SEI_FILE_LITENDIAN; + fdp->iflg = (int32) freord | fendian; + + /************************************* + * length of file correct? * + *************************************/ + retc = + do_fread((void *)&lng, 4, 1, 4, fp, SEI_CURR_FPOS, freord, fendian, + ifno, serr); + if (retc != OK) return (retc); - }/**/ - } - return(OK); + fpos = ftell(fp); + if (fseek(fp, 0L, SEEK_END) != 0) + goto file_damage; + flen = ftell(fp); + if (lng != flen) + goto file_damage; + + /********************************************************** + * DE number of JPL ephemeris which this file is based on * + **********************************************************/ + retc = + do_fread((void *)&fdp->sweph_denum, 4, 1, 4, fp, fpos, freord, + fendian, ifno, serr); + if (retc != OK) + return (retc); + swed.jpldenum = fdp->sweph_denum; + + /************************************* + * start and end epoch of file * + *************************************/ + retc = + do_fread((void *)&fdp->tfstart, 8, 1, 8, fp, SEI_CURR_FPOS, freord, + fendian, ifno, serr); + if (retc != OK) + return (retc); + retc = + do_fread((void *)&fdp->tfend, 8, 1, 8, fp, SEI_CURR_FPOS, freord, + fendian, ifno, serr); + if (retc != OK) + return (retc); + + /************************************* + * how many planets are in file? * + *************************************/ + retc = + do_fread((void *)&nplan, 2, 1, 2, fp, SEI_CURR_FPOS, freord, fendian, + ifno, serr); + if (retc != OK) + return (retc); + if (nplan > 256) { + nbytes_ipl = 4; + nplan %= 256; + } + if (nplan < 1 || nplan > 20) + goto file_damage; + fdp->npl = nplan; + /* which ones? */ + retc = + do_fread((void *)fdp->ipl, nbytes_ipl, (int)nplan, sizeof(int), fp, + SEI_CURR_FPOS, freord, fendian, ifno, serr); + if (retc != OK) + return (retc); + + /************************************* + * asteroid name * + *************************************/ + if (ifno == SEI_FILE_ANY_AST) { + char sastno[12]; + int j; + /* name of asteroid is taken from orbital elements record + * read above */ + j = 4; /* old astorb.dat had only 4 characters for MPC# */ + while (sastnam[j] != ' ' && j < 10) /* new astorb.dat has 5 */ + j++; + strncpy(sastno, sastnam, j); + sastno[j] = '\0'; + i = (int)atol(sastno); + if (i == fdp->ipl[0] - SE_AST_OFFSET) { + /* element record is from bowell database */ + strncpy(fdp->astnam, sastnam + j + 1, lastnam); + /* overread old ast. name field */ + if (fread((void *)s, 30, 1, fp) != 1) + goto file_damage; + } + else { + /* older elements record structure: the name + * is taken from old name field */ + if (fread((void *)fdp->astnam, 30, 1, fp) != 1) + goto file_damage; + } + /* in worst case strlen of not null terminated area! */ + i = strlen(fdp->astnam) - 1; + if (i < 0) + i = 0; + sp = fdp->astnam + i; + while (*sp == ' ') { + sp--; + } + sp[1] = '\0'; + } + + /************************************* + * check CRC * + *************************************/ + fpos = ftell(fp); + /* read CRC from file */ + retc = + do_fread((void *)&ulng, 4, 1, 4, fp, SEI_CURR_FPOS, freord, fendian, + ifno, serr); + if (retc != OK) + return (retc); + /* read check area from file */ + fseek(fp, 0L, SEEK_SET); + /* must check that defined length of s is less than fpos */ + if (fpos - 1 > 2 * AS_MAXCH) + goto file_damage; + if (fread((void *)s, (size_t) fpos, 1, fp) != 1) + goto file_damage; +#if 1 + if (swi_crc32((unsigned char *)s, (int)fpos) != ulng) + goto file_damage; + /*printf("crc %d %d\n", ulng2, ulng); */ +#endif + fseek(fp, fpos + 4, SEEK_SET); + + /************************************* + * read general constants * + *************************************/ + /* clight, aunit, helgravconst, ratme, sunradius + * these constants are currently not in use */ + retc = + do_fread((void *)&doubles[0], 8, 5, 8, fp, SEI_CURR_FPOS, freord, + fendian, ifno, serr); + if (retc != OK) + return (retc); + swed.gcdat.clight = doubles[0]; + swed.gcdat.aunit = doubles[1]; + swed.gcdat.helgravconst = doubles[2]; + swed.gcdat.ratme = doubles[3]; + swed.gcdat.sunradius = doubles[4]; + + /************************************* + * read constants of planets * + *************************************/ + for (kpl = 0; kpl < fdp->npl; kpl++) { + /* get SEI_ planet number */ + ipli = fdp->ipl[kpl]; + if (ipli >= SE_AST_OFFSET) + pdp = &swed.pldat[SEI_ANYBODY]; + else + pdp = &swed.pldat[ipli]; + pdp->ibdy = ipli; + /* file position of planet's index */ + retc = + do_fread((void *)&pdp->lndx0, 4, 1, 4, fp, SEI_CURR_FPOS, freord, + fendian, ifno, serr); + if (retc != OK) + return (retc); + /* flags: helio/geocentric, rotation, reference ellipse */ + retc = + do_fread((void *)&pdp->iflg, 1, 1, sizeof(int32), fp, + SEI_CURR_FPOS, freord, fendian, ifno, serr); + if (retc != OK) + return (retc); + /* number of chebyshew coefficients / segment */ + /* = interpolation order +1 */ + retc = + do_fread((void *)&pdp->ncoe, 1, 1, sizeof(int), fp, SEI_CURR_FPOS, + freord, fendian, ifno, serr); + if (retc != OK) + return (retc); + /* rmax = normalisation factor */ + retc = + do_fread((void *)&lng, 4, 1, 4, fp, SEI_CURR_FPOS, freord, + fendian, ifno, serr); + if (retc != OK) + return (retc); + pdp->rmax = lng / 1000.0; + /* start and end epoch of planetary ephemeris, */ + /* segment length, and orbital elements */ + retc = + do_fread((void *)doubles, 8, 10, 8, fp, SEI_CURR_FPOS, freord, + fendian, ifno, serr); + if (retc != OK) + return (retc); + pdp->tfstart = doubles[0]; + pdp->tfend = doubles[1]; + pdp->dseg = doubles[2]; + pdp->nndx = (int32) ((doubles[1] - doubles[0] + 0.1) / doubles[2]); + pdp->telem = doubles[3]; + pdp->prot = doubles[4]; + pdp->dprot = doubles[5]; + pdp->qrot = doubles[6]; + pdp->dqrot = doubles[7]; + pdp->peri = doubles[8]; + pdp->dperi = doubles[9]; + /* alloc space for chebyshew coefficients */ + /* if reference ellipse is used, read its coefficients */ + if (pdp->iflg & SEI_FLG_ELLIPSE) { + if (pdp->refep != NULL) { /* if switch to other eph. file */ + free((void *)pdp->refep); + if (pdp->segp != NULL) { + free((void *)pdp->segp); /* array of coefficients of */ + pdp->segp = NULL; /* ephemeris segment */ + } + } + pdp->refep = (double *)malloc((size_t) pdp->ncoe * 2 * 8); + retc = + do_fread((void *)pdp->refep, 8, 2 * pdp->ncoe, 8, fp, + SEI_CURR_FPOS, freord, fendian, ifno, serr); + if (retc != OK) + return (retc); + } + /**/} + return (OK); file_damage: - if (serr != NULL) { - *serr = '\0'; - if (errmsglen < AS_MAXCH) - sprintf(serr, serr_file_damage, fdp->fnam); - } + if (serr != NULL) { + *serr = '\0'; + if (errmsglen < AS_MAXCH) + sprintf(serr, serr_file_damage, fdp->fnam); + } return_error: - fclose(fp); - fdp->fptr = NULL; - return(ERR); + fclose(fp); + fdp->fptr = NULL; + return (ERR); } /* SWISSEPH - * reads from a file and, if necessary, reorders bytes + * reads from a file and, if necessary, reorders bytes * targ target pointer * size size of item to be read * count number of items - * corrsize in what size should it be returned + * corrsize in what size should it be returned * (e.g. 3 byte int -> 4 byte int) * fp file pointer * fpos file position: if (fpos >= 0) then fseek @@ -4003,57 +4307,65 @@ return_error: * ifno file number * serr error string */ -static int do_fread(void *trg, int size, int count, int corrsize, FILE *fp, int32 fpos, int freord, int fendian, int ifno, char *serr) +static int +do_fread(void *trg, int size, int count, int corrsize, FILE * fp, int32 fpos, + int freord, int fendian, int ifno, char *serr) { - int i, j, k; - int totsize; - unsigned char space[1000]; - unsigned char *targ = (unsigned char *) trg; - totsize = size * count; - if (fpos >= 0) - fseek(fp, fpos, SEEK_SET); - /* if no byte reorder has to be done, and read size == return size */ - if (!freord && size == corrsize) { - if (fread((void *) targ, (size_t) totsize, 1, fp) == 0) { - if (serr != NULL) { - strcpy(serr, "Ephemeris file is damaged. "); - if (strlen(serr) + strlen(swed.fidat[ifno].fnam) < AS_MAXCH - 1) - sprintf(serr, "Ephemeris file %s is damaged.", swed.fidat[ifno].fnam); - } - fclose(fp); - fp = NULL; - return(ERR); - } else - return(OK); - } else { - if (fread((void *) &space[0], (size_t) totsize, 1, fp) == 0) { - if (serr != NULL) { - strcpy(serr, "Ephemeris file is damaged. "); - if (strlen(serr) + strlen(swed.fidat[ifno].fnam) < AS_MAXCH - 1) - sprintf(serr, "Ephemeris file %s is damaged.", swed.fidat[ifno].fnam); - } - fclose(fp); - fp = NULL; - return(ERR); + int i, j, k; + int totsize; + unsigned char space[1000]; + unsigned char *targ = (unsigned char *)trg; + totsize = size * count; + if (fpos >= 0) + fseek(fp, fpos, SEEK_SET); + /* if no byte reorder has to be done, and read size == return size */ + if (!freord && size == corrsize) { + if (fread((void *)targ, (size_t) totsize, 1, fp) == 0) { + if (serr != NULL) { + strcpy(serr, "Ephemeris file is damaged. "); + if (strlen(serr) + strlen(swed.fidat[ifno].fnam) < + AS_MAXCH - 1) + sprintf(serr, "Ephemeris file %s is damaged.", + swed.fidat[ifno].fnam); + } + fclose(fp); + fp = NULL; + return (ERR); + } + else + return (OK); } - if (size != corrsize) { - memset((void *) targ, 0, (size_t) count * corrsize); + else { + if (fread((void *)&space[0], (size_t) totsize, 1, fp) == 0) { + if (serr != NULL) { + strcpy(serr, "Ephemeris file is damaged. "); + if (strlen(serr) + strlen(swed.fidat[ifno].fnam) < + AS_MAXCH - 1) + sprintf(serr, "Ephemeris file %s is damaged.", + swed.fidat[ifno].fnam); + } + fclose(fp); + fp = NULL; + return (ERR); + } + if (size != corrsize) { + memset((void *)targ, 0, (size_t) count * corrsize); + } + for (i = 0; i < count; i++) { + for (j = size - 1; j >= 0; j--) { + if (freord) + k = size - j - 1; + else + k = j; + if (size != corrsize) + if ((fendian == SEI_FILE_BIGENDIAN && !freord) + || (fendian == SEI_FILE_LITENDIAN && freord)) + k += corrsize - size; + targ[i * corrsize + k] = space[i * size + j]; + } + } } - for(i = 0; i < count; i++) { - for (j = size-1; j >= 0; j--) { - if (freord) - k = size-j-1; - else - k = j; - if (size != corrsize) - if ((fendian == SEI_FILE_BIGENDIAN && !freord) || - (fendian == SEI_FILE_LITENDIAN && freord)) - k += corrsize - size; - targ[i*corrsize+k] = space[i*size+j]; - } - } - } - return(OK); + return (OK); } /* SWISSEPH @@ -4062,95 +4374,97 @@ static int do_fread(void *trg, int size, int count, int corrsize, FILE *fp, int3 * * ipli planet number */ -static void rot_back(int ipli) +static void +rot_back(int ipli) { - int i; - double t, tdiff; - double qav, pav, dn; - double omtild, com, som, cosih2; - double x[MAXORD+1][3]; - double uix[3], uiy[3], uiz[3]; - double xrot, yrot, zrot; - double *chcfx, *chcfy, *chcfz; - double *refepx, *refepy; - double seps2000 = swed.oec2000.seps; - double ceps2000 = swed.oec2000.ceps; - struct plan_data *pdp = &swed.pldat[ipli]; - int nco = pdp->ncoe; - t = pdp->tseg0 + pdp->dseg / 2; - chcfx = pdp->segp; - chcfy = chcfx + nco; - chcfz = chcfx + 2 * nco; - tdiff= (t - pdp->telem) / 365250.0; - if (ipli == SEI_MOON) { - dn = pdp->prot + tdiff * pdp->dprot; - i = (int) (dn / TWOPI); - dn -= i * TWOPI; - qav = (pdp->qrot + tdiff * pdp->dqrot) * cos(dn); - pav = (pdp->qrot + tdiff * pdp->dqrot) * sin(dn); - } else { - qav = pdp->qrot + tdiff * pdp->dqrot; - pav = pdp->prot + tdiff * pdp->dprot; - } - /*calculate cosine and sine of average perihelion longitude. */ - for (i = 0; i < nco; i++) { - x[i][0] = chcfx[i]; - x[i][1] = chcfy[i]; - x[i][2] = chcfz[i]; - } - if (pdp->iflg & SEI_FLG_ELLIPSE) { - refepx = pdp->refep; - refepy = refepx + nco; - omtild = pdp->peri + tdiff * pdp->dperi; - i = (int) (omtild / TWOPI); - omtild -= i * TWOPI; - com = cos(omtild); - som = sin(omtild); - /*add reference orbit. */ - for (i = 0; i < nco; i++) { - x[i][0] = chcfx[i] + com * refepx[i] - som * refepy[i]; - x[i][1] = chcfy[i] + com * refepy[i] + som * refepx[i]; - } - } - /* construct right handed orthonormal system with first axis along - origin of longitudes and third axis along angular momentum - this uses the standard formulas for equinoctal variables - (see papers by broucke and by cefola). */ - cosih2 = 1.0 / (1.0 + qav * qav + pav * pav); - /* calculate orbit pole. */ - uiz[0] = 2.0 * pav * cosih2; - uiz[1] = -2.0 * qav * cosih2; - uiz[2] = (1.0 - qav * qav - pav * pav) * cosih2; - /* calculate origin of longitudes vector. */ - uix[0] = (1.0 + qav * qav - pav * pav) * cosih2; - uix[1] = 2.0 * qav * pav * cosih2; - uix[2] = -2.0 * pav * cosih2; - /* calculate vector in orbital plane orthogonal to origin of - longitudes. */ - uiy[0] =2.0 * qav * pav * cosih2; - uiy[1] =(1.0 - qav * qav + pav * pav) * cosih2; - uiy[2] =2.0 * qav * cosih2; - /* rotate to actual orientation in space. */ - for (i = 0; i < nco; i++) { - xrot = x[i][0] * uix[0] + x[i][1] * uiy[0] + x[i][2] * uiz[0]; - yrot = x[i][0] * uix[1] + x[i][1] * uiy[1] + x[i][2] * uiz[1]; - zrot = x[i][0] * uix[2] + x[i][1] * uiy[2] + x[i][2] * uiz[2]; - if (fabs(xrot) + fabs(yrot) + fabs(zrot) >= 1e-14) - pdp->neval = i; - x[i][0] = xrot; - x[i][1] = yrot; - x[i][2] = zrot; + int i; + double t, tdiff; + double qav, pav, dn; + double omtild, com, som, cosih2; + double x[MAXORD + 1][3]; + double uix[3], uiy[3], uiz[3]; + double xrot, yrot, zrot; + double *chcfx, *chcfy, *chcfz; + double *refepx, *refepy; + double seps2000 = swed.oec2000.seps; + double ceps2000 = swed.oec2000.ceps; + struct plan_data *pdp = &swed.pldat[ipli]; + int nco = pdp->ncoe; + t = pdp->tseg0 + pdp->dseg / 2; + chcfx = pdp->segp; + chcfy = chcfx + nco; + chcfz = chcfx + 2 * nco; + tdiff = (t - pdp->telem) / 365250.0; if (ipli == SEI_MOON) { - /* rotate to j2000 equator */ - x[i][1] = ceps2000 * yrot - seps2000 * zrot; - x[i][2] = seps2000 * yrot + ceps2000 * zrot; + dn = pdp->prot + tdiff * pdp->dprot; + i = (int)(dn / TWOPI); + dn -= i * TWOPI; + qav = (pdp->qrot + tdiff * pdp->dqrot) * cos(dn); + pav = (pdp->qrot + tdiff * pdp->dqrot) * sin(dn); + } + else { + qav = pdp->qrot + tdiff * pdp->dqrot; + pav = pdp->prot + tdiff * pdp->dprot; + } + /*calculate cosine and sine of average perihelion longitude. */ + for (i = 0; i < nco; i++) { + x[i][0] = chcfx[i]; + x[i][1] = chcfy[i]; + x[i][2] = chcfz[i]; + } + if (pdp->iflg & SEI_FLG_ELLIPSE) { + refepx = pdp->refep; + refepy = refepx + nco; + omtild = pdp->peri + tdiff * pdp->dperi; + i = (int)(omtild / TWOPI); + omtild -= i * TWOPI; + com = cos(omtild); + som = sin(omtild); + /*add reference orbit. */ + for (i = 0; i < nco; i++) { + x[i][0] = chcfx[i] + com * refepx[i] - som * refepy[i]; + x[i][1] = chcfy[i] + com * refepy[i] + som * refepx[i]; + } + } + /* construct right handed orthonormal system with first axis along + * origin of longitudes and third axis along angular momentum + * this uses the standard formulas for equinoctal variables + * (see papers by broucke and by cefola). */ + cosih2 = 1.0 / (1.0 + qav * qav + pav * pav); + /* calculate orbit pole. */ + uiz[0] = 2.0 * pav * cosih2; + uiz[1] = -2.0 * qav * cosih2; + uiz[2] = (1.0 - qav * qav - pav * pav) * cosih2; + /* calculate origin of longitudes vector. */ + uix[0] = (1.0 + qav * qav - pav * pav) * cosih2; + uix[1] = 2.0 * qav * pav * cosih2; + uix[2] = -2.0 * pav * cosih2; + /* calculate vector in orbital plane orthogonal to origin of + * longitudes. */ + uiy[0] = 2.0 * qav * pav * cosih2; + uiy[1] = (1.0 - qav * qav + pav * pav) * cosih2; + uiy[2] = 2.0 * qav * cosih2; + /* rotate to actual orientation in space. */ + for (i = 0; i < nco; i++) { + xrot = x[i][0] * uix[0] + x[i][1] * uiy[0] + x[i][2] * uiz[0]; + yrot = x[i][0] * uix[1] + x[i][1] * uiy[1] + x[i][2] * uiz[1]; + zrot = x[i][0] * uix[2] + x[i][1] * uiy[2] + x[i][2] * uiz[2]; + if (fabs(xrot) + fabs(yrot) + fabs(zrot) >= 1e-14) + pdp->neval = i; + x[i][0] = xrot; + x[i][1] = yrot; + x[i][2] = zrot; + if (ipli == SEI_MOON) { + /* rotate to j2000 equator */ + x[i][1] = ceps2000 * yrot - seps2000 * zrot; + x[i][2] = seps2000 * yrot + ceps2000 * zrot; + } + } + for (i = 0; i < nco; i++) { + chcfx[i] = x[i][0]; + chcfy[i] = x[i][1]; + chcfz[i] = x[i][2]; } - } - for (i = 0; i < nco; i++) { - chcfx[i] = x[i][0]; - chcfy[i] = x[i][1]; - chcfz[i] = x[i][2]; - } } /* Adjust position from Earth-Moon barycenter to Earth @@ -4159,38 +4473,40 @@ static void rot_back(int ipli) * earth (output) * xmoon= geocentric position or velocity vector of moon */ -static void embofs(double *xemb, double *xmoon) +static void +embofs(double *xemb, double *xmoon) { - int i; - for (i = 0; i <= 2; i++) - xemb[i] -= xmoon[i] / (EARTH_MOON_MRAT + 1.0); + int i; + for (i = 0; i <= 2; i++) + xemb[i] -= xmoon[i] / (EARTH_MOON_MRAT + 1.0); } /* calculates the nutation matrix * nu pointer to nutation data structure * oe pointer to epsilon data structure */ -static void nut_matrix(struct nut *nu, struct epsilon *oe) +static void +nut_matrix(struct nut *nu, struct epsilon *oe) { - double psi, eps; - double sinpsi, cospsi, sineps, coseps, sineps0, coseps0; - psi = nu->nutlo[0]; - eps = oe->eps + nu->nutlo[1]; - sinpsi = sin(psi); - cospsi = cos(psi); - sineps0 = oe->seps; - coseps0 = oe->ceps; - sineps = sin(eps); - coseps = cos(eps); - nu->matrix[0][0] = cospsi; - nu->matrix[0][1] = sinpsi * coseps; - nu->matrix[0][2] = sinpsi * sineps; - nu->matrix[1][0] = -sinpsi * coseps0; - nu->matrix[1][1] = cospsi * coseps * coseps0 + sineps * sineps0; - nu->matrix[1][2] = cospsi * sineps * coseps0 - coseps * sineps0; - nu->matrix[2][0] = -sinpsi * sineps0; - nu->matrix[2][1] = cospsi * coseps * sineps0 - sineps * coseps0; - nu->matrix[2][2] = cospsi * sineps * sineps0 + coseps * coseps0; + double psi, eps; + double sinpsi, cospsi, sineps, coseps, sineps0, coseps0; + psi = nu->nutlo[0]; + eps = oe->eps + nu->nutlo[1]; + sinpsi = sin(psi); + cospsi = cos(psi); + sineps0 = oe->seps; + coseps0 = oe->ceps; + sineps = sin(eps); + coseps = cos(eps); + nu->matrix[0][0] = cospsi; + nu->matrix[0][1] = sinpsi * coseps; + nu->matrix[0][2] = sinpsi * sineps; + nu->matrix[1][0] = -sinpsi * coseps0; + nu->matrix[1][1] = cospsi * coseps * coseps0 + sineps * sineps0; + nu->matrix[1][2] = cospsi * sineps * coseps0 - coseps * sineps0; + nu->matrix[2][0] = -sinpsi * sineps0; + nu->matrix[2][1] = cospsi * coseps * sineps0 - sineps * coseps0; + nu->matrix[2][2] = cospsi * sineps * sineps0 + coseps * coseps0; } /* lunar osculating elements, i.e. @@ -4208,25 +4524,25 @@ static void nut_matrix(struct nut *nu, struct epsilon *oe) * it is really at the osculating node, and when it passes * its greatest distance from earth it is really at the * osculating apogee. with the mean elements this is not - * the case. (some define the apogee as the second focus of - * the lunar ellipse. but, as seen from the geocenter, both + * the case. (some define the apogee as the second focus of + * the lunar ellipse. but, as seen from the geocenter, both * points are in the same direction.) * problems: * the osculating apogee is given in the 'New International * Ephemerides' (Editions St. Michel) as the 'True Lilith'. * however, this name is misleading. this point is based on * the idea that the lunar orbit can be approximated by an - * ellipse. - * arguments against this: + * ellipse. + * arguments against this: * 1. this procedure considers celestial motions as two body * problems. this is quite good for planets, but not for - * the moon. the strong gravitational attraction of the sun + * the moon. the strong gravitational attraction of the sun * destroys the idea of an ellipse. * 2. the NIE 'True Lilith' has strong oscillations around the * mean one with an amplitude of about 30 degrees. however, * when the moon is in apogee, its distance from the mean * apogee never exceeds 5 degrees. - * besides, the computation of NIE is INACCURATE. the mistake + * besides, the computation of NIE is INACCURATE. the mistake * reaches 20 arc minutes. * According to Santoni, the point was calculated using 'les 58 * premiers termes correctifs au Perigee moyen' published by @@ -4238,23 +4554,23 @@ static void nut_matrix(struct nut *nu, struct epsilon *oe) * how about the node? it is less problematic, because we * we needn't derive it from an orbital ellipse. we can say: * the axis of the osculating nodes is the intersection line of - * the actual orbital plane of the moon and the plane of the + * the actual orbital plane of the moon and the plane of the * ecliptic. or: the osculating nodes are the intersections of - * the two great circles representing the momentary apparent + * the two great circles representing the momentary apparent * orbit of the moon and the ecliptic. in this way they make * some sense. then, the nodes are really an axis, and they * have no geocentric distance. however, in this routine * we give a distance derived from the osculating ellipse. * the node could also be defined as the intersection axis * of the lunar orbital plane and the solar orbital plane, - * which is not precisely identical to the ecliptic. this + * which is not precisely identical to the ecliptic. this * would make a difference of several arcseconds. * * is it possible to keep the idea of a continuously moving * apogee that is exact at the moment when the moon passes * its greatest distance from earth? - * to achieve this, we would probably have to interpolate between - * the actual apogees. + * to achieve this, we would probably have to interpolate between + * the actual apogees. * the nodes could also be computed by interpolation. the resulting * nodes would deviate from the so-called 'true node' by less than * 30 arc minutes. @@ -4264,585 +4580,629 @@ static void nut_matrix(struct nut *nu, struct epsilon *oe) * there is another procedure that computes the node for the ecliptic * of t0(ayanamsa) or J2000. it is excluded by * #ifdef SID_TNODE_FROM_ECL_T0 - */ -static int lunar_osc_elem(double tjd, int ipl, int32 iflag, char *serr) + */ +static int +lunar_osc_elem(double tjd, int ipl, int32 iflag, char *serr) { - int i, j, istart; - int ipli = SEI_MOON; - int32 epheflag = SEFLG_DEFAULTEPH; - int retc = ERR; - int32 flg1, flg2; + int i, j, istart; + int ipli = SEI_MOON; + int32 epheflag = SEFLG_DEFAULTEPH; + int retc = ERR; + int32 flg1, flg2; #if 0 - struct node_data *ndp, *ndnp, *ndap; + struct node_data *ndp, *ndnp, *ndap; #else - struct plan_data *ndp, *ndnp, *ndap; + struct plan_data *ndp, *ndnp, *ndap; #endif - struct epsilon *oe; - double speed_intv = NODE_CALC_INTV; /* to silence gcc warning */ - double a, b; - double xpos[3][6], xx[3][6], xxa[3][6], xnorm[6], r[6]; - double *xp; - double rxy, rxyz, t, dt, fac, sgn; - double sinnode, cosnode, sinincl, cosincl, sinu, cosu, sinE, cosE; - double uu, ny, sema, ecce, Gmsm, c2, v2, pp; - int32 speedf1, speedf2; + struct epsilon *oe; + double speed_intv = NODE_CALC_INTV; /* to silence gcc warning */ + double a, b; + double xpos[3][6], xx[3][6], xxa[3][6], xnorm[6], r[6]; + double *xp; + double rxy, rxyz, t, dt, fac, sgn; + double sinnode, cosnode, sinincl, cosincl, sinu, cosu, sinE, cosE; + double uu, ny, sema, ecce, Gmsm, c2, v2, pp; + int32 speedf1, speedf2; #ifdef SID_TNODE_FROM_ECL_T0 - struct sid_data *sip = &swed.sidd; - struct epsilon oectmp; - if (iflag & SEFLG_SIDEREAL) { - calc_epsilon(sip->t0, &oectmp); - oe = &oectmp; - } else if (iflag & SEFLG_J2000) - oe = &swed.oec2000; - else + struct sid_data *sip = &swed.sidd; + struct epsilon oectmp; + if (iflag & SEFLG_SIDEREAL) { + calc_epsilon(sip->t0, &oectmp); + oe = &oectmp; + } + else if (iflag & SEFLG_J2000) + oe = &swed.oec2000; + else #endif - oe = &swed.oec; - ndp = &swed.nddat[ipl]; - /* if elements have already been computed for this date, return - * if speed flag has been turned on, recompute */ - flg1 = iflag & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; - flg2 = ndp->xflgs & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; - speedf1 = ndp->xflgs & SEFLG_SPEED; - speedf2 = iflag & SEFLG_SPEED; - if (tjd == ndp->teval - && tjd != 0 - && flg1 == flg2 - && (!speedf2 || speedf1)) { - ndp->xflgs = iflag; - ndp->iephe = iflag & SEFLG_EPHMASK; - return OK; - } - /* the geocentric position vector and the speed vector of the - * moon make up the lunar orbital plane. the position vector - * of the node is along the intersection line of the orbital - * plane and the plane of the ecliptic. - * to calculate the osculating node, we need one lunar position - * with speed. - * to calculate the speed of the osculating node, we need - * three lunar positions and the speed of each of them. - * this is relatively cheap, if the jpl-moon or the swisseph - * moon is used. with the moshier moon this is much more - * expensive, because then we need 9 lunar positions for - * three speeds. but one position and speed can normally - * be taken from swed.pldat[moon], which corresponds to - * three moshier moon calculations. - * the same is also true for the osculating apogee: we need - * three lunar positions and speeds. - */ + oe = &swed.oec; + ndp = &swed.nddat[ipl]; + /* if elements have already been computed for this date, return + * if speed flag has been turned on, recompute */ + flg1 = iflag & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; + flg2 = ndp->xflgs & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; + speedf1 = ndp->xflgs & SEFLG_SPEED; + speedf2 = iflag & SEFLG_SPEED; + if (tjd == ndp->teval && tjd != 0 && flg1 == flg2 + && (!speedf2 || speedf1)) { + ndp->xflgs = iflag; + ndp->iephe = iflag & SEFLG_EPHMASK; + return OK; + } + /* the geocentric position vector and the speed vector of the + * moon make up the lunar orbital plane. the position vector + * of the node is along the intersection line of the orbital + * plane and the plane of the ecliptic. + * to calculate the osculating node, we need one lunar position + * with speed. + * to calculate the speed of the osculating node, we need + * three lunar positions and the speed of each of them. + * this is relatively cheap, if the jpl-moon or the swisseph + * moon is used. with the moshier moon this is much more + * expensive, because then we need 9 lunar positions for + * three speeds. but one position and speed can normally + * be taken from swed.pldat[moon], which corresponds to + * three moshier moon calculations. + * the same is also true for the osculating apogee: we need + * three lunar positions and speeds. + */ + /********************************************* - * now three lunar positions with speeds * + * now three lunar positions with speeds * *********************************************/ - if (iflag & SEFLG_MOSEPH) - epheflag = SEFLG_MOSEPH; - else if (iflag & SEFLG_SWIEPH) - epheflag = SEFLG_SWIEPH; - else if (iflag & SEFLG_JPLEPH) - epheflag = SEFLG_JPLEPH; - /* there may be a moon of wrong ephemeris in save area - * force new computation: */ - swed.pldat[SEI_MOON].teval = 0; - if (iflag & SEFLG_SPEED) - istart = 0; - else - istart = 2; - if (serr != NULL) - *serr = '\0'; - three_positions: - switch(epheflag) { + if (iflag & SEFLG_MOSEPH) + epheflag = SEFLG_MOSEPH; + else if (iflag & SEFLG_SWIEPH) + epheflag = SEFLG_SWIEPH; + else if (iflag & SEFLG_JPLEPH) + epheflag = SEFLG_JPLEPH; + /* there may be a moon of wrong ephemeris in save area + * force new computation: */ + swed.pldat[SEI_MOON].teval = 0; + if (iflag & SEFLG_SPEED) + istart = 0; + else + istart = 2; + if (serr != NULL) + *serr = '\0'; +three_positions: + switch (epheflag) { #ifndef NO_JPL - case SEFLG_JPLEPH: - speed_intv = NODE_CALC_INTV; - for (i = istart; i <= 2; i++) { - if (i == 0) - t = tjd - speed_intv; - else if (i == 1) - t = tjd + speed_intv; - else - t = tjd; - xp = xpos[i]; - retc = jplplan(t, ipli, iflag, NO_SAVE, xp, NULL, NULL, serr); - /* read error or corrupt file */ - if (retc == ERR) - return(ERR); - /* light-time-corrected moon for apparent node - * this makes a difference of several milliarcseconds with - * the node and 0.1" with the apogee. - * the simple formual 'x[j] -= dt * speed' should not be - * used here. the error would be greater than the advantage - * of computation speed. */ - if ((iflag & SEFLG_TRUEPOS) == 0 && retc >= OK) { - dt = sqrt(square_sum(xpos[i])) * AUNIT / CLIGHT / 86400.0; - retc = jplplan(t-dt, ipli, iflag, NO_SAVE, xpos[i], NULL, NULL, serr);/**/ - /* read error or corrupt file */ - if (retc == ERR) - return(ERR); - } - /* jpl ephemeris not on disk, or date beyond ephemeris range */ - if (retc == NOT_AVAILABLE) { - iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_SWIEPH; - epheflag = SEFLG_SWIEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, " \ntrying Swiss Eph; "); - break; - } else if (retc == BEYOND_EPH_LIMITS) { - if (tjd > MOSHLUEPH_START && tjd < MOSHLUEPH_END) { - iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_MOSEPH; - epheflag = SEFLG_MOSEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, " \nusing Moshier Eph; "); - break; - } else - return ERR; - } - /* precession and nutation etc. */ - retc = swi_plan_for_osc_elem(iflag|SEFLG_SPEED, t, xpos[i]); /* retc is always ok */ - } - break; -#endif /* NO_JPL */ - case SEFLG_SWIEPH: + case SEFLG_JPLEPH: + speed_intv = NODE_CALC_INTV; + for (i = istart; i <= 2; i++) { + if (i == 0) + t = tjd - speed_intv; + else if (i == 1) + t = tjd + speed_intv; + else + t = tjd; + xp = xpos[i]; + retc = jplplan(t, ipli, iflag, NO_SAVE, xp, NULL, NULL, serr); + /* read error or corrupt file */ + if (retc == ERR) + return (ERR); + /* light-time-corrected moon for apparent node + * this makes a difference of several milliarcseconds with + * the node and 0.1" with the apogee. + * the simple formual 'x[j] -= dt * speed' should not be + * used here. the error would be greater than the advantage + * of computation speed. */ + if ((iflag & SEFLG_TRUEPOS) == 0 && retc >= OK) { + dt = sqrt(square_sum(xpos[i])) * AUNIT / CLIGHT / 86400.0; + retc = + jplplan(t - dt, ipli, iflag, NO_SAVE, xpos[i], NULL, + NULL, serr); + /**/ + /* read error or corrupt file */ + if (retc == ERR) + return (ERR); + } + /* jpl ephemeris not on disk, or date beyond ephemeris range */ + if (retc == NOT_AVAILABLE) { + iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_SWIEPH; + epheflag = SEFLG_SWIEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, " \ntrying Swiss Eph; "); + break; + } + else if (retc == BEYOND_EPH_LIMITS) { + if (tjd > MOSHLUEPH_START && tjd < MOSHLUEPH_END) { + iflag = (iflag & ~SEFLG_JPLEPH) | SEFLG_MOSEPH; + epheflag = SEFLG_MOSEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, " \nusing Moshier Eph; "); + break; + } + else + return ERR; + } + /* precession and nutation etc. */ + retc = swi_plan_for_osc_elem(iflag | SEFLG_SPEED, t, xpos[i]); /* retc is always ok */ + } + break; +#endif /* NO_JPL */ + case SEFLG_SWIEPH: #if 0 - sweph_moon: +sweph_moon: #endif - speed_intv = NODE_CALC_INTV; - for (i = istart; i <= 2; i++) { - if (i == 0) - t = tjd - speed_intv; - else if (i == 1) - t = tjd + speed_intv; - else - t = tjd; - retc = swemoon(t, iflag | SEFLG_SPEED, NO_SAVE, xpos[i], serr);/**/ - if (retc == ERR) - return(ERR); - /* light-time-corrected moon for apparent node (~ 0.006") */ - if ((iflag & SEFLG_TRUEPOS) == 0 && retc >= OK) { - dt = sqrt(square_sum(xpos[i])) * AUNIT / CLIGHT / 86400.0; - retc = swemoon(t-dt, iflag | SEFLG_SPEED, NO_SAVE, xpos[i], serr);/**/ - if (retc == ERR) - return(ERR); - } - if (retc == NOT_AVAILABLE) { - if (tjd > MOSHPLEPH_START && tjd < MOSHPLEPH_END) { - iflag = (iflag & ~SEFLG_SWIEPH) | SEFLG_MOSEPH; - epheflag = SEFLG_MOSEPH; - if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) - strcat(serr, " \nusing Moshier eph.; "); - break; - } else - return ERR; - } - /* precession and nutation etc. */ - retc = swi_plan_for_osc_elem(iflag|SEFLG_SPEED, t, xpos[i]); /* retc is always ok */ - } - break; - case SEFLG_MOSEPH: + speed_intv = NODE_CALC_INTV; + for (i = istart; i <= 2; i++) { + if (i == 0) + t = tjd - speed_intv; + else if (i == 1) + t = tjd + speed_intv; + else + t = tjd; + retc = + swemoon(t, iflag | SEFLG_SPEED, NO_SAVE, xpos[i], serr); + /**/ if (retc == ERR) + return (ERR); + /* light-time-corrected moon for apparent node (~ 0.006") */ + if ((iflag & SEFLG_TRUEPOS) == 0 && retc >= OK) { + dt = sqrt(square_sum(xpos[i])) * AUNIT / CLIGHT / 86400.0; + retc = + swemoon(t - dt, iflag | SEFLG_SPEED, NO_SAVE, xpos[i], + serr); + /**/ if (retc == ERR) + return (ERR); + } + if (retc == NOT_AVAILABLE) { + if (tjd > MOSHPLEPH_START && tjd < MOSHPLEPH_END) { + iflag = (iflag & ~SEFLG_SWIEPH) | SEFLG_MOSEPH; + epheflag = SEFLG_MOSEPH; + if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) + strcat(serr, " \nusing Moshier eph.; "); + break; + } + else + return ERR; + } + /* precession and nutation etc. */ + retc = swi_plan_for_osc_elem(iflag | SEFLG_SPEED, t, xpos[i]); /* retc is always ok */ + } + break; + case SEFLG_MOSEPH: #if 0 - moshier_moon: +moshier_moon: #endif - /* with moshier moon, we need a greater speed_intv, because here the - * node and apogee oscillate wildly within small intervals */ - speed_intv = NODE_CALC_INTV_MOSH; - for (i = istart; i <= 2; i++) { - if (i == 0) - t = tjd - speed_intv; - else if (i == 1) - t = tjd + speed_intv; - else - t = tjd; - retc = swi_moshmoon(t, NO_SAVE, xpos[i], serr);/**/ - if (retc == ERR) - return(retc); + /* with moshier moon, we need a greater speed_intv, because here the + * node and apogee oscillate wildly within small intervals */ + speed_intv = NODE_CALC_INTV_MOSH; + for (i = istart; i <= 2; i++) { + if (i == 0) + t = tjd - speed_intv; + else if (i == 1) + t = tjd + speed_intv; + else + t = tjd; + retc = swi_moshmoon(t, NO_SAVE, xpos[i], serr); + /**/ if (retc == ERR) + return (retc); #if 0 - /* light-time-corrected moon for apparent node. - * can be neglected with moshier */ - if ((iflag & SEFLG_TRUEPOS) == 0 && retc >= OK) { - dt = sqrt(square_sum(xpos[i])) * AUNIT / CLIGHT / 86400; - retc = swi_moshmoon(t-dt, NO_SAVE, xpos[i], serr);/**/ - } + /* light-time-corrected moon for apparent node. + * can be neglected with moshier */ + if ((iflag & SEFLG_TRUEPOS) == 0 && retc >= OK) { + dt = sqrt(square_sum(xpos[i])) * AUNIT / CLIGHT / 86400; + retc = swi_moshmoon(t - dt, NO_SAVE, xpos[i], serr); + /**/} #endif - /* precession and nutation etc. */ - retc = swi_plan_for_osc_elem(iflag|SEFLG_SPEED, t, xpos[i]); /* retc is always ok */ - } - break; - default: - break; - } - if (retc == NOT_AVAILABLE || retc == BEYOND_EPH_LIMITS) - goto three_positions; + /* precession and nutation etc. */ + retc = swi_plan_for_osc_elem(iflag | SEFLG_SPEED, t, xpos[i]); /* retc is always ok */ + } + break; + default: + break; + } + if (retc == NOT_AVAILABLE || retc == BEYOND_EPH_LIMITS) + goto three_positions; + /********************************************* - * node with speed * + * node with speed * *********************************************/ - /* node is always needed, even if apogee is wanted */ - ndnp = &swed.nddat[SEI_TRUE_NODE]; - /* three nodes */ - for (i = istart; i <= 2; i++) { - if (fabs(xpos[i][5]) < 1e-15) - xpos[i][5] = 1e-15; - fac = xpos[i][2] / xpos[i][5]; - sgn = xpos[i][5] / fabs(xpos[i][5]); - for (j = 0; j <= 2; j++) - xx[i][j] = (xpos[i][j] - fac * xpos[i][j+3]) * sgn; - } - /* now we have the correct direction of the node, the - * intersection of the lunar plane and the ecliptic plane. - * the distance is the distance of the point where the tangent - * of the lunar motion penetrates the ecliptic plane. - * this can be very large, e.g. j2415080.37372. - * below, a new distance will be derived from the osculating - * ellipse. - */ - /* save position and speed */ - for (i = 0; i <= 2; i++) { - ndnp->x[i] = xx[2][i]; - if (iflag & SEFLG_SPEED) { - b = (xx[1][i] - xx[0][i]) / 2; - a = (xx[1][i] + xx[0][i]) / 2 - xx[2][i]; - ndnp->x[i+3] = (2 * a + b) / speed_intv; - } else - ndnp->x[i+3] = 0; - ndnp->teval = tjd; - ndnp->iephe = epheflag; - } + /* node is always needed, even if apogee is wanted */ + ndnp = &swed.nddat[SEI_TRUE_NODE]; + /* three nodes */ + for (i = istart; i <= 2; i++) { + if (fabs(xpos[i][5]) < 1e-15) + xpos[i][5] = 1e-15; + fac = xpos[i][2] / xpos[i][5]; + sgn = xpos[i][5] / fabs(xpos[i][5]); + for (j = 0; j <= 2; j++) + xx[i][j] = (xpos[i][j] - fac * xpos[i][j + 3]) * sgn; + } + /* now we have the correct direction of the node, the + * intersection of the lunar plane and the ecliptic plane. + * the distance is the distance of the point where the tangent + * of the lunar motion penetrates the ecliptic plane. + * this can be very large, e.g. j2415080.37372. + * below, a new distance will be derived from the osculating + * ellipse. + */ + /* save position and speed */ + for (i = 0; i <= 2; i++) { + ndnp->x[i] = xx[2][i]; + if (iflag & SEFLG_SPEED) { + b = (xx[1][i] - xx[0][i]) / 2; + a = (xx[1][i] + xx[0][i]) / 2 - xx[2][i]; + ndnp->x[i + 3] = (2 * a + b) / speed_intv; + } + else + ndnp->x[i + 3] = 0; + ndnp->teval = tjd; + ndnp->iephe = epheflag; + } + /************************************************************ - * apogee with speed * + * apogee with speed * * must be computed anyway to get the node's distance * ************************************************************/ - ndap = &swed.nddat[SEI_OSCU_APOG]; - Gmsm = GEOGCONST * (1 + 1 / EARTH_MOON_MRAT) /AUNIT/AUNIT/AUNIT*86400.0*86400.0; - /* three apogees */ - for (i = istart; i <= 2; i++) { - /* node */ - rxy = sqrt(xx[i][0] * xx[i][0] + xx[i][1] * xx[i][1]); - cosnode = xx[i][0] / rxy; - sinnode = xx[i][1] / rxy; - /* inclination */ - swi_cross_prod(xpos[i], xpos[i]+3, xnorm); - rxy = xnorm[0] * xnorm[0] + xnorm[1] * xnorm[1]; - c2 = (rxy + xnorm[2] * xnorm[2]); - rxyz = sqrt(c2); - rxy = sqrt(rxy); - sinincl = rxy / rxyz; - cosincl = sqrt(1 - sinincl * sinincl); - /* argument of latitude */ - cosu = xpos[i][0] * cosnode + xpos[i][1] * sinnode; - sinu = xpos[i][2] / sinincl; - uu = atan2(sinu, cosu); - /* semi-axis */ - rxyz = sqrt(square_sum(xpos[i])); - v2 = square_sum((xpos[i]+3)); - sema = 1 / (2 / rxyz - v2 / Gmsm); - /* eccentricity */ - pp = c2 / Gmsm; - ecce = sqrt(1 - pp / sema); - /* eccentric anomaly */ - cosE = 1 / ecce * (1 - rxyz / sema); - sinE = 1 / ecce / sqrt(sema * Gmsm) * dot_prod(xpos[i], (xpos[i]+3)); - /* true anomaly */ - ny = 2 * atan(sqrt((1+ecce)/(1-ecce)) * sinE / (1 + cosE)); - /* distance of apogee from ascending node */ - xxa[i][0] = swi_mod2PI(uu - ny + PI); - xxa[i][1] = 0; /* latitude */ - xxa[i][2] = sema * (1 + ecce); /* distance */ - /* transformation to ecliptic coordinates */ - swi_polcart(xxa[i], xxa[i]); - swi_coortrf2(xxa[i], xxa[i], -sinincl, cosincl); - swi_cartpol(xxa[i], xxa[i]); - /* adding node, we get apogee in ecl. coord. */ - xxa[i][0] += atan2(sinnode, cosnode); - swi_polcart(xxa[i], xxa[i]); - /* new distance of node from orbital ellipse: - * true anomaly of node: */ - ny = swi_mod2PI(ny - uu); - /* eccentric anomaly */ - cosE = cos(2 * atan(tan(ny / 2) / sqrt((1+ecce) / (1-ecce)))); - /* new distance */ - r[0] = sema * (1 - ecce * cosE); - /* old node distance */ - r[1] = sqrt(square_sum(xx[i])); - /* correct length of position vector */ - for (j = 0; j <= 2; j++) - xx[i][j] *= r[0] / r[1]; - } - /* save position and speed */ - for (i = 0; i <= 2; i++) { - /* apogee */ - ndap->x[i] = xxa[2][i]; - if (iflag & SEFLG_SPEED) - ndap->x[i+3] = (xxa[1][i] - xxa[0][i]) / speed_intv / 2; - else - ndap->x[i+3] = 0; - ndap->teval = tjd; - ndap->iephe = epheflag; - /* node */ - ndnp->x[i] = xx[2][i]; - if (iflag & SEFLG_SPEED) - ndnp->x[i+3] = (xx[1][i] - xx[0][i]) / speed_intv / 2;/**/ - else - ndnp->x[i+3] = 0; - } + ndap = &swed.nddat[SEI_OSCU_APOG]; + Gmsm = + GEOGCONST * (1 + + 1 / EARTH_MOON_MRAT) / AUNIT / AUNIT / AUNIT * 86400.0 * + 86400.0; + /* three apogees */ + for (i = istart; i <= 2; i++) { + /* node */ + rxy = sqrt(xx[i][0] * xx[i][0] + xx[i][1] * xx[i][1]); + cosnode = xx[i][0] / rxy; + sinnode = xx[i][1] / rxy; + /* inclination */ + swi_cross_prod(xpos[i], xpos[i] + 3, xnorm); + rxy = xnorm[0] * xnorm[0] + xnorm[1] * xnorm[1]; + c2 = (rxy + xnorm[2] * xnorm[2]); + rxyz = sqrt(c2); + rxy = sqrt(rxy); + sinincl = rxy / rxyz; + cosincl = sqrt(1 - sinincl * sinincl); + /* argument of latitude */ + cosu = xpos[i][0] * cosnode + xpos[i][1] * sinnode; + sinu = xpos[i][2] / sinincl; + uu = atan2(sinu, cosu); + /* semi-axis */ + rxyz = sqrt(square_sum(xpos[i])); + v2 = square_sum((xpos[i] + 3)); + sema = 1 / (2 / rxyz - v2 / Gmsm); + /* eccentricity */ + pp = c2 / Gmsm; + ecce = sqrt(1 - pp / sema); + /* eccentric anomaly */ + cosE = 1 / ecce * (1 - rxyz / sema); + sinE = + 1 / ecce / sqrt(sema * Gmsm) * dot_prod(xpos[i], (xpos[i] + 3)); + /* true anomaly */ + ny = 2 * atan(sqrt((1 + ecce) / (1 - ecce)) * sinE / (1 + cosE)); + /* distance of apogee from ascending node */ + xxa[i][0] = swi_mod2PI(uu - ny + PI); + xxa[i][1] = 0; /* latitude */ + xxa[i][2] = sema * (1 + ecce); /* distance */ + /* transformation to ecliptic coordinates */ + swi_polcart(xxa[i], xxa[i]); + swi_coortrf2(xxa[i], xxa[i], -sinincl, cosincl); + swi_cartpol(xxa[i], xxa[i]); + /* adding node, we get apogee in ecl. coord. */ + xxa[i][0] += atan2(sinnode, cosnode); + swi_polcart(xxa[i], xxa[i]); + /* new distance of node from orbital ellipse: + * true anomaly of node: */ + ny = swi_mod2PI(ny - uu); + /* eccentric anomaly */ + cosE = cos(2 * atan(tan(ny / 2) / sqrt((1 + ecce) / (1 - ecce)))); + /* new distance */ + r[0] = sema * (1 - ecce * cosE); + /* old node distance */ + r[1] = sqrt(square_sum(xx[i])); + /* correct length of position vector */ + for (j = 0; j <= 2; j++) + xx[i][j] *= r[0] / r[1]; + } + /* save position and speed */ + for (i = 0; i <= 2; i++) { + /* apogee */ + ndap->x[i] = xxa[2][i]; + if (iflag & SEFLG_SPEED) + ndap->x[i + 3] = (xxa[1][i] - xxa[0][i]) / speed_intv / 2; + else + ndap->x[i + 3] = 0; + ndap->teval = tjd; + ndap->iephe = epheflag; + /* node */ + ndnp->x[i] = xx[2][i]; + if (iflag & SEFLG_SPEED) + ndnp->x[i + 3] = (xx[1][i] - xx[0][i]) / speed_intv / 2; + /**/ + else + ndnp->x[i + 3] = 0; + } + /********************************************************************** * precession and nutation have already been taken into account * because the computation is on the basis of lunar positions - * that have gone through swi_plan_for_osc_elem. + * that have gone through swi_plan_for_osc_elem. * light-time is already contained in lunar positions. * now compute polar and equatorial coordinates: **********************************************************************/ - for (j = 0; j <= 1; j++) { - double x[6]; - if (j == 0) - ndp = &swed.nddat[SEI_TRUE_NODE]; - else - ndp = &swed.nddat[SEI_OSCU_APOG]; - memset((void *) ndp->xreturn, 0, 24 * sizeof(double)); - /* cartesian ecliptic */ - for (i = 0; i <= 5; i++) - ndp->xreturn[6+i] = ndp->x[i]; - /* polar ecliptic */ - swi_cartpol_sp(ndp->xreturn+6, ndp->xreturn); - /* cartesian equatorial */ - swi_coortrf2(ndp->xreturn+6, ndp->xreturn+18, -oe->seps, oe->ceps); - if (iflag & SEFLG_SPEED) - swi_coortrf2(ndp->xreturn+9, ndp->xreturn+21, -oe->seps, oe->ceps); + for (j = 0; j <= 1; j++) { + double x[6]; + if (j == 0) + ndp = &swed.nddat[SEI_TRUE_NODE]; + else + ndp = &swed.nddat[SEI_OSCU_APOG]; + memset((void *)ndp->xreturn, 0, 24 * sizeof(double)); + /* cartesian ecliptic */ + for (i = 0; i <= 5; i++) + ndp->xreturn[6 + i] = ndp->x[i]; + /* polar ecliptic */ + swi_cartpol_sp(ndp->xreturn + 6, ndp->xreturn); + /* cartesian equatorial */ + swi_coortrf2(ndp->xreturn + 6, ndp->xreturn + 18, -oe->seps, + oe->ceps); + if (iflag & SEFLG_SPEED) + swi_coortrf2(ndp->xreturn + 9, ndp->xreturn + 21, -oe->seps, + oe->ceps); #ifdef SID_TNODE_FROM_ECL_T0 - /* sideral: we return NORMAL equatorial coordinates, there are no - * sidereal ones */ - if (iflag & SEFLG_SIDEREAL) { - /* to J2000 */ - swi_precess(ndp->xreturn+18, sip->t0, J_TO_J2000); - if (iflag & SEFLG_SPEED) - swi_precess_speed(ndp->xreturn+21, sip->t0, J_TO_J2000); - if (!(iflag & SEFLG_J2000)) { - /* to tjd */ - swi_precess(ndp->xreturn+18, tjd, J2000_TO_J); - if (iflag & SEFLG_SPEED) - swi_precess_speed(ndp->xreturn+21, tjd, J2000_TO_J); - } - } + /* sideral: we return NORMAL equatorial coordinates, there are no + * sidereal ones */ + if (iflag & SEFLG_SIDEREAL) { + /* to J2000 */ + swi_precess(ndp->xreturn + 18, sip->t0, J_TO_J2000); + if (iflag & SEFLG_SPEED) + swi_precess_speed(ndp->xreturn + 21, sip->t0, J_TO_J2000); + if (!(iflag & SEFLG_J2000)) { + /* to tjd */ + swi_precess(ndp->xreturn + 18, tjd, J2000_TO_J); + if (iflag & SEFLG_SPEED) + swi_precess_speed(ndp->xreturn + 21, tjd, J2000_TO_J); + } + } #endif - if (!(iflag & SEFLG_NONUT)) { - swi_coortrf2(ndp->xreturn+18, ndp->xreturn+18, -swed.nut.snut, swed.nut.cnut); - if (iflag & SEFLG_SPEED) - swi_coortrf2(ndp->xreturn+21, ndp->xreturn+21, -swed.nut.snut, swed.nut.cnut); - } - /* polar equatorial */ - swi_cartpol_sp(ndp->xreturn+18, ndp->xreturn+12); - ndp->xflgs = iflag; - ndp->iephe = iflag & SEFLG_EPHMASK; + if (!(iflag & SEFLG_NONUT)) { + swi_coortrf2(ndp->xreturn + 18, ndp->xreturn + 18, -swed.nut.snut, + swed.nut.cnut); + if (iflag & SEFLG_SPEED) + swi_coortrf2(ndp->xreturn + 21, ndp->xreturn + 21, + -swed.nut.snut, swed.nut.cnut); + } + /* polar equatorial */ + swi_cartpol_sp(ndp->xreturn + 18, ndp->xreturn + 12); + ndp->xflgs = iflag; + ndp->iephe = iflag & SEFLG_EPHMASK; #ifdef SID_TNODE_FROM_ECL_T0 - /* node and apogee are already referred to t0; - * nothing has to be done */ + /* node and apogee are already referred to t0; + * nothing has to be done */ #else - if (iflag & SEFLG_SIDEREAL) { - /* node and apogee are referred to t; - * the ecliptic position must be transformed to t0 */ - /* rigorous algorithm */ - if ((swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) - || (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE)) { - for (i = 0; i <= 5; i++) - x[i] = ndp->xreturn[18+i]; - /* remove nutation */ - if (!(iflag & SEFLG_NONUT)) - swi_nutate(x, iflag, TRUE); - /* precess to J2000 */ - swi_precess(x, tjd, J_TO_J2000); - if (iflag & SEFLG_SPEED) - swi_precess_speed(x, tjd, J_TO_J2000); - if (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) - swi_trop_ra2sid_lon(x, ndp->xreturn+6, ndp->xreturn+18, iflag, NULL); - /* project onto solar system equator */ - else if (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE) - swi_trop_ra2sid_lon_sosy(x, ndp->xreturn+6, ndp->xreturn+18, iflag, NULL); - /* to polar */ - swi_cartpol_sp(ndp->xreturn+6, ndp->xreturn); - swi_cartpol_sp(ndp->xreturn+18, ndp->xreturn+12); - /* traditional algorithm; - * this is a bit clumsy, but allows us to keep the - * sidereal code together */ - } else { - swi_cartpol_sp(ndp->xreturn+6, ndp->xreturn); - ndp->xreturn[0] -= swe_get_ayanamsa(ndp->teval) * DEGTORAD; - swi_polcart_sp(ndp->xreturn, ndp->xreturn+6); - } - } else if (iflag & SEFLG_J2000) { - /* node and apogee are referred to t; - * the ecliptic position must be transformed to J2000 */ - for (i = 0; i <= 5; i++) - x[i] = ndp->xreturn[18+i]; - /* precess to J2000 */ - swi_precess(x, tjd, J_TO_J2000); - if (iflag & SEFLG_SPEED) - swi_precess_speed(x, tjd, J_TO_J2000); - for (i = 0; i <= 5; i++) - ndp->xreturn[18+i] = x[i]; - swi_cartpol_sp(ndp->xreturn+18, ndp->xreturn+12); - swi_coortrf2(ndp->xreturn+18, ndp->xreturn+6, swed.oec2000.seps, swed.oec2000.ceps); - if (iflag & SEFLG_SPEED) - swi_coortrf2(ndp->xreturn+21, ndp->xreturn+9, swed.oec2000.seps, swed.oec2000.ceps); - swi_cartpol_sp(ndp->xreturn+6, ndp->xreturn); - } + if (iflag & SEFLG_SIDEREAL) { + /* node and apogee are referred to t; + * the ecliptic position must be transformed to t0 */ + /* rigorous algorithm */ + if ((swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) + || (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE)) { + for (i = 0; i <= 5; i++) + x[i] = ndp->xreturn[18 + i]; + /* remove nutation */ + if (!(iflag & SEFLG_NONUT)) + swi_nutate(x, iflag, TRUE); + /* precess to J2000 */ + swi_precess(x, tjd, J_TO_J2000); + if (iflag & SEFLG_SPEED) + swi_precess_speed(x, tjd, J_TO_J2000); + if (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) + swi_trop_ra2sid_lon(x, ndp->xreturn + 6, + ndp->xreturn + 18, iflag, NULL); + /* project onto solar system equator */ + else if (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE) + swi_trop_ra2sid_lon_sosy(x, ndp->xreturn + 6, + ndp->xreturn + 18, iflag, NULL); + /* to polar */ + swi_cartpol_sp(ndp->xreturn + 6, ndp->xreturn); + swi_cartpol_sp(ndp->xreturn + 18, ndp->xreturn + 12); + /* traditional algorithm; + * this is a bit clumsy, but allows us to keep the + * sidereal code together */ + } + else { + swi_cartpol_sp(ndp->xreturn + 6, ndp->xreturn); + ndp->xreturn[0] -= swe_get_ayanamsa(ndp->teval) * DEGTORAD; + swi_polcart_sp(ndp->xreturn, ndp->xreturn + 6); + } + } + else if (iflag & SEFLG_J2000) { + /* node and apogee are referred to t; + * the ecliptic position must be transformed to J2000 */ + for (i = 0; i <= 5; i++) + x[i] = ndp->xreturn[18 + i]; + /* precess to J2000 */ + swi_precess(x, tjd, J_TO_J2000); + if (iflag & SEFLG_SPEED) + swi_precess_speed(x, tjd, J_TO_J2000); + for (i = 0; i <= 5; i++) + ndp->xreturn[18 + i] = x[i]; + swi_cartpol_sp(ndp->xreturn + 18, ndp->xreturn + 12); + swi_coortrf2(ndp->xreturn + 18, ndp->xreturn + 6, + swed.oec2000.seps, swed.oec2000.ceps); + if (iflag & SEFLG_SPEED) + swi_coortrf2(ndp->xreturn + 21, ndp->xreturn + 9, + swed.oec2000.seps, swed.oec2000.ceps); + swi_cartpol_sp(ndp->xreturn + 6, ndp->xreturn); + } #endif - /********************** + + /********************** * radians to degrees * **********************/ - /*if (!(iflag & SEFLG_RADIANS)) {*/ - for (i = 0; i < 2; i++) { - ndp->xreturn[i] *= RADTODEG; /* ecliptic */ - ndp->xreturn[i+3] *= RADTODEG; - ndp->xreturn[i+12] *= RADTODEG; /* equator */ - ndp->xreturn[i+15] *= RADTODEG; - } - ndp->xreturn[0] = swe_degnorm(ndp->xreturn[0]); - ndp->xreturn[12] = swe_degnorm(ndp->xreturn[12]); - /*}*/ - } - return OK; + /*if (!(iflag & SEFLG_RADIANS)) { */ + for (i = 0; i < 2; i++) { + ndp->xreturn[i] *= RADTODEG; /* ecliptic */ + ndp->xreturn[i + 3] *= RADTODEG; + ndp->xreturn[i + 12] *= RADTODEG; /* equator */ + ndp->xreturn[i + 15] *= RADTODEG; + } + ndp->xreturn[0] = swe_degnorm(ndp->xreturn[0]); + ndp->xreturn[12] = swe_degnorm(ndp->xreturn[12]); + /*} */ + } + return OK; } /* lunar osculating elements, i.e. - */ -static int intp_apsides(double tjd, int ipl, int32 iflag, char *serr) + */ +static int +intp_apsides(double tjd, int ipl, int32 iflag, char *serr) { - int i; - int32 flg1, flg2; - struct plan_data *ndp; - struct epsilon *oe; - struct nut *nut; - double speed_intv = 0.1; - double t, dt; - double xpos[3][6], xx[6], x[6]; - int32 speedf1, speedf2; - oe = &swed.oec; - nut = &swed.nut; - ndp = &swed.nddat[ipl]; - /* if same calculation was done before, return - * if speed flag has been turned on, recompute */ - flg1 = iflag & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; - flg2 = ndp->xflgs & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; - speedf1 = ndp->xflgs & SEFLG_SPEED; - speedf2 = iflag & SEFLG_SPEED; - if (tjd == ndp->teval - && tjd != 0 - && flg1 == flg2 - && (!speedf2 || speedf1)) { - ndp->xflgs = iflag; - ndp->iephe = iflag & SEFLG_MOSEPH; - return OK; - } + int i; + int32 flg1, flg2; + struct plan_data *ndp; + struct epsilon *oe; + struct nut *nut; + double speed_intv = 0.1; + double t, dt; + double xpos[3][6], xx[6], x[6]; + int32 speedf1, speedf2; + oe = &swed.oec; + nut = &swed.nut; + ndp = &swed.nddat[ipl]; + /* if same calculation was done before, return + * if speed flag has been turned on, recompute */ + flg1 = iflag & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; + flg2 = ndp->xflgs & ~SEFLG_EQUATORIAL & ~SEFLG_XYZ; + speedf1 = ndp->xflgs & SEFLG_SPEED; + speedf2 = iflag & SEFLG_SPEED; + if (tjd == ndp->teval && tjd != 0 && flg1 == flg2 + && (!speedf2 || speedf1)) { + ndp->xflgs = iflag; + ndp->iephe = iflag & SEFLG_MOSEPH; + return OK; + } + /********************************************* - * now three apsides * + * now three apsides * *********************************************/ - for (t = tjd - speed_intv, i = 0; i < 3; t += speed_intv, i++) { - if (! (iflag & SEFLG_SPEED) && i != 1) continue; - swi_intp_apsides(t, xpos[i], ipl); - } + for (t = tjd - speed_intv, i = 0; i < 3; t += speed_intv, i++) { + if (!(iflag & SEFLG_SPEED) && i != 1) + continue; + swi_intp_apsides(t, xpos[i], ipl); + } + /************************************************************ - * apsis with speed * + * apsis with speed * ************************************************************/ - for (i = 0; i < 3; i++) { - xx[i] = xpos[1][i]; - xx[i+3] = 0; - } - if (iflag & SEFLG_SPEED) { - xx[3] = swe_difrad2n(xpos[2][0], xpos[0][0]) / speed_intv / 2.0; - xx[4] = (xpos[2][1] - xpos[0][1]) / speed_intv / 2.0; - xx[5] = (xpos[2][2] - xpos[0][2]) / speed_intv / 2.0; - } - memset((void *) ndp->xreturn, 0, 24 * sizeof(double)); - /* ecliptic polar to cartesian */ - swi_polcart_sp(xx, xx); - /* light-time */ - if (!(iflag & SEFLG_TRUEPOS)) { - dt = sqrt(square_sum(xx)) * AUNIT / CLIGHT / 86400.0; - for (i = 1; i < 3; i++) - xx[i] -= dt * xx[i+3]; - } - for (i = 0; i <= 5; i++) - ndp->xreturn[i+6] = xx[i]; - /*printf("%.10f, %.10f, %.10f, %.10f\n", xx[0] /DEGTORAD, xx[1] / DEGTORAD, xx [2], xx[3] /DEGTORAD);*/ - /* equatorial cartesian */ - swi_coortrf2(ndp->xreturn+6, ndp->xreturn+18, -oe->seps, oe->ceps); - if (iflag & SEFLG_SPEED) - swi_coortrf2(ndp->xreturn+9, ndp->xreturn+21, -oe->seps, oe->ceps); - ndp->teval = tjd; - ndp->xflgs = iflag; - ndp->iephe = iflag & SEFLG_EPHMASK; - if (iflag & SEFLG_SIDEREAL) { - /* apogee is referred to t; - * the ecliptic position must be transformed to t0 */ - /* rigorous algorithm */ - if ((swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) - || (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE)) { - for (i = 0; i <= 5; i++) - x[i] = ndp->xreturn[18+i]; - /* precess to J2000 */ - swi_precess(x, tjd, J_TO_J2000); - if (iflag & SEFLG_SPEED) - swi_precess_speed(x, tjd, J_TO_J2000); - if (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) - swi_trop_ra2sid_lon(x, ndp->xreturn+6, ndp->xreturn+18, iflag, NULL); - /* project onto solar system equator */ - else if (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE) - swi_trop_ra2sid_lon_sosy(x, ndp->xreturn+6, ndp->xreturn+18, iflag, NULL); - /* to polar */ - swi_cartpol_sp(ndp->xreturn+6, ndp->xreturn); - swi_cartpol_sp(ndp->xreturn+18, ndp->xreturn+12); - } else { - /* traditional algorithm */ - swi_cartpol_sp(ndp->xreturn+6, ndp->xreturn); - ndp->xreturn[0] -= swe_get_ayanamsa(ndp->teval) * DEGTORAD; - swi_polcart_sp(ndp->xreturn, ndp->xreturn+6); - swi_cartpol_sp(ndp->xreturn+18, ndp->xreturn+12); + for (i = 0; i < 3; i++) { + xx[i] = xpos[1][i]; + xx[i + 3] = 0; + } + if (iflag & SEFLG_SPEED) { + xx[3] = swe_difrad2n(xpos[2][0], xpos[0][0]) / speed_intv / 2.0; + xx[4] = (xpos[2][1] - xpos[0][1]) / speed_intv / 2.0; + xx[5] = (xpos[2][2] - xpos[0][2]) / speed_intv / 2.0; + } + memset((void *)ndp->xreturn, 0, 24 * sizeof(double)); + /* ecliptic polar to cartesian */ + swi_polcart_sp(xx, xx); + /* light-time */ + if (!(iflag & SEFLG_TRUEPOS)) { + dt = sqrt(square_sum(xx)) * AUNIT / CLIGHT / 86400.0; + for (i = 1; i < 3; i++) + xx[i] -= dt * xx[i + 3]; } - } else if (iflag & SEFLG_J2000) { - /* node and apogee are referred to t; - * the ecliptic position must be transformed to J2000 */ for (i = 0; i <= 5; i++) - x[i] = ndp->xreturn[18+i]; - /* precess to J2000 */ - swi_precess(x, tjd, J_TO_J2000); + ndp->xreturn[i + 6] = xx[i]; + /*printf("%.10f, %.10f, %.10f, %.10f\n", xx[0] /DEGTORAD, xx[1] / DEGTORAD, xx [2], xx[3] /DEGTORAD); */ + /* equatorial cartesian */ + swi_coortrf2(ndp->xreturn + 6, ndp->xreturn + 18, -oe->seps, oe->ceps); if (iflag & SEFLG_SPEED) - swi_precess_speed(x, tjd, J_TO_J2000); - for (i = 0; i <= 5; i++) - ndp->xreturn[18+i] = x[i]; - swi_cartpol_sp(ndp->xreturn+18, ndp->xreturn+12); - swi_coortrf2(ndp->xreturn+18, ndp->xreturn+6, swed.oec2000.seps, swed.oec2000.ceps); - if (iflag & SEFLG_SPEED) - swi_coortrf2(ndp->xreturn+21, ndp->xreturn+9, swed.oec2000.seps, swed.oec2000.ceps); - swi_cartpol_sp(ndp->xreturn+6, ndp->xreturn); - } else { - /* tropical ecliptic positions */ - /* precession has already been taken into account, but not nutation */ - if (!(iflag & SEFLG_NONUT)) { - swi_nutate(ndp->xreturn+18, iflag, FALSE); + swi_coortrf2(ndp->xreturn + 9, ndp->xreturn + 21, -oe->seps, + oe->ceps); + ndp->teval = tjd; + ndp->xflgs = iflag; + ndp->iephe = iflag & SEFLG_EPHMASK; + if (iflag & SEFLG_SIDEREAL) { + /* apogee is referred to t; + * the ecliptic position must be transformed to t0 */ + /* rigorous algorithm */ + if ((swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) + || (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE)) { + for (i = 0; i <= 5; i++) + x[i] = ndp->xreturn[18 + i]; + /* precess to J2000 */ + swi_precess(x, tjd, J_TO_J2000); + if (iflag & SEFLG_SPEED) + swi_precess_speed(x, tjd, J_TO_J2000); + if (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) + swi_trop_ra2sid_lon(x, ndp->xreturn + 6, ndp->xreturn + 18, + iflag, NULL); + /* project onto solar system equator */ + else if (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE) + swi_trop_ra2sid_lon_sosy(x, ndp->xreturn + 6, + ndp->xreturn + 18, iflag, NULL); + /* to polar */ + swi_cartpol_sp(ndp->xreturn + 6, ndp->xreturn); + swi_cartpol_sp(ndp->xreturn + 18, ndp->xreturn + 12); + } + else { + /* traditional algorithm */ + swi_cartpol_sp(ndp->xreturn + 6, ndp->xreturn); + ndp->xreturn[0] -= swe_get_ayanamsa(ndp->teval) * DEGTORAD; + swi_polcart_sp(ndp->xreturn, ndp->xreturn + 6); + swi_cartpol_sp(ndp->xreturn + 18, ndp->xreturn + 12); + } } - /* equatorial polar */ - swi_cartpol_sp(ndp->xreturn+18, ndp->xreturn+12); - /* ecliptic cartesian */ - swi_coortrf2(ndp->xreturn+18, ndp->xreturn+6, oe->seps, oe->ceps); - if (iflag & SEFLG_SPEED) - swi_coortrf2(ndp->xreturn+21, ndp->xreturn+9, oe->seps, oe->ceps); - if (!(iflag & SEFLG_NONUT)) { - swi_coortrf2(ndp->xreturn+6, ndp->xreturn+6, nut->snut, nut->cnut); - if (iflag & SEFLG_SPEED) - swi_coortrf2(ndp->xreturn+9, ndp->xreturn+9, nut->snut, nut->cnut); + else if (iflag & SEFLG_J2000) { + /* node and apogee are referred to t; + * the ecliptic position must be transformed to J2000 */ + for (i = 0; i <= 5; i++) + x[i] = ndp->xreturn[18 + i]; + /* precess to J2000 */ + swi_precess(x, tjd, J_TO_J2000); + if (iflag & SEFLG_SPEED) + swi_precess_speed(x, tjd, J_TO_J2000); + for (i = 0; i <= 5; i++) + ndp->xreturn[18 + i] = x[i]; + swi_cartpol_sp(ndp->xreturn + 18, ndp->xreturn + 12); + swi_coortrf2(ndp->xreturn + 18, ndp->xreturn + 6, swed.oec2000.seps, + swed.oec2000.ceps); + if (iflag & SEFLG_SPEED) + swi_coortrf2(ndp->xreturn + 21, ndp->xreturn + 9, + swed.oec2000.seps, swed.oec2000.ceps); + swi_cartpol_sp(ndp->xreturn + 6, ndp->xreturn); } - /* ecliptic polar */ - swi_cartpol_sp(ndp->xreturn+6, ndp->xreturn); - } - /********************** + else { + /* tropical ecliptic positions */ + /* precession has already been taken into account, but not nutation */ + if (!(iflag & SEFLG_NONUT)) { + swi_nutate(ndp->xreturn + 18, iflag, FALSE); + } + /* equatorial polar */ + swi_cartpol_sp(ndp->xreturn + 18, ndp->xreturn + 12); + /* ecliptic cartesian */ + swi_coortrf2(ndp->xreturn + 18, ndp->xreturn + 6, oe->seps, oe->ceps); + if (iflag & SEFLG_SPEED) + swi_coortrf2(ndp->xreturn + 21, ndp->xreturn + 9, oe->seps, + oe->ceps); + if (!(iflag & SEFLG_NONUT)) { + swi_coortrf2(ndp->xreturn + 6, ndp->xreturn + 6, nut->snut, + nut->cnut); + if (iflag & SEFLG_SPEED) + swi_coortrf2(ndp->xreturn + 9, ndp->xreturn + 9, nut->snut, + nut->cnut); + } + /* ecliptic polar */ + swi_cartpol_sp(ndp->xreturn + 6, ndp->xreturn); + } + + /********************** * radians to degrees * **********************/ - /*if (!(iflag & SEFLG_RADIANS)) {*/ - for (i = 0; i < 2; i++) { - ndp->xreturn[i] *= RADTODEG; /* ecliptic */ - ndp->xreturn[i+3] *= RADTODEG; - ndp->xreturn[i+12] *= RADTODEG; /* equator */ - ndp->xreturn[i+15] *= RADTODEG; - } - ndp->xreturn[0] = swe_degnorm(ndp->xreturn[0]); - ndp->xreturn[12] = swe_degnorm(ndp->xreturn[12]); - /*}*/ - return OK; + /*if (!(iflag & SEFLG_RADIANS)) { */ + for (i = 0; i < 2; i++) { + ndp->xreturn[i] *= RADTODEG; /* ecliptic */ + ndp->xreturn[i + 3] *= RADTODEG; + ndp->xreturn[i + 12] *= RADTODEG; /* equator */ + ndp->xreturn[i + 15] *= RADTODEG; + } + ndp->xreturn[0] = swe_degnorm(ndp->xreturn[0]); + ndp->xreturn[12] = swe_degnorm(ndp->xreturn[12]); + /*} */ + return OK; } /* transforms the position of the moon in a way we can use it @@ -4855,349 +5215,463 @@ static int intp_apsides(double tjd, int ipl, int32 iflag, char *serr) * xx array equatorial cartesian position and speed * serr error string */ -int swi_plan_for_osc_elem(int32 iflag, double tjd, double *xx) +int +swi_plan_for_osc_elem(int32 iflag, double tjd, double *xx) { - int i; - double x[6]; - struct nut nuttmp; - struct nut *nutp = &nuttmp; /* dummy assign, to silence gcc warning */ - struct epsilon *oe = &swed.oec; - struct epsilon oectmp; - /* ICRS to J2000 */ - if (!(iflag & SEFLG_ICRS) && swed.jpldenum >= 403) { - swi_bias(xx, iflag, FALSE); - }/**/ + int i; + double x[6]; + struct nut nuttmp; + struct nut *nutp = &nuttmp; /* dummy assign, to silence gcc warning */ + struct epsilon *oe = &swed.oec; + struct epsilon oectmp; + /* ICRS to J2000 */ + if (!(iflag & SEFLG_ICRS) && swed.jpldenum >= 403) { + swi_bias(xx, iflag, FALSE); + } + /**/ + /************************************************ * precession, equator 2000 -> equator of date * * attention: speed vector has to be rotated, * * but daily precession 0.137" may not be added!*/ #ifdef SID_TNODE_FROM_ECL_T0 - struct sid_data *sip = &swed.sidd; - /* For sidereal calculation we need node refered* - * to ecliptic of t0 of ayanamsa * - ************************************************/ - if (iflag & SEFLG_SIDEREAL) { - tjd = sip->t0; - swi_precess(xx, tjd, J2000_TO_J); - swi_precess(xx+3, tjd, J2000_TO_J); - calc_epsilon(tjd, &oectmp); - oe = &oectmp; - } else if (!(iflag & SEFLG_J2000)) { -#endif - swi_precess(xx, tjd, J2000_TO_J); - swi_precess(xx+3, tjd, J2000_TO_J); - /* epsilon */ - if (tjd == swed.oec.teps) - oe = &swed.oec; - else if (tjd == J2000) - oe = &swed.oec2000; - else { - calc_epsilon(tjd, &oectmp); - oe = &oectmp; + struct sid_data *sip = &swed.sidd; + /* For sidereal calculation we need node refered* + * to ecliptic of t0 of ayanamsa * + ************************************************/ + if (iflag & SEFLG_SIDEREAL) { + tjd = sip->t0; + swi_precess(xx, tjd, J2000_TO_J); + swi_precess(xx + 3, tjd, J2000_TO_J); + calc_epsilon(tjd, &oectmp); + oe = &oectmp; } -#ifdef SID_TNODE_FROM_ECL_T0 - } else /* if SEFLG_J2000 */ - oe = &swed.oec2000; + else if (!(iflag & SEFLG_J2000)) { #endif + swi_precess(xx, tjd, J2000_TO_J); + swi_precess(xx + 3, tjd, J2000_TO_J); + /* epsilon */ + if (tjd == swed.oec.teps) + oe = &swed.oec; + else if (tjd == J2000) + oe = &swed.oec2000; + else { + calc_epsilon(tjd, &oectmp); + oe = &oectmp; + } +#ifdef SID_TNODE_FROM_ECL_T0 + } + else /* if SEFLG_J2000 */ + oe = &swed.oec2000; +#endif + /************************************************ * nutation * * again: speed vector must be rotated, but not * * added 'speed' of nutation * ************************************************/ - if (!(iflag & SEFLG_NONUT)) { - if (tjd == swed.nut.tnut) - nutp = &swed.nut; - else if (tjd == J2000) - nutp = &swed.nut2000; - else if (tjd == swed.nutv.tnut) - nutp = &swed.nutv; - else { - nutp = &nuttmp; - swi_nutation(tjd, nutp->nutlo); - nutp->tnut = tjd; - nutp->snut = sin(nutp->nutlo[1]); - nutp->cnut = cos(nutp->nutlo[1]); - nut_matrix(nutp, oe); + if (!(iflag & SEFLG_NONUT)) { + if (tjd == swed.nut.tnut) + nutp = &swed.nut; + else if (tjd == J2000) + nutp = &swed.nut2000; + else if (tjd == swed.nutv.tnut) + nutp = &swed.nutv; + else { + nutp = &nuttmp; + swi_nutation(tjd, nutp->nutlo); + nutp->tnut = tjd; + nutp->snut = sin(nutp->nutlo[1]); + nutp->cnut = cos(nutp->nutlo[1]); + nut_matrix(nutp, oe); + } + for (i = 0; i <= 2; i++) + x[i] = + xx[0] * nutp->matrix[0][i] + xx[1] * nutp->matrix[1][i] + + xx[2] * nutp->matrix[2][i]; + /* speed: + * rotation only */ + for (i = 0; i <= 2; i++) + x[i + 3] = + xx[3] * nutp->matrix[0][i] + xx[4] * nutp->matrix[1][i] + + xx[5] * nutp->matrix[2][i]; + for (i = 0; i <= 5; i++) + xx[i] = x[i]; } - for (i = 0; i <= 2; i++) - x[i] = xx[0] * nutp->matrix[0][i] + - xx[1] * nutp->matrix[1][i] + - xx[2] * nutp->matrix[2][i]; - /* speed: - * rotation only */ - for (i = 0; i <= 2; i++) - x[i+3] = xx[3] * nutp->matrix[0][i] + - xx[4] * nutp->matrix[1][i] + - xx[5] * nutp->matrix[2][i]; - for (i = 0; i <= 5; i++) - xx[i] = x[i]; - } + /************************************************ * transformation to ecliptic * ************************************************/ - swi_coortrf2(xx, xx, oe->seps, oe->ceps); - swi_coortrf2(xx+3, xx+3, oe->seps, oe->ceps); + swi_coortrf2(xx, xx, oe->seps, oe->ceps); + swi_coortrf2(xx + 3, xx + 3, oe->seps, oe->ceps); #ifdef SID_TNODE_FROM_ECL_T0 - if (iflag & SEFLG_SIDEREAL) { - /* subtract ayan_t0 */ - swi_cartpol_sp(xx, xx); - xx[0] -= sip->ayan_t0; - swi_polcart_sp(xx, xx); - } else + if (iflag & SEFLG_SIDEREAL) { + /* subtract ayan_t0 */ + swi_cartpol_sp(xx, xx); + xx[0] -= sip->ayan_t0; + swi_polcart_sp(xx, xx); + } + else #endif - if (!(iflag & SEFLG_NONUT)) { - swi_coortrf2(xx, xx, nutp->snut, nutp->cnut); - swi_coortrf2(xx+3, xx+3, nutp->snut, nutp->cnut); - } - return(OK); + if (!(iflag & SEFLG_NONUT)) { + swi_coortrf2(xx, xx, nutp->snut, nutp->cnut); + swi_coortrf2(xx + 3, xx + 3, nutp->snut, nutp->cnut); + } + return (OK); } static const struct meff_ele FAR eff_arr[] = { - /* - * r , m_eff for photon passing the sun at min distance r (fraction of Rsun) - * the values where computed with sun_model.c, which is a classic - * treatment of a photon passing a gravity field, multiplied by 2. - * The sun mass distribution m(r) is from Michael Stix, The Sun, p. 47. - */ - {1.000, 1.000000}, - {0.990, 0.999979}, - {0.980, 0.999940}, - {0.970, 0.999881}, - {0.960, 0.999811}, - {0.950, 0.999724}, - {0.940, 0.999622}, - {0.930, 0.999497}, - {0.920, 0.999354}, - {0.910, 0.999192}, - {0.900, 0.999000}, - {0.890, 0.998786}, - {0.880, 0.998535}, - {0.870, 0.998242}, - {0.860, 0.997919}, - {0.850, 0.997571}, - {0.840, 0.997198}, - {0.830, 0.996792}, - {0.820, 0.996316}, - {0.810, 0.995791}, - {0.800, 0.995226}, - {0.790, 0.994625}, - {0.780, 0.993991}, - {0.770, 0.993326}, - {0.760, 0.992598}, - {0.750, 0.991770}, - {0.740, 0.990873}, - {0.730, 0.989919}, - {0.720, 0.988912}, - {0.710, 0.987856}, - {0.700, 0.986755}, - {0.690, 0.985610}, - {0.680, 0.984398}, - {0.670, 0.982986}, - {0.660, 0.981437}, - {0.650, 0.979779}, - {0.640, 0.978024}, - {0.630, 0.976182}, - {0.620, 0.974256}, - {0.610, 0.972253}, - {0.600, 0.970174}, - {0.590, 0.968024}, - {0.580, 0.965594}, - {0.570, 0.962797}, - {0.560, 0.959758}, - {0.550, 0.956515}, - {0.540, 0.953088}, - {0.530, 0.949495}, - {0.520, 0.945741}, - {0.510, 0.941838}, - {0.500, 0.937790}, - {0.490, 0.933563}, - {0.480, 0.928668}, - {0.470, 0.923288}, - {0.460, 0.917527}, - {0.450, 0.911432}, - {0.440, 0.905035}, - {0.430, 0.898353}, - {0.420, 0.891022}, - {0.410, 0.882940}, - {0.400, 0.874312}, - {0.390, 0.865206}, - {0.380, 0.855423}, - {0.370, 0.844619}, - {0.360, 0.833074}, - {0.350, 0.820876}, - {0.340, 0.808031}, - {0.330, 0.793962}, - {0.320, 0.778931}, - {0.310, 0.763021}, - {0.300, 0.745815}, - {0.290, 0.727557}, - {0.280, 0.708234}, - {0.270, 0.687583}, - {0.260, 0.665741}, - {0.250, 0.642597}, - {0.240, 0.618252}, - {0.230, 0.592586}, - {0.220, 0.565747}, - {0.210, 0.537697}, - {0.200, 0.508554}, - {0.190, 0.478420}, - {0.180, 0.447322}, - {0.170, 0.415454}, - {0.160, 0.382892}, - {0.150, 0.349955}, - {0.140, 0.316691}, - {0.130, 0.283565}, - {0.120, 0.250431}, - {0.110, 0.218327}, - {0.100, 0.186794}, - {0.090, 0.156287}, - {0.080, 0.128421}, - {0.070, 0.102237}, - {0.060, 0.077393}, - {0.050, 0.054833}, - {0.040, 0.036361}, - {0.030, 0.020953}, - {0.020, 0.009645}, - {0.010, 0.002767}, - {0.000, 0.000000} + /* + * r , m_eff for photon passing the sun at min distance r (fraction of Rsun) + * the values where computed with sun_model.c, which is a classic + * treatment of a photon passing a gravity field, multiplied by 2. + * The sun mass distribution m(r) is from Michael Stix, The Sun, p. 47. + */ + { + 1.000, 1.000000}, + { + 0.990, 0.999979}, + { + 0.980, 0.999940}, + { + 0.970, 0.999881}, + { + 0.960, 0.999811}, + { + 0.950, 0.999724}, + { + 0.940, 0.999622}, + { + 0.930, 0.999497}, + { + 0.920, 0.999354}, + { + 0.910, 0.999192}, + { + 0.900, 0.999000}, + { + 0.890, 0.998786}, + { + 0.880, 0.998535}, + { + 0.870, 0.998242}, + { + 0.860, 0.997919}, + { + 0.850, 0.997571}, + { + 0.840, 0.997198}, + { + 0.830, 0.996792}, + { + 0.820, 0.996316}, + { + 0.810, 0.995791}, + { + 0.800, 0.995226}, + { + 0.790, 0.994625}, + { + 0.780, 0.993991}, + { + 0.770, 0.993326}, + { + 0.760, 0.992598}, + { + 0.750, 0.991770}, + { + 0.740, 0.990873}, + { + 0.730, 0.989919}, + { + 0.720, 0.988912}, + { + 0.710, 0.987856}, + { + 0.700, 0.986755}, + { + 0.690, 0.985610}, + { + 0.680, 0.984398}, + { + 0.670, 0.982986}, + { + 0.660, 0.981437}, + { + 0.650, 0.979779}, + { + 0.640, 0.978024}, + { + 0.630, 0.976182}, + { + 0.620, 0.974256}, + { + 0.610, 0.972253}, + { + 0.600, 0.970174}, + { + 0.590, 0.968024}, + { + 0.580, 0.965594}, + { + 0.570, 0.962797}, + { + 0.560, 0.959758}, + { + 0.550, 0.956515}, + { + 0.540, 0.953088}, + { + 0.530, 0.949495}, + { + 0.520, 0.945741}, + { + 0.510, 0.941838}, + { + 0.500, 0.937790}, + { + 0.490, 0.933563}, + { + 0.480, 0.928668}, + { + 0.470, 0.923288}, + { + 0.460, 0.917527}, + { + 0.450, 0.911432}, + { + 0.440, 0.905035}, + { + 0.430, 0.898353}, + { + 0.420, 0.891022}, + { + 0.410, 0.882940}, + { + 0.400, 0.874312}, + { + 0.390, 0.865206}, + { + 0.380, 0.855423}, + { + 0.370, 0.844619}, + { + 0.360, 0.833074}, + { + 0.350, 0.820876}, + { + 0.340, 0.808031}, + { + 0.330, 0.793962}, + { + 0.320, 0.778931}, + { + 0.310, 0.763021}, + { + 0.300, 0.745815}, + { + 0.290, 0.727557}, + { + 0.280, 0.708234}, + { + 0.270, 0.687583}, + { + 0.260, 0.665741}, + { + 0.250, 0.642597}, + { + 0.240, 0.618252}, + { + 0.230, 0.592586}, + { + 0.220, 0.565747}, + { + 0.210, 0.537697}, + { + 0.200, 0.508554}, + { + 0.190, 0.478420}, + { + 0.180, 0.447322}, + { + 0.170, 0.415454}, + { + 0.160, 0.382892}, + { + 0.150, 0.349955}, + { + 0.140, 0.316691}, + { + 0.130, 0.283565}, + { + 0.120, 0.250431}, + { + 0.110, 0.218327}, + { + 0.100, 0.186794}, + { + 0.090, 0.156287}, + { + 0.080, 0.128421}, + { + 0.070, 0.102237}, + { + 0.060, 0.077393}, + { + 0.050, 0.054833}, + { + 0.040, 0.036361}, + { + 0.030, 0.020953}, + { + 0.020, 0.009645}, + { + 0.010, 0.002767}, + { + 0.000, 0.000000} }; -static double meff(double r) + +static double +meff(double r) { - double f, m; - int i; - if (r <= 0) - return 0.0; - else if (r >= 1) - return 1.0; - for (i = 0; eff_arr[i].r > r; i++) - ; /* empty body */ - f = (r - eff_arr[i-1].r) / (eff_arr[i].r - eff_arr[i-1].r); - m = eff_arr[i-1].m + f * (eff_arr[i].m - eff_arr[i-1].m); - return m; + double f, m; + int i; + if (r <= 0) + return 0.0; + else if (r >= 1) + return 1.0; + for (i = 0; eff_arr[i].r > r; i++); /* empty body */ + f = (r - eff_arr[i - 1].r) / (eff_arr[i].r - eff_arr[i - 1].r); + m = eff_arr[i - 1].m + f * (eff_arr[i].m - eff_arr[i - 1].m); + return m; } -static void denormalize_positions(double *x0, double *x1, double *x2) +static void +denormalize_positions(double *x0, double *x1, double *x2) { - int i; - /* x*[0] = ecliptic longitude, x*[12] = rectascension */ - for (i = 0; i <= 12; i += 12) { - if (x1[i] - x0[i] < -180) - x0[i] -= 360; - if (x1[i] - x0[i] > 180) - x0[i] += 360; - if (x1[i] - x2[i] < -180) - x2[i] -= 360; - if (x1[i] - x2[i] > 180) - x2[i] += 360; - } -} - -static void calc_speed(double *x0, double *x1, double *x2, double dt) -{ - int i, j, k; - double a, b; - for (j = 0; j <= 18; j += 6) { - for (i = 0; i < 3; i++) { - k = j + i; - b = (x2[k] - x0[k]) / 2; - a = (x2[k] + x0[k]) / 2 - x1[k]; - x1[k+3] = (2 * a + b) / dt; + int i; + /* x*[0] = ecliptic longitude, x*[12] = rectascension */ + for (i = 0; i <= 12; i += 12) { + if (x1[i] - x0[i] < -180) + x0[i] -= 360; + if (x1[i] - x0[i] > 180) + x0[i] += 360; + if (x1[i] - x2[i] < -180) + x2[i] -= 360; + if (x1[i] - x2[i] > 180) + x2[i] += 360; } - } } -void swi_check_ecliptic(double tjd) +static void +calc_speed(double *x0, double *x1, double *x2, double dt) { - if (swed.oec2000.teps != J2000) { - calc_epsilon(J2000, &swed.oec2000); - } - if (tjd == J2000) { - swed.oec.teps = swed.oec2000.teps; - swed.oec.eps = swed.oec2000.eps; - swed.oec.seps = swed.oec2000.seps; - swed.oec.ceps = swed.oec2000.ceps; - return; - } - if (swed.oec.teps != tjd || tjd == 0) { - calc_epsilon(tjd, &swed.oec); - } + int i, j, k; + double a, b; + for (j = 0; j <= 18; j += 6) { + for (i = 0; i < 3; i++) { + k = j + i; + b = (x2[k] - x0[k]) / 2; + a = (x2[k] + x0[k]) / 2 - x1[k]; + x1[k + 3] = (2 * a + b) / dt; + } + } +} + +void +swi_check_ecliptic(double tjd) +{ + if (swed.oec2000.teps != J2000) { + calc_epsilon(J2000, &swed.oec2000); + } + if (tjd == J2000) { + swed.oec.teps = swed.oec2000.teps; + swed.oec.eps = swed.oec2000.eps; + swed.oec.seps = swed.oec2000.seps; + swed.oec.ceps = swed.oec2000.ceps; + return; + } + if (swed.oec.teps != tjd || tjd == 0) { + calc_epsilon(tjd, &swed.oec); + } } /* computes nutation, if it is wanted and has not yet been computed. - * if speed flag has been turned on since last computation, + * if speed flag has been turned on since last computation, * nutation is recomputed */ -void swi_check_nutation(double tjd, int32 iflag) +void +swi_check_nutation(double tjd, int32 iflag) { - int32 speedf1, speedf2; - static int32 nutflag = 0; - double t; - speedf1 = nutflag & SEFLG_SPEED; - speedf2 = iflag & SEFLG_SPEED; - if (!(iflag & SEFLG_NONUT) - && (tjd != swed.nut.tnut || tjd == 0 - || (!speedf1 && speedf2))) { - swi_nutation(tjd, swed.nut.nutlo); - swed.nut.tnut = tjd; - swed.nut.snut = sin(swed.nut.nutlo[1]); - swed.nut.cnut = cos(swed.nut.nutlo[1]); - nutflag = iflag; - nut_matrix(&swed.nut, &swed.oec); - if (iflag & SEFLG_SPEED) { - /* once more for 'speed' of nutation, which is needed for - * planetary speeds */ - t = tjd - NUT_SPEED_INTV; - swi_nutation(t, swed.nutv.nutlo); - swed.nutv.tnut = t; - swed.nutv.snut = sin(swed.nutv.nutlo[1]); - swed.nutv.cnut = cos(swed.nutv.nutlo[1]); - nut_matrix(&swed.nutv, &swed.oec); - } - } -} + int32 speedf1, speedf2; + static int32 nutflag = 0; + double t; + speedf1 = nutflag & SEFLG_SPEED; + speedf2 = iflag & SEFLG_SPEED; + if (!(iflag & SEFLG_NONUT) + && (tjd != swed.nut.tnut || tjd == 0 || (!speedf1 && speedf2))) { + swi_nutation(tjd, swed.nut.nutlo); + swed.nut.tnut = tjd; + swed.nut.snut = sin(swed.nut.nutlo[1]); + swed.nut.cnut = cos(swed.nut.nutlo[1]); + nutflag = iflag; + nut_matrix(&swed.nut, &swed.oec); + if (iflag & SEFLG_SPEED) { + /* once more for 'speed' of nutation, which is needed for + * planetary speeds */ + t = tjd - NUT_SPEED_INTV; + swi_nutation(t, swed.nutv.nutlo); + swed.nutv.tnut = t; + swed.nutv.snut = sin(swed.nutv.nutlo[1]); + swed.nutv.cnut = cos(swed.nutv.nutlo[1]); + nut_matrix(&swed.nutv, &swed.oec); + } + } +} -static int32 plaus_iflag(int32 iflag) +static int32 +plaus_iflag(int32 iflag) { - int32 epheflag = 0; - /* if topocentric bit, turn helio- and barycentric bits off */ - if (iflag & SEFLG_TOPOCTR) - iflag = iflag & ~(SEFLG_HELCTR | SEFLG_BARYCTR); - /* if heliocentric bit, turn aberration and deflection off */ - if (iflag & SEFLG_HELCTR) - iflag |= SEFLG_NOABERR | SEFLG_NOGDEFL; /*iflag |= SEFLG_TRUEPOS;*/ - /* same, if barycentric bit */ - if (iflag & SEFLG_BARYCTR) - iflag |= SEFLG_NOABERR | SEFLG_NOGDEFL; /*iflag |= SEFLG_TRUEPOS;*/ - /* if no_precession bit is set, set also no_nutation bit */ - if (iflag & SEFLG_J2000) - iflag |= SEFLG_NONUT; - /* if sidereal bit is set, set also no_nutation bit */ - if (iflag & SEFLG_SIDEREAL) - iflag |= SEFLG_NONUT; - /* if truepos is set, turn off grav. defl. and aberration */ - if (iflag & SEFLG_TRUEPOS) - iflag |= (SEFLG_NOGDEFL | SEFLG_NOABERR); - if (iflag & SEFLG_MOSEPH) - epheflag = SEFLG_MOSEPH; - if (iflag & SEFLG_SWIEPH) - epheflag = SEFLG_SWIEPH; - if (iflag & SEFLG_JPLEPH) - epheflag = SEFLG_JPLEPH; - if (epheflag == 0) - epheflag = SEFLG_DEFAULTEPH; + int32 epheflag = 0; + /* if topocentric bit, turn helio- and barycentric bits off */ + if (iflag & SEFLG_TOPOCTR) + iflag = iflag & ~(SEFLG_HELCTR | SEFLG_BARYCTR); + /* if heliocentric bit, turn aberration and deflection off */ + if (iflag & SEFLG_HELCTR) + iflag |= SEFLG_NOABERR | SEFLG_NOGDEFL; /*iflag |= SEFLG_TRUEPOS; */ + /* same, if barycentric bit */ + if (iflag & SEFLG_BARYCTR) + iflag |= SEFLG_NOABERR | SEFLG_NOGDEFL; /*iflag |= SEFLG_TRUEPOS; */ + /* if no_precession bit is set, set also no_nutation bit */ + if (iflag & SEFLG_J2000) + iflag |= SEFLG_NONUT; + /* if sidereal bit is set, set also no_nutation bit */ + if (iflag & SEFLG_SIDEREAL) + iflag |= SEFLG_NONUT; + /* if truepos is set, turn off grav. defl. and aberration */ + if (iflag & SEFLG_TRUEPOS) + iflag |= (SEFLG_NOGDEFL | SEFLG_NOABERR); + if (iflag & SEFLG_MOSEPH) + epheflag = SEFLG_MOSEPH; + if (iflag & SEFLG_SWIEPH) + epheflag = SEFLG_SWIEPH; + if (iflag & SEFLG_JPLEPH) + epheflag = SEFLG_JPLEPH; + if (epheflag == 0) + epheflag = SEFLG_DEFAULTEPH; #ifdef NO_JPL - if (epheflag == SEFLG_JPLEPH) - epheflag = SEFLG_SWIEPH; + if (epheflag == SEFLG_JPLEPH) + epheflag = SEFLG_SWIEPH; #endif - /* delete wrong ephe bits from flag */ - iflag = (iflag & ~SEFLG_EPHMASK) | epheflag; + /* delete wrong ephe bits from flag */ + iflag = (iflag & ~SEFLG_EPHMASK) | epheflag; - return iflag; + return iflag; } /********************************************************** * get fixstar positions * parameters: - * star name of star or line number in star file + * star name of star or line number in star file * (start from 1, don't count comment). * If no error occurs, the name of the star is returned * in the format trad_name, nomeclat_name @@ -5207,79 +5681,84 @@ static int32 plaus_iflag(int32 iflag) * x pointer for returning the ecliptic coordinates * serr error return string **********************************************************/ -int32 FAR PASCAL_CONV swe_fixstar(char *star, double tjd, int32 iflag, - double *xx, char *serr) +int32 FAR PASCAL_CONV +swe_fixstar(char *star, double tjd, int32 iflag, double *xx, char *serr) { - int i; - int star_nr = 0; - AS_BOOL isnomclat = FALSE; - size_t cmplen; - double x[6], xxsv[6], xobs[6], *xpo = NULL; - char *cpos[20]; - char sstar[SE_MAX_STNAME + 1]; - char fstar[SE_MAX_STNAME + 1]; - static char slast_stardata[AS_MAXCH]; - static char slast_starname[AS_MAXCH]; - char s[AS_MAXCH + 20], *sp, *sp2; /* 20 byte for SE_STARFILE */ - double ra_s, ra_pm, de_pm, ra, de, t, cosra, cosde, sinra, sinde; - double ra_h, ra_m, de_d, de_m, de_s; - char *sde_d; - double epoch, radv, parall, u; - int line = 0; - int fline = 0; - struct plan_data *pedp = &swed.pldat[SEI_EARTH]; - struct plan_data *psdp = &swed.pldat[SEI_SUNBARY]; - struct epsilon *oe = &swed.oec2000; - int retc; - int32 epheflag, iflgsave; - iflag |= SEFLG_SPEED; /* we need this in order to work correctly */ - iflgsave = iflag; - if (serr != NULL) - *serr = '\0'; -#ifdef TRACE - swi_open_trace(serr); - trace_swe_fixstar(1, star, tjd, iflag, xx, serr); -#endif /* TRACE */ - iflag = plaus_iflag(iflag); - if (iflag & SEFLG_SIDEREAL && !swed.ayana_is_set) - swe_set_sid_mode(SE_SIDM_FAGAN_BRADLEY, 0, 0); - epheflag = iflag & SEFLG_EPHMASK; - /****************************************** - * obliquity of ecliptic 2000 and of date * - ******************************************/ - swi_check_ecliptic(tjd); - /****************************************** - * nutation * - ******************************************/ - swi_check_nutation(tjd, iflag); - strncpy(sstar, star, SE_MAX_STNAME); - sstar[SE_MAX_STNAME] = '\0'; - if (*sstar == ',') { - isnomclat = TRUE; - } else if (isdigit((int) *sstar)) { - star_nr = atoi(sstar); - } else { - /* traditional name of star to lower case */ - for (sp = sstar; *sp != '\0'; sp++) - *sp = tolower((int) *sp); - if ((sp = strchr(sstar, ',')) != NULL) - *sp = '\0'; - } - /*swi_right_trim(sstar);*/ - while ((sp = strchr(sstar, ' ')) != NULL) - swi_strcpy(sp, sp+1); - cmplen = strlen(sstar); - if (cmplen == 0) { + int i; + int star_nr = 0; + AS_BOOL isnomclat = FALSE; + size_t cmplen; + double x[6], xxsv[6], xobs[6], *xpo = NULL; + char *cpos[20]; + char sstar[SE_MAX_STNAME + 1]; + char fstar[SE_MAX_STNAME + 1]; + static char slast_stardata[AS_MAXCH]; + static char slast_starname[AS_MAXCH]; + char s[AS_MAXCH + 20], *sp, *sp2; /* 20 byte for SE_STARFILE */ + double ra_s, ra_pm, de_pm, ra, de, t, cosra, cosde, sinra, sinde; + double ra_h, ra_m, de_d, de_m, de_s; + char *sde_d; + double epoch, radv, parall, u; + int line = 0; + int fline = 0; + struct plan_data *pedp = &swed.pldat[SEI_EARTH]; + struct plan_data *psdp = &swed.pldat[SEI_SUNBARY]; + struct epsilon *oe = &swed.oec2000; + int retc; + int32 epheflag, iflgsave; + iflag |= SEFLG_SPEED; /* we need this in order to work correctly */ + iflgsave = iflag; if (serr != NULL) - sprintf(serr, "swe_fixstar(): star name empty"); - retc = ERR; - goto return_err; - } - /* star elements from last call: */ - if (*slast_stardata != '\0' && strcmp(slast_starname, sstar) == 0) { - strcpy(s, slast_stardata); - goto found; - } + *serr = '\0'; +#ifdef TRACE + swi_open_trace(serr); + trace_swe_fixstar(1, star, tjd, iflag, xx, serr); +#endif /* TRACE */ + iflag = plaus_iflag(iflag); + if (iflag & SEFLG_SIDEREAL && !swed.ayana_is_set) + swe_set_sid_mode(SE_SIDM_FAGAN_BRADLEY, 0, 0); + epheflag = iflag & SEFLG_EPHMASK; + + /****************************************** + * obliquity of ecliptic 2000 and of date * + ******************************************/ + swi_check_ecliptic(tjd); + + /****************************************** + * nutation * + ******************************************/ + swi_check_nutation(tjd, iflag); + strncpy(sstar, star, SE_MAX_STNAME); + sstar[SE_MAX_STNAME] = '\0'; + if (*sstar == ',') { + isnomclat = TRUE; + } + else if (isdigit((int)*sstar)) { + star_nr = atoi(sstar); + } + else { + /* traditional name of star to lower case */ + for (sp = sstar; *sp != '\0'; sp++) + *sp = tolower((int)*sp); + if ((sp = strchr(sstar, ',')) != NULL) + *sp = '\0'; + } + /*swi_right_trim(sstar); */ + while ((sp = strchr(sstar, ' ')) != NULL) + swi_strcpy(sp, sp + 1); + cmplen = strlen(sstar); + if (cmplen == 0) { + if (serr != NULL) + sprintf(serr, "swe_fixstar(): star name empty"); + retc = ERR; + goto return_err; + } + /* star elements from last call: */ + if (*slast_stardata != '\0' && strcmp(slast_starname, sstar) == 0) { + strcpy(s, slast_stardata); + goto found; + } + /****************************************************** * Star file * close to the beginning, a few stars selected by Astrodienst. @@ -5287,361 +5766,397 @@ int32 FAR PASCAL_CONV swe_fixstar(char *star, double tjd, int32 iflag, * All other stars can be accessed by name. * Comment lines start with # and are ignored. ******************************************************/ - if (swed.fixfp == NULL) { - if ((swed.fixfp = swi_fopen(SEI_FILE_FIXSTAR, SE_STARFILE, swed.ephepath, serr)) == NULL) { - swed.is_old_starfile = TRUE; - if ((swed.fixfp = swi_fopen(SEI_FILE_FIXSTAR, SE_STARFILE_OLD, swed.ephepath, NULL)) == NULL) { - retc = ERR; - goto return_err; - } + if (swed.fixfp == NULL) { + if ((swed.fixfp = + swi_fopen(SEI_FILE_FIXSTAR, SE_STARFILE, swed.ephepath, + serr)) == NULL) { + swed.is_old_starfile = TRUE; + if ((swed.fixfp = + swi_fopen(SEI_FILE_FIXSTAR, SE_STARFILE_OLD, swed.ephepath, + NULL)) == NULL) { + retc = ERR; + goto return_err; + } + } } - } - rewind(swed.fixfp); - while (fgets(s, AS_MAXCH, swed.fixfp) != NULL) { - fline++; - if (*s == '#') continue; - line++; - if (star_nr == line) - goto found; - else if (star_nr > 0) - continue; - if ((sp = strchr(s, ',')) == NULL) { - if (serr != NULL) - sprintf(serr, "star file %s damaged at line %d", SE_STARFILE, fline); - retc = ERR; - goto return_err; - } - if (isnomclat) { - if (strncmp(sp, sstar, cmplen) == 0) - goto found; - else - continue; + rewind(swed.fixfp); + while (fgets(s, AS_MAXCH, swed.fixfp) != NULL) { + fline++; + if (*s == '#') + continue; + line++; + if (star_nr == line) + goto found; + else if (star_nr > 0) + continue; + if ((sp = strchr(s, ',')) == NULL) { + if (serr != NULL) + sprintf(serr, "star file %s damaged at line %d", SE_STARFILE, + fline); + retc = ERR; + goto return_err; + } + if (isnomclat) { + if (strncmp(sp, sstar, cmplen) == 0) + goto found; + else + continue; + } + *sp = '\0'; /* cut off first field */ + strncpy(fstar, s, SE_MAX_STNAME); + *sp = ','; + fstar[SE_MAX_STNAME] = '\0'; /* force termination */ + /*swi_right_trim(fstar); */ + while ((sp = strchr(fstar, ' ')) != NULL) + swi_strcpy(sp, sp + 1); + i = strlen(fstar); + if (i < (int)cmplen) + continue; + for (sp2 = fstar; *sp2 != '\0'; sp2++) { + *sp2 = tolower((int)*sp2); + } + if (strncmp(fstar, sstar, cmplen) == 0) + goto found; } - *sp = '\0'; /* cut off first field */ - strncpy(fstar, s, SE_MAX_STNAME); - *sp = ','; - fstar[SE_MAX_STNAME] = '\0'; /* force termination */ - /*swi_right_trim(fstar);*/ - while ((sp = strchr(fstar, ' ')) != NULL) - swi_strcpy(sp, sp+1); - i = strlen(fstar); - if (i < (int) cmplen) - continue; - for (sp2 = fstar; *sp2 != '\0'; sp2++) { - *sp2 = tolower((int) *sp2); - } - if (strncmp(fstar, sstar, cmplen) == 0) - goto found; - } - if (serr != NULL && strlen(star) < AS_MAXCH - 20) - sprintf(serr, "star %s not found", star); - retc = ERR; - goto return_err; - found: - strcpy(slast_stardata, s); - strcpy(slast_starname, sstar); - i = swi_cutstr(s, ",", cpos, 20); - swi_right_trim(cpos[0]); - swi_right_trim(cpos[1]); - if (i < 13) { - if (serr != NULL) - sprintf(serr, "data of star '%s,%s' incomplete", cpos[0], cpos[1]); + if (serr != NULL && strlen(star) < AS_MAXCH - 20) + sprintf(serr, "star %s not found", star); retc = ERR; goto return_err; - } - epoch = atof(cpos[2]); - ra_h = atof(cpos[3]); - ra_m = atof(cpos[4]); - ra_s = atof(cpos[5]); - de_d = atof(cpos[6]); - sde_d = cpos[6]; - de_m = atof(cpos[7]); - de_s = atof(cpos[8]); - ra_pm = atof(cpos[9]); - de_pm = atof(cpos[10]); - radv = atof(cpos[11]); - parall = atof(cpos[12]); - /* return trad. name, nomeclature name */ - if (strlen(cpos[0]) > SE_MAX_STNAME) - cpos[0][SE_MAX_STNAME] = '\0'; - if (strlen(cpos[1]) > SE_MAX_STNAME-1) - cpos[1][SE_MAX_STNAME-1] = '\0'; - sprintf(star, "%s,%s", cpos[0], cpos[1]); +found: + strcpy(slast_stardata, s); + strcpy(slast_starname, sstar); + i = swi_cutstr(s, ",", cpos, 20); + swi_right_trim(cpos[0]); + swi_right_trim(cpos[1]); + if (i < 13) { + if (serr != NULL) + sprintf(serr, "data of star '%s,%s' incomplete", cpos[0], + cpos[1]); + retc = ERR; + goto return_err; + } + epoch = atof(cpos[2]); + ra_h = atof(cpos[3]); + ra_m = atof(cpos[4]); + ra_s = atof(cpos[5]); + de_d = atof(cpos[6]); + sde_d = cpos[6]; + de_m = atof(cpos[7]); + de_s = atof(cpos[8]); + ra_pm = atof(cpos[9]); + de_pm = atof(cpos[10]); + radv = atof(cpos[11]); + parall = atof(cpos[12]); + /* return trad. name, nomeclature name */ + if (strlen(cpos[0]) > SE_MAX_STNAME) + cpos[0][SE_MAX_STNAME] = '\0'; + if (strlen(cpos[1]) > SE_MAX_STNAME - 1) + cpos[1][SE_MAX_STNAME - 1] = '\0'; + sprintf(star, "%s,%s", cpos[0], cpos[1]); + /**************************************** * position and speed (equinox) ****************************************/ - /* ra and de in degrees */ - ra = (ra_s / 3600.0 + ra_m / 60.0 + ra_h) * 15.0; - if (strchr(sde_d, '-') == NULL) - de = de_s / 3600.0 + de_m / 60.0 + de_d; - else - de = -de_s / 3600.0 - de_m / 60.0 + de_d; - /* speed in ra and de, degrees per century */ - if (swed.is_old_starfile == TRUE) { - ra_pm = ra_pm * 15 / 3600.0; - de_pm = de_pm / 3600.0; - } else { - ra_pm = ra_pm / 10.0 / 3600.0; - de_pm = de_pm / 10.0 / 3600.0; - parall /= 1000.0; - } - /* parallax, degrees */ - if (parall > 1) - parall = (1 / parall / 3600.0); - else - parall /= 3600; - /* radial velocity in AU per century */ - radv *= KM_S_TO_AU_CTY; - /*printf("ra=%.17f,de=%.17f,ma=%.17f,md=%.17f,pa=%.17f,rv=%.17f\n",ra,de,ra_pm,de_pm,parall,radv);*/ - /* radians */ - ra *= DEGTORAD; - de *= DEGTORAD; - ra_pm *= DEGTORAD; - de_pm *= DEGTORAD; - ra_pm /= cos(de); /* catalogues give proper motion in RA as great circle */ - parall *= DEGTORAD; - x[0] = ra; - x[1] = de; - x[2] = 1; /* -> unit vector */ - /* cartesian */ - swi_polcart(x, x); - /*space motion vector */ - cosra = cos(ra); - cosde = cos(de); - sinra = sin(ra); - sinde = sin(de); - x[3] = -ra_pm * cosde * sinra - de_pm * sinde * cosra - + radv * parall * cosde * cosra; - x[4] = ra_pm * cosde * cosra - de_pm * sinde * sinra - + radv * parall * cosde * sinra; - x[5] = de_pm * cosde + radv * parall * sinde; - x[3] /= 36525; - x[4] /= 36525; - x[5] /= 36525; + /* ra and de in degrees */ + ra = (ra_s / 3600.0 + ra_m / 60.0 + ra_h) * 15.0; + if (strchr(sde_d, '-') == NULL) + de = de_s / 3600.0 + de_m / 60.0 + de_d; + else + de = -de_s / 3600.0 - de_m / 60.0 + de_d; + /* speed in ra and de, degrees per century */ + if (swed.is_old_starfile == TRUE) { + ra_pm = ra_pm * 15 / 3600.0; + de_pm = de_pm / 3600.0; + } + else { + ra_pm = ra_pm / 10.0 / 3600.0; + de_pm = de_pm / 10.0 / 3600.0; + parall /= 1000.0; + } + /* parallax, degrees */ + if (parall > 1) + parall = (1 / parall / 3600.0); + else + parall /= 3600; + /* radial velocity in AU per century */ + radv *= KM_S_TO_AU_CTY; + /*printf("ra=%.17f,de=%.17f,ma=%.17f,md=%.17f,pa=%.17f,rv=%.17f\n",ra,de,ra_pm,de_pm,parall,radv); */ + /* radians */ + ra *= DEGTORAD; + de *= DEGTORAD; + ra_pm *= DEGTORAD; + de_pm *= DEGTORAD; + ra_pm /= cos(de); /* catalogues give proper motion in RA as great circle */ + parall *= DEGTORAD; + x[0] = ra; + x[1] = de; + x[2] = 1; /* -> unit vector */ + /* cartesian */ + swi_polcart(x, x); + /*space motion vector */ + cosra = cos(ra); + cosde = cos(de); + sinra = sin(ra); + sinde = sin(de); + x[3] = + -ra_pm * cosde * sinra - de_pm * sinde * cosra + + radv * parall * cosde * cosra; + x[4] = + ra_pm * cosde * cosra - de_pm * sinde * sinra + + radv * parall * cosde * sinra; + x[5] = de_pm * cosde + radv * parall * sinde; + x[3] /= 36525; + x[4] /= 36525; + x[5] /= 36525; + /****************************************** * FK5 ******************************************/ - if (epoch == 1950) { - swi_FK4_FK5(x, B1950); - swi_precess(x, B1950, J_TO_J2000); - swi_precess(x+3, B1950, J_TO_J2000); - } - /* FK5 to ICRS, if jpl ephemeris is referred to ICRS - * With data that are already ICRS, epoch = 0 */ - if (epoch != 0) { - swi_icrs2fk5(x, iflag, TRUE); - /* with ephemerides < DE403, we now convert to J2000 */ - if (swed.jpldenum < 403) - swi_bias(x, iflag, FALSE); - } + if (epoch == 1950) { + swi_FK4_FK5(x, B1950); + swi_precess(x, B1950, J_TO_J2000); + swi_precess(x + 3, B1950, J_TO_J2000); + } + /* FK5 to ICRS, if jpl ephemeris is referred to ICRS + * With data that are already ICRS, epoch = 0 */ + if (epoch != 0) { + swi_icrs2fk5(x, iflag, TRUE); + /* with ephemerides < DE403, we now convert to J2000 */ + if (swed.jpldenum < 403) + swi_bias(x, iflag, FALSE); + } #if 0 - if (((iflag & SEFLG_NOGDEFL) == 0 || (iflag & SEFLG_NOABERR) == 0) - && (iflag & SEFLG_HELCTR) == 0 - && (iflag & SEFLG_BARYCTR) == 0 - && (iflag & SEFLG_TRUEPOS) == 0) + if (((iflag & SEFLG_NOGDEFL) == 0 || (iflag & SEFLG_NOABERR) == 0) + && (iflag & SEFLG_HELCTR) == 0 && (iflag & SEFLG_BARYCTR) == 0 + && (iflag & SEFLG_TRUEPOS) == 0) #endif - /**************************************************** - * earth/sun + + /**************************************************** + * earth/sun * for parallax, light deflection, and aberration, ****************************************************/ - if (!(iflag & SEFLG_BARYCTR) && (!(iflag & SEFLG_HELCTR) || !(iflag & SEFLG_MOSEPH))) { - if ((retc = main_planet(tjd, SEI_EARTH, epheflag, iflag, serr)) != OK) { - /*retc = ERR; - goto return_err;*/ - iflag &= ~(SEFLG_TOPOCTR|SEFLG_HELCTR); - /* on error, we provide barycentric position: */ - iflag |= SEFLG_BARYCTR | SEFLG_TRUEPOS | SEFLG_NOGDEFL; - retc = iflag; - } else { - /* iflag (ephemeris bit) may have changed in main_planet() */ - iflag = swed.pldat[SEI_EARTH].xflgs; - } - } + if (!(iflag & SEFLG_BARYCTR) + && (!(iflag & SEFLG_HELCTR) || !(iflag & SEFLG_MOSEPH))) { + if ((retc = + main_planet(tjd, SEI_EARTH, epheflag, iflag, serr)) != OK) { + /*retc = ERR; + * goto return_err; */ + iflag &= ~(SEFLG_TOPOCTR | SEFLG_HELCTR); + /* on error, we provide barycentric position: */ + iflag |= SEFLG_BARYCTR | SEFLG_TRUEPOS | SEFLG_NOGDEFL; + retc = iflag; + } + else { + /* iflag (ephemeris bit) may have changed in main_planet() */ + iflag = swed.pldat[SEI_EARTH].xflgs; + } + } + /************************************ * observer: geocenter or topocenter ************************************/ - /* if topocentric position is wanted */ - if (iflag & SEFLG_TOPOCTR) { - if (swed.topd.teval != pedp->teval - || swed.topd.teval == 0) { - if (swi_get_observer(pedp->teval, iflag, DO_SAVE, xobs, serr) != OK) - return ERR; - } else { - for (i = 0; i <= 5; i++) - xobs[i] = swed.topd.xobs[i]; + /* if topocentric position is wanted */ + if (iflag & SEFLG_TOPOCTR) { + if (swed.topd.teval != pedp->teval || swed.topd.teval == 0) { + if (swi_get_observer(pedp->teval, iflag, DO_SAVE, xobs, serr) + != OK) + return ERR; + } + else { + for (i = 0; i <= 5; i++) + xobs[i] = swed.topd.xobs[i]; + } + /* barycentric position of observer */ + for (i = 0; i <= 5; i++) + xobs[i] = xobs[i] + pedp->x[i]; } - /* barycentric position of observer */ - for (i = 0; i <= 5; i++) - xobs[i] = xobs[i] + pedp->x[i]; - } else if (!(iflag & SEFLG_BARYCTR) && (!(iflag & SEFLG_HELCTR) || !(iflag & SEFLG_MOSEPH))) { - /* barycentric position of geocenter */ - for (i = 0; i <= 5; i++) - xobs[i] = pedp->x[i]; - } + else if (!(iflag & SEFLG_BARYCTR) + && (!(iflag & SEFLG_HELCTR) || !(iflag & SEFLG_MOSEPH))) { + /* barycentric position of geocenter */ + for (i = 0; i <= 5; i++) + xobs[i] = pedp->x[i]; + } + /************************************ * position and speed at tjd * ************************************/ - if (epoch == 1950) - t= (tjd - B1950); /* days since 1950.0 */ - else /* epoch == 2000 */ - t= (tjd - J2000); /* days since 2000.0 */ - /* for parallax */ - if ((iflag & SEFLG_HELCTR) && (iflag & SEFLG_MOSEPH)) - xpo = NULL; /* no parallax, if moshier and heliocentric */ - else if (iflag & SEFLG_HELCTR) - xpo = psdp->x; - else if (iflag & SEFLG_BARYCTR) - xpo = NULL; /* no parallax, if barycentric */ - else - xpo = xobs; - if (xpo == NULL) { - for (i = 0; i <= 2; i++) - x[i] += t * x[i+3]; - } else { - for (i = 0; i <= 2; i++) { - x[i] += t * x[i+3] - parall * xpo[i]; - x[i+3] -= parall * xpo[i+3]; + if (epoch == 1950) + t = (tjd - B1950); /* days since 1950.0 */ + else /* epoch == 2000 */ + t = (tjd - J2000); /* days since 2000.0 */ + /* for parallax */ + if ((iflag & SEFLG_HELCTR) && (iflag & SEFLG_MOSEPH)) + xpo = NULL; /* no parallax, if moshier and heliocentric */ + else if (iflag & SEFLG_HELCTR) + xpo = psdp->x; + else if (iflag & SEFLG_BARYCTR) + xpo = NULL; /* no parallax, if barycentric */ + else + xpo = xobs; + if (xpo == NULL) { + for (i = 0; i <= 2; i++) + x[i] += t * x[i + 3]; } - } + else { + for (i = 0; i <= 2; i++) { + x[i] += t * x[i + 3] - parall * xpo[i]; + x[i + 3] -= parall * xpo[i + 3]; + } + } + /************************************ * relativistic deflection of light * ************************************/ - for (i = 0; i <= 5; i++) - x[i] *= 10000; /* great distance, to allow - * algorithm used with planets */ - if ((iflag & SEFLG_TRUEPOS) == 0 && (iflag & SEFLG_NOGDEFL) == 0) { - swi_deflect_light(x, 0, iflag & SEFLG_SPEED); - } + for (i = 0; i <= 5; i++) + x[i] *= 10000; /* great distance, to allow + * algorithm used with planets */ + if ((iflag & SEFLG_TRUEPOS) == 0 && (iflag & SEFLG_NOGDEFL) == 0) { + swi_deflect_light(x, 0, iflag & SEFLG_SPEED); + } + /********************************** * 'annual' aberration of light * * speed is incorrect !!! * **********************************/ - if ((iflag & SEFLG_TRUEPOS) == 0 && (iflag & SEFLG_NOABERR) == 0) - swi_aberr_light(x, xpo, iflag & SEFLG_SPEED); - /* ICRS to J2000 */ - if (!(iflag & SEFLG_ICRS) && (swed.jpldenum >= 403 || iflag & SEFLG_BARYCTR)) { - swi_bias(x, iflag, FALSE); - }/**/ - /* save J2000 coordinates; required for sidereal positions */ - for (i = 0; i <= 5; i++) - xxsv[i] = x[i]; + if ((iflag & SEFLG_TRUEPOS) == 0 && (iflag & SEFLG_NOABERR) == 0) + swi_aberr_light(x, xpo, iflag & SEFLG_SPEED); + /* ICRS to J2000 */ + if (!(iflag & SEFLG_ICRS) + && (swed.jpldenum >= 403 || iflag & SEFLG_BARYCTR)) { + swi_bias(x, iflag, FALSE); + } + /**/ + /* save J2000 coordinates; required for sidereal positions */ + for (i = 0; i <= 5; i++) + xxsv[i] = x[i]; + /************************************************ * precession, equator 2000 -> equator of date * ************************************************/ - /*x[0] = -0.374018403; x[1] = -0.312548592; x[2] = -0.873168719;*/ - if ((iflag & SEFLG_J2000) == 0) { - swi_precess(x, tjd, J2000_TO_J); - if (iflag & SEFLG_SPEED) - swi_precess_speed(x, tjd, J2000_TO_J); - oe = &swed.oec; - } else - oe = &swed.oec2000; + /*x[0] = -0.374018403; x[1] = -0.312548592; x[2] = -0.873168719; */ + if ((iflag & SEFLG_J2000) == 0) { + swi_precess(x, tjd, J2000_TO_J); + if (iflag & SEFLG_SPEED) + swi_precess_speed(x, tjd, J2000_TO_J); + oe = &swed.oec; + } + else + oe = &swed.oec2000; + /************************************************ * nutation * ************************************************/ - if (!(iflag & SEFLG_NONUT)) - swi_nutate(x, 0, FALSE); -if (0) { - double r = sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]); - printf("%.17f %.17f %f\n", x[0]/r, x[1]/r, x[2]/r); -} + if (!(iflag & SEFLG_NONUT)) + swi_nutate(x, 0, FALSE); + if (0) { + double r = sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]); + printf("%.17f %.17f %f\n", x[0] / r, x[1] / r, x[2] / r); + } + /************************************************ * unit vector (distance = 1) * ************************************************/ - u = sqrt(square_sum(x)); - for (i = 0; i <= 5; i++) - x[i] /= u; - u = sqrt(square_sum(xxsv)); - for (i = 0; i <= 5; i++) - xxsv[i] /= u; + u = sqrt(square_sum(x)); + for (i = 0; i <= 5; i++) + x[i] /= u; + u = sqrt(square_sum(xxsv)); + for (i = 0; i <= 5; i++) + xxsv[i] /= u; + /************************************************ - * set speed = 0, because not correct (aberration) + * set speed = 0, because not correct (aberration) ************************************************/ - for (i = 3; i <= 5; i++) - x[i] = xxsv[i] = 0; + for (i = 3; i <= 5; i++) + x[i] = xxsv[i] = 0; + /************************************************ * transformation to ecliptic. * * with sidereal calc. this will be overwritten * * afterwards. * ************************************************/ - if ((iflag & SEFLG_EQUATORIAL) == 0) { - swi_coortrf2(x, x, oe->seps, oe->ceps); - if (iflag & SEFLG_SPEED) - swi_coortrf2(x+3, x+3, oe->seps, oe->ceps); - if (!(iflag & SEFLG_NONUT)) { - swi_coortrf2(x, x, swed.nut.snut, swed.nut.cnut); - if (iflag & SEFLG_SPEED) - swi_coortrf2(x+3, x+3, swed.nut.snut, swed.nut.cnut); + if ((iflag & SEFLG_EQUATORIAL) == 0) { + swi_coortrf2(x, x, oe->seps, oe->ceps); + if (iflag & SEFLG_SPEED) + swi_coortrf2(x + 3, x + 3, oe->seps, oe->ceps); + if (!(iflag & SEFLG_NONUT)) { + swi_coortrf2(x, x, swed.nut.snut, swed.nut.cnut); + if (iflag & SEFLG_SPEED) + swi_coortrf2(x + 3, x + 3, swed.nut.snut, swed.nut.cnut); + } } - } + /************************************ * sidereal positions * ************************************/ - if (iflag & SEFLG_SIDEREAL) { - /* rigorous algorithm */ - if (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) { - if (swi_trop_ra2sid_lon(xxsv, x, xxsv, iflag, serr) != OK) - return ERR; - if (iflag & SEFLG_EQUATORIAL) - for (i = 0; i <= 5; i++) - x[i] = xxsv[i]; - /* project onto solar system equator */ - } else if (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE) { - if (swi_trop_ra2sid_lon_sosy(xxsv, x, xxsv, iflag, serr) != OK) - return ERR; - if (iflag & SEFLG_EQUATORIAL) - for (i = 0; i <= 5; i++) - x[i] = xxsv[i]; - /* traditional algorithm */ - } else { - swi_cartpol_sp(x, x); - x[0] -= swe_get_ayanamsa(tjd) * DEGTORAD; - swi_polcart_sp(x, x); + if (iflag & SEFLG_SIDEREAL) { + /* rigorous algorithm */ + if (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) { + if (swi_trop_ra2sid_lon(xxsv, x, xxsv, iflag, serr) != OK) + return ERR; + if (iflag & SEFLG_EQUATORIAL) + for (i = 0; i <= 5; i++) + x[i] = xxsv[i]; + /* project onto solar system equator */ + } + else if (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE) { + if (swi_trop_ra2sid_lon_sosy(xxsv, x, xxsv, iflag, serr) != OK) + return ERR; + if (iflag & SEFLG_EQUATORIAL) + for (i = 0; i <= 5; i++) + x[i] = xxsv[i]; + /* traditional algorithm */ + } + else { + swi_cartpol_sp(x, x); + x[0] -= swe_get_ayanamsa(tjd) * DEGTORAD; + swi_polcart_sp(x, x); + } } - } + /************************************************ * transformation to polar coordinates * ************************************************/ - if ((iflag & SEFLG_XYZ) == 0) - swi_cartpol_sp(x, x); - /********************** + if ((iflag & SEFLG_XYZ) == 0) + swi_cartpol_sp(x, x); + + /********************** * radians to degrees * **********************/ - if ((iflag & SEFLG_RADIANS) == 0 && (iflag & SEFLG_XYZ) == 0) { - for (i = 0; i < 2; i++) { - x[i] *= RADTODEG; - x[i+3] *= RADTODEG; + if ((iflag & SEFLG_RADIANS) == 0 && (iflag & SEFLG_XYZ) == 0) { + for (i = 0; i < 2; i++) { + x[i] *= RADTODEG; + x[i + 3] *= RADTODEG; + } } - } - for (i = 0; i <= 5; i++) - xx[i] = x[i]; - /* if no ephemeris has been specified, do not return chosen ephemeris */ - if ((iflgsave & SEFLG_EPHMASK) == 0) - iflag = iflag & ~SEFLG_DEFAULTEPH; - iflag = iflag & ~SEFLG_SPEED; + for (i = 0; i <= 5; i++) + xx[i] = x[i]; + /* if no ephemeris has been specified, do not return chosen ephemeris */ + if ((iflgsave & SEFLG_EPHMASK) == 0) + iflag = iflag & ~SEFLG_DEFAULTEPH; + iflag = iflag & ~SEFLG_SPEED; #ifdef TRACE - trace_swe_fixstar(2, star, tjd, iflag, xx, serr); + trace_swe_fixstar(2, star, tjd, iflag, xx, serr); #endif - return iflag; - return_err: - for (i = 0; i <= 5; i++) - xx[i] = 0; + return iflag; +return_err: + for (i = 0; i <= 5; i++) + xx[i] = 0; #ifdef TRACE - trace_swe_fixstar(2, star, tjd, iflag, xx, serr); + trace_swe_fixstar(2, star, tjd, iflag, xx, serr); #endif - return retc; + return retc; } -int32 FAR PASCAL_CONV swe_fixstar_ut(char *star, double tjd_ut, int32 iflag, - double *xx, char *serr) +int32 FAR PASCAL_CONV +swe_fixstar_ut(char *star, double tjd_ut, int32 iflag, double *xx, char *serr) { - return swe_fixstar(star, tjd_ut + swe_deltat(tjd_ut), iflag, xx, serr); + return swe_fixstar(star, tjd_ut + swe_deltat(tjd_ut), iflag, xx, serr); } /********************************************************** * get fixstar magnitude * parameters: - * star name of star or line number in star file + * star name of star or line number in star file * (start from 1, don't count comment). * If no error occurs, the name of the star is returned * in the format trad_name, nomeclat_name @@ -5649,21 +6164,23 @@ int32 FAR PASCAL_CONV swe_fixstar_ut(char *star, double tjd_ut, int32 iflag, * mag pointer to a double, for star magnitude * serr error return string **********************************************************/ -int32 FAR PASCAL_CONV swe_fixstar_mag(char *star, double *mag, char *serr) +int32 FAR PASCAL_CONV +swe_fixstar_mag(char *star, double *mag, char *serr) { - int i; - int star_nr = 0; - AS_BOOL isnomclat = FALSE; - size_t cmplen; - char *cpos[20]; - char sstar[SE_MAX_STNAME + 1]; - char fstar[SE_MAX_STNAME + 1]; - char s[AS_MAXCH + 20], *sp, *sp2; /* 20 byte for SE_STARFILE */ - int line = 0; - int fline = 0; - int retc; - if (serr != NULL) - *serr = '\0'; + int i; + int star_nr = 0; + AS_BOOL isnomclat = FALSE; + size_t cmplen; + char *cpos[20]; + char sstar[SE_MAX_STNAME + 1]; + char fstar[SE_MAX_STNAME + 1]; + char s[AS_MAXCH + 20], *sp, *sp2; /* 20 byte for SE_STARFILE */ + int line = 0; + int fline = 0; + int retc; + if (serr != NULL) + *serr = '\0'; + /****************************************************** * Star file * close to the beginning, a few stars selected by Astrodienst. @@ -5671,586 +6188,630 @@ int32 FAR PASCAL_CONV swe_fixstar_mag(char *star, double *mag, char *serr) * All other stars can be accessed by name. * Comment lines start with # and are ignored. ******************************************************/ - if (swed.fixfp == NULL) { - if ((swed.fixfp = swi_fopen(SEI_FILE_FIXSTAR, SE_STARFILE, swed.ephepath, serr)) == NULL) { - swed.is_old_starfile = TRUE; - if ((swed.fixfp = swi_fopen(SEI_FILE_FIXSTAR, SE_STARFILE_OLD, swed.ephepath, NULL)) == NULL) { - retc = ERR; - goto return_err; - } + if (swed.fixfp == NULL) { + if ((swed.fixfp = + swi_fopen(SEI_FILE_FIXSTAR, SE_STARFILE, swed.ephepath, + serr)) == NULL) { + swed.is_old_starfile = TRUE; + if ((swed.fixfp = + swi_fopen(SEI_FILE_FIXSTAR, SE_STARFILE_OLD, swed.ephepath, + NULL)) == NULL) { + retc = ERR; + goto return_err; + } + } } - } - rewind(swed.fixfp); - strncpy(sstar, star, SE_MAX_STNAME); - sstar[SE_MAX_STNAME] = '\0'; - if (*sstar == ',') { - isnomclat = TRUE; - } else if (isdigit((int) *sstar)) { - star_nr = atoi(sstar); - } else { - /* traditional name of star to lower case */ - for (sp = sstar; *sp != '\0'; sp++) - *sp = tolower((int) *sp); - if ((sp = strchr(sstar, ',')) != NULL) - *sp = '\0'; - } - swi_right_trim(sstar); - cmplen = strlen(sstar); - if (cmplen == 0) { - if (serr != NULL) - sprintf(serr, "swe_fixstar_mag(): star name empty"); + rewind(swed.fixfp); + strncpy(sstar, star, SE_MAX_STNAME); + sstar[SE_MAX_STNAME] = '\0'; + if (*sstar == ',') { + isnomclat = TRUE; + } + else if (isdigit((int)*sstar)) { + star_nr = atoi(sstar); + } + else { + /* traditional name of star to lower case */ + for (sp = sstar; *sp != '\0'; sp++) + *sp = tolower((int)*sp); + if ((sp = strchr(sstar, ',')) != NULL) + *sp = '\0'; + } + swi_right_trim(sstar); + cmplen = strlen(sstar); + if (cmplen == 0) { + if (serr != NULL) + sprintf(serr, "swe_fixstar_mag(): star name empty"); + retc = ERR; + goto return_err; + } + while (fgets(s, AS_MAXCH, swed.fixfp) != NULL) { + fline++; + if (*s == '#') + continue; + line++; + if (star_nr == line) + goto found; + else if (star_nr > 0) + continue; + if ((sp = strchr(s, ',')) == NULL) { + if (serr != NULL) + sprintf(serr, "star file %s damaged at line %d", SE_STARFILE, + fline); + retc = ERR; + goto return_err; + } + if (isnomclat) { + if (strncmp(sp, sstar, cmplen) == 0) + goto found; + else + continue; + } + *sp = '\0'; /* cut off first field */ + strncpy(fstar, s, SE_MAX_STNAME); + *sp = ','; + fstar[SE_MAX_STNAME] = '\0'; /* force termination */ + swi_right_trim(fstar); + i = strlen(fstar); + if (i < (int)cmplen) + continue; + for (sp2 = fstar; *sp2 != '\0'; sp2++) { + *sp2 = tolower((int)*sp2); + } + if (strncmp(fstar, sstar, cmplen) == 0) + goto found; + } + if (serr != NULL && strlen(star) < AS_MAXCH - 20) + sprintf(serr, "star %s not found", star); retc = ERR; goto return_err; - } - while (fgets(s, AS_MAXCH, swed.fixfp) != NULL) { - fline++; - if (*s == '#') continue; - line++; - if (star_nr == line) - goto found; - else if (star_nr > 0) - continue; - if ((sp = strchr(s, ',')) == NULL) { - if (serr != NULL) - sprintf(serr, "star file %s damaged at line %d", SE_STARFILE, fline); - retc = ERR; - goto return_err; - } - if (isnomclat) { - if (strncmp(sp, sstar, cmplen) == 0) - goto found; - else - continue; +found: + i = swi_cutstr(s, ",", cpos, 20); + swi_right_trim(cpos[0]); + swi_right_trim(cpos[1]); + if (i < 13) { + if (serr != NULL) + sprintf(serr, "data of star '%s,%s' incomplete", cpos[0], + cpos[1]); + retc = ERR; + goto return_err; } - *sp = '\0'; /* cut off first field */ - strncpy(fstar, s, SE_MAX_STNAME); - *sp = ','; - fstar[SE_MAX_STNAME] = '\0'; /* force termination */ - swi_right_trim(fstar); - i = strlen(fstar); - if (i < (int) cmplen) - continue; - for (sp2 = fstar; *sp2 != '\0'; sp2++) { - *sp2 = tolower((int) *sp2); - } - if (strncmp(fstar, sstar, cmplen) == 0) - goto found; - } - if (serr != NULL && strlen(star) < AS_MAXCH - 20) - sprintf(serr, "star %s not found", star); - retc = ERR; - goto return_err; - found: - i = swi_cutstr(s, ",", cpos, 20); - swi_right_trim(cpos[0]); - swi_right_trim(cpos[1]); - if (i < 13) { - if (serr != NULL) - sprintf(serr, "data of star '%s,%s' incomplete", cpos[0], cpos[1]); - retc = ERR; - goto return_err; - } - *mag = atof(cpos[13]); - /* return trad. name, nomeclature name */ - if (strlen(cpos[0]) > SE_MAX_STNAME) - cpos[0][SE_MAX_STNAME] = '\0'; - if (strlen(cpos[1]) > SE_MAX_STNAME-1) - cpos[1][SE_MAX_STNAME-1] = '\0'; - sprintf(star, "%s,%s", cpos[0], cpos[1]); - return OK; - return_err: - *mag = 0; - return retc; + *mag = atof(cpos[13]); + /* return trad. name, nomeclature name */ + if (strlen(cpos[0]) > SE_MAX_STNAME) + cpos[0][SE_MAX_STNAME] = '\0'; + if (strlen(cpos[1]) > SE_MAX_STNAME - 1) + cpos[1][SE_MAX_STNAME - 1] = '\0'; + sprintf(star, "%s,%s", cpos[0], cpos[1]); + return OK; +return_err: + *mag = 0; + return retc; } #if 0 -int swe_fixstar(char *star, double tjd, int32 iflag, double *xx, char *serr) +int +swe_fixstar(char *star, double tjd, int32 iflag, double *xx, char *serr) { - int i, j; - int32 iflgcoor = SEFLG_EQUATORIAL | SEFLG_XYZ | SEFLG_RADIANS; - int retc; - double *xs, x0[6], x2[6]; - double dt; - /* only one speed flag */ - if (iflag & SEFLG_SPEED3) - iflag |= SEFLG_SPEED; - /* cartesian flag excludes radians flag */ - if ((iflag & SEFLG_XYZ) && (iflag & SEFLG_RADIANS)) - iflag = iflag & ~SEFLG_RADIANS; - if ((iflag & SEFLG_SPEED) == 0) { - /* without speed: */ - if ((retc = swecalc(tjd, ipl, iflag, xx, serr)) == ERR) - goto return_error; - } else { - /* with speed from three calls of fixstar() */ - dt = PLAN_SPEED_INTV; - if ((retc = fixstar(star, tjd-dt, iflag, x0, serr)) == ERR) - goto return_error; - if ((retc = fixstar(star, tjd+dt, iflag, x2, serr)) == ERR) - goto return_error; - if ((retc = fixstar(star, tjd, iflag, xx, serr)) == ERR) - goto return_error; - denormalize_positions(x0, xx, x2); /* nonsense !!!!!!!!!!! */ - calc_speed(x0, xx, x2, dt); - } - return retc; - return_error: - for (i = 0; i < 6; i++) - xx[i] = 0; - return ERR; + int i, j; + int32 iflgcoor = SEFLG_EQUATORIAL | SEFLG_XYZ | SEFLG_RADIANS; + int retc; + double *xs, x0[6], x2[6]; + double dt; + /* only one speed flag */ + if (iflag & SEFLG_SPEED3) + iflag |= SEFLG_SPEED; + /* cartesian flag excludes radians flag */ + if ((iflag & SEFLG_XYZ) && (iflag & SEFLG_RADIANS)) + iflag = iflag & ~SEFLG_RADIANS; + if ((iflag & SEFLG_SPEED) == 0) { + /* without speed: */ + if ((retc = swecalc(tjd, ipl, iflag, xx, serr)) == ERR) + goto return_error; + } + else { + /* with speed from three calls of fixstar() */ + dt = PLAN_SPEED_INTV; + if ((retc = fixstar(star, tjd - dt, iflag, x0, serr)) == ERR) + goto return_error; + if ((retc = fixstar(star, tjd + dt, iflag, x2, serr)) == ERR) + goto return_error; + if ((retc = fixstar(star, tjd, iflag, xx, serr)) == ERR) + goto return_error; + denormalize_positions(x0, xx, x2); /* nonsense !!!!!!!!!!! */ + calc_speed(x0, xx, x2, dt); + } + return retc; +return_error: + for (i = 0; i < 6; i++) + xx[i] = 0; + return ERR; } #endif -char *FAR PASCAL_CONV swe_get_planet_name(int ipl, char *s) +char *FAR PASCAL_CONV +swe_get_planet_name(int ipl, char *s) { - int i; - int32 retc; - double xp[6]; + int i; + int32 retc; + double xp[6]; #ifdef TRACE - swi_open_trace(NULL); - trace_swe_get_planet_name(1, ipl, s); + swi_open_trace(NULL); + trace_swe_get_planet_name(1, ipl, s); #endif - /* function calls for Pluto with asteroid number 134340 - * are treated as calls for Pluto as main body SE_PLUTO */ - if (ipl == SE_AST_OFFSET + 134340) - ipl = SE_PLUTO; - if (ipl != 0 && ipl == swed.i_saved_planet_name) { - strcpy(s, swed.saved_planet_name); - return s; - } - switch(ipl) { - case SE_SUN: - strcpy(s, SE_NAME_SUN); - break; - case SE_MOON: - strcpy(s, SE_NAME_MOON); - break; - case SE_MERCURY: - strcpy(s, SE_NAME_MERCURY); - break; - case SE_VENUS: - strcpy(s, SE_NAME_VENUS); - break; - case SE_MARS: - strcpy(s, SE_NAME_MARS); - break; - case SE_JUPITER: - strcpy(s, SE_NAME_JUPITER); - break; - case SE_SATURN: - strcpy(s, SE_NAME_SATURN); - break; - case SE_URANUS: - strcpy(s, SE_NAME_URANUS); - break; - case SE_NEPTUNE: - strcpy(s, SE_NAME_NEPTUNE); - break; - case SE_PLUTO: - strcpy(s, SE_NAME_PLUTO); - break; - case SE_MEAN_NODE: - strcpy(s, SE_NAME_MEAN_NODE); - break; - case SE_TRUE_NODE: - strcpy(s, SE_NAME_TRUE_NODE); - break; - case SE_MEAN_APOG: - strcpy(s, SE_NAME_MEAN_APOG); - break; - case SE_OSCU_APOG: - strcpy(s, SE_NAME_OSCU_APOG); - break; - case SE_INTP_APOG: - strcpy(s, SE_NAME_INTP_APOG); - break; - case SE_INTP_PERG: - strcpy(s, SE_NAME_INTP_PERG); - break; - case SE_EARTH: - strcpy(s, SE_NAME_EARTH); - break; - case SE_CHIRON: - case SE_AST_OFFSET + MPC_CHIRON: - strcpy(s, SE_NAME_CHIRON); - break; - case SE_PHOLUS: - case SE_AST_OFFSET + MPC_PHOLUS: - strcpy(s, SE_NAME_PHOLUS); - break; - case SE_CERES: - case SE_AST_OFFSET + MPC_CERES: - strcpy(s, SE_NAME_CERES); - break; - case SE_PALLAS: - case SE_AST_OFFSET + MPC_PALLAS: - strcpy(s, SE_NAME_PALLAS); - break; - case SE_JUNO: - case SE_AST_OFFSET + MPC_JUNO: - strcpy(s, SE_NAME_JUNO); - break; - case SE_VESTA: - case SE_AST_OFFSET + MPC_VESTA: - strcpy(s, SE_NAME_VESTA); - break; - default: - /* fictitious planets */ - if (ipl >= SE_FICT_OFFSET && ipl <= SE_FICT_MAX) { - swi_get_fict_name(ipl - SE_FICT_OFFSET, s); - break; - } - /* asteroids */ - if (ipl > SE_AST_OFFSET) { - /* if name is already available */ - if (ipl == swed.fidat[SEI_FILE_ANY_AST].ipl[0]) - strcpy(s, swed.fidat[SEI_FILE_ANY_AST].astnam); - /* else try to get it from ephemeris file */ - else { - retc = sweph(J2000, ipl, SEI_FILE_ANY_AST, 0, NULL, NO_SAVE, xp, NULL); - if (retc != ERR && retc != NOT_AVAILABLE) - strcpy(s, swed.fidat[SEI_FILE_ANY_AST].astnam); - else - sprintf(s, "%d: not found", ipl - SE_AST_OFFSET); - } - /* If there is a provisional designation only in ephemeris file, - * we look for a name in seasnam.txt, which can be updated by - * the user. - * Some old ephemeris files return a '?' in the first position. - * There are still a couple of unnamed bodies that got their - * provisional designation before 1925, when the current method - * of provisional designations was introduced. They have an 'A' - * as the first character, e.g. A924 RC. - * The file seasnam.txt may contain comments starting with '#'. - * There must be at least two columns: - * 1. asteroid catalog number - * 2. asteroid name - * The asteroid number may or may not be in brackets - */ - if (s[0] == '?' || isdigit((int) s[1])) { - int ipli = (int) (ipl - SE_AST_OFFSET), iplf = 0; - FILE *fp; - char si[AS_MAXCH], *sp, *sp2; - if ((fp = swi_fopen(-1, SE_ASTNAMFILE, swed.ephepath, NULL)) != NULL) { - while(ipli != iplf && (sp = fgets(si, AS_MAXCH, fp)) != NULL) { - while (*sp == ' ' || *sp == '\t' - || *sp == '(' || *sp == '[' || *sp == '{') - sp++; - if (*sp == '#' || *sp == '\r' || *sp == '\n' || *sp == '\0') - continue; - /* catalog number of body of current line */ - iplf = atoi(sp); - if (ipli != iplf) - continue; - /* set pointer after catalog number */ - sp = strpbrk(sp, " \t"); - if (sp == NULL) - continue; /* there is no name */ - while (*sp == ' ' || *sp == '\t') - sp++; - sp2 = strpbrk(sp, "#\r\n"); - if (sp2 != NULL) - *sp2 = '\0'; - if (*sp == '\0') - continue; - swi_right_trim(sp); - strcpy(s, sp); + /* function calls for Pluto with asteroid number 134340 + * are treated as calls for Pluto as main body SE_PLUTO */ + if (ipl == SE_AST_OFFSET + 134340) + ipl = SE_PLUTO; + if (ipl != 0 && ipl == swed.i_saved_planet_name) { + strcpy(s, swed.saved_planet_name); + return s; + } + switch (ipl) { + case SE_SUN: + strcpy(s, SE_NAME_SUN); + break; + case SE_MOON: + strcpy(s, SE_NAME_MOON); + break; + case SE_MERCURY: + strcpy(s, SE_NAME_MERCURY); + break; + case SE_VENUS: + strcpy(s, SE_NAME_VENUS); + break; + case SE_MARS: + strcpy(s, SE_NAME_MARS); + break; + case SE_JUPITER: + strcpy(s, SE_NAME_JUPITER); + break; + case SE_SATURN: + strcpy(s, SE_NAME_SATURN); + break; + case SE_URANUS: + strcpy(s, SE_NAME_URANUS); + break; + case SE_NEPTUNE: + strcpy(s, SE_NAME_NEPTUNE); + break; + case SE_PLUTO: + strcpy(s, SE_NAME_PLUTO); + break; + case SE_MEAN_NODE: + strcpy(s, SE_NAME_MEAN_NODE); + break; + case SE_TRUE_NODE: + strcpy(s, SE_NAME_TRUE_NODE); + break; + case SE_MEAN_APOG: + strcpy(s, SE_NAME_MEAN_APOG); + break; + case SE_OSCU_APOG: + strcpy(s, SE_NAME_OSCU_APOG); + break; + case SE_INTP_APOG: + strcpy(s, SE_NAME_INTP_APOG); + break; + case SE_INTP_PERG: + strcpy(s, SE_NAME_INTP_PERG); + break; + case SE_EARTH: + strcpy(s, SE_NAME_EARTH); + break; + case SE_CHIRON: + case SE_AST_OFFSET + MPC_CHIRON: + strcpy(s, SE_NAME_CHIRON); + break; + case SE_PHOLUS: + case SE_AST_OFFSET + MPC_PHOLUS: + strcpy(s, SE_NAME_PHOLUS); + break; + case SE_CERES: + case SE_AST_OFFSET + MPC_CERES: + strcpy(s, SE_NAME_CERES); + break; + case SE_PALLAS: + case SE_AST_OFFSET + MPC_PALLAS: + strcpy(s, SE_NAME_PALLAS); + break; + case SE_JUNO: + case SE_AST_OFFSET + MPC_JUNO: + strcpy(s, SE_NAME_JUNO); + break; + case SE_VESTA: + case SE_AST_OFFSET + MPC_VESTA: + strcpy(s, SE_NAME_VESTA); + break; + default: + /* fictitious planets */ + if (ipl >= SE_FICT_OFFSET && ipl <= SE_FICT_MAX) { + swi_get_fict_name(ipl - SE_FICT_OFFSET, s); + break; } - fclose(fp); - } - } - } else { - i = ipl; - sprintf(s, "%d", i); - } - break; - } + /* asteroids */ + if (ipl > SE_AST_OFFSET) { + /* if name is already available */ + if (ipl == swed.fidat[SEI_FILE_ANY_AST].ipl[0]) + strcpy(s, swed.fidat[SEI_FILE_ANY_AST].astnam); + /* else try to get it from ephemeris file */ + else { + retc = + sweph(J2000, ipl, SEI_FILE_ANY_AST, 0, NULL, NO_SAVE, + xp, NULL); + if (retc != ERR && retc != NOT_AVAILABLE) + strcpy(s, swed.fidat[SEI_FILE_ANY_AST].astnam); + else + sprintf(s, "%d: not found", ipl - SE_AST_OFFSET); + } + /* If there is a provisional designation only in ephemeris file, + * we look for a name in seasnam.txt, which can be updated by + * the user. + * Some old ephemeris files return a '?' in the first position. + * There are still a couple of unnamed bodies that got their + * provisional designation before 1925, when the current method + * of provisional designations was introduced. They have an 'A' + * as the first character, e.g. A924 RC. + * The file seasnam.txt may contain comments starting with '#'. + * There must be at least two columns: + * 1. asteroid catalog number + * 2. asteroid name + * The asteroid number may or may not be in brackets + */ + if (s[0] == '?' || isdigit((int)s[1])) { + int ipli = (int)(ipl - SE_AST_OFFSET), iplf = 0; + FILE *fp; + char si[AS_MAXCH], *sp, *sp2; + if ((fp = + swi_fopen(-1, SE_ASTNAMFILE, swed.ephepath, + NULL)) != NULL) { + while (ipli != iplf + && (sp = fgets(si, AS_MAXCH, fp)) != NULL) { + while (*sp == ' ' || *sp == '\t' || *sp == '(' + || *sp == '[' || *sp == '{') + sp++; + if (*sp == '#' || *sp == '\r' || *sp == '\n' + || *sp == '\0') + continue; + /* catalog number of body of current line */ + iplf = atoi(sp); + if (ipli != iplf) + continue; + /* set pointer after catalog number */ + sp = strpbrk(sp, " \t"); + if (sp == NULL) + continue; /* there is no name */ + while (*sp == ' ' || *sp == '\t') + sp++; + sp2 = strpbrk(sp, "#\r\n"); + if (sp2 != NULL) + *sp2 = '\0'; + if (*sp == '\0') + continue; + swi_right_trim(sp); + strcpy(s, sp); + } + fclose(fp); + } + } + } + else { + i = ipl; + sprintf(s, "%d", i); + } + break; + } #ifdef TRACE - swi_open_trace(NULL); - trace_swe_get_planet_name(2, ipl, s); + swi_open_trace(NULL); + trace_swe_get_planet_name(2, ipl, s); #endif - if (strlen(s) < 80) { - swed.i_saved_planet_name = ipl; - strcpy(swed.saved_planet_name, s); - } - return s; + if (strlen(s) < 80) { + swed.i_saved_planet_name = ipl; + strcpy(swed.saved_planet_name, s); + } + return s; } -char *FAR PASCAL_CONV swe_get_ayanamsa_name(int32 isidmode) +char *FAR PASCAL_CONV +swe_get_ayanamsa_name(int32 isidmode) { - if (isidmode < SE_NSIDM_PREDEF) - return ayanamsa_name[isidmode]; - return NULL; + if (isidmode < SE_NSIDM_PREDEF) + return ayanamsa_name[isidmode]; + return NULL; } #ifdef TRACE -static void trace_swe_calc(int swtch, double tjd, int ipl, int32 iflag, double *xx, char *serr) +static void +trace_swe_calc(int swtch, double tjd, int ipl, int32 iflag, double *xx, + char *serr) { - if (swi_trace_count >= TRACE_COUNT_MAX) - return; - switch(swtch) { - case 1: - if (swi_fp_trace_c != NULL) { - fputs("\n/*SWE_CALC*/\n", swi_fp_trace_c); - fprintf(swi_fp_trace_c, " tjd = %.9f;", tjd); - fprintf(swi_fp_trace_c, " ipl = %d;", ipl); - fprintf(swi_fp_trace_c, " iflag = %d;\n", iflag); - fprintf(swi_fp_trace_c, " iflgret = swe_calc(tjd, ipl, iflag, xx, serr);"); - fprintf(swi_fp_trace_c, " /* xx = %d */\n", (int32) xx); - fflush(swi_fp_trace_c); - } - break; - case 2: - if (swi_fp_trace_c != NULL) { - fputs(" printf(\"swe_calc: %f\\t%d\\t%d\\t%f\\t%f\\t%f\\t%f\\t%f\\t%f\\t\", ", swi_fp_trace_c); - fputs("\n\ttjd, ipl, iflgret, xx[0], xx[1], xx[2], xx[3], xx[4], xx[5]);\n", swi_fp_trace_c); - fputs(" if (*serr != '\\0')", swi_fp_trace_c); - fputs(" printf(serr);", swi_fp_trace_c); - fputs(" printf(\"\\n\");\n", swi_fp_trace_c); - fflush(swi_fp_trace_c); - } - if (swi_fp_trace_out != NULL) { - fprintf(swi_fp_trace_out, "swe_calc: %f\t%d\t%d\t%f\t%f\t%f\t%f\t%f\t%f\t", - tjd, ipl, iflag, xx[0], xx[1], xx[2], xx[3], xx[4], xx[5]); - if (serr != NULL && *serr != '\0') { - fputs(serr, swi_fp_trace_out); - } - fputs("\n", swi_fp_trace_out); - fflush(swi_fp_trace_out); - } - break; - default: - break; - } + if (swi_trace_count >= TRACE_COUNT_MAX) + return; + switch (swtch) { + case 1: + if (swi_fp_trace_c != NULL) { + fputs("\n/*SWE_CALC*/\n", swi_fp_trace_c); + fprintf(swi_fp_trace_c, " tjd = %.9f;", tjd); + fprintf(swi_fp_trace_c, " ipl = %d;", ipl); + fprintf(swi_fp_trace_c, " iflag = %d;\n", iflag); + fprintf(swi_fp_trace_c, + " iflgret = swe_calc(tjd, ipl, iflag, xx, serr);"); + fprintf(swi_fp_trace_c, " /* xx = %d */\n", (int32) xx); + fflush(swi_fp_trace_c); + } + break; + case 2: + if (swi_fp_trace_c != NULL) { + fputs + (" printf(\"swe_calc: %f\\t%d\\t%d\\t%f\\t%f\\t%f\\t%f\\t%f\\t%f\\t\", ", + swi_fp_trace_c); + fputs + ("\n\ttjd, ipl, iflgret, xx[0], xx[1], xx[2], xx[3], xx[4], xx[5]);\n", + swi_fp_trace_c); + fputs(" if (*serr != '\\0')", swi_fp_trace_c); + fputs(" printf(serr);", swi_fp_trace_c); + fputs(" printf(\"\\n\");\n", swi_fp_trace_c); + fflush(swi_fp_trace_c); + } + if (swi_fp_trace_out != NULL) { + fprintf(swi_fp_trace_out, + "swe_calc: %f\t%d\t%d\t%f\t%f\t%f\t%f\t%f\t%f\t", tjd, + ipl, iflag, xx[0], xx[1], xx[2], xx[3], xx[4], xx[5]); + if (serr != NULL && *serr != '\0') { + fputs(serr, swi_fp_trace_out); + } + fputs("\n", swi_fp_trace_out); + fflush(swi_fp_trace_out); + } + break; + default: + break; + } } -static void trace_swe_fixstar(int swtch, char *star, double tjd, int32 iflag, double *xx, char *serr) +static void +trace_swe_fixstar(int swtch, char *star, double tjd, int32 iflag, double *xx, + char *serr) { - if (swi_trace_count >= TRACE_COUNT_MAX) - return; - switch(swtch) { - case 1: - if (swi_fp_trace_c != NULL) { - fputs("\n/*SWE_FIXSTAR*/\n", swi_fp_trace_c); - fprintf(swi_fp_trace_c, " strcpy(star, \"%s\");", star); - fprintf(swi_fp_trace_c, " tjd = %.9f;", tjd); - fprintf(swi_fp_trace_c, " iflag = %d;\n", iflag); - fprintf(swi_fp_trace_c, " iflgret = swe_fixstar(star, tjd, iflag, xx, serr);"); - fprintf(swi_fp_trace_c, " /* xx = %d */\n", (int32) xx); - fflush(swi_fp_trace_c); - } - break; - case 2: - if (swi_fp_trace_c != NULL) { - fputs(" printf(\"swe_fixstar: %s\\t%f\\t%d\\t%f\\t%f\\t%f\\t%f\\t%f\\t%f\\t\", ", swi_fp_trace_c); - fputs("\n\tstar, tjd, iflgret, xx[0], xx[1], xx[2], xx[3], xx[4], xx[5]);\n", swi_fp_trace_c);/**/ - fputs(" if (*serr != '\\0')", swi_fp_trace_c); - fputs(" printf(serr);", swi_fp_trace_c); - fputs(" printf(\"\\n\");\n", swi_fp_trace_c); - fflush(swi_fp_trace_c); + if (swi_trace_count >= TRACE_COUNT_MAX) + return; + switch (swtch) { + case 1: + if (swi_fp_trace_c != NULL) { + fputs("\n/*SWE_FIXSTAR*/\n", swi_fp_trace_c); + fprintf(swi_fp_trace_c, " strcpy(star, \"%s\");", star); + fprintf(swi_fp_trace_c, " tjd = %.9f;", tjd); + fprintf(swi_fp_trace_c, " iflag = %d;\n", iflag); + fprintf(swi_fp_trace_c, + " iflgret = swe_fixstar(star, tjd, iflag, xx, serr);"); + fprintf(swi_fp_trace_c, " /* xx = %d */\n", (int32) xx); + fflush(swi_fp_trace_c); + } + break; + case 2: + if (swi_fp_trace_c != NULL) { + fputs + (" printf(\"swe_fixstar: %s\\t%f\\t%d\\t%f\\t%f\\t%f\\t%f\\t%f\\t%f\\t\", ", + swi_fp_trace_c); + fputs + ("\n\tstar, tjd, iflgret, xx[0], xx[1], xx[2], xx[3], xx[4], xx[5]);\n", + swi_fp_trace_c); + /**/ fputs(" if (*serr != '\\0')", swi_fp_trace_c); + fputs(" printf(serr);", swi_fp_trace_c); + fputs(" printf(\"\\n\");\n", swi_fp_trace_c); + fflush(swi_fp_trace_c); + } + if (swi_fp_trace_out != NULL) { + fprintf(swi_fp_trace_out, + "swe_fixstar: %s\t%f\t%d\t%f\t%f\t%f\t%f\t%f\t%f\t", + star, tjd, iflag, xx[0], xx[1], xx[2], xx[3], xx[4], + xx[5]); + if (serr != NULL && *serr != '\0') { + fputs(serr, swi_fp_trace_out); + } + fputs("\n", swi_fp_trace_out); + fflush(swi_fp_trace_out); + } + break; + default: + break; } - if (swi_fp_trace_out != NULL) { - fprintf(swi_fp_trace_out, "swe_fixstar: %s\t%f\t%d\t%f\t%f\t%f\t%f\t%f\t%f\t", - star, tjd, iflag, xx[0], xx[1], xx[2], xx[3], xx[4], xx[5]); - if (serr != NULL && *serr != '\0') { - fputs(serr, swi_fp_trace_out); - } - fputs("\n", swi_fp_trace_out); - fflush(swi_fp_trace_out); - } - break; - default: - break; - } } -static void trace_swe_get_planet_name(int swtch, int ipl, char *s) +static void +trace_swe_get_planet_name(int swtch, int ipl, char *s) { - if (swi_trace_count >= TRACE_COUNT_MAX) - return; - switch(swtch) { - case 1: - if (swi_fp_trace_c != NULL) { - fputs("\n/*SWE_GET_PLANET_NAME*/\n", swi_fp_trace_c); - fprintf(swi_fp_trace_c, " ipl = %d;\n", ipl); - fprintf(swi_fp_trace_c, " swe_get_planet_name(ipl, s);"); - fprintf(swi_fp_trace_c, " /* s = %d */\n", (int32) s); - fflush(swi_fp_trace_c); - } - break; - case 2: - if (swi_fp_trace_c != NULL) { - fputs(" printf(\"swe_get_planet_name: %d\\t%s\\t\\n\", ", swi_fp_trace_c); - fputs("ipl, s);\n", swi_fp_trace_c);/**/ - fflush(swi_fp_trace_c); - } - if (swi_fp_trace_out != NULL) { - fprintf(swi_fp_trace_out, "swe_get_planet_name: %d\t%s\t\n", ipl, s); - fflush(swi_fp_trace_out); - } - break; - default: - break; - } + if (swi_trace_count >= TRACE_COUNT_MAX) + return; + switch (swtch) { + case 1: + if (swi_fp_trace_c != NULL) { + fputs("\n/*SWE_GET_PLANET_NAME*/\n", swi_fp_trace_c); + fprintf(swi_fp_trace_c, " ipl = %d;\n", ipl); + fprintf(swi_fp_trace_c, " swe_get_planet_name(ipl, s);"); + fprintf(swi_fp_trace_c, " /* s = %d */\n", (int32) s); + fflush(swi_fp_trace_c); + } + break; + case 2: + if (swi_fp_trace_c != NULL) { + fputs(" printf(\"swe_get_planet_name: %d\\t%s\\t\\n\", ", + swi_fp_trace_c); + fputs("ipl, s);\n", swi_fp_trace_c); + /**/ fflush(swi_fp_trace_c); + } + if (swi_fp_trace_out != NULL) { + fprintf(swi_fp_trace_out, "swe_get_planet_name: %d\t%s\t\n", + ipl, s); + fflush(swi_fp_trace_out); + } + break; + default: + break; + } } #endif /* set geographic position and altitude of observer */ -void FAR PASCAL_CONV swe_set_topo(double geolon, double geolat, double geoalt) +void FAR PASCAL_CONV +swe_set_topo(double geolon, double geolat, double geoalt) { - swed.topd.geolon = geolon; - swed.topd.geolat = geolat; - swed.topd.geoalt = geoalt; - swed.geopos_is_set = TRUE; - /* to force new calculation of observer position vector */ - swed.topd.teval = 0; - /* to force new calculation of light-time etc. - */ - swi_force_app_pos_etc(); + swed.topd.geolon = geolon; + swed.topd.geolat = geolat; + swed.topd.geoalt = geoalt; + swed.geopos_is_set = TRUE; + /* to force new calculation of observer position vector */ + swed.topd.teval = 0; + /* to force new calculation of light-time etc. + */ + swi_force_app_pos_etc(); } -void swi_force_app_pos_etc() +void +swi_force_app_pos_etc() { - int i; - for (i = 0; i < SEI_NPLANETS; i++) - swed.pldat[i].xflgs = -1; - for (i = 0; i < SEI_NNODE_ETC; i++) - swed.nddat[i].xflgs = -1; - for (i = 0; i < SE_NPLANETS; i++) { - swed.savedat[i].tsave = 0; - swed.savedat[i].iflgsave = -1; - } + int i; + for (i = 0; i < SEI_NPLANETS; i++) + swed.pldat[i].xflgs = -1; + for (i = 0; i < SEI_NNODE_ETC; i++) + swed.nddat[i].xflgs = -1; + for (i = 0; i < SE_NPLANETS; i++) { + swed.savedat[i].tsave = 0; + swed.savedat[i].iflgsave = -1; + } } -int swi_get_observer(double tjd, int32 iflag, - AS_BOOL do_save, double *xobs, char *serr) +int +swi_get_observer(double tjd, int32 iflag, AS_BOOL do_save, double *xobs, + char *serr) { - int i; - double sidt, delt, tjd_ut, eps, nut, nutlo[2]; - double f = EARTH_OBLATENESS; - double re = EARTH_RADIUS; - double cosfi, sinfi, cc, ss, cosl, sinl, h; - if (!swed.geopos_is_set) { - if (serr != NULL) - strcpy(serr, "geographic position has not been set"); - return ERR; - } - /* geocentric position of observer depends on sidereal time, - * which depends on UT. - * compute UT from ET. this UT will be slightly different - * from the user's UT, but this difference is extremely small. - */ - delt = swe_deltat(tjd); - tjd_ut = tjd - delt; - if (swed.oec.teps == tjd && swed.nut.tnut == tjd) { - eps = swed.oec.eps; - nutlo[1] = swed.nut.nutlo[1]; - nutlo[0] = swed.nut.nutlo[0]; - } else { - eps = swi_epsiln(tjd); - if (!(iflag & SEFLG_NONUT)) - swi_nutation(tjd, nutlo); - } - if (iflag & SEFLG_NONUT) { - nut = 0; - } else { - eps += nutlo[1]; - nut = nutlo[0]; - } - /* mean or apparent sidereal time, depending on whether or - * not SEFLG_NONUT is set */ - sidt = swe_sidtime0(tjd_ut, eps, nut); - sidt *= 15; /* in degrees */ - /* length of position and speed vectors; - * the height above sea level must be taken into account. - * with the moon, an altitude of 3000 m makes a difference - * of about 2 arc seconds. - * height is referred to the average sea level. however, - * the spheroid (geoid), which is defined by the average - * sea level (or rather by all points of same gravitational - * potential), is of irregular shape and cannot easily - * be taken into account. therefore, we refer height to - * the surface of the ellipsoid. the resulting error - * is below 500 m, i.e. 0.2 - 0.3 arc seconds with the moon. - */ - cosfi = cos(swed.topd.geolat * DEGTORAD); - sinfi = sin(swed.topd.geolat * DEGTORAD); - cc= 1 / sqrt(cosfi * cosfi + (1-f) * (1-f) * sinfi * sinfi); - ss= (1-f) * (1-f) * cc; - /* neglect polar motion (displacement of a few meters), as long as - * we use the earth ellipsoid */ - /* ... */ - /* add sidereal time */ - cosl = cos((swed.topd.geolon + sidt) * DEGTORAD); - sinl = sin((swed.topd.geolon + sidt) * DEGTORAD); - h = swed.topd.geoalt; - xobs[0] = (re * cc + h) * cosfi * cosl; - xobs[1] = (re * cc + h) * cosfi * sinl; - xobs[2] = (re * ss + h) * sinfi; - /* polar coordinates */ - swi_cartpol(xobs, xobs); - /* speed */ - xobs[3] = EARTH_ROT_SPEED; - xobs[4] = xobs[5] = 0; - swi_polcart_sp(xobs, xobs); - /* to AUNIT */ - for (i = 0; i <= 5; i++) - xobs[i] /= AUNIT; - /* subtract nutation, set backward flag */ - if (!(iflag & SEFLG_NONUT)) { - swi_coortrf2(xobs, xobs, -swed.nut.snut, swed.nut.cnut); - if (iflag & SEFLG_SPEED) - swi_coortrf2(xobs+3, xobs+3, -swed.nut.snut, swed.nut.cnut); - swi_nutate(xobs, iflag, TRUE); - } - /* precess to J2000 */ - swi_precess(xobs, tjd, J_TO_J2000); - if (iflag & SEFLG_SPEED) - swi_precess_speed(xobs, tjd, J_TO_J2000); - /* neglect frame bias (displacement of 45cm) */ - /* ... */ - /* save */ - if (do_save) { + int i; + double sidt, delt, tjd_ut, eps, nut, nutlo[2]; + double f = EARTH_OBLATENESS; + double re = EARTH_RADIUS; + double cosfi, sinfi, cc, ss, cosl, sinl, h; + if (!swed.geopos_is_set) { + if (serr != NULL) + strcpy(serr, "geographic position has not been set"); + return ERR; + } + /* geocentric position of observer depends on sidereal time, + * which depends on UT. + * compute UT from ET. this UT will be slightly different + * from the user's UT, but this difference is extremely small. + */ + delt = swe_deltat(tjd); + tjd_ut = tjd - delt; + if (swed.oec.teps == tjd && swed.nut.tnut == tjd) { + eps = swed.oec.eps; + nutlo[1] = swed.nut.nutlo[1]; + nutlo[0] = swed.nut.nutlo[0]; + } + else { + eps = swi_epsiln(tjd); + if (!(iflag & SEFLG_NONUT)) + swi_nutation(tjd, nutlo); + } + if (iflag & SEFLG_NONUT) { + nut = 0; + } + else { + eps += nutlo[1]; + nut = nutlo[0]; + } + /* mean or apparent sidereal time, depending on whether or + * not SEFLG_NONUT is set */ + sidt = swe_sidtime0(tjd_ut, eps, nut); + sidt *= 15; /* in degrees */ + /* length of position and speed vectors; + * the height above sea level must be taken into account. + * with the moon, an altitude of 3000 m makes a difference + * of about 2 arc seconds. + * height is referred to the average sea level. however, + * the spheroid (geoid), which is defined by the average + * sea level (or rather by all points of same gravitational + * potential), is of irregular shape and cannot easily + * be taken into account. therefore, we refer height to + * the surface of the ellipsoid. the resulting error + * is below 500 m, i.e. 0.2 - 0.3 arc seconds with the moon. + */ + cosfi = cos(swed.topd.geolat * DEGTORAD); + sinfi = sin(swed.topd.geolat * DEGTORAD); + cc = 1 / sqrt(cosfi * cosfi + (1 - f) * (1 - f) * sinfi * sinfi); + ss = (1 - f) * (1 - f) * cc; + /* neglect polar motion (displacement of a few meters), as long as + * we use the earth ellipsoid */ + /* ... */ + /* add sidereal time */ + cosl = cos((swed.topd.geolon + sidt) * DEGTORAD); + sinl = sin((swed.topd.geolon + sidt) * DEGTORAD); + h = swed.topd.geoalt; + xobs[0] = (re * cc + h) * cosfi * cosl; + xobs[1] = (re * cc + h) * cosfi * sinl; + xobs[2] = (re * ss + h) * sinfi; + /* polar coordinates */ + swi_cartpol(xobs, xobs); + /* speed */ + xobs[3] = EARTH_ROT_SPEED; + xobs[4] = xobs[5] = 0; + swi_polcart_sp(xobs, xobs); + /* to AUNIT */ for (i = 0; i <= 5; i++) - swed.topd.xobs[i] = xobs[i]; - swed.topd.teval = tjd; - swed.topd.tjd_ut = tjd_ut; /* -> save area */ - } - return OK; + xobs[i] /= AUNIT; + /* subtract nutation, set backward flag */ + if (!(iflag & SEFLG_NONUT)) { + swi_coortrf2(xobs, xobs, -swed.nut.snut, swed.nut.cnut); + if (iflag & SEFLG_SPEED) + swi_coortrf2(xobs + 3, xobs + 3, -swed.nut.snut, swed.nut.cnut); + swi_nutate(xobs, iflag, TRUE); + } + /* precess to J2000 */ + swi_precess(xobs, tjd, J_TO_J2000); + if (iflag & SEFLG_SPEED) + swi_precess_speed(xobs, tjd, J_TO_J2000); + /* neglect frame bias (displacement of 45cm) */ + /* ... */ + /* save */ + if (do_save) { + for (i = 0; i <= 5; i++) + swed.topd.xobs[i] = xobs[i]; + swed.topd.teval = tjd; + swed.topd.tjd_ut = tjd_ut; /* -> save area */ + } + return OK; } /* Equation of Time * - * The function returns the difference between + * The function returns the difference between * local apparent and local mean time in days. * E = LAT - LMT * Input variable tjd is ET. * Algorithm according to Meeus, German, p. 190ff. */ -int FAR PASCAL_CONV swe_time_equ(double tjd, double *E, char *serr) +int FAR PASCAL_CONV +swe_time_equ(double tjd, double *E, char *serr) { - double L0, dpsi, eps, x[6], nutlo[2]; - double tau = (tjd - J2000) / 365250; - double tau2 = tau * tau; - double tau3 = tau * tau2; - double tau4 = tau * tau3; - double tau5 = tau * tau4; - L0 = 280.4664567 + swe_degnorm(tau * 360007.6982779) - + tau2 * 0.03032028 - + tau3 * 1 / 49931 - - tau4 * 1 / 15299 - - tau5 * 1 / 1988000; - swi_nutation(tjd, nutlo); - eps = (swi_epsiln(tjd) + nutlo[1]) * RADTODEG; - dpsi = nutlo[0] * RADTODEG; - if (swe_calc(tjd, SE_SUN, SEFLG_EQUATORIAL, x, serr) == ERR) - return ERR; - *E = swe_degnorm(L0 - 0.0057183 - x[0] + dpsi * cos(eps * DEGTORAD)); - if (*E > 180) - *E -= 360; - *E *= 4 / 1440.0; - return OK; + double L0, dpsi, eps, x[6], nutlo[2]; + double tau = (tjd - J2000) / 365250; + double tau2 = tau * tau; + double tau3 = tau * tau2; + double tau4 = tau * tau3; + double tau5 = tau * tau4; + L0 = 280.4664567 + swe_degnorm(tau * 360007.6982779) + + tau2 * 0.03032028 + tau3 * 1 / 49931 - tau4 * 1 / 15299 - + tau5 * 1 / 1988000; + swi_nutation(tjd, nutlo); + eps = (swi_epsiln(tjd) + nutlo[1]) * RADTODEG; + dpsi = nutlo[0] * RADTODEG; + if (swe_calc(tjd, SE_SUN, SEFLG_EQUATORIAL, x, serr) == ERR) + return ERR; + *E = swe_degnorm(L0 - 0.0057183 - x[0] + dpsi * cos(eps * DEGTORAD)); + if (*E > 180) + *E -= 360; + *E *= 4 / 1440.0; + return OK; } diff --git a/swe/src/sweph.h b/swe/src/sweph.h index f9c1490..ace8164 100644 --- a/swe/src/sweph.h +++ b/swe/src/sweph.h @@ -5,6 +5,7 @@ Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich ************************************************************/ + /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -65,9 +66,9 @@ #define SE_VERSION "1.79.00" -#define J2000 2451545.0 /* 2000 January 1.5 */ -#define B1950 2433282.42345905 /* 1950 January 0.923 */ -#define J1900 2415020.0 /* 1900 January 0.5 */ +#define J2000 2451545.0 /* 2000 January 1.5 */ +#define B1950 2433282.42345905 /* 1950 January 0.923 */ +#define J1900 2415020.0 /* 1900 January 0.5 */ #define MPC_CERES 1 #define MPC_PALLAS 2 @@ -100,7 +101,7 @@ #define SE_NAME_CHIRON "Chiron" #define SE_NAME_PHOLUS "Pholus" - + #define SE_NAME_CUPIDO "Cupido" #define SE_NAME_HADES "Hades" #define SE_NAME_ZEUS "Zeus" @@ -124,10 +125,10 @@ * by Chapront/Chapront-Touzé/Francou A&A 387 (2002), p. 705. */ #define SE_TIDAL_DE200 (-23.8946) -#define SE_TIDAL_DE403 (-25.580) /* was (-25.8) until V. 1.76.2 */ -#define SE_TIDAL_DE404 (-25.580) /* was (-25.8) until V. 1.76.2 */ -#define SE_TIDAL_DE405 (-25.826) /* was (-25.7376) until V. 1.76.2 */ -#define SE_TIDAL_DE406 (-25.826) /* was (-25.7376) until V. 1.76.2 */ +#define SE_TIDAL_DE403 (-25.580) /* was (-25.8) until V. 1.76.2 */ +#define SE_TIDAL_DE404 (-25.580) /* was (-25.8) until V. 1.76.2 */ +#define SE_TIDAL_DE405 (-25.826) /* was (-25.7376) until V. 1.76.2 */ +#define SE_TIDAL_DE406 (-25.826) /* was (-25.7376) until V. 1.76.2 */ #define SE_TIDAL_26 (-26.0) @@ -137,33 +138,33 @@ * earlier content */ -#define PI M_PI /* 3.14159265358979323846, math.h */ +#define PI M_PI /* 3.14159265358979323846, math.h */ #define TWOPI (2.0 * PI) #define ENDMARK -99 #define SEI_EPSILON -2 #define SEI_NUTATION -1 -#define SEI_EMB 0 -#define SEI_EARTH 0 -#define SEI_SUN 0 -#define SEI_MOON 1 -#define SEI_MERCURY 2 -#define SEI_VENUS 3 -#define SEI_MARS 4 -#define SEI_JUPITER 5 -#define SEI_SATURN 6 -#define SEI_URANUS 7 -#define SEI_NEPTUNE 8 -#define SEI_PLUTO 9 -#define SEI_SUNBARY 10 /* barycentric sun */ -#define SEI_ANYBODY 11 /* any asteroid */ -#define SEI_CHIRON 12 -#define SEI_PHOLUS 13 -#define SEI_CERES 14 -#define SEI_PALLAS 15 -#define SEI_JUNO 16 -#define SEI_VESTA 17 +#define SEI_EMB 0 +#define SEI_EARTH 0 +#define SEI_SUN 0 +#define SEI_MOON 1 +#define SEI_MERCURY 2 +#define SEI_VENUS 3 +#define SEI_MARS 4 +#define SEI_JUPITER 5 +#define SEI_SATURN 6 +#define SEI_URANUS 7 +#define SEI_NEPTUNE 8 +#define SEI_PLUTO 9 +#define SEI_SUNBARY 10 /* barycentric sun */ +#define SEI_ANYBODY 11 /* any asteroid */ +#define SEI_CHIRON 12 +#define SEI_PHOLUS 13 +#define SEI_CERES 14 +#define SEI_PALLAS 15 +#define SEI_JUNO 16 +#define SEI_VESTA 17 #define SEI_NPLANETS 18 @@ -179,21 +180,21 @@ #define SEI_FLG_HELIO 1 #define SEI_FLG_ROTATE 2 #define SEI_FLG_ELLIPSE 4 -#define SEI_FLG_EMBHEL 8 /* TRUE, if heliocentric earth is given - * instead of barycentric sun - * i.e. bary sun is computed from - * barycentric and heliocentric earth */ +#define SEI_FLG_EMBHEL 8 /* TRUE, if heliocentric earth is given + * instead of barycentric sun + * i.e. bary sun is computed from + * barycentric and heliocentric earth */ #define SEI_FILE_PLANET 0 -#define SEI_FILE_MOON 1 +#define SEI_FILE_MOON 1 #define SEI_FILE_MAIN_AST 2 #define SEI_FILE_ANY_AST 3 #define SEI_FILE_FIXSTAR 4 #if 0 -#define SEI_FILE_TEST_ENDIAN (97L * 65536L + 98L * 256L + 99L) /*abc*/ +#define SEI_FILE_TEST_ENDIAN (97L * 65536L + 98L * 256L + 99L) /*abc */ #endif -#define SEI_FILE_TEST_ENDIAN (0x616263L) /* abc*/ +#define SEI_FILE_TEST_ENDIAN (0x616263L) /* abc */ #define SEI_FILE_BIGENDIAN 0 #define SEI_FILE_NOREORD 0 #define SEI_FILE_LITENDIAN 1 @@ -212,31 +213,32 @@ * with Saturn. Accepting a maximum error of 5 degrees, * the ephemeris is good between the following dates: */ -#define CHIRON_START 1958470.5 /* 1.1.650 */ -#define CHIRON_END 3419437.5 /* 1.1.4650 */ +#define CHIRON_START 1958470.5 /* 1.1.650 */ +#define CHIRON_END 3419437.5 /* 1.1.4650 */ /* Pholus's orbit is unstable as well, because he sometimes * approaches Saturn. * Accepting a maximum error of 5 degrees, * the ephemeris is good after the following date: */ -#define PHOLUS_START 314845.5 /* 1.1.-3850 */ +#define PHOLUS_START 314845.5 /* 1.1.-3850 */ #define MOSHPLEPH_START 625000.5 #define MOSHPLEPH_END 2818000.5 #define MOSHLUEPH_START 625000.5 #define MOSHLUEPH_END 2818000.5 -#define MOSHNDEPH_START -254900.5 /* 14 Feb -5410 00:00 ET jul.cal.*/ -#define MOSHNDEPH_END 3697000.5 /* 11 Dec 5409 00:00 ET, greg. cal */ +#define MOSHNDEPH_START -254900.5 /* 14 Feb -5410 00:00 ET jul.cal. */ +#define MOSHNDEPH_END 3697000.5 /* 11 Dec 5409 00:00 ET, greg. cal */ + /* #define MOSHPLEPH_START -225000.5 #define MOSHPLEPH_END 3600000.5 #define MOSHLUEPH_START -225000.5 #define MOSHLUEPH_END 3600000.5 */ -#if FALSE /* Alois commented out, not used anywhere */ -#define JPLEPH_START 625307.5 /* about -3000 (DE406) */ -#define JPLEPH_END 2816848.5 /* about 3000 (DE406) */ +#if FALSE /* Alois commented out, not used anywhere */ +#define JPLEPH_START 625307.5 /* about -3000 (DE406) */ +#define JPLEPH_END 2816848.5 /* about 3000 (DE406) */ #define SWIEPH_START 625614.927151 #define SWIEPH_END 2813641.5 #define ALLEPH_START MOSHPLEPH_START @@ -247,7 +249,7 @@ #define MAXORD 40 -#define NCTIES 6.0 /* number of centuries per eph. file */ +#define NCTIES 6.0 /* number of centuries per eph. file */ #define OK (0) #define ERR (-1) @@ -258,48 +260,52 @@ #define J2000_TO_J -1 /* we always use Astronomical Almanac constants, if available */ -#define MOON_MEAN_DIST 384400000.0 /* in m, AA 1996, F2 */ -#define MOON_MEAN_INCL 5.1453964 /* AA 1996, D2 */ -#define MOON_MEAN_ECC 0.054900489 /* AA 1996, F2 */ -/* #define SUN_EARTH_MRAT 328900.561400 Su/(Ea+Mo) AA 2006 K7 */ -#define SUN_EARTH_MRAT 332946.050895 /* Su / (Ea only) AA 2006 K7 */ -#define EARTH_MOON_MRAT (1 / 0.0123000383) /* AA 2006, K7 */ -#if 0 -#define EARTH_MOON_MRAT 81.30056 /* de406 */ -#endif -#define AUNIT 1.49597870691e+11 /* au in meters, AA 2006 K6 */ -#define CLIGHT 2.99792458e+8 /* m/s, AA 1996 K6 */ -#if 0 -#define HELGRAVCONST 1.32712438e+20 /* G * M(sun), m^3/sec^2, AA 1996 K6 */ -#endif -#define HELGRAVCONST 1.32712440017987e+20 /* G * M(sun), m^3/sec^2, AA 2006 K6 */ -#define GEOGCONST 3.98600448e+14 /* G * M(earth) m^3/sec^2, AA 1996 K6 */ -#define KGAUSS 0.01720209895 /* Gaussian gravitational constant K6 */ -#define SUN_RADIUS (959.63 / 3600 * DEGTORAD) /* Meeus germ. p 391 */ -#define EARTH_RADIUS 6378136.6 /* AA 2006 K6 */ -/*#define EARTH_OBLATENESS (1.0/ 298.257223563) * AA 1998 K13 */ -#define EARTH_OBLATENESS (1.0/ 298.25642) /* AA 2006 K6 */ -#define EARTH_ROT_SPEED (7.2921151467e-5 * 86400) /* in rad/day, expl. suppl., p 162 */ +#define MOON_MEAN_DIST 384400000.0 /* in m, AA 1996, F2 */ +#define MOON_MEAN_INCL 5.1453964 /* AA 1996, D2 */ +#define MOON_MEAN_ECC 0.054900489 /* AA 1996, F2 */ -#define LIGHTTIME_AUNIT (499.0047838061/3600/24) /* 8.3167 minutes (days), AA 2006 K6 */ +/* #define SUN_EARTH_MRAT 328900.561400 Su/(Ea+Mo) AA 2006 K7 */ +#define SUN_EARTH_MRAT 332946.050895 /* Su / (Ea only) AA 2006 K7 */ +#define EARTH_MOON_MRAT (1 / 0.0123000383) /* AA 2006, K7 */ +#if 0 +#define EARTH_MOON_MRAT 81.30056 /* de406 */ +#endif +#define AUNIT 1.49597870691e+11 /* au in meters, AA 2006 K6 */ +#define CLIGHT 2.99792458e+8 /* m/s, AA 1996 K6 */ +#if 0 +#define HELGRAVCONST 1.32712438e+20 /* G * M(sun), m^3/sec^2, AA 1996 K6 */ +#endif +#define HELGRAVCONST 1.32712440017987e+20 /* G * M(sun), m^3/sec^2, AA 2006 K6 */ +#define GEOGCONST 3.98600448e+14 /* G * M(earth) m^3/sec^2, AA 1996 K6 */ +#define KGAUSS 0.01720209895 /* Gaussian gravitational constant K6 */ +#define SUN_RADIUS (959.63 / 3600 * DEGTORAD) /* Meeus germ. p 391 */ +#define EARTH_RADIUS 6378136.6 /* AA 2006 K6 */ + +/*#define EARTH_OBLATENESS (1.0/ 298.257223563) * AA 1998 K13 */ +#define EARTH_OBLATENESS (1.0/ 298.25642) /* AA 2006 K6 */ +#define EARTH_ROT_SPEED (7.2921151467e-5 * 86400) /* in rad/day, expl. suppl., p 162 */ + +#define LIGHTTIME_AUNIT (499.0047838061/3600/24) /* 8.3167 minutes (days), AA 2006 K6 */ /* node of ecliptic measured on ecliptic 2000 */ #define SSY_PLANE_NODE_E2000 (107.582569 * DEGTORAD) + /* node of ecliptic measured on solar system rotation plane */ #define SSY_PLANE_NODE (107.58883388 * DEGTORAD) + /* inclination of ecliptic against solar system rotation plane */ #define SSY_PLANE_INCL (1.578701 * DEGTORAD) -#define KM_S_TO_AU_CTY 21.095 /* km/s to AU/century */ -#define MOON_SPEED_INTV 0.00005 /* 4.32 seconds (in days) */ -#define PLAN_SPEED_INTV 0.0001 /* 8.64 seconds (in days) */ -#define MEAN_NODE_SPEED_INTV 0.001 -#define NODE_CALC_INTV 0.0001 -#define NODE_CALC_INTV_MOSH 0.1 +#define KM_S_TO_AU_CTY 21.095 /* km/s to AU/century */ +#define MOON_SPEED_INTV 0.00005 /* 4.32 seconds (in days) */ +#define PLAN_SPEED_INTV 0.0001 /* 8.64 seconds (in days) */ +#define MEAN_NODE_SPEED_INTV 0.001 +#define NODE_CALC_INTV 0.0001 +#define NODE_CALC_INTV_MOSH 0.1 #define NUT_SPEED_INTV 0.0001 #define DEFL_SPEED_INTV 0.0000005 -#define SE_LAPSE_RATE 0.0065 /* deg K / m, for refraction */ +#define SE_LAPSE_RATE 0.0065 /* deg K / m, for refraction */ #define square_sum(x) (x[0]*x[0]+x[1]*x[1]+x[2]*x[2]) #define dot_prod(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2]) @@ -308,25 +314,25 @@ /* planetary radii in meters */ #define NDIAM (SE_VESTA + 1) -static const double pla_diam[NDIAM] = {1392000000.0, /* Sun */ - 3476300.0, /* Moon */ - 2439000.0 * 2, /* Mercury */ - 6052000.0 * 2, /* Venus */ - 3397200.0 * 2, /* Mars */ - 71398000.0 * 2, /* Jupiter */ - 60000000.0 * 2, /* Saturn */ - 25400000.0 * 2, /* Uranus */ - 24300000.0 * 2, /* Neptune */ - 2500000.0 * 2, /* Pluto */ - 0, 0, 0, 0, /* nodes and apogees */ - 6378140.0 * 2, /* Earth */ - 0.0, /* Chiron */ - 0.0, /* Pholus */ - 913000.0, /* Ceres */ - 523000.0, /* Pallas */ - 244000.0, /* Juno */ - 501000.0, /* Vesta */ - }; +static const double pla_diam[NDIAM] = { 1392000000.0, /* Sun */ + 3476300.0, /* Moon */ + 2439000.0 * 2, /* Mercury */ + 6052000.0 * 2, /* Venus */ + 3397200.0 * 2, /* Mars */ + 71398000.0 * 2, /* Jupiter */ + 60000000.0 * 2, /* Saturn */ + 25400000.0 * 2, /* Uranus */ + 24300000.0 * 2, /* Neptune */ + 2500000.0 * 2, /* Pluto */ + 0, 0, 0, 0, /* nodes and apogees */ + 6378140.0 * 2, /* Earth */ + 0.0, /* Chiron */ + 0.0, /* Pholus */ + 913000.0, /* Ceres */ + 523000.0, /* Pallas */ + 244000.0, /* Juno */ + 501000.0, /* Vesta */ +}; /* Ayanamsas @@ -334,13 +340,16 @@ static const double pla_diam[NDIAM] = {1392000000.0, /* Sun */ * t0 epoch of ayanamsa, TDT (ET) * ayan_t0 ayanamsa value at epoch */ -struct aya_init {double t0, ayan_t0;}; +struct aya_init +{ + double t0, ayan_t0; +}; static const struct aya_init ayanamsa[] = { - {2433282.5, 24.042044444}, /* 0: Fagan/Bradley (Default) */ + {2433282.5, 24.042044444}, /* 0: Fagan/Bradley (Default) */ /*{J1900, 360 - 337.53953}, * 1: Lahiri (Robert Hand) */ - {2435553.5, 23.250182778 - 0.004660222}, /* 1: Lahiri (derived from: - * Indian Astronomical Ephemeris 1989, p. 556; - * the subtracted value is nutation) */ + {2435553.5, 23.250182778 - 0.004660222}, /* 1: Lahiri (derived from: + * Indian Astronomical Ephemeris 1989, p. 556; + * the subtracted value is nutation) */ {J1900, 360 - 333.58695}, /* 2: De Luce (Robert Hand) */ {J1900, 360 - 338.98556}, /* 3: Raman (Robert Hand) */ {J1900, 360 - 341.33904}, /* 4: Ushashashi (Robert Hand) */ @@ -360,32 +369,33 @@ static const struct aya_init ayanamsa[] = { {1927135.8747793, 0}, /*16: Sassanian */ /*{1746443.513, 0}, *17: Galactic Center at 0 Sagittarius */ {1746447.518, 0}, /*17: Galactic Center at 0 Sagittarius */ - {J2000, 0}, /*18: J2000 */ - {J1900, 0}, /*19: J1900 */ - {B1950, 0}, /*20: B1950 */ - {1903396.8128654, 0}, /*21: Suryasiddhanta, assuming - ingress of mean Sun into Aries at point - of mean equinox of date on - 21.3.499, noon, Ujjain (75.7684565 E) - = 7:30:31.57 UT */ - {1903396.8128654,-0.21463395},/*22: Suryasiddhanta, assuming - ingress of mean Sun into Aries at - true position of mean Sun at same epoch */ - {1903396.7895321, 0}, /*23: Aryabhata, same date, but UT 6:56:55.57 - analogous 21 */ - {1903396.7895321,-0.23763238},/*24: Aryabhata, analogous 22 */ + {J2000, 0}, /*18: J2000 */ + {J1900, 0}, /*19: J1900 */ + {B1950, 0}, /*20: B1950 */ + {1903396.8128654, 0}, /*21: Suryasiddhanta, assuming + * ingress of mean Sun into Aries at point + * of mean equinox of date on + * 21.3.499, noon, Ujjain (75.7684565 E) + * = 7:30:31.57 UT */ + {1903396.8128654, -0.21463395}, /*22: Suryasiddhanta, assuming + * ingress of mean Sun into Aries at + * true position of mean Sun at same epoch */ + {1903396.7895321, 0}, /*23: Aryabhata, same date, but UT 6:56:55.57 + * analogous 21 */ + {1903396.7895321, -0.23763238}, /*24: Aryabhata, analogous 22 */ {0, 0}, /*25: - */ {0, 0}, /*26: - */ - {0, 0}, /*27: - */ - {0, 0}, /*28: - */ - {0, 0}, /*29: - */ - }; + {0, 0}, /*27: - */ + {0, 0}, /*28: - */ + {0, 0}, /*29: - */ +}; #define PLAN_DATA struct plan_data /* obliquity of ecliptic */ -struct epsilon { - double teps, eps, seps, ceps; /* jd, eps, sin(eps), cos(eps) */ +struct epsilon +{ + double teps, eps, seps, ceps; /* jd, eps, sin(eps), cos(eps) */ }; /* @@ -393,52 +403,53 @@ extern struct epsilon oec2000; extern struct epsilon oec; */ -struct plan_data { - /* the following data are read from file only once, immediately after - * file has been opened */ - int ibdy; /* internal body number */ - int32 iflg; /* contains several bit flags describing the data: - * SEI_FLG_HELIO: true if helio, false if bary - * SEI_FLG_ROTATE: TRUE if coefficients are referred - * to coordinate system of orbital plane - * SEI_FLG_ELLIPSE: TRUE if reference ellipse */ - int ncoe; /* # of coefficients of ephemeris polynomial, - is polynomial order + 1 */ - /* where is the segment index on the file */ - int32 lndx0; /* file position of begin of planet's index */ - int32 nndx; /* number of index entries on file: computed */ - double tfstart; /* file contains ephemeris for tfstart thru tfend */ - double tfend; /* for this particular planet !!! */ - double dseg; /* segment size (days covered by a polynomial) */ - /* orbital elements: */ - double telem; /* epoch of elements */ - double prot; - double qrot; - double dprot; - double dqrot; - double rmax; /* normalisation factor of cheby coefficients */ - /* in addition, if reference ellipse is used: */ - double peri; - double dperi; - double *refep; /* pointer to cheby coeffs of reference ellipse, - * size of data is 2 x ncoe */ - /* unpacked segment information, only updated when a segment is read: */ - double tseg0, tseg1; /* start and end jd of current segment */ - double *segp; /* pointer to unpacked cheby coeffs of segment; - * the size is 3 x ncoe */ - int neval; /* how many coefficients to evaluate. this may - * be less than ncoe */ - /* result of most recent data evaluation for this body: */ - double teval; /* time for which previous computation was made */ - int32 iephe; /* which ephemeris was used */ - double x[6]; /* position and speed vectors equatorial J2000 */ - int32 xflgs; /* hel., light-time, aberr., prec. flags etc. */ - double xreturn[24]; /* return positions: - * xreturn+0 ecliptic polar coordinates - * xreturn+6 ecliptic cartesian coordinates - * xreturn+12 equatorial polar coordinates - * xreturn+18 equatorial cartesian coordinates - */ +struct plan_data +{ + /* the following data are read from file only once, immediately after + * file has been opened */ + int ibdy; /* internal body number */ + int32 iflg; /* contains several bit flags describing the data: + * SEI_FLG_HELIO: true if helio, false if bary + * SEI_FLG_ROTATE: TRUE if coefficients are referred + * to coordinate system of orbital plane + * SEI_FLG_ELLIPSE: TRUE if reference ellipse */ + int ncoe; /* # of coefficients of ephemeris polynomial, + * is polynomial order + 1 */ + /* where is the segment index on the file */ + int32 lndx0; /* file position of begin of planet's index */ + int32 nndx; /* number of index entries on file: computed */ + double tfstart; /* file contains ephemeris for tfstart thru tfend */ + double tfend; /* for this particular planet !!! */ + double dseg; /* segment size (days covered by a polynomial) */ + /* orbital elements: */ + double telem; /* epoch of elements */ + double prot; + double qrot; + double dprot; + double dqrot; + double rmax; /* normalisation factor of cheby coefficients */ + /* in addition, if reference ellipse is used: */ + double peri; + double dperi; + double *refep; /* pointer to cheby coeffs of reference ellipse, + * size of data is 2 x ncoe */ + /* unpacked segment information, only updated when a segment is read: */ + double tseg0, tseg1; /* start and end jd of current segment */ + double *segp; /* pointer to unpacked cheby coeffs of segment; + * the size is 3 x ncoe */ + int neval; /* how many coefficients to evaluate. this may + * be less than ncoe */ + /* result of most recent data evaluation for this body: */ + double teval; /* time for which previous computation was made */ + int32 iephe; /* which ephemeris was used */ + double x[6]; /* position and speed vectors equatorial J2000 */ + int32 xflgs; /* hel., light-time, aberr., prec. flags etc. */ + double xreturn[24]; /* return positions: + * xreturn+0 ecliptic polar coordinates + * xreturn+6 ecliptic cartesian coordinates + * xreturn+12 equatorial polar coordinates + * xreturn+18 equatorial cartesian coordinates + */ }; /* @@ -446,134 +457,141 @@ struct plan_data { * and constants used inside these functions. ************************************************************/ -#define STR 4.8481368110953599359e-6 /* radians per arc second */ +#define STR 4.8481368110953599359e-6 /* radians per arc second */ /* moon, s. moshmoon.c */ extern int swi_mean_node(double jd, double *x, char *serr); extern int swi_mean_apog(double jd, double *x, char *serr); -extern int swi_moshmoon(double tjd, AS_BOOL do_save, double *xpm, char *serr) ; +extern int swi_moshmoon(double tjd, AS_BOOL do_save, double *xpm, char *serr); extern int swi_moshmoon2(double jd, double *x); extern int swi_intp_apsides(double J, double *pol, int ipli); /* planets, s. moshplan.c */ -extern int swi_moshplan(double tjd, int ipli, AS_BOOL do_save, double *xpret, double *xeret, char *serr); +extern int swi_moshplan(double tjd, int ipli, AS_BOOL do_save, double *xpret, + double *xeret, char *serr); extern int swi_moshplan2(double J, int iplm, double *pobj); -extern int swi_osc_el_plan(double tjd, double *xp, int ipl, int ipli, double *xearth, double *xsun, char *serr); +extern int swi_osc_el_plan(double tjd, double *xp, int ipl, int ipli, + double *xearth, double *xsun, char *serr); extern FILE *swi_fopen(int ifno, char *fname, char *ephepath, char *serr); /* nutation */ -struct nut { - double tnut; - double nutlo[2]; /* nutation in longitude and obliquity */ - double snut, cnut; /* sine and cosine of nutation in obliquity */ - double matrix[3][3]; +struct nut +{ + double tnut; + double nutlo[2]; /* nutation in longitude and obliquity */ + double snut, cnut; /* sine and cosine of nutation in obliquity */ + double matrix[3][3]; }; -struct plantbl { - char max_harmonic[9]; - char max_power_of_t; - signed char *arg_tbl; - double *lon_tbl; - double *lat_tbl; - double *rad_tbl; - double distance; +struct plantbl +{ + char max_harmonic[9]; + char max_power_of_t; + signed char *arg_tbl; + double *lon_tbl; + double *lat_tbl; + double *rad_tbl; + double distance; }; -struct file_data { - char fnam[AS_MAXCH]; /* ephemeris file name */ - int fversion; /* version number of file */ - char astnam[50]; /* asteroid name, if asteroid file */ - int32 sweph_denum; /* DE number of JPL ephemeris, which this file - * is derived from. */ - FILE *fptr; /* ephemeris file pointer */ - double tfstart; /* file may be used from this date */ - double tfend; /* through this date */ - int32 iflg; /* byte reorder flag and little/bigendian flag */ - short npl; /* how many planets in file */ - int ipl[SEI_FILE_NMAXPLAN]; /* planet numbers */ -}; - -struct gen_const { - double clight, - aunit, - helgravconst, - ratme, - sunradius; +struct file_data +{ + char fnam[AS_MAXCH]; /* ephemeris file name */ + int fversion; /* version number of file */ + char astnam[50]; /* asteroid name, if asteroid file */ + int32 sweph_denum; /* DE number of JPL ephemeris, which this file + * is derived from. */ + FILE *fptr; /* ephemeris file pointer */ + double tfstart; /* file may be used from this date */ + double tfend; /* through this date */ + int32 iflg; /* byte reorder flag and little/bigendian flag */ + short npl; /* how many planets in file */ + int ipl[SEI_FILE_NMAXPLAN]; /* planet numbers */ }; -struct save_positions { - int ipl; - double tsave; - int32 iflgsave; - /* position at t = tsave, - * in ecliptic polar (offset 0), - * ecliptic cartesian (offset 6), - * equatorial polar (offset 12), - * and equatorial cartesian coordinates (offset 18). - * 6 doubles each for position and speed coordinates. - */ - double xsaves[24]; +struct gen_const +{ + double clight, aunit, helgravconst, ratme, sunradius; }; -struct node_data { - /* result of most recent data evaluation for this body: */ - double teval; /* time for which last computation was made */ - int32 iephe; /* which ephemeris was used */ - double x[6]; /* position and speed vectors equatorial J2000 */ - int32 xflgs; /* hel., light-time, aberr., prec. flags etc. */ - double xreturn[24]; /* return positions: - * xreturn+0 ecliptic polar coordinates - * xreturn+6 ecliptic cartesian coordinates - * xreturn+12 equatorial polar coordinates - * xreturn+18 equatorial cartesian coordinates - */ +struct save_positions +{ + int ipl; + double tsave; + int32 iflgsave; + /* position at t = tsave, + * in ecliptic polar (offset 0), + * ecliptic cartesian (offset 6), + * equatorial polar (offset 12), + * and equatorial cartesian coordinates (offset 18). + * 6 doubles each for position and speed coordinates. + */ + double xsaves[24]; }; -struct topo_data { - double geolon, geolat, geoalt; - double teval; - double tjd_ut; - double xobs[6]; +struct node_data +{ + /* result of most recent data evaluation for this body: */ + double teval; /* time for which last computation was made */ + int32 iephe; /* which ephemeris was used */ + double x[6]; /* position and speed vectors equatorial J2000 */ + int32 xflgs; /* hel., light-time, aberr., prec. flags etc. */ + double xreturn[24]; /* return positions: + * xreturn+0 ecliptic polar coordinates + * xreturn+6 ecliptic cartesian coordinates + * xreturn+12 equatorial polar coordinates + * xreturn+18 equatorial cartesian coordinates + */ }; -struct sid_data { - int32 sid_mode; - double ayan_t0; - double t0; +struct topo_data +{ + double geolon, geolat, geoalt; + double teval; + double tjd_ut; + double xobs[6]; }; -struct swe_data { - AS_BOOL ephe_path_is_set; - short jpl_file_is_open; - FILE *fixfp; /* fixed stars file pointer */ - char ephepath[AS_MAXCH]; - char jplfnam[AS_MAXCH]; - short jpldenum; - AS_BOOL geopos_is_set; - AS_BOOL ayana_is_set; - AS_BOOL is_old_starfile; - struct file_data fidat[SEI_NEPHFILES]; - struct gen_const gcdat; - struct plan_data pldat[SEI_NPLANETS]; +struct sid_data +{ + int32 sid_mode; + double ayan_t0; + double t0; +}; + +struct swe_data +{ + AS_BOOL ephe_path_is_set; + short jpl_file_is_open; + FILE *fixfp; /* fixed stars file pointer */ + char ephepath[AS_MAXCH]; + char jplfnam[AS_MAXCH]; + short jpldenum; + AS_BOOL geopos_is_set; + AS_BOOL ayana_is_set; + AS_BOOL is_old_starfile; + struct file_data fidat[SEI_NEPHFILES]; + struct gen_const gcdat; + struct plan_data pldat[SEI_NPLANETS]; #if 0 - struct node_data nddat[SEI_NNODE_ETC]; + struct node_data nddat[SEI_NNODE_ETC]; #else - struct plan_data nddat[SEI_NNODE_ETC]; + struct plan_data nddat[SEI_NNODE_ETC]; #endif - struct save_positions savedat[SE_NPLANETS+1]; - struct epsilon oec; - struct epsilon oec2000; - struct nut nut; - struct nut nut2000; - struct nut nutv; - struct topo_data topd; - struct sid_data sidd; - char astelem[AS_MAXCH * 2]; - double ast_G; - double ast_H; - double ast_diam; - int i_saved_planet_name; - char saved_planet_name[80]; + struct save_positions savedat[SE_NPLANETS + 1]; + struct epsilon oec; + struct epsilon oec2000; + struct nut nut; + struct nut nut2000; + struct nut nutv; + struct topo_data topd; + struct sid_data sidd; + char astelem[AS_MAXCH * 2]; + double ast_G; + double ast_H; + double ast_diam; + int i_saved_planet_name; + char saved_planet_name[80]; }; extern struct swe_data FAR swed; diff --git a/swe/src/swephexp.h b/swe/src/swephexp.h index 7616b96..b4a00f1 100644 --- a/swe/src/swephexp.h +++ b/swe/src/swephexp.h @@ -1,3 +1,4 @@ + /************************************************************ $Header: /home/dieter/sweph/RCS/swephexp.h,v 1.75 2009/04/08 07:19:08 dieter Exp $ SWISSEPH: exported definitions and constants @@ -19,6 +20,7 @@ Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich ************************************************************/ + /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -74,7 +76,8 @@ */ #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif #ifndef _SWEPHEXP_INCLUDED /* allow multiple #includes of swephexp.h */ @@ -87,46 +90,46 @@ extern "C" { ***********************************************************/ /* values for gregflag in swe_julday() and swe_revjul() */ -# define SE_JUL_CAL 0 -# define SE_GREG_CAL 1 +#define SE_JUL_CAL 0 +#define SE_GREG_CAL 1 /* * planet numbers for the ipl parameter in swe_calc() */ -#define SE_ECL_NUT -1 +#define SE_ECL_NUT -1 -#define SE_SUN 0 -#define SE_MOON 1 -#define SE_MERCURY 2 -#define SE_VENUS 3 -#define SE_MARS 4 -#define SE_JUPITER 5 -#define SE_SATURN 6 -#define SE_URANUS 7 -#define SE_NEPTUNE 8 -#define SE_PLUTO 9 -#define SE_MEAN_NODE 10 +#define SE_SUN 0 +#define SE_MOON 1 +#define SE_MERCURY 2 +#define SE_VENUS 3 +#define SE_MARS 4 +#define SE_JUPITER 5 +#define SE_SATURN 6 +#define SE_URANUS 7 +#define SE_NEPTUNE 8 +#define SE_PLUTO 9 +#define SE_MEAN_NODE 10 #define SE_TRUE_NODE 11 -#define SE_MEAN_APOG 12 -#define SE_OSCU_APOG 13 -#define SE_EARTH 14 -#define SE_CHIRON 15 -#define SE_PHOLUS 16 -#define SE_CERES 17 -#define SE_PALLAS 18 -#define SE_JUNO 19 -#define SE_VESTA 20 -#define SE_INTP_APOG 21 -#define SE_INTP_PERG 22 +#define SE_MEAN_APOG 12 +#define SE_OSCU_APOG 13 +#define SE_EARTH 14 +#define SE_CHIRON 15 +#define SE_PHOLUS 16 +#define SE_CERES 17 +#define SE_PALLAS 18 +#define SE_JUNO 19 +#define SE_VESTA 20 +#define SE_INTP_APOG 21 +#define SE_INTP_PERG 22 -#define SE_NPLANETS 23 +#define SE_NPLANETS 23 #define SE_AST_OFFSET 10000 #define SE_VARUNA (SE_AST_OFFSET + 20000) #define SE_FICT_OFFSET 40 #define SE_FICT_OFFSET_1 39 -#define SE_FICT_MAX 999 +#define SE_FICT_MAX 999 #define SE_NFICT_ELEM 15 #define SE_COMET_OFFSET 1000 @@ -142,6 +145,7 @@ extern "C" { #define SE_ADMETOS 45 #define SE_VULKANUS 46 #define SE_POSEIDON 47 + /* other fictitious bodies */ #define SE_ISIS 48 #define SE_NIBIRU 49 @@ -161,10 +165,10 @@ extern "C" { #define SE_MC 1 #define SE_ARMC 2 #define SE_VERTEX 3 -#define SE_EQUASC 4 /* "equatorial ascendant" */ -#define SE_COASC1 5 /* "co-ascendant" (W. Koch) */ -#define SE_COASC2 6 /* "co-ascendant" (M. Munkasey) */ -#define SE_POLASC 7 /* "polar ascendant" (M. Munkasey) */ +#define SE_EQUASC 4 /* "equatorial ascendant" */ +#define SE_COASC1 5 /* "co-ascendant" (W. Koch) */ +#define SE_COASC2 6 /* "co-ascendant" (M. Munkasey) */ +#define SE_POLASC 7 /* "polar ascendant" (M. Munkasey) */ #define SE_NASCMC 8 /* @@ -183,26 +187,28 @@ extern "C" { #define SEFLG_SWIEPH 2 /* use SWISSEPH ephemeris */ #define SEFLG_MOSEPH 4 /* use Moshier ephemeris */ -#define SEFLG_HELCTR 8 /* return heliocentric position */ -#define SEFLG_TRUEPOS 16 /* return true positions, not apparent */ -#define SEFLG_J2000 32 /* no precession, i.e. give J2000 equinox */ -#define SEFLG_NONUT 64 /* no nutation, i.e. mean equinox of date */ +#define SEFLG_HELCTR 8 /* return heliocentric position */ +#define SEFLG_TRUEPOS 16 /* return true positions, not apparent */ +#define SEFLG_J2000 32 /* no precession, i.e. give J2000 equinox */ +#define SEFLG_NONUT 64 /* no nutation, i.e. mean equinox of date */ #define SEFLG_SPEED3 128 /* speed from 3 positions (do not use it, - SEFLG_SPEED is faster and more precise.) */ + * SEFLG_SPEED is faster and more precise.) */ #define SEFLG_SPEED 256 /* high precision speed */ #define SEFLG_NOGDEFL 512 /* turn off gravitational deflection */ #define SEFLG_NOABERR 1024 /* turn off 'annual' aberration of light */ -#define SEFLG_EQUATORIAL (2*1024) /* equatorial positions are wanted */ -#define SEFLG_XYZ (4*1024) /* cartesian, not polar, coordinates */ -#define SEFLG_RADIANS (8*1024) /* coordinates in radians, not degrees */ -#define SEFLG_BARYCTR (16*1024) /* barycentric positions */ -#define SEFLG_TOPOCTR (32*1024) /* topocentric positions */ -#define SEFLG_SIDEREAL (64*1024) /* sidereal positions */ -#define SEFLG_ICRS (128*1024) /* ICRS (DE406 reference frame) */ +#define SEFLG_EQUATORIAL (2*1024) /* equatorial positions are wanted */ +#define SEFLG_XYZ (4*1024) /* cartesian, not polar, coordinates */ +#define SEFLG_RADIANS (8*1024) /* coordinates in radians, not degrees */ +#define SEFLG_BARYCTR (16*1024) /* barycentric positions */ +#define SEFLG_TOPOCTR (32*1024) /* topocentric positions */ +#define SEFLG_SIDEREAL (64*1024) /* sidereal positions */ +#define SEFLG_ICRS (128*1024) /* ICRS (DE406 reference frame) */ #define SE_SIDBITS 256 + /* for projection onto ecliptic of t0 */ #define SE_SIDBIT_ECL_T0 256 + /* for projection onto solar system plane */ #define SE_SIDBIT_SSY_PLANE 512 @@ -237,19 +243,19 @@ extern "C" { #define SE_NSIDM_PREDEF 27 /* used for swe_nod_aps(): */ -#define SE_NODBIT_MEAN 1 /* mean nodes/apsides */ -#define SE_NODBIT_OSCU 2 /* osculating nodes/apsides */ -#define SE_NODBIT_OSCU_BAR 4 /* same, but motion about solar system barycenter is considered */ -#define SE_NODBIT_FOPOINT 256 /* focal point of orbit instead of aphelion */ +#define SE_NODBIT_MEAN 1 /* mean nodes/apsides */ +#define SE_NODBIT_OSCU 2 /* osculating nodes/apsides */ +#define SE_NODBIT_OSCU_BAR 4 /* same, but motion about solar system barycenter is considered */ +#define SE_NODBIT_FOPOINT 256 /* focal point of orbit instead of aphelion */ /* default ephemeris used when no ephemeris flagbit is set */ #define SEFLG_DEFAULTEPH SEFLG_SWIEPH -#define SE_MAX_STNAME 256 /* maximum size of fixstar name; +#define SE_MAX_STNAME 256 /* maximum size of fixstar name; * the parameter star in swe_fixstar - * must allow twice this space for - * the returned star name. - */ + * must allow twice this space for + * the returned star name. + */ /* defines for eclipse computations */ @@ -268,29 +274,29 @@ extern "C" { #define SE_ECL_2ND_VISIBLE 1024 #define SE_ECL_3RD_VISIBLE 2048 #define SE_ECL_4TH_VISIBLE 4096 -#define SE_ECL_ONE_TRY (32*1024) - /* check if the next conjunction of the moon with - * a planet is an occultation; don't search further */ +#define SE_ECL_ONE_TRY (32*1024) + /* check if the next conjunction of the moon with + * a planet is an occultation; don't search further */ /* for swe_rise_transit() */ #define SE_CALC_RISE 1 #define SE_CALC_SET 2 #define SE_CALC_MTRANSIT 4 #define SE_CALC_ITRANSIT 8 -#define SE_BIT_DISC_CENTER 256 /* to be or'ed to SE_CALC_RISE/SET, - * if rise or set of disc center is - * required */ -#define SE_BIT_DISC_BOTTOM 8192 /* to be or'ed to SE_CALC_RISE/SET, - * if rise or set of lower limb of - * disc is requried */ -#define SE_BIT_NO_REFRACTION 512 /* to be or'ed to SE_CALC_RISE/SET, - * if refraction is to be ignored */ -#define SE_BIT_CIVIL_TWILIGHT 1024 /* to be or'ed to SE_CALC_RISE/SET */ -#define SE_BIT_NAUTIC_TWILIGHT 2048 /* to be or'ed to SE_CALC_RISE/SET */ -#define SE_BIT_ASTRO_TWILIGHT 4096 /* to be or'ed to SE_CALC_RISE/SET */ -#define SE_BIT_FIXED_DISC_SIZE (16*1024) /* or'ed to SE_CALC_RISE/SET: - * neglect the effect of distance on - * disc size */ +#define SE_BIT_DISC_CENTER 256 /* to be or'ed to SE_CALC_RISE/SET, + * if rise or set of disc center is + * required */ +#define SE_BIT_DISC_BOTTOM 8192 /* to be or'ed to SE_CALC_RISE/SET, + * if rise or set of lower limb of + * disc is requried */ +#define SE_BIT_NO_REFRACTION 512 /* to be or'ed to SE_CALC_RISE/SET, + * if refraction is to be ignored */ +#define SE_BIT_CIVIL_TWILIGHT 1024 /* to be or'ed to SE_CALC_RISE/SET */ +#define SE_BIT_NAUTIC_TWILIGHT 2048 /* to be or'ed to SE_CALC_RISE/SET */ +#define SE_BIT_ASTRO_TWILIGHT 4096 /* to be or'ed to SE_CALC_RISE/SET */ +#define SE_BIT_FIXED_DISC_SIZE (16*1024) /* or'ed to SE_CALC_RISE/SET: + * neglect the effect of distance on + * disc size */ /* for swe_azalt() and swe_azalt_rev() */ @@ -330,34 +336,34 @@ extern "C" { #ifndef SE_EPHE_PATH #if MSDOS #ifdef PAIR_SWEPH -# define SE_EPHE_PATH "\\pair\\ephe\\" +#define SE_EPHE_PATH "\\pair\\ephe\\" #else -# define SE_EPHE_PATH "\\sweph\\ephe\\" +#define SE_EPHE_PATH "\\sweph\\ephe\\" #endif #else -# ifdef MACOS -# define SE_EPHE_PATH ":ephe:" -# else -# define SE_EPHE_PATH ".:/users/ephe2/:/users/ephe/" - /* At Astrodienst, we maintain two ephemeris areas for - the thousands of asteroid files: - the short files in /users/ephe/ast*, - the long file in /users/ephe2/ast*. */ -# endif +#ifdef MACOS +#define SE_EPHE_PATH ":ephe:" +#else +#define SE_EPHE_PATH ".:/users/ephe2/:/users/ephe/" + /* At Astrodienst, we maintain two ephemeris areas for + * the thousands of asteroid files: + * the short files in /users/ephe/ast*, + * the long file in /users/ephe2/ast*. */ #endif -#endif /* SE_EPHE_PATH */ +#endif +#endif /* SE_EPHE_PATH */ /* defines for function swe_split_deg() (in swephlib.c) */ -# define SE_SPLIT_DEG_ROUND_SEC 1 -# define SE_SPLIT_DEG_ROUND_MIN 2 -# define SE_SPLIT_DEG_ROUND_DEG 4 -# define SE_SPLIT_DEG_ZODIACAL 8 -# define SE_SPLIT_DEG_KEEP_SIGN 16 /* don't round to next sign, - * e.g. 29.9999999 will be rounded - * to 29d59'59" (or 29d59' or 29d) */ -# define SE_SPLIT_DEG_KEEP_DEG 32 /* don't round to next degree - * e.g. 13.9999999 will be rounded - * to 13d59'59" (or 13d59' or 13d) */ +#define SE_SPLIT_DEG_ROUND_SEC 1 +#define SE_SPLIT_DEG_ROUND_MIN 2 +#define SE_SPLIT_DEG_ROUND_DEG 4 +#define SE_SPLIT_DEG_ZODIACAL 8 +#define SE_SPLIT_DEG_KEEP_SIGN 16 /* don't round to next sign, + * e.g. 29.9999999 will be rounded + * to 29d59'59" (or 29d59' or 29d) */ +#define SE_SPLIT_DEG_KEEP_DEG 32 /* don't round to next degree + * e.g. 13.9999999 will be rounded + * to 13d59'59" (or 13d59' or 13d) */ /* for heliacal functions */ #define SE_HELIACAL_RISING 1 @@ -366,19 +372,19 @@ extern "C" { #define SE_EVENING_LAST SE_HELIACAL_SETTING #define SE_EVENING_FIRST 3 #define SE_MORNING_LAST 4 -#define SE_ACRONYCHAL_RISING 5 /* still not implemented */ -#define SE_ACRONYCHAL_SETTING 6 /* still not implemented */ +#define SE_ACRONYCHAL_RISING 5 /* still not implemented */ +#define SE_ACRONYCHAL_SETTING 6 /* still not implemented */ #define SE_COSMICAL_SETTING SE_ACRONYCHAL_SETTING #define SE_HELFLAG_LONG_SEARCH 128 #define SE_HELFLAG_HIGH_PRECISION 256 #define SE_HELFLAG_OPTICAL_PARAMS 512 #define SE_HELFLAG_NO_DETAILS 1024 -#define SE_HELFLAG_SEARCH_1_PERIOD (1 << 11) /* 2048 */ -#define SE_HELFLAG_VISLIM_DARK (1 << 12) /* 4096 */ -#define SE_HELFLAG_VISLIM_NOMOON (1 << 13) /* 8192 */ -#define SE_HELFLAG_VISLIM_PHOTOPIC (1 << 14) /* 16384 */ -#define SE_HELFLAG_AVKIND_VR (1 << 15) /* 32768 */ +#define SE_HELFLAG_SEARCH_1_PERIOD (1 << 11) /* 2048 */ +#define SE_HELFLAG_VISLIM_DARK (1 << 12) /* 4096 */ +#define SE_HELFLAG_VISLIM_NOMOON (1 << 13) /* 8192 */ +#define SE_HELFLAG_VISLIM_PHOTOPIC (1 << 14) /* 16384 */ +#define SE_HELFLAG_AVKIND_VR (1 << 15) /* 32768 */ #define SE_HELFLAG_AVKIND_PTO (1 << 16) #define SE_HELFLAG_AVKIND_MIN7 (1 << 17) #define SE_HELFLAG_AVKIND_MIN9 (1 << 18) @@ -390,11 +396,11 @@ extern "C" { #define SE_HELIACAL_HIGH_PRECISION 256 #define SE_HELIACAL_OPTICAL_PARAMS 512 #define SE_HELIACAL_NO_DETAILS 1024 -#define SE_HELIACAL_SEARCH_1_PERIOD (1 << 11) /* 2048 */ -#define SE_HELIACAL_VISLIM_DARK (1 << 12) /* 4096 */ -#define SE_HELIACAL_VISLIM_NOMOON (1 << 13) /* 8192 */ -#define SE_HELIACAL_VISLIM_PHOTOPIC (1 << 14) /* 16384 */ -#define SE_HELIACAL_AVKIND_VR (1 << 15) /* 32768 */ +#define SE_HELIACAL_SEARCH_1_PERIOD (1 << 11) /* 2048 */ +#define SE_HELIACAL_VISLIM_DARK (1 << 12) /* 4096 */ +#define SE_HELIACAL_VISLIM_NOMOON (1 << 13) /* 8192 */ +#define SE_HELIACAL_VISLIM_PHOTOPIC (1 << 14) /* 16384 */ +#define SE_HELIACAL_AVKIND_VR (1 << 15) /* 32768 */ #define SE_HELIACAL_AVKIND_PTO (1 << 16) #define SE_HELIACAL_AVKIND_MIN7 (1 << 17) #define SE_HELIACAL_AVKIND_MIN9 (1 << 18) @@ -414,8 +420,8 @@ extern "C" { * The option is called PAIR_SWEPH because it was introduced for * Astrodienst's partner software PAIR. */ -#ifdef PAIR_SWEPH -# define NO_JPL +#ifdef PAIR_SWEPH +#define NO_JPL #endif /************************************************************** @@ -426,60 +432,60 @@ extern "C" { * and skip to the export function decarations below. ************************************************************/ #if defined(MAKE_DLL) || defined(USE_DLL) || defined(_WINDOWS) -# include +#include #endif #ifdef USE_DLL -# include "swedll.h" +#include "swedll.h" #endif #if defined(DOS32) || !MSDOS || defined(WIN32) - /* use compiler switch to define DOS32 */ -# ifndef FAR -# define FAR -# endif -# define MALLOC malloc -# define CALLOC calloc -# define FREE free + /* use compiler switch to define DOS32 */ +#ifndef FAR +#define FAR +#endif +#define MALLOC malloc +#define CALLOC calloc +#define FREE free #else -# ifndef FAR -# define FAR far -# endif -# ifdef __BORLANDC__ -# include -# define MALLOC farmalloc -# define CALLOC farcalloc -# define FREE farfree -# else -# define MALLOC _fmalloc -# define CALLOC _fcalloc -# define FREE _ffree -# endif +#ifndef FAR +#define FAR far +#endif +#ifdef __BORLANDC__ +#include +#define MALLOC farmalloc +#define CALLOC farcalloc +#define FREE farfree +#else +#define MALLOC _fmalloc +#define CALLOC _fcalloc +#define FREE _ffree +#endif #endif /* DLL defines */ #ifdef MAKE_DLL - #if defined (PASCAL) - #define PASCAL_CONV PASCAL - #else - #define PASCAL_CONV - #endif - #ifdef MAKE_DLL16 /* 16bit DLL */ +#if defined (PASCAL) +#define PASCAL_CONV PASCAL +#else +#define PASCAL_CONV +#endif +#ifdef MAKE_DLL16 /* 16bit DLL */ /* We compiled the 16bit DLL for Windows 3.x using Borland C/C++ Ver:3.x - and the -WD or -WDE compiler switch. */ - #define EXP16 __export - #define EXP32 - #else /* 32bit DLL */ + * and the -WD or -WDE compiler switch. */ +#define EXP16 __export +#define EXP32 +#else /* 32bit DLL */ /* To export symbols in the new DLL model of Win32, Microsoft - recommends the following approach */ - #define EXP16 - #define EXP32 __declspec( dllexport ) - #endif -#else - #define PASCAL_CONV - #define EXP16 - #define EXP32 -#endif + * recommends the following approach */ +#define EXP16 +#define EXP32 __declspec( dllexport ) +#endif +#else +#define PASCAL_CONV +#define EXP16 +#define EXP32 +#endif #ifndef _SWEDLL_H @@ -488,221 +494,240 @@ extern "C" { ***********************************************************/ #define ext_def(x) extern EXP32 x FAR PASCAL_CONV EXP16 - /* ext_def(x) evaluates to x on Unix */ + /* ext_def(x) evaluates to x on Unix */ + + ext_def(int32) swe_heliacal_ut(double tjdstart_ut, double *geopos, + double *datm, double *dobs, + char *ObjectName, int32 TypeEvent, + int32 iflag, double *dret, char *serr); + ext_def(int32) swe_heliacal_pheno_ut(double tjd_ut, double *geopos, + double *datm, double *dobs, + char *ObjectName, int32 TypeEvent, + int32 helflag, double *darr, + char *serr); + ext_def(int32) swe_vis_limit_mag(double tjdut, double *geopos, + double *datm, double *dobs, + char *ObjectName, int32 helflag, + double *dret, char *serr); -ext_def(int32) swe_heliacal_ut(double tjdstart_ut, double *geopos, double *datm, double *dobs, char *ObjectName, int32 TypeEvent, int32 iflag, double *dret, char *serr); -ext_def(int32) swe_heliacal_pheno_ut(double tjd_ut, double *geopos, double *datm, double *dobs, char *ObjectName, int32 TypeEvent, int32 helflag, double *darr, char *serr); -ext_def(int32) swe_vis_limit_mag(double tjdut, double *geopos, double *datm, double *dobs, char *ObjectName, int32 helflag, double *dret, char *serr); /* the following are secret, for Victor Reijs' */ -ext_def(int32) swe_heliacal_angle(double tjdut, double *dgeo, double *datm, double *dobs, int32 helflag, double mag, double azi_obj, double azi_sun, double azi_moon, double alt_moon, double *dret, char *serr); -ext_def(int32) swe_topo_arcus_visionis(double tjdut, double *dgeo, double *datm, double *dobs, int32 helflag, double mag, double azi_obj, double alt_obj, double azi_sun, double azi_moon, double alt_moon, double *dret, char *serr); + ext_def(int32) swe_heliacal_angle(double tjdut, double *dgeo, + double *datm, double *dobs, + int32 helflag, double mag, + double azi_obj, double azi_sun, + double azi_moon, double alt_moon, + double *dret, char *serr); + ext_def(int32) swe_topo_arcus_visionis(double tjdut, double *dgeo, + double *datm, double *dobs, + int32 helflag, double mag, + double azi_obj, double alt_obj, + double azi_sun, double azi_moon, + double alt_moon, double *dret, + char *serr); /**************************** * exports from sweph.c ****************************/ -ext_def(char *) swe_version(char *); + ext_def(char *) swe_version(char *); /* planets, moon, nodes etc. */ -ext_def( int32 ) swe_calc( - double tjd, int ipl, int32 iflag, - double *xx, - char *serr); + ext_def(int32) swe_calc(double tjd, int ipl, int32 iflag, double *xx, + char *serr); -ext_def(int32) swe_calc_ut(double tjd_ut, int32 ipl, int32 iflag, - double *xx, char *serr); + ext_def(int32) swe_calc_ut(double tjd_ut, int32 ipl, int32 iflag, + double *xx, char *serr); /* fixed stars */ -ext_def( int32 ) swe_fixstar( - char *star, double tjd, int32 iflag, - double *xx, - char *serr); + ext_def(int32) swe_fixstar(char *star, double tjd, int32 iflag, + double *xx, char *serr); -ext_def(int32) swe_fixstar_ut(char *star, double tjd_ut, int32 iflag, - double *xx, char *serr); + ext_def(int32) swe_fixstar_ut(char *star, double tjd_ut, int32 iflag, + double *xx, char *serr); -ext_def(int32) swe_fixstar_mag(char *star, double *mag, char *serr); + ext_def(int32) swe_fixstar_mag(char *star, double *mag, char *serr); /* close Swiss Ephemeris */ -ext_def( void ) swe_close(void); + ext_def(void) swe_close(void); /* set directory path of ephemeris files */ -ext_def( void ) swe_set_ephe_path(char *path); + ext_def(void) swe_set_ephe_path(char *path); /* set file name of JPL file */ -ext_def( void ) swe_set_jpl_file(char *fname); + ext_def(void) swe_set_jpl_file(char *fname); /* get planet name */ -ext_def( char *) swe_get_planet_name(int ipl, char *spname); + ext_def(char *) swe_get_planet_name(int ipl, char *spname); /* set geographic position of observer */ -ext_def (void) swe_set_topo(double geolon, double geolat, double geoalt); + ext_def(void) swe_set_topo(double geolon, double geolat, double geoalt); /* set sidereal mode */ -ext_def(void) swe_set_sid_mode(int32 sid_mode, double t0, double ayan_t0); + ext_def(void) swe_set_sid_mode(int32 sid_mode, double t0, + double ayan_t0); /* get ayanamsa */ -ext_def(double) swe_get_ayanamsa(double tjd_et); + ext_def(double) swe_get_ayanamsa(double tjd_et); -ext_def(double) swe_get_ayanamsa_ut(double tjd_ut); + ext_def(double) swe_get_ayanamsa_ut(double tjd_ut); -ext_def( char *) swe_get_ayanamsa_name(int32 isidmode); + ext_def(char *) swe_get_ayanamsa_name(int32 isidmode); /**************************** * exports from swedate.c ****************************/ -ext_def( int ) swe_date_conversion( - int y , int m , int d , /* year, month, day */ - double utime, /* universal time in hours (decimal) */ - char c, /* calendar g[regorian]|j[ulian] */ - double *tjd); + ext_def(int) swe_date_conversion(int y, int m, int d, /* year, month, day */ + double utime, /* universal time in hours (decimal) */ + char c, /* calendar g[regorian]|j[ulian] */ + double *tjd); -ext_def( double ) swe_julday( - int year, int month, int day, double hour, - int gregflag); + ext_def(double) swe_julday(int year, int month, int day, double hour, + int gregflag); -ext_def( void ) swe_revjul ( - double jd, - int gregflag, - int *jyear, int *jmon, int *jday, double *jut); + ext_def(void) swe_revjul(double jd, int gregflag, int *jyear, int *jmon, + int *jday, double *jut); -ext_def(int32) swe_utc_to_jd( - int32 iyear, int32 imonth, int32 iday, - int32 ihour, int32 imin, double dsec, - int32 gregflag, double *dret, char *serr); + ext_def(int32) swe_utc_to_jd(int32 iyear, int32 imonth, int32 iday, + int32 ihour, int32 imin, double dsec, + int32 gregflag, double *dret, char *serr); -ext_def(void) swe_jdet_to_utc( - double tjd_et, int32 gregflag, - int32 *iyear, int32 *imonth, int32 *iday, - int32 *ihour, int32 *imin, double *dsec); + ext_def(void) swe_jdet_to_utc(double tjd_et, int32 gregflag, + int32 * iyear, int32 * imonth, + int32 * iday, int32 * ihour, int32 * imin, + double *dsec); -ext_def(void) swe_jdut1_to_utc( - double tjd_ut, int32 gregflag, - int32 *iyear, int32 *imonth, int32 *iday, - int32 *ihour, int32 *imin, double *dsec); + ext_def(void) swe_jdut1_to_utc(double tjd_ut, int32 gregflag, + int32 * iyear, int32 * imonth, + int32 * iday, int32 * ihour, + int32 * imin, double *dsec); -ext_def(void) swe_utc_time_zone( - int32 iyear, int32 imonth, int32 iday, - int32 ihour, int32 imin, double dsec, - double d_timezone, - int32 *iyear_out, int32 *imonth_out, int32 *iday_out, - int32 *ihour_out, int32 *imin_out, double *dsec_out); + ext_def(void) swe_utc_time_zone(int32 iyear, int32 imonth, int32 iday, + int32 ihour, int32 imin, double dsec, + double d_timezone, int32 * iyear_out, + int32 * imonth_out, int32 * iday_out, + int32 * ihour_out, int32 * imin_out, + double *dsec_out); /**************************** * exports from swehouse.c ****************************/ -ext_def( int ) swe_houses( - double tjd_ut, double geolat, double geolon, int hsys, - double *cusps, double *ascmc); + ext_def(int) swe_houses(double tjd_ut, double geolat, double geolon, + int hsys, double *cusps, double *ascmc); -ext_def( int ) swe_houses_ex( - double tjd_ut, int32 iflag, double geolat, double geolon, int hsys, - double *cusps, double *ascmc); + ext_def(int) swe_houses_ex(double tjd_ut, int32 iflag, double geolat, + double geolon, int hsys, double *cusps, + double *ascmc); -ext_def( int ) swe_houses_armc( - double armc, double geolat, double eps, int hsys, - double *cusps, double *ascmc); + ext_def(int) swe_houses_armc(double armc, double geolat, double eps, + int hsys, double *cusps, double *ascmc); -ext_def(double) swe_house_pos( - double armc, double geolat, double eps, int hsys, double *xpin, char *serr); + ext_def(double) swe_house_pos(double armc, double geolat, double eps, + int hsys, double *xpin, char *serr); /**************************** * exports from swecl.c ****************************/ -ext_def(int32) swe_gauquelin_sector(double t_ut, int32 ipl, char *starname, int32 iflag, int32 imeth, double *geopos, double atpress, double attemp, double *dgsect, char *serr); + ext_def(int32) swe_gauquelin_sector(double t_ut, int32 ipl, + char *starname, int32 iflag, + int32 imeth, double *geopos, + double atpress, double attemp, + double *dgsect, char *serr); /* computes geographic location and attributes of solar * eclipse at a given tjd */ -ext_def (int32) swe_sol_eclipse_where(double tjd, int32 ifl, double *geopos, double *attr, char *serr); + ext_def(int32) swe_sol_eclipse_where(double tjd, int32 ifl, + double *geopos, double *attr, + char *serr); -ext_def (int32) swe_lun_occult_where(double tjd, int32 ipl, char *starname, int32 ifl, double *geopos, double *attr, char *serr); + ext_def(int32) swe_lun_occult_where(double tjd, int32 ipl, + char *starname, int32 ifl, + double *geopos, double *attr, + char *serr); /* computes attributes of a solar eclipse for given tjd, geolon, geolat */ -ext_def (int32) swe_sol_eclipse_how(double tjd, int32 ifl, double *geopos, double *attr, char *serr); + ext_def(int32) swe_sol_eclipse_how(double tjd, int32 ifl, + double *geopos, double *attr, + char *serr); /* finds time of next local eclipse */ -ext_def (int32) swe_sol_eclipse_when_loc(double tjd_start, int32 ifl, double *geopos, double *tret, double *attr, int32 backward, char *serr); + ext_def(int32) swe_sol_eclipse_when_loc(double tjd_start, int32 ifl, + double *geopos, double *tret, + double *attr, int32 backward, + char *serr); -ext_def (int32) swe_lun_occult_when_loc(double tjd_start, int32 ipl, char *starname, int32 ifl, - double *geopos, double *tret, double *attr, int32 backward, char *serr); + ext_def(int32) swe_lun_occult_when_loc(double tjd_start, int32 ipl, + char *starname, int32 ifl, + double *geopos, double *tret, + double *attr, int32 backward, + char *serr); /* finds time of next eclipse globally */ -ext_def (int32) swe_sol_eclipse_when_glob(double tjd_start, int32 ifl, int32 ifltype, - double *tret, int32 backward, char *serr); + ext_def(int32) swe_sol_eclipse_when_glob(double tjd_start, int32 ifl, + int32 ifltype, double *tret, + int32 backward, char *serr); /* finds time of next occultation globally */ -ext_def (int32) swe_lun_occult_when_glob(double tjd_start, int32 ipl, char *starname, int32 ifl, int32 ifltype, - double *tret, int32 backward, char *serr); + ext_def(int32) swe_lun_occult_when_glob(double tjd_start, int32 ipl, + char *starname, int32 ifl, + int32 ifltype, double *tret, + int32 backward, char *serr); /* computes attributes of a lunar eclipse for given tjd */ -ext_def (int32) swe_lun_eclipse_how( - double tjd_ut, - int32 ifl, - double *geopos, - double *attr, - char *serr); + ext_def(int32) swe_lun_eclipse_how(double tjd_ut, int32 ifl, + double *geopos, double *attr, + char *serr); -ext_def (int32) swe_lun_eclipse_when(double tjd_start, int32 ifl, int32 ifltype, - double *tret, int32 backward, char *serr); + ext_def(int32) swe_lun_eclipse_when(double tjd_start, int32 ifl, + int32 ifltype, double *tret, + int32 backward, char *serr); /* planetary phenomena */ -ext_def (int32) swe_pheno(double tjd, int32 ipl, int32 iflag, double *attr, char *serr); - -ext_def(int32) swe_pheno_ut(double tjd_ut, int32 ipl, int32 iflag, double *attr, char *serr); + ext_def(int32) swe_pheno(double tjd, int32 ipl, int32 iflag, + double *attr, char *serr); -ext_def (double) swe_refrac(double inalt, double atpress, double attemp, int32 calc_flag); + ext_def(int32) swe_pheno_ut(double tjd_ut, int32 ipl, int32 iflag, + double *attr, char *serr); -ext_def (double) swe_refrac_extended(double inalt, double geoalt, double atpress, double attemp, double lapse_rate, int32 calc_flag, double *dret); + ext_def(double) swe_refrac(double inalt, double atpress, double attemp, + int32 calc_flag); -ext_def (void) swe_set_lapse_rate(double lapse_rate); + ext_def(double) swe_refrac_extended(double inalt, double geoalt, + double atpress, double attemp, + double lapse_rate, int32 calc_flag, + double *dret); -ext_def (void) swe_azalt( - double tjd_ut, - int32 calc_flag, - double *geopos, - double atpress, - double attemp, - double *xin, - double *xaz); + ext_def(void) swe_set_lapse_rate(double lapse_rate); -ext_def (void) swe_azalt_rev( - double tjd_ut, - int32 calc_flag, - double *geopos, - double *xin, - double *xout); + ext_def(void) swe_azalt(double tjd_ut, int32 calc_flag, double *geopos, + double atpress, double attemp, double *xin, + double *xaz); -ext_def (int32) swe_rise_trans_true_hor( - double tjd_ut, int32 ipl, char *starname, - int32 epheflag, int32 rsmi, - double *geopos, - double atpress, double attemp, - double horhgt, - double *tret, - char *serr); + ext_def(void) swe_azalt_rev(double tjd_ut, int32 calc_flag, + double *geopos, double *xin, double *xout); -ext_def (int32) swe_rise_trans( - double tjd_ut, int32 ipl, char *starname, - int32 epheflag, int32 rsmi, - double *geopos, - double atpress, double attemp, - double *tret, - char *serr); + ext_def(int32) swe_rise_trans_true_hor(double tjd_ut, int32 ipl, + char *starname, int32 epheflag, + int32 rsmi, double *geopos, + double atpress, double attemp, + double horhgt, double *tret, + char *serr); -ext_def (int32) swe_nod_aps(double tjd_et, int32 ipl, int32 iflag, - int32 method, - double *xnasc, double *xndsc, - double *xperi, double *xaphe, - char *serr); + ext_def(int32) swe_rise_trans(double tjd_ut, int32 ipl, char *starname, + int32 epheflag, int32 rsmi, + double *geopos, double atpress, + double attemp, double *tret, char *serr); -ext_def (int32) swe_nod_aps_ut(double tjd_ut, int32 ipl, int32 iflag, - int32 method, - double *xnasc, double *xndsc, - double *xperi, double *xaphe, - char *serr); + ext_def(int32) swe_nod_aps(double tjd_et, int32 ipl, int32 iflag, + int32 method, double *xnasc, double *xndsc, + double *xperi, double *xaphe, char *serr); + + ext_def(int32) swe_nod_aps_ut(double tjd_ut, int32 ipl, int32 iflag, + int32 method, double *xnasc, + double *xndsc, double *xperi, + double *xaphe, char *serr); /**************************** @@ -710,29 +735,31 @@ ext_def (int32) swe_nod_aps_ut(double tjd_ut, int32 ipl, int32 iflag, ****************************/ /* delta t */ -ext_def( double ) swe_deltat(double tjd); + ext_def(double) swe_deltat(double tjd); /* equation of time */ -ext_def( int ) swe_time_equ(double tjd, double *te, char *serr); + ext_def(int) swe_time_equ(double tjd, double *te, char *serr); /* sidereal time */ -ext_def( double ) swe_sidtime0(double tjd_ut, double eps, double nut); -ext_def( double ) swe_sidtime(double tjd_ut); + ext_def(double) swe_sidtime0(double tjd_ut, double eps, double nut); + ext_def(double) swe_sidtime(double tjd_ut); /* coordinate transformation polar -> polar */ -ext_def( void ) swe_cotrans(double *xpo, double *xpn, double eps); -ext_def( void ) swe_cotrans_sp(double *xpo, double *xpn, double eps); + ext_def(void) swe_cotrans(double *xpo, double *xpn, double eps); + ext_def(void) swe_cotrans_sp(double *xpo, double *xpn, double eps); /* tidal acceleration to be used in swe_deltat() */ -ext_def( double ) swe_get_tid_acc(void); -ext_def( void ) swe_set_tid_acc(double t_acc); + ext_def(double) swe_get_tid_acc(void); + ext_def(void) swe_set_tid_acc(double t_acc); -ext_def( double ) swe_degnorm(double x); -ext_def( double ) swe_radnorm(double x); -ext_def( double ) swe_rad_midp(double x1, double x0); -ext_def( double ) swe_deg_midp(double x1, double x0); + ext_def(double) swe_degnorm(double x); + ext_def(double) swe_radnorm(double x); + ext_def(double) swe_rad_midp(double x1, double x0); + ext_def(double) swe_deg_midp(double x1, double x0); -ext_def( void ) swe_split_deg(double ddeg, int32 roundflag, int32 *ideg, int32 *imin, int32 *isec, double *dsecfr, int32 *isgn); + ext_def(void) swe_split_deg(double ddeg, int32 roundflag, int32 * ideg, + int32 * imin, int32 * isec, double *dsecfr, + int32 * isgn); /******************************************************* * other functions from swephlib.c; @@ -741,38 +768,40 @@ ext_def( void ) swe_split_deg(double ddeg, int32 roundflag, int32 *ideg, int32 * ********************************************************/ /* normalize argument into interval [0..DEG360] */ -ext_def( centisec ) swe_csnorm(centisec p); + ext_def(centisec) swe_csnorm(centisec p); /* distance in centisecs p1 - p2 normalized to [0..360[ */ -ext_def( centisec ) swe_difcsn (centisec p1, centisec p2); + ext_def(centisec) swe_difcsn(centisec p1, centisec p2); -ext_def( double ) swe_difdegn (double p1, double p2); + ext_def(double) swe_difdegn(double p1, double p2); /* distance in centisecs p1 - p2 normalized to [-180..180[ */ -ext_def( centisec ) swe_difcs2n(centisec p1, centisec p2); + ext_def(centisec) swe_difcs2n(centisec p1, centisec p2); -ext_def( double ) swe_difdeg2n(double p1, double p2); -ext_def( double ) swe_difrad2n(double p1, double p2); + ext_def(double) swe_difdeg2n(double p1, double p2); + ext_def(double) swe_difrad2n(double p1, double p2); /* round second, but at 29.5959 always down */ -ext_def( centisec ) swe_csroundsec(centisec x); + ext_def(centisec) swe_csroundsec(centisec x); /* double to int32 with rounding, no overflow check */ -ext_def( int32 ) swe_d2l(double x); + ext_def(int32) swe_d2l(double x); /* monday = 0, ... sunday = 6 */ -ext_def( int ) swe_day_of_week(double jd); + ext_def(int) swe_day_of_week(double jd); -ext_def( char *) swe_cs2timestr(CSEC t, int sep, AS_BOOL suppressZero, char *a); + ext_def(char *) swe_cs2timestr(CSEC t, int sep, AS_BOOL suppressZero, + char *a); -ext_def( char *) swe_cs2lonlatstr(CSEC t, char pchar, char mchar, char *s); + ext_def(char *) swe_cs2lonlatstr(CSEC t, char pchar, char mchar, + char *s); -ext_def( char *) swe_cs2degstr(CSEC t, char *a); + ext_def(char *) swe_cs2degstr(CSEC t, char *a); -#endif /* #ifndef _SWEDLL_H */ +#endif /* #ifndef _SWEDLL_H */ -#endif /* #ifndef _SWEPHEXP_INCLUDED */ +#endif /* #ifndef _SWEPHEXP_INCLUDED */ #ifdef __cplusplus -} /* extern C */ +} /* extern C */ #endif diff --git a/swe/src/swephlib.c b/swe/src/swephlib.c index 438bd52..c8bcb7a 100644 --- a/swe/src/swephlib.c +++ b/swe/src/swephlib.c @@ -20,6 +20,7 @@ modulo and normalization functions **************************************************************/ + /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -80,7 +81,7 @@ #include "sweph.h" #include "swephlib.h" #if MSDOS -# include +#include #endif #ifdef TRACE @@ -99,117 +100,131 @@ static double deltat_espenak_meeus_1620(double tjd); static double deltat_longterm_morrison_stephenson(double tjd); static double deltat_stephenson_morrison_1600(double tjd); static double deltat_aa(double tjd); -static int precess0(double *R, double J, int direction ); +static int precess0(double *R, double J, int direction); /* Reduce x modulo 360 degrees */ -double FAR PASCAL_CONV swe_degnorm(double x) +double FAR PASCAL_CONV +swe_degnorm(double x) { - double y; - y = fmod(x, 360.0); - if (fabs(y) < 1e-13) y = 0; /* Alois fix 11-dec-1999 */ - if( y < 0.0 ) y += 360.0; - return(y); + double y; + y = fmod(x, 360.0); + if (fabs(y) < 1e-13) + y = 0; /* Alois fix 11-dec-1999 */ + if (y < 0.0) + y += 360.0; + return (y); } /* Reduce x modulo TWOPI degrees */ -double FAR PASCAL_CONV swe_radnorm(double x) +double FAR PASCAL_CONV +swe_radnorm(double x) { - double y; - y = fmod(x, TWOPI); - if (fabs(y) < 1e-13) y = 0; /* Alois fix 11-dec-1999 */ - if( y < 0.0 ) y += TWOPI; - return(y); + double y; + y = fmod(x, TWOPI); + if (fabs(y) < 1e-13) + y = 0; /* Alois fix 11-dec-1999 */ + if (y < 0.0) + y += TWOPI; + return (y); } -double FAR PASCAL_CONV swe_deg_midp(double x1, double x0) +double FAR PASCAL_CONV +swe_deg_midp(double x1, double x0) { - double d, y; - d = swe_difdeg2n(x1, x0); /* arc from x0 to x1 */ - y = swe_degnorm(x0 + d / 2); - return(y); + double d, y; + d = swe_difdeg2n(x1, x0); /* arc from x0 to x1 */ + y = swe_degnorm(x0 + d / 2); + return (y); } -double FAR PASCAL_CONV swe_rad_midp(double x1, double x0) +double FAR PASCAL_CONV +swe_rad_midp(double x1, double x0) { - return DEGTORAD * swe_deg_midp(x1 * RADTODEG, x0 * RADTODEG); + return DEGTORAD * swe_deg_midp(x1 * RADTODEG, x0 * RADTODEG); } /* Reduce x modulo 2*PI */ -double swi_mod2PI(double x) +double +swi_mod2PI(double x) { - double y; - y = fmod(x, TWOPI); - if( y < 0.0 ) y += TWOPI; - return(y); + double y; + y = fmod(x, TWOPI); + if (y < 0.0) + y += TWOPI; + return (y); } -double swi_angnorm(double x) +double +swi_angnorm(double x) { - if (x < 0.0 ) - return x + TWOPI; - else if (x >= TWOPI) - return x - TWOPI; - else - return x; + if (x < 0.0) + return x + TWOPI; + else if (x >= TWOPI) + return x - TWOPI; + else + return x; } -void swi_cross_prod(double *a, double *b, double *x) +void +swi_cross_prod(double *a, double *b, double *x) { - x[0] = a[1]*b[2] - a[2]*b[1]; - x[1] = a[2]*b[0] - a[0]*b[2]; - x[2] = a[0]*b[1] - a[1]*b[0]; + x[0] = a[1] * b[2] - a[2] * b[1]; + x[1] = a[2] * b[0] - a[0] * b[2]; + x[2] = a[0] * b[1] - a[1] * b[0]; } /* Evaluates a given chebyshev series coef[0..ncf-1] * with ncf terms at x in [-1,1]. Communications of the ACM, algorithm 446, * April 1973 (vol. 16 no.4) by Dr. Roger Broucke. */ -double swi_echeb(double x, double *coef, int ncf) +double +swi_echeb(double x, double *coef, int ncf) { - int j; - double x2, br, brp2, brpp; - x2 = x * 2.; - br = 0.; - brp2 = 0.; /* dummy assign to silence gcc warning */ - brpp = 0.; - for (j = ncf - 1; j >= 0; j--) { - brp2 = brpp; - brpp = br; - br = x2 * brpp - brp2 + coef[j]; - } - return (br - brp2) * .5; + int j; + double x2, br, brp2, brpp; + x2 = x * 2.; + br = 0.; + brp2 = 0.; /* dummy assign to silence gcc warning */ + brpp = 0.; + for (j = ncf - 1; j >= 0; j--) { + brp2 = brpp; + brpp = br; + br = x2 * brpp - brp2 + coef[j]; + } + return (br - brp2) * .5; } /* * evaluates derivative of chebyshev series, see echeb */ -double swi_edcheb(double x, double *coef, int ncf) +double +swi_edcheb(double x, double *coef, int ncf) { - double bjpl, xjpl; - int j; - double x2, bf, bj, dj, xj, bjp2, xjp2; - x2 = x * 2.; - bf = 0.; /* dummy assign to silence gcc warning */ - bj = 0.; /* dummy assign to silence gcc warning */ - xjp2 = 0.; - xjpl = 0.; - bjp2 = 0.; - bjpl = 0.; - for (j = ncf - 1; j >= 1; j--) { - dj = (double) (j + j); - xj = coef[j] * dj + xjp2; - bj = x2 * bjpl - bjp2 + xj; - bf = bjp2; - bjp2 = bjpl; - bjpl = bj; - xjp2 = xjpl; - xjpl = xj; - } - return (bj - bf) * .5; + double bjpl, xjpl; + int j; + double x2, bf, bj, dj, xj, bjp2, xjp2; + x2 = x * 2.; + bf = 0.; /* dummy assign to silence gcc warning */ + bj = 0.; /* dummy assign to silence gcc warning */ + xjp2 = 0.; + xjpl = 0.; + bjp2 = 0.; + bjpl = 0.; + for (j = ncf - 1; j >= 1; j--) { + dj = (double)(j + j); + xj = coef[j] * dj + xjp2; + bj = x2 * bjpl - bjp2 + xj; + bf = bjp2; + bjp2 = bjpl; + bjpl = bj; + xjp2 = xjpl; + xjpl = xj; + } + return (bj - bf) * .5; } /* @@ -220,23 +235,24 @@ double swi_edcheb(double x, double *coef, int ncf) * xpo, xpn are arrays of 3 doubles containing position. * attention: input must be in degrees! */ -void FAR PASCAL_CONV swe_cotrans(double *xpo, double *xpn, double eps) +void FAR PASCAL_CONV +swe_cotrans(double *xpo, double *xpn, double eps) { - int i; - double x[6], e = eps * DEGTORAD; - for(i = 0; i <= 1; i++) - x[i] = xpo[i]; - x[0] *= DEGTORAD; - x[1] *= DEGTORAD; - x[2] = 1; - for(i = 3; i <= 5; i++) - x[i] = 0; - swi_polcart(x, x); - swi_coortrf(x, x, e); - swi_cartpol(x, x); - xpn[0] = x[0] * RADTODEG; - xpn[1] = x[1] * RADTODEG; - xpn[2] = xpo[2]; + int i; + double x[6], e = eps * DEGTORAD; + for (i = 0; i <= 1; i++) + x[i] = xpo[i]; + x[0] *= DEGTORAD; + x[1] *= DEGTORAD; + x[2] = 1; + for (i = 3; i <= 5; i++) + x[i] = 0; + swi_polcart(x, x); + swi_coortrf(x, x, e); + swi_cartpol(x, x); + xpn[0] = x[0] * RADTODEG; + xpn[1] = x[1] * RADTODEG; + xpn[2] = xpo[2]; } /* @@ -248,27 +264,28 @@ void FAR PASCAL_CONV swe_cotrans(double *xpo, double *xpn, double eps) * xpo, xpn are arrays of 6 doubles containing position and speed. * attention: input must be in degrees! */ -void FAR PASCAL_CONV swe_cotrans_sp(double *xpo, double *xpn, double eps) +void FAR PASCAL_CONV +swe_cotrans_sp(double *xpo, double *xpn, double eps) { - int i; - double x[6], e = eps * DEGTORAD; - for (i = 0; i <= 5; i++) - x[i] = xpo[i]; - x[0] *= DEGTORAD; - x[1] *= DEGTORAD; - x[2] = 1; /* avoids problems with polcart(), if x[2] = 0 */ - x[3] *= DEGTORAD; - x[4] *= DEGTORAD; - swi_polcart_sp(x, x); - swi_coortrf(x, x, e); - swi_coortrf(x+3, x+3, e); - swi_cartpol_sp(x, xpn); - xpn[0] *= RADTODEG; - xpn[1] *= RADTODEG; - xpn[2] = xpo[2]; - xpn[3] *= RADTODEG; - xpn[4] *= RADTODEG; - xpn[5] = xpo[5]; + int i; + double x[6], e = eps * DEGTORAD; + for (i = 0; i <= 5; i++) + x[i] = xpo[i]; + x[0] *= DEGTORAD; + x[1] *= DEGTORAD; + x[2] = 1; /* avoids problems with polcart(), if x[2] = 0 */ + x[3] *= DEGTORAD; + x[4] *= DEGTORAD; + swi_polcart_sp(x, x); + swi_coortrf(x, x, e); + swi_coortrf(x + 3, x + 3, e); + swi_cartpol_sp(x, xpn); + xpn[0] *= RADTODEG; + xpn[1] *= RADTODEG; + xpn[2] = xpo[2]; + xpn[3] *= RADTODEG; + xpn[4] *= RADTODEG; + xpn[5] = xpo[5]; } /* @@ -276,18 +293,19 @@ void FAR PASCAL_CONV swe_cotrans_sp(double *xpo, double *xpn, double eps) * for ecl. to equ. eps must be negative * for equ. to ecl. eps must be positive */ -void swi_coortrf(double *xpo, double *xpn, double eps) +void +swi_coortrf(double *xpo, double *xpn, double eps) { - double sineps, coseps; - double x[3]; - sineps = sin(eps); - coseps = cos(eps); - x[0] = xpo[0]; - x[1] = xpo[1] * coseps + xpo[2] * sineps; - x[2] = -xpo[1] * sineps + xpo[2] * coseps; - xpn[0] = x[0]; - xpn[1] = x[1]; - xpn[2] = x[2]; + double sineps, coseps; + double x[3]; + sineps = sin(eps); + coseps = cos(eps); + x[0] = xpo[0]; + x[1] = xpo[1] * coseps + xpo[2] * sineps; + x[2] = -xpo[1] * sineps + xpo[2] * coseps; + xpn[0] = x[0]; + xpn[1] = x[1]; + xpn[2] = x[2]; } /* @@ -296,54 +314,58 @@ void swi_coortrf(double *xpo, double *xpn, double eps) * coseps cos(eps) * for ecl. to equ. sineps must be -sin(eps) */ -void swi_coortrf2(double *xpo, double *xpn, double sineps, double coseps) +void +swi_coortrf2(double *xpo, double *xpn, double sineps, double coseps) { - double x[3]; - x[0] = xpo[0]; - x[1] = xpo[1] * coseps + xpo[2] * sineps; - x[2] = -xpo[1] * sineps + xpo[2] * coseps; - xpn[0] = x[0]; - xpn[1] = x[1]; - xpn[2] = x[2]; + double x[3]; + x[0] = xpo[0]; + x[1] = xpo[1] * coseps + xpo[2] * sineps; + x[2] = -xpo[1] * sineps + xpo[2] * coseps; + xpn[0] = x[0]; + xpn[1] = x[1]; + xpn[2] = x[2]; } /* conversion of cartesian (x[3]) to polar coordinates (l[3]). * x = l is allowed. * if |x| = 0, then lon, lat and rad := 0. */ -void swi_cartpol(double *x, double *l) +void +swi_cartpol(double *x, double *l) { - double rxy; - double ll[3]; - if (x[0] == 0 && x[1] == 0 && x[2] == 0) { - l[0] = l[1] = l[2] = 0; - return; - } - rxy = x[0]*x[0] + x[1]*x[1]; - ll[2] = sqrt(rxy + x[2]*x[2]); - rxy = sqrt(rxy); - ll[0] = atan2(x[1], x[0]); - if (ll[0] < 0.0) ll[0] += TWOPI; - ll[1] = atan(x[2] / rxy); - l[0] = ll[0]; - l[1] = ll[1]; - l[2] = ll[2]; + double rxy; + double ll[3]; + if (x[0] == 0 && x[1] == 0 && x[2] == 0) { + l[0] = l[1] = l[2] = 0; + return; + } + rxy = x[0] * x[0] + x[1] * x[1]; + ll[2] = sqrt(rxy + x[2] * x[2]); + rxy = sqrt(rxy); + ll[0] = atan2(x[1], x[0]); + if (ll[0] < 0.0) + ll[0] += TWOPI; + ll[1] = atan(x[2] / rxy); + l[0] = ll[0]; + l[1] = ll[1]; + l[2] = ll[2]; } /* conversion from polar (l[3]) to cartesian coordinates (x[3]). * x = l is allowed. */ -void swi_polcart(double *l, double *x) +void +swi_polcart(double *l, double *x) { - double xx[3]; - double cosl1; - cosl1 = cos(l[1]); - xx[0] = l[2] * cosl1 * cos(l[0]); - xx[1] = l[2] * cosl1 * sin(l[0]); - xx[2] = l[2] * sin(l[1]); - x[0] = xx[0]; - x[1] = xx[1]; - x[2] = xx[2]; + double xx[3]; + double cosl1; + cosl1 = cos(l[1]); + xx[0] = l[2] * cosl1 * cos(l[0]); + xx[1] = l[2] * cosl1 * sin(l[0]); + xx[2] = l[2] * sin(l[1]); + x[0] = xx[0]; + x[1] = xx[1]; + x[2] = xx[2]; } /* conversion of position and speed. @@ -352,54 +374,56 @@ void swi_polcart(double *l, double *x) * if position is 0, function returns direction of * motion. */ -void swi_cartpol_sp(double *x, double *l) +void +swi_cartpol_sp(double *x, double *l) { - double xx[6], ll[6]; - double rxy, coslon, sinlon, coslat, sinlat; - /* zero position */ - if (x[0] == 0 && x[1] == 0 && x[2] == 0) { - l[0] = l[1] = l[3] = l[4] = 0; - l[5] = sqrt(square_sum((x+3))); - swi_cartpol(x+3, l); - l[2] = 0; - return; - } - /* zero speed */ - if (x[3] == 0 && x[4] == 0 && x[5] == 0) { - l[3] = l[4] = l[5] = 0; - swi_cartpol(x, l); - return; - } - /* position */ - rxy = x[0]*x[0] + x[1]*x[1]; - ll[2] = sqrt(rxy + x[2]*x[2]); - rxy = sqrt(rxy); - ll[0] = atan2(x[1], x[0]); - if (ll[0] < 0.0) ll[0] += TWOPI; - ll[1] = atan(x[2] / rxy); - /* speed: - * 1. rotate coordinate system by longitude of position about z-axis, - * so that new x-axis = position radius projected onto x-y-plane. - * in the new coordinate system - * vy'/r = dlong/dt, where r = sqrt(x^2 +y^2). - * 2. rotate coordinate system by latitude about new y-axis. - * vz"/r = dlat/dt, where r = position radius. - * vx" = dr/dt - */ - coslon = x[0] / rxy; /* cos(l[0]); */ - sinlon = x[1] / rxy; /* sin(l[0]); */ - coslat = rxy / ll[2]; /* cos(l[1]); */ - sinlat = x[2] / ll[2]; /* sin(ll[1]); */ - xx[3] = x[3] * coslon + x[4] * sinlon; - xx[4] = -x[3] * sinlon + x[4] * coslon; - l[3] = xx[4] / rxy; /* speed in longitude */ - xx[4] = -sinlat * xx[3] + coslat * x[5]; - xx[5] = coslat * xx[3] + sinlat * x[5]; - l[4] = xx[4] / ll[2]; /* speed in latitude */ - l[5] = xx[5]; /* speed in radius */ - l[0] = ll[0]; /* return position */ - l[1] = ll[1]; - l[2] = ll[2]; + double xx[6], ll[6]; + double rxy, coslon, sinlon, coslat, sinlat; + /* zero position */ + if (x[0] == 0 && x[1] == 0 && x[2] == 0) { + l[0] = l[1] = l[3] = l[4] = 0; + l[5] = sqrt(square_sum((x + 3))); + swi_cartpol(x + 3, l); + l[2] = 0; + return; + } + /* zero speed */ + if (x[3] == 0 && x[4] == 0 && x[5] == 0) { + l[3] = l[4] = l[5] = 0; + swi_cartpol(x, l); + return; + } + /* position */ + rxy = x[0] * x[0] + x[1] * x[1]; + ll[2] = sqrt(rxy + x[2] * x[2]); + rxy = sqrt(rxy); + ll[0] = atan2(x[1], x[0]); + if (ll[0] < 0.0) + ll[0] += TWOPI; + ll[1] = atan(x[2] / rxy); + /* speed: + * 1. rotate coordinate system by longitude of position about z-axis, + * so that new x-axis = position radius projected onto x-y-plane. + * in the new coordinate system + * vy'/r = dlong/dt, where r = sqrt(x^2 +y^2). + * 2. rotate coordinate system by latitude about new y-axis. + * vz"/r = dlat/dt, where r = position radius. + * vx" = dr/dt + */ + coslon = x[0] / rxy; /* cos(l[0]); */ + sinlon = x[1] / rxy; /* sin(l[0]); */ + coslat = rxy / ll[2]; /* cos(l[1]); */ + sinlat = x[2] / ll[2]; /* sin(ll[1]); */ + xx[3] = x[3] * coslon + x[4] * sinlon; + xx[4] = -x[3] * sinlon + x[4] * coslon; + l[3] = xx[4] / rxy; /* speed in longitude */ + xx[4] = -sinlat * xx[3] + coslat * x[5]; + xx[5] = coslat * xx[3] + sinlat * x[5]; + l[4] = xx[4] / ll[2]; /* speed in latitude */ + l[5] = xx[5]; /* speed in radius */ + l[0] = ll[0]; /* return position */ + l[1] = ll[1]; + l[2] = ll[2]; } /* conversion of position and speed @@ -407,51 +431,53 @@ void swi_cartpol_sp(double *x, double *l) * x = l is allowed * explanation s. swi_cartpol_sp() */ -void swi_polcart_sp(double *l, double *x) +void +swi_polcart_sp(double *l, double *x) { - double sinlon, coslon, sinlat, coslat; - double xx[6], rxy, rxyz; - /* zero speed */ - if (l[3] == 0 && l[4] == 0 && l[5] == 0) { - x[3] = x[4] = x[5] = 0; - swi_polcart(l, x); - return; - } - /* position */ - coslon = cos(l[0]); - sinlon = sin(l[0]); - coslat = cos(l[1]); - sinlat = sin(l[1]); - xx[0] = l[2] * coslat * coslon; - xx[1] = l[2] * coslat * sinlon; - xx[2] = l[2] * sinlat; - /* speed; explanation s. swi_cartpol_sp(), same method the other way round*/ - rxyz = l[2]; - rxy = sqrt(xx[0] * xx[0] + xx[1] * xx[1]); - xx[5] = l[5]; - xx[4] = l[4] * rxyz; - x[5] = sinlat * xx[5] + coslat * xx[4]; /* speed z */ - xx[3] = coslat * xx[5] - sinlat * xx[4]; - xx[4] = l[3] * rxy; - x[3] = coslon * xx[3] - sinlon * xx[4]; /* speed x */ - x[4] = sinlon * xx[3] + coslon * xx[4]; /* speed y */ - x[0] = xx[0]; /* return position */ - x[1] = xx[1]; - x[2] = xx[2]; + double sinlon, coslon, sinlat, coslat; + double xx[6], rxy, rxyz; + /* zero speed */ + if (l[3] == 0 && l[4] == 0 && l[5] == 0) { + x[3] = x[4] = x[5] = 0; + swi_polcart(l, x); + return; + } + /* position */ + coslon = cos(l[0]); + sinlon = sin(l[0]); + coslat = cos(l[1]); + sinlat = sin(l[1]); + xx[0] = l[2] * coslat * coslon; + xx[1] = l[2] * coslat * sinlon; + xx[2] = l[2] * sinlat; + /* speed; explanation s. swi_cartpol_sp(), same method the other way round */ + rxyz = l[2]; + rxy = sqrt(xx[0] * xx[0] + xx[1] * xx[1]); + xx[5] = l[5]; + xx[4] = l[4] * rxyz; + x[5] = sinlat * xx[5] + coslat * xx[4]; /* speed z */ + xx[3] = coslat * xx[5] - sinlat * xx[4]; + xx[4] = l[3] * rxy; + x[3] = coslon * xx[3] - sinlon * xx[4]; /* speed x */ + x[4] = sinlon * xx[3] + coslon * xx[4]; /* speed y */ + x[0] = xx[0]; /* return position */ + x[1] = xx[1]; + x[2] = xx[2]; } -double swi_dot_prod_unit(double *x, double *y) +double +swi_dot_prod_unit(double *x, double *y) { - double dop = x[0]*y[0]+x[1]*y[1]+x[2]*y[2]; - double e1 = sqrt(x[0]*x[0]+x[1]*x[1]+x[2]*x[2]); - double e2 = sqrt(y[0]*y[0]+y[1]*y[1]+y[2]*y[2]); - dop /= e1; - dop /= e2; - if (dop > 1) - dop = 1; - if (dop < -1) - dop = -1; - return dop; + double dop = x[0] * y[0] + x[1] * y[1] + x[2] * y[2]; + double e1 = sqrt(x[0] * x[0] + x[1] * x[1] + x[2] * x[2]); + double e2 = sqrt(y[0] * y[0] + y[1] * y[1] + y[2] * y[2]); + dop /= e1; + dop /= e2; + if (dop > 1) + dop = 1; + if (dop < -1) + dop = -1; + return dop; } /* functions for precession and ecliptic obliquity according to Vondrák et alii, 2011 */ @@ -466,92 +492,113 @@ double swi_dot_prod_unit(double *x, double *y) #define NPER_PEQU 14 /* for pre_peps(): */ + /* polynomials */ static double pepol[NPOL_PEPS][2] = { - {+8134.017132, +84028.206305}, - {+5043.0520035, +0.3624445}, - {-0.00710733, -0.00004039}, - {+0.000000271, -0.000000110} + {+8134.017132, +84028.206305}, + {+5043.0520035, +0.3624445}, + {-0.00710733, -0.00004039}, + {+0.000000271, -0.000000110} }; /* periodics */ static double peper[5][NPER_PEPS] = { - {+409.90, +396.15, +537.22, +402.90, +417.15, +288.92, +4043.00, +306.00, +277.00, +203.00}, - {-6908.287473, -3198.706291, +1453.674527, -857.748557, +1173.231614, -156.981465, +371.836550, -216.619040, +193.691479, +11.891524}, - {+753.872780, -247.805823, +379.471484, -53.880558, -90.109153, -353.600190, -63.115353, -28.248187, +17.703387, +38.911307}, - {-2845.175469, +449.844989, -1255.915323, +886.736783, +418.887514, +997.912441, -240.979710, +76.541307, -36.788069, -170.964086}, - {-1704.720302, -862.308358, +447.832178, -889.571909, +190.402846, -56.564991, -296.222622, -75.859952, +67.473503, +3.014055} + {+409.90, +396.15, +537.22, +402.90, +417.15, +288.92, +4043.00, +306.00, + +277.00, +203.00}, + {-6908.287473, -3198.706291, +1453.674527, -857.748557, +1173.231614, + -156.981465, +371.836550, -216.619040, +193.691479, +11.891524}, + {+753.872780, -247.805823, +379.471484, -53.880558, -90.109153, + -353.600190, -63.115353, -28.248187, +17.703387, +38.911307}, + {-2845.175469, +449.844989, -1255.915323, +886.736783, +418.887514, + +997.912441, -240.979710, +76.541307, -36.788069, -170.964086}, + {-1704.720302, -862.308358, +447.832178, -889.571909, +190.402846, + -56.564991, -296.222622, -75.859952, +67.473503, +3.014055} }; /* for pre_pecl(): */ + /* polynomials */ static double pqpol[NPOL_PECL][2] = { - {+5851.607687, -1600.886300}, - {-0.1189000, +1.1689818}, - {-0.00028913, -0.00000020}, - {+0.000000101, -0.000000437} + {+5851.607687, -1600.886300}, + {-0.1189000, +1.1689818}, + {-0.00028913, -0.00000020}, + {+0.000000101, -0.000000437} }; /* periodics */ static double pqper[5][NPER_PECL] = { - {708.15, 2309, 1620, 492.2, 1183, 622, 882, 547}, - {-5486.751211, -17.127623, -617.517403, 413.44294, 78.614193, -180.732815, -87.676083, 46.140315}, - {-684.66156, 2446.28388, 399.671049, -356.652376, -186.387003, -316.80007, 198.296701, 101.135679}, /* typo in publication fixed */ - {667.66673, -2354.886252, -428.152441, 376.202861, 184.778874, 335.321713, -185.138669, -120.97283}, - {-5523.863691, -549.74745, -310.998056, 421.535876, -36.776172, -145.278396, -34.74445, 22.885731} + {708.15, 2309, 1620, 492.2, 1183, 622, 882, 547}, + {-5486.751211, -17.127623, -617.517403, 413.44294, 78.614193, -180.732815, + -87.676083, 46.140315}, + {-684.66156, 2446.28388, 399.671049, -356.652376, -186.387003, -316.80007, 198.296701, 101.135679}, /* typo in publication fixed */ + {667.66673, -2354.886252, -428.152441, 376.202861, 184.778874, 335.321713, + -185.138669, -120.97283}, + {-5523.863691, -549.74745, -310.998056, 421.535876, -36.776172, + -145.278396, -34.74445, 22.885731} }; /* for pre_pequ(): */ + /* polynomials */ static double xypol[NPOL_PEQU][2] = { - {+5453.282155, -73750.930350}, - {+0.4252841, -0.7675452}, - {-0.00037173, -0.00018725}, - {-0.000000152, +0.000000231} + {+5453.282155, -73750.930350}, + {+0.4252841, -0.7675452}, + {-0.00037173, -0.00018725}, + {-0.000000152, +0.000000231} }; /* periodics */ static double xyper[5][NPER_PEQU] = { - {256.75, 708.15, 274.2, 241.45, 2309, 492.2, 396.1, 288.9, 231.1, 1610, 620, 157.87, 220.3, 1200}, - {-819.940624, -8444.676815, 2600.009459, 2755.17563, -167.659835, 871.855056, 44.769698, -512.313065, -819.415595, -538.071099, -189.793622, -402.922932, 179.516345, -9.814756}, - {75004.344875, 624.033993, 1251.136893, -1102.212834, -2660.66498, 699.291817, 153.16722, -950.865637, 499.754645, -145.18821, 558.116553, -23.923029, -165.405086, 9.344131}, - {81491.287984, 787.163481, 1251.296102, -1257.950837, -2966.79973, 639.744522, 131.600209, -445.040117, 584.522874, -89.756563, 524.42963, -13.549067, -210.157124, -44.919798}, - {1558.515853, 7774.939698, -2219.534038, -2523.969396, 247.850422, -846.485643, -1393.124055, 368.526116, 749.045012, 444.704518, 235.934465, 374.049623, -171.33018, -22.899655} + {256.75, 708.15, 274.2, 241.45, 2309, 492.2, 396.1, 288.9, 231.1, 1610, + 620, 157.87, 220.3, 1200}, + {-819.940624, -8444.676815, 2600.009459, 2755.17563, -167.659835, + 871.855056, 44.769698, -512.313065, -819.415595, -538.071099, + -189.793622, -402.922932, 179.516345, -9.814756}, + {75004.344875, 624.033993, 1251.136893, -1102.212834, -2660.66498, + 699.291817, 153.16722, -950.865637, 499.754645, -145.18821, 558.116553, + -23.923029, -165.405086, 9.344131}, + {81491.287984, 787.163481, 1251.296102, -1257.950837, -2966.79973, + 639.744522, 131.600209, -445.040117, 584.522874, -89.756563, 524.42963, + -13.549067, -210.157124, -44.919798}, + {1558.515853, 7774.939698, -2219.534038, -2523.969396, 247.850422, + -846.485643, -1393.124055, 368.526116, 749.045012, 444.704518, + 235.934465, 374.049623, -171.33018, -22.899655} }; -void swi_ldp_peps(double tjd, double *dpre, double *deps) +void +swi_ldp_peps(double tjd, double *dpre, double *deps) { - int i; - int npol = NPOL_PEPS; - int nper = NPER_PEPS; - double t, p, q, w, a, s, c; - t = (tjd - J2000) / 36525.0; - p = 0; - q = 0; - /* periodic terms */ - for (i = 0; i < nper; i++) { - w = D2PI * t; - a = w / peper[0][i]; - s = sin(a); - c = cos(a); - p += c * peper[1][i] + s * peper[3][i]; - q += c * peper[2][i] + s * peper[4][i]; - } - /* polynomial terms */ - w = 1; - for (i = 0; i < npol; i++) { - p += pepol[i][0] * w; - q += pepol[i][1] * w; - w *= t; - } - /* both to radians */ - p *= AS2R; - q *= AS2R; - /* return */ - if (dpre != NULL) - *dpre = p; - if (deps != NULL) - *deps = q; + int i; + int npol = NPOL_PEPS; + int nper = NPER_PEPS; + double t, p, q, w, a, s, c; + t = (tjd - J2000) / 36525.0; + p = 0; + q = 0; + /* periodic terms */ + for (i = 0; i < nper; i++) { + w = D2PI * t; + a = w / peper[0][i]; + s = sin(a); + c = cos(a); + p += c * peper[1][i] + s * peper[3][i]; + q += c * peper[2][i] + s * peper[4][i]; + } + /* polynomial terms */ + w = 1; + for (i = 0; i < npol; i++) { + p += pepol[i][0] * w; + q += pepol[i][1] * w; + w *= t; + } + /* both to radians */ + p *= AS2R; + q *= AS2R; + /* return */ + if (dpre != NULL) + *dpre = p; + if (deps != NULL) + *deps = q; } /* @@ -559,118 +606,123 @@ void swi_ldp_peps(double tjd, double *dpre, double *deps) * according to Vondrak/Capitaine/Wallace, "New precession expressions, valid * for long time intervals", in A&A 534, A22(2011). */ + /* precession of the ecliptic */ -static void pre_pecl(double tjd, double *vec) +static void +pre_pecl(double tjd, double *vec) { - int i; - int npol = NPOL_PECL; - int nper = NPER_PECL; - double t, p, q, w, a, s, c, z; - t = (tjd - J2000) / 36525.0; - p = 0; - q = 0; - /* periodic terms */ - for (i = 0; i < nper; i++) { - w = D2PI * t; - a = w / pqper[0][i]; - s = sin(a); - c = cos(a); - p += c * pqper[1][i] + s * pqper[3][i]; - q += c * pqper[2][i] + s * pqper[4][i]; - } - /* polynomial terms */ - w = 1; - for (i = 0; i < npol; i++) { - p += pqpol[i][0] * w; - q += pqpol[i][1] * w; - w *= t; - } - /* both to radians */ - p *= AS2R; - q *= AS2R; - /* ecliptic pole vector */ - z = 1 - p * p - q * q; - if (z < 0) - z = 0; - else - z = sqrt(z); - s = sin(EPS0); - c = cos(EPS0); - vec[0] = p; - vec[1] = - q * c - z * s; - vec[2] = - q * s + z * c; + int i; + int npol = NPOL_PECL; + int nper = NPER_PECL; + double t, p, q, w, a, s, c, z; + t = (tjd - J2000) / 36525.0; + p = 0; + q = 0; + /* periodic terms */ + for (i = 0; i < nper; i++) { + w = D2PI * t; + a = w / pqper[0][i]; + s = sin(a); + c = cos(a); + p += c * pqper[1][i] + s * pqper[3][i]; + q += c * pqper[2][i] + s * pqper[4][i]; + } + /* polynomial terms */ + w = 1; + for (i = 0; i < npol; i++) { + p += pqpol[i][0] * w; + q += pqpol[i][1] * w; + w *= t; + } + /* both to radians */ + p *= AS2R; + q *= AS2R; + /* ecliptic pole vector */ + z = 1 - p * p - q * q; + if (z < 0) + z = 0; + else + z = sqrt(z); + s = sin(EPS0); + c = cos(EPS0); + vec[0] = p; + vec[1] = -q * c - z * s; + vec[2] = -q * s + z * c; } /* precession of the equator */ -static void pre_pequ(double tjd, double *veq) +static void +pre_pequ(double tjd, double *veq) { - int i; - int npol = NPOL_PEQU; - int nper = NPER_PEQU; - double t, x, y, w, a, s, c; - t = (tjd - J2000) / 36525.0; - x = 0; - y = 0; - for (i = 0; i < nper; i++) { - w = D2PI * t; - a = w / xyper[0][i]; - s = sin(a); - c = cos(a); - x += c * xyper[1][i] + s * xyper[3][i]; - y += c * xyper[2][i] + s * xyper[4][i]; - } - /* polynomial terms */ - w = 1; - for (i = 0; i < npol; i++) { - x += xypol[i][0] * w; - y += xypol[i][1] * w; - w *= t; - } - x *= AS2R; - y *= AS2R; - /* equator pole vector */ - veq[0] = x; - veq[1] = y; - w = x * x + y * y; - if (w < 1) - veq[2] = sqrt(1 - w); - else - veq[2] = 0; + int i; + int npol = NPOL_PEQU; + int nper = NPER_PEQU; + double t, x, y, w, a, s, c; + t = (tjd - J2000) / 36525.0; + x = 0; + y = 0; + for (i = 0; i < nper; i++) { + w = D2PI * t; + a = w / xyper[0][i]; + s = sin(a); + c = cos(a); + x += c * xyper[1][i] + s * xyper[3][i]; + y += c * xyper[2][i] + s * xyper[4][i]; + } + /* polynomial terms */ + w = 1; + for (i = 0; i < npol; i++) { + x += xypol[i][0] * w; + y += xypol[i][1] * w; + w *= t; + } + x *= AS2R; + y *= AS2R; + /* equator pole vector */ + veq[0] = x; + veq[1] = y; + w = x * x + y * y; + if (w < 1) + veq[2] = sqrt(1 - w); + else + veq[2] = 0; } #if 0 -static void swi_cross_prod(double *a, double *b, double *x) +static void +swi_cross_prod(double *a, double *b, double *x) { - x[0] = a[1] * b[2] - a[2] * b[1]; - x[1] = a[2] * b[0] - a[0] * b[2]; - x[2] = a[0] * b[1] - a[1] * b[0]; + x[0] = a[1] * b[2] - a[2] * b[1]; + x[1] = a[2] * b[0] - a[0] * b[2]; + x[2] = a[0] * b[1] - a[1] * b[0]; } #endif /* precession matrix */ -static void pre_pmat(double tjd, double *rp) +static void +pre_pmat(double tjd, double *rp) { - double peqr[3], pecl[3], v[3], w, eqx[3]; - /*equator pole */ - pre_pequ(tjd, peqr); - /* ecliptic pole */ - pre_pecl(tjd, pecl); - /* equinox */ - swi_cross_prod(peqr, pecl, v); - w = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); - eqx[0] = v[0] / w; - eqx[1] = v[1] / w; - eqx[2] = v[2] / w; - swi_cross_prod(peqr, eqx, v); - rp[0] = eqx[0]; - rp[1] = eqx[1]; - rp[2] = eqx[2]; - rp[3] = v[0]; - rp[4] = v[1]; - rp[5] = v[2]; - rp[6] = peqr[0]; - rp[7] = peqr[1]; - rp[8] = peqr[2]; + double peqr[3], pecl[3], v[3], w, eqx[3]; + /*equator pole */ + pre_pequ(tjd, peqr); + /* ecliptic pole */ + pre_pecl(tjd, pecl); + /* equinox */ + swi_cross_prod(peqr, pecl, v); + w = sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); + eqx[0] = v[0] / w; + eqx[1] = v[1] / w; + eqx[2] = v[2] / w; + swi_cross_prod(peqr, eqx, v); + rp[0] = eqx[0]; + rp[1] = eqx[1]; + rp[2] = eqx[2]; + rp[3] = v[0]; + rp[4] = v[1]; + rp[5] = v[2]; + rp[6] = peqr[0]; + rp[7] = peqr[1]; + rp[8] = peqr[2]; } /* Obliquity of the ecliptic at Julian date J @@ -693,31 +745,44 @@ static void pre_pmat(double tjd, double *rp) * * See precess and page B18 of the Astronomical Almanac. */ -double swi_epsiln(double J) +double +swi_epsiln(double J) { - double T, eps; - T = (J - 2451545.0)/36525.0; - if (PREC_IAU_1976 && fabs(T) <= PREC_IAU_1976_CTIES ) { - eps = (((1.813e-3*T-5.9e-4)*T-46.8150)*T+84381.448)*DEGTORAD/3600; - } else if (PREC_IAU_2003 && fabs(T) <= PREC_IAU_2003_CTIES) { - eps = (((((-4.34e-8 * T -5.76e-7) * T +2.0034e-3) * T -1.831e-4) * T -46.836769) * T + 84381.406) * DEGTORAD / 3600.0; - } else if (PREC_BRETAGNON_2003) { - eps = ((((((-3e-11 * T - 2.48e-8) * T -5.23e-7) * T +1.99911e-3) * T -1.667e-4) * T -46.836051) * T + 84381.40880) * DEGTORAD / 3600.0;/* */ - } else if (PREC_SIMON_1994) { - eps = (((((2.5e-8 * T -5.1e-7) * T +1.9989e-3) * T -1.52e-4) * T -46.80927) * T + 84381.412) * DEGTORAD / 3600.0;/* */ - } else if (PREC_WILLIAMS_1994) { - eps = ((((-1.0e-6 * T +2.0e-3) * T -1.74e-4) * T -46.833960) * T + 84381.409) * DEGTORAD / 3600.0;/* */ - } else if (PREC_LASKAR_1986) { - T /= 10.0; - eps = ((((((((( 2.45e-10*T + 5.79e-9)*T + 2.787e-7)*T - + 7.12e-7)*T - 3.905e-5)*T - 2.4967e-3)*T - - 5.138e-3)*T + 1.99925)*T - 0.0155)*T - 468.093)*T - + 84381.448; - eps *= DEGTORAD/3600; - } else { /* PREC_VONDRAK_2011 */ - swi_ldp_peps(J, NULL, &eps); - } - return(eps); + double T, eps; + T = (J - 2451545.0) / 36525.0; + if (PREC_IAU_1976 && fabs(T) <= PREC_IAU_1976_CTIES) { + eps = + (((1.813e-3 * T - 5.9e-4) * T - 46.8150) * T + + 84381.448) * DEGTORAD / 3600; + } + else if (PREC_IAU_2003 && fabs(T) <= PREC_IAU_2003_CTIES) { + eps = + (((((-4.34e-8 * T - 5.76e-7) * T + 2.0034e-3) * T - + 1.831e-4) * T - 46.836769) * T + + 84381.406) * DEGTORAD / 3600.0; + } + else if (PREC_BRETAGNON_2003) { + eps = ((((((-3e-11 * T - 2.48e-8) * T - 5.23e-7) * T + 1.99911e-3) * T - 1.667e-4) * T - 46.836051) * T + 84381.40880) * DEGTORAD / 3600.0; /* */ + } + else if (PREC_SIMON_1994) { + eps = (((((2.5e-8 * T - 5.1e-7) * T + 1.9989e-3) * T - 1.52e-4) * T - 46.80927) * T + 84381.412) * DEGTORAD / 3600.0; /* */ + } + else if (PREC_WILLIAMS_1994) { + eps = ((((-1.0e-6 * T + 2.0e-3) * T - 1.74e-4) * T - 46.833960) * T + 84381.409) * DEGTORAD / 3600.0; /* */ + } + else if (PREC_LASKAR_1986) { + T /= 10.0; + eps = + (((((((((2.45e-10 * T + 5.79e-9) * T + 2.787e-7) * T + + 7.12e-7) * T - 3.905e-5) * T - 2.4967e-3) * T - + 5.138e-3) * T + 1.99925) * T - 0.0155) * T - 468.093) * T + + 84381.448; + eps *= DEGTORAD / 3600; + } + else { /* PREC_VONDRAK_2011 */ + swi_ldp_peps(J, NULL, &eps); + } + return (eps); } /* Precession of the equinox and ecliptic @@ -771,62 +836,80 @@ double swi_epsiln(double J) * Laskar's data, retaining powers up to T**10 in the result. * */ + /* In WILLIAMS and SIMON, Laskar's terms of order higher than t^4 have been retained, because Simon et al mention that the solution is the same except for the lower order terms. */ -#if (PREC_WILLIAMS_1994 || PREC_VONDRAK_2011) /* Vondrak only added to shut up the compiler */ +#if (PREC_WILLIAMS_1994 || PREC_VONDRAK_2011) /* Vondrak only added to shut up the compiler */ static double pAcof[] = { - -8.66e-10, -4.759e-8, 2.424e-7, 1.3095e-5, 1.7451e-4, -1.8055e-3, - -0.235316, 0.076, 110.5407, 50287.70000 }; + -8.66e-10, -4.759e-8, 2.424e-7, 1.3095e-5, 1.7451e-4, -1.8055e-3, + -0.235316, 0.076, 110.5407, 50287.70000 +}; + static double nodecof[] = { - 6.6402e-16, -2.69151e-15, -1.547021e-12, 7.521313e-12, 1.9e-10, - -3.54e-9, -1.8103e-7, 1.26e-7, 7.436169e-5, - -0.04207794833, 3.052115282424}; + 6.6402e-16, -2.69151e-15, -1.547021e-12, 7.521313e-12, 1.9e-10, + -3.54e-9, -1.8103e-7, 1.26e-7, 7.436169e-5, + -0.04207794833, 3.052115282424 +}; + static double inclcof[] = { - 1.2147e-16, 7.3759e-17, -8.26287e-14, 2.503410e-13, 2.4650839e-11, - -5.4000441e-11, 1.32115526e-9, -6.012e-7, -1.62442e-5, - 0.00227850649, 0.0 }; + 1.2147e-16, 7.3759e-17, -8.26287e-14, 2.503410e-13, 2.4650839e-11, + -5.4000441e-11, 1.32115526e-9, -6.012e-7, -1.62442e-5, + 0.00227850649, 0.0 +}; #endif #if PREC_SIMON_1994 + /* Precession coefficients from Simon et al: */ static double pAcof[] = { - -8.66e-10, -4.759e-8, 2.424e-7, 1.3095e-5, 1.7451e-4, -1.8055e-3, - -0.235316, 0.07732, 111.2022, 50288.200 }; + -8.66e-10, -4.759e-8, 2.424e-7, 1.3095e-5, 1.7451e-4, -1.8055e-3, + -0.235316, 0.07732, 111.2022, 50288.200 +}; + static double nodecof[] = { - 6.6402e-16, -2.69151e-15, -1.547021e-12, 7.521313e-12, 1.9e-10, - -3.54e-9, -1.8103e-7, 2.579e-8, 7.4379679e-5, - -0.0420782900, 3.0521126906}; + 6.6402e-16, -2.69151e-15, -1.547021e-12, 7.521313e-12, 1.9e-10, + -3.54e-9, -1.8103e-7, 2.579e-8, 7.4379679e-5, + -0.0420782900, 3.0521126906 +}; + static double inclcof[] = { - 1.2147e-16, 7.3759e-17, -8.26287e-14, 2.503410e-13, 2.4650839e-11, - -5.4000441e-11, 1.32115526e-9, -5.99908e-7, -1.624383e-5, - 0.002278492868, 0.0 }; + 1.2147e-16, 7.3759e-17, -8.26287e-14, 2.503410e-13, 2.4650839e-11, + -5.4000441e-11, 1.32115526e-9, -5.99908e-7, -1.624383e-5, + 0.002278492868, 0.0 +}; #endif #if PREC_LASKAR_1986 + /* Precession coefficients taken from Laskar's paper: */ static double pAcof[] = { - -8.66e-10, -4.759e-8, 2.424e-7, 1.3095e-5, 1.7451e-4, -1.8055e-3, - -0.235316, 0.07732, 111.1971, 50290.966 }; + -8.66e-10, -4.759e-8, 2.424e-7, 1.3095e-5, 1.7451e-4, -1.8055e-3, + -0.235316, 0.07732, 111.1971, 50290.966 +}; + /* Node and inclination of the earth's orbit computed from * Laskar's data as done in Bretagnon and Francou's paper. * Units are radians. */ static double nodecof[] = { - 6.6402e-16, -2.69151e-15, -1.547021e-12, 7.521313e-12, 6.3190131e-10, - -3.48388152e-9, -1.813065896e-7, 2.75036225e-8, 7.4394531426e-5, - -0.042078604317, 3.052112654975 }; + 6.6402e-16, -2.69151e-15, -1.547021e-12, 7.521313e-12, 6.3190131e-10, + -3.48388152e-9, -1.813065896e-7, 2.75036225e-8, 7.4394531426e-5, + -0.042078604317, 3.052112654975 +}; + static double inclcof[] = { - 1.2147e-16, 7.3759e-17, -8.26287e-14, 2.503410e-13, 2.4650839e-11, - -5.4000441e-11, 1.32115526e-9, -5.998737027e-7, -1.6242797091e-5, - 0.002278495537, 0.0 }; + 1.2147e-16, 7.3759e-17, -8.26287e-14, 2.503410e-13, 2.4650839e-11, + -5.4000441e-11, 1.32115526e-9, -5.998737027e-7, -1.6242797091e-5, + 0.002278495537, 0.0 +}; #endif #if PREC_BRETAGNON_2003 -static double pAcof[] = {}; -static double nodecof[] = {}; -static double inclcof[] = {}; +static double pAcof[] = { }; +static double nodecof[] = { }; +static double inclcof[] = { }; #endif /* Subroutine arguments: @@ -841,177 +924,197 @@ static double inclcof[] = {}; * first go from J1 to J2000, then call the program again * to go from J2000 to J2. */ -int swi_precess(double *R, double J, int direction ) +int +swi_precess(double *R, double J, int direction) { - return precess0(R, J, direction); + return precess0(R, J, direction); } -static int precess0(double *R, double J, int direction ) +static int +precess0(double *R, double J, int direction) { - double sinth, costh, sinZ, cosZ, sinz, cosz; - double eps, sineps, coseps; - double A, B, T, Z, z, TH, pA, W; - double x[3], pmat[9]; - double *p; - int i, j; - if( J == J2000 ) - return(0); - /* Each precession angle is specified by a polynomial in - * T = Julian centuries from J2000.0. See AA page B18. - */ - T = (J - J2000)/36525.0; - /* Use IAU formula for a few centuries. */ - if (PREC_IAU_1976 && fabs(T) <= PREC_IAU_1976_CTIES) { - Z = (( 0.017998*T + 0.30188)*T + 2306.2181)*T*DEGTORAD/3600; - z = (( 0.018203*T + 1.09468)*T + 2306.2181)*T*DEGTORAD/3600; - TH = ((-0.041833*T - 0.42665)*T + 2004.3109)*T*DEGTORAD/3600; - } else if (PREC_IAU_2003 && fabs(T) <= PREC_IAU_2003_CTIES) { - Z = (((((- 0.0000003173*T - 0.000005971)*T + 0.01801828)*T + 0.2988499)*T + 2306.083227)*T + 2.650545)*DEGTORAD/3600; - z = (((((- 0.0000002904*T - 0.000028596)*T + 0.01826837)*T + 1.0927348)*T + 2306.077181)*T - 2.650545)*DEGTORAD/3600; - TH = ((((-0.00000011274*T - 0.000007089)*T - 0.04182264)*T - 0.4294934)*T + 2004.191903)*T*DEGTORAD/3600; - /* AA 2006 B28: - Z = (((((- 0.0000002*T - 0.0000327)*T + 0.0179663)*T + 0.3019015)*T + 2306.0809506)*T + 2.5976176)*DEGTORAD/3600; - z = (((((- 0.0000003*T - 0.000047)*T + 0.0182237)*T + 1.0947790)*T + 2306.0803226)*T - 2.5976176)*DEGTORAD/3600; - TH = ((((-0.0000001*T - 0.0000601)*T - 0.0418251)*T - 0.4269353)*T + 2004.1917476)*T*DEGTORAD/3600; - */ - } else if (PREC_BRETAGNON_2003) { - Z = ((((((-0.00000000013*T - 0.0000003040)*T - 0.000005708)*T + 0.01801752)*T + 0.3023262)*T + 2306.080472)*T + 2.72767)*DEGTORAD/3600; - z = ((((((-0.00000000005*T - 0.0000002486)*T - 0.000028276)*T + 0.01826676)*T + 1.0956768)*T + 2306.076070)*T - 2.72767)*DEGTORAD/3600; - TH = ((((((0.000000000009*T + 0.00000000036)*T -0.0000001127)*T - 0.000007291)*T - 0.04182364)*T - 0.4266980)*T + 2004.190936)*T*DEGTORAD/3600; - } else if (PREC_LASKAR_1986) { - goto laskar; - } else { /* PREC_VONDRAK_2011 */ - pre_pmat(J, pmat); - if (direction == -1) { - for (i = 0, j = 0; i <= 2; i++, j = i * 3) { - x[i] = R[0] * pmat[j + 0] + - R[1] * pmat[j + 1] + - R[2] * pmat[j + 2]; - } - } else { - for (i = 0, j = 0; i <= 2; i++, j = i * 3) { - x[i] = R[0] * pmat[i + 0] + - R[1] * pmat[i + 3] + - R[2] * pmat[i + 6]; - } + double sinth, costh, sinZ, cosZ, sinz, cosz; + double eps, sineps, coseps; + double A, B, T, Z, z, TH, pA, W; + double x[3], pmat[9]; + double *p; + int i, j; + if (J == J2000) + return (0); + /* Each precession angle is specified by a polynomial in + * T = Julian centuries from J2000.0. See AA page B18. + */ + T = (J - J2000) / 36525.0; + /* Use IAU formula for a few centuries. */ + if (PREC_IAU_1976 && fabs(T) <= PREC_IAU_1976_CTIES) { + Z = ((0.017998 * T + 0.30188) * T + 2306.2181) * T * DEGTORAD / 3600; + z = ((0.018203 * T + 1.09468) * T + 2306.2181) * T * DEGTORAD / 3600; + TH = ((-0.041833 * T - 0.42665) * T + + 2004.3109) * T * DEGTORAD / 3600; } + else if (PREC_IAU_2003 && fabs(T) <= PREC_IAU_2003_CTIES) { + Z = (((((-0.0000003173 * T - 0.000005971) * T + 0.01801828) * T + + 0.2988499) * T + 2306.083227) * T + + 2.650545) * DEGTORAD / 3600; + z = (((((-0.0000002904 * T - 0.000028596) * T + 0.01826837) * T + + 1.0927348) * T + 2306.077181) * T - + 2.650545) * DEGTORAD / 3600; + TH = ((((-0.00000011274 * T - 0.000007089) * T - 0.04182264) * T - + 0.4294934) * T + 2004.191903) * T * DEGTORAD / 3600; + /* AA 2006 B28: + * Z = (((((- 0.0000002*T - 0.0000327)*T + 0.0179663)*T + 0.3019015)*T + 2306.0809506)*T + 2.5976176)*DEGTORAD/3600; + * z = (((((- 0.0000003*T - 0.000047)*T + 0.0182237)*T + 1.0947790)*T + 2306.0803226)*T - 2.5976176)*DEGTORAD/3600; + * TH = ((((-0.0000001*T - 0.0000601)*T - 0.0418251)*T - 0.4269353)*T + 2004.1917476)*T*DEGTORAD/3600; + */ + } + else if (PREC_BRETAGNON_2003) { + Z = ((((((-0.00000000013 * T - 0.0000003040) * T - 0.000005708) * T + + 0.01801752) * T + 0.3023262) * T + 2306.080472) * T + + 2.72767) * DEGTORAD / 3600; + z = ((((((-0.00000000005 * T - 0.0000002486) * T - 0.000028276) * T + + 0.01826676) * T + 1.0956768) * T + 2306.076070) * T - + 2.72767) * DEGTORAD / 3600; + TH = ((((((0.000000000009 * T + 0.00000000036) * T - + 0.0000001127) * T - 0.000007291) * T - 0.04182364) * T - + 0.4266980) * T + 2004.190936) * T * DEGTORAD / 3600; + } + else if (PREC_LASKAR_1986) { + goto laskar; + } + else { /* PREC_VONDRAK_2011 */ + pre_pmat(J, pmat); + if (direction == -1) { + for (i = 0, j = 0; i <= 2; i++, j = i * 3) { + x[i] = + R[0] * pmat[j + 0] + R[1] * pmat[j + 1] + R[2] * pmat[j + + 2]; + } + } + else { + for (i = 0, j = 0; i <= 2; i++, j = i * 3) { + x[i] = + R[0] * pmat[i + 0] + R[1] * pmat[i + 3] + R[2] * pmat[i + + 6]; + } + } + for (i = 0; i < 3; i++) + R[i] = x[i]; + return (0); + } + sinth = sin(TH); + costh = cos(TH); + sinZ = sin(Z); + cosZ = cos(Z); + sinz = sin(z); + cosz = cos(z); + A = cosZ * costh; + B = sinZ * costh; + if (direction < 0) { /* From J2000.0 to J */ + x[0] = (A * cosz - sinZ * sinz) * R[0] + - (B * cosz + cosZ * sinz) * R[1] + - sinth * cosz * R[2]; + x[1] = (A * sinz + sinZ * cosz) * R[0] + - (B * sinz - cosZ * cosz) * R[1] + - sinth * sinz * R[2]; + x[2] = cosZ * sinth * R[0] + - sinZ * sinth * R[1] + + costh * R[2]; + } + else { /* From J to J2000.0 */ + x[0] = (A * cosz - sinZ * sinz) * R[0] + + (A * sinz + sinZ * cosz) * R[1] + + cosZ * sinth * R[2]; + x[1] = -(B * cosz + cosZ * sinz) * R[0] + - (B * sinz - cosZ * cosz) * R[1] + - sinZ * sinth * R[2]; + x[2] = -sinth * cosz * R[0] + - sinth * sinz * R[1] + + costh * R[2]; + } + goto done; +laskar: + /* Implementation by elementary rotations using Laskar's expansions. + * First rotate about the x axis from the initial equator + * to the ecliptic. (The input is equatorial.) + */ + if (direction == 1) + eps = swi_epsiln(J); /* To J2000 */ + else + eps = swi_epsiln(J2000); /* From J2000 */ + sineps = sin(eps); + coseps = cos(eps); + x[0] = R[0]; + z = coseps * R[1] + sineps * R[2]; + x[2] = -sineps * R[1] + coseps * R[2]; + x[1] = z; + /* Precession in longitude */ + T /= 10.0; /* thousands of years */ + p = pAcof; + pA = *p++; + for (i = 0; i < 9; i++) + pA = pA * T + *p++; + pA *= DEGTORAD / 3600 * T; + /* Node of the moving ecliptic on the J2000 ecliptic. + */ + p = nodecof; + W = *p++; + for (i = 0; i < 10; i++) + W = W * T + *p++; + /* Rotate about z axis to the node. + */ + if (direction == 1) + z = W + pA; + else + z = W; + B = cos(z); + A = sin(z); + z = B * x[0] + A * x[1]; + x[1] = -A * x[0] + B * x[1]; + x[0] = z; + /* Rotate about new x axis by the inclination of the moving + * ecliptic on the J2000 ecliptic. + */ + p = inclcof; + z = *p++; + for (i = 0; i < 10; i++) + z = z * T + *p++; + if (direction == 1) + z = -z; + B = cos(z); + A = sin(z); + z = B * x[1] + A * x[2]; + x[2] = -A * x[1] + B * x[2]; + x[1] = z; + /* Rotate about new z axis back from the node. + */ + if (direction == 1) + z = -W; + else + z = -W - pA; + B = cos(z); + A = sin(z); + z = B * x[0] + A * x[1]; + x[1] = -A * x[0] + B * x[1]; + x[0] = z; + /* Rotate about x axis to final equator. + */ + if (direction == 1) + eps = swi_epsiln(J2000); + else + eps = swi_epsiln(J); + sineps = sin(eps); + coseps = cos(eps); + z = coseps * x[1] - sineps * x[2]; + x[2] = sineps * x[1] + coseps * x[2]; + x[1] = z; +done: for (i = 0; i < 3; i++) - R[i] = x[i]; - return(0); - } - sinth = sin(TH); - costh = cos(TH); - sinZ = sin(Z); - cosZ = cos(Z); - sinz = sin(z); - cosz = cos(z); - A = cosZ*costh; - B = sinZ*costh; - if( direction < 0 ) { /* From J2000.0 to J */ - x[0] = (A*cosz - sinZ*sinz)*R[0] - - (B*cosz + cosZ*sinz)*R[1] - - sinth*cosz*R[2]; - x[1] = (A*sinz + sinZ*cosz)*R[0] - - (B*sinz - cosZ*cosz)*R[1] - - sinth*sinz*R[2]; - x[2] = cosZ*sinth*R[0] - - sinZ*sinth*R[1] - + costh*R[2]; - } - else { /* From J to J2000.0 */ - x[0] = (A*cosz - sinZ*sinz)*R[0] - + (A*sinz + sinZ*cosz)*R[1] - + cosZ*sinth*R[2]; - x[1] = - (B*cosz + cosZ*sinz)*R[0] - - (B*sinz - cosZ*cosz)*R[1] - - sinZ*sinth*R[2]; - x[2] = - sinth*cosz*R[0] - - sinth*sinz*R[1] - + costh*R[2]; - } - goto done; - laskar: - /* Implementation by elementary rotations using Laskar's expansions. - * First rotate about the x axis from the initial equator - * to the ecliptic. (The input is equatorial.) - */ - if( direction == 1 ) - eps = swi_epsiln(J); /* To J2000 */ - else - eps = swi_epsiln(J2000); /* From J2000 */ - sineps = sin(eps); - coseps = cos(eps); - x[0] = R[0]; - z = coseps*R[1] + sineps*R[2]; - x[2] = -sineps*R[1] + coseps*R[2]; - x[1] = z; - /* Precession in longitude */ - T /= 10.0; /* thousands of years */ - p = pAcof; - pA = *p++; - for( i=0; i<9; i++ ) - pA = pA * T + *p++; - pA *= DEGTORAD/3600 * T; - /* Node of the moving ecliptic on the J2000 ecliptic. - */ - p = nodecof; - W = *p++; - for( i=0; i<10; i++ ) - W = W * T + *p++; - /* Rotate about z axis to the node. - */ - if( direction == 1 ) - z = W + pA; - else - z = W; - B = cos(z); - A = sin(z); - z = B * x[0] + A * x[1]; - x[1] = -A * x[0] + B * x[1]; - x[0] = z; - /* Rotate about new x axis by the inclination of the moving - * ecliptic on the J2000 ecliptic. - */ - p = inclcof; - z = *p++; - for( i=0; i<10; i++ ) - z = z * T + *p++; - if( direction == 1 ) - z = -z; - B = cos(z); - A = sin(z); - z = B * x[1] + A * x[2]; - x[2] = -A * x[1] + B * x[2]; - x[1] = z; - /* Rotate about new z axis back from the node. - */ - if( direction == 1 ) - z = -W; - else - z = -W - pA; - B = cos(z); - A = sin(z); - z = B * x[0] + A * x[1]; - x[1] = -A * x[0] + B * x[1]; - x[0] = z; - /* Rotate about x axis to final equator. - */ - if( direction == 1 ) - eps = swi_epsiln(J2000); - else - eps = swi_epsiln(J); - sineps = sin(eps); - coseps = cos(eps); - z = coseps * x[1] - sineps * x[2]; - x[2] = sineps * x[1] + coseps * x[2]; - x[1] = z; - done: - for( i=0; i<3; i++ ) - R[i] = x[i]; - return(0); + R[i] = x[i]; + return (0); } #if NUT_IAU_1980 + /* Nutation in longitude and obliquity * computed at Julian date J. * @@ -1067,282 +1170,287 @@ static int precess0(double *R, double J, int direction ) * .0123 .0880 .0224 .0905 * .0386 .1808 .0895 .1129 */ -static short FAR nt[] = { +static short FAR nt[] = { + /* LS and OC are units of 0.0001" *LS2 and OC2 are units of 0.00001" *MM,MS,FF,DD,OM, LS, LS2,OC, OC2 */ - 0, 0, 0, 0, 2, 2062, 2,-895, 5, --2, 0, 2, 0, 1, 46, 0,-24, 0, - 2, 0,-2, 0, 0, 11, 0, 0, 0, --2, 0, 2, 0, 2,-3, 0, 1, 0, - 1,-1, 0,-1, 0,-3, 0, 0, 0, - 0,-2, 2,-2, 1,-2, 0, 1, 0, - 2, 0,-2, 0, 1, 1, 0, 0, 0, - 0, 0, 2,-2, 2,-13187,-16, 5736,-31, - 0, 1, 0, 0, 0, 1426,-34, 54,-1, - 0, 1, 2,-2, 2,-517, 12, 224,-6, - 0,-1, 2,-2, 2, 217,-5,-95, 3, - 0, 0, 2,-2, 1, 129, 1,-70, 0, - 2, 0, 0,-2, 0, 48, 0, 1, 0, - 0, 0, 2,-2, 0,-22, 0, 0, 0, - 0, 2, 0, 0, 0, 17,-1, 0, 0, - 0, 1, 0, 0, 1,-15, 0, 9, 0, - 0, 2, 2,-2, 2,-16, 1, 7, 0, - 0,-1, 0, 0, 1,-12, 0, 6, 0, --2, 0, 0, 2, 1,-6, 0, 3, 0, - 0,-1, 2,-2, 1,-5, 0, 3, 0, - 2, 0, 0,-2, 1, 4, 0,-2, 0, - 0, 1, 2,-2, 1, 4, 0,-2, 0, - 1, 0, 0,-1, 0,-4, 0, 0, 0, - 2, 1, 0,-2, 0, 1, 0, 0, 0, - 0, 0,-2, 2, 1, 1, 0, 0, 0, - 0, 1,-2, 2, 0,-1, 0, 0, 0, - 0, 1, 0, 0, 2, 1, 0, 0, 0, --1, 0, 0, 1, 1, 1, 0, 0, 0, - 0, 1, 2,-2, 0,-1, 0, 0, 0, - 0, 0, 2, 0, 2,-2274,-2, 977,-5, - 1, 0, 0, 0, 0, 712, 1,-7, 0, - 0, 0, 2, 0, 1,-386,-4, 200, 0, - 1, 0, 2, 0, 2,-301, 0, 129,-1, - 1, 0, 0,-2, 0,-158, 0,-1, 0, --1, 0, 2, 0, 2, 123, 0,-53, 0, - 0, 0, 0, 2, 0, 63, 0,-2, 0, - 1, 0, 0, 0, 1, 63, 1,-33, 0, --1, 0, 0, 0, 1,-58,-1, 32, 0, --1, 0, 2, 2, 2,-59, 0, 26, 0, - 1, 0, 2, 0, 1,-51, 0, 27, 0, - 0, 0, 2, 2, 2,-38, 0, 16, 0, - 2, 0, 0, 0, 0, 29, 0,-1, 0, - 1, 0, 2,-2, 2, 29, 0,-12, 0, - 2, 0, 2, 0, 2,-31, 0, 13, 0, - 0, 0, 2, 0, 0, 26, 0,-1, 0, --1, 0, 2, 0, 1, 21, 0,-10, 0, --1, 0, 0, 2, 1, 16, 0,-8, 0, - 1, 0, 0,-2, 1,-13, 0, 7, 0, --1, 0, 2, 2, 1,-10, 0, 5, 0, - 1, 1, 0,-2, 0,-7, 0, 0, 0, - 0, 1, 2, 0, 2, 7, 0,-3, 0, - 0,-1, 2, 0, 2,-7, 0, 3, 0, - 1, 0, 2, 2, 2,-8, 0, 3, 0, - 1, 0, 0, 2, 0, 6, 0, 0, 0, - 2, 0, 2,-2, 2, 6, 0,-3, 0, - 0, 0, 0, 2, 1,-6, 0, 3, 0, - 0, 0, 2, 2, 1,-7, 0, 3, 0, - 1, 0, 2,-2, 1, 6, 0,-3, 0, - 0, 0, 0,-2, 1,-5, 0, 3, 0, - 1,-1, 0, 0, 0, 5, 0, 0, 0, - 2, 0, 2, 0, 1,-5, 0, 3, 0, - 0, 1, 0,-2, 0,-4, 0, 0, 0, - 1, 0,-2, 0, 0, 4, 0, 0, 0, - 0, 0, 0, 1, 0,-4, 0, 0, 0, - 1, 1, 0, 0, 0,-3, 0, 0, 0, - 1, 0, 2, 0, 0, 3, 0, 0, 0, - 1,-1, 2, 0, 2,-3, 0, 1, 0, --1,-1, 2, 2, 2,-3, 0, 1, 0, --2, 0, 0, 0, 1,-2, 0, 1, 0, - 3, 0, 2, 0, 2,-3, 0, 1, 0, - 0,-1, 2, 2, 2,-3, 0, 1, 0, - 1, 1, 2, 0, 2, 2, 0,-1, 0, --1, 0, 2,-2, 1,-2, 0, 1, 0, - 2, 0, 0, 0, 1, 2, 0,-1, 0, - 1, 0, 0, 0, 2,-2, 0, 1, 0, - 3, 0, 0, 0, 0, 2, 0, 0, 0, - 0, 0, 2, 1, 2, 2, 0,-1, 0, --1, 0, 0, 0, 2, 1, 0,-1, 0, - 1, 0, 0,-4, 0,-1, 0, 0, 0, --2, 0, 2, 2, 2, 1, 0,-1, 0, --1, 0, 2, 4, 2,-2, 0, 1, 0, - 2, 0, 0,-4, 0,-1, 0, 0, 0, - 1, 1, 2,-2, 2, 1, 0,-1, 0, - 1, 0, 2, 2, 1,-1, 0, 1, 0, --2, 0, 2, 4, 2,-1, 0, 1, 0, --1, 0, 4, 0, 2, 1, 0, 0, 0, - 1,-1, 0,-2, 0, 1, 0, 0, 0, - 2, 0, 2,-2, 1, 1, 0,-1, 0, - 2, 0, 2, 2, 2,-1, 0, 0, 0, - 1, 0, 0, 2, 1,-1, 0, 0, 0, - 0, 0, 4,-2, 2, 1, 0, 0, 0, - 3, 0, 2,-2, 2, 1, 0, 0, 0, - 1, 0, 2,-2, 0,-1, 0, 0, 0, - 0, 1, 2, 0, 1, 1, 0, 0, 0, --1,-1, 0, 2, 1, 1, 0, 0, 0, - 0, 0,-2, 0, 1,-1, 0, 0, 0, - 0, 0, 2,-1, 2,-1, 0, 0, 0, - 0, 1, 0, 2, 0,-1, 0, 0, 0, - 1, 0,-2,-2, 0,-1, 0, 0, 0, - 0,-1, 2, 0, 1,-1, 0, 0, 0, - 1, 1, 0,-2, 1,-1, 0, 0, 0, - 1, 0,-2, 2, 0,-1, 0, 0, 0, - 2, 0, 0, 2, 0, 1, 0, 0, 0, - 0, 0, 2, 4, 2,-1, 0, 0, 0, - 0, 1, 0, 1, 0, 1, 0, 0, 0, -#if NUT_CORR_1987 + 0, 0, 0, 0, 2, 2062, 2, -895, 5, + -2, 0, 2, 0, 1, 46, 0, -24, 0, + 2, 0, -2, 0, 0, 11, 0, 0, 0, + -2, 0, 2, 0, 2, -3, 0, 1, 0, + 1, -1, 0, -1, 0, -3, 0, 0, 0, + 0, -2, 2, -2, 1, -2, 0, 1, 0, + 2, 0, -2, 0, 1, 1, 0, 0, 0, + 0, 0, 2, -2, 2, -13187, -16, 5736, -31, + 0, 1, 0, 0, 0, 1426, -34, 54, -1, + 0, 1, 2, -2, 2, -517, 12, 224, -6, + 0, -1, 2, -2, 2, 217, -5, -95, 3, + 0, 0, 2, -2, 1, 129, 1, -70, 0, + 2, 0, 0, -2, 0, 48, 0, 1, 0, + 0, 0, 2, -2, 0, -22, 0, 0, 0, + 0, 2, 0, 0, 0, 17, -1, 0, 0, + 0, 1, 0, 0, 1, -15, 0, 9, 0, + 0, 2, 2, -2, 2, -16, 1, 7, 0, + 0, -1, 0, 0, 1, -12, 0, 6, 0, + -2, 0, 0, 2, 1, -6, 0, 3, 0, + 0, -1, 2, -2, 1, -5, 0, 3, 0, + 2, 0, 0, -2, 1, 4, 0, -2, 0, + 0, 1, 2, -2, 1, 4, 0, -2, 0, + 1, 0, 0, -1, 0, -4, 0, 0, 0, + 2, 1, 0, -2, 0, 1, 0, 0, 0, + 0, 0, -2, 2, 1, 1, 0, 0, 0, + 0, 1, -2, 2, 0, -1, 0, 0, 0, + 0, 1, 0, 0, 2, 1, 0, 0, 0, + -1, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 1, 2, -2, 0, -1, 0, 0, 0, + 0, 0, 2, 0, 2, -2274, -2, 977, -5, + 1, 0, 0, 0, 0, 712, 1, -7, 0, + 0, 0, 2, 0, 1, -386, -4, 200, 0, + 1, 0, 2, 0, 2, -301, 0, 129, -1, + 1, 0, 0, -2, 0, -158, 0, -1, 0, + -1, 0, 2, 0, 2, 123, 0, -53, 0, + 0, 0, 0, 2, 0, 63, 0, -2, 0, + 1, 0, 0, 0, 1, 63, 1, -33, 0, + -1, 0, 0, 0, 1, -58, -1, 32, 0, + -1, 0, 2, 2, 2, -59, 0, 26, 0, + 1, 0, 2, 0, 1, -51, 0, 27, 0, + 0, 0, 2, 2, 2, -38, 0, 16, 0, + 2, 0, 0, 0, 0, 29, 0, -1, 0, + 1, 0, 2, -2, 2, 29, 0, -12, 0, + 2, 0, 2, 0, 2, -31, 0, 13, 0, + 0, 0, 2, 0, 0, 26, 0, -1, 0, + -1, 0, 2, 0, 1, 21, 0, -10, 0, + -1, 0, 0, 2, 1, 16, 0, -8, 0, + 1, 0, 0, -2, 1, -13, 0, 7, 0, + -1, 0, 2, 2, 1, -10, 0, 5, 0, + 1, 1, 0, -2, 0, -7, 0, 0, 0, + 0, 1, 2, 0, 2, 7, 0, -3, 0, + 0, -1, 2, 0, 2, -7, 0, 3, 0, + 1, 0, 2, 2, 2, -8, 0, 3, 0, + 1, 0, 0, 2, 0, 6, 0, 0, 0, + 2, 0, 2, -2, 2, 6, 0, -3, 0, + 0, 0, 0, 2, 1, -6, 0, 3, 0, + 0, 0, 2, 2, 1, -7, 0, 3, 0, + 1, 0, 2, -2, 1, 6, 0, -3, 0, + 0, 0, 0, -2, 1, -5, 0, 3, 0, + 1, -1, 0, 0, 0, 5, 0, 0, 0, + 2, 0, 2, 0, 1, -5, 0, 3, 0, + 0, 1, 0, -2, 0, -4, 0, 0, 0, + 1, 0, -2, 0, 0, 4, 0, 0, 0, + 0, 0, 0, 1, 0, -4, 0, 0, 0, + 1, 1, 0, 0, 0, -3, 0, 0, 0, + 1, 0, 2, 0, 0, 3, 0, 0, 0, + 1, -1, 2, 0, 2, -3, 0, 1, 0, + -1, -1, 2, 2, 2, -3, 0, 1, 0, + -2, 0, 0, 0, 1, -2, 0, 1, 0, + 3, 0, 2, 0, 2, -3, 0, 1, 0, + 0, -1, 2, 2, 2, -3, 0, 1, 0, + 1, 1, 2, 0, 2, 2, 0, -1, 0, + -1, 0, 2, -2, 1, -2, 0, 1, 0, + 2, 0, 0, 0, 1, 2, 0, -1, 0, + 1, 0, 0, 0, 2, -2, 0, 1, 0, + 3, 0, 0, 0, 0, 2, 0, 0, 0, + 0, 0, 2, 1, 2, 2, 0, -1, 0, + -1, 0, 0, 0, 2, 1, 0, -1, 0, + 1, 0, 0, -4, 0, -1, 0, 0, 0, + -2, 0, 2, 2, 2, 1, 0, -1, 0, + -1, 0, 2, 4, 2, -2, 0, 1, 0, + 2, 0, 0, -4, 0, -1, 0, 0, 0, + 1, 1, 2, -2, 2, 1, 0, -1, 0, + 1, 0, 2, 2, 1, -1, 0, 1, 0, + -2, 0, 2, 4, 2, -1, 0, 1, 0, + -1, 0, 4, 0, 2, 1, 0, 0, 0, + 1, -1, 0, -2, 0, 1, 0, 0, 0, + 2, 0, 2, -2, 1, 1, 0, -1, 0, + 2, 0, 2, 2, 2, -1, 0, 0, 0, + 1, 0, 0, 2, 1, -1, 0, 0, 0, + 0, 0, 4, -2, 2, 1, 0, 0, 0, + 3, 0, 2, -2, 2, 1, 0, 0, 0, + 1, 0, 2, -2, 0, -1, 0, 0, 0, + 0, 1, 2, 0, 1, 1, 0, 0, 0, + -1, -1, 0, 2, 1, 1, 0, 0, 0, + 0, 0, -2, 0, 1, -1, 0, 0, 0, + 0, 0, 2, -1, 2, -1, 0, 0, 0, + 0, 1, 0, 2, 0, -1, 0, 0, 0, + 1, 0, -2, -2, 0, -1, 0, 0, 0, + 0, -1, 2, 0, 1, -1, 0, 0, 0, + 1, 1, 0, -2, 1, -1, 0, 0, 0, + 1, 0, -2, 2, 0, -1, 0, 0, 0, + 2, 0, 0, 2, 0, 1, 0, 0, 0, + 0, 0, 2, 4, 2, -1, 0, 0, 0, + 0, 1, 0, 1, 0, 1, 0, 0, 0, +#if NUT_CORR_1987 + /* corrections to IAU 1980 nutation series by Herring 1987 * in 0.00001" !!! * LS OC */ - 101, 0, 0, 0, 1,-725, 0, 213, 0, - 101, 1, 0, 0, 0, 523, 0, 208, 0, - 101, 0, 2,-2, 2, 102, 0, -41, 0, - 101, 0, 2, 0, 2, -81, 0, 32, 0, + 101, 0, 0, 0, 1, -725, 0, 213, 0, + 101, 1, 0, 0, 0, 523, 0, 208, 0, + 101, 0, 2, -2, 2, 102, 0, -41, 0, + 101, 0, 2, 0, 2, -81, 0, 32, 0, + /* LC OS !!! */ - 102, 0, 0, 0, 1, 417, 0, 224, 0, - 102, 1, 0, 0, 0, 61, 0, -24, 0, - 102, 0, 2,-2, 2,-118, 0, -47, 0, + 102, 0, 0, 0, 1, 417, 0, 224, 0, + 102, 1, 0, 0, 0, 61, 0, -24, 0, + 102, 0, 2, -2, 2, -118, 0, -47, 0, #endif - ENDMARK, + ENDMARK, }; #endif #if NUT_IAU_1980 -int swi_nutation(double J, double *nutlo) +int +swi_nutation(double J, double *nutlo) { - /* arrays to hold sines and cosines of multiple angles */ - double ss[5][8]; - double cc[5][8]; - double arg; - double args[5]; - double f, g, T, T2; - double MM, MS, FF, DD, OM; - double cu, su, cv, sv, sw, s; - double C, D; - int i, j, k, k1, m, n; - int ns[5]; - short *p; - /* Julian centuries from 2000 January 1.5, - * barycentric dynamical time - */ - T = (J - 2451545.0) / 36525.0; - T2 = T * T; - /* Fundamental arguments in the FK5 reference system. - * The coefficients, originally given to 0.001", - * are converted here to degrees. - */ - /* longitude of the mean ascending node of the lunar orbit - * on the ecliptic, measured from the mean equinox of date - */ - OM = -6962890.539 * T + 450160.280 + (0.008 * T + 7.455) * T2; - OM = swe_degnorm(OM/3600) * DEGTORAD; - /* mean longitude of the Sun minus the - * mean longitude of the Sun's perigee - */ - MS = 129596581.224 * T + 1287099.804 - (0.012 * T + 0.577) * T2; - MS = swe_degnorm(MS/3600) * DEGTORAD; - /* mean longitude of the Moon minus the - * mean longitude of the Moon's perigee - */ - MM = 1717915922.633 * T + 485866.733 + (0.064 * T + 31.310) * T2; - MM = swe_degnorm(MM/3600) * DEGTORAD; - /* mean longitude of the Moon minus the - * mean longitude of the Moon's node - */ - FF = 1739527263.137 * T + 335778.877 + (0.011 * T - 13.257) * T2; - FF = swe_degnorm(FF/3600) * DEGTORAD; - /* mean elongation of the Moon from the Sun. - */ - DD = 1602961601.328 * T + 1072261.307 + (0.019 * T - 6.891) * T2; - DD = swe_degnorm(DD/3600) * DEGTORAD; - args[0] = MM; - ns[0] = 3; - args[1] = MS; - ns[1] = 2; - args[2] = FF; - ns[2] = 4; - args[3] = DD; - ns[3] = 4; - args[4] = OM; - ns[4] = 2; - /* Calculate sin( i*MM ), etc. for needed multiple angles - */ - for (k = 0; k <= 4; k++) { - arg = args[k]; - n = ns[k]; - su = sin(arg); - cu = cos(arg); - ss[k][0] = su; /* sin(L) */ - cc[k][0] = cu; /* cos(L) */ - sv = 2.0*su*cu; - cv = cu*cu - su*su; - ss[k][1] = sv; /* sin(2L) */ - cc[k][1] = cv; - for( i=2; i 100) - j = 0; /* p[0] is a flag */ - if( j ) { - k = j; - if( j < 0 ) - k = -k; - su = ss[m][k-1]; /* sin(k*angle) */ - if( j < 0 ) - su = -su; - cu = cc[m][k-1]; - if( k1 == 0 ) { /* set first angle */ - sv = su; - cv = cu; - k1 = 1; - } - else { /* combine angles */ - sw = su*cv + cu*sv; - cv = cu*cv - su*sv; - sv = sw; - } - } - } - /* longitude coefficient, in 0.0001" */ - f = p[5] * 0.0001; - if( p[6] != 0 ) - f += 0.00001 * T * p[6]; - /* obliquity coefficient, in 0.0001" */ - g = p[7] * 0.0001; - if( p[8] != 0 ) - g += 0.00001 * T * p[8]; - if (*p >= 100) { /* coefficients in 0.00001" */ - f *= 0.1; - g *= 0.1; - } - /* accumulate the terms */ - if (*p != 102) { - C += f * sv; - D += g * cv; - } - else { /* cos for nutl and sin for nuto */ - C += f * cv; - D += g * sv; + /* first terms, not in table: */ + C = (-0.01742 * T - 17.1996) * ss[4][0]; /* sin(OM) */ + D = (0.00089 * T + 9.2025) * cc[4][0]; /* cos(OM) */ + for (p = &nt[0]; *p != ENDMARK; p += 9) { + /* argument of sine and cosine */ + k1 = 0; + cv = 0.0; + sv = 0.0; + for (m = 0; m < 5; m++) { + j = p[m]; + if (j > 100) + j = 0; /* p[0] is a flag */ + if (j) { + k = j; + if (j < 0) + k = -k; + su = ss[m][k - 1]; /* sin(k*angle) */ + if (j < 0) + su = -su; + cu = cc[m][k - 1]; + if (k1 == 0) { /* set first angle */ + sv = su; + cv = cu; + k1 = 1; + } + else { /* combine angles */ + sw = su * cv + cu * sv; + cv = cu * cv - su * sv; + sv = sw; + } + } + } + /* longitude coefficient, in 0.0001" */ + f = p[5] * 0.0001; + if (p[6] != 0) + f += 0.00001 * T * p[6]; + /* obliquity coefficient, in 0.0001" */ + g = p[7] * 0.0001; + if (p[8] != 0) + g += 0.00001 * T * p[8]; + if (*p >= 100) { /* coefficients in 0.00001" */ + f *= 0.1; + g *= 0.1; + } + /* accumulate the terms */ + if (*p != 102) { + C += f * sv; + D += g * cv; + } + else { /* cos for nutl and sin for nuto */ + C += f * cv; + D += g * sv; + } + /* + * if (i >= 105) { + * printf("%4.10f, %4.10f\n",f*sv,g*cv); + * } + */ } /* - if (i >= 105) { - printf("%4.10f, %4.10f\n",f*sv,g*cv); - } - */ - } - /* - printf("%4.10f, %4.10f, %4.10f, %4.10f\n",MS*RADTODEG,FF*RADTODEG,DD*RADTODEG,OM*RADTODEG); - printf( "nutation: in longitude %.9f\", in obliquity %.9f\"\n", C, D ); - */ - /* Save answers, expressed in radians */ - nutlo[0] = DEGTORAD * C / 3600.0; - nutlo[1] = DEGTORAD * D / 3600.0; - return(0); + * printf("%4.10f, %4.10f, %4.10f, %4.10f\n",MS*RADTODEG,FF*RADTODEG,DD*RADTODEG,OM*RADTODEG); + * printf( "nutation: in longitude %.9f\", in obliquity %.9f\"\n", C, D ); + */ + /* Save answers, expressed in radians */ + nutlo[0] = DEGTORAD * C / 3600.0; + nutlo[1] = DEGTORAD * D / 3600.0; + return (0); } #endif #if NUT_IAU_2000A || NUT_IAU_2000B + /* Nutation IAU 2000A model * (MHB2000 luni-solar and planetary nutation, without free core nutation) * @@ -1390,231 +1498,230 @@ int swi_nutation(double J, double *nutlo) */ #include "swenut2000a.h" -int swi_nutation(double J, double *nutlo) +int +swi_nutation(double J, double *nutlo) { - int i, j, k, inls; - double M, SM, F, D, OM; + int i, j, k, inls; + double M, SM, F, D, OM; #if NUT_IAU_2000A - double AL, ALSU, AF, AD, AOM, APA; - double ALME, ALVE, ALEA, ALMA, ALJU, ALSA, ALUR, ALNE; + double AL, ALSU, AF, AD, AOM, APA; + double ALME, ALVE, ALEA, ALMA, ALJU, ALSA, ALUR, ALNE; #endif - double darg, sinarg, cosarg; - double dpsi = 0, deps = 0; - double T = (J - J2000 ) / 36525.0; - /* luni-solar nutation */ - /* Fundamental arguments, Simon & al. (1994) */ - /* Mean anomaly of the Moon. */ - M = swe_degnorm(( 485868.249036 + - T*( 1717915923.2178 + - T*( 31.8792 + - T*( 0.051635 + - T*( - 0.00024470 ))))) / 3600.0) * DEGTORAD; - /* Mean anomaly of the Sun */ - SM = swe_degnorm((1287104.79305 + - T*( 129596581.0481 + - T*( - 0.5532 + - T*( 0.000136 + - T*( - 0.00001149 ))))) / 3600.0) * DEGTORAD; - /* Mean argument of the latitude of the Moon. */ - F = swe_degnorm(( 335779.526232 + - T*( 1739527262.8478 + - T*( - 12.7512 + - T*( - 0.001037 + - T*( 0.00000417 ))))) / 3600.0) * DEGTORAD; - /* Mean elongation of the Moon from the Sun. */ - D = swe_degnorm((1072260.70369 + - T*( 1602961601.2090 + - T*( - 6.3706 + - T*( 0.006593 + - T*( - 0.00003169 ))))) / 3600.0) * DEGTORAD; - /* Mean longitude of the ascending node of the Moon. */ - OM = swe_degnorm(( 450160.398036 + - T*( - 6962890.5431 + - T*( 7.4722 + - T*( 0.007702 + - T*( - 0.00005939 ))))) / 3600.0) * DEGTORAD; - /* luni-solar nutation series, in reverse order, starting with small terms */ + double darg, sinarg, cosarg; + double dpsi = 0, deps = 0; + double T = (J - J2000) / 36525.0; + /* luni-solar nutation */ + /* Fundamental arguments, Simon & al. (1994) */ + /* Mean anomaly of the Moon. */ + M = swe_degnorm((485868.249036 + + T * (1717915923.2178 + + T * (31.8792 + + T * (0.051635 + + T * (-0.00024470))))) / 3600.0) * + DEGTORAD; + /* Mean anomaly of the Sun */ + SM = swe_degnorm((1287104.79305 + + T * (129596581.0481 + + T * (-0.5532 + + T * (0.000136 + + T * (-0.00001149))))) / 3600.0) * + DEGTORAD; + /* Mean argument of the latitude of the Moon. */ + F = swe_degnorm((335779.526232 + + T * (1739527262.8478 + + T * (-12.7512 + + T * (-0.001037 + + T * (0.00000417))))) / 3600.0) * DEGTORAD; + /* Mean elongation of the Moon from the Sun. */ + D = swe_degnorm((1072260.70369 + + T * (1602961601.2090 + + T * (-6.3706 + + T * (0.006593 + + T * (-0.00003169))))) / 3600.0) * + DEGTORAD; + /* Mean longitude of the ascending node of the Moon. */ + OM = swe_degnorm((450160.398036 + + T * (-6962890.5431 + + T * (7.4722 + + T * (0.007702 + + T * (-0.00005939))))) / 3600.0) * + DEGTORAD; + /* luni-solar nutation series, in reverse order, starting with small terms */ #if NUT_IAU_2000B - inls = NLS_2000B; + inls = NLS_2000B; #else - inls = NLS; + inls = NLS; #endif - for (i = inls - 1; i >= 0; i--) { - j = i * 5; - darg = swe_radnorm((double) nls[j + 0] * M + - (double) nls[j + 1] * SM + - (double) nls[j + 2] * F + - (double) nls[j + 3] * D + - (double) nls[j + 4] * OM); - sinarg = sin(darg); - cosarg = cos(darg); - k = i * 6; - dpsi += (cls[k+0] + cls[k+1] * T) * sinarg + cls[k+2] * cosarg; - deps += (cls[k+3] + cls[k+4] * T) * cosarg + cls[k+5] * sinarg; - } - nutlo[0] = dpsi * O1MAS2DEG; - nutlo[1] = deps * O1MAS2DEG; + for (i = inls - 1; i >= 0; i--) { + j = i * 5; + darg = + swe_radnorm((double)nls[j + 0] * M + (double)nls[j + 1] * SM + + (double)nls[j + 2] * F + (double)nls[j + 3] * D + + (double)nls[j + 4] * OM); + sinarg = sin(darg); + cosarg = cos(darg); + k = i * 6; + dpsi += (cls[k + 0] + cls[k + 1] * T) * sinarg + cls[k + 2] * cosarg; + deps += (cls[k + 3] + cls[k + 4] * T) * cosarg + cls[k + 5] * sinarg; + } + nutlo[0] = dpsi * O1MAS2DEG; + nutlo[1] = deps * O1MAS2DEG; #if NUT_IAU_2000A - /* planetary nutation - * note: The MHB2000 code computes the luni-solar and planetary nutation - * in different routines, using slightly different Delaunay - * arguments in the two cases. This behaviour is faithfully - * reproduced here. Use of the Simon et al. expressions for both - * cases leads to negligible changes, well below 0.1 microarcsecond.*/ - /* Mean anomaly of the Moon.*/ - AL = swe_radnorm(2.35555598 + 8328.6914269554 * T); - /* Mean anomaly of the Sun.*/ - ALSU = swe_radnorm(6.24006013 + 628.301955 * T); - /* Mean argument of the latitude of the Moon. */ - AF = swe_radnorm(1.627905234 + 8433.466158131 * T); - /* Mean elongation of the Moon from the Sun. */ - AD = swe_radnorm(5.198466741 + 7771.3771468121 * T); - /* Mean longitude of the ascending node of the Moon. */ - AOM = swe_radnorm(2.18243920 - 33.757045 * T); - /* General accumulated precession in longitude. */ - APA = (0.02438175 + 0.00000538691 * T) * T; - /* Planetary longitudes, Mercury through Neptune (Souchay et al. 1999). */ - ALME = swe_radnorm(4.402608842 + 2608.7903141574 * T); - ALVE = swe_radnorm(3.176146697 + 1021.3285546211 * T); - ALEA = swe_radnorm(1.753470314 + 628.3075849991 * T); - ALMA = swe_radnorm(6.203480913 + 334.0612426700 * T); - ALJU = swe_radnorm(0.599546497 + 52.9690962641 * T); - ALSA = swe_radnorm(0.874016757 + 21.3299104960 * T); - ALUR = swe_radnorm(5.481293871 + 7.4781598567 * T); - ALNE = swe_radnorm(5.321159000 + 3.8127774000 * T); - /* planetary nutation series (in reverse order).*/ - dpsi = 0; - deps = 0; - for (i = NPL - 1; i >= 0; i--) { - j = i * 14; - darg = swe_radnorm((double) npl[j + 0] * AL + - (double) npl[j + 1] * ALSU + - (double) npl[j + 2] * AF + - (double) npl[j + 3] * AD + - (double) npl[j + 4] * AOM + - (double) npl[j + 5] * ALME + - (double) npl[j + 6] * ALVE + - (double) npl[j + 7] * ALEA + - (double) npl[j + 8] * ALMA + - (double) npl[j + 9] * ALJU + - (double) npl[j +10] * ALSA + - (double) npl[j +11] * ALUR + - (double) npl[j +12] * ALNE + - (double) npl[j +13] * APA); - k = i * 4; - sinarg = sin(darg); - cosarg = cos(darg); - dpsi += (double) icpl[k+0] * sinarg + (double) icpl[k+1] * cosarg; - deps += (double) icpl[k+2] * sinarg + (double) icpl[k+3] * cosarg; - } - nutlo[0] += dpsi * O1MAS2DEG; - nutlo[1] += deps * O1MAS2DEG; + /* planetary nutation + * note: The MHB2000 code computes the luni-solar and planetary nutation + * in different routines, using slightly different Delaunay + * arguments in the two cases. This behaviour is faithfully + * reproduced here. Use of the Simon et al. expressions for both + * cases leads to negligible changes, well below 0.1 microarcsecond.*/ + /* Mean anomaly of the Moon. */ + AL = swe_radnorm(2.35555598 + 8328.6914269554 * T); + /* Mean anomaly of the Sun. */ + ALSU = swe_radnorm(6.24006013 + 628.301955 * T); + /* Mean argument of the latitude of the Moon. */ + AF = swe_radnorm(1.627905234 + 8433.466158131 * T); + /* Mean elongation of the Moon from the Sun. */ + AD = swe_radnorm(5.198466741 + 7771.3771468121 * T); + /* Mean longitude of the ascending node of the Moon. */ + AOM = swe_radnorm(2.18243920 - 33.757045 * T); + /* General accumulated precession in longitude. */ + APA = (0.02438175 + 0.00000538691 * T) * T; + /* Planetary longitudes, Mercury through Neptune (Souchay et al. 1999). */ + ALME = swe_radnorm(4.402608842 + 2608.7903141574 * T); + ALVE = swe_radnorm(3.176146697 + 1021.3285546211 * T); + ALEA = swe_radnorm(1.753470314 + 628.3075849991 * T); + ALMA = swe_radnorm(6.203480913 + 334.0612426700 * T); + ALJU = swe_radnorm(0.599546497 + 52.9690962641 * T); + ALSA = swe_radnorm(0.874016757 + 21.3299104960 * T); + ALUR = swe_radnorm(5.481293871 + 7.4781598567 * T); + ALNE = swe_radnorm(5.321159000 + 3.8127774000 * T); + /* planetary nutation series (in reverse order). */ + dpsi = 0; + deps = 0; + for (i = NPL - 1; i >= 0; i--) { + j = i * 14; + darg = + swe_radnorm((double)npl[j + 0] * AL + (double)npl[j + 1] * ALSU + + (double)npl[j + 2] * AF + (double)npl[j + 3] * AD + + (double)npl[j + 4] * AOM + (double)npl[j + 5] * ALME + + (double)npl[j + 6] * ALVE + (double)npl[j + + 7] * ALEA + + (double)npl[j + 8] * ALMA + (double)npl[j + + 9] * ALJU + + (double)npl[j + 10] * ALSA + (double)npl[j + + 11] * ALUR + + (double)npl[j + 12] * ALNE + (double)npl[j + + 13] * APA); + k = i * 4; + sinarg = sin(darg); + cosarg = cos(darg); + dpsi += (double)icpl[k + 0] * sinarg + (double)icpl[k + 1] * cosarg; + deps += (double)icpl[k + 2] * sinarg + (double)icpl[k + 3] * cosarg; + } + nutlo[0] += dpsi * O1MAS2DEG; + nutlo[1] += deps * O1MAS2DEG; #if 1 - /* changes required by adoption of P03 precession - * according to Capitaine et al. A & A 412, 366 (2005) */ - dpsi = -8.1 * sin(OM) - 0.6 * sin(2 * F - 2 * D + 2 * OM); - dpsi += T * (47.8 * sin(OM) + 3.7 * sin(2 * F - 2 * D + 2 * OM) + 0.6 * sin(2 * F + 2 * OM) - 0.6 * sin(2 * OM)); - deps = T * (-25.6 * cos(OM) - 1.6 * cos(2 * F - 2 * D + 2 * OM)); - nutlo[0] += dpsi / (3600.0 * 1000000.0); - nutlo[1] += deps / (3600.0 * 1000000.0); + /* changes required by adoption of P03 precession + * according to Capitaine et al. A & A 412, 366 (2005) */ + dpsi = -8.1 * sin(OM) - 0.6 * sin(2 * F - 2 * D + 2 * OM); + dpsi += + T * (47.8 * sin(OM) + 3.7 * sin(2 * F - 2 * D + 2 * OM) + + 0.6 * sin(2 * F + 2 * OM) - 0.6 * sin(2 * OM)); + deps = T * (-25.6 * cos(OM) - 1.6 * cos(2 * F - 2 * D + 2 * OM)); + nutlo[0] += dpsi / (3600.0 * 1000000.0); + nutlo[1] += deps / (3600.0 * 1000000.0); #endif #endif - nutlo[0] *= DEGTORAD; - nutlo[1] *= DEGTORAD; - return 0; + nutlo[0] *= DEGTORAD; + nutlo[1] *= DEGTORAD; + return 0; } #endif /* GCRS to J2000 */ -void swi_bias(double *x, int32 iflag, AS_BOOL backward) +void +swi_bias(double *x, int32 iflag, AS_BOOL backward) { #if 0 - double DAS2R = 1.0 / 3600.0 * DEGTORAD; - double dpsi_bias = -0.041775 * DAS2R; - double deps_bias = -0.0068192 * DAS2R; - double dra0 = -0.0146 * DAS2R; - double deps2000 = 84381.448 * DAS2R; + double DAS2R = 1.0 / 3600.0 * DEGTORAD; + double dpsi_bias = -0.041775 * DAS2R; + double deps_bias = -0.0068192 * DAS2R; + double dra0 = -0.0146 * DAS2R; + double deps2000 = 84381.448 * DAS2R; #endif - double xx[6], rb[3][3]; - int i; - rb[0][0] = +0.9999999999999942; - rb[0][1] = +0.0000000707827948; - rb[0][2] = -0.0000000805621738; - rb[1][0] = -0.0000000707827974; - rb[1][1] = +0.9999999999999969; - rb[1][2] = -0.0000000330604088; - rb[2][0] = +0.0000000805621715; - rb[2][1] = +0.0000000330604145; - rb[2][2] = +0.9999999999999962; - if (backward) { - for (i = 0; i <= 2; i++) { - xx[i] = x[0] * rb[i][0] + - x[1] * rb[i][1] + - x[2] * rb[i][2]; - if (iflag & SEFLG_SPEED) - xx[i+3] = x[3] * rb[i][0] + - x[4] * rb[i][1] + - x[5] * rb[i][2]; + double xx[6], rb[3][3]; + int i; + rb[0][0] = +0.9999999999999942; + rb[0][1] = +0.0000000707827948; + rb[0][2] = -0.0000000805621738; + rb[1][0] = -0.0000000707827974; + rb[1][1] = +0.9999999999999969; + rb[1][2] = -0.0000000330604088; + rb[2][0] = +0.0000000805621715; + rb[2][1] = +0.0000000330604145; + rb[2][2] = +0.9999999999999962; + if (backward) { + for (i = 0; i <= 2; i++) { + xx[i] = x[0] * rb[i][0] + x[1] * rb[i][1] + x[2] * rb[i][2]; + if (iflag & SEFLG_SPEED) + xx[i + 3] = + x[3] * rb[i][0] + x[4] * rb[i][1] + x[5] * rb[i][2]; + } } - } else { - for (i = 0; i <= 2; i++) { - xx[i] = x[0] * rb[0][i] + - x[1] * rb[1][i] + - x[2] * rb[2][i]; - if (iflag & SEFLG_SPEED) - xx[i+3] = x[3] * rb[0][i] + - x[4] * rb[1][i] + - x[5] * rb[2][i]; + else { + for (i = 0; i <= 2; i++) { + xx[i] = x[0] * rb[0][i] + x[1] * rb[1][i] + x[2] * rb[2][i]; + if (iflag & SEFLG_SPEED) + xx[i + 3] = + x[3] * rb[0][i] + x[4] * rb[1][i] + x[5] * rb[2][i]; + } } - } - for (i = 0; i <= 2; i++) x[i] = xx[i]; - if (iflag & SEFLG_SPEED) - for (i = 3; i <= 5; i++) x[i] = xx[i]; + for (i = 0; i <= 2; i++) + x[i] = xx[i]; + if (iflag & SEFLG_SPEED) + for (i = 3; i <= 5; i++) + x[i] = xx[i]; } /* GCRS to FK5 */ -void swi_icrs2fk5(double *x, int32 iflag, AS_BOOL backward) +void +swi_icrs2fk5(double *x, int32 iflag, AS_BOOL backward) { #if 0 - double DAS2R = 1.0 / 3600.0 * DEGTORAD; - double dra0 = -0.0229 * DAS2R; - double dxi0 = 0.0091 * DAS2R; - double det0 = -0.0199 * DAS2R; + double DAS2R = 1.0 / 3600.0 * DEGTORAD; + double dra0 = -0.0229 * DAS2R; + double dxi0 = 0.0091 * DAS2R; + double det0 = -0.0199 * DAS2R; #endif - double xx[6], rb[3][3]; - int i; - rb[0][0] = +0.9999999999999928; - rb[0][1] = +0.0000001110223287; - rb[0][2] = +0.0000000441180557; - rb[1][0] = -0.0000001110223330; - rb[1][1] = +0.9999999999999891; - rb[1][2] = +0.0000000964779176; - rb[2][0] = -0.0000000441180450; - rb[2][1] = -0.0000000964779225; - rb[2][2] = +0.9999999999999943; - if (backward) { - for (i = 0; i <= 2; i++) { - xx[i] = x[0] * rb[i][0] + - x[1] * rb[i][1] + - x[2] * rb[i][2]; - if (iflag & SEFLG_SPEED) - xx[i+3] = x[3] * rb[i][0] + - x[4] * rb[i][1] + - x[5] * rb[i][2]; + double xx[6], rb[3][3]; + int i; + rb[0][0] = +0.9999999999999928; + rb[0][1] = +0.0000001110223287; + rb[0][2] = +0.0000000441180557; + rb[1][0] = -0.0000001110223330; + rb[1][1] = +0.9999999999999891; + rb[1][2] = +0.0000000964779176; + rb[2][0] = -0.0000000441180450; + rb[2][1] = -0.0000000964779225; + rb[2][2] = +0.9999999999999943; + if (backward) { + for (i = 0; i <= 2; i++) { + xx[i] = x[0] * rb[i][0] + x[1] * rb[i][1] + x[2] * rb[i][2]; + if (iflag & SEFLG_SPEED) + xx[i + 3] = + x[3] * rb[i][0] + x[4] * rb[i][1] + x[5] * rb[i][2]; + } } - } else { - for (i = 0; i <= 2; i++) { - xx[i] = x[0] * rb[0][i] + - x[1] * rb[1][i] + - x[2] * rb[2][i]; - if (iflag & SEFLG_SPEED) - xx[i+3] = x[3] * rb[0][i] + - x[4] * rb[1][i] + - x[5] * rb[2][i]; + else { + for (i = 0; i <= 2; i++) { + xx[i] = x[0] * rb[0][i] + x[1] * rb[1][i] + x[2] * rb[2][i]; + if (iflag & SEFLG_SPEED) + xx[i + 3] = + x[3] * rb[0][i] + x[4] * rb[1][i] + x[5] * rb[2][i]; + } } - } - for (i = 0; i <= 5; i++) x[i] = xx[i]; + for (i = 0; i <= 5; i++) + x[i] = xx[i]; } /* DeltaT = Ephemeris Time - Universal Time, in days. @@ -1720,66 +1827,83 @@ void swi_icrs2fk5(double *x, int32 iflag, AS_BOOL backward) */ #define TABSTART 1620 #define TABEND 2017 -#define TABSIZ (TABEND-TABSTART+1) +#define TABSIZ (TABEND-TABSTART+1) + /* we make the table greater for additional values read from external file */ #define TABSIZ_SPACE (TABSIZ+100) static double FAR dt[TABSIZ_SPACE] = { + /* 1620.0 thru 1659.0 */ -124.00, 119.00, 115.00, 110.00, 106.00, 102.00, 98.00, 95.00, 91.00, 88.00, -85.00, 82.00, 79.00, 77.00, 74.00, 72.00, 70.00, 67.00, 65.00, 63.00, -62.00, 60.00, 58.00, 57.00, 55.00, 54.00, 53.00, 51.00, 50.00, 49.00, -48.00, 47.00, 46.00, 45.00, 44.00, 43.00, 42.00, 41.00, 40.00, 38.00, + 124.00, 119.00, 115.00, 110.00, 106.00, 102.00, 98.00, 95.00, 91.00, + 88.00, + 85.00, 82.00, 79.00, 77.00, 74.00, 72.00, 70.00, 67.00, 65.00, 63.00, + 62.00, 60.00, 58.00, 57.00, 55.00, 54.00, 53.00, 51.00, 50.00, 49.00, + 48.00, 47.00, 46.00, 45.00, 44.00, 43.00, 42.00, 41.00, 40.00, 38.00, + /* 1660.0 thru 1699.0 */ -37.00, 36.00, 35.00, 34.00, 33.00, 32.00, 31.00, 30.00, 28.00, 27.00, -26.00, 25.00, 24.00, 23.00, 22.00, 21.00, 20.00, 19.00, 18.00, 17.00, -16.00, 15.00, 14.00, 14.00, 13.00, 12.00, 12.00, 11.00, 11.00, 10.00, -10.00, 10.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, + 37.00, 36.00, 35.00, 34.00, 33.00, 32.00, 31.00, 30.00, 28.00, 27.00, + 26.00, 25.00, 24.00, 23.00, 22.00, 21.00, 20.00, 19.00, 18.00, 17.00, + 16.00, 15.00, 14.00, 14.00, 13.00, 12.00, 12.00, 11.00, 11.00, 10.00, + 10.00, 10.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, + /* 1700.0 thru 1739.0 */ -9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 10.00, 10.00, -10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 11.00, 11.00, 11.00, -11.00, 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, -11.00, 11.00, 11.00, 11.00, 12.00, 12.00, 12.00, 12.00, 12.00, 12.00, + 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 9.00, 10.00, 10.00, + 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 11.00, 11.00, 11.00, + 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, 11.00, + 11.00, 11.00, 11.00, 11.00, 12.00, 12.00, 12.00, 12.00, 12.00, 12.00, + /* 1740.0 thru 1779.0 */ -12.00, 12.00, 12.00, 12.00, 13.00, 13.00, 13.00, 13.00, 13.00, 13.00, -13.00, 14.00, 14.00, 14.00, 14.00, 14.00, 14.00, 14.00, 15.00, 15.00, -15.00, 15.00, 15.00, 15.00, 15.00, 16.00, 16.00, 16.00, 16.00, 16.00, -16.00, 16.00, 16.00, 16.00, 16.00, 17.00, 17.00, 17.00, 17.00, 17.00, + 12.00, 12.00, 12.00, 12.00, 13.00, 13.00, 13.00, 13.00, 13.00, 13.00, + 13.00, 14.00, 14.00, 14.00, 14.00, 14.00, 14.00, 14.00, 15.00, 15.00, + 15.00, 15.00, 15.00, 15.00, 15.00, 16.00, 16.00, 16.00, 16.00, 16.00, + 16.00, 16.00, 16.00, 16.00, 16.00, 17.00, 17.00, 17.00, 17.00, 17.00, + /* 1780.0 thru 1799.0 */ -17.00, 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, -17.00, 17.00, 16.00, 16.00, 16.00, 16.00, 15.00, 15.00, 14.00, 14.00, + 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, 17.00, + 17.00, 17.00, 16.00, 16.00, 16.00, 16.00, 15.00, 15.00, 14.00, 14.00, + /* 1800.0 thru 1819.0 */ -13.70, 13.40, 13.10, 12.90, 12.70, 12.60, 12.50, 12.50, 12.50, 12.50, -12.50, 12.50, 12.50, 12.50, 12.50, 12.50, 12.50, 12.40, 12.30, 12.20, + 13.70, 13.40, 13.10, 12.90, 12.70, 12.60, 12.50, 12.50, 12.50, 12.50, + 12.50, 12.50, 12.50, 12.50, 12.50, 12.50, 12.50, 12.40, 12.30, 12.20, + /* 1820.0 thru 1859.0 */ -12.00, 11.70, 11.40, 11.10, 10.60, 10.20, 9.60, 9.10, 8.60, 8.00, -7.50, 7.00, 6.60, 6.30, 6.00, 5.80, 5.70, 5.60, 5.60, 5.60, -5.70, 5.80, 5.90, 6.10, 6.20, 6.30, 6.50, 6.60, 6.80, 6.90, -7.10, 7.20, 7.30, 7.40, 7.50, 7.60, 7.70, 7.70, 7.80, 7.80, + 12.00, 11.70, 11.40, 11.10, 10.60, 10.20, 9.60, 9.10, 8.60, 8.00, + 7.50, 7.00, 6.60, 6.30, 6.00, 5.80, 5.70, 5.60, 5.60, 5.60, + 5.70, 5.80, 5.90, 6.10, 6.20, 6.30, 6.50, 6.60, 6.80, 6.90, + 7.10, 7.20, 7.30, 7.40, 7.50, 7.60, 7.70, 7.70, 7.80, 7.80, + /* 1860.0 thru 1899.0 */ -7.88, 7.82, 7.54, 6.97, 6.40, 6.02, 5.41, 4.10, 2.92, 1.82, -1.61, .10, -1.02, -1.28, -2.69, -3.24, -3.64, -4.54, -4.71, -5.11, --5.40, -5.42, -5.20, -5.46, -5.46, -5.79, -5.63, -5.64, -5.80, -5.66, --5.87, -6.01, -6.19, -6.64, -6.44, -6.47, -6.09, -5.76, -4.66, -3.74, + 7.88, 7.82, 7.54, 6.97, 6.40, 6.02, 5.41, 4.10, 2.92, 1.82, + 1.61, .10, -1.02, -1.28, -2.69, -3.24, -3.64, -4.54, -4.71, -5.11, + -5.40, -5.42, -5.20, -5.46, -5.46, -5.79, -5.63, -5.64, -5.80, -5.66, + -5.87, -6.01, -6.19, -6.64, -6.44, -6.47, -6.09, -5.76, -4.66, -3.74, + /* 1900.0 thru 1939.0 */ --2.72, -1.54, -.02, 1.24, 2.64, 3.86, 5.37, 6.14, 7.75, 9.13, -10.46, 11.53, 13.36, 14.65, 16.01, 17.20, 18.24, 19.06, 20.25, 20.95, -21.16, 22.25, 22.41, 23.03, 23.49, 23.62, 23.86, 24.49, 24.34, 24.08, -24.02, 24.00, 23.87, 23.95, 23.86, 23.93, 23.73, 23.92, 23.96, 24.02, + -2.72, -1.54, -.02, 1.24, 2.64, 3.86, 5.37, 6.14, 7.75, 9.13, + 10.46, 11.53, 13.36, 14.65, 16.01, 17.20, 18.24, 19.06, 20.25, 20.95, + 21.16, 22.25, 22.41, 23.03, 23.49, 23.62, 23.86, 24.49, 24.34, 24.08, + 24.02, 24.00, 23.87, 23.95, 23.86, 23.93, 23.73, 23.92, 23.96, 24.02, + /* 1940.0 thru 1979.0 */ - 24.33, 24.83, 25.30, 25.70, 26.24, 26.77, 27.28, 27.78, 28.25, 28.71, - 29.15, 29.57, 29.97, 30.36, 30.72, 31.07, 31.35, 31.68, 32.18, 32.68, - 33.15, 33.59, 34.00, 34.47, 35.03, 35.73, 36.54, 37.43, 38.29, 39.20, - 40.18, 41.17, 42.23, 43.37, 44.49, 45.48, 46.46, 47.52, 48.53, 49.59, + 24.33, 24.83, 25.30, 25.70, 26.24, 26.77, 27.28, 27.78, 28.25, 28.71, + 29.15, 29.57, 29.97, 30.36, 30.72, 31.07, 31.35, 31.68, 32.18, 32.68, + 33.15, 33.59, 34.00, 34.47, 35.03, 35.73, 36.54, 37.43, 38.29, 39.20, + 40.18, 41.17, 42.23, 43.37, 44.49, 45.48, 46.46, 47.52, 48.53, 49.59, + /* 1980.0 thru 1999.0 */ - 50.54, 51.38, 52.17, 52.96, 53.79, 54.34, 54.87, 55.32, 55.82, 56.30, - 56.86, 57.57, 58.31, 59.12, 59.98, 60.78, 61.63, 62.30, 62.97, 63.47, + 50.54, 51.38, 52.17, 52.96, 53.79, 54.34, 54.87, 55.32, 55.82, 56.30, + 56.86, 57.57, 58.31, 59.12, 59.98, 60.78, 61.63, 62.30, 62.97, 63.47, + /* 2000.0 thru 2009.0 */ - 63.83, 64.09, 64.30, 64.47, 64.57, 64.69, 64.85, 65.15, 65.46, 65.78, + 63.83, 64.09, 64.30, 64.47, 64.57, 64.69, 64.85, 65.15, 65.46, 65.78, + /* 2010.0 thru 2013.0 */ - 66.07, 66.32, 66.60, 66.91, + 66.07, 66.32, 66.60, 66.91, + /* Extrapolated values, 2014 - 2017 */ - 67.50, 68.00, 68.50, 69.00, + 67.50, 68.00, 68.50, 69.00, }; + #define ESPENAK_MEEUS_2006 TRUE #define TAB2_SIZ 27 #define TAB2_START (-1000) @@ -1787,331 +1911,371 @@ static double FAR dt[TABSIZ_SPACE] = { #define TAB2_STEP 100 #define LTERM_EQUATION_YSTART 1820 #define LTERM_EQUATION_COEFF 32 + /* Table for -1000 through 1600, from Morrison & Stephenson (2004). */ static short FAR dt2[TAB2_SIZ] = { + /*-1000 -900 -800 -700 -600 -500 -400 -300 -200 -100*/ - 25400,23700,22000,21000,19040,17190,15530,14080,12790,11640, + 25400, 23700, 22000, 21000, 19040, 17190, 15530, 14080, 12790, 11640, + /* 0 100 200 300 400 500 600 700 800 900*/ - 10580, 9600, 8640, 7680, 6700, 5710, 4740, 3810, 2960, 2200, + 10580, 9600, 8640, 7680, 6700, 5710, 4740, 3810, 2960, 2200, + /* 1000 1100 1200 1300 1400 1500 1600, */ - 1570, 1090, 740, 490, 320, 200, 120, + 1570, 1090, 740, 490, 320, 200, 120, }; + /* returns DeltaT (ET - UT) in days * double tjd = julian day in UT */ #define DEMO 0 -double FAR PASCAL_CONV swe_deltat(double tjd) +double FAR PASCAL_CONV +swe_deltat(double tjd) { - double ans = 0; - double B, Y, Ygreg, dd; - int iy; - /* read additional values from swedelta.txt */ - AS_BOOL use_espenak_meeus = ESPENAK_MEEUS_2006; - Y = 2000.0 + (tjd - J2000)/365.25; - Ygreg = 2000.0 + (tjd - J2000)/365.2425; - /* Before 1633 AD, if the macro ESPENAK_MEEUS_2006 is TRUE: - * Polynomials by Espenak & Meeus 2006, derived from Stephenson & Morrison - * 2004. - * Note, Espenak & Meeus use their formulae only from 2000 BC on. - * However, they use the long-term formula of Morrison & Stephenson, - * which can be used even for the remoter past. - */ - if (use_espenak_meeus && tjd < 2317746.13090277789) { - return deltat_espenak_meeus_1620(tjd); - } - /* If the macro ESPENAK_MEEUS_2006 is FALSE: - * Before 1620, we follow Stephenson & Morrsion 2004. For the tabulated - * values 1000 BC through 1600 AD, we use linear interpolation. - */ - if (Y < TABSTART) { - if (Y < TAB2_END) { - return deltat_stephenson_morrison_1600(tjd); - } else { - /* between 1600 and 1620: - * linear interpolation between - * end of table dt2 and start of table dt */ - if (Y >= TAB2_END) { - B = TABSTART - TAB2_END; - iy = (TAB2_END - TAB2_START) / TAB2_STEP; - dd = (Y - TAB2_END) / B; - /*ans = dt2[iy] + dd * (dt[0] / 100.0 - dt2[iy]);*/ - ans = dt2[iy] + dd * (dt[0] - dt2[iy]); - ans = adjust_for_tidacc(ans, Ygreg); - return ans / 86400.0; - } + double ans = 0; + double B, Y, Ygreg, dd; + int iy; + /* read additional values from swedelta.txt */ + AS_BOOL use_espenak_meeus = ESPENAK_MEEUS_2006; + Y = 2000.0 + (tjd - J2000) / 365.25; + Ygreg = 2000.0 + (tjd - J2000) / 365.2425; + /* Before 1633 AD, if the macro ESPENAK_MEEUS_2006 is TRUE: + * Polynomials by Espenak & Meeus 2006, derived from Stephenson & Morrison + * 2004. + * Note, Espenak & Meeus use their formulae only from 2000 BC on. + * However, they use the long-term formula of Morrison & Stephenson, + * which can be used even for the remoter past. + */ + if (use_espenak_meeus && tjd < 2317746.13090277789) { + return deltat_espenak_meeus_1620(tjd); + } + /* If the macro ESPENAK_MEEUS_2006 is FALSE: + * Before 1620, we follow Stephenson & Morrsion 2004. For the tabulated + * values 1000 BC through 1600 AD, we use linear interpolation. + */ + if (Y < TABSTART) { + if (Y < TAB2_END) { + return deltat_stephenson_morrison_1600(tjd); + } + else { + /* between 1600 and 1620: + * linear interpolation between + * end of table dt2 and start of table dt */ + if (Y >= TAB2_END) { + B = TABSTART - TAB2_END; + iy = (TAB2_END - TAB2_START) / TAB2_STEP; + dd = (Y - TAB2_END) / B; + /*ans = dt2[iy] + dd * (dt[0] / 100.0 - dt2[iy]); */ + ans = dt2[iy] + dd * (dt[0] - dt2[iy]); + ans = adjust_for_tidacc(ans, Ygreg); + return ans / 86400.0; + } + } + } + /* 1620 - today + a few years (tabend): + * Besselian interpolation from tabulated values in table dt. + * See AA page K11. + */ + if (Y >= TABSTART) { + return deltat_aa(tjd); } - } - /* 1620 - today + a few years (tabend): - * Besselian interpolation from tabulated values in table dt. - * See AA page K11. - */ - if (Y >= TABSTART) { - return deltat_aa(tjd); - } #ifdef TRACE - swi_open_trace(NULL); - if (swi_trace_count < TRACE_COUNT_MAX) { - if (swi_fp_trace_c != NULL) { - fputs("\n/*SWE_DELTAT*/\n", swi_fp_trace_c); - fprintf(swi_fp_trace_c, " tjd = %.9f;", tjd); - fprintf(swi_fp_trace_c, " t = swe_deltat(tjd);\n"); - fputs(" printf(\"swe_deltat: %f\\t%f\\t\\n\", ", swi_fp_trace_c); - fputs("tjd, t);\n", swi_fp_trace_c); - fflush(swi_fp_trace_c); + swi_open_trace(NULL); + if (swi_trace_count < TRACE_COUNT_MAX) { + if (swi_fp_trace_c != NULL) { + fputs("\n/*SWE_DELTAT*/\n", swi_fp_trace_c); + fprintf(swi_fp_trace_c, " tjd = %.9f;", tjd); + fprintf(swi_fp_trace_c, " t = swe_deltat(tjd);\n"); + fputs(" printf(\"swe_deltat: %f\\t%f\\t\\n\", ", swi_fp_trace_c); + fputs("tjd, t);\n", swi_fp_trace_c); + fflush(swi_fp_trace_c); + } + if (swi_fp_trace_out != NULL) { + fprintf(swi_fp_trace_out, "swe_deltat: %f\t%f\t\n", tjd, ans); + fflush(swi_fp_trace_out); + } } - if (swi_fp_trace_out != NULL) { - fprintf(swi_fp_trace_out, "swe_deltat: %f\t%f\t\n", tjd, ans); - fflush(swi_fp_trace_out); - } - } #endif - return ans / 86400.0; -} - -static double deltat_aa(double tjd) -{ - double ans = 0, ans2, ans3; - double p, B, B2, Y, dd; - double d[6]; - int i, iy, k; - /* read additional values from swedelta.txt */ - int tabsiz = init_dt(); - int tabend = TABSTART + tabsiz - 1; - /*Y = 2000.0 + (tjd - J2000)/365.25;*/ - Y = 2000.0 + (tjd - J2000)/365.2425; - if (Y <= tabend) { - /* Index into the table. - */ - p = floor(Y); - iy = (int) (p - TABSTART); - /* Zeroth order estimate is value at start of year - */ - ans = dt[iy]; - k = iy + 1; - if( k >= tabsiz ) - goto done; /* No data, can't go on. */ - /* The fraction of tabulation interval - */ - p = Y - p; - /* First order interpolated value - */ - ans += p*(dt[k] - dt[iy]); - if( (iy-1 < 0) || (iy+2 >= tabsiz) ) - goto done; /* can't do second differences */ - /* Make table of first differences - */ - k = iy - 2; - for( i=0; i<5; i++ ) { - if( (k < 0) || (k+1 >= tabsiz) ) - d[i] = 0; - else - d[i] = dt[k+1] - dt[k]; - k += 1; - } - /* Compute second differences - */ - for( i=0; i<4; i++ ) - d[i] = d[i+1] - d[i]; - B = 0.25*p*(p-1.0); - ans += B*(d[1] + d[2]); - #if DEMO - printf( "B %.4lf, ans %.4lf\n", B, ans ); - #endif - if( iy+2 >= tabsiz ) - goto done; - /* Compute third differences - */ - for( i=0; i<3; i++ ) - d[i] = d[i+1] - d[i]; - B = 2.0*B/3.0; - ans += (p-0.5)*B*d[1]; - #if DEMO - printf( "B %.4lf, ans %.4lf\n", B*(p-0.5), ans ); - #endif - if( (iy-2 < 0) || (iy+3 > tabsiz) ) - goto done; - /* Compute fourth differences - */ - for( i=0; i<2; i++ ) - d[i] = d[i+1] - d[i]; - B = 0.125*B*(p+1.0)*(p-2.0); - ans += B*(d[0] + d[1]); - #if DEMO - printf( "B %.4lf, ans %.4lf\n", B, ans ); - #endif - done: - ans = adjust_for_tidacc(ans, Y); return ans / 86400.0; - } - /* today - : - * Formula Stephenson (1997; p. 507), - * with modification to avoid jump at end of AA table, - * similar to what Meeus 1998 had suggested. - * Slow transition within 100 years. - */ - B = 0.01 * (Y - 1820); - ans = -20 + 31 * B * B; - /* slow transition from tabulated values to Stephenson formula: */ - if (Y <= tabend+100) { - B2 = 0.01 * (tabend - 1820); - ans2 = -20 + 31 * B2 * B2; - ans3 = dt[tabsiz-1]; - dd = (ans2 - ans3); - ans += dd * (Y - (tabend + 100)) * 0.01; - } - return ans / 86400.0; } -static double deltat_longterm_morrison_stephenson(double tjd) +static double +deltat_aa(double tjd) { - double Ygreg = 2000.0 + (tjd - J2000)/365.2425; - double u = (Ygreg - 1820) / 100.0; - return (-20 + 32 * u * u); -} - -static double deltat_stephenson_morrison_1600(double tjd) -{ - double ans = 0, ans2, ans3; - double p, B, dd; - double tjd0; - int iy; - /* read additional values from swedelta.txt */ - double Y = 2000.0 + (tjd - J2000)/365.2425; - /* double Y = 2000.0 + (tjd - J2000)/365.25;*/ - /* before -1000: - * formula by Stephenson&Morrison (2004; p. 335) but adjusted to fit the - * starting point of table dt2. */ - if( Y < TAB2_START ) { - /*B = (Y - LTERM_EQUATION_YSTART) * 0.01; - ans = -20 + LTERM_EQUATION_COEFF * B * B;*/ - ans = deltat_longterm_morrison_stephenson(tjd); - ans = adjust_for_tidacc(ans, Y); - /* transition from formula to table over 100 years */ - if (Y >= TAB2_START - 100) { - /* starting value of table dt2: */ - ans2 = adjust_for_tidacc(dt2[0], TAB2_START); - /* value of formula at epoch TAB2_START */ - /* B = (TAB2_START - LTERM_EQUATION_YSTART) * 0.01; - ans3 = -20 + LTERM_EQUATION_COEFF * B * B;*/ - tjd0 = (TAB2_START - 2000) * 365.2425 + J2000; - ans3 = deltat_longterm_morrison_stephenson(tjd0); - ans3 = adjust_for_tidacc(ans3, Y); - dd = ans3 - ans2; - B = (Y - (TAB2_START - 100)) * 0.01; - /* fit to starting point of table dt2. */ - ans = ans - dd * B; + double ans = 0, ans2, ans3; + double p, B, B2, Y, dd; + double d[6]; + int i, iy, k; + /* read additional values from swedelta.txt */ + int tabsiz = init_dt(); + int tabend = TABSTART + tabsiz - 1; + /*Y = 2000.0 + (tjd - J2000)/365.25; */ + Y = 2000.0 + (tjd - J2000) / 365.2425; + if (Y <= tabend) { + /* Index into the table. + */ + p = floor(Y); + iy = (int)(p - TABSTART); + /* Zeroth order estimate is value at start of year + */ + ans = dt[iy]; + k = iy + 1; + if (k >= tabsiz) + goto done; /* No data, can't go on. */ + /* The fraction of tabulation interval + */ + p = Y - p; + /* First order interpolated value + */ + ans += p * (dt[k] - dt[iy]); + if ((iy - 1 < 0) || (iy + 2 >= tabsiz)) + goto done; /* can't do second differences */ + /* Make table of first differences + */ + k = iy - 2; + for (i = 0; i < 5; i++) { + if ((k < 0) || (k + 1 >= tabsiz)) + d[i] = 0; + else + d[i] = dt[k + 1] - dt[k]; + k += 1; + } + /* Compute second differences + */ + for (i = 0; i < 4; i++) + d[i] = d[i + 1] - d[i]; + B = 0.25 * p * (p - 1.0); + ans += B * (d[1] + d[2]); +#if DEMO + printf("B %.4lf, ans %.4lf\n", B, ans); +#endif + if (iy + 2 >= tabsiz) + goto done; + /* Compute third differences + */ + for (i = 0; i < 3; i++) + d[i] = d[i + 1] - d[i]; + B = 2.0 * B / 3.0; + ans += (p - 0.5) * B * d[1]; +#if DEMO + printf("B %.4lf, ans %.4lf\n", B * (p - 0.5), ans); +#endif + if ((iy - 2 < 0) || (iy + 3 > tabsiz)) + goto done; + /* Compute fourth differences + */ + for (i = 0; i < 2; i++) + d[i] = d[i + 1] - d[i]; + B = 0.125 * B * (p + 1.0) * (p - 2.0); + ans += B * (d[0] + d[1]); +#if DEMO + printf("B %.4lf, ans %.4lf\n", B, ans); +#endif +done: + ans = adjust_for_tidacc(ans, Y); + return ans / 86400.0; } - } - /* between -1000 and 1600: - * linear interpolation between values of table dt2 (Stephenson&Morrison 2004) */ - if (Y >= TAB2_START && Y < TAB2_END) { - double Yjul = 2000 + (tjd - 2451557.5) / 365.25; - p = floor(Yjul); - iy = (int) ((p - TAB2_START) / TAB2_STEP); - dd = (Yjul - (TAB2_START + TAB2_STEP * iy)) / TAB2_STEP; - ans = dt2[iy] + (dt2[iy+1] - dt2[iy]) * dd; - /* correction for tidal acceleration used by our ephemeris */ - ans = adjust_for_tidacc(ans, Y); - } - ans /= 86400.0; - return ans; + /* today - : + * Formula Stephenson (1997; p. 507), + * with modification to avoid jump at end of AA table, + * similar to what Meeus 1998 had suggested. + * Slow transition within 100 years. + */ + B = 0.01 * (Y - 1820); + ans = -20 + 31 * B * B; + /* slow transition from tabulated values to Stephenson formula: */ + if (Y <= tabend + 100) { + B2 = 0.01 * (tabend - 1820); + ans2 = -20 + 31 * B2 * B2; + ans3 = dt[tabsiz - 1]; + dd = (ans2 - ans3); + ans += dd * (Y - (tabend + 100)) * 0.01; + } + return ans / 86400.0; } -static double deltat_espenak_meeus_1620(double tjd) +static double +deltat_longterm_morrison_stephenson(double tjd) { - double ans = 0; - double Ygreg; - double u; - /* double Y = 2000.0 + (tjd - J2000)/365.25;*/ - Ygreg = 2000.0 + (tjd - J2000)/365.2425; - if (Ygreg < -500) { - ans = deltat_longterm_morrison_stephenson(tjd); - } else if (Ygreg < 500) { - u = Ygreg / 100.0; - ans = (((((0.0090316521 * u + 0.022174192) * u - 0.1798452) * u - 5.952053) * u+ 33.78311) * u - 1014.41) * u + 10583.6; - } else if (Ygreg < 1600) { - u = (Ygreg - 1000) / 100.0; - ans = (((((0.0083572073 * u - 0.005050998) * u - 0.8503463) * u + 0.319781) * u + 71.23472) * u - 556.01) * u + 1574.2; - } else if (Ygreg < 1700) { - u = Ygreg - 1600; - ans = 120 - 0.9808 * u - 0.01532 * u * u + u * u * u / 7129.0; - } else if (Ygreg < 1800) { - u = Ygreg - 1700; - ans = (((-u / 1174000.0 + 0.00013336) * u - 0.0059285) * u + 0.1603) * u + 8.83; - } else if (Ygreg < 1860) { - u = Ygreg - 1800; - ans = ((((((0.000000000875 * u - 0.0000001699) * u + 0.0000121272) * u - 0.00037436) * u + 0.0041116) * u + 0.0068612) * u - 0.332447) * u + 13.72; - } else if (Ygreg < 1900) { - u = Ygreg - 1860; - ans = ((((u / 233174.0 - 0.0004473624) * u + 0.01680668) * u - 0.251754) * u + 0.5737) * u + 7.62; - } else if (Ygreg < 1920) { - u = Ygreg - 1900; - ans = (((-0.000197 * u + 0.0061966) * u - 0.0598939) * u + 1.494119) * u -2.79; - } else if (Ygreg < 1941) { - u = Ygreg - 1920; - ans = 21.20 + 0.84493 * u - 0.076100 * u * u + 0.0020936 * u * u * u; - } else if (Ygreg < 1961) { - u = Ygreg - 1950; - ans = 29.07 + 0.407 * u - u * u / 233.0 + u * u * u / 2547.0; - } else if (Ygreg < 1986) { - u = Ygreg - 1975; - ans = 45.45 + 1.067 * u - u * u / 260.0 - u * u * u / 718.0; - } else if (Ygreg < 2005) { - u = Ygreg - 2000; - ans = ((((0.00002373599 * u + 0.000651814) * u + 0.0017275) * u - 0.060374) * u + 0.3345) * u + 63.86; - } - ans = adjust_for_tidacc(ans, Ygreg); - ans /= 86400.0; - return ans; + double Ygreg = 2000.0 + (tjd - J2000) / 365.2425; + double u = (Ygreg - 1820) / 100.0; + return (-20 + 32 * u * u); +} + +static double +deltat_stephenson_morrison_1600(double tjd) +{ + double ans = 0, ans2, ans3; + double p, B, dd; + double tjd0; + int iy; + /* read additional values from swedelta.txt */ + double Y = 2000.0 + (tjd - J2000) / 365.2425; + /* double Y = 2000.0 + (tjd - J2000)/365.25; */ + /* before -1000: + * formula by Stephenson&Morrison (2004; p. 335) but adjusted to fit the + * starting point of table dt2. */ + if (Y < TAB2_START) { + /*B = (Y - LTERM_EQUATION_YSTART) * 0.01; + * ans = -20 + LTERM_EQUATION_COEFF * B * B; */ + ans = deltat_longterm_morrison_stephenson(tjd); + ans = adjust_for_tidacc(ans, Y); + /* transition from formula to table over 100 years */ + if (Y >= TAB2_START - 100) { + /* starting value of table dt2: */ + ans2 = adjust_for_tidacc(dt2[0], TAB2_START); + /* value of formula at epoch TAB2_START */ + /* B = (TAB2_START - LTERM_EQUATION_YSTART) * 0.01; + * ans3 = -20 + LTERM_EQUATION_COEFF * B * B; */ + tjd0 = (TAB2_START - 2000) * 365.2425 + J2000; + ans3 = deltat_longterm_morrison_stephenson(tjd0); + ans3 = adjust_for_tidacc(ans3, Y); + dd = ans3 - ans2; + B = (Y - (TAB2_START - 100)) * 0.01; + /* fit to starting point of table dt2. */ + ans = ans - dd * B; + } + } + /* between -1000 and 1600: + * linear interpolation between values of table dt2 (Stephenson&Morrison 2004) */ + if (Y >= TAB2_START && Y < TAB2_END) { + double Yjul = 2000 + (tjd - 2451557.5) / 365.25; + p = floor(Yjul); + iy = (int)((p - TAB2_START) / TAB2_STEP); + dd = (Yjul - (TAB2_START + TAB2_STEP * iy)) / TAB2_STEP; + ans = dt2[iy] + (dt2[iy + 1] - dt2[iy]) * dd; + /* correction for tidal acceleration used by our ephemeris */ + ans = adjust_for_tidacc(ans, Y); + } + ans /= 86400.0; + return ans; +} + +static double +deltat_espenak_meeus_1620(double tjd) +{ + double ans = 0; + double Ygreg; + double u; + /* double Y = 2000.0 + (tjd - J2000)/365.25; */ + Ygreg = 2000.0 + (tjd - J2000) / 365.2425; + if (Ygreg < -500) { + ans = deltat_longterm_morrison_stephenson(tjd); + } + else if (Ygreg < 500) { + u = Ygreg / 100.0; + ans = + (((((0.0090316521 * u + 0.022174192) * u - 0.1798452) * u - + 5.952053) * u + 33.78311) * u - 1014.41) * u + 10583.6; + } + else if (Ygreg < 1600) { + u = (Ygreg - 1000) / 100.0; + ans = + (((((0.0083572073 * u - 0.005050998) * u - 0.8503463) * u + + 0.319781) * u + 71.23472) * u - 556.01) * u + 1574.2; + } + else if (Ygreg < 1700) { + u = Ygreg - 1600; + ans = 120 - 0.9808 * u - 0.01532 * u * u + u * u * u / 7129.0; + } + else if (Ygreg < 1800) { + u = Ygreg - 1700; + ans = + (((-u / 1174000.0 + 0.00013336) * u - 0.0059285) * u + + 0.1603) * u + 8.83; + } + else if (Ygreg < 1860) { + u = Ygreg - 1800; + ans = + ((((((0.000000000875 * u - 0.0000001699) * u + 0.0000121272) * u - + 0.00037436) * u + 0.0041116) * u + 0.0068612) * u - + 0.332447) * u + 13.72; + } + else if (Ygreg < 1900) { + u = Ygreg - 1860; + ans = + ((((u / 233174.0 - 0.0004473624) * u + 0.01680668) * u - + 0.251754) * u + 0.5737) * u + 7.62; + } + else if (Ygreg < 1920) { + u = Ygreg - 1900; + ans = + (((-0.000197 * u + 0.0061966) * u - 0.0598939) * u + + 1.494119) * u - 2.79; + } + else if (Ygreg < 1941) { + u = Ygreg - 1920; + ans = 21.20 + 0.84493 * u - 0.076100 * u * u + 0.0020936 * u * u * u; + } + else if (Ygreg < 1961) { + u = Ygreg - 1950; + ans = 29.07 + 0.407 * u - u * u / 233.0 + u * u * u / 2547.0; + } + else if (Ygreg < 1986) { + u = Ygreg - 1975; + ans = 45.45 + 1.067 * u - u * u / 260.0 - u * u * u / 718.0; + } + else if (Ygreg < 2005) { + u = Ygreg - 2000; + ans = + ((((0.00002373599 * u + 0.000651814) * u + 0.0017275) * u - + 0.060374) * u + 0.3345) * u + 63.86; + } + ans = adjust_for_tidacc(ans, Ygreg); + ans /= 86400.0; + return ans; } /* Read delta t values from external file. * record structure: year(whitespace)delta_t in 0.01 sec. */ -static int init_dt(void) +static int +init_dt(void) { - FILE *fp; - int year; - int tab_index; - int tabsiz; - int i; - char s[AS_MAXCH]; - char *sp; - if (!init_dt_done) { - init_dt_done = TRUE; - /* no error message if file is missing */ - if ((fp = swi_fopen(-1, "swe_deltat.txt", swed.ephepath, NULL)) == NULL - && (fp = swi_fopen(-1, "sedeltat.txt", swed.ephepath, NULL)) == NULL) - return TABSIZ; - while(fgets(s, AS_MAXCH, fp) != NULL) { - sp = s; - while (strchr(" \t", *sp) != NULL && *sp != '\0') - sp++; /* was *sp++ fixed by Alois 2-jul-2003 */ - if (*sp == '#' || *sp == '\n') - continue; - year = atoi(s); - tab_index = year - TABSTART; - /* table space is limited. no error msg, if exceeded */ - if (tab_index >= TABSIZ_SPACE) - continue; - sp += 4; - while (strchr(" \t", *sp) != NULL && *sp != '\0') - sp++; /* was *sp++ fixed by Alois 2-jul-2003 */ - /*dt[tab_index] = (short) (atof(sp) * 100 + 0.5);*/ - dt[tab_index] = atof(sp); + FILE *fp; + int year; + int tab_index; + int tabsiz; + int i; + char s[AS_MAXCH]; + char *sp; + if (!init_dt_done) { + init_dt_done = TRUE; + /* no error message if file is missing */ + if ((fp = + swi_fopen(-1, "swe_deltat.txt", swed.ephepath, NULL)) == NULL + && (fp = + swi_fopen(-1, "sedeltat.txt", swed.ephepath, NULL)) == NULL) + return TABSIZ; + while (fgets(s, AS_MAXCH, fp) != NULL) { + sp = s; + while (strchr(" \t", *sp) != NULL && *sp != '\0') + sp++; /* was *sp++ fixed by Alois 2-jul-2003 */ + if (*sp == '#' || *sp == '\n') + continue; + year = atoi(s); + tab_index = year - TABSTART; + /* table space is limited. no error msg, if exceeded */ + if (tab_index >= TABSIZ_SPACE) + continue; + sp += 4; + while (strchr(" \t", *sp) != NULL && *sp != '\0') + sp++; /* was *sp++ fixed by Alois 2-jul-2003 */ + /*dt[tab_index] = (short) (atof(sp) * 100 + 0.5); */ + dt[tab_index] = atof(sp); + } + fclose(fp); } - fclose(fp); - } - /* find table size */ - tabsiz = 2001 - TABSTART + 1; - for (i = tabsiz - 1; i < TABSIZ_SPACE; i++) { - if (dt[i] == 0) - break; - else - tabsiz++; - } - tabsiz--; - return tabsiz; + /* find table size */ + tabsiz = 2001 - TABSTART + 1; + for (i = tabsiz - 1; i < TABSIZ_SPACE; i++) { + if (dt[i] == 0) + break; + else + tabsiz++; + } + tabsiz--; + return tabsiz; } /* Astronomical Almanac table is corrected by adding the expression @@ -2122,47 +2286,50 @@ static int init_dt(void) * Entries after 1955 are referred to atomic time standards and * are not affected by errors in Lunar or planetary theory. */ -static double adjust_for_tidacc(double ans, double Y) +static double +adjust_for_tidacc(double ans, double Y) { - double B; - if( Y < 1955.0 ) { - B = (Y - 1955.0); - ans += -0.000091 * (tid_acc + 26.0) * B * B; - } - return ans; + double B; + if (Y < 1955.0) { + B = (Y - 1955.0); + ans += -0.000091 * (tid_acc + 26.0) * B * B; + } + return ans; } /* returns tidal acceleration used in swe_deltat() */ -double FAR PASCAL_CONV swe_get_tid_acc() +double FAR PASCAL_CONV +swe_get_tid_acc() { #if 0 - if (tid_acc == TID_ACC_DE403) - return 403; - if (tid_acc == TID_ACC_DE402) - return 200; + if (tid_acc == TID_ACC_DE403) + return 403; + if (tid_acc == TID_ACC_DE402) + return 200; #endif - return tid_acc; + return tid_acc; } -void FAR PASCAL_CONV swe_set_tid_acc(double t_acc) +void FAR PASCAL_CONV +swe_set_tid_acc(double t_acc) { - tid_acc = t_acc; + tid_acc = t_acc; #if TRACE - swi_open_trace(NULL); - if (swi_trace_count < TRACE_COUNT_MAX) { - if (swi_fp_trace_c != NULL) { - fputs("\n/*SWE_SET_TID_ACC*/\n", swi_fp_trace_c); - fprintf(swi_fp_trace_c, " t = %.9f;\n", t_acc); - fprintf(swi_fp_trace_c, " swe_set_tid_acc(t);\n"); - fputs(" printf(\"swe_set_tid_acc: %f\\t\\n\", ", swi_fp_trace_c); - fputs("t);\n", swi_fp_trace_c); - fflush(swi_fp_trace_c); + swi_open_trace(NULL); + if (swi_trace_count < TRACE_COUNT_MAX) { + if (swi_fp_trace_c != NULL) { + fputs("\n/*SWE_SET_TID_ACC*/\n", swi_fp_trace_c); + fprintf(swi_fp_trace_c, " t = %.9f;\n", t_acc); + fprintf(swi_fp_trace_c, " swe_set_tid_acc(t);\n"); + fputs(" printf(\"swe_set_tid_acc: %f\\t\\n\", ", swi_fp_trace_c); + fputs("t);\n", swi_fp_trace_c); + fflush(swi_fp_trace_c); + } + if (swi_fp_trace_out != NULL) { + fprintf(swi_fp_trace_out, "swe_set_tid_acc: %f\t\n", t_acc); + fflush(swi_fp_trace_out); + } } - if (swi_fp_trace_out != NULL) { - fprintf(swi_fp_trace_out, "swe_set_tid_acc: %f\t\n", t_acc); - fflush(swi_fp_trace_out); - } - } #endif } @@ -2181,98 +2348,119 @@ void FAR PASCAL_CONV swe_set_tid_acc(double t_acc) * eps obliquity of ecliptic, degrees * nut nutation, degrees */ -double FAR PASCAL_CONV swe_sidtime0( double tjd, double eps, double nut ) +double FAR PASCAL_CONV +swe_sidtime0(double tjd, double eps, double nut) { - double jd0; /* Julian day at midnight Universal Time */ - double secs; /* Time of day, UT seconds since UT midnight */ - double eqeq, jd, tu, tt, msday; - double gmst; - /* Julian day at given UT */ - jd = tjd; - jd0 = floor(jd); - secs = tjd - jd0; - if( secs < 0.5 ) { - jd0 -= 0.5; - secs += 0.5; - } else { - jd0 += 0.5; - secs -= 0.5; - } - secs *= 86400.0; - tu = (jd0 - J2000)/36525.0; /* UT1 in centuries after J2000 */ -if (PREC_IAU_2003) { - tt = (jd0 + swe_deltat(jd0) - J2000)/36525.0; /* TT in centuries after J2000 */ - gmst = (((-0.000000002454*tt - 0.00000199708)*tt - 0.0000002926)*tt + 0.092772110)*tt*tt + 307.4771013*(tt-tu) + 8640184.79447825*tu + 24110.5493771; - /* mean solar days per sidereal day at date tu; - * for the derivative of gmst, we can assume UT1 =~ TT */ - msday = 1 + ((((-0.000000012270*tt - 0.00000798832)*tt - 0.0000008778)*tt + 0.185544220)*tt + 8640184.79447825)/(86400.*36525.); -} else { - /* Greenwich Mean Sidereal Time at 0h UT of date */ - gmst = (( -6.2e-6*tu + 9.3104e-2)*tu + 8640184.812866)*tu + 24110.54841; - /* mean solar days per sidereal day at date tu, = 1.00273790934 in 1986 */ - msday = 1.0 + ((-1.86e-5*tu + 0.186208)*tu + 8640184.812866)/(86400.*36525.); -} - /* Local apparent sidereal time at given UT at Greenwich */ - eqeq = 240.0 * nut * cos(eps * DEGTORAD); - gmst = gmst + msday*secs + eqeq /* + 240.0*tlong */; - /* Sidereal seconds modulo 1 sidereal day */ - gmst = gmst - 86400.0 * floor( gmst/86400.0 ); - /* return in hours */ - gmst /= 3600; + double jd0; /* Julian day at midnight Universal Time */ + double secs; /* Time of day, UT seconds since UT midnight */ + double eqeq, jd, tu, tt, msday; + double gmst; + /* Julian day at given UT */ + jd = tjd; + jd0 = floor(jd); + secs = tjd - jd0; + if (secs < 0.5) { + jd0 -= 0.5; + secs += 0.5; + } + else { + jd0 += 0.5; + secs -= 0.5; + } + secs *= 86400.0; + tu = (jd0 - J2000) / 36525.0; /* UT1 in centuries after J2000 */ + if (PREC_IAU_2003) { + tt = (jd0 + swe_deltat(jd0) - J2000) / 36525.0; /* TT in centuries after J2000 */ + gmst = + (((-0.000000002454 * tt - 0.00000199708) * tt - + 0.0000002926) * tt + 0.092772110) * tt * tt + + 307.4771013 * (tt - tu) + 8640184.79447825 * tu + 24110.5493771; + /* mean solar days per sidereal day at date tu; + * for the derivative of gmst, we can assume UT1 =~ TT */ + msday = + 1 + + ((((-0.000000012270 * tt - 0.00000798832) * tt - + 0.0000008778) * tt + 0.185544220) * tt + + 8640184.79447825) / (86400. * 36525.); + } + else { + /* Greenwich Mean Sidereal Time at 0h UT of date */ + gmst = + ((-6.2e-6 * tu + 9.3104e-2) * tu + 8640184.812866) * tu + + 24110.54841; + /* mean solar days per sidereal day at date tu, = 1.00273790934 in 1986 */ + msday = + 1.0 + ((-1.86e-5 * tu + 0.186208) * tu + + 8640184.812866) / (86400. * 36525.); + } + /* Local apparent sidereal time at given UT at Greenwich */ + eqeq = 240.0 * nut * cos(eps * DEGTORAD); + gmst = gmst + msday * secs + eqeq /* + 240.0*tlong */ ; + /* Sidereal seconds modulo 1 sidereal day */ + gmst = gmst - 86400.0 * floor(gmst / 86400.0); + /* return in hours */ + gmst /= 3600; #ifdef TRACE - swi_open_trace(NULL); - if (swi_trace_count < TRACE_COUNT_MAX) { - if (swi_fp_trace_c != NULL) { - fputs("\n/*SWE_SIDTIME0*/\n", swi_fp_trace_c); - fprintf(swi_fp_trace_c, " tjd = %.9f;", tjd); - fprintf(swi_fp_trace_c, " eps = %.9f;", eps); - fprintf(swi_fp_trace_c, " nut = %.9f;\n", nut); - fprintf(swi_fp_trace_c, " t = swe_sidtime0(tjd, eps, nut);\n"); - fputs(" printf(\"swe_sidtime0: %f\\tsidt = %f\\teps = %f\\tnut = %f\\t\\n\", ", swi_fp_trace_c); - fputs("tjd, t, eps, nut);\n", swi_fp_trace_c); - fflush(swi_fp_trace_c); + swi_open_trace(NULL); + if (swi_trace_count < TRACE_COUNT_MAX) { + if (swi_fp_trace_c != NULL) { + fputs("\n/*SWE_SIDTIME0*/\n", swi_fp_trace_c); + fprintf(swi_fp_trace_c, " tjd = %.9f;", tjd); + fprintf(swi_fp_trace_c, " eps = %.9f;", eps); + fprintf(swi_fp_trace_c, " nut = %.9f;\n", nut); + fprintf(swi_fp_trace_c, " t = swe_sidtime0(tjd, eps, nut);\n"); + fputs + (" printf(\"swe_sidtime0: %f\\tsidt = %f\\teps = %f\\tnut = %f\\t\\n\", ", + swi_fp_trace_c); + fputs("tjd, t, eps, nut);\n", swi_fp_trace_c); + fflush(swi_fp_trace_c); + } + if (swi_fp_trace_out != NULL) { + fprintf(swi_fp_trace_out, + "swe_sidtime0: %f\tsidt = %f\teps = %f\tnut = %f\t\n", + tjd, gmst, eps, nut); + fflush(swi_fp_trace_out); + } } - if (swi_fp_trace_out != NULL) { - fprintf(swi_fp_trace_out, "swe_sidtime0: %f\tsidt = %f\teps = %f\tnut = %f\t\n", tjd, gmst, eps, nut); - fflush(swi_fp_trace_out); - } - } #endif - return gmst; + return gmst; } /* sidereal time, without eps and nut as parameters. * tjd must be UT !!! * for more informsation, see comment with swe_sidtime0() */ -double FAR PASCAL_CONV swe_sidtime(double tjd_ut) +double FAR PASCAL_CONV +swe_sidtime(double tjd_ut) { - int i; - double eps, nutlo[2], tsid; - double tjde = tjd_ut + swe_deltat(tjd_ut); - eps = swi_epsiln(tjde) * RADTODEG; - swi_nutation(tjde, nutlo); - for (i = 0; i < 2; i++) - nutlo[i] *= RADTODEG; - tsid = swe_sidtime0(tjd_ut, eps + nutlo[1], nutlo[0]); + int i; + double eps, nutlo[2], tsid; + double tjde = tjd_ut + swe_deltat(tjd_ut); + eps = swi_epsiln(tjde) * RADTODEG; + swi_nutation(tjde, nutlo); + for (i = 0; i < 2; i++) + nutlo[i] *= RADTODEG; + tsid = swe_sidtime0(tjd_ut, eps + nutlo[1], nutlo[0]); #ifdef TRACE - swi_open_trace(NULL); - if (swi_trace_count < TRACE_COUNT_MAX) { - if (swi_fp_trace_c != NULL) { - fputs("\n/*SWE_SIDTIME*/\n", swi_fp_trace_c); - fprintf(swi_fp_trace_c, " tjd = %.9f;\n", tjd_ut); - fprintf(swi_fp_trace_c, " t = swe_sidtime(tjd);\n"); - fputs(" printf(\"swe_sidtime: %f\\t%f\\t\\n\", ", swi_fp_trace_c); - fputs("tjd, t);\n", swi_fp_trace_c); - fflush(swi_fp_trace_c); + swi_open_trace(NULL); + if (swi_trace_count < TRACE_COUNT_MAX) { + if (swi_fp_trace_c != NULL) { + fputs("\n/*SWE_SIDTIME*/\n", swi_fp_trace_c); + fprintf(swi_fp_trace_c, " tjd = %.9f;\n", tjd_ut); + fprintf(swi_fp_trace_c, " t = swe_sidtime(tjd);\n"); + fputs(" printf(\"swe_sidtime: %f\\t%f\\t\\n\", ", + swi_fp_trace_c); + fputs("tjd, t);\n", swi_fp_trace_c); + fflush(swi_fp_trace_c); + } + if (swi_fp_trace_out != NULL) { + fprintf(swi_fp_trace_out, "swe_sidtime: %f\t%f\t\n", tjd_ut, + tsid); + fflush(swi_fp_trace_out); + } } - if (swi_fp_trace_out != NULL) { - fprintf(swi_fp_trace_out, "swe_sidtime: %f\t%f\t\n", tjd_ut, tsid); - fflush(swi_fp_trace_out); - } - } #endif - return tsid; + return tsid; } /* SWISSEPH @@ -2289,84 +2477,85 @@ double FAR PASCAL_CONV swe_sidtime(double tjd_ut) * ipli = number of planet * fname = ephemeris file name */ -void swi_gen_filename(double tjd, int ipli, char *fname) -{ - int icty; - int ncties = (int) NCTIES; - short gregflag; - int jmon, jday, jyear, sgn; - double jut; - char *sform; - switch(ipli) { - case SEI_MOON: - strcpy(fname, "semo"); - break; - case SEI_EMB: - case SEI_MERCURY: - case SEI_VENUS: - case SEI_MARS: - case SEI_JUPITER: - case SEI_SATURN: - case SEI_URANUS: - case SEI_NEPTUNE: - case SEI_PLUTO: - case SEI_SUNBARY: - strcpy(fname, "sepl"); - break; - case SEI_CERES: - case SEI_PALLAS: - case SEI_JUNO: - case SEI_VESTA: - case SEI_CHIRON: - case SEI_PHOLUS: - strcpy(fname, "seas"); - break; - default: /* asteroid */ - sform = "ast%d%sse%05d.%s"; - if (ipli - SE_AST_OFFSET > 99999) - sform = "ast%d%ss%06d.%s"; - sprintf(fname, sform, - (ipli - SE_AST_OFFSET) / 1000, DIR_GLUE, ipli - SE_AST_OFFSET, - SE_FILE_SUFFIX); - return; /* asteroids: only one file 3000 bc - 3000 ad */ - /* break; */ - } - /* century of tjd */ - /* if tjd > 1600 then gregorian calendar */ - if (tjd >= 2305447.5) { - gregflag = TRUE; - swe_revjul(tjd, gregflag, &jyear, &jmon, &jday, &jut); - /* else julian calendar */ - } else { - gregflag = FALSE; - swe_revjul(tjd, gregflag, &jyear, &jmon, &jday, &jut); - } - /* start century of file containing tjd */ - if (jyear < 0) - sgn = -1; - else - sgn = 1; - icty = jyear / 100; - if (sgn < 0 && jyear % 100 != 0) - icty -=1; - while(icty % ncties != 0) - icty--; +void +swi_gen_filename(double tjd, int ipli, char *fname) +{ + int icty; + int ncties = (int)NCTIES; + short gregflag; + int jmon, jday, jyear, sgn; + double jut; + char *sform; + switch (ipli) { + case SEI_MOON: + strcpy(fname, "semo"); + break; + case SEI_EMB: + case SEI_MERCURY: + case SEI_VENUS: + case SEI_MARS: + case SEI_JUPITER: + case SEI_SATURN: + case SEI_URANUS: + case SEI_NEPTUNE: + case SEI_PLUTO: + case SEI_SUNBARY: + strcpy(fname, "sepl"); + break; + case SEI_CERES: + case SEI_PALLAS: + case SEI_JUNO: + case SEI_VESTA: + case SEI_CHIRON: + case SEI_PHOLUS: + strcpy(fname, "seas"); + break; + default: /* asteroid */ + sform = "ast%d%sse%05d.%s"; + if (ipli - SE_AST_OFFSET > 99999) + sform = "ast%d%ss%06d.%s"; + sprintf(fname, sform, (ipli - SE_AST_OFFSET) / 1000, DIR_GLUE, + ipli - SE_AST_OFFSET, SE_FILE_SUFFIX); + return; /* asteroids: only one file 3000 bc - 3000 ad */ + /* break; */ + } + /* century of tjd */ + /* if tjd > 1600 then gregorian calendar */ + if (tjd >= 2305447.5) { + gregflag = TRUE; + swe_revjul(tjd, gregflag, &jyear, &jmon, &jday, &jut); + /* else julian calendar */ + } + else { + gregflag = FALSE; + swe_revjul(tjd, gregflag, &jyear, &jmon, &jday, &jut); + } + /* start century of file containing tjd */ + if (jyear < 0) + sgn = -1; + else + sgn = 1; + icty = jyear / 100; + if (sgn < 0 && jyear % 100 != 0) + icty -= 1; + while (icty % ncties != 0) + icty--; #if 0 - if (icty < BEG_YEAR / 100) - icty = BEG_YEAR / 100; - if (icty >= END_YEAR / 100) - icty = END_YEAR / 100 - ncties; + if (icty < BEG_YEAR / 100) + icty = BEG_YEAR / 100; + if (icty >= END_YEAR / 100) + icty = END_YEAR / 100 - ncties; #endif - /* B.C. or A.D. */ - if (icty < 0) - strcat(fname, "m"); - else - strcat(fname, "_"); - icty = abs(icty); - sprintf(fname + strlen(fname), "%02d.%s", icty, SE_FILE_SUFFIX); + /* B.C. or A.D. */ + if (icty < 0) + strcat(fname, "m"); + else + strcat(fname, "_"); + icty = abs(icty); + sprintf(fname + strlen(fname), "%02d.%s", icty, SE_FILE_SUFFIX); #if 0 - printf("fname %s\n", fname); - fflush(stdout); + printf("fname %s\n", fname); + fflush(stdout); #endif } @@ -2381,32 +2570,36 @@ cpos[0] = "word" and cpos[1] = "word2". If more than nmax fields are found, nmax is returned and the last field nmax-1 rmains un-cut. **************************************************************/ -int swi_cutstr(char *s, char *cutlist, char *cpos[], int nmax) +int +swi_cutstr(char *s, char *cutlist, char *cpos[], int nmax) { - int n = 1; - cpos [0] = s; - while (*s != '\0') { - if ((strchr(cutlist, (int) *s) != NULL) && n < nmax) { - *s = '\0'; - while (*(s + 1) != '\0' && strchr (cutlist, (int) *(s + 1)) != NULL) s++; - cpos[n++] = s + 1; + int n = 1; + cpos[0] = s; + while (*s != '\0') { + if ((strchr(cutlist, (int)*s) != NULL) && n < nmax) { + *s = '\0'; + while (*(s + 1) != '\0' && strchr(cutlist, (int)*(s + 1)) != NULL) + s++; + cpos[n++] = s + 1; + } + if (*s == '\n' || *s == '\r') { /* treat nl or cr like end of string */ + *s = '\0'; + break; + } + s++; } - if (*s == '\n' || *s == '\r') { /* treat nl or cr like end of string */ - *s = '\0'; - break; - } - s++; - } - if (n < nmax) cpos[n] = NULL; - return (n); -} /* cutstr */ + if (n < nmax) + cpos[n] = NULL; + return (n); +} /* cutstr */ -char *swi_right_trim(char *s) +char * +swi_right_trim(char *s) { - char *sp = s + strlen(s) - 1; - while (isspace((int)(unsigned char) *sp) && sp >= s) - *sp-- = '\0'; - return s; + char *sp = s + strlen(s) - 1; + while (isspace((int)(unsigned char)*sp) && sp >= s) + *sp-- = '\0'; + return s; } /* @@ -2420,36 +2613,39 @@ char *swi_right_trim(char *s) * of several of the popular FDDI "MAC" chips. */ static uint32 crc32_table[256]; + /* Initialized first time "crc32()" is called. If you prefer, you can * statically initialize it at compile time. [Another exercise.] */ -uint32 swi_crc32(unsigned char *buf, int len) +uint32 +swi_crc32(unsigned char *buf, int len) { - unsigned char *p; - uint32 crc; - if (!crc32_table[1]) /* if not already done, */ - init_crc32(); /* build table */ - crc = 0xffffffff; /* preload shift register, per CRC-32 spec */ - for (p = buf; len > 0; ++p, --len) - crc = (crc << 8) ^ crc32_table[(crc >> 24) ^ *p]; - return ~crc; /* transmit complement, per CRC-32 spec */ + unsigned char *p; + uint32 crc; + if (!crc32_table[1]) /* if not already done, */ + init_crc32(); /* build table */ + crc = 0xffffffff; /* preload shift register, per CRC-32 spec */ + for (p = buf; len > 0; ++p, --len) + crc = (crc << 8) ^ crc32_table[(crc >> 24) ^ *p]; + return ~crc; /* transmit complement, per CRC-32 spec */ } /* * Build auxiliary table for parallel byte-at-a-time CRC-32. */ -#define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ +#define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ -static void init_crc32(void) +static void +init_crc32(void) { - int32 i, j; - uint32 c; - for (i = 0; i < 256; ++i) { - for (c = i << 24, j = 8; j > 0; --j) - c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1); - crc32_table[i] = c; - } + int32 i, j; + uint32 c; + for (i = 0; i < 256; ++i) { + for (c = i << 24, j = 8; j > 0; --j) + c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1); + crc32_table[i] = c; + } } /******************************************************* @@ -2461,151 +2657,178 @@ static void init_crc32(void) /************************************ normalize argument into interval [0..DEG360] *************************************/ -centisec FAR PASCAL_CONV swe_csnorm(centisec p) +centisec FAR PASCAL_CONV +swe_csnorm(centisec p) { - if (p < 0) - do { p += DEG360; } while (p < 0); - else if (p >= DEG360) - do { p -= DEG360; } while (p >= DEG360); - return (p); + if (p < 0) + do { + p += DEG360; + } while (p < 0); + else if (p >= DEG360) + do { + p -= DEG360; + } while (p >= DEG360); + return (p); } /************************************ distance in centisecs p1 - p2 normalized to [0..360[ **************************************/ -centisec FAR PASCAL_CONV swe_difcsn (centisec p1, centisec p2) -{ - return (swe_csnorm(p1 - p2)); +centisec FAR PASCAL_CONV +swe_difcsn(centisec p1, centisec p2) +{ + return (swe_csnorm(p1 - p2)); } -double FAR PASCAL_CONV swe_difdegn (double p1, double p2) -{ - return (swe_degnorm(p1 - p2)); +double FAR PASCAL_CONV +swe_difdegn(double p1, double p2) +{ + return (swe_degnorm(p1 - p2)); } /************************************ distance in centisecs p1 - p2 normalized to [-180..180[ **************************************/ -centisec FAR PASCAL_CONV swe_difcs2n(centisec p1, centisec p2) -{ centisec dif; - dif = swe_csnorm(p1 - p2); - if (dif >= DEG180) return (dif - DEG360); - return (dif); +centisec FAR PASCAL_CONV +swe_difcs2n(centisec p1, centisec p2) +{ + centisec dif; + dif = swe_csnorm(p1 - p2); + if (dif >= DEG180) + return (dif - DEG360); + return (dif); } -double FAR PASCAL_CONV swe_difdeg2n(double p1, double p2) -{ double dif; - dif = swe_degnorm(p1 - p2); - if (dif >= 180.0) return (dif - 360.0); - return (dif); +double FAR PASCAL_CONV +swe_difdeg2n(double p1, double p2) +{ + double dif; + dif = swe_degnorm(p1 - p2); + if (dif >= 180.0) + return (dif - 360.0); + return (dif); } -double FAR PASCAL_CONV swe_difrad2n(double p1, double p2) -{ double dif; - dif = swe_radnorm(p1 - p2); - if (dif >= TWOPI / 2) return (dif - TWOPI); - return (dif); +double FAR PASCAL_CONV +swe_difrad2n(double p1, double p2) +{ + double dif; + dif = swe_radnorm(p1 - p2); + if (dif >= TWOPI / 2) + return (dif - TWOPI); + return (dif); } /************************************* round second, but at 29.5959 always down -*************************************/ -centisec FAR PASCAL_CONV swe_csroundsec(centisec x) +*************************************/ +centisec FAR PASCAL_CONV +swe_csroundsec(centisec x) { - centisec t; - t = (x + 50) / 100 *100L; /* round to seconds */ - if (t > x && t % DEG30 == 0) /* was rounded up to next sign */ - t = x / 100 * 100L; /* round last second of sign downwards */ - return (t); + centisec t; + t = (x + 50) / 100 * 100L; /* round to seconds */ + if (t > x && t % DEG30 == 0) /* was rounded up to next sign */ + t = x / 100 * 100L; /* round last second of sign downwards */ + return (t); } /************************************* double to int32 with rounding, no overflow check -*************************************/ -int32 FAR PASCAL_CONV swe_d2l(double x) +*************************************/ +int32 FAR PASCAL_CONV +swe_d2l(double x) { - if (x >=0) - return ((int32) (x + 0.5)); - else - return (- (int32) (0.5 - x)); + if (x >= 0) + return ((int32) (x + 0.5)); + else + return (-(int32) (0.5 - x)); } /* * monday = 0, ... sunday = 6 */ -int FAR PASCAL_CONV swe_day_of_week(double jd) +int FAR PASCAL_CONV +swe_day_of_week(double jd) { - return (((int) floor (jd - 2433282 - 1.5) %7) + 7) % 7; + return (((int)floor(jd - 2433282 - 1.5) % 7) + 7) % 7; } -char *FAR PASCAL_CONV swe_cs2timestr(CSEC t, int sep, AS_BOOL suppressZero, char *a) +char *FAR PASCAL_CONV +swe_cs2timestr(CSEC t, int sep, AS_BOOL suppressZero, char *a) + /* does not suppress zeros in hours or minutes */ { - /* static char a[9];*/ - centisec h,m,s; - strcpy (a, " "); - a[2] = a [5] = sep; - t = ((t + 50) / 100) % (24L *3600L); /* round to seconds */ - s = t % 60L; - m = (t / 60) % 60L; - h = t / 3600 % 100L; - if (s == 0 && suppressZero) - a[5] = '\0'; - else { - a [6] = (char) (s / 10 + '0'); - a [7] = (char) (s % 10 + '0'); - }; - a [0] = (char) (h / 10 + '0'); - a [1] = (char) (h % 10 + '0'); - a [3] = (char) (m / 10 + '0'); - a [4] = (char) (m % 10 + '0'); - return (a); - } /* swe_cs2timestr() */ + /* static char a[9]; */ + centisec h, m, s; + strcpy(a, " "); + a[2] = a[5] = sep; + t = ((t + 50) / 100) % (24L * 3600L); /* round to seconds */ + s = t % 60L; + m = (t / 60) % 60L; + h = t / 3600 % 100L; + if (s == 0 && suppressZero) + a[5] = '\0'; + else { + a[6] = (char)(s / 10 + '0'); + a[7] = (char)(s % 10 + '0'); + }; + a[0] = (char)(h / 10 + '0'); + a[1] = (char)(h % 10 + '0'); + a[3] = (char)(m / 10 + '0'); + a[4] = (char)(m % 10 + '0'); + return (a); +} /* swe_cs2timestr() */ -char *FAR PASCAL_CONV swe_cs2lonlatstr(CSEC t, char pchar, char mchar, char *sp) +char *FAR PASCAL_CONV +swe_cs2lonlatstr(CSEC t, char pchar, char mchar, char *sp) { - char a[10]; /* must be initialized at each call */ - char *aa; - centisec h,m,s; - strcpy (a, " ' "); - /* mask dddEmm'ss" */ - if (t < 0 ) pchar = mchar; - t = (ABS4 (t) + 50) / 100; /* round to seconds */ - s = t % 60L; - m = t / 60 % 60L; - h = t / 3600 % 1000L; - if (s == 0) - a[6] = '\0'; /* cut off seconds */ - else { - a [7] = (char) (s / 10 + '0'); - a [8] = (char) (s % 10 + '0'); - } - a [3] = pchar; - if (h > 99) a [0] = (char) (h / 100 + '0'); - if (h > 9) a [1] = (char) (h % 100 / 10 + '0'); - a [2] = (char) (h % 10 + '0'); - a [4] = (char) (m / 10 + '0'); - a [5] = (char) (m % 10 + '0'); - aa = a; - while (*aa == ' ') aa++; - strcpy(sp, aa); - return (sp); -} /* swe_cs2lonlatstr() */ + char a[10]; /* must be initialized at each call */ + char *aa; + centisec h, m, s; + strcpy(a, " ' "); + /* mask dddEmm'ss" */ + if (t < 0) + pchar = mchar; + t = (ABS4(t) + 50) / 100; /* round to seconds */ + s = t % 60L; + m = t / 60 % 60L; + h = t / 3600 % 1000L; + if (s == 0) + a[6] = '\0'; /* cut off seconds */ + else { + a[7] = (char)(s / 10 + '0'); + a[8] = (char)(s % 10 + '0'); + } + a[3] = pchar; + if (h > 99) + a[0] = (char)(h / 100 + '0'); + if (h > 9) + a[1] = (char)(h % 100 / 10 + '0'); + a[2] = (char)(h % 10 + '0'); + a[4] = (char)(m / 10 + '0'); + a[5] = (char)(m % 10 + '0'); + aa = a; + while (*aa == ' ') + aa++; + strcpy(sp, aa); + return (sp); +} /* swe_cs2lonlatstr() */ -char *FAR PASCAL_CONV swe_cs2degstr(CSEC t, char *a) +char *FAR PASCAL_CONV +swe_cs2degstr(CSEC t, char *a) /* does suppress leading zeros in degrees */ { - /* char a[9]; must be initialized at each call */ - centisec h,m,s; - t = t / 100 % (30L*3600L); /* truncate to seconds */ - s = t % 60L; - m = t / 60 % 60L; - h = t / 3600 % 100L; /* only 0..99 degrees */ - sprintf(a, "%2d%s%02d'%02d", h, ODEGREE_STRING, m, s); - return (a); -} /* swe_cs2degstr() */ + /* char a[9]; must be initialized at each call */ + centisec h, m, s; + t = t / 100 % (30L * 3600L); /* truncate to seconds */ + s = t % 60L; + m = t / 60 % 60L; + h = t / 3600 % 100L; /* only 0..99 degrees */ + sprintf(a, "%2d%s%02d'%02d", h, ODEGREE_STRING, m, s); + return (a); +} /* swe_cs2degstr() */ /********************************************************* * function for splitting centiseconds into * @@ -2617,200 +2840,230 @@ char *FAR PASCAL_CONV swe_cs2degstr(CSEC t, char *a) * or +/- sign * *********************************************************/ -void FAR PASCAL_CONV swe_split_deg(double ddeg, int32 roundflag, int32 *ideg, int32 *imin, int32 *isec, double *dsecfr, int32 *isgn) +void FAR PASCAL_CONV +swe_split_deg(double ddeg, int32 roundflag, int32 * ideg, int32 * imin, + int32 * isec, double *dsecfr, int32 * isgn) { - double dadd = 0; - *isgn = 1; - if (ddeg < 0) { - *isgn = -1; - ddeg = -ddeg; - } - if (roundflag & SE_SPLIT_DEG_ROUND_DEG) { - dadd = 0.5; - } else if (roundflag & SE_SPLIT_DEG_ROUND_MIN) { - dadd = 0.5 / 60; - } else if (roundflag & SE_SPLIT_DEG_ROUND_SEC) { - dadd = 0.5 / 3600; - } - if (roundflag & SE_SPLIT_DEG_KEEP_DEG) { - if ((int32) (ddeg + dadd) - (int32) ddeg > 0) - dadd = 0; - } else if (roundflag & SE_SPLIT_DEG_KEEP_SIGN) { - if (fmod(ddeg, 30) + dadd >= 30) - dadd = 0; - } - ddeg += dadd; - if (roundflag & SE_SPLIT_DEG_ZODIACAL) { - *isgn = (int32) (ddeg / 30); - ddeg = fmod(ddeg, 30); - } - *ideg = (int32) ddeg; - ddeg -= *ideg; - *imin = (int32) (ddeg * 60); - ddeg -= *imin / 60.0; - *isec = (int32) (ddeg * 3600); - if (!(roundflag & (SE_SPLIT_DEG_ROUND_DEG | SE_SPLIT_DEG_ROUND_MIN | SE_SPLIT_DEG_ROUND_SEC))) { - *dsecfr = ddeg * 3600 - *isec; - } -} /* end split_deg */ - -double swi_kepler(double E, double M, double ecce) -{ - double dE = 1, E0; - double x; - /* simple formula for small eccentricities */ - if (ecce < 0.4) { - while(dE > 1e-12) { - E0 = E; - E = M + ecce * sin(E0); - dE = fabs(E - E0); + double dadd = 0; + *isgn = 1; + if (ddeg < 0) { + *isgn = -1; + ddeg = -ddeg; } - /* complicated formula for high eccentricities */ - } else { - while(dE > 1e-12) { - E0 = E; - /* - * Alois 21-jul-2000: workaround an optimizer problem in gcc - * swi_mod2PI sees very small negative argument e-322 and returns +2PI; - * we avoid swi_mod2PI for small x. - */ - x = (M + ecce * sin(E0) - E0) / (1 - ecce * cos(E0)); - dE = fabs(x); - if (dE < 1e-2) { - E = E0 + x; - } else { - E = swi_mod2PI(E0 + x); - dE = fabs(E - E0); - } + if (roundflag & SE_SPLIT_DEG_ROUND_DEG) { + dadd = 0.5; } - } - return E; -} + else if (roundflag & SE_SPLIT_DEG_ROUND_MIN) { + dadd = 0.5 / 60; + } + else if (roundflag & SE_SPLIT_DEG_ROUND_SEC) { + dadd = 0.5 / 3600; + } + if (roundflag & SE_SPLIT_DEG_KEEP_DEG) { + if ((int32) (ddeg + dadd) - (int32) ddeg > 0) + dadd = 0; + } + else if (roundflag & SE_SPLIT_DEG_KEEP_SIGN) { + if (fmod(ddeg, 30) + dadd >= 30) + dadd = 0; + } + ddeg += dadd; + if (roundflag & SE_SPLIT_DEG_ZODIACAL) { + *isgn = (int32) (ddeg / 30); + ddeg = fmod(ddeg, 30); + } + *ideg = (int32) ddeg; + ddeg -= *ideg; + *imin = (int32) (ddeg * 60); + ddeg -= *imin / 60.0; + *isec = (int32) (ddeg * 3600); + if (! + (roundflag & + (SE_SPLIT_DEG_ROUND_DEG | SE_SPLIT_DEG_ROUND_MIN | + SE_SPLIT_DEG_ROUND_SEC))) { + *dsecfr = ddeg * 3600 - *isec; + } +} /* end split_deg */ -void swi_FK4_FK5(double *xp, double tjd) +double +swi_kepler(double E, double M, double ecce) { - if (xp[0] == 0 && xp[1] == 0 && xp[2] == 0) - return; - swi_cartpol(xp, xp); - /* according to Expl.Suppl., p. 167f. */ - xp[0] += (0.035 + 0.085 * (tjd - B1950) / 36524.2198782) / 3600 * 15 * DEGTORAD; - xp[3] += (0.085 / 36524.2198782) / 3600 * 15 * DEGTORAD; - swi_polcart(xp, xp); + double dE = 1, E0; + double x; + /* simple formula for small eccentricities */ + if (ecce < 0.4) { + while (dE > 1e-12) { + E0 = E; + E = M + ecce * sin(E0); + dE = fabs(E - E0); + } + /* complicated formula for high eccentricities */ + } + else { + while (dE > 1e-12) { + E0 = E; + /* + * Alois 21-jul-2000: workaround an optimizer problem in gcc + * swi_mod2PI sees very small negative argument e-322 and returns +2PI; + * we avoid swi_mod2PI for small x. + */ + x = (M + ecce * sin(E0) - E0) / (1 - ecce * cos(E0)); + dE = fabs(x); + if (dE < 1e-2) { + E = E0 + x; + } + else { + E = swi_mod2PI(E0 + x); + dE = fabs(E - E0); + } + } + } + return E; } -void swi_FK5_FK4(double *xp, double tjd) +void +swi_FK4_FK5(double *xp, double tjd) { - if (xp[0] == 0 && xp[1] == 0 && xp[2] == 0) - return; - swi_cartpol(xp, xp); - /* according to Expl.Suppl., p. 167f. */ - xp[0] -= (0.035 + 0.085 * (tjd - B1950) / 36524.2198782) / 3600 * 15 * DEGTORAD; - xp[3] -= (0.085 / 36524.2198782) / 3600 * 15 * DEGTORAD; - swi_polcart(xp, xp); + if (xp[0] == 0 && xp[1] == 0 && xp[2] == 0) + return; + swi_cartpol(xp, xp); + /* according to Expl.Suppl., p. 167f. */ + xp[0] += + (0.035 + + 0.085 * (tjd - B1950) / 36524.2198782) / 3600 * 15 * DEGTORAD; + xp[3] += (0.085 / 36524.2198782) / 3600 * 15 * DEGTORAD; + swi_polcart(xp, xp); } -char *swi_strcpy(char *to, char *from) +void +swi_FK5_FK4(double *xp, double tjd) { - char *s; - if (*from == '\0') { - *to = '\0'; - return to; - } - s = strdup(from); - if (s == NULL) { - strcpy(to, from); - return to; - } - strcpy(to, s); - free(s); - return to; + if (xp[0] == 0 && xp[1] == 0 && xp[2] == 0) + return; + swi_cartpol(xp, xp); + /* according to Expl.Suppl., p. 167f. */ + xp[0] -= + (0.035 + + 0.085 * (tjd - B1950) / 36524.2198782) / 3600 * 15 * DEGTORAD; + xp[3] -= (0.085 / 36524.2198782) / 3600 * 15 * DEGTORAD; + swi_polcart(xp, xp); } -char *swi_strncpy(char *to, char *from, size_t n) -{ - char *s; - if (*from == '\0') { +char * +swi_strcpy(char *to, char *from) +{ + char *s; + if (*from == '\0') { + *to = '\0'; + return to; + } + s = strdup(from); + if (s == NULL) { + strcpy(to, from); + return to; + } + strcpy(to, s); + free(s); return to; - } - s = strdup(from); - if (s == NULL) { - strncpy(to, from, n); +} + +char * +swi_strncpy(char *to, char *from, size_t n) +{ + char *s; + if (*from == '\0') { + return to; + } + s = strdup(from); + if (s == NULL) { + strncpy(to, from, n); + return to; + } + strncpy(to, s, n); + free(s); return to; - } - strncpy(to, s, n); - free(s); - return to; } #ifdef TRACE -void swi_open_trace(char *serr) +void +swi_open_trace(char *serr) { - swi_trace_count++; - if (swi_trace_count >= TRACE_COUNT_MAX) { - if (swi_trace_count == TRACE_COUNT_MAX) { - if (serr != NULL) - sprintf(serr, "trace stopped, %d calls exceeded.", TRACE_COUNT_MAX); - if (swi_fp_trace_out != NULL) - fprintf(swi_fp_trace_out, "trace stopped, %d calls exceeded.\n", TRACE_COUNT_MAX); - if (swi_fp_trace_c != NULL) - fprintf(swi_fp_trace_c, "/* trace stopped, %d calls exceeded. */\n", TRACE_COUNT_MAX); + swi_trace_count++; + if (swi_trace_count >= TRACE_COUNT_MAX) { + if (swi_trace_count == TRACE_COUNT_MAX) { + if (serr != NULL) + sprintf(serr, "trace stopped, %d calls exceeded.", + TRACE_COUNT_MAX); + if (swi_fp_trace_out != NULL) + fprintf(swi_fp_trace_out, + "trace stopped, %d calls exceeded.\n", + TRACE_COUNT_MAX); + if (swi_fp_trace_c != NULL) + fprintf(swi_fp_trace_c, + "/* trace stopped, %d calls exceeded. */\n", + TRACE_COUNT_MAX); + } + return; } - return; - } - if (swi_fp_trace_c == NULL) { - char fname[AS_MAXCH]; + if (swi_fp_trace_c == NULL) { + char fname[AS_MAXCH]; #if TRACE == 2 - char *sp, *sp1; - int ipid; + char *sp, *sp1; + int ipid; #endif - /* remove(fname_trace_c); */ - strcpy(fname, fname_trace_c); + /* remove(fname_trace_c); */ + strcpy(fname, fname_trace_c); #if TRACE == 2 - sp = strchr(fname_trace_c, '.'); - sp1 = strchr(fname, '.'); -# if MSDOS - ipid = _getpid(); -# else - ipid = getpid(); -# endif - sprintf(sp1, "_%d%s", ipid, sp); + sp = strchr(fname_trace_c, '.'); + sp1 = strchr(fname, '.'); +#if MSDOS + ipid = _getpid(); +#else + ipid = getpid(); #endif - if ((swi_fp_trace_c = fopen(fname, FILE_A_ACCESS)) == NULL) { - if (serr != NULL) - sprintf(serr, "could not open trace output file '%s'", fname); - } else { - fputs("#include \"sweodef.h\"\n", swi_fp_trace_c); - fputs("#include \"swephexp.h\"\n\n", swi_fp_trace_c); - fputs("void main()\n{\n", swi_fp_trace_c); - fputs(" double tjd, t, nut, eps; int i, ipl, retc; int32 iflag;\n", swi_fp_trace_c); - fputs(" double armc, geolat, cusp[12], ascmc[10]; int hsys;\n", swi_fp_trace_c); - fputs(" double xx[6]; int32 iflgret;\n", swi_fp_trace_c); - fputs(" char s[AS_MAXCH], star[AS_MAXCH], serr[AS_MAXCH];\n", swi_fp_trace_c); - fflush(swi_fp_trace_c); + sprintf(sp1, "_%d%s", ipid, sp); +#endif + if ((swi_fp_trace_c = fopen(fname, FILE_A_ACCESS)) == NULL) { + if (serr != NULL) + sprintf(serr, "could not open trace output file '%s'", fname); + } + else { + fputs("#include \"sweodef.h\"\n", swi_fp_trace_c); + fputs("#include \"swephexp.h\"\n\n", swi_fp_trace_c); + fputs("void main()\n{\n", swi_fp_trace_c); + fputs + (" double tjd, t, nut, eps; int i, ipl, retc; int32 iflag;\n", + swi_fp_trace_c); + fputs(" double armc, geolat, cusp[12], ascmc[10]; int hsys;\n", + swi_fp_trace_c); + fputs(" double xx[6]; int32 iflgret;\n", swi_fp_trace_c); + fputs(" char s[AS_MAXCH], star[AS_MAXCH], serr[AS_MAXCH];\n", + swi_fp_trace_c); + fflush(swi_fp_trace_c); + } } - } - if (swi_fp_trace_out == NULL) { - char fname[AS_MAXCH]; + if (swi_fp_trace_out == NULL) { + char fname[AS_MAXCH]; #if TRACE == 2 - char *sp, *sp1; - int ipid; + char *sp, *sp1; + int ipid; #endif - /* remove(fname_trace_out); */ - strcpy(fname, fname_trace_out); + /* remove(fname_trace_out); */ + strcpy(fname, fname_trace_out); #if TRACE == 2 - sp = strchr(fname_trace_out, '.'); - sp1 = strchr(fname, '.'); -# if MSDOS - ipid = _getpid(); -# else - ipid = getpid(); -# endif - sprintf(sp1, "_%d%s", ipid, sp); + sp = strchr(fname_trace_out, '.'); + sp1 = strchr(fname, '.'); +#if MSDOS + ipid = _getpid(); +#else + ipid = getpid(); #endif - if ((swi_fp_trace_out = fopen(fname, FILE_A_ACCESS)) == NULL) { - if (serr != NULL) - sprintf(serr, "could not open trace output file '%s'", fname); + sprintf(sp1, "_%d%s", ipid, sp); +#endif + if ((swi_fp_trace_out = fopen(fname, FILE_A_ACCESS)) == NULL) { + if (serr != NULL) + sprintf(serr, "could not open trace output file '%s'", fname); + } } - } } #endif diff --git a/swe/src/swephlib.h b/swe/src/swephlib.h index 7a289db..2255e3a 100644 --- a/swe/src/swephlib.h +++ b/swe/src/swephlib.h @@ -5,6 +5,7 @@ Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich ************************************************************/ + /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -67,57 +68,63 @@ /* Precession coefficients for remote past and future. * One of the following four defines must be true. */ -#define PREC_VONDRAK_2011 TRUE -#define PREC_WILLIAMS_1994 FALSE +#define PREC_VONDRAK_2011 TRUE +#define PREC_WILLIAMS_1994 FALSE #define PREC_SIMON_1994 FALSE #define PREC_LASKAR_1986 FALSE -#define PREC_BRETAGNON_2003 FALSE +#define PREC_BRETAGNON_2003 FALSE + /* IAU precession 1976 or 2003 for recent centuries. * only one of the following two defines may be TRUE */ -#define PREC_IAU_1976 FALSE -#define PREC_IAU_2003 FALSE /* precession model P03 */ -#define PREC_IAU_1976_CTIES 2.0 /* J2000 +/- two centuries */ +#define PREC_IAU_1976 FALSE +#define PREC_IAU_2003 FALSE /* precession model P03 */ +#define PREC_IAU_1976_CTIES 2.0 /* J2000 +/- two centuries */ + /* we use P03 for whole ephemeris */ -#define PREC_IAU_2003_CTIES 75.0 /* J2000 +/- 75 centuries */ +#define PREC_IAU_2003_CTIES 75.0 /* J2000 +/- 75 centuries */ /* choose between the following nutation models */ #define NUT_IAU_1980 FALSE -#define NUT_IAU_2000A FALSE /* very time consuming ! */ -#define NUT_IAU_2000B TRUE /* fast, but precision of milli-arcsec */ - +#define NUT_IAU_2000A FALSE /* very time consuming ! */ +#define NUT_IAU_2000B TRUE /* fast, but precision of milli-arcsec */ + /* coordinate transformation */ extern void swi_coortrf(double *xpo, double *xpn, double eps); /* coordinate transformation */ -extern void swi_coortrf2(double *xpo, double *xpn, double sineps, double coseps); +extern void swi_coortrf2(double *xpo, double *xpn, double sineps, + double coseps); /* cartesian to polar coordinates */ extern void swi_cartpol(double *x, double *l); - + /* cartesian to polar coordinates with velocity */ extern void swi_cartpol_sp(double *x, double *l); extern void swi_polcart_sp(double *l, double *x); - + /* polar to cartesian coordinates */ extern void swi_polcart(double *l, double *x); /* GCRS to J2000 */ extern void swi_bias(double *x, int32 iflag, AS_BOOL backward); + /* GCRS to FK5 */ extern void swi_icrs2fk5(double *x, int32 iflag, AS_BOOL backward); /* precession */ -extern int swi_precess(double *R, double J, int direction ); +extern int swi_precess(double *R, double J, int direction); extern void swi_precess_speed(double *xx, double t, int direction); /* from sweph.c, light deflection, aberration, etc. */ extern void swi_deflect_light(double *xx, double dt, int32 iflag); extern void swi_aberr_light(double *xx, double *xe, int32 iflag); extern int swi_plan_for_osc_elem(int32 iflag, double tjd, double *xx); -extern int swi_trop_ra2sid_lon(double *xin, double *xout, double *xoutr, int32 iflag, char *serr); -extern int swi_trop_ra2sid_lon_sosy(double *xin, double *xout, double *xoutr, int32 iflag, char *serr); -extern int swi_get_observer(double tjd, int32 iflag, - AS_BOOL do_save, double *xobs, char *serr); +extern int swi_trop_ra2sid_lon(double *xin, double *xout, double *xoutr, + int32 iflag, char *serr); +extern int swi_trop_ra2sid_lon_sosy(double *xin, double *xout, double *xoutr, + int32 iflag, char *serr); +extern int swi_get_observer(double tjd, int32 iflag, AS_BOOL do_save, + double *xobs, char *serr); extern void swi_force_app_pos_etc(); /* obliquity of ecliptic */ @@ -130,9 +137,9 @@ extern void swi_check_nutation(double tjd, int32 iflag); extern int swi_nutation(double J, double *nutlo); extern void swi_nutate(double *xx, int32 iflag, AS_BOOL backward); -extern void swi_mean_lunar_elements(double tjd, - double *node, double *dnode, - double *peri, double *dperi); +extern void swi_mean_lunar_elements(double tjd, double *node, double *dnode, + double *peri, double *dperi); + /* */ extern double swi_mod2PI(double x); @@ -142,6 +149,7 @@ extern double swi_edcheb(double x, double *coef, int ncf); /* cross product of vectors */ extern void swi_cross_prod(double *a, double *b, double *x); + /* dot product of vecotrs */ extern double swi_dot_prod_unit(double *x, double *y); @@ -166,14 +174,14 @@ extern char *swi_strcpy(char *to, char *from); extern char *swi_strncpy(char *to, char *from, size_t n); #ifdef TRACE -# define TRACE_COUNT_MAX 10000 - extern FILE *swi_fp_trace_c; - extern FILE *swi_fp_trace_out; - extern void swi_open_trace(char *serr); - extern int32 swi_trace_count; - static char *fname_trace_c = "swetrace.c"; - static char *fname_trace_out = "swetrace.txt"; +#define TRACE_COUNT_MAX 10000 +extern FILE *swi_fp_trace_c; +extern FILE *swi_fp_trace_out; +extern void swi_open_trace(char *serr); +extern int32 swi_trace_count; +static char *fname_trace_c = "swetrace.c"; +static char *fname_trace_out = "swetrace.txt"; #ifdef FORCE_IFLAG - static char *fname_force_flg = "force.flg"; +static char *fname_force_flg = "force.flg"; #endif #endif /* TRACE */