From 9c694df8db27409864c0dfb70f98e6aa80369e8d Mon Sep 17 00:00:00 2001 From: "Gergely POLONKAI (W00d5t0ck)" Date: Mon, 2 Sep 2013 23:14:30 +0200 Subject: [PATCH] Now displaying planetary calculations based on SWE-GLib instead of pure SWE --- src/astrognome.c | 110 ++++++++++++++++++++++++++++++++++++----------- src/calculate.c | 63 --------------------------- src/calculate.h | 1 - 3 files changed, 85 insertions(+), 89 deletions(-) diff --git a/src/astrognome.c b/src/astrognome.c index 1695324..99db604 100644 --- a/src/astrognome.c +++ b/src/astrognome.c @@ -322,7 +322,7 @@ main(int argc, char *argv[]) cusps[13], ascmc[10]; planetInfo_t *planetInfo; - moonPhase *phase; + GsweMoonPhaseData *moon_phase; GHashTable *signDataTable, *planetDataTable, *planetInfoTable; @@ -332,6 +332,7 @@ main(int argc, char *argv[]) struct aspect_check_data aspectCheckData; GsweTimestamp *timestamp; GsweMoment *moment; + GswePlanetData *planet_data; #if 1 year = 1983; @@ -408,13 +409,20 @@ main(int argc, char *argv[]) printf("\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); + planetInfo = g_new0(planetInfo_t, 1); planetInfo->position = ascmc[0]; planetInfo->sign = get_sign(ascmc[0]); planetInfo->house = 1; planetInfo->retrograde = FALSE; g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_NPLANETS + SE_ASC), planetInfo); - printf("Asc.......: %s (%f)\n", signName[planetInfo->sign], planetInfo->position); + + // 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); planetInfo = g_new0(planetInfo_t, 1); planetInfo->position = ascmc[1]; @@ -422,7 +430,10 @@ main(int argc, char *argv[]) planetInfo->house = 10; planetInfo->retrograde = FALSE; g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_NPLANETS + SE_MC), planetInfo); - printf("MC........: %s (%f)\n", signName[planetInfo->sign], planetInfo->position); + + // 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); planetInfo = g_new0(planetInfo_t, 1); planetInfo->position = ascmc[3]; @@ -430,77 +441,126 @@ main(int argc, char *argv[]) planetInfo->house = get_house(ascmc[3], cusps); planetInfo->retrograde = FALSE; g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_NPLANETS + SE_VERTEX), planetInfo); - printf("Vertex....: %s (%f)\n", signName[planetInfo->sign], planetInfo->position); + + // 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" : ""); planetInfo = get_planet_info(SE_SUN, te, cusps); g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_SUN), planetInfo); - printf("Sun.......: %s, House: %d (%f%s)\n", signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); + + // 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" : ""); planetInfo = get_planet_info(SE_MOON, te, cusps); g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_MOON), planetInfo); - phase = get_moon_phase(year, month, day, hour, min, sec); - printf("Moon......: %s (%.2f%% visibility), %s, House: %d (%f%s)\n", moonStateName[phase->phase], phase->visiblePercentage, signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); - g_free(phase); + + // 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" : ""); planetInfo = get_planet_info(SE_MERCURY, te, cusps); g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_MERCURY), planetInfo); - printf("Mercury...: %s, House: %d (%f%s)\n", signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); + + // 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" : ""); planetInfo = get_planet_info (SE_VENUS, te, cusps); g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_VENUS), planetInfo); - printf("Venus.....: %s, House: %d (%f%s)\n", signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); + + // 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" : ""); planetInfo = get_planet_info(SE_MARS, te, cusps); g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_MARS), planetInfo); - printf("Mars......: %s, House: %d (%f%s)\n", signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); + + // 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" : ""); planetInfo = get_planet_info(SE_JUPITER, te, cusps); g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_JUPITER), planetInfo); - printf("Jupiter...: %s, House: %d (%f%s)\n", signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); + + // 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" : ""); planetInfo = get_planet_info(SE_SATURN, te, cusps); g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_SATURN), planetInfo); - printf("Saturn....: %s, House: %d (%f%s)\n", signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); + + // 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" : ""); planetInfo = get_planet_info(SE_URANUS, te, cusps); g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_URANUS), planetInfo); - printf("Uranus....: %s, House: %d (%f%s)\n", signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); + + // 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" : ""); planetInfo = get_planet_info(SE_NEPTUNE, te, cusps); g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_NEPTUNE), planetInfo); - printf("Neptune...: %s, House: %d (%f%s)\n", signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); + + // 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" : ""); planetInfo = get_planet_info(SE_PLUTO, te, cusps); g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_PLUTO), planetInfo); - printf("Pluto.....: %s, House: %d (%f%s)\n", signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); - planetInfo = get_planet_info(SE_CHIRON, te, cusps); - g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_CHIRON), planetInfo); - printf("Chiron....: %s, House: %d (%f%s)\n", signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); + // 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" : ""); planetInfo = get_planet_info(SE_MEAN_NODE, te, cusps); g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_MEAN_NODE), planetInfo); - printf("North Node: %s, House: %d (%f%s)\n", signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); + + // 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" : ""); planetInfo = get_planet_info(SE_MEAN_APOG, te, cusps); g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_MEAN_APOG), planetInfo); - printf("Dark Moon.: %s, House: %d (%f%s)\n", signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); + + // 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" : ""); + + planetInfo = get_planet_info(SE_CHIRON, te, cusps); + g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_CHIRON), planetInfo); + + // 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" : ""); planetInfo = get_planet_info(SE_CERES, te, cusps); g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_CERES), planetInfo); - printf("Ceres.....: %s, House: %d (%f%s)\n", signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); + + // 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" : ""); planetInfo = get_planet_info(SE_PALLAS, te, cusps); g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_PALLAS), planetInfo); - printf("Pallas....: %s, House: %d (%f%s)\n", signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); + + // 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" : ""); planetInfo = get_planet_info(SE_JUNO, te, cusps); g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_JUNO), planetInfo); - printf("Juno......: %s, House: %d (%f%s)\n", signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); + + // 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" : ""); planetInfo = get_planet_info(SE_VESTA, te, cusps); g_hash_table_replace(planetInfoTable, GINT_TO_POINTER(SE_VESTA), planetInfo); - printf("Vesta.....: %s, House: %d (%f%s)\n", signName[planetInfo->sign], planetInfo->house, planetInfo->position, (planetInfo->retrograde) ? ", retrograde" : ""); printf("\nELEMENTS\n========\n\n"); diff --git a/src/calculate.c b/src/calculate.c index 3944874..227962a 100644 --- a/src/calculate.c +++ b/src/calculate.c @@ -130,66 +130,3 @@ get_sign(double pos) return (int)ceilf(pos / 30.0); } -moonPhase * -get_moon_phase(gint year, gint month, gint day, gint hour, gint min, gint sec) -{ - GDateTime *baseDate, - *gds; - GTimeSpan diff; - gdouble phasePercent, - realPercent; - moonState state; - moonPhase *ret; - - baseDate = g_date_time_new_utc(2005, 5, 8, 8, 48, 0); - // TODO: this should use the time zone used at the birth place - gds = g_date_time_new_local(year, month, day, 0, 0, 0); - diff = g_date_time_difference(gds, baseDate) / 1000; - - g_date_time_unref(gds); - g_date_time_unref(baseDate); - - // The current phase of the moon, between 0 and 100 (both 0 and 100 are new moon, 50 is full moon) - phasePercent = fmod((diff * 100) / (SYNODIC * MSPERDAY), 100); - - if (phasePercent < 0) { - phasePercent += 100.0; - } - - if ((phasePercent < 0) || (phasePercent > 100)) { - fprintf(stderr, "Error during moon phase calculation!\n"); - - return NULL; - } - - // The real percentage is a number around the illumination percentage of the moon - realPercent = (50.0 - fabs(phasePercent - 50.0)) * 2; - - // Uuuugly! - if (phasePercent == 0) { - state = MOON_STATE_NEW; - } else if (phasePercent < 25) { - state = MOON_STATE_WAXING_CRESCENT; - } else if (phasePercent == 25) { - state = MOON_STATE_WAXING_HALF; - } else if (phasePercent < 50) { - state = MOON_STATE_WAXING_GIBBOUS; - } else if (phasePercent == 50) { - state = MOON_STATE_FULL; - } else if (phasePercent < 75) { - state = MOON_STATE_WANING_GIBBOUS; - } else if (phasePercent == 75) { - state = MOON_STATE_WANING_HALF; - } else if (phasePercent < 100) { - state = MOON_STATE_WANING_CRESCENT; - } else { - state = MOON_STATE_DARK; - } - - ret = g_new0(moonPhase, 1); - ret->phase = state; - ret->visiblePercentage = realPercent; - - return ret; -} - diff --git a/src/calculate.h b/src/calculate.h index aa35066..91df42e 100644 --- a/src/calculate.h +++ b/src/calculate.h @@ -72,4 +72,3 @@ 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); long int get_sign(double pos); -moonPhase *get_moon_phase(gint year, gint month, gint day, gint hour, gint min, gint sec);