Now doing all calculations through SWE-GLib

This commit is contained in:
Gergely Polonkai 2013-09-03 13:14:28 +02:00
parent c30c3fd9ac
commit 1e4b769314
4 changed files with 151 additions and 578 deletions

View File

@ -1,6 +1,6 @@
bin_PROGRAMS = astrognome
astrognome_SOURCES = astrognome.c calculate.c
astrognome_SOURCES = astrognome.c
astrognome_LDADD = $(LIBSWE_LIBS) $(LIBSWE_GLIB_LIBS) $(GTK_LIBS)
astrognome_LDFLAGS = -rdynamic
astrognome_CFLAGS = $(CFLAGS) $(GTK_CFLAGS) -Wall

View File

@ -1,24 +1,9 @@
#include <glib.h>
#include "calculate.h"
#include "../swe/src/swephexp.h"
#include "../swe-glib/src/swe-glib.h"
#define EPHEDIR "/home/polesz/Projektek/c/astrognome/swe/data"
typedef struct {
int planetId;
gchar *name;
gdouble orb;
zodiacSign domicile1,
domicile2,
exile1,
exile2,
exalted,
fall;
} planetData_t;
const char *moonStateName[] = {
"New Moon",
"Waxing Crescent Moon",
@ -31,230 +16,12 @@ const char *moonStateName[] = {
"Dark Moon"
};
typedef struct {
gchar *name;
guint size;
guint orbModifier;
gboolean harmonic;
gboolean major;
} aspectData_t;
typedef struct {
gchar *name;
zodiacSign startSign;
gboolean middleAxis;
} mirrorpointData_t;
const aspectData_t aspectData[] = {
// Name Size Orb Harmonic Major
{ "Conjuction", 0, 0, TRUE, TRUE },
{ "Opposition", 180, 0, TRUE, TRUE },
{ "Trine", 120, 0, TRUE, TRUE },
{ "Square", 90, 0, FALSE, TRUE },
{ "Sextile", 60, 1, TRUE, TRUE },
{ "Quincunx", 150, 2, FALSE, FALSE },
{ "Semi-sextile", 30, 2, TRUE, FALSE },
{ "Semi-square", 45, 2, FALSE, FALSE },
{ "Sesqui-square", 135, 2, FALSE, FALSE },
{ "Quintile", 72, 3, TRUE, FALSE },
{ "Bi-quintile", 144, 3, TRUE, FALSE }
};
const mirrorpointData_t mirrorpointData[] = {
{ "Aries/Libra", SIGN_ARIES, FALSE },
{ "mid Taurus/Scoripo", SIGN_TAURUS, TRUE },
{ "Cancer/Capricorn", SIGN_CANCER, FALSE },
{ "mid Leo/Aquarius", SIGN_LEO, TRUE },
};
#define ADD_PLANET(ht, v, i, n, o, dom1, dom2, exi1, exi2, exa, fal) (v) = g_new0(planetData_t, 1); \
(v)->planetId = (i); \
(v)->name = g_strdup(n); \
(v)->orb = (o); \
(v)->domicile1 = (dom1); \
(v)->domicile2 = (dom2); \
(v)->exile1 = (exi1); \
(v)->exile2 = (exi2); \
(v)->exalted = (exa); \
(v)->fall = (fal); \
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v));
struct aspect_check_data {
GList *planetIdList;
guint currentOuterPlanetId;
guint currentInnerPlanetId;
GHashTable *planetInfoTable;
GHashTable *planetDataTable;
};
void
check_aspects_inner_loop(gpointer data, gpointer user_data)
{
struct aspect_check_data *checkData = user_data;
gint outerPlanetId = GPOINTER_TO_INT(g_list_nth_data(checkData->planetIdList, checkData->currentOuterPlanetId));
gint innerPlanetId = GPOINTER_TO_INT(g_list_nth_data(checkData->planetIdList, checkData->currentInnerPlanetId));
planetInfo_t *outerPlanet,
*innerPlanet;
planetData_t *outerPlanetData,
*innerPlanetData;
gdouble planetOrb,
distance,
difference;
gint i;
const aspectData_t *aspect = NULL;
if (outerPlanetId == innerPlanetId) {
checkData->currentInnerPlanetId++;
return;
}
outerPlanet = g_hash_table_lookup(checkData->planetInfoTable, GINT_TO_POINTER(outerPlanetId));
innerPlanet = g_hash_table_lookup(checkData->planetInfoTable, GINT_TO_POINTER(innerPlanetId));
g_assert(outerPlanet != NULL);
g_assert(innerPlanet != NULL);
outerPlanetData = g_hash_table_lookup(checkData->planetDataTable, GINT_TO_POINTER(outerPlanetId));
innerPlanetData = g_hash_table_lookup(checkData->planetDataTable, GINT_TO_POINTER(innerPlanetId));
g_assert(outerPlanetData != NULL);
g_assert(innerPlanetData != NULL);
planetOrb = fmin(outerPlanetData->orb, innerPlanetData->orb);
distance = fabs(outerPlanet->position - innerPlanet->position);
if (distance > 180.0) {
distance = 360.0 - distance;
}
for (i = 0; i < sizeof(aspectData) / sizeof(aspectData_t); i++) {
gdouble diff = fabs(aspectData[i].size - distance);
gdouble aspectOrb = fmax(1.0, planetOrb - aspectData[i].orbModifier);
if (diff <= aspectOrb) {
aspect = &(aspectData[i]);
if (aspectData[i].size == 0) {
difference = (1 - ((360.0 - diff) / 360.0)) * 100.0;
} else {
difference = (1 - ((aspectData[i].size - diff) / aspectData[i].size)) * 100.0;
}
break;
}
}
if (aspect != NULL) {
printf("%s vs. %s: %s (±%f%%)\n", outerPlanetData->name, innerPlanetData->name, aspect->name, difference);
}
checkData->currentInnerPlanetId++;
}
void
check_aspects_outer_loop(gpointer data, gpointer user_data)
{
struct aspect_check_data *checkData = user_data;
checkData->currentInnerPlanetId = checkData->currentOuterPlanetId;
printf("\n");
g_list_foreach(g_list_nth(checkData->planetIdList, checkData->currentOuterPlanetId), check_aspects_inner_loop, user_data);
checkData->currentOuterPlanetId++;
}
void
check_mirrorpoints_inner_loop(gpointer data, gpointer user_data)
{
struct aspect_check_data *checkData = user_data;
gint outerPlanetId = GPOINTER_TO_INT(g_list_nth_data(checkData->planetIdList, checkData->currentOuterPlanetId));
gint innerPlanetId = GPOINTER_TO_INT(g_list_nth_data(checkData->planetIdList, checkData->currentInnerPlanetId));
planetInfo_t *outerPlanet,
*innerPlanet;
planetData_t *outerPlanetData,
*innerPlanetData;
gdouble planetOrb,
difference;
gint i;
const mirrorpointData_t *mirrorpoint = NULL;
if (outerPlanetId == innerPlanetId) {
checkData->currentInnerPlanetId++;
return;
}
outerPlanet = g_hash_table_lookup(checkData->planetInfoTable, GINT_TO_POINTER(outerPlanetId));
innerPlanet = g_hash_table_lookup(checkData->planetInfoTable, GINT_TO_POINTER(innerPlanetId));
g_assert(outerPlanet != NULL);
g_assert(innerPlanet != NULL);
outerPlanetData = g_hash_table_lookup(checkData->planetDataTable, GINT_TO_POINTER(outerPlanetId));
innerPlanetData = g_hash_table_lookup(checkData->planetDataTable, GINT_TO_POINTER(innerPlanetId));
g_assert(outerPlanetData != NULL);
g_assert(innerPlanetData != NULL);
planetOrb = fmin(outerPlanetData->orb, innerPlanetData->orb);
for (i = 0; i < sizeof(mirrorpointData) / sizeof(mirrorpointData_t); i++) {
gdouble mirrorPosition;
gdouble startPoint = (mirrorpointData[i].startSign - 1) * 30;
if (mirrorpointData[i].middleAxis == TRUE) {
startPoint += 15.0;
}
mirrorPosition = 2 * startPoint - outerPlanet->position;
if (mirrorPosition < 0) {
mirrorPosition += 360.0;
}
if ((difference = fabs(innerPlanet->position - mirrorPosition)) <= planetOrb) {
mirrorpoint = &(mirrorpointData[i]);
break;
}
}
if (mirrorpoint != NULL) {
printf("%s vs. %s: %s (±%f)\n", outerPlanetData->name, innerPlanetData->name, mirrorpoint->name, difference);
}
checkData->currentInnerPlanetId++;
}
void
check_mirrorpoints_outer_loop(gpointer data, gpointer user_data)
{
struct aspect_check_data *checkData = user_data;
checkData->currentInnerPlanetId = checkData->currentOuterPlanetId;
printf("\n");
g_list_foreach(g_list_nth(checkData->planetIdList, checkData->currentOuterPlanetId), check_mirrorpoints_inner_loop, user_data);
checkData->currentOuterPlanetId++;
}
void
free_planet_data(gpointer data)
{
planetData_t *planetData = data;
g_free(planetData->name);
g_free(planetData);
}
void
print_house_cusp(gpointer data, gpointer user_data)
{
GsweHouseData *house_data = data;
printf("House %2d..: %s (%f)\n", house_data->house, house_data->sign->name, house_data->cusp_position);
g_print("House %2d..: %s (%f)\n", house_data->house, house_data->sign->name, house_data->cusp_position);
}
void
@ -264,7 +31,18 @@ print_aspects(GsweAspectData *aspect_data, gpointer user_data)
GswePlanetData *other_planet = (aspect_data->planet1->planet_id == planet) ? aspect_data->planet2 : aspect_data->planet1;
if (aspect_data->aspect != GSWE_ASPECT_NONE) {
printf(" %s: %s (±%f%%)\n", other_planet->planet_info->name, aspect_data->aspect_info->name, aspect_data->difference);
g_print(" %s: %s (±%f%%)\n", other_planet->planet_info->name, aspect_data->aspect_info->name, aspect_data->difference);
}
}
void
print_mirrorpoints(GsweMirrorData *mirror_data, gpointer user_data)
{
GswePlanet planet = GPOINTER_TO_INT(user_data);
GswePlanetData *other_planet = (mirror_data->planet1->planet_id == planet) ? mirror_data->planet2 : mirror_data->planet1;
if (mirror_data->mirror != GSWE_MIRROR_NONE) {
g_print(" %s: %s (±%f°)\n", other_planet->planet_info->name, mirror_data->mirror_info->name, mirror_data->difference);
}
}
@ -277,24 +55,15 @@ main(int argc, char *argv[])
hour = 23,
min = 39,
sec = 34;
double timezone = 1.0,
lon = 20.766666,
double lon = 20.766666,
lat = 48.2,
alt = 200,
te,
cusps[13],
ascmc[10];
planetInfo_t *planetInfo;
alt = 200;
GsweMoonPhaseData *moon_phase;
GHashTable *planetDataTable,
*planetInfoTable;
planetData_t *planetData;
GList *planetIdList;
struct aspect_check_data aspectCheckData;
GsweTimestamp *timestamp;
GsweMoment *moment;
GswePlanetData *planet_data;
GList *aspects;
GList *aspects,
*mirrorpoints;
#if 1
year = 1983;
@ -307,331 +76,314 @@ main(int argc, char *argv[])
lat = 47.462485;
#endif
planetDataTable = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, free_planet_data);
planetInfoTable = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
// Initialize planet data table
ADD_PLANET(planetDataTable, planetData, SE_SUN, "Sun", 13.0, SIGN_LEO, SIGN_NONE, SIGN_AQUARIUS, SIGN_NONE, SIGN_ARIES, SIGN_LIBRA);
ADD_PLANET(planetDataTable, planetData, SE_MOON, "Moon", 9.0, SIGN_CANCER, SIGN_NONE, SIGN_CAPRICORN, SIGN_NONE, SIGN_TAURUS, SIGN_SCORPIO);
ADD_PLANET(planetDataTable, planetData, SE_MERCURY, "Mercury", 7.0, SIGN_GEMINI, SIGN_VIRGO, SIGN_SAGITTARIUS, SIGN_PISCES, SIGN_VIRGO, SIGN_PISCES);
ADD_PLANET(planetDataTable, planetData, SE_VENUS, "Venus", 7.0, SIGN_TAURUS, SIGN_LIBRA, SIGN_SCORPIO, SIGN_ARIES, SIGN_PISCES, SIGN_VIRGO);
ADD_PLANET(planetDataTable, planetData, SE_MARS, "Mars", 7.0, SIGN_ARIES, SIGN_SCORPIO, SIGN_LIBRA, SIGN_TAURUS, SIGN_CAPRICORN, SIGN_CANCER);
ADD_PLANET(planetDataTable, planetData, SE_JUPITER, "Jupiter", 9.0, SIGN_SAGITTARIUS, SIGN_PISCES, SIGN_GEMINI, SIGN_VIRGO, SIGN_CANCER, SIGN_CAPRICORN);
ADD_PLANET(planetDataTable, planetData, SE_SATURN, "Saturn", 7.0, SIGN_CAPRICORN, SIGN_AQUARIUS, SIGN_CANCER, SIGN_LEO, SIGN_LIBRA, SIGN_ARIES);
ADD_PLANET(planetDataTable, planetData, SE_URANUS, "Uranus", 5.0, SIGN_AQUARIUS, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE);
ADD_PLANET(planetDataTable, planetData, SE_NEPTUNE, "Neptune", 5.0, SIGN_PISCES, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE);
ADD_PLANET(planetDataTable, planetData, SE_PLUTO, "Pluto", 3.0, SIGN_SCORPIO, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE);
ADD_PLANET(planetDataTable, planetData, SE_CHIRON, "Chiron", 2.0, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE);
ADD_PLANET(planetDataTable, planetData, SE_MEAN_NODE, "Ascending Moon Node", 2.0, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE);
ADD_PLANET(planetDataTable, planetData, SE_MEAN_APOG, "Dark Moon", 2.0, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE);
ADD_PLANET(planetDataTable, planetData, SE_CERES, "Ceres", 2.0, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE);
ADD_PLANET(planetDataTable, planetData, SE_PALLAS, "Pallas", 2.0, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE);
ADD_PLANET(planetDataTable, planetData, SE_JUNO, "Juno", 2.0, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE);
ADD_PLANET(planetDataTable, planetData, SE_VESTA, "Vesta", 2.0, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE);
ADD_PLANET(planetDataTable, planetData, SE_NPLANETS + SE_ASC, "Ascendent", 9.0, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE);
ADD_PLANET(planetDataTable, planetData, SE_NPLANETS + SE_MC, "Midheaven", 5.0, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE);
ADD_PLANET(planetDataTable, planetData, SE_NPLANETS + SE_VERTEX, "Vertex", 2.0, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE, SIGN_NONE);
gswe_init(EPHEDIR);
timestamp = gswe_timestamp_new_from_gregorian_full(year, month, day, hour, min, sec, 0, 1.0);
moment = gswe_moment_new_full(timestamp, lon, lat, alt, GSWE_HOUSE_SYSTEM_PLACIDUS);
gswe_moment_add_all_planets(moment);
if (set_location_and_time(lon, lat, alt, year, month, day, hour, min, sec, timezone, &te) == 0) {
return 1;
}
g_print("Date: %02d.%02d.%d at %02d:%02d:%02d, at %f, %f\n", year, month, day, hour, min, sec, lon, lat);
printf("Date: %02d.%02d.%d at %02d:%02d:%02d, at %f, %f\n", year, month, day, hour, min, sec, lon, lat);
printf("\nHOUSES\n======\n\n");
swe_houses(te, lat, lon, 'P', cusps, ascmc);
g_print("\nHOUSES\n======\n\n");
g_list_foreach(gswe_moment_get_house_cusps(moment), print_house_cusp, NULL);
printf("\nPLANETS AND POINTS\n==================\n\n");
g_print("\nPLANETS AND POINTS\n==================\n\n");
// Ascendent
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_ASCENDENT);
printf("%s: %s (%f)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->position);
g_print("%s: %s (%f)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->position);
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_ASCENDENT);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_ASCENDENT));
g_list_free(aspects);
planetInfo = g_new0(planetInfo_t, 1);
planetInfo->position = planet_data->position;
planetInfo->sign = planet_data->sign->sign_id;
planetInfo->house = 1;
planetInfo->retrograde = FALSE;
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_NPLANETS + SE_ASC), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_ASCENDENT);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_ASCENDENT));
g_list_free(mirrorpoints);
// Midheaven
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_MC);
printf("%s: %s (%f)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->position);
g_print("%s: %s (%f)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->position);
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_MC);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_MC));
g_list_free(aspects);
planetInfo = g_new0(planetInfo_t, 1);
planetInfo->position = planet_data->position;
planetInfo->sign = planet_data->sign->sign_id;
planetInfo->house = 10;
planetInfo->retrograde = FALSE;
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_NPLANETS + SE_MC), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_MC);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_MC));
g_list_free(mirrorpoints);
// Vertex
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_VERTEX);
printf("%s: %s (%f)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->position);
g_print("%s: %s (%f)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->position);
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_VERTEX);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_VERTEX));
g_list_free(aspects);
planetInfo = g_new0(planetInfo_t, 1);
planetInfo->position = planet_data->position;
planetInfo->sign = planet_data->sign->sign_id;
planetInfo->house = planet_data->house;
planetInfo->retrograde = FALSE;
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_NPLANETS + SE_VERTEX), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_VERTEX);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_VERTEX));
g_list_free(mirrorpoints);
// Sun
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_SUN);
printf("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_SUN);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_SUN));
g_list_free(aspects);
planetInfo = get_planet_info(SE_SUN, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_SUN), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_SUN);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_SUN));
g_list_free(mirrorpoints);
// Moon
moon_phase = gswe_moment_get_moon_phase(moment);
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_MOON);
printf("%s: %s (%.2f%% visibility), %s, House: %d (%f%s)\n", planet_data->planet_info->name, moonStateName[moon_phase->phase], moon_phase->illumination, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s (%.2f%% visibility), %s, House: %d (%f%s)\n", planet_data->planet_info->name, moonStateName[moon_phase->phase], moon_phase->illumination, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_MOON);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_MOON));
g_list_free(aspects);
planetInfo = get_planet_info(SE_MOON, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_MOON), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_MOON);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_MOON));
g_list_free(mirrorpoints);
// Mercury
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_MERCURY);
printf("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_MERCURY);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_MERCURY));
g_list_free(aspects);
planetInfo = get_planet_info(SE_MERCURY, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_MERCURY), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_MERCURY);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_MERCURY));
g_list_free(mirrorpoints);
// Venus
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_VENUS);
printf("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_VENUS);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_VENUS));
g_list_free(aspects);
planetInfo = get_planet_info (SE_VENUS, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_VENUS), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_VENUS);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_VENUS));
g_list_free(mirrorpoints);
// Mars
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_MARS);
printf("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_MARS);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_MARS));
g_list_free(aspects);
planetInfo = get_planet_info(SE_MARS, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_MARS), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_MARS);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_MARS));
g_list_free(mirrorpoints);
// Jupiter
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_JUPITER);
printf("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_JUPITER);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_JUPITER));
g_list_free(aspects);
planetInfo = get_planet_info(SE_JUPITER, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_JUPITER), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_JUPITER);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_JUPITER));
g_list_free(mirrorpoints);
// Saturn
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_SATURN);
printf("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_SATURN);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_SATURN));
g_list_free(aspects);
planetInfo = get_planet_info(SE_SATURN, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_SATURN), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_SATURN);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_SATURN));
g_list_free(mirrorpoints);
// Uranus
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_URANUS);
printf("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_URANUS);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_URANUS));
g_list_free(aspects);
planetInfo = get_planet_info(SE_URANUS, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_URANUS), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_URANUS);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_URANUS));
g_list_free(mirrorpoints);
// Neptune
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_NEPTUNE);
printf("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_NEPTUNE);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_NEPTUNE));
g_list_free(aspects);
planetInfo = get_planet_info(SE_NEPTUNE, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_NEPTUNE), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_NEPTUNE);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_NEPTUNE));
g_list_free(mirrorpoints);
// Pluto
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_PLUTO);
printf("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_PLUTO);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_PLUTO));
g_list_free(aspects);
planetInfo = get_planet_info(SE_PLUTO, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_PLUTO), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_PLUTO);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_PLUTO));
g_list_free(mirrorpoints);
// Mean node
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_MOON_NODE);
printf("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_MOON_NODE);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_MOON_NODE));
g_list_free(aspects);
planetInfo = get_planet_info(SE_MEAN_NODE, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_MEAN_NODE), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_MOON_NODE);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_MOON_NODE));
g_list_free(mirrorpoints);
// Mean apogee
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_MOON_APOGEE);
printf("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_MOON_APOGEE);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_MOON_APOGEE));
g_list_free(aspects);
planetInfo = get_planet_info(SE_MEAN_APOG, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_MEAN_APOG), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_MOON_APOGEE);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_MOON_APOGEE));
g_list_free(mirrorpoints);
// Chiron
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_CHIRON);
printf("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_CHIRON);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_CHIRON));
g_list_free(aspects);
planetInfo = get_planet_info(SE_CHIRON, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_CHIRON), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_CHIRON);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_CHIRON));
g_list_free(mirrorpoints);
// Ceres
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_CERES);
printf("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_CERES);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_CERES));
g_list_free(aspects);
planetInfo = get_planet_info(SE_CERES, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_CERES), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_CERES);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_CERES));
g_list_free(mirrorpoints);
// Pallas
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_PALLAS);
printf("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_PALLAS);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_PALLAS));
g_list_free(aspects);
planetInfo = get_planet_info(SE_PALLAS, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_PALLAS), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_PALLAS);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_PALLAS));
g_list_free(mirrorpoints);
// Juno
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_JUNO);
printf("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_JUNO);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_JUNO));
g_list_free(aspects);
planetInfo = get_planet_info(SE_JUNO, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_JUNO), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_JUNO);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_JUNO));
g_list_free(mirrorpoints);
// Vesta
planet_data = gswe_moment_get_planet(moment, GSWE_PLANET_VESTA);
printf("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
g_print("%s: %s, House: %d (%f%s)\n", planet_data->planet_info->name, planet_data->sign->name, planet_data->house, planet_data->position, (planet_data->retrograde) ? ", retrograde" : "");
aspects = gswe_moment_get_planet_aspects(moment, GSWE_PLANET_VESTA);
printf(" Aspects:\n");
g_print(" Aspects:\n");
g_list_foreach(aspects, (GFunc)print_aspects, GINT_TO_POINTER(GSWE_PLANET_VESTA));
g_list_free(aspects);
planetInfo = get_planet_info(SE_VESTA, te, cusps);
g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_VESTA), planetInfo);
mirrorpoints = gswe_moment_get_all_planet_mirrorpoints(moment, GSWE_PLANET_VESTA);
g_print(" Antiscia:\n");
g_list_foreach(mirrorpoints, (GFunc)print_mirrorpoints, GINT_TO_POINTER(GSWE_PLANET_VESTA));
g_list_free(mirrorpoints);
printf("\nELEMENTS\n========\n\n");
g_print("\nELEMENTS\n========\n\n");
printf("Fire: %d\n", gswe_moment_get_element_points(moment, GSWE_ELEMENT_FIRE));
printf("Earth: %d\n", gswe_moment_get_element_points(moment, GSWE_ELEMENT_EARTH));
printf("Air: %d\n", gswe_moment_get_element_points(moment, GSWE_ELEMENT_AIR));
printf("Water: %d\n", gswe_moment_get_element_points(moment, GSWE_ELEMENT_WATER));
g_print("Fire: %d\n", gswe_moment_get_element_points(moment, GSWE_ELEMENT_FIRE));
g_print("Earth: %d\n", gswe_moment_get_element_points(moment, GSWE_ELEMENT_EARTH));
g_print("Air: %d\n", gswe_moment_get_element_points(moment, GSWE_ELEMENT_AIR));
g_print("Water: %d\n", gswe_moment_get_element_points(moment, GSWE_ELEMENT_WATER));
printf("\nQUALITIES\n=========\n\n");
g_print("\nQUALITIES\n=========\n\n");
printf("Cardinal: %d\n", gswe_moment_get_quality_points(moment, GSWE_QUALITY_CARDINAL));
printf("Fix: %d\n", gswe_moment_get_quality_points(moment, GSWE_QUALITY_FIX));
printf("Mutable: %d\n", gswe_moment_get_quality_points(moment, GSWE_QUALITY_MUTABLE));
g_print("Cardinal: %d\n", gswe_moment_get_quality_points(moment, GSWE_QUALITY_CARDINAL));
g_print("Fix: %d\n", gswe_moment_get_quality_points(moment, GSWE_QUALITY_FIX));
g_print("Mutable: %d\n", gswe_moment_get_quality_points(moment, GSWE_QUALITY_MUTABLE));
printf("\nANTISCIA\n========\n\n");
planetIdList = g_hash_table_get_keys(planetInfoTable);
aspectCheckData.planetIdList = planetIdList;
aspectCheckData.currentOuterPlanetId = 0;
aspectCheckData.planetInfoTable = planetInfoTable;
aspectCheckData.planetDataTable = planetDataTable;
g_list_foreach(planetIdList, check_mirrorpoints_outer_loop, &aspectCheckData);
g_list_free(planetIdList);
g_hash_table_unref(planetInfoTable);
g_hash_table_unref(planetDataTable);
return OK;
return 0;
}

View File

@ -1,126 +0,0 @@
#include <glib.h>
#include "calculate.h"
/**
* SECTION:calculate
* @short_description: functions for astronomical calculations
* @title: Astronomical calculation functions
* @section_id:
* @include: calculate.h
*
* These functions are for astronomical calculations. They are deprecated by SWE-GLib on the long run
*/
const signTypePair_t signType[] = {
{ 0, 0, 0, 0, 0, 0, 0 },
// Type Element Dominating planet Detriment planet Fall planet
// Domicile planet Exalted planet
{ TYPE_CARDINAL, ELEMENT_FIRE, SE_MARS, SE_MARS, SE_VENUS, SE_SUN, SE_SATURN }, // Aries
{ TYPE_FIX, ELEMENT_EARTH, SE_VENUS, SE_VENUS, SE_MARS, SE_MOON, 0 }, // Taurus
{ TYPE_MUTABLE, ELEMENT_AIR, SE_MERCURY, SE_MERCURY, SE_JUPITER, 0, 0 }, // Gemini
{ TYPE_CARDINAL, ELEMENT_WATER, SE_MOON, SE_MOON, SE_SATURN, SE_JUPITER, SE_MARS }, // Cancer
{ TYPE_FIX, ELEMENT_FIRE, SE_SUN, SE_SUN, SE_SATURN, 0, 0 }, // Leo
{ TYPE_MUTABLE, ELEMENT_EARTH, SE_MERCURY, SE_MERCURY, SE_JUPITER, SE_MERCURY, SE_VENUS }, // Virgo
{ TYPE_CARDINAL, ELEMENT_AIR, SE_VENUS, SE_VENUS, SE_MARS, SE_SATURN, SE_SUN }, // Libra
{ TYPE_FIX, ELEMENT_WATER, SE_PLUTO, SE_MARS, SE_VENUS, 0, SE_MOON }, // Scorpio
{ TYPE_MUTABLE, ELEMENT_FIRE, SE_JUPITER, SE_JUPITER, SE_MERCURY, 0, 0 }, // Sagittarius
{ TYPE_CARDINAL, ELEMENT_EARTH, SE_SATURN, SE_SATURN, SE_MOON, SE_MARS, SE_JUPITER }, // Capricorn
{ TYPE_FIX, ELEMENT_AIR, SE_URANUS, SE_SATURN, SE_SUN, 0, 0 }, // Aquarius
{ TYPE_MUTABLE, ELEMENT_WATER, SE_NEPTUNE, SE_JUPITER, SE_MERCURY, SE_VENUS, SE_MERCURY }, // Pisces
};
/**
* get_house:
* @position: the latitude position of the celestial body on the sky
* @cusps: an array of gdoubles, which contains the position of the house
* cusps. MUST contain 12 gdouble values!
*
* Calculates in which house the given position is.
*
* Returns: the number of the house in which the given position is
*/
guint
get_house(gdouble position, gdouble cusps[])
{
guint i,
house = 0;
for (i = 1; i < 13; i++) {
int j = (i < 12) ? i + 1 : 1;
if (cusps[j] < cusps[i]) {
if ((position >= cusps[i]) || (position < cusps[j])) {
house = i;
break;
}
} else {
if ((position >= cusps[i]) && (position < cusps[j])) {
house = i;
break;
}
}
}
return house;
}
planetInfo_t *
get_planet_info(int32 planetNo, double date, double cusps[])
{
int32 iflgret,
iflag = SEFLG_SPEED | SEFLG_TOPOCTR;
double x2[6];
char serr[AS_MAXCH];
planetInfo_t *ret = g_new0(planetInfo_t, 1);
iflgret = swe_calc(date, planetNo, iflag, x2, serr);
if (iflgret < 0) {
printf("error: %s\n", serr);
return NULL;
} else if (iflgret != iflag) {
printf("warning: iflgret != iflag. %s\n", serr);
}
ret->house = get_house(x2[0], cusps);
ret->position = x2[0];
ret->sign = (int)ceilf(x2[0] / 30.0);
ret->retrograde = x2[3] < 0;
ret->type = signType[ret->sign].type;
ret->element = signType[ret->sign].element;
return ret;
}
int
set_location_and_time(double lon, double lat, double alt, int year, int month, int day, int hour, int min, double sec, double d_timezone, double *jd)
{
int utc_year,
utc_month,
utc_day,
utc_hour,
utc_min;
double utc_sec,
retval,
dret[2];
char serr[AS_MAXCH];
swe_set_topo(lon, lat, alt);
swe_utc_time_zone(year, month, day, hour, min, sec, d_timezone, &utc_year, &utc_month, &utc_day, &utc_hour, &utc_min, &utc_sec);
if ((retval = swe_utc_to_jd(utc_year, utc_month, utc_day, utc_hour, utc_min, utc_sec, SE_GREG_CAL, dret, serr)) == ERR) {
printf("error: %s\n", serr);
return 0;
}
*jd = dret[0];
return 1;
}

View File

@ -1,53 +0,0 @@
#include "../swe/src/swephexp.h"
typedef enum {
SIGN_NONE,
SIGN_ARIES,
SIGN_TAURUS,
SIGN_GEMINI,
SIGN_CANCER,
SIGN_LEO,
SIGN_VIRGO,
SIGN_LIBRA,
SIGN_SCORPIO,
SIGN_SAGITTARIUS,
SIGN_CAPRICORN,
SIGN_AQUARIUS,
SIGN_PISCES
} zodiacSign;
typedef enum {
TYPE_CARDINAL = 1,
TYPE_FIX,
TYPE_MUTABLE
} signType_t;
typedef enum {
ELEMENT_FIRE = 1,
ELEMENT_EARTH,
ELEMENT_AIR,
ELEMENT_WATER
} signElement_t;
typedef struct {
signType_t type;
signElement_t element;
int rulingPlanet;
int domicilePlanet;
int detrimentPlanet;
int exaltedPlanet;
int fallingPlanet;
} signTypePair_t;
typedef struct {
double position;
zodiacSign sign;
int house;
short int retrograde;
signType_t type;
signElement_t element;
} planetInfo_t;
guint get_house(gdouble position, gdouble cusps[]);
planetInfo_t *get_planet_info(int32 planetNo, double date, double cusps[]);
int set_location_and_time(double lon, double lat, double alt, int year, int month, int day, int hour, int min, double sec, double d_timezone, double *jd);