(split from Astrognome)Moved all SWE and SWE-GLib related files under swe-glib/

!!!WARNING!!!   The build system is not updated to reflect this! The
!!!WARNING!!!   whole point is to subtree the swe-glib/ directory,
!!!WARNING!!!   making SWE-Glib a separate project as it intended to be.
This commit is contained in:
Gergely Polonkai 2013-09-05 11:36:43 +02:00
parent a8662b2e7d
commit 449e26259b
94 changed files with 71693 additions and 0 deletions

BIN
data/seas_00.se1 Normal file

Binary file not shown.

BIN
data/seas_06.se1 Normal file

Binary file not shown.

BIN
data/seas_12.se1 Normal file

Binary file not shown.

BIN
data/seas_18.se1 Normal file

Binary file not shown.

BIN
data/seas_24.se1 Normal file

Binary file not shown.

BIN
data/seas_30.se1 Normal file

Binary file not shown.

BIN
data/seas_36.se1 Normal file

Binary file not shown.

BIN
data/seas_42.se1 Normal file

Binary file not shown.

BIN
data/seas_48.se1 Normal file

Binary file not shown.

BIN
data/seasm06.se1 Normal file

Binary file not shown.

BIN
data/seasm12.se1 Normal file

Binary file not shown.

BIN
data/seasm18.se1 Normal file

Binary file not shown.

BIN
data/seasm24.se1 Normal file

Binary file not shown.

BIN
data/seasm30.se1 Normal file

Binary file not shown.

BIN
data/seasm36.se1 Normal file

Binary file not shown.

BIN
data/seasm42.se1 Normal file

Binary file not shown.

BIN
data/seasm48.se1 Normal file

Binary file not shown.

BIN
data/seasm54.se1 Normal file

Binary file not shown.

BIN
data/semo_00.se1 Normal file

Binary file not shown.

BIN
data/semo_06.se1 Normal file

Binary file not shown.

BIN
data/semo_12.se1 Normal file

Binary file not shown.

BIN
data/semo_18.se1 Normal file

Binary file not shown.

BIN
data/semo_24.se1 Normal file

Binary file not shown.

BIN
data/semo_30.se1 Normal file

Binary file not shown.

BIN
data/semo_36.se1 Normal file

Binary file not shown.

BIN
data/semo_42.se1 Normal file

Binary file not shown.

BIN
data/semo_48.se1 Normal file

Binary file not shown.

BIN
data/semom06.se1 Normal file

Binary file not shown.

BIN
data/semom12.se1 Normal file

Binary file not shown.

BIN
data/semom18.se1 Normal file

Binary file not shown.

BIN
data/semom24.se1 Normal file

Binary file not shown.

BIN
data/semom30.se1 Normal file

Binary file not shown.

BIN
data/semom36.se1 Normal file

Binary file not shown.

BIN
data/semom42.se1 Normal file

Binary file not shown.

BIN
data/semom48.se1 Normal file

Binary file not shown.

BIN
data/semom54.se1 Normal file

Binary file not shown.

BIN
data/sepl_00.se1 Normal file

Binary file not shown.

BIN
data/sepl_06.se1 Normal file

Binary file not shown.

BIN
data/sepl_12.se1 Normal file

Binary file not shown.

BIN
data/sepl_18.se1 Normal file

Binary file not shown.

BIN
data/sepl_24.se1 Normal file

Binary file not shown.

BIN
data/sepl_30.se1 Normal file

Binary file not shown.

BIN
data/sepl_36.se1 Normal file

Binary file not shown.

BIN
data/sepl_42.se1 Normal file

Binary file not shown.

BIN
data/sepl_48.se1 Normal file

Binary file not shown.

BIN
data/seplm06.se1 Normal file

Binary file not shown.

BIN
data/seplm12.se1 Normal file

Binary file not shown.

BIN
data/seplm18.se1 Normal file

Binary file not shown.

BIN
data/seplm24.se1 Normal file

Binary file not shown.

BIN
data/seplm30.se1 Normal file

Binary file not shown.

BIN
data/seplm36.se1 Normal file

Binary file not shown.

BIN
data/seplm42.se1 Normal file

Binary file not shown.

BIN
data/seplm48.se1 Normal file

Binary file not shown.

BIN
data/seplm54.se1 Normal file

Binary file not shown.

View File

@ -0,0 +1,105 @@
## Process this file with automake to produce Makefile.in
# We require automake 1.6 at least.
AUTOMAKE_OPTIONS = 1.6
# This is a blank Makefile.am for using gtk-doc.
# Copy this to your project's API docs directory and modify the variables to
# suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples
# of using the various options.
# The name of the module, e.g. 'glib'.
DOC_MODULE=swe-glib
# Uncomment for versioned docs and specify the version of the module, e.g. '2'.
DOC_MODULE_VERSION=0
# The top-level XML file (SGML in the past). You can change this if you want to.
DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.xml
# Directories containing the source code.
# gtk-doc will search all .c and .h files beneath these paths
# for inline comments documenting functions and macros.
# e.g. DOC_SOURCE_DIR=$(top_srcdir)/gtk $(top_srcdir)/gdk
DOC_SOURCE_DIR=$(top_srcdir)/swe-glib/src
# Extra options to pass to gtkdoc-scangobj. Not normally needed.
SCANGOBJ_OPTIONS=
# Extra options to supply to gtkdoc-scan.
# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED"
SCAN_OPTIONS=--rebuild-sections --rebuild-types
# Extra options to supply to gtkdoc-mkdb.
# e.g. MKDB_OPTIONS=--xml-mode --output-format=xml
MKDB_OPTIONS=--xml-mode --output-format=xml
# Extra options to supply to gtkdoc-mktmpl
# e.g. MKTMPL_OPTIONS=--only-section-tmpl
MKTMPL_OPTIONS=
# Extra options to supply to gtkdoc-mkhtml
MKHTML_OPTIONS=
# Extra options to supply to gtkdoc-fixref. Not normally needed.
# e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html
FIXXREF_OPTIONS=
# Used for dependencies. The docs will be rebuilt if any of these change.
# e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h
# e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c
HFILE_GLOB=$(top_srcdir)/swe-glib/src/*.h
CFILE_GLOB=$(top_srcdir)/swe-glib/src/*.c
# Extra header to include when scanning, which are not under DOC_SOURCE_DIR
# e.g. EXTRA_HFILES=$(top_srcdir}/contrib/extra.h
EXTRA_HFILES=
# Header files or dirs to ignore when scanning. Use base file/dir names
# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code
IGNORE_HFILES=
# Images to copy into HTML directory.
# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
HTML_IMAGES=
# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE).
# e.g. content_files=running.sgml building.sgml changes-2.0.sgml
content_files=
# SGML files where gtk-doc abbrevations (#GtkWidget) are expanded
# These files must be listed here *and* in content_files
# e.g. expand_content_files=running.sgml
expand_content_files=
# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library.
# Only needed if you are using gtkdoc-scangobj to dynamically query widget
# signals and properties.
# e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
GTKDOC_CFLAGS=
GTKDOC_LIBS=$(LIBSWE_GLIB_LIBS) $(NULL)
# This includes the standard gtk-doc make rules, copied by gtkdocize.
include $(top_srcdir)/gtk-doc.make
# Other files to distribute
# e.g. EXTRA_DIST += version.xml.in
EXTRA_DIST +=
# Files not to distribute
# for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types
# for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt
#DISTCLEANFILES +=
# Comment this out if you want 'make check' to test you doc status
# and run some sanity checks
if ENABLE_GTK_DOC
TESTS_ENVIRONMENT = cd $(srcdir) && \
DOC_MODULE=$(DOC_MODULE) DOC_MAIN_SGML_FILE=$(DOC_MAIN_SGML_FILE) \
SRCDIR=$(abs_srcdir) BUILDDIR=$(abs_builddir)
#TESTS = $(GTKDOC_CHECK)
endif
-include $(top_srcdir)/git.mk

6
swe/README Normal file
View File

@ -0,0 +1,6 @@
This directory contains version 1.75 of the Swiss Ephemeris programming
library in a reduced form, so it can be used in an Autotools project like
Astrognome.
If you need the full version, you can download it from
ftp://ftp.astro.com/pub/swisseph/ (as of July, 2013)

BIN
swe/doc/sweph.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
swe/doc/swephin.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

14343
swe/doc/swephprg.htm Normal file

File diff suppressed because it is too large Load Diff

BIN
swe/doc/swephprg.pdf Normal file

Binary file not shown.

8190
swe/doc/swisseph.htm Normal file

File diff suppressed because it is too large Load Diff

BIN
swe/doc/swisseph.pdf Normal file

Binary file not shown.

54
swe/src/LICENSE Normal file
View File

@ -0,0 +1,54 @@
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
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.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
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/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/

4
swe/src/Makefile.am Normal file
View File

@ -0,0 +1,4 @@
lib_LTLIBRARIES = libswe-1.75.la
libswe_1_75_la_SOURCES = swedate.c swehouse.c swejpl.c swemmoon.c swemplan.c swepcalc.c sweph.c swepdate.c swephlib.c swecl.c swehel.c
libswe_1_75_la_CFLAGS = $(CFLAGS) -Wall
libswe_1_75_la_LIBADD = $(LIBS)

6
swe/src/README Normal file
View File

@ -0,0 +1,6 @@
This directory holds the Swiss Ephemeris library. It can be downloaded from
http://www.astro.com/swisseph/ and used via the GPL licence.
The original directory is stripped down, and the unneded files are deleted (like
the swetest source and such. In the future, even the library may be optimised
further.

1258
swe/src/fixstars.cat Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
# This file allows to make new Delta T known to the Swiss Ephemeris.
# Note, these values override the values given in the internal Delta T
# table of the Swiss Ephemeris.
#
# If you want to use this file, change its file name and remove the
# the extension '.inactive'. As soon as you do so, the values below
# will be used, i.e. they will override the internal Delta T values
# of the Swiss Ephemeris.
#
# Format: year and seconds (decimal)
2007 65.15
2008 65.46
2009 65.78

1258
swe/src/sefstars.txt Normal file

File diff suppressed because it is too large Load Diff

5
swe/src/seleapsec.txt Normal file
View File

@ -0,0 +1,5 @@
# This file contains the dates of leap seconds to be taken into account
# by the Swiss Ephemeris.
# For each new leap second add the date of its insertion in the format
# yyyymmdd, e.g. "20081231" for 21 december 2008
20081231

78
swe/src/seorbel.txt Normal file
View File

@ -0,0 +1,78 @@
# Orbital elements of ficticious planets
# 27 Jan. 2000
#
# This file is part of the Swiss Ephemeris, from Version 1.52 on.
#
# Warning! These planets do not exist!
#
# The user can add his or her own elements.
# 960 is the maximum number of ficticious planets.
#
# The elements order is as follows:
# 1. epoch of elements (Julian day)
# 2. equinox (Julian day or "J1900" or "B1950" or "J2000")
# 3. mean anomaly at epoch
# 4. semi-axis
# 5. eccentricity
# 6. argument of perihelion (ang. distance of perihelion from node)
# 7. ascending node
# 8. inclination
# 9. name of planet
#
# use '#' for comments
# to compute a body with swe_calc(), use planet number
# ipl = SE_FICT_OFFSET_1 + number_of_elements_set,
# e.g. number of Kronos is ipl = 39 + 4 = 43
#
# Witte/Sieggruen planets, refined by James Neely
#2456200.5, J2000, 143.49291, 1.4579341, 0.2225740, 178.78899, 304.33810, 10.82816, Eros # 1
J1900, J1900, 163.7409, 40.99837, 0.00460, 171.4333, 129.8325, 1.0833, Cupido # 1
J1900, J1900, 27.6496, 50.66744, 0.00245, 148.1796, 161.3339, 1.0500, Hades # 2
J1900, J1900, 165.1232, 59.21436, 0.00120, 299.0440, 0.0000, 0.0000, Zeus # 3
J1900, J1900, 169.0193, 64.81960, 0.00305, 208.8801, 0.0000, 0.0000, Kronos # 4
J1900, J1900, 138.0533, 70.29949, 0.00000, 0.0000, 0.0000, 0.0000, Apollon # 5
J1900, J1900, 351.3350, 73.62765, 0.00000, 0.0000, 0.0000, 0.0000, Admetos # 6
J1900, J1900, 55.8983, 77.25568, 0.00000, 0.0000, 0.0000, 0.0000, Vulcanus # 7
J1900, J1900, 165.5163, 83.66907, 0.00000, 0.0000, 0.0000, 0.0000, Poseidon # 8
#
# Isis-Transpluto; elements from "Die Sterne" 3/1952, p. 70ff.
# Strubell does not give an equinox. 1945 is taken in order to
# reproduce the as best as ASTRON ephemeris. (This is a strange
# choice, though.)
# The epoch according to Strubell is 1772.76.
# 1772 is a leap year!
# The fraction is counted from 1 Jan. 1772
2368547.66, 2431456.5, 0.0, 77.775, 0.3, 0.7, 0, 0, Isis-Transpluto # 9
# Nibiru, elements from Christian Woeltge, Hannover
1856113.380954, 1856113.380954, 0.0, 234.8921, 0.981092, 103.966, -44.567, 158.708, Nibiru # 10
# Harrington, elements from Astronomical Journal 96(4), Oct. 1988
2374696.5, J2000, 0.0, 101.2, 0.411, 208.5, 275.4, 32.4, Harrington # 11
# 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, Leverrier (Neptune) # 12
2395662.5, 2395662.5, 24.28, 37.25, 0.12062, 299.11, 0, 0, Adams (Neptune) # 13
2425977.5, 2425977.5, 281, 43.0, 0.202, 204.9, 0, 0, Lowell (Pluto) # 14
2425977.5, 2425977.5, 48.95, 55.1, 0.31, 280.1, 100, 15, Pickering (Pluto) # 15
# intramercurian hypothetical Vulcan acc. to L.H. Weston
J1900,JDATE, 252.8987988 + 707550.7341 * T, 0.13744, 0.019, 322.212069+1670.056*T, 47.787931-1670.056*T, 7.5, Vulcan # 16
# Selena/White Moon
J2000,JDATE, 242.2205555 + 5143.5418158 * T, 0.05280098949, 0.0, 0.0, 0.0, 0.0, Selena/White Moon, geo # 17
# Hypothetical planet Proserpina, according to http://www.geocities.com/Hollywood/Academy/7519/proserpina.html
# J1900, 170.73 + 51.05 * T
J1900,JDATE, 170.73, 79.225630, 0, 0, 0, 0, Proserpina #18
# Waldemath's Second Earth Moon
# Elements were derived by D.Koch from Waldemaths original elements as given in
# David Walters' book on Vulcan. They differ from Solar Fire (Graham Dawsons)
# elements, which are based on the assumption that the "mean longitude" given
# by Waldemath is an observation (a true longitude)
# Neither Swisseph nor Solar fire elements agree with Delphine Jay's ephemeris,
# which is obviously wrong.
2414290.95827875,2414290.95827875, 70.3407215 + 109023.2634989 * T, 0.0068400705250028, 0.1587, 8.14049594 + 2393.47417444 * T, 136.24878256 - 1131.71719709 * T, 2.5, Waldemath, geo # 19
##############################################
# The following elements are for test only
# (Selena without T)
2454000.5,J2000,268.05505,57.3693459,0.1104221,284.48762,252.36907,46.75377,2004XR190
J2000,JDATE, 242.2205555, 0.05279142865925, 0.0, 0.0, 0.0, 0.0, Selena/White Moon, geo # 17
# (Selena with T, gives exactly the same position)
J2000,JDATE, 242.2205555 + 5143.5418158 * T, 0.05279142865925, 0.0, 0.0, 0.0, 0.0, Selena/White Moon with T Terms, geo # 17
J2000, JDATE, 174.794787 + 149472.5157715 * T, 0.38709831, 0.20563175 + 0.000020406 * T, 29.125226 + 0.3702885 * T, 48.330893 + 1.186189 * T, 7.004986 + 0.0018215 * T, Mercury elem. for equ. of date # 18
J2000, J2000, 174.794787 + 149472.5157715 * T, 0.38709831, 0.20563175 + 0.000020406 * T, 29.125226 + 0.2842872 * T, 48.330893 - 0.1254229 * T, 7.004986 - 0.0059516 * T, Mercury Test J2000 Elements# 18

5308
swe/src/swecl.c Normal file

File diff suppressed because it is too large Load Diff

611
swe/src/swedate.c Normal file
View File

@ -0,0 +1,611 @@
/*********************************************************
$Header: /home/dieter/sweph/RCS/swedate.c,v 1.75 2009/04/08 07:17:29 dieter Exp $
version 15-feb-89 16:30
swe_date_conversion()
swe_revjul()
swe_julday()
************************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
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.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
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/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
/*
swe_date_conversion():
This function converts some date+time input {d,m,y,uttime}
into the Julian day number tjd.
The function checks that the input is a legal combination
of dates; for illegal dates like 32 January 1993 it returns ERR
but still converts the date correctly, i.e. like 1 Feb 1993.
The function is usually used to convert user input of birth data
into the Julian day number. Illegal dates should be notified to the user.
Be aware that we always use astronomical year numbering for the years
before Christ, not the historical year numbering.
Astronomical years are done with negative numbers, historical
years with indicators BC or BCE (before common era).
Year 0 (astronomical) = 1 BC historical.
year -1 (astronomical) = 2 BC
etc.
Many users of Astro programs do not know about this difference.
Return: OK or ERR (for illegal date)
*********************************************************/
#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 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)
* for a given calendar date.
* The arguments are a calendar date: day, month, year as integers,
* hour as double with decimal fraction.
* If gregflag = SE_GREG_CAL (1), Gregorian calendar is assumed,
* if gregflag = SE_JUL_CAL (0),Julian calendar is assumed.
The Julian day number is a system of numbering all days continously
within the time range of known human history. It should be familiar
to every astrological or astronomical programmer. The time variable
in astronomical theories is usually expressed in Julian days or
Julian centuries (36525 days per century) relative to some start day;
the start day is called 'the epoch'.
The Julian day number is a double representing the number of
days since JD = 0.0 on 1 Jan -4712, 12:00 noon (in the Julian calendar).
Midnight has always a JD with fraction .5, because traditionally
the astronomical day started at noon. This was practical because
then there was no change of date during a night at the telescope.
From this comes also the fact the noon ephemerides were printed
before midnight ephemerides were introduced early in the 20th century.
NOTE: The Julian day number must not be confused with the Julian
calendar system.
Be aware the we always use astronomical year numbering for the years
before Christ, not the historical year numbering.
Astronomical years are done with negative numbers, historical
years with indicators BC or BCE (before common era).
Year 0 (astronomical) = 1 BC
year -1 (astronomical) = 2 BC
etc.
Original author: Marc Pottenger, Los Angeles.
with bug fix for year < -4711 15-aug-88 by Alois Treindl
(The parameter sequence m,d,y still indicates the US origin,
be careful because the similar function date_conversion() uses
other parameter sequence and also Astrodienst relative juldate.)
References: Oliver Montenbruck, Grundlagen der Ephemeridenrechnung,
Verlag Sterne und Weltraum (1987), p.49 ff
related functions: swe_revjul() reverse Julian day number: compute the
calendar date from a given JD
date_conversion() includes test for legal date values
and notifies errors like 32 January.
****************************************************************/
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;
}
/*** swe_revjul ******************************************************
swe_revjul() is the inverse function to swe_julday(), see the description
there.
Arguments are julian day number, calendar flag (0=julian, 1=gregorian)
return values are the calendar day, month, year and the hour of
the day with decimal fraction (0 .. 23.999999).
Be aware the we use astronomical year numbering for the years
before Christ, not the historical year numbering.
Astronomical years are done with negative numbers, historical
years with indicators BC or BCE (before common era).
Year 0 (astronomical) = 1 BC historical year
year -1 (astronomical) = 2 BC historical year
year -234 (astronomical) = 235 BC historical year
etc.
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)
{
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
*
* input
* iyear ... dsec date and time
* d_timezone timezone offset
* output
* iyear_out ... dsec_out
*
* For time zones east of Greenwich, d_timezone is positive.
* For time zones west of Greenwich, d_timezone is negative.
*
* 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)
{
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;
}
/*
* functions for the handling of UTC
*/
/* Leap seconds were inserted at the end of the following days:*/
#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 */
};
#define J1972 2441317.5
#define NLEAP_INIT 10
/* Read additional leap second dates from external file, if given.
*/
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)
return tabsiz;
leap_seconds[tabsiz] = ndat;
tabsiz++;
}
if (tabsiz > NLEAP_SECONDS)
leap_seconds[tabsiz] = 0; /* end mark */
fclose(fp);
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;
}
/*
* Input: Clock time UTC, year, month, day, hour, minute, second (decimal).
* gregflag Calendar flag
* serr error string
* Output: An array of doubles:
* dret[0] = Julian day number TT (ET)
* dret[1] = Julian day number UT1
*
* Function returns OK or Error.
*
* - Before 1972, swe_utc_to_jd() treats its input time as UT1.
* Note: UTC was introduced in 1961. From 1961 - 1971, the length of the
* UTC second was regularly changed, so that UTC remained very close to UT1.
* - From 1972 on, input time is treated as UTC.
* - If delta_t - nleap - 32.184 > 1, the input time is treated as UT1.
* Note: Like this we avoid errors greater than 1 second in case that
* 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)
{
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;
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;
}
/*
* Input: tjd_et Julian day number, terrestrial time (ephemeris time).
* gregfalg Calendar flag
* Output: UTC year, month, day, hour, minute, second (decimal).
*
* - Before 1 jan 1972 UTC, output UT1.
* Note: UTC was introduced in 1961. From 1961 - 1971, the length of the
* UTC second was regularly changed, so that UTC remained very close to UT1.
* - From 1972 on, output is UTC.
* - If delta_t - nleap - 32.184 > 1, the output is UT1.
* Note: Like this we avoid errors greater than 1 second in case that
* 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)
{
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;
}
}
/*
* 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);
*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);
}
}
/*
* Input: tjd_ut Julian day number, universal time (UT1).
* gregfalg Calendar flag
* Output: UTC year, month, day, hour, minute, second (decimal).
*
* - Before 1 jan 1972 UTC, output UT1.
* Note: UTC was introduced in 1961. From 1961 - 1971, the length of the
* UTC second was regularly changed, so that UTC remained very close to UT1.
* - From 1972 on, output is UTC.
* - If delta_t - nleap - 32.184 > 1, the output is UT1.
* Note: Like this we avoid errors greater than 1 second in case that
* 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)
{
double tjd_et = tjd_ut + swe_deltat(tjd_ut);
swe_jdet_to_utc(tjd_et, gregflag, iyear, imonth, iday, ihour, imin, dsec);
}

85
swe/src/swedate.h Normal file
View File

@ -0,0 +1,85 @@
/*********************************************************
$Header: /home/dieter/sweph/RCS/swedate.h,v 1.74 2008/06/16 10:07:20 dieter Exp $
version 15-feb-89 16:30
*********************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
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.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
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/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
#ifdef __cplusplus
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 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);
#endif
#ifdef __cplusplus
} /* extern C */
#endif

618
swe/src/swedll.h Normal file
View File

@ -0,0 +1,618 @@
/* 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
------------------
This file is part of Swiss Ephemeris.
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.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
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/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
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 $ */
#ifdef __cplusplus
extern "C"
{
#endif /* */
#ifndef _SWEDLL_H
#define _SWEDLL_H
#ifndef _SWEPHEXP_INCLUDED
#include "swephexp.h"
#endif /* */
#ifdef USE_DLL16 /* 16bit DLL */
#define DllImport extern
#else /* */
#ifdef __cplusplus
#define DllImport extern "C" __declspec( dllimport )
#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);
/****************************
* 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);
/*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);*/
/*******************************************************
* 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);
/* 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);
/****************************
* 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 */
#ifdef __cplusplus
} /* extern C */
#endif /* */

4189
swe/src/swehel.c Normal file

File diff suppressed because it is too large Load Diff

1768
swe/src/swehouse.c Normal file

File diff suppressed because it is too large Load Diff

87
swe/src/swehouse.h Normal file
View File

@ -0,0 +1,87 @@
/*******************************************************
$Header: /home/dieter/sweph/RCS/swehouse.h,v 1.74 2008/06/16 10:07:20 dieter Exp $
module swehouse.h
house and (simple) aspect calculation
*******************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
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.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
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/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
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;
};
#define HOUSES struct houses
#define VERY_SMALL 1E-10
#define degtocs(x) (d2l((x) * DEG))
#define cstodeg(x) (double)((x) * CS2DEG)
#define sind(x) sin(x * DEGTORAD)
#define cosd(x) cos(x * DEGTORAD)
#define tand(x) tan(x * DEGTORAD)
#define asind(x) (asin(x) * RADTODEG)
#define acosd(x) (acos(x) * RADTODEG)
#define atand(x) (atan(x) * RADTODEG)
#define atan2d(y, x) (atan2(y, x) * RADTODEG)

976
swe/src/swejpl.c Normal file
View File

@ -0,0 +1,976 @@
/*
| $Header: /home/dieter/sweph/RCS/swejpl.c,v 1.76 2008/08/26 13:55:36 dieter Exp $
|
| Subroutines for reading JPL ephemerides.
| derived from testeph.f as contained in DE403 distribution July 1995.
| works with DE200, DE102, DE403, DE404, DE405, DE406.
| (attention, DE102 has 1950 reference frame and also DE4* has slightly
| different reference frame from DE200. With DE4*, use routine
| IERS_FK5().)
Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich
************************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
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.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
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/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
#include <string.h>
#include "swephexp.h"
#include "sweph.h"
#include "swejpl.h"
#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;
};
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 int32 fsizer(char *serr);
static void reorder(char *x, int size, int number);
static int read_const_jpl(double *ss, char *serr);
/* information about eh_ipt[] and buf[]
DE200 DE102 DE403
3 3 ipt[0] 3 body 0 (mercury) starts at buf[2]
12 15 ipt[1] 14 body 0, ncf = coefficients per component
4 2 ipt[2] 4 na = nintervals, tot 14*4*3=168
147 93 ipt[3] 171 body 1 (venus) starts at buf[170]
12 15 ipt[4] 10 ncf = coefficients per component
1 1 ipt[5] 2 total 10*2*3=60
183 138 ipt[6] 231 body 2 (earth) starts at buf[230]
15 15 ipt[7] 13 ncf = coefficients per component
2 2 ipt[8] 2 total 13*2*3=78
273 228 ipt[9] 309 body 3 (mars) starts at buf[308]
10 10 ipt[10] 11 ncf = coefficients per component
1 1 ipt[11] 1 total 11*1*3=33
303 258 ipt[12] 342 body 4 (jupiter) at buf[341]
9 9 ipt[13] 8 total 8 * 1 * 3 = 24
1 1 ipt[14] 1
330 285 ipt[15] 366 body 5 (saturn) at buf[365]
8 8 ipt[16] 7 total 7 * 1 * 3 = 21
1 1 ipt[17] 1
354 309 ipt[18] 387 body 6 (uranus) at buf[386]
8 8 ipt[19] 6 total 6 * 1 * 3 = 18
1 1 ipt[20] 1
378 333 ipt[21] 405 body 7 (neptune) at buf[404]
6 6 ipt[22] 6 total 18
1 1 ipt[23] 1
396 351 ipt[24] 423 body 8 (pluto) at buf[422]
6 6 ipt[25] 6 total 18
1 1 ipt[26] 1
414 369 ipt[27] 441 body 9 (moon) at buf[440]
12 15 ipt[28] 13 total 13 * 8 * 3 = 312
8 8 ipt[29] 8
702 729 ipt[30] 753 SBARY SUN, starts at buf[752]
15 15 ipt[31] 11 SBARY SUN, ncf = coeff per component
1 1 ipt[32] 2 total 11*2*3=66
747 774 ipt[33] 819 nutations, starts at buf[818]
10 0 ipt[34] 10 total 10 * 4 * 2 = 80
4 0 ipt[35] 4 (nutation only two coordinates)
0 0 ipt[36] 899 librations, start at buf[898]
0 0 ipt[37] 10 total 10 * 4 * 3 = 120
0 0 ipt[38] 4
last element of buf[1017]
buf[0] contains start jd and buf[1] end jd of segment;
each segment is 32 days in de403, 64 days in DE102, 32 days in DE200
Length of blocks: DE406 = 1456*4=5824 bytes = 728 double
DE405 = 2036*4=8144 bytes = 1018 double
DE404 = 1456*4=5824 bytes = 728 double
DE403 = 2036*4=8144 bytes = 1018 double
DE200 = 1652*4=6608 bytes = 826 double
DE102 = 1546*4=6184 bytes = 773 double
each DE102 record has 53*8=424 fill bytes so that
the records have the same length as DE200.
*/
/*
* This subroutine opens the file jplfname, with a phony record length,
* reads the first record, and uses the info to compute ksize,
* the number of single precision words in a record.
* RETURN: ksize (record size of ephemeris data)
* jplfptr is opened on return.
* note 26-aug-2008: now record size is computed by fsizer(), not
* 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)
{
/* 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;
}
#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;
}
/*
* This subroutine reads the jpl planetary ephemeris
* and gives the position and velocity of the point 'ntarg'
* with respect to 'ncent'.
* calling sequence parameters:
* et = d.p. julian ephemeris date at which interpolation
* is wanted.
* ** note the entry dpleph for a doubly-dimensioned time **
* the reason for this option is discussed in the
* subroutine state
* ntarg = integer number of 'target' point.
* ncent = integer number of center point.
* the numbering convention for 'ntarg' and 'ncent' is:
* 0 = mercury 7 = neptune
* 1 = venus 8 = pluto
* 2 = earth 9 = moon
* 3 = mars 10 = sun
* 4 = jupiter 11 = solar-system barycenter
* 5 = saturn 12 = earth-moon barycenter
* 6 = uranus 13 = nutations (longitude and obliq)
* 14 = librations, if on eph file
* (if nutations are wanted, set ntarg = 13. for librations,
* set ntarg = 14. set ncent=0.)
* rrd = output 6-word d.p. array containing position and velocity
* of point 'ntarg' relative to 'ncent'. the units are au and
* au/day. for librations the units are radians and radians
* per day. in the case of nutations the first four words of
* rrd will be set to nutations and rates, having units of
* radians and radians/day.
* 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 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);
}
}
/* 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.;
}
}
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 (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
* set of chebyshev coefficients to give pos, vel, acc, and jerk
* calling sequence parameters:
* input:
* buf 1st location of array of d.p. chebyshev coefficients of position
* t is dp fractional time in interval covered by
* coefficients at which interpolation is wanted, 0 <= t <= 1
* intv is dp length of whole interval in input time units.
* ncf number of coefficients per component
* ncm number of components per set of coefficients
* na number of sets of coefficients in full array
* (i.e., number of sub-intervals in full interval)
* ifl int flag: =1 for positions only
* =2 for pos and vel
* =3 for pos, vel, and acc
* =4 for pos, vel, acc, and jerk
* output:
* 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)
{
/* 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;
}
/*
| ********** state ********************
| this subroutine reads and interpolates the jpl planetary ephemeris file
| calling sequence parameters:
| input:
| et dp julian ephemeris epoch at which interpolation is wanted.
| list 12-word integer array specifying what interpolation
| is wanted for each of the bodies on the file.
| list(i)=0, no interpolation for body i
| =1, position only
| =2, position and velocity
| the designation of the astronomical bodies by i is:
| i = 0: mercury
| = 1: venus
| = 2: earth-moon barycenter, NOT earth!
| = 3: mars
| = 4: jupiter
| = 5: saturn
| = 6: uranus
| = 7: neptune
| = 8: pluto
| = 9: geocentric moon
| =10: nutations in longitude and obliquity
| =11: lunar librations (if on file)
| If called with list = NULL, only the header records are read and
| stored in the global areas.
| do_bary short, if true, barycentric, if false, heliocentric.
| only the 9 planets 0..8 are affected by it.
| output:
| pv dp 6 x 11 array that will contain requested interpolated
| quantities. the body specified by list(i) will have its
| state in the array starting at pv(1,i). (on any given
| call, only those words in 'pv' which are affected by the
| first 10 'list' entries (and by list(11) if librations are
| on the file) are set. the rest of the 'pv' array
| is untouched.) the order of components starting in
| pv is: x,y,z,dx,dy,dz.
| all output vectors are referenced to the earth mean
| equator and equinox of epoch. the moon state is always
| geocentric; the other nine states are either heliocentric
| or solar-system barycentric, depending on the setting of
| common flags (see below).
| lunar librations, if on file, are put into pv(k,10) if
| list(11) is 1 or 2.
| pvsun dp 6-word array containing the barycentric position and
| velocity of the sun.
| nut dp 4-word array that will contain nutations and rates,
| depending on the setting of list(10). the order of
| quantities in nut is:
| d psi (nutation in longitude)
| d epsilon (nutation in obliquity)
| d psi dot
| d epsilon dot
| globals used:
| do_km logical flag defining physical units of the output states.
| TRUE = return km and km/sec, FALSE = return au and au/day
| 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)
{
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;
}
#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;
#if 0
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);
}
/* 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;
}
/* 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);
}
}
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;
}
}
}
}
/* 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)
{
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);
}
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()
{
return js->eh_denum;
}
#endif /* NO_JPL */

108
swe/src/swejpl.h Normal file
View File

@ -0,0 +1,108 @@
/*
| $Header: /home/dieter/sweph/RCS/swejpl.h,v 1.74 2008/06/16 10:07:20 dieter Exp $
|
| Subroutines for reading JPL ephemerides.
| derived from testeph.f as contained in DE403 distribution July 1995.
| works with DE200, DE102, DE403, DE404, DE405, DE406
| (attention, DE102 has 950 reference frame and also DE403 has slightly
| different reference frame from DE200).
Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich
**************************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
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.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
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/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
#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_EARTH 2
#define J_MARS 3
#define J_JUPITER 4
#define J_SATURN 5
#define J_URANUS 6
#define J_NEPTUNE 7
#define J_PLUTO 8
#define J_MOON 9
#define J_SUN 10
#define J_SBARY 11
#define J_EMB 12
#define J_NUT 13
#define J_LIB 14
/*
* compute position and speed at time et, for body ntarg with center
* ncent. rrd must be double[6] to contain the return vectors.
* 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);
/*
* read the ephemeris constants. ss[0..2] returns start, end and granule size.
* If do_show is TRUE, a list of constants is printed to stdout.
*/
extern void swi_close_jpl_file(void);
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);

131
swe/src/swemini.c Normal file
View File

@ -0,0 +1,131 @@
/*
$Header: /home/dieter/sweph/RCS/swemini.c,v 1.74 2008/06/16 10:07:20 dieter Exp $
swemini.c A minimal program to test the Swiss Ephemeris.
Input: a date (in gregorian calendar, sequence day.month.year)
Output: Planet positions at midnight Universal time, ecliptic coordinates,
geocentric apparent positions relative to true equinox of date, as
usual in western astrology.
Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich
**************************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
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.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
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/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
#include "swephexp.h" /* this includes "sweodef.h" */
int main()
{
char sdate[AS_MAXCH], snam[40], serr[AS_MAXCH];
int jday = 1, jmon = 1, jyear = 2000;
double jut = 0.0;
double tjd, te, x2[6];
int32 iflag, iflgret;
int p;
iflag = SEFLG_SPEED;
while (TRUE) {
printf("\nDate (d.m.y) ?");
/*gets(sdate);*/
if( !fgets(sdate, sizeof(sdate)-1, stdin) ) return OK;
/*
* stop if a period . is entered
*/
if (*sdate == '.')
return OK;
if (sscanf (sdate, "%d%*c%d%*c%d", &jday,&jmon,&jyear) < 1) exit(1);
/*
* we have day, month and year and convert to Julian day number
*/
tjd = swe_julday(jyear,jmon,jday,jut,SE_GREG_CAL);
/*
* compute Ephemeris time from Universal time by adding delta_t
*/
te = tjd + swe_deltat(tjd);
printf("date: %02d.%02d.%d at 0:00 Universal time\n", jday, jmon, jyear);
printf("planet \tlongitude\tlatitude\tdistance\tspeed long.\n");
/*
* a loop over all planets
*/
for (p = SE_SUN; p <= SE_CHIRON; p++) {
if (p == SE_EARTH) continue;
/*
* do the coordinate calculation for this planet p
*/
iflgret = swe_calc(te, p, iflag, x2, serr);
/*
* if there is a problem, a negative value is returned and an
* errpr message is in serr.
*/
if (iflgret < 0)
printf("error: %s\n", serr);
else if (iflgret != iflag)
printf("warning: iflgret != iflag. %s\n", serr);
/*
* get the name of the planet p
*/
swe_get_planet_name(p, snam);
/*
* print the coordinates
*/
printf("%10s\t%11.7f\t%10.7f\t%10.7f\t%10.7f\n",
snam, x2[0], x2[1], x2[2], x2[3]);
}
}
return OK;
}

1890
swe/src/swemmoon.c Normal file

File diff suppressed because it is too large Load Diff

974
swe/src/swemplan.c Normal file
View File

@ -0,0 +1,974 @@
/* SWISSEPH
$Header: /home/dieter/sweph/RCS/swemplan.c,v 1.74 2008/06/16 10:07:20 dieter Exp $
Moshier planet routines
modified for SWISSEPH by Dieter Koch
**************************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
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.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
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/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
#include <string.h>
#include "swephexp.h"
#include "sweph.h"
#include "swephlib.h"
#include "swemptab.c"
#define TIMESCALE 3652500.0
#define mods3600(x) ((x) - 1.296e6 * floor ((x)/1.296e6))
#define FICT_GEO 1
#define KGAUSS_GEO 0.0000298122353216 /* Earth only */
/* #define KGAUSS_GEO 0.00002999502129737 Earth + Moon */
static void embofs_mosh(double J, double *xemb);
static int check_t_terms(double t, char *sinp, double *doutp);
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 pnoint2msh[] = { 2, 2, 0, 1, 3, 4, 5, 6, 7, 8, };
/* From Simon et al (1994) */
static double freqs[] = {
/* Arc sec per 10000 Julian years. */
53810162868.8982,
21066413643.3548,
12959774228.3429,
6890507749.3988,
1092566037.7991,
439960985.5372,
154248119.3933,
78655032.0744,
52272245.1795
};
static double phases[] = {
/* Arc sec. */
252.25090552 * 3600.,
181.97980085 * 3600.,
100.46645683 * 3600.,
355.43299958 * 3600.,
34.35151874 * 3600.,
50.07744430 * 3600.,
314.05500511 * 3600.,
304.34866548 * 3600.,
860492.1546,
};
static struct plantbl *planets[] = {
&mer404,
&ven404,
&ear404,
&mar404,
&jup404,
&sat404,
&ura404,
&nep404,
&plu404
};
static double FAR ss[9][24];
static double FAR cc[9][24];
static void sscc(int k, double arg, int n);
int
swi_moshplan2(double J, int iplm, double *pobj)
{
int i, j, k, m, k1, ip, np, nt;
signed char FAR *p;
double FAR *pl, *pb, *pr;
double su, cu, sv, cv, T;
double t, sl, sb, sr;
struct plantbl *plan = planets[iplm];
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;
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;
}
/* Moshier ephemeris.
* computes heliocentric cartesian equatorial coordinates of
* equinox 2000
* for earth and a planet
* tjd julian day
* ipli internal SWEPH planet number
* xp array of 6 doubles for planet's position and speed
* xe earth's
* serr error string
*/
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);
}
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];
}
}
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)
{
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;
}
}
/* Adjust position from Earth-Moon barycenter to Earth
*
* J = Julian day number
* xemb = rectangular equatorial coordinates of Earth
*/
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);
}
/* orbital elements of planets that are computed from osculating elements
* epoch
* equinox
* mean anomaly,
* semi axis,
* eccentricity,
* argument of perihelion,
* ascending node
* inclination
*/
#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",
};
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;
}
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 */
#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 */
#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}, /**/
#endif
};
/* computes a planet from osculating elements *
* tjd julian day
* ipl body number
* 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)
{
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];
}
}
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)
{
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;
}
/*
* 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;
}
#endif
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 */
}

10671
swe/src/swemptab.c Normal file

File diff suppressed because it is too large Load Diff

2826
swe/src/swenut2000a.h Normal file

File diff suppressed because it is too large Load Diff

327
swe/src/sweodef.h Normal file
View File

@ -0,0 +1,327 @@
/************************************************************
$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,
only required for compiling the libraries, not for the external
interface of the libraries.
The definitions are a subset of Astrodienst's ourdef.h content
and must be kept compatible. Everything not used in SwissEph
has been deleted.
Does auto-detection of MSDOS (TURBO_C or MS_C), HPUNIX, Linux.
Must be extended for more portability; there should be a way
to detect byte order and file system type.
************************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
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.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
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/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
#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 */
#ifdef _WIN32 /* Microsoft VC 5.0 does not define MSDOS anymore */
#undef MSDOS
#define MSDOS MY_TRUE
#include <wtypes.h>
#include <objbase.h>
#include <wincon.h>
#include <winbase.h>
#include <io.h>
#include <windows.h>
#define sleep(x) Sleep((x) * 1000)
#endif
#ifdef _MSC_VER
#define MS_VC
#endif
#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
#endif
#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
#endif
#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
#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
#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
#endif
#include <math.h>
#include <stdlib.h>
#ifndef FILE
#include <stdio.h>
#endif
#if HPUNIX
#include <unistd.h>
#endif
/*
* if we have 16-bit ints, we define INT_16; we will need %ld to printf an int32
* if we have 64-bit long, we define LONG_64
* If none is defined, we have int = long = 32 bit, and use %d to printf an int32
*/
#include <limits.h>
#if INT_MAX < 40000
#define INT_16
#else
#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
#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;
/* 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 */
#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 */
#endif
#if MSDOS
#ifdef TURBO_C
#include <alloc.h> /* MSC needs malloc ! */
#else
#include <malloc.h>
#endif
#define SIGALRM SIGINT
#endif
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#ifndef OK
#define OK (0)
#define ERR (-1)
#endif
/* hack because UCHAR is already used by mingw gcc */
#ifdef __GNUC__
#ifdef _WIN32
#define UCHAR SWE_UCHAR
#endif
#endif
typedef unsigned char UCHAR;
#define UCP (UCHAR*)
#define SCP (char*)
#define ODEGREE_STRING "°" /* degree as string, utf8 encoding */
#ifndef HUGE
#define HUGE 1.7E+308 /* biggest value for REAL8 */
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define forward static
#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 */
#define DEG15 (15 * DEG)
#define DEG24 (24 * DEG)
#define DEG30 (30 * DEG)
#define DEG60 (60 * DEG)
#define DEG90 (90 * DEG)
#define DEG120 (120 * DEG)
#define DEG150 (150 * DEG)
#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 */
/* 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 */
#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 */
/* 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
#endif
#include <string.h>
#include <ctype.h>
#endif /* _SWEODEF_INCLUDED */
#endif /* _OURDEF_INCLUDED */

933
swe/src/swepcalc.c Normal file
View File

@ -0,0 +1,933 @@
/*****************************************************
$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
------------------
This file is part of Swiss Ephemeris.
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.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
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/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
/*
* This file is the PLACALC compatibility interface for Swiss Ephemeris.
* It allows very easy porting of older Placalc application to the SwissEph.
* A user has to replace #include "placalc.h" and "housasp.h" with
* #include "swepcalc.h"
* If he has used "ourdef.h" he replaces it with "sweodef.h".
* Then he links his application with swepcalc.o and runs it against the
* Swiss Ephemeris DLL or linkable library.
*
* All calls which were present in the placalc sources are contained
* here, and either implemented directly or translated into Swiss Ephemeris
* calls.
*
*
*/
#include "swepcalc.h"
#include "swephexp.h"
/************************************************************
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,
};
/* If there occurs an internal error in placalc, a message is
* written into the string variable perrtx.
* The message can be read with placalc_get_errtext();
*/
static char perrtx[AS_MAXCH];
static double ekl, nut;
/*
* mimimum and maximum distances computed over 1000 years with plamimax,
* 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}
};
/**********************************************************
function nacalc ()
calculates an array of planet longitudes and speeds,
as needed for complete nathan data records.
The function knows itself how many planets and in which mode
they have to be calculated for Nathan.
return OK or ERR
The returned positions are in centiseconds, our standard
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 */
)
{
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 */
/******************************************************************
* calculation server
* delivers positions in string format which can be sent easily
* 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);
}
}
/*
* 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);
}
}
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);
}
}
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():
This is the main routine for computing a planets position.
The function has several modes, which are controlled by bits in
the parameter 'flag'. The normal mode (flag == 0) computes
a planets apparent geocentric position in ecliptic coordinates relative to
the true equinox of date, without speed
Explanation of the arguments: see the functions header.
Returns OK or ERR (if some planet out of time range). OK and ERR are
defined in ourdef.h and must not be confused with TRUE and FALSE.
OK and ERR are of type int, not of type AS_BOOL.
Bits used in flag:
CALC_BIT_HELIO 0 = geocentric, 1 = heliocentric
CALC_BIT_NOAPP 0 = apparent positions, 1 = true positions
CALC_BIT_NONUT 0 = do nutation (true equinox of date)
1 = don't do nutation (mean equinox of date).
CALC_BIT_SPEED 0 = don't calc speed,
1 = calc speed
Time range:
The function can be used savely in the time range 3000 BC to
3000 AD.
Getting ecliptic and nutation:
calc(CALC_ONLY_ECL_NUT,teph,0,&nutv,&meaneklv,&eklv,NULL);
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)
/* 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
*/
{
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)
{
/*
* 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 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)
{
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)
{
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)
{
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)
{
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()
{
swe_close();
}
char *
placalc_get_errtext()
{
return perrtx;
}
/*****************************************************
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);
}
/**********************************************************
* get fixstar positions
* parameters:
* star
* if string star contains a name, this star is searched.
* if it contains a number, the n'th star of the file
* is returned, starting with 0.
* In any case the name of the star is returned.
* jd absolute julian day
* lon, lat pointer for returning the ecliptic coordinates
* (mean ecliptic and equinox of date)
**********************************************************/
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
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 */
/*
* originally in swephous.c
*/
/*************************************
return in which house pp is;
houses are numbered from 1 .. 12
*************************************/
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);
}
/************************************
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);
}
/* variation of InpHouseNr(). Able to handle house pre-orbs that are
* proportional to house size.
* value 1 in doff[0] means that the offset is proportional to house size,
* e.g. doff[ihs] = -5 means here:
* doff[ihs] = -5 / 30 * preceding_house_size;
* 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 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);
}
/* ********************************************************* */
/* 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)
{
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)
{
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 */
/* ecl, nuta ecliptic and nutation of date, in degrees */
{
return swe_sidtime0(jd_ad + JUL_OFFSET, ecl, nuta);
}
#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 */
{
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

464
swe/src/swepcalc.h Normal file
View File

@ -0,0 +1,464 @@
/************************************************************
$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
This should only be used for porting older Placalc applications.
All new applications should directly use the Swiss Ephemeris API.
A programmer using the Placalc API needs only to include this file
in his code, and link his application with the SwissEph library.
There is no documentation, as it is only intended for porting old
existing Placalc applications.
The Placalc API is not supported in the Windows DLL versions of
Swiss Ephemeris.
************************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
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.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
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/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
#ifndef _SWEPCALC_INCLUDED
#define _SWEPCALC_INCLUDED
#include "swephexp.h"
#define degtocs(x) (d2l((x) * DEG))
#define cstodeg(x) (double)((x) * CS2DEG)
/*
* Some functions which came in the source files csec.c and d2l.c
* are by default not included in the compatibility interface because
* they have an identical counterpart in the SwissEph library.
* 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)
#endif
/*************************************************************
Exported functions, originally from placalc.c
In all functions the variable jd_ad indicates the use of
Astrodienst relative julian days, and jd the use of absolute
julian days.
*************************************************************/
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 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 double fraction(double t);
extern double sidtime(double jd_ad, double ecl, double nuta);
extern double smod8360(double x);
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 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 */
/*
* 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)
/*
* 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.
*/
extern int planet2afl(int p);
extern char *planet2abbr2(int planet);
extern char *planet2abbr3(int planet);
/*************************************************************
exported variables
(these cannot be used by DLL clients)
*************************************************************/
/*************************************************************
definitions
*************************************************************/
/*
* 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 EARTH 0
#define MOON 1
#define MERCURY 2
#define VENUS 3
#define MARS 4
#define JUPITER 5
#define SATURN 6
#define URANUS 7
#define NEPTUNE 8
#define PLUTO 9
#define LASTPLANET PLUTO
#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 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 */
/*
* houses and axes get also a 'planet' index number, but they
* are not used by placalc itself
* between chiron and AC we leave 6 places unused for some other celestial
* bodies or chart factors.
* 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 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 */
/*
* AFL: Astrological factor letters for use in selections strings.
* Each factor (planet, house cusp etc) has a typical letter which
* can be combined in a selection string for specifying a certain
* sequence of factors for a table or other kind of display.
* The function afl2planet() can be used to translate the AFL letters
* into planet indices.
* 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'
/*
* 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 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 */
#ifndef GREG_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 */
/*
* stuff from astrolib.h
*/
#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)))
ADATE { /* date structure used by revjuls and juldays */
int day, month, year;
centisec csec;
};
#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 int day_of_week(double t);
/*
* end swpdate.c
*/
/*
* stuff from housasp.h
*/
#ifndef ASP_144 /* allow including housasp wihout conflict */
#define MAXPLANETS 16
/*
* definitions for aspect numbering; we always have a name and an angle
* due to historical reasons index 0 is unused, conjunct is 1.
* 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 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
/*
* 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 asp_bit(asp) (1 << (asp))
/*
* sometimes it is desirable to have a compact way to express planet-aspect
* combinations.
* We define PASP(planet,aspect) as a constant, 100*planet + aspect.
* We can then write things like:
* case PASP(PLUTO, JONJ): ...
* A definition like p << 8 + a would be faster but the combinations would
* be harder to read.
*/
#define PASP(p,a) (100*(p) + (a))
/*
* used to initialize an array centisec angles[MAXASPECTS+1]
*/
#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 houses
{
centisec cusp[13];
centisec ac;
centisec mc;
};
#define HOUSES struct houses
#endif /* ifndef ASP_144 */
/**********************************
functions exported originally from housasp.c
***********************************/
extern int HouseNr(HOUSES * h, CSEC p);
/*
* return in which house pp is,
* The caller is responsible for proper initialization of cusps
*/
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);
/* variation of InpHouseNr(). Comment in swepcalc.c */
extern void CalcHouses(CSEC th, CSEC fi, CSEC ekl, char hsy, int icnt,
struct houses *h);
extern void RecalcAspects(struct AspectType *a);
extern void longreorder(UCHAR * p, int n);
#endif /* _SWEPCALC_INCLUDED */

249
swe/src/swepdate.c Normal file
View File

@ -0,0 +1,249 @@
/*****************************************************
$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
------------------
This file is part of Swiss Ephemeris.
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.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
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/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
/*
* This file is part of the PLACALC compatibility interface for Swiss Ephemeris.
* It allows very easy porting of older Placalc application to the SwissEph.
* A user has to replace #include "placalc.h" and "housasp.h" with
* #include "swepcalc.h"
* If he has used "ourdef.h" he replaces it with "sweodef.h".
* Then he links his application with swepcalc.o and runs it against the
* Swiss Ephemeris DLL or linkable library.
*
* All calls which were present in the placalc sources are contained
* here, and either implemented directly or translated into Swiss Ephemeris
* calls.
*
*
*/
#include "swepcalc.h"
#include "swephexp.h"
/*************** julday ********************************************
* This function returns the absolute Julian day number (JD)
* for a given calendar date.
* The arguments are a calendar date: day, month, year as integers,
* hour as double with decimal fraction.
* If gregflag = 1, Gregorian calendar is assumed, gregflag = 0
* Julian calendar is assumed.
*
The Julian day number is system of numbering all days continously
within the time range of known human history. It should be familiar
for every astrological or astronomical programmer. The time variable
in astronomical theories is usually expressed in Julian days or
Julian centuries (36525 days per century) relative to some start day;
the start day is called 'the epoch'.
The Julian day number is a double representing the number of
days since JD = 0.0 on 1 Jan -4712, 12:00 noon.
Midnight has always a JD with fraction .5, because traditionally
the astronomical day started at noon. This was practical because
then there was no change of date during a night at the telescope.
From this comes also the fact the noon ephemerides were printed
before midnight ephemerides were introduced early in the 20th century.
NOTE: The Julian day number is named after the monk Julianus. It must
not be confused with the Julian calendar system, which is named after
Julius Cesar, the Roman politician who introduced this calendar.
The Julian century is named after Cesar, i.e. a century in the Julian
calendar. The 'gregorian' century has a variable length.
Be aware the we always use astronomical year numbering for the years
before Christ, not the historical year numbering.
Astronomical years are done with negative numbers, historical
years with indicators BC or BCE (before common era).
Year 0 (astronomical) = 1 BC
year -1 (astronomical) = 2 BC
etc.
Original author: Marc Pottenger, Los Angeles.
with bug fix for year < -4711 15-aug-88 by Alois Treindl
(The parameter sequence m,d,y still indicates the US origin,
be careful because the similar function date_conversion() uses
other parameter sequence and also Astrodienst relative juldate.)
References: Oliver Montenbruck, Grundlagen der Ephemeridenrechnung,
Verlag Sterne und Weltraum (1987), p.49 ff
related functions: revjul() reverse Julian day number: compute the
calendar date from a given JD
date_conversion() includes test for legal date values
and notifies errors like 32 January.
****************************************************************/
double
julday(int month, int day, int year, double hour, int gregflag)
{
double jd;
jd = swe_julday(year, month, day, hour, gregflag);
return jd;
}
/*
* monday = 0, ... sunday = 6
*/
int
day_of_week(double jd)
{
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)
{
return swe_julday(adp->year, adp->month, adp->day, adp->csec / 360000.0,
gregflag);
}
/*** revjul ******************************************************
revjul() is the inverse function to julday(), see the description
there.
Arguments are julian day number, calendar flag (0=julian, 1=gregorian)
return values are the calendar day, month, year and the hour of
the day with decimal fraction (0 .. 23.999999).
Be aware the we use astronomical year numbering for the years
before Christ, not the historical year numbering.
Astronomical years are done with negative numbers, historical
years with indicators BC or BCE (before common era).
Year 0 (astronomical) = 1 BC historical year
year -1 (astronomical) = 2 BC historical year
year -234 (astronomical) = 235 BC historical year
etc.
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)
{
swe_revjul(jd, gregflag, jyear, jmon, jday, jut);
}
/************************************* revjul *********
get calendar date from julian day #
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)
{
double jut;
swe_revjul(jd, gregflag, &adp->year, &adp->month, &adp->day, &jut);
adp->csec = jut * 360000.0 + 0.5;
}
/*********************************************************
$Header: swepdate.c,v 1.65 2003/06/14 13:02:01 alois Exp $
version 15-feb-89 16:30
This function converts some date+time input {d,m,y,utime}
into the Julian day number tgmt, which is an Astrodienst relative
Julian date.
The function checks that the input is a legal combination
of dates; for illegal dates like 32 January 1993 it returns ERR
but still converts the date correctly, i.e. like 1 Feb 1993.
The function is usually used to convert user input of birth data
into the Julian day number. Illegal dates should be notified to the user.
Be aware the we always use astronomical year numbering for the years
before Christ, not the historical year numbering.
Astronomical years are done with negative numbers, historical
years with indicators BC or BCE (before common era).
Year 0 (astronomical) = 1 BC historical.
year -1 (astronomical) = 2 BC
etc.
Many users of Astro programs do not know about this difference.
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 */

6817
swe/src/sweph.c Normal file

File diff suppressed because it is too large Load Diff

597
swe/src/sweph.h Normal file
View File

@ -0,0 +1,597 @@
/************************************************************
$Header: /home/dieter/sweph/RCS/sweph.h,v 1.74 2008/06/16 10:07:20 dieter Exp $
definitions and constants SWISSEPH
Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich
************************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
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.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
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/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
/*
* move over from swephexp.h
*/
#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 MPC_CERES 1
#define MPC_PALLAS 2
#define MPC_JUNO 3
#define MPC_VESTA 4
#define MPC_CHIRON 2060
#define MPC_PHOLUS 5145
#define SE_NAME_SUN "Sun"
#define SE_NAME_MOON "Moon"
#define SE_NAME_MERCURY "Mercury"
#define SE_NAME_VENUS "Venus"
#define SE_NAME_MARS "Mars"
#define SE_NAME_JUPITER "Jupiter"
#define SE_NAME_SATURN "Saturn"
#define SE_NAME_URANUS "Uranus"
#define SE_NAME_NEPTUNE "Neptune"
#define SE_NAME_PLUTO "Pluto"
#define SE_NAME_MEAN_NODE "mean Node"
#define SE_NAME_TRUE_NODE "true Node"
#define SE_NAME_MEAN_APOG "mean Apogee"
#define SE_NAME_OSCU_APOG "osc. Apogee"
#define SE_NAME_INTP_APOG "intp. Apogee"
#define SE_NAME_INTP_PERG "intp. Perigee"
#define SE_NAME_EARTH "Earth"
#define SE_NAME_CERES "Ceres"
#define SE_NAME_PALLAS "Pallas"
#define SE_NAME_JUNO "Juno"
#define SE_NAME_VESTA "Vesta"
#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"
#define SE_NAME_KRONOS "Kronos"
#define SE_NAME_APOLLON "Apollon"
#define SE_NAME_ADMETOS "Admetos"
#define SE_NAME_VULKANUS "Vulkanus"
#define SE_NAME_POSEIDON "Poseidon"
#define SE_NAME_ISIS "Isis"
#define SE_NAME_NIBIRU "Nibiru"
#define SE_NAME_HARRINGTON "Harrington"
#define SE_NAME_NEPTUNE_LEVERRIER "Leverrier"
#define SE_NAME_NEPTUNE_ADAMS "Adams"
#define SE_NAME_PLUTO_LOWELL "Lowell"
#define SE_NAME_PLUTO_PICKERING "Pickering"
#define SE_NAME_VULCAN "Vulcan"
#define SE_NAME_WHITE_MOON "White Moon"
/* for delta t: intrinsic tidal acceleration in the mean motion of the moon,
* not given in the parameters list of the ephemeris files but computed
* 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_26 (-26.0)
#define SE_TIDAL_DEFAULT SE_TIDAL_DE406
/*
* earlier content
*/
#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_NPLANETS 18
#define SEI_MEAN_NODE 0
#define SEI_TRUE_NODE 1
#define SEI_MEAN_APOG 2
#define SEI_OSCU_APOG 3
#define SEI_INTP_APOG 4
#define SEI_INTP_PERG 5
#define SEI_NNODE_ETC 6
#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_FILE_PLANET 0
#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 */
#endif
#define SEI_FILE_TEST_ENDIAN (0x616263L) /* abc */
#define SEI_FILE_BIGENDIAN 0
#define SEI_FILE_NOREORD 0
#define SEI_FILE_LITENDIAN 1
#define SEI_FILE_REORD 2
#define SEI_FILE_NMAXPLAN 50
#define SEI_FILE_EFPOSBEGIN 500
#define SE_FILE_SUFFIX "se1"
#define SEI_NEPHFILES 7
#define SEI_CURR_FPOS -1
/* Chiron's orbit becomes chaotic
* before 720 AD and after 4606 AD, because of close encounters
* 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 */
/* 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 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 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) */
#define SWIEPH_START 625614.927151
#define SWIEPH_END 2813641.5
#define ALLEPH_START MOSHPLEPH_START
#define ALLEPH_END MOSHPLEPH_END
#define BEG_YEAR (-3000)
#define END_YEAR 3000
#endif
#define MAXORD 40
#define NCTIES 6.0 /* number of centuries per eph. file */
#define OK (0)
#define ERR (-1)
#define NOT_AVAILABLE (-2)
#define BEYOND_EPH_LIMITS (-3)
#define J_TO_J2000 1
#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 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 NUT_SPEED_INTV 0.0001
#define DEFL_SPEED_INTV 0.0000005
#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])
#define PNOINT2JPL {J_EARTH, J_MOON, J_MERCURY, J_VENUS, J_MARS, J_JUPITER, J_SATURN, J_URANUS, J_NEPTUNE, J_PLUTO, J_SUN, }
/* 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 */
};
/* Ayanamsas
* For each ayanamsa, there are two values:
* t0 epoch of ayanamsa, TDT (ET)
* ayan_t0 ayanamsa value at epoch
*/
struct aya_init
{
double t0, ayan_t0;
};
static const struct aya_init ayanamsa[] = {
{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) */
{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) */
{J1900, 360 - 337.636111}, /* 5: Krishnamurti (Robert Hand) */
{J1900, 360 - 333.0369024}, /* 6: Djwhal Khool; (Graham Dawson)
* Aquarius entered on 1 July 2117 */
{J1900, 360 - 338.917778}, /* 7: Yukteshwar; (David Cochrane) */
{J1900, 360 - 338.634444}, /* 8: JN Bhasin; (David Cochrane) */
{1684532.5, -3.36667}, /* 9: Babylonian, Kugler 1 */
{1684532.5, -4.76667}, /*10: Babylonian, Kugler 2 */
{1684532.5, -5.61667}, /*11: Babylonian, Kugler 3 */
{1684532.5, -4.56667}, /*12: Babylonian, Huber */
{1673941, -5.079167}, /*13: Babylonian, Mercier;
* eta Piscium culminates with zero point */
{1684532.5, -4.44088389}, /*14: t0 is defined by Aldebaran at 15 Taurus */
{1674484, -9.33333}, /*15: Hipparchos */
{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 */
{0, 0}, /*25: - */
{0, 0}, /*26: - */
{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) */
};
/*
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
*/
};
/*
* stuff exported from swemplan.c and swemmoon.c
* and constants used inside these functions.
************************************************************/
#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_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_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 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 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 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 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 topo_data
{
double geolon, geolat, geoalt;
double teval;
double tjd_ut;
double xobs[6];
};
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];
#else
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];
};
extern struct swe_data FAR swed;

807
swe/src/swephexp.h Normal file
View File

@ -0,0 +1,807 @@
/************************************************************
$Header: /home/dieter/sweph/RCS/swephexp.h,v 1.75 2009/04/08 07:19:08 dieter Exp $
SWISSEPH: exported definitions and constants
This file represents the standard application interface (API)
to the Swiss Ephemeris.
A C programmer needs only to include this file, and link his code
with the SwissEph library.
The function calls are documented in the Programmer's documentation,
which is online in HTML format.
Structure of this file:
Public API definitions
Internal developer's definitions
Public API functions.
Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich
************************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
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.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
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/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef _SWEPHEXP_INCLUDED /* allow multiple #includes of swephexp.h */
#define _SWEPHEXP_INCLUDED
#include "sweodef.h"
/***********************************************************
* definitions for use also by non-C programmers
***********************************************************/
/* values for gregflag in swe_julday() and swe_revjul() */
#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_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_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_NFICT_ELEM 15
#define SE_COMET_OFFSET 1000
#define SE_NALL_NAT_POINTS (SE_NPLANETS + SE_NFICT_ELEM)
/* Hamburger or Uranian "planets" */
#define SE_CUPIDO 40
#define SE_HADES 41
#define SE_ZEUS 42
#define SE_KRONOS 43
#define SE_APOLLON 44
#define SE_ADMETOS 45
#define SE_VULKANUS 46
#define SE_POSEIDON 47
/* other fictitious bodies */
#define SE_ISIS 48
#define SE_NIBIRU 49
#define SE_HARRINGTON 50
#define SE_NEPTUNE_LEVERRIER 51
#define SE_NEPTUNE_ADAMS 52
#define SE_PLUTO_LOWELL 53
#define SE_PLUTO_PICKERING 54
#define SE_VULCAN 55
#define SE_WHITE_MOON 56
#define SE_PROSERPINA 57
#define SE_WALDEMATH 58
#define SE_FIXSTAR -10
#define SE_ASC 0
#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_NASCMC 8
/*
* flag bits for parameter iflag in function swe_calc()
* The flag bits are defined in such a way that iflag = 0 delivers what one
* usually wants:
* - the default ephemeris (SWISS EPHEMERIS) is used,
* - apparent geocentric positions referring to the true equinox of date
* are returned.
* If not only coordinates, but also speed values are required, use
* flag = SEFLG_SPEED.
*
* The 'L' behind the number indicates that 32-bit integers (Long) are used.
*/
#define SEFLG_JPLEPH 1 /* use JPL ephemeris */
#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_SPEED3 128 /* speed from 3 positions (do not use it,
* 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 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
/* sidereal modes (ayanamsas) */
#define SE_SIDM_FAGAN_BRADLEY 0
#define SE_SIDM_LAHIRI 1
#define SE_SIDM_DELUCE 2
#define SE_SIDM_RAMAN 3
#define SE_SIDM_USHASHASHI 4
#define SE_SIDM_KRISHNAMURTI 5
#define SE_SIDM_DJWHAL_KHUL 6
#define SE_SIDM_YUKTESHWAR 7
#define SE_SIDM_JN_BHASIN 8
#define SE_SIDM_BABYL_KUGLER1 9
#define SE_SIDM_BABYL_KUGLER2 10
#define SE_SIDM_BABYL_KUGLER3 11
#define SE_SIDM_BABYL_HUBER 12
#define SE_SIDM_BABYL_ETPSC 13
#define SE_SIDM_ALDEBARAN_15TAU 14
#define SE_SIDM_HIPPARCHOS 15
#define SE_SIDM_SASSANIAN 16
#define SE_SIDM_GALCENT_0SAG 17
#define SE_SIDM_J2000 18
#define SE_SIDM_J1900 19
#define SE_SIDM_B1950 20
#define SE_SIDM_SURYASIDDHANTA 21
#define SE_SIDM_SURYASIDDHANTA_MSUN 22
#define SE_SIDM_ARYABHATA 23
#define SE_SIDM_ARYABHATA_MSUN 24
#define SE_SIDM_USER 255
#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 */
/* default ephemeris used when no ephemeris flagbit is set */
#define SEFLG_DEFAULTEPH SEFLG_SWIEPH
#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.
*/
/* defines for eclipse computations */
#define SE_ECL_CENTRAL 1
#define SE_ECL_NONCENTRAL 2
#define SE_ECL_TOTAL 4
#define SE_ECL_ANNULAR 8
#define SE_ECL_PARTIAL 16
#define SE_ECL_ANNULAR_TOTAL 32
#define SE_ECL_PENUMBRAL 64
#define SE_ECL_ALLTYPES_SOLAR (SE_ECL_CENTRAL|SE_ECL_NONCENTRAL|SE_ECL_TOTAL|SE_ECL_ANNULAR|SE_ECL_PARTIAL|SE_ECL_ANNULAR_TOTAL)
#define SE_ECL_ALLTYPES_LUNAR (SE_ECL_TOTAL|SE_ECL_PARTIAL|SE_ECL_PENUMBRAL)
#define SE_ECL_VISIBLE 128
#define SE_ECL_MAX_VISIBLE 256
#define SE_ECL_1ST_VISIBLE 512
#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 */
/* 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 */
/* for swe_azalt() and swe_azalt_rev() */
#define SE_ECL2HOR 0
#define SE_EQU2HOR 1
#define SE_HOR2ECL 0
#define SE_HOR2EQU 1
/* for swe_refrac() */
#define SE_TRUE_TO_APP 0
#define SE_APP_TO_TRUE 1
/*
* only used for experimenting with various JPL ephemeris files
* which are available at Astrodienst's internal network
*/
#define SE_DE_NUMBER 406
#define SE_FNAME_DE200 "de200.eph"
#define SE_FNAME_DE403 "de403.eph"
#define SE_FNAME_DE404 "de404.eph"
#define SE_FNAME_DE405 "de405.eph"
#define SE_FNAME_DE406 "de406.eph"
#define SE_FNAME_DFT SE_FNAME_DE406
#define SE_STARFILE_OLD "fixstars.cat"
#define SE_STARFILE "sefstars.txt"
#define SE_ASTNAMFILE "seasnam.txt"
#define SE_FICTFILE "seorbel.txt"
/*
* ephemeris path
* this defines where ephemeris files are expected if the function
* swe_set_ephe_path() is not called by the application.
* Normally, every application should make this call to define its
* own place for the ephemeris files.
*/
#ifndef SE_EPHE_PATH
#if MSDOS
#ifdef PAIR_SWEPH
#define SE_EPHE_PATH "\\pair\\ephe\\"
#else
#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
#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) */
/* for heliacal functions */
#define SE_HELIACAL_RISING 1
#define SE_HELIACAL_SETTING 2
#define SE_MORNING_FIRST SE_HELIACAL_RISING
#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_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_AVKIND_PTO (1 << 16)
#define SE_HELFLAG_AVKIND_MIN7 (1 << 17)
#define SE_HELFLAG_AVKIND_MIN9 (1 << 18)
#define SE_HELFLAG_AVKIND (SE_HELFLAG_AVKIND_VR|SE_HELFLAG_AVKIND_PTO|SE_HELFLAG_AVKIND_MIN7|SE_HELFLAG_AVKIND_MIN9)
#define TJD_INVALID 99999999.0
#define SIMULATE_VICTORVB 1
#define SE_HELIACAL_LONG_SEARCH 128
#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_AVKIND_PTO (1 << 16)
#define SE_HELIACAL_AVKIND_MIN7 (1 << 17)
#define SE_HELIACAL_AVKIND_MIN9 (1 << 18)
#define SE_HELIACAL_AVKIND (SE_HELFLAG_AVKIND_VR|SE_HELFLAG_AVKIND_PTO|SE_HELFLAG_AVKIND_MIN7|SE_HELFLAG_AVKIND_MIN9)
#define SE_PHOTOPIC_FLAG 0
#define SE_SCOTOPIC_FLAG 1
#define SE_MIXEDOPIC_FLAG 2
/*
* by compiling with -DPAIR_SWEPH in the compiler options it
* is possible to create a more compact version of SwissEph which
* contains no code for the JPL ephemeris file and for the builtin
* Moshier ephemeris.
* This is quite useful for MSDOS real mode applications which need to
* run within 640 kb.
* The option is called PAIR_SWEPH because it was introduced for
* Astrodienst's partner software PAIR.
*/
#ifdef PAIR_SWEPH
#define NO_JPL
#endif
/**************************************************************
* here follow some ugly definitions which are only required
* if SwissEphemeris is compiled on Windows, either to use a DLL
* or to create a DLL.
* Unix users can savely ignore his section
* and skip to the export function decarations below.
************************************************************/
#if defined(MAKE_DLL) || defined(USE_DLL) || defined(_WINDOWS)
#include <windows.h>
#endif
#ifdef USE_DLL
#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
#else
#ifndef FAR
#define FAR far
#endif
#ifdef __BORLANDC__
#include <alloc.h>
#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 */
/* 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 */
/* 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
#ifndef _SWEDLL_H
/***********************************************************
* exported functions
***********************************************************/
#define ext_def(x) extern EXP32 x FAR PASCAL_CONV EXP16
/* 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);
/* 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);
/****************************
* exports from sweph.c
****************************/
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_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_ut(char *star, double tjd_ut, int32 iflag,
double *xx, char *serr);
ext_def(int32) swe_fixstar_mag(char *star, double *mag, char *serr);
/* close Swiss Ephemeris */
ext_def(void) swe_close(void);
/* set directory path of ephemeris files */
ext_def(void) swe_set_ephe_path(char *path);
/* set file name of JPL file */
ext_def(void) swe_set_jpl_file(char *fname);
/* get planet name */
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);
/* set sidereal mode */
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_ut(double tjd_ut);
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(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(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_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);
/****************************
* 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_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(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);
/* 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_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);
/* 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_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);
/* 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);
/* 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_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(double) swe_refrac(double inalt, double atpress, double attemp,
int32 calc_flag);
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_set_lapse_rate(double lapse_rate);
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_azalt_rev(double tjd_ut, int32 calc_flag,
double *geopos, double *xin, double *xout);
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_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(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);
/****************************
* exports from swephlib.c
****************************/
/* delta t */
ext_def(double) swe_deltat(double tjd);
/* equation of time */
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);
/* 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);
/* 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_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);
/*******************************************************
* 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] */
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(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(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);
/* double to int32 with rounding, no overflow check */
ext_def(int32) swe_d2l(double x);
/* monday = 0, ... sunday = 6 */
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_cs2lonlatstr(CSEC t, char pchar, char mchar,
char *s);
ext_def(char *) swe_cs2degstr(CSEC t, char *a);
#endif /* #ifndef _SWEDLL_H */
#endif /* #ifndef _SWEPHEXP_INCLUDED */
#ifdef __cplusplus
} /* extern C */
#endif

3069
swe/src/swephlib.c Normal file

File diff suppressed because it is too large Load Diff

187
swe/src/swephlib.h Normal file
View File

@ -0,0 +1,187 @@
/************************************************************
$Header: /home/dieter/sweph/RCS/swephlib.h,v 1.74 2008/06/16 10:07:20 dieter Exp $
Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich
************************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
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.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
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/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
/* Set TRUE, to include Herring's (1987) corrections to IAU 1980
* nutation series. AA (1996) neglects them. */
#define NUT_CORR_1987 FALSE
/* 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_SIMON_1994 FALSE
#define PREC_LASKAR_1986 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 */
/* we use P03 for whole ephemeris */
#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 */
/* 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);
/* 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 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 void swi_force_app_pos_etc();
/* obliquity of ecliptic */
extern void swi_check_ecliptic(double tjd);
extern double swi_epsiln(double J);
extern void swi_ldp_peps(double J, double *dpre, double *deps);
/* nutation */
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 double swi_mod2PI(double x);
/* evaluation of chebyshew series and derivative */
extern double swi_echeb(double x, double *coef, int ncf);
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);
extern double swi_angnorm(double x);
/* generation of SWISSEPH file names */
extern void swi_gen_filename(double tjd, int ipli, char *fname);
/* cyclic redundancy checksum (CRC), 32 bit */
extern uint32 swi_crc32(unsigned char *buf, int len);
extern int swi_cutstr(char *s, char *cutlist, char *cpos[], int nmax);
extern char *swi_right_trim(char *s);
extern double swi_kepler(double E, double M, double ecce);
extern char *swi_get_fict_name(int32 ipl, char *s);
extern void swi_FK4_FK5(double *xp, double tjd);
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";
#ifdef FORCE_IFLAG
static char *fname_force_flg = "force.flg";
#endif
#endif /* TRACE */

2681
swe/src/swetest.c Normal file

File diff suppressed because it is too large Load Diff