Removed SWE-GLib from the source tree after making it a separate project

This commit is contained in:
Gergely Polonkai 2013-09-06 12:51:20 +02:00
parent 8b661ed04d
commit 459163a480
106 changed files with 0 additions and 73926 deletions

5
.gitignore vendored
View File

@ -45,11 +45,6 @@ Makefile.in
/po/quot.sed
/po/remove-potcdate.sin
# SWE-GLib related files, should be removed when SWE-GLib goes separate
/swe-glib/src/enumtypes.c
/swe-glib/src/enumtypes.h
/swe-glib/src/gswetest
#Documentation related files
/docs/reference/*/*.args
/docs/reference/*/*.hierarchy

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,105 +0,0 @@
## 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

View File

@ -1,24 +0,0 @@
AM_CPPFLAGS = -DG_LOG_DOMAIN=\"SWE-GLib\" -DLOCALEDIR=\"$(localedir)\" -D__SWE_GLIB_BUILDING__
lib_LTLIBRARIES = libswe-glib-0.1.la
libswe_glib_sources = swe-glib.c gswe-moment.c gswe-timestamp.c enumtypes.c
gswe_headers = gswe-timestamp.h gswe-types.h
libswe_glib_0_1_la_SOURCES = $(libswe_glib_sources)
libswe_glib_0_1_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) -Wall
libswe_glib_0_1_la_LIBADD = $(GLIB_LIBS) $(GOBJECT_LIBS) $(LIBSWE_LIBS)
BUILT_SOURCES = enumtypes.c enumtypes.h
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = enumtypes.h.template enumtypes.c.template
enumtypes.h: $(gswe_headers) enumtypes.h.template
$(GLIB_MKENUMS) --template $(filter %.template,$^) $(filter-out %.template,$^) > \
enumtypes.h.tmp && mv enumtypes.h.tmp enumtypes.h
enumtypes.c: $(gswe_headers) enumtypes.h enumtypes.c.template
$(GLIB_MKENUMS) --template $(filter %.template,$^) $(filter-out %.template,$^) > \
enumtypes.c.tmp && mv enumtypes.c.tmp enumtypes.c

View File

@ -1,38 +0,0 @@
/*** BEGIN file-header ***/
#include "enumtypes.h"
#include "@filename@"
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@filename@" */
/*** END file-production ***/
/*** BEGIN value-header ***/
GType
@enum_name@_get_type(void)
{
static volatile gsize g_define_type_id__volatile = 0;
if (g_once_init_enter(&g_define_type_id__volatile)) {
static const G@Type@Value values[] = {
/*** END value-header ***/
/*** BEGIN value-production ***/
{ @VALUENAME@, "@VALUENAME@", "@valuenick@" },
/*** END value-production ***/
/*** BEGIN value-tail ***/
{ 0, NULL, NULL }
};
GType g_define_type_id = g_@type@_register_static(g_intern_static_string("@EnumName@"), values);
g_once_init_leave(&g_define_type_id__volatile, g_define_type_id);
}
return g_define_type_id__volatile;
}
/*** END value-tail ***/

View File

@ -1,25 +0,0 @@
/*** BEGIN file-header ***/
#ifndef __GSWE_ENUM_TYPES_H__
#define __GSWE_ENUM_TYPES_H__
#include <glib-object.h>
/*** END file-header ***/
/*** BEGIN file-production ***/
/* enumerations from "@filename@" */
#include "@filename@"
/*** END file-production ***/
/*** BEGIN value-header ***/
GType @enum_name@_get_type(void);
#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
/*** END value-header ***/
/*** BEGIN file-tail ***/
#endif /* __GSWE_ENUM_TYPES_H__ */
/*** END file-tail ***/

View File

@ -1,906 +0,0 @@
#include "swe-glib.h"
#include "gswe-types.h"
#include "gswe-moment.h"
#include "swe-glib-private.h"
#include "../../swe/src/swephexp.h"
#define SYNODIC 29.53058867
#define GSWE_MOMENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), GSWE_TYPE_MOMENT, GsweMomentPrivate))
/**
* GsweMomentPrivate:
* @timestamp: a #GsweTimestmp object representing the current local time at
* the given position specified by @coordinates. Be warned though,
* that the time zone is NOT checked against the coordinates!
* @coordinates: the coordinates of the observers position
* @revision: an internal counter which is incremented whenever the timestamp
* or the coordinates change. Planetary positions are recalculated
* if this number changes
*/
struct _GsweMomentPrivate {
GsweTimestamp *timestamp;
GsweCoordinates coordinates;
GsweHouseSystem house_system;
guint revision;
GList *house_list;
guint house_revision;
GList *planet_list;
guint points_revision;
GHashTable *element_points;
GHashTable *quality_points;
guint moon_phase_revision;
GsweMoonPhaseData moon_phase;
GList *aspect_list;
guint aspect_revision;
GList *mirrorpoint_list;
guint mirrorpoint_revision;
};
enum {
SIGNAL_CHANGED,
SIGNAL_LAST
};
enum {
PROP_0,
PROP_TIMESTAMP
};
struct GsweAspectFinder {
GswePlanet planet1;
GswePlanet planet2;
};
static guint gswe_moment_signals[SIGNAL_LAST] = {0};
static void gswe_moment_dispose(GObject *gobject);
static void gswe_moment_finalize(GObject *gobject);
static void gswe_moment_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gswe_moment_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
G_DEFINE_TYPE(GsweMoment, gswe_moment, G_TYPE_OBJECT);
static void
gswe_moment_class_init(GsweMomentClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
g_type_class_add_private(klass, sizeof(GsweMomentPrivate));
gobject_class->dispose = gswe_moment_dispose;
gobject_class->finalize = gswe_moment_finalize;
gobject_class->set_property = gswe_moment_set_property;
gobject_class->get_property = gswe_moment_get_property;
/**
* GsweMoment::changed:
* @moment: the GsweMoment object that received the signal
*
* The ::changed signal is emitted each time the time or coordinates are changed
*/
gswe_moment_signals[SIGNAL_CHANGED] = g_signal_new("changed", G_OBJECT_CLASS_TYPE(gobject_class), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET(GsweMomentClass, changed), NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 0);
/**
* GsweMoment:timestamp:
*
* The timestamp associated with this moment
*/
g_object_class_install_property(gobject_class, PROP_TIMESTAMP, g_param_spec_object("timestamp", "Timestamp", "Timestamp of this moment", GSWE_TYPE_TIMESTAMP, G_PARAM_READWRITE));
}
static void
gswe_moment_emit_changed(GsweMoment *moment)
{
g_signal_emit(moment, gswe_moment_signals[SIGNAL_CHANGED], 0);
}
void
gswe_moment_init(GsweMoment *moment)
{
moment->priv = GSWE_MOMENT_GET_PRIVATE(moment);
moment->priv->timestamp = NULL;
moment->priv->house_list = NULL;
moment->priv->planet_list = NULL;
moment->priv->aspect_list = NULL;
moment->priv->mirrorpoint_list = NULL;
moment->priv->element_points = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL);
moment->priv->quality_points = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL);
moment->priv->house_revision = 0;
moment->priv->points_revision = 0;
moment->priv->moon_phase_revision = 0;
moment->priv->aspect_revision = 0;
moment->priv->mirrorpoint_revision = 0;
moment->priv->revision = 1;
}
static void
gswe_moment_timestamp_changed(GsweMoment *moment, gpointer data)
{
moment->priv->revision++;
gswe_moment_emit_changed(moment);
}
static void
gswe_moment_dispose(GObject *gobject)
{
GsweMoment *moment = GSWE_MOMENT(gobject);
g_signal_handlers_disconnect_by_func(moment->priv->timestamp, gswe_moment_timestamp_changed, NULL);
g_clear_object(&moment->priv->timestamp);
G_OBJECT_CLASS(gswe_moment_parent_class)->dispose(gobject);
}
static void
gswe_moment_finalize(GObject *gobject)
{
GsweMoment *moment = GSWE_MOMENT(gobject);
g_list_free_full(moment->priv->house_list, g_free);
g_list_free_full(moment->priv->planet_list, g_free);
G_OBJECT_CLASS(gswe_moment_parent_class)->finalize(gobject);
}
static void
gswe_moment_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
GsweMoment *moment = GSWE_MOMENT(object);
switch (prop_id) {
case PROP_TIMESTAMP:
gswe_moment_set_timestamp(moment, (g_value_get_object(value)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
gswe_moment_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
GsweMoment *moment = GSWE_MOMENT(object);
GsweMomentPrivate *priv = moment->priv;
switch (prop_id) {
case PROP_TIMESTAMP:
g_value_set_object(value, priv->timestamp);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
/**
* gswe_moment_set_timestamp:
* @moment: A GsweMoment object
* @timestamp: A GsweTimestamp object. The moment object holds a reference on
* timestamp, which is cleared when a new timestamp is set, or the
* moment object is disposed.
*
* Sets a new timestamp for this planetary moment. Also emits the ::changed
* signal to notify owner of this change. This helps redrawing screen data
* according to the new time value.
*/
void
gswe_moment_set_timestamp(GsweMoment *moment, GsweTimestamp *timestamp)
{
if (moment->priv->timestamp != NULL) {
g_signal_handlers_disconnect_by_func(moment->priv->timestamp, gswe_moment_timestamp_changed, NULL);
g_clear_object(&moment->priv->timestamp);
}
moment->priv->timestamp = timestamp;
g_object_ref(timestamp);
g_signal_connect(G_OBJECT(timestamp), "changed", G_CALLBACK(gswe_moment_timestamp_changed), NULL);
/* Emit the changed signal to notify registrants of the change */
gswe_moment_emit_changed(moment);
}
/**
* gswe_moment_get_timestamp:
* @moment: The GsweMoment object of which you requent its timestamp object
*
* Get the timestamp object of the given GsweMoment. The moment object holds a
* reference to this object, so if you need the timestamp object after moment
* is disposed, call g_object_ref() on it!
*
* Returns: a #GsweTimestamp object assigned to the given moment
*/
GsweTimestamp *
gswe_moment_get_timestamp(GsweMoment *moment)
{
return moment->priv->timestamp;
}
GQuark
gswe_moment_error_quark(void)
{
return g_quark_from_static_string("swe-glib-gswe-moment-error");
}
GsweMoment *
gswe_moment_new(void)
{
return (GsweMoment *)g_object_new(GSWE_TYPE_MOMENT, NULL);
}
GsweMoment *
gswe_moment_new_full(GsweTimestamp *timestamp, gdouble longitude, gdouble latitude, gdouble altitude, GsweHouseSystem house_system)
{
GsweMoment *moment = gswe_moment_new();
moment->priv->timestamp = timestamp;
g_object_ref(timestamp);
g_signal_connect(G_OBJECT(timestamp), "changed", G_CALLBACK(gswe_moment_timestamp_changed), NULL);
moment->priv->coordinates.longitude = longitude;
moment->priv->coordinates.latitude = latitude;
moment->priv->coordinates.altitude = altitude;
moment->priv->house_system = house_system;
return moment;
}
static gint
find_by_planet_id(gconstpointer a, gconstpointer b)
{
const GswePlanetData *planet_data = a;
const GswePlanet *planet = b;
if (planet_data->planet_id == *planet) {
return 0;
}
return 1;
}
static void
gswe_calculate_data_by_position(GsweMoment *moment, GswePlanet planet, gdouble position)
{
GswePlanetData *planet_data = (GswePlanetData *)(g_list_find_custom(moment->priv->planet_list, &planet, find_by_planet_id)->data);
GsweZodiac sign;
GsweSignInfo *sign_info;
if (planet_data == NULL) {
return;
}
if (planet_data->revision == moment->priv->revision) {
return;
}
sign = (GsweZodiac)ceil(position / 30.0);
if ((sign_info = g_hash_table_lookup(gswe_sign_info_table, GINT_TO_POINTER(sign))) == NULL) {
g_error("Calculations brought an unknown sign!");
}
planet_data->position = position;
planet_data->retrograde = FALSE;
planet_data->house = gswe_moment_get_house(moment, position);
planet_data->sign = sign_info;
planet_data->revision = moment->priv->revision;
}
static void
gswe_moment_calculate_house_positions(GsweMoment *moment)
{
gdouble cusps[13],
ascmc[10];
gint i;
GsweHouseSystemInfo *house_system_data;
if (moment->priv->house_revision == moment->priv->revision) {
return;
}
if ((house_system_data = g_hash_table_lookup(gswe_house_system_info_table, GINT_TO_POINTER(moment->priv->house_system))) == NULL) {
g_error("Unknown house system!");
}
swe_houses(gswe_timestamp_get_julian_day(moment->priv->timestamp), moment->priv->coordinates.latitude, moment->priv->coordinates.longitude, house_system_data->sweph_id, cusps, ascmc);
g_list_free_full(moment->priv->house_list, g_free);
moment->priv->house_list = NULL;
for (i = 12; i >= 1; i--) {
GsweHouseData *house_data = g_new0(GsweHouseData, 1);
house_data->house = i;
house_data->cusp_position = cusps[i];
if ((house_data->sign = g_hash_table_lookup(gswe_sign_info_table, GINT_TO_POINTER((gint)ceilf(cusps[i] / 30.0)))) == NULL) {
g_error("Calculations brought an unknown sign!");
}
moment->priv->house_list = g_list_prepend(moment->priv->house_list, house_data);
}
moment->priv->house_revision = moment->priv->revision;
if (gswe_moment_has_planet(moment, GSWE_PLANET_ASCENDENT)) {
gswe_calculate_data_by_position(moment, GSWE_PLANET_ASCENDENT, ascmc[0]);
}
if (gswe_moment_has_planet(moment, GSWE_PLANET_MC)) {
gswe_calculate_data_by_position(moment, GSWE_PLANET_MC, ascmc[1]);
}
if (gswe_moment_has_planet(moment, GSWE_PLANET_VERTEX)) {
gswe_calculate_data_by_position(moment, GSWE_PLANET_VERTEX, ascmc[3]);
}
}
GList *
gswe_moment_get_house_cusps(GsweMoment *moment)
{
if (moment->priv->house_revision != moment->priv->revision) {
gswe_moment_calculate_house_positions(moment);
}
return moment->priv->house_list;
}
gboolean
gswe_moment_has_planet(GsweMoment *moment, GswePlanet planet)
{
return (g_list_find_custom(moment->priv->planet_list, &planet, find_by_planet_id) != NULL);
}
void
gswe_moment_add_planet(GsweMoment *moment, GswePlanet planet)
{
GswePlanetData *planet_data = g_new0(GswePlanetData, 1);
GswePlanetInfo *planet_info;
if (gswe_moment_has_planet(moment, planet)) {
return;
}
if ((planet_info = g_hash_table_lookup(gswe_planet_info_table, GINT_TO_POINTER(planet))) == NULL) {
g_warning("Unknown planet ID: %d", planet);
return;
}
planet_data->planet_id = planet;
planet_data->planet_info = planet_info;
planet_data->position = 0.0;
planet_data->house = 1;
planet_data->sign = NULL;
planet_data->revision = 0;
moment->priv->planet_list = g_list_append(moment->priv->planet_list, planet_data);
}
static void
planet_add(gpointer key, gpointer value, gpointer user_data)
{
GswePlanet planet = (GswePlanet)GPOINTER_TO_INT(key);
GsweMoment *moment = GSWE_MOMENT(user_data);
gswe_moment_add_planet(moment, planet);
}
void
gswe_moment_add_all_planets(GsweMoment *moment)
{
g_hash_table_foreach(gswe_planet_info_table, planet_add, moment);
}
static void
gswe_moment_calculate_planet(GsweMoment *moment, GswePlanet planet)
{
GswePlanetData *planet_data = (GswePlanetData *)(g_list_find_custom(moment->priv->planet_list, &planet, find_by_planet_id)->data);
gchar serr[AS_MAXCH];
gint ret;
gdouble x2[6];
if (planet_data == NULL) {
return;
}
if (planet_data->revision == moment->priv->revision) {
return;
}
if (planet_data->planet_info->real_body == FALSE) {
g_warning("The position data of planet %d can not be calculated by this function", planet);
return;
}
swe_set_topo(moment->priv->coordinates.longitude, moment->priv->coordinates.latitude, moment->priv->coordinates.altitude);
if ((ret = swe_calc(gswe_timestamp_get_julian_day(moment->priv->timestamp), planet_data->planet_info->sweph_id, SEFLG_SPEED | SEFLG_TOPOCTR, x2, serr)) < 0) {
g_warning("Swiss Ephemeris error: %s", serr);
return;
} else if (ret != (SEFLG_SPEED | SEFLG_TOPOCTR)) {
g_warning("Swiss Ephemeris error: %s", serr);
}
gswe_calculate_data_by_position(moment, planet, x2[0]);
planet_data->retrograde = (x2[3] < 0);
}
void
calculate_planet(gpointer data, gpointer user_data)
{
GswePlanetData *planet_data = data;
GsweMoment *moment = user_data;
gswe_moment_calculate_planet(moment, planet_data->planet_id);
}
void
gswe_moment_calculate_all_planets(GsweMoment *moment)
{
g_list_foreach(moment->priv->planet_list, calculate_planet, moment);
}
GList *
gswe_moment_get_planets(GsweMoment *moment)
{
return moment->priv->planet_list;
}
gint
gswe_moment_get_house(GsweMoment *moment, gdouble position)
{
gint i;
gswe_moment_calculate_house_positions(moment);
for (i = 1; i <= 12; i++) {
gint j = (i < 12) ? i + 1 : 1;
gdouble cusp_i = *(gdouble *)g_list_nth_data(moment->priv->house_list, i - 1),
cusp_j = *(gdouble *)g_list_nth_data(moment->priv->house_list, j - 1);
if (cusp_j < cusp_i) {
if ((position >= cusp_i) || (position < cusp_j)) {
return i;
}
} else {
if ((position >= cusp_i) && (position < cusp_j)) {
return i;
}
}
}
return 0;
}
GswePlanetData *
gswe_moment_get_planet(GsweMoment *moment, GswePlanet planet)
{
GswePlanetData *planet_data = (GswePlanetData *)(g_list_find_custom(moment->priv->planet_list, &planet, find_by_planet_id)->data);
if (planet_data == NULL) {
return NULL;
}
gswe_moment_calculate_planet(moment, planet);
return planet_data;
}
static void
add_points(GswePlanetData *planet_data, GsweMoment *moment)
{
guint point;
gswe_moment_calculate_planet(moment, planet_data->planet_id);
point = GPOINTER_TO_INT(g_hash_table_lookup(moment->priv->element_points, GINT_TO_POINTER(planet_data->sign->element))) + planet_data->planet_info->points;
g_hash_table_replace(moment->priv->element_points, GINT_TO_POINTER(planet_data->sign->element), GINT_TO_POINTER(point));
point = GPOINTER_TO_INT(g_hash_table_lookup(moment->priv->quality_points, GINT_TO_POINTER(planet_data->sign->quality)));
point += planet_data->planet_info->points;
g_hash_table_replace(moment->priv->quality_points, GINT_TO_POINTER(planet_data->sign->quality), GINT_TO_POINTER(point));
}
static void
gswe_moment_calculate_points(GsweMoment *moment)
{
if (moment->priv->points_revision == moment->priv->revision) {
return;
}
g_hash_table_remove_all(moment->priv->element_points);
g_hash_table_remove_all(moment->priv->quality_points);
g_list_foreach(moment->priv->planet_list, (GFunc)add_points, moment);
moment->priv->points_revision = moment->priv->revision;
}
guint
gswe_moment_get_element_points(GsweMoment *moment, GsweElement element)
{
guint point;
gswe_moment_calculate_points(moment);
point = GPOINTER_TO_INT(g_hash_table_lookup(moment->priv->element_points, GINT_TO_POINTER(element)));
return point;
}
guint
gswe_moment_get_quality_points(GsweMoment *moment, GsweQuality quality)
{
guint point;
gswe_moment_calculate_points(moment);
point = GPOINTER_TO_INT(g_hash_table_lookup(moment->priv->quality_points, GINT_TO_POINTER(quality)));
return point;
}
GsweMoonPhaseData *
gswe_moment_get_moon_phase(GsweMoment *moment)
{
gdouble difference,
phase_percent;
if (moment->priv->moon_phase_revision == moment->priv->revision) {
return &(moment->priv->moon_phase);
}
difference = (gswe_timestamp_get_julian_day(moment->priv->timestamp) - gswe_timestamp_get_julian_day(gswe_full_moon_base_date));
phase_percent = fmod((difference * 100) / SYNODIC, 100);
if (phase_percent < 0) {
phase_percent += 100.0;
}
if ((phase_percent < 0) || (phase_percent > 100)) {
g_error("Error during Moon phase calculation!");
}
moment->priv->moon_phase.illumination = (50.0 - fabs(phase_percent - 50.0)) * 2;
if (phase_percent == 0) {
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_NEW;
} else if (phase_percent < 25) {
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_WAXING_CRESCENT;
} else if (phase_percent == 25) {
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_WAXING_HALF;
} else if (phase_percent < 50) {
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_WAXING_GIBBOUS;
} else if (phase_percent == 50) {
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_FULL;
} else if (phase_percent < 75) {
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_WANING_GIBBOUS;
} else if (phase_percent == 75) {
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_WANING_HALF;
} else if (phase_percent < 100) {
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_WANING_CRESCENT;
} else {
moment->priv->moon_phase.phase = GSWE_MOON_PHASE_DARK;
}
moment->priv->moon_phase_revision = moment->priv->revision;
return &(moment->priv->moon_phase);
}
static gint
find_aspect_by_both_planets(GsweAspectData *aspect, struct GsweAspectFinder *aspect_finder)
{
if (((aspect->planet1->planet_id == aspect_finder->planet1) && (aspect->planet2->planet_id == aspect_finder->planet2)) || ((aspect->planet1->planet_id == aspect_finder->planet2) && (aspect->planet2->planet_id == aspect_finder->planet1))) {
return 0;
}
return 1;
}
static gboolean
find_aspect(gpointer aspect_p, GsweAspectInfo *aspect_info, GsweAspectData *aspect_data)
{
GsweAspect aspect = GPOINTER_TO_INT(aspect_p);
gdouble diff,
planet_orb,
aspect_orb;
aspect_data->distance = fabs(aspect_data->planet1->position - aspect_data->planet2->position);
if (aspect_data->distance > 180.0) {
aspect_data->distance = 360.0 - aspect_data->distance;
}
diff = fabs(aspect_info->size - aspect_data->distance);
planet_orb = fmin(aspect_data->planet1->planet_info->orb, aspect_data->planet2->planet_info->orb);
aspect_orb = fmax(1.0, planet_orb - aspect_info->orb_modifier);
if (diff < aspect_orb) {
aspect_data->aspect = aspect;
aspect_data->aspect_info = aspect_info;
if (aspect_info->size == 0) {
aspect_data->difference = (1 - ((360.0 - diff) / 360.0)) * 100.0;
} else {
aspect_data->difference = (1 - ((aspect_info->size - diff) / aspect_info->size)) * 100.0;
}
return TRUE;
}
return FALSE;
}
static void
gswe_moment_calculate_aspects(GsweMoment *moment)
{
GList *oplanet,
*iplanet;
if (moment->priv->aspect_revision == moment->priv->revision) {
return;
}
gswe_moment_calculate_all_planets(moment);
g_list_free_full(moment->priv->aspect_list, g_free);
for (oplanet = moment->priv->planet_list; oplanet; oplanet = oplanet->next) {
for (iplanet = moment->priv->planet_list; iplanet; iplanet = iplanet->next) {
GswePlanetData *outer_planet = oplanet->data,
*inner_planet = iplanet->data;
struct GsweAspectFinder aspect_finder;
GsweAspectData *aspect_data;
if (outer_planet->planet_id == inner_planet->planet_id) {
continue;
}
aspect_finder.planet1 = outer_planet->planet_id;
aspect_finder.planet2 = inner_planet->planet_id;
if (g_list_find_custom(moment->priv->aspect_list, &aspect_finder, (GCompareFunc)find_aspect_by_both_planets) != NULL) {
continue;
}
aspect_data = g_new0(GsweAspectData, 1);
aspect_data->planet1 = outer_planet;
aspect_data->planet2 = inner_planet;
aspect_data->aspect = GSWE_ASPECT_NONE;
(void)g_hash_table_find(gswe_aspect_info_table, (GHRFunc)find_aspect, aspect_data);
if (aspect_data->aspect == GSWE_ASPECT_NONE) {
aspect_data->aspect_info = g_hash_table_lookup(gswe_aspect_info_table, GINT_TO_POINTER(GSWE_ASPECT_NONE));
}
moment->priv->aspect_list = g_list_prepend(moment->priv->aspect_list, aspect_data);
}
}
moment->priv->aspect_revision = moment->priv->revision;
}
/**
* gswe_moment_get_aspects:
* @moment: the GsweMoment to operate on
*
* Gets all planetary aspects between the planets added by
* gswe_moment_add_planet() or gswe_moment_add_all_planets().
*
* Returns: a GList of #GsweAspectData. Both the GList and GsweAspectData
* objects belong to @moment, and should not be freed or modified.
*/
GList *
gswe_moment_get_aspects(GsweMoment *moment)
{
gswe_moment_calculate_aspects(moment);
return moment->priv->aspect_list;
}
/**
* gswe_moment_get_planet_aspects:
* @moment: the GsweMoment to operate on
* @planet: the planet whose aspects you want to get
*
* Get all the aspects between @planet and all the other planets added with
* gswe_moment_add_planet() or gswe_moment_add_all_planets().
*
* Returns: a GList of #GsweAspectData. The GsweAspectData structures belong to
* @moment, but the GList should be freed using g_list_free(). If the
* planet has no aspects, or the planet has not been added to @moment,
* returns NULL.
*/
GList *
gswe_moment_get_planet_aspects(GsweMoment *moment, GswePlanet planet)
{
GList *ret = NULL,
*aspect;
gswe_moment_calculate_aspects(moment);
for (aspect = moment->priv->aspect_list; aspect; aspect = aspect->next) {
GsweAspectData *aspect_data = aspect->data;
if ((aspect_data->planet1->planet_id == planet) || (aspect_data->planet2->planet_id == planet)) {
ret = g_list_prepend(ret, aspect_data);
}
}
return ret;
}
static gboolean
find_mirror(gpointer mirror_p, GsweMirrorInfo *mirror_info, GsweMirrorData *mirror_data)
{
GsweMirror mirror = GPOINTER_TO_INT(mirror_p);
gdouble start_point,
mirror_position,
planet_orb;
if (mirror == GSWE_MIRROR_NONE) {
return FALSE;
}
planet_orb = fmin(mirror_data->planet1->planet_info->orb, mirror_data->planet2->planet_info->orb);
start_point = (mirror_info->start_sign->sign_id - 1) * 30.0;
if (mirror_info->middle_axis == TRUE) {
start_point += 15.0;
}
mirror_position = 2 * start_point - mirror_data->planet1->position;
if (mirror_position < 0) {
mirror_position += 360.0;
}
if ((mirror_data->difference = fabs(mirror_data->planet2->position - mirror_position)) <= planet_orb) {
mirror_data->mirror_info = mirror_info;
mirror_data->mirror = mirror;
return TRUE;
} else {
mirror_data->difference = 0.0;
}
return FALSE;
}
static gint
find_mirror_by_both_planets(GsweMirrorData *mirror, struct GsweAspectFinder *mirror_finder)
{
if (((mirror->planet1->planet_id == mirror_finder->planet1) && (mirror->planet2->planet_id == mirror_finder->planet2)) || ((mirror->planet1->planet_id == mirror_finder->planet2) && (mirror->planet2->planet_id == mirror_finder->planet1))) {
return 0;
}
return 1;
}
static void
gswe_moment_calculate_mirrorpoints(GsweMoment *moment)
{
GList *oplanet,
*iplanet;
if (moment->priv->mirrorpoint_revision == moment->priv->revision) {
return;
}
gswe_moment_calculate_all_planets(moment);
g_list_free_full(moment->priv->mirrorpoint_list, g_free);
for (oplanet = moment->priv->planet_list; oplanet; oplanet = oplanet->next) {
for (iplanet = moment->priv->planet_list; iplanet; iplanet = iplanet->next) {
GswePlanetData *outer_planet = oplanet->data,
*inner_planet = iplanet->data;
GsweMirrorData *mirror_data;
struct GsweAspectFinder mirror_finder;
if (outer_planet->planet_id == inner_planet->planet_id) {
continue;
}
mirror_finder.planet1 = outer_planet->planet_id;
mirror_finder.planet2 = inner_planet->planet_id;
if (g_list_find_custom(moment->priv->mirrorpoint_list, &mirror_finder, (GCompareFunc)find_mirror_by_both_planets) != NULL) {
continue;
}
mirror_data = g_new0(GsweMirrorData, 1);
mirror_data->planet1 = outer_planet;
mirror_data->planet2 = inner_planet;
mirror_data->mirror = GSWE_MIRROR_NONE;
(void)g_hash_table_find(gswe_mirror_info_table, (GHRFunc)find_mirror, mirror_data);
if (mirror_data->mirror == GSWE_MIRROR_NONE) {
mirror_data->mirror_info = g_hash_table_lookup(gswe_mirror_info_table, GINT_TO_POINTER(GSWE_MIRROR_NONE));
}
moment->priv->mirrorpoint_list = g_list_prepend(moment->priv->mirrorpoint_list, mirror_data);
}
}
moment->priv->mirrorpoint_revision = moment->priv->revision;
}
GList *
gswe_moment_get_all_mirrorpoints(GsweMoment *moment)
{
gswe_moment_calculate_mirrorpoints(moment);
return moment->priv->mirrorpoint_list;
}
GList *
gswe_moment_get_all_planet_mirrorpoints(GsweMoment *moment, GswePlanet planet)
{
GList *ret = NULL,
*mirror;
gswe_moment_calculate_mirrorpoints(moment);
for (mirror = moment->priv->mirrorpoint_list; mirror; mirror = mirror->next) {
GsweMirrorData *mirror_data = mirror->data;
if ((mirror_data->planet1->planet_id == planet) || (mirror_data->planet2->planet_id == planet)) {
ret = g_list_prepend(ret, mirror_data);
}
}
return ret;
}
GList *
gswe_moment_get_mirror_mirrorpoints(GsweMoment *moment, GsweMirror mirror)
{
GList *ret = NULL,
*mirror_l;
gswe_moment_calculate_mirrorpoints(moment);
for (mirror_l = moment->priv->mirrorpoint_list; mirror_l; mirror_l = mirror_l->next) {
GsweMirrorData *mirror_data = mirror_l->data;
if (mirror_data->mirror == mirror) {
ret = g_list_prepend(ret, mirror_data);
}
}
return ret;
}
GList *
gswe_moment_get_mirror_planet_mirrorpoints(GsweMoment *moment, GsweMirror mirror, GswePlanet planet)
{
GList *ret = NULL,
*mirror_l;
gswe_moment_calculate_mirrorpoints(moment);
for (mirror_l = moment->priv->mirrorpoint_list; mirror_l; mirror_l = mirror_l->next) {
GsweMirrorData *mirror_data = mirror_l->data;
if (((mirror_data->planet1->planet_id == planet) || (mirror_data->planet2->planet_id == planet)) && (mirror_data->mirror == mirror)) {
ret = g_list_prepend(ret, mirror_data);
}
}
return ret;
}

View File

@ -1,136 +0,0 @@
#ifndef __GSWE_MOMENT_H__
#define __GSWE_MOMENT_H__
#include <glib-object.h>
#include "gswe-timestamp.h"
#define GSWE_TYPE_MOMENT (gswe_moment_get_type())
#define GSWE_MOMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GSWE_TYPE_MOMENT, GsweMoment))
#define GSWE_IS_MOMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GSWE_TYPE_MOMENT))
#define GSWE_MOMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GSWE_TYPE_MOMENT, GsweMomentClass))
#define GSWE_IS_MOMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GSWE_TYPE_MOMENT))
#define GSWE_MOMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GSWE_TYPE_MOMENT, GsweMomentClass))
typedef struct _GsweMoment GsweMoment;
typedef struct _GsweMomentClass GsweMomentClass;
typedef struct _GsweMomentPrivate GsweMomentPrivate;
#define GSWE_MOMENT_ERROR gswe_moment_error_quark()
GQuark gswe_moment_error_quark(void);
/*
* GsweMomentError:
*
* Error values for GsweTimestamp initialization
*/
//typedef enum {
//} GsweMomentError;
/**
* GsweCoordinates:
* @longitude: longitude part of the coordinates
* @latitude: latitude part of the coordinates
* @altitude: altitude relative to sea level
*
* GsweCoordinates specifies an exact point on Earth's surface
*/
typedef struct _GsweCoordinates {
gdouble longitude;
gdouble latitude;
gdouble altitude;
} GsweCoordinates;
/**
* GswePlanetData:
* @planet_id: A GswePlanet, the identifier of the planet
* @planet_info: A GswePlanetInfo structure, holding every information about the planet
* @position: The longitude position of the planet
* @house: Number of the house in which the planet is in
* @sign: A GsweSignInfo structure, holding every information about the sign the planet is in
* @revision: An internal version number of the calculation
*/
typedef struct {
GswePlanet planet_id;
GswePlanetInfo *planet_info;
gdouble position;
gboolean retrograde;
gint house;
GsweSignInfo *sign;
guint revision;
} GswePlanetData;
typedef struct {
guint house;
gdouble cusp_position;
GsweSignInfo *sign;
} GsweHouseData;
typedef struct {
GsweMoonPhase phase;
gdouble illumination;
} GsweMoonPhaseData;
typedef struct {
GswePlanetData *planet1;
GswePlanetData *planet2;
gdouble distance;
GsweAspect aspect;
GsweAspectInfo *aspect_info;
gdouble difference;
} GsweAspectData;
typedef struct {
GswePlanetData *planet1;
GswePlanetData *planet2;
GsweMirror mirror;
GsweMirrorInfo *mirror_info;
gdouble difference;
} GsweMirrorData;
struct _GsweMoment {
/* Parent instance structure */
GObject parent_instance;
/* Instance members */
/*< private >*/
GsweMomentPrivate *priv;
};
struct _GsweMomentClass {
/* Parent class structure */
GObjectClass parent_class;
/* Class members */
/*< private >*/
void (*changed)(GsweMoment *moment);
};
/* used by GSWE_TYPE_MOMENT */
GType gswe_moment_get_type(void);
/* Method definitions */
GsweMoment *gswe_moment_new(void);
GsweMoment *gswe_moment_new_full(GsweTimestamp *timestamp, gdouble longitude, gdouble latitude, gdouble altitude, GsweHouseSystem house_system);
void gswe_moment_set_timestamp(GsweMoment *moment, GsweTimestamp *timestamp);
GList *gswe_moment_get_house_cusps(GsweMoment *moment);
gint gswe_moment_get_house(GsweMoment *moment, gdouble position);
gboolean gswe_moment_has_planet(GsweMoment *moment, GswePlanet planet);
void gswe_moment_add_planet(GsweMoment *moment, GswePlanet planet);
void gswe_moment_add_all_planets(GsweMoment *moment);
GList *gswe_moment_get_planets(GsweMoment *moment);
GswePlanetData *gswe_moment_get_planet(GsweMoment *moment, GswePlanet planet);
guint gswe_moment_get_element_points(GsweMoment *moment, GsweElement element);
guint gswe_moment_get_quality_points(GsweMoment *moment, GsweQuality quality);
GsweMoonPhaseData *gswe_moment_get_moon_phase(GsweMoment *moment);
GList *gswe_moment_get_aspects(GsweMoment *moment);
GList *gswe_moment_get_planet_aspects(GsweMoment *moment, GswePlanet planet);
GList *gswe_moment_get_all_mirrorpoints(GsweMoment *moment);
GList *gswe_moment_get_all_planet_mirrorpoints(GsweMoment *moment, GswePlanet planet);
GList *gswe_moment_get_mirror_mirrorpoints(GsweMoment *moment, GsweMirror mirror);
GList *gswe_moment_get_mirror_planet_mirrorpoints(GsweMoment *moment, GsweMirror mirror, GswePlanet planet);
#endif /* __GSWE_MOMENT_H__ */

View File

@ -1,631 +0,0 @@
#include <math.h>
#include <glib.h>
#include "../../swe/src/swephexp.h"
#include "swe-glib-private.h"
#include "gswe-timestamp.h"
#define GSWE_TIMESTAMP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), GSWE_TYPE_TIMESTAMP, GsweTimestampPrivate))
typedef enum {
VALID_GREGORIAN = 1 << 0,
VALID_JULIAN_DAY = 1 << 1
} TimestampValidity;
struct _GsweTimestampPrivate {
gboolean instant_recalc;
TimestampValidity valid_dates;
gint gregorian_year;
gint gregorian_month;
gint gregorian_day;
gint gregorian_hour;
gint gregorian_minute;
gint gregorian_second;
gint gregorian_microsecond;
gdouble gregorian_timezone_offset;
gdouble julian_day;
};
enum {
SIGNAL_CHANGED,
SIGNAL_LAST
};
enum {
PROP_0,
PROP_INSTANT_RECALC,
PROP_GREGORIAN_VALID,
PROP_GREGORIAN_YEAR,
PROP_GREGORIAN_MONTH,
PROP_GREGORIAN_DAY,
PROP_GREGORIAN_HOUR,
PROP_GREGORIAN_MINUTE,
PROP_GREGORIAN_SECOND,
PROP_GREGORIAN_MICROSECOND,
PROP_GREGORIAN_TIMEZONE_OFFSET,
PROP_JULIAN_DAY_VALID
};
static guint gswe_timestamp_signals[SIGNAL_LAST] = { 0 };
static void gswe_timestamp_dispose(GObject *gobject);
static void gswe_timestamp_finalize(GObject *gobject);
static void gswe_timestamp_set_property(GObject *gobject, guint prop_id, const GValue *value, GParamSpec *pspec);
static void gswe_timestamp_get_property(GObject *gobject, guint prop_id, GValue *value, GParamSpec *pspec);
static void gswe_timestamp_calculate_all(GsweTimestamp *timestamp);
static void gswe_timestamp_calculate_gregorian(GsweTimestamp *timestamp);
static void gswe_timestamp_calculate_julian(GsweTimestamp *timestamp);
G_DEFINE_TYPE(GsweTimestamp, gswe_timestamp, G_TYPE_OBJECT);
static void
gswe_timestamp_class_init(GsweTimestampClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
GDateTime *local_time = g_date_time_new_now_local();
g_type_class_add_private(klass, sizeof(GsweTimestampPrivate));
gobject_class->dispose = gswe_timestamp_dispose;
gobject_class->finalize = gswe_timestamp_finalize;
gobject_class->set_property = gswe_timestamp_set_property;
gobject_class->get_property = gswe_timestamp_get_property;
/**
* GsweTimestamp::changed:
* @timestamp: the GsweTimestamp that receives the signal
*
* The ::changed signal is emitted each time the timestamp is changed
*/
gswe_timestamp_signals[SIGNAL_CHANGED] = g_signal_new("changed", G_OBJECT_CLASS_TYPE(gobject_class), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET(GsweTimestampClass, changed), NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 0);
/**
* GsweTimestamp:instant-recalc:
*
* If set to TRUE, recalculate timestamp values instantly, when changing a
* parameter (e.g. recalculate Julian date when changing Gregorian year).
* Otherwise, the values are recalculated only upon request (e.g. on
* calling #gswe_timestamp_get_julian_day()).
*/
g_object_class_install_property(gobject_class, PROP_INSTANT_RECALC, g_param_spec_boolean("instant-recalc", "Instant recalculation", "Instantly recalculate values upon parameter change", FALSE, G_PARAM_READWRITE));
/**
* GsweTimestamp:gregorian-valid
*
* If TRUE, the Gregorian value stored in the GsweTimestamp object is
* currently considered as valid, thus, no recalculation is needed.
* Otherwise, the Gregorian date components will be recalculated upon
* request.
*/
g_object_class_install_property(gobject_class, PROP_GREGORIAN_VALID, g_param_spec_boolean("gregorian-valid", "Gregorian date is valid", "TRUE if the Gregorian date components are considered as valid.", TRUE, G_PARAM_READABLE));
/**
* GsweTimestamp:gregorian-year:
*
* The Gregorian year of the timestamp
*/
g_object_class_install_property(gobject_class, PROP_GREGORIAN_YEAR, g_param_spec_int("gregorian-year", "Gregorian year", "The year according to the Gregorian calendar", G_MININT, G_MAXINT, g_date_time_get_year(local_time), G_PARAM_READWRITE));
/**
* GsweTimestamp:gregorian-month:
*
* The Gregorian month of the timestamp
*/
g_object_class_install_property(gobject_class, PROP_GREGORIAN_MONTH, g_param_spec_int("gregorian-month", "Gregorian month", "The month according to the Gregorian calendar", 1, 12, g_date_time_get_month(local_time), G_PARAM_READWRITE));
/**
* GsweTimestamp:gregorian-day:
*
* The Gregorian day of the timestamp
*/
g_object_class_install_property(gobject_class, PROP_GREGORIAN_DAY, g_param_spec_int("gregorian-day", "Gregorian day", "The day according to the Gregorian calendar", 1, 31, g_date_time_get_day_of_month(local_time), G_PARAM_READWRITE));
/**
* GsweTimestamp:gregorian-hour:
*
* The Gregorian hour of the timestamp
*/
g_object_class_install_property(gobject_class, PROP_GREGORIAN_HOUR, g_param_spec_int("gregorian-hour", "Gregorian hour", "The hour according to the Gregorian calendar", 0, 23, g_date_time_get_hour(local_time), G_PARAM_READWRITE));
/**
* GsweTimestamp:gregorian-minute:
*
* The Gregorian minute of the timestamp
*/
g_object_class_install_property(gobject_class, PROP_GREGORIAN_MINUTE, g_param_spec_int("gregorian-minute", "Gregorian minute", "The minute according to the Gregorian calendar", 0, 59, g_date_time_get_minute(local_time), G_PARAM_READWRITE));
/**
* GsweTimestamp:gregorian-second:
*
* The Gregorian second of the timestamp
*/
g_object_class_install_property(gobject_class, PROP_GREGORIAN_SECOND, g_param_spec_int("gregorian-second", "Gregorian second", "The second according to the Gregorian calendar", 0, 61, g_date_time_get_second(local_time), G_PARAM_READWRITE));
/**
* GsweTimestamp:gregorian-microsecond:
*
* The Gregorian microsecond of the timestamp
*/
g_object_class_install_property(gobject_class, PROP_GREGORIAN_MICROSECOND, g_param_spec_int("gregorian-microsecond", "Gregorian microsecond", "The microsecond according to the Gregorian calendar", 0, G_MAXINT, g_date_time_get_microsecond(local_time), G_PARAM_READWRITE));
/**
* GsweTimestamp:gregorian-timezone-offset:
*
* The time zone offset in hours, relative to UTC
*/
g_object_class_install_property(gobject_class, PROP_GREGORIAN_TIMEZONE_OFFSET, g_param_spec_double("gregorian-timezone-offset", "Gregorian timezone offset", "The offset relative to UTC in the Gregorian calendar", -24.0, 24.0, 0.0, G_PARAM_READWRITE));
/**
* GsweTimestamp:julian-day-valid
*
* If TRUE, the Julian day value stored in the GsweTimestamp object is
* currently considered as valid, thus, no recalculation is needed.
* Otherwise, the Julian day components will be recalculated upon request.
*/
g_object_class_install_property(gobject_class, PROP_JULIAN_DAY_VALID, g_param_spec_boolean("julian-day-valid", "Julian day is valid", "TRUE if the Julian day components are considered as valid.", TRUE, G_PARAM_READABLE));
g_date_time_unref(local_time);
}
static void
gswe_timestamp_emit_changed(GsweTimestamp *timestamp)
{
g_signal_emit(timestamp, gswe_timestamp_signals[SIGNAL_CHANGED], 0);
}
void
gswe_timestamp_init(GsweTimestamp *self)
{
self->priv = GSWE_TIMESTAMP_GET_PRIVATE(self);
}
static void
gswe_timestamp_dispose(GObject *gobject)
{
G_OBJECT_CLASS(gswe_timestamp_parent_class)->dispose(gobject);
}
static void
gswe_timestamp_finalize(GObject *gobject)
{
G_OBJECT_CLASS(gswe_timestamp_parent_class)->finalize(gobject);
}
static void
gswe_timestamp_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
GsweTimestamp *timestamp = GSWE_TIMESTAMP(object);
switch (prop_id) {
case PROP_INSTANT_RECALC:
gswe_timestamp_calculate_all(timestamp);
break;
case PROP_GREGORIAN_YEAR:
gswe_timestamp_set_gregorian_year(timestamp, g_value_get_int(value));
break;
case PROP_GREGORIAN_MONTH:
gswe_timestamp_set_gregorian_month(timestamp, g_value_get_int(value));
break;
case PROP_GREGORIAN_DAY:
gswe_timestamp_set_gregorian_day(timestamp, g_value_get_int(value));
break;
case PROP_GREGORIAN_HOUR:
gswe_timestamp_set_gregorian_hour(timestamp, g_value_get_int(value));
break;
case PROP_GREGORIAN_MINUTE:
gswe_timestamp_set_gregorian_minute(timestamp, g_value_get_int(value));
break;
case PROP_GREGORIAN_SECOND:
gswe_timestamp_set_gregorian_second(timestamp, g_value_get_int(value));
break;
case PROP_GREGORIAN_MICROSECOND:
gswe_timestamp_set_gregorian_microsecond(timestamp, g_value_get_int(value));
break;
case PROP_GREGORIAN_TIMEZONE_OFFSET:
gswe_timestamp_set_gregorian_timezone(timestamp, g_value_get_double(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
gswe_timestamp_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
GsweTimestamp *timestamp = GSWE_TIMESTAMP(object);
switch (prop_id) {
case PROP_INSTANT_RECALC:
g_value_set_boolean(value, timestamp->priv->instant_recalc);
break;
case PROP_GREGORIAN_VALID:
g_value_set_boolean(value, ((timestamp->priv->valid_dates & VALID_GREGORIAN) == VALID_GREGORIAN));
break;
case PROP_GREGORIAN_YEAR:
gswe_timestamp_calculate_gregorian(timestamp);
g_value_set_int(value, timestamp->priv->gregorian_year);
break;
case PROP_GREGORIAN_MONTH:
gswe_timestamp_calculate_gregorian(timestamp);
g_value_set_int(value, timestamp->priv->gregorian_month);
break;
case PROP_GREGORIAN_DAY:
gswe_timestamp_calculate_gregorian(timestamp);
g_value_set_int(value, timestamp->priv->gregorian_day);
break;
case PROP_GREGORIAN_HOUR:
gswe_timestamp_calculate_gregorian(timestamp);
g_value_set_int(value, timestamp->priv->gregorian_hour);
break;
case PROP_GREGORIAN_MINUTE:
gswe_timestamp_calculate_gregorian(timestamp);
g_value_set_int(value, timestamp->priv->gregorian_minute);
break;
case PROP_GREGORIAN_SECOND:
gswe_timestamp_calculate_gregorian(timestamp);
g_value_set_int(value, timestamp->priv->gregorian_second);
break;
case PROP_GREGORIAN_MICROSECOND:
gswe_timestamp_calculate_gregorian(timestamp);
g_value_set_int(value, timestamp->priv->gregorian_microsecond);
break;
case PROP_GREGORIAN_TIMEZONE_OFFSET:
g_value_set_double(value, timestamp->priv->gregorian_timezone_offset);
break;
case PROP_JULIAN_DAY_VALID:
g_value_set_boolean(value, ((timestamp->priv->valid_dates & VALID_JULIAN_DAY) == VALID_JULIAN_DAY));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
static void
gswe_timestamp_calculate_all(GsweTimestamp *timestamp)
{
if ((timestamp->priv->valid_dates & VALID_JULIAN_DAY) != VALID_JULIAN_DAY) {
gswe_timestamp_calculate_julian(timestamp);
}
if ((timestamp->priv->valid_dates & VALID_GREGORIAN) != VALID_GREGORIAN) {
gswe_timestamp_calculate_gregorian(timestamp);
}
}
static void
gswe_timestamp_calculate_gregorian(GsweTimestamp *timestamp)
{
if ((timestamp->priv->valid_dates & VALID_GREGORIAN) == VALID_GREGORIAN) {
return;
}
if (timestamp->priv->valid_dates == 0) {
g_error("This timestamp object holds no valid values. This can't be good.");
}
g_warning("This method is not implemented yet.");
}
void
gswe_timestamp_set_instant_recalc(GsweTimestamp *timestamp, gboolean instant_recalc)
{
timestamp->priv->instant_recalc = instant_recalc;
if (instant_recalc == TRUE) {
gswe_timestamp_calculate_all(timestamp);
}
}
gboolean
gswe_timestamp_get_instant_recalc(GsweTimestamp *timestamp)
{
return timestamp->priv->instant_recalc;
}
void
gswe_timestamp_set_gregorian_year(GsweTimestamp *timestamp, gint gregorian_year)
{
timestamp->priv->gregorian_year = gregorian_year;
timestamp->priv->valid_dates = VALID_GREGORIAN;
if (timestamp->priv->instant_recalc == TRUE) {
gswe_timestamp_calculate_all(timestamp);
}
gswe_timestamp_emit_changed(timestamp);
}
gint
gswe_timestamp_get_gregorian_year(GsweTimestamp *timestamp)
{
gswe_timestamp_calculate_gregorian(timestamp);
return timestamp->priv->gregorian_year;
}
void
gswe_timestamp_set_gregorian_month(GsweTimestamp *timestamp, gint gregorian_month)
{
timestamp->priv->gregorian_month = gregorian_month;
timestamp->priv->valid_dates = VALID_GREGORIAN;
if (timestamp->priv->instant_recalc == TRUE) {
gswe_timestamp_calculate_all(timestamp);
}
gswe_timestamp_emit_changed(timestamp);
}
gint
gswe_timestamp_get_gregorian_month(GsweTimestamp *timestamp)
{
gswe_timestamp_calculate_gregorian(timestamp);
return timestamp->priv->gregorian_month;
}
void
gswe_timestamp_set_gregorian_day(GsweTimestamp *timestamp, gint gregorian_day)
{
timestamp->priv->gregorian_day = gregorian_day;
timestamp->priv->valid_dates = VALID_GREGORIAN;
if (timestamp->priv->instant_recalc == TRUE) {
gswe_timestamp_calculate_all(timestamp);
}
gswe_timestamp_emit_changed(timestamp);
}
gint
gswe_timestamp_get_gregorian_day(GsweTimestamp *timestamp)
{
gswe_timestamp_calculate_gregorian(timestamp);
return timestamp->priv->gregorian_day;
}
void
gswe_timestamp_set_gregorian_hour(GsweTimestamp *timestamp, gint gregorian_hour)
{
timestamp->priv->gregorian_hour = gregorian_hour;
timestamp->priv->valid_dates = VALID_GREGORIAN;
if (timestamp->priv->instant_recalc == TRUE) {
gswe_timestamp_calculate_all(timestamp);
}
gswe_timestamp_emit_changed(timestamp);
}
gint
gswe_timestamp_get_gregorian_hour(GsweTimestamp *timestamp)
{
gswe_timestamp_calculate_gregorian(timestamp);
return timestamp->priv->gregorian_hour;
}
void
gswe_timestamp_set_gregorian_minute(GsweTimestamp *timestamp, gint gregorian_minute)
{
timestamp->priv->gregorian_minute = gregorian_minute;
timestamp->priv->valid_dates = VALID_GREGORIAN;
if (timestamp->priv->instant_recalc == TRUE) {
gswe_timestamp_calculate_all(timestamp);
}
gswe_timestamp_emit_changed(timestamp);
}
gint
gswe_timestamp_get_gregorian_minute(GsweTimestamp *timestamp)
{
gswe_timestamp_calculate_gregorian(timestamp);
return timestamp->priv->gregorian_minute;
}
void
gswe_timestamp_set_gregorian_second(GsweTimestamp *timestamp, gint gregorian_second)
{
timestamp->priv->gregorian_second = gregorian_second;
timestamp->priv->valid_dates = VALID_GREGORIAN;
if (timestamp->priv->instant_recalc == TRUE) {
gswe_timestamp_calculate_all(timestamp);
}
gswe_timestamp_emit_changed(timestamp);
}
gint
gswe_timestamp_get_gregorian_second(GsweTimestamp *timestamp)
{
gswe_timestamp_calculate_gregorian(timestamp);
return timestamp->priv->gregorian_second;
}
void
gswe_timestamp_set_gregorian_microsecond(GsweTimestamp *timestamp, gint gregorian_microsecond)
{
timestamp->priv->gregorian_microsecond = gregorian_microsecond;
timestamp->priv->valid_dates = VALID_GREGORIAN;
if (timestamp->priv->instant_recalc == TRUE) {
gswe_timestamp_calculate_all(timestamp);
}
gswe_timestamp_emit_changed(timestamp);
}
gint
gswe_timestamp_get_gregorian_microsecond(GsweTimestamp *timestamp)
{
gswe_timestamp_calculate_gregorian(timestamp);
return timestamp->priv->gregorian_microsecond;
}
void
gswe_timestamp_set_gregorian_timezone(GsweTimestamp *timestamp, gdouble gregorian_timezone_offset)
{
timestamp->priv->gregorian_timezone_offset = gregorian_timezone_offset;
timestamp->priv->valid_dates = VALID_GREGORIAN;
if (timestamp->priv->instant_recalc == TRUE) {
gswe_timestamp_calculate_all(timestamp);
}
gswe_timestamp_emit_changed(timestamp);
}
gdouble
gswe_timestamp_get_gregorian_timezone(GsweTimestamp *timestamp)
{
gswe_timestamp_calculate_gregorian(timestamp);
return timestamp->priv->gregorian_timezone_offset;
}
static void
gswe_timestamp_calculate_julian(GsweTimestamp *timestamp)
{
gint utc_year,
utc_month,
utc_day,
utc_hour,
utc_minute,
retval;
gdouble utc_second,
dret[2];
gchar serr[AS_MAXCH];
if ((timestamp->priv->valid_dates & VALID_JULIAN_DAY) == VALID_JULIAN_DAY) {
return;
}
if (timestamp->priv->valid_dates == 0) {
g_error("This timestamp object holds no valid values. This can't be good.");
}
swe_utc_time_zone(timestamp->priv->gregorian_year, timestamp->priv->gregorian_month, timestamp->priv->gregorian_day, timestamp->priv->gregorian_hour, timestamp->priv->gregorian_minute, timestamp->priv->gregorian_second + timestamp->priv->gregorian_microsecond / 1000.0, timestamp->priv->gregorian_timezone_offset, &utc_year, &utc_month, &utc_day, &utc_hour, &utc_minute, &utc_second);
if ((retval = swe_utc_to_jd(utc_year, utc_month, utc_day, utc_hour, utc_minute, utc_second, SE_GREG_CAL, dret, serr)) == ERR) {
g_error("Swiss Ephemeris error: %s", serr);
} else {
timestamp->priv->julian_day = dret[0];
timestamp->priv->valid_dates |= VALID_JULIAN_DAY;
}
}
void
gswe_timestamp_set_julian_day(GsweTimestamp *timestamp, gdouble julian_day)
{
timestamp->priv->julian_day = julian_day;
timestamp->priv->valid_dates = VALID_JULIAN_DAY;
if (timestamp->priv->instant_recalc == TRUE) {
gswe_timestamp_calculate_all(timestamp);
}
gswe_timestamp_emit_changed(timestamp);
}
gdouble
gswe_timestamp_get_julian_day(GsweTimestamp *timestamp)
{
gswe_timestamp_calculate_julian(timestamp);
return timestamp->priv->julian_day;
}
GQuark
gswe_timestamp_error_quark(void)
{
return g_quark_from_static_string("swe-glib-gswe-timestamp-error");
}
GsweTimestamp *
gswe_timestamp_new(void)
{
return GSWE_TIMESTAMP(g_object_new(GSWE_TYPE_TIMESTAMP, NULL));
}
GsweTimestamp *
gswe_timestamp_new_from_gregorian_full(gint year, gint month, gint day, gint hour, gint minute, gint second, gint microsecond, gdouble time_zone_offset)
{
GsweTimestamp *timestamp = GSWE_TIMESTAMP(g_object_new(GSWE_TYPE_TIMESTAMP,
"gregorian-year", year,
"gregorian-month", month,
"gregorian-day", day,
"gregorian-hour", hour,
"gregorian-minute", minute,
"gregorian-second", second,
"gregorian-microsecond", microsecond,
"gregorian-timezone-offset", time_zone_offset,
NULL));
timestamp->priv->valid_dates = VALID_GREGORIAN;
return timestamp;
}
GsweTimestamp *
gswe_timestamp_new_from_julian_day(gdouble julian_day)
{
GsweTimestamp *timestamp = gswe_timestamp_new();
gswe_timestamp_set_julian_day(timestamp, julian_day);
return timestamp;
}

View File

@ -1,71 +0,0 @@
#ifndef __SWE_GLIB_GSWE_TIMESTAMP_H__
#define __SWE_GLIB_GSWE_TIMESTAMP_H__
#include <glib-object.h>
#define GSWE_TYPE_TIMESTAMP (gswe_timestamp_get_type())
#define GSWE_TIMESTAMP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GSWE_TYPE_TIMESTAMP, GsweTimestamp))
#define GSWE_IS_TIMESTAMP(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GSWE_TYPE_TIMESTAMP))
#define GSWE_TIMESTAMP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GSWE_TYPE_TIMESTAMP, GsweTimestampClass))
#define GSWE_IS_TIMESTAMP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GSWE_TYPE_TIMESTAMP))
#define GSWE_TIMESTAMP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GSWE_TYPE_TIMESTAMP, GsweTimestampClass))
typedef struct _GsweTimestamp GsweTimestamp;
typedef struct _GsweTimestampClass GsweTimestampClass;
typedef struct _GsweTimestampPrivate GsweTimestampPrivate;
#define GSWE_TIMESTAMP_ERROR (gswe_timestamp_error_quark())
GQuark gswe_timestamp_error_quark(void);
typedef enum {
GSWE_TIMESTAMP_ERROR_INVALID_DATE,
GSWE_TIMESTAMP_ERROR_INVALID_TIME
} GsweTimestampError;
struct _GsweTimestamp {
/* Parent instance structure */
GObject parent_instance;
/* Instance members */
/*< private >*/
GsweTimestampPrivate *priv;
};
struct _GsweTimestampClass {
/* Parent class */
GObjectClass parent_class;
/* Class members */
void (*changed)(GsweTimestamp *self);
};
GType gswe_timestamp_get_type(void);
/* Method definitions */
GsweTimestamp *gswe_timestamp_new(void);
GsweTimestamp *gswe_timestamp_new_from_julian_day(gdouble julian_day);
GsweTimestamp * gswe_timestamp_new_from_gregorian_full(gint year, gint month, gint day, gint hour, gint minute, gint second, gint microsecond, gdouble time_zone_offset);
void gswe_timestamp_set_instant_recalc(GsweTimestamp *timestamp, gboolean instant_recalc);
gboolean gswe_timestamp_get_instant_recalc(GsweTimestamp *timestamp);
void gswe_timestamp_set_gregorian_year(GsweTimestamp *timestamp, gint gregorian_year);
gint gswe_timestamp_get_gregorian_year(GsweTimestamp *timestamp);
void gswe_timestamp_set_gregorian_month(GsweTimestamp *timestamp, gint gregorian_month);
gint gswe_timestamp_get_gregorian_month(GsweTimestamp *timestamp);
void gswe_timestamp_set_gregorian_day(GsweTimestamp *timestamp, gint gregorian_day);
gint gswe_timestamp_get_gregorian_day(GsweTimestamp *timestamp);
void gswe_timestamp_set_gregorian_hour(GsweTimestamp *timestamp, gint gregorian_hour);
gint gswe_timestamp_get_gregorian_hour(GsweTimestamp *timestamp);
void gswe_timestamp_set_gregorian_minute(GsweTimestamp *timestamp, gint gregorian_minute);
gint gswe_timestamp_get_gregorian_minute(GsweTimestamp *timestamp);
void gswe_timestamp_set_gregorian_second(GsweTimestamp *timestamp, gint gregorian_second);
gint gswe_timestamp_get_gregorian_second(GsweTimestamp *timestamp);
void gswe_timestamp_set_gregorian_microsecond(GsweTimestamp *timestamp, gint gregorian_microsecond);
gint gswe_timestamp_get_gregorian_microsecond(GsweTimestamp *timestamp);
void gswe_timestamp_set_gregorian_timezone(GsweTimestamp *timestamp, gdouble gregorian_timezone_offset);
gdouble gswe_timestamp_get_gregorian_timezone(GsweTimestamp *timestamp);
void gswe_timestamp_set_julian_day(GsweTimestamp *timestamp, gdouble julian_day);
gdouble gswe_timestamp_get_julian_day(GsweTimestamp *timestamp);
#endif /* __SWE_GLIB_GSWE_TIMESTAMP_H__ */

View File

@ -1,175 +0,0 @@
#ifndef __SWE_GLIB_GSWE_PLANETS_H__
#define __SWE_GLIB_GSWE_PLANETS_H__
#include <glib.h>
typedef enum {
GSWE_PLANET_NONE,
GSWE_PLANET_SUN,
GSWE_PLANET_MOON,
GSWE_PLANET_MERCURY,
GSWE_PLANET_VENUS,
GSWE_PLANET_EARTH,
GSWE_PLANET_MARS,
GSWE_PLANET_JUPITER,
GSWE_PLANET_SATURN,
GSWE_PLANET_URANUS,
GSWE_PLANET_NEPTUNE,
GSWE_PLANET_PLUTO,
GSWE_PLANET_CHIRON,
GSWE_PLANET_CERES,
GSWE_PLANET_PALLAS,
GSWE_PLANET_JUNO,
GSWE_PLANET_VESTA,
GSWE_PLANET_MOON_NODE,
GSWE_PLANET_MOON_APOGEE,
GSWE_PLANET_ASCENDENT,
GSWE_PLANET_MC,
GSWE_PLANET_VERTEX
} GswePlanet;
typedef enum {
GSWE_SIGN_NONE,
GSWE_SIGN_ARIES,
GSWE_SIGN_TAURUS,
GSWE_SIGN_GEMINI,
GSWE_SIGN_CANCER,
GSWE_SIGN_LEO,
GSWE_SIGN_VIRGO,
GSWE_SIGN_LIBRA,
GSWE_SIGN_SCORPIO,
GSWE_SIGN_SAGITTARIUS,
GSWE_SIGN_CAPRICORN,
GSWE_SIGN_AQUARIUS,
GSWE_SIGN_PISCES
} GsweZodiac;
typedef enum {
GSWE_ASPECT_NONE,
GSWE_ASPECT_CONJUCTION,
GSWE_ASPECT_SEXTILE,
GSWE_ASPECT_SQUARE,
GSWE_ASPECT_TRINE,
GSWE_ASPECT_OPPOSITION,
GSWE_ASPECT_SEMISEXTILE,
GSWE_ASPECT_SEMISQUARE,
GSWE_ASPECT_QUINTILE,
GSWE_ASPECT_SESQUISQUARE,
GSWE_ASPECT_BIQUINTILE,
GSWE_ASPECT_QUINCUNX
} GsweAspect;
typedef enum {
GSWE_MIRROR_NONE,
GSWE_MIRROR_ARIES,
GSWE_MIRROR_MID_TAURUS,
GSWE_MIRROR_CANCER,
GSWE_MIRROR_MID_LEO
} GsweMirror;
typedef enum {
GSWE_ELEMENT_NONE,
GSWE_ELEMENT_FIRE,
GSWE_ELEMENT_EARTH,
GSWE_ELEMENT_AIR,
GSWE_ELEMENT_WATER
} GsweElement;
typedef enum {
GSWE_QUALITY_NONE,
GSWE_QUALITY_CARDINAL,
GSWE_QUALITY_FIX,
GSWE_QUALITY_MUTABLE
} GsweQuality;
typedef enum {
GSWE_HOUSE_SYSTEM_NONE,
GSWE_HOUSE_SYSTEM_PLACIDUS,
GSWE_HOUSE_SYSTEM_KOCH,
GSWE_HOUSE_SISTEM_EQUAL
} GsweHouseSystem;
typedef enum {
GSWE_MOON_PHASE_NEW,
GSWE_MOON_PHASE_WAXING_CRESCENT,
GSWE_MOON_PHASE_WAXING_HALF,
GSWE_MOON_PHASE_WAXING_GIBBOUS,
GSWE_MOON_PHASE_FULL,
GSWE_MOON_PHASE_WANING_GIBBOUS,
GSWE_MOON_PHASE_WANING_HALF,
GSWE_MOON_PHASE_WANING_CRESCENT,
GSWE_MOON_PHASE_DARK
} GsweMoonPhase;
/**
* GswePlanetInfo:
* @planet: the planet ID
* @sweph_id: the planet ID according to the Swiss Ephemeris libarary
* (or -1, if the planet has no such ID)
* @real_body: TRUE if the planet is a "real" celestial body on the sky.
* Please note that this will be true for Dark Moon (Lilith).
* Everything that has a planet ID in Swiss Ephemeris is
* treated as a real celestial body.
* @orb: the planet's personal orb
* @name: the planet's name
* @points: the value this planet counts in the element/quality points
* table
* @domicile_sign_1: the first sign in which the planet is domicile
* @domicile_sign_2: the second sign in which the planet is domicile
* @exile_sign_1: the first sign in which the planet is in exile
* @exile_sign_2: the second sign in which the planet is in exile
* @exalted_sign: the sign in which the planet is exalted
* @fall_sign: the sign in which the planet is in fall
*/
typedef struct {
GswePlanet planet;
gint sweph_id;
gboolean real_body;
gdouble orb;
gchar *name;
gint points;
GsweZodiac domicile_sign_1;
GsweZodiac domicile_sign_2;
GsweZodiac exile_sign_1;
GsweZodiac exile_sign_2;
GsweZodiac exalted_sign;
GsweZodiac fall_sign;
} GswePlanetInfo;
typedef struct {
GsweZodiac sign_id;
gchar *name;
GsweElement element;
GsweQuality quality;
} GsweSignInfo;
/**
* GsweHouseSystemInfo:
* @system: the house system's ID
* @sweph_id: the character value that represents this house system in the Swiss Ephemeris library
* @name: the name of this house system
*/
typedef struct {
GsweHouseSystem system;
gchar sweph_id;
gchar *name;
} GsweHouseSystemInfo;
typedef struct {
GsweAspect aspect;
gchar *name;
guint size;
guint orb_modifier;
gboolean harmonic;
gboolean major;
} GsweAspectInfo;
typedef struct {
GsweMirror mirror_id;
GsweSignInfo *start_sign;
gchar *name;
gboolean middle_axis;
} GsweMirrorInfo;
#endif /* __SWE_GLIB_GSWE_PLANETS_H__ */

View File

@ -1,13 +0,0 @@
#ifdef __SWE_GLIB_BUILDING__
#ifndef __SWE_GLIB_PRIVATE_H__
#include "gswe-timestamp.h"
extern gchar *gswe_ephe_path;
extern GsweTimestamp *gswe_full_moon_base_date;
#endif /* __SWE_GLIB_PRIVATE_H__ */
#else /* not defined __SWE_GLIB_BUILDING__ */
#error __FILE__ "Can not be included, unless building SWE-GLib"
#endif /* __SWE_GLIB_BUILDING__ */

View File

@ -1,191 +0,0 @@
#include <glib.h>
#define GETTEXT_PACKAGE "swe-glib"
#include <glib/gi18n-lib.h>
#include "../../swe/src/swephexp.h"
#include "swe-glib.h"
gboolean gswe_initialized = FALSE;
gchar *gswe_ephe_path = NULL;
GHashTable *gswe_planet_info_table;
GHashTable *gswe_sign_info_table;
GHashTable *gswe_house_system_info_table;
GHashTable *gswe_aspect_info_table;
GHashTable *gswe_mirror_info_table;
GsweTimestamp *gswe_full_moon_base_date;
#define ADD_PLANET(ht, v, i, s, r, n, o, h, dom1, dom2, exi1, exi2, exa, fal) (v) = g_new0(GswePlanetInfo, 1); \
(v)->planet = (i); \
(v)->sweph_id = (s); \
(v)->real_body = (r); \
(v)->orb = (o); \
(v)->name = g_strdup(n); \
(v)->points = (h); \
(v)->domicile_sign_1 = (dom1); \
(v)->domicile_sign_2 = (dom2); \
(v)->exile_sign_1 = (exi1); \
(v)->exile_sign_2 = (exi2); \
(v)->exalted_sign = (exa); \
(v)->fall_sign = (fal); \
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v));
#define ADD_SIGN(ht, v, s, n, e, q) (v) = g_new0(GsweSignInfo, 1); \
(v)->sign_id = (s); \
(v)->name = g_strdup(n); \
(v)->element = (e); \
(v)->quality = (q); \
g_hash_table_replace((ht), GINT_TO_POINTER(s), (v));
#define ADD_HOUSE_SYSTEM(ht, v, i, s, n) (v) = g_new0(GsweHouseSystemInfo, 1); \
(v)->system = i; \
(v)->sweph_id = s; \
(v)->name = g_strdup(n); \
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v));
#define ADD_ASPECT(ht, v, i, n, s, o, h, m) (v) = g_new0(GsweAspectInfo, 1); \
(v)->aspect = (i); \
(v)->name = g_strdup(n); \
(v)->size = (s); \
(v)->orb_modifier = (o); \
(v)->harmonic = (h); \
(v)->major = (m); \
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v));
#define ADD_MIRROR(ht, v, hts, vs, i, n, s, m) (v) = g_new0(GsweMirrorInfo, 1); \
(vs) = g_hash_table_lookup((hts), GINT_TO_POINTER(i)); \
(v)->mirror_id = (i); \
(v)->start_sign = (vs); \
(v)->name = g_strdup(n); \
(v)->middle_axis = m; \
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v));
void
gswe_free_planet_info(gpointer planet_info)
{
g_free(((GswePlanetInfo *)planet_info)->name);
g_free(planet_info);
}
void
gswe_free_sign_info(gpointer sign_info)
{
g_free(((GsweSignInfo *)sign_info)->name);
g_free(sign_info);
}
void
gswe_free_house_system_info(gpointer house_system_info)
{
g_free(((GsweHouseSystemInfo *)house_system_info)->name);
g_free(house_system_info);
}
void
gswe_free_aspect_info(gpointer aspect_info)
{
g_free(((GsweAspectInfo *)aspect_info)->name);
g_free(aspect_info);
}
void
gswe_free_mirror_info(gpointer mirror_info)
{
g_free(((GsweMirrorInfo *)mirror_info)->name);
g_free(mirror_info);
}
/**
* gswe_init:
* @sweph_path: the file system path to the Swiss Ephemeris data files
*
* Initializes the SWE-GLib library. It must be called before any calculations
* are made.
*/
void
gswe_init(gchar *sweph_path)
{
GswePlanetInfo *planet_info;
GsweSignInfo *sign_info;
GsweHouseSystemInfo *house_system_info;
GsweAspectInfo *aspect_info;
GsweMirrorInfo *mirror_info;
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
gswe_planet_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, gswe_free_planet_info);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_SUN, SE_SUN, TRUE, _("Sun"), 13.0, 2, GSWE_SIGN_LEO, GSWE_SIGN_NONE, GSWE_SIGN_AQUARIUS, GSWE_SIGN_NONE, GSWE_SIGN_ARIES, GSWE_SIGN_LIBRA);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MOON, SE_MOON, TRUE, _("Moon"), 9.0, 2, GSWE_SIGN_CANCER, GSWE_SIGN_NONE, GSWE_SIGN_CAPRICORN, GSWE_SIGN_NONE, GSWE_SIGN_TAURUS, GSWE_SIGN_SCORPIO);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MERCURY, SE_MERCURY, TRUE, _("Mercury"), 7.0, 2, GSWE_SIGN_GEMINI, GSWE_SIGN_VIRGO, GSWE_SIGN_SAGITTARIUS, GSWE_SIGN_PISCES, GSWE_SIGN_VIRGO, GSWE_SIGN_PISCES);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_VENUS, SE_VENUS, TRUE, _("Venus"), 7.0, 1, GSWE_SIGN_TAURUS, GSWE_SIGN_LIBRA, GSWE_SIGN_SCORPIO, GSWE_SIGN_ARIES, GSWE_SIGN_PISCES, GSWE_SIGN_VIRGO);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MARS, SE_MARS, TRUE, _("Mars"), 7.0, 1, GSWE_SIGN_ARIES, GSWE_SIGN_SCORPIO, GSWE_SIGN_LIBRA, GSWE_SIGN_TAURUS, GSWE_SIGN_CAPRICORN, GSWE_SIGN_CANCER);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_JUPITER, SE_JUPITER, TRUE, _("Jupiter"), 9.0, 1, GSWE_SIGN_SAGITTARIUS, GSWE_SIGN_PISCES, GSWE_SIGN_GEMINI, GSWE_SIGN_VIRGO, GSWE_SIGN_CANCER, GSWE_SIGN_CAPRICORN);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_SATURN, SE_SATURN, TRUE, _("Saturn"), 7.0, 1, GSWE_SIGN_CAPRICORN, GSWE_SIGN_AQUARIUS, GSWE_SIGN_CANCER, GSWE_SIGN_LEO, GSWE_SIGN_LIBRA, GSWE_SIGN_ARIES);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_URANUS, SE_URANUS, TRUE, _("Uranus"), 5.0, 1, GSWE_SIGN_AQUARIUS, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_NEPTUNE, SE_NEPTUNE, TRUE, _("Neptune"), 5.0, 1, GSWE_SIGN_PISCES, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_PLUTO, SE_PLUTO, TRUE, _("Pluto"), 3.0, 1, GSWE_SIGN_SCORPIO, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_CHIRON, SE_CHIRON, TRUE, _("Chiron"), 2.0, 0, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_CERES, SE_CERES, TRUE, _("Ceres"), 2.0, 0, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_PALLAS, SE_PALLAS, TRUE, _("Pallas"), 2.0, 0, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_JUNO, SE_JUNO, TRUE, _("Juno"), 2.0, 0, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_VESTA, SE_VESTA, TRUE, _("Vesta"), 2.0, 0, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MOON_NODE, SE_MEAN_NODE, TRUE, _("Ascending Moon Node"), 2.0, 1, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MOON_APOGEE, SE_MEAN_APOG, TRUE, _("Dark Moon"), 2.0, 0, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_ASCENDENT, -1, FALSE, _("Ascendent"), 9.0, 2, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_MC, -1, FALSE, _("Midheaven"), 5.0, 1, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
ADD_PLANET(gswe_planet_info_table, planet_info, GSWE_PLANET_VERTEX, -1, FALSE, _("Vertex"), 2.0, 0, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE, GSWE_SIGN_NONE);
gswe_sign_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, gswe_free_sign_info);
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_ARIES, _("Aries"), GSWE_ELEMENT_FIRE, GSWE_QUALITY_CARDINAL);
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_TAURUS, _("Taurus"), GSWE_ELEMENT_EARTH, GSWE_QUALITY_FIX);
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_GEMINI, _("Gemini"), GSWE_ELEMENT_AIR, GSWE_QUALITY_MUTABLE);
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_CANCER, _("Cancer"), GSWE_ELEMENT_WATER, GSWE_QUALITY_CARDINAL);
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_LEO, _("Leo"), GSWE_ELEMENT_FIRE, GSWE_QUALITY_FIX);
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_VIRGO, _("Virgo"), GSWE_ELEMENT_EARTH, GSWE_QUALITY_MUTABLE);
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_LIBRA, _("Libra"), GSWE_ELEMENT_AIR, GSWE_QUALITY_CARDINAL);
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_SCORPIO, _("Scorpio"), GSWE_ELEMENT_WATER, GSWE_QUALITY_FIX);
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_SAGITTARIUS, _("Sagittarius"), GSWE_ELEMENT_FIRE, GSWE_QUALITY_MUTABLE);
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_CAPRICORN, _("Capricorn"), GSWE_ELEMENT_EARTH, GSWE_QUALITY_CARDINAL);
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_AQUARIUS, _("Aquarius"), GSWE_ELEMENT_AIR, GSWE_QUALITY_FIX);
ADD_SIGN(gswe_sign_info_table, sign_info, GSWE_SIGN_PISCES, _("Pisces"), GSWE_ELEMENT_WATER, GSWE_QUALITY_MUTABLE);
gswe_house_system_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, gswe_free_house_system_info);
ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_NONE, 0, _("None"));
ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_PLACIDUS, 'P', _("Placidus"));
ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SYSTEM_KOCH, 'K', _("Koch"));
ADD_HOUSE_SYSTEM(gswe_house_system_info_table, house_system_info, GSWE_HOUSE_SISTEM_EQUAL, 'E', _("Equal"));
gswe_aspect_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, gswe_free_aspect_info);
// Note that because all aspects must be <= 180°, GSWE_ASPECT_NONE can
// never really exist. It is provided for name fetching purposes only.
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_NONE, _("None"), 360, 4, FALSE, FALSE);
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_CONJUCTION, _("Conjuction"), 0, 0, TRUE, TRUE);
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_OPPOSITION, _("Opposition"), 180, 0, TRUE, TRUE);
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_TRINE, _("Trine"), 120, 0, TRUE, TRUE);
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_SQUARE, _("Square"), 90, 0, FALSE, TRUE);
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_SEXTILE, _("Sextile"), 60, 1, TRUE, TRUE);
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_QUINCUNX, _("Quincunx"), 150, 2, FALSE, FALSE);
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_SEMISEXTILE, _("Semi-sextile"), 30, 2, TRUE, FALSE);
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_SEMISQUARE, _("Semi-square"), 45, 2, FALSE, FALSE);
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_SESQUISQUARE, _("Sesqui-square"), 135, 2, FALSE, FALSE);
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_QUINTILE, _("Quintile"), 72, 3, TRUE, FALSE);
ADD_ASPECT(gswe_aspect_info_table, aspect_info, GSWE_ASPECT_BIQUINTILE, _("Bi-quintile"), 144, 3, TRUE, FALSE);
gswe_mirror_info_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, gswe_free_mirror_info);
ADD_MIRROR(gswe_mirror_info_table, mirror_info, gswe_sign_info_table, sign_info, GSWE_MIRROR_NONE, _("None"), GSWE_SIGN_NONE, FALSE);
ADD_MIRROR(gswe_mirror_info_table, mirror_info, gswe_sign_info_table, sign_info, GSWE_MIRROR_ARIES, _("Aries/Libra"), GSWE_SIGN_ARIES, FALSE);
ADD_MIRROR(gswe_mirror_info_table, mirror_info, gswe_sign_info_table, sign_info, GSWE_MIRROR_MID_TAURUS, _("mid Taurus/Scorpio"), GSWE_SIGN_TAURUS, TRUE);
ADD_MIRROR(gswe_mirror_info_table, mirror_info, gswe_sign_info_table, sign_info, GSWE_MIRROR_CANCER, _("Cancer/Capricorn"), GSWE_SIGN_CANCER, FALSE);
ADD_MIRROR(gswe_mirror_info_table, mirror_info, gswe_sign_info_table, sign_info, GSWE_MIRROR_MID_LEO, _("mid Leo/Aquarius"), GSWE_SIGN_LEO, TRUE);
gswe_full_moon_base_date = gswe_timestamp_new_from_gregorian_full(2005, 5, 8, 3, 48, 0, 0, 0.0);
gswe_ephe_path = g_strdup(sweph_path);
swe_set_ephe_path(sweph_path);
gswe_initialized = TRUE;
}

View File

@ -1,18 +0,0 @@
#ifndef __SWE_GLIB_H__
#define __SWE_GLIB_H__
#include <glib.h>
#include "gswe-types.h"
#include "gswe-timestamp.h"
#include "gswe-moment.h"
extern GHashTable *gswe_planet_info_table;
extern GHashTable *gswe_sign_info_table;
extern GHashTable *gswe_house_system_info_table;
extern GHashTable *gswe_aspect_info_table;
extern GHashTable *gswe_mirror_info_table;
void gswe_init(gchar *sweph_path);
#endif /* __SWE_GLIB_H__ */

View File

@ -1,6 +0,0 @@
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)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -1,54 +0,0 @@
/* 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.
*/

View File

@ -1,4 +0,0 @@
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)

View File

@ -1,6 +0,0 @@
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.

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +0,0 @@
# 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

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +0,0 @@
# 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

View File

@ -1,78 +0,0 @@
# 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

File diff suppressed because it is too large Load Diff

View File

@ -1,611 +0,0 @@
/*********************************************************
$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);
}

View File

@ -1,85 +0,0 @@
/*********************************************************
$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

View File

@ -1,618 +0,0 @@
/* 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 /* */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,87 +0,0 @@
/*******************************************************
$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)

View File

@ -1,976 +0,0 @@
/*
| $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 */

View File

@ -1,108 +0,0 @@
/*
| $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);

View File

@ -1,131 +0,0 @@
/*
$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;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,974 +0,0 @@
/* 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 */
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,327 +0,0 @@
/************************************************************
$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 */

View File

@ -1,933 +0,0 @@
/*****************************************************
$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

View File

@ -1,464 +0,0 @@
/************************************************************
$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 */

View File

@ -1,249 +0,0 @@
/*****************************************************
$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 */

Some files were not shown because too many files have changed in this diff Show More