Examples of how to use comet functions.
#include <stdio.h>
#include <libnova/comet.h>
#include <libnova/julian_day.h>
#include <libnova/rise_set.h>
#include <libnova/transform.h>
#include <libnova/elliptic_motion.h>
#define MEEUS 0
static void print_date(
const char *title,
struct ln_zonedate *date)
{
fprintf(stdout, "\n%s\n",title);
fprintf(stdout,
" Year : %d\n", date->
years);
fprintf(stdout,
" Month : %d\n", date->
months);
fprintf(stdout,
" Day : %d\n", date->
days);
fprintf(stdout,
" Hours : %d\n", date->
hours);
fprintf(stdout,
" Minutes : %d\n", date->
minutes);
fprintf(stdout,
" Seconds : %f\n", date->
seconds);
fprintf(stdout,
" GMT offset %ld\n", date->
gmtoff);
}
int main (int argc, const char *argv[])
{
#if MEEUS
#endif
double JD, e_JD;
double E, v, V, r, l, dist, M;
observer.lat = 55.92;
observer.lng = -3.18;
#if MEEUS
date.years = 1990;
date.months = 10;
date.days = 6;
date.hours = 0;
date.minutes = 0;
date.seconds = 0;
#else
fprintf(stdout, "JD %f\n", JD);
#endif
#if MEEUS
epoch_date.years = 1990;
epoch_date.months = 10;
epoch_date.days = 28;
epoch_date.hours = 12;
epoch_date.minutes = 30;
epoch_date.seconds = 0;
#else
e_JD = 2456617.5;
#endif
fprintf(stdout, "Epoch JD %f diff %f\n", e_JD, JD - e_JD);
#if MEEUS
orbit.JD = e_JD;
orbit.a = 2.2091404;
orbit.e = 0.8502196;
orbit.i = 11.94525;
orbit.omega = 334.75006;
orbit.w = 186.23352;
orbit.n = 0;
#else
orbit.JD = e_JD;
orbit.a = 2.214743;
orbit.e = 0.848232;
orbit.i = 11.7790;
orbit.omega = 334.5731;
orbit.w = 186.5356;
orbit.n = 0;
#endif
if (orbit.n == 0.0)
fprintf(stdout,
"(Mean Anomaly) M when n is %f and JD diff is %f = %f\n",
orbit.n, JD - orbit.JD, M);
fprintf(stdout,
"(Equation of kepler) E when e is %f and M is %f = %f\n",
orbit.e, M, E);
fprintf(stdout,
"(True Anomaly) v when e is %f and E is %f = %f\n", orbit.e, E, v);
fprintf(stdout,
"(Radius Vector) r when e is %f and E is %f = %f\n", orbit.e, E, r);
fprintf(stdout,
"(Geocentric Rect Coords X) for comet Encke %f\n", posn.X);
fprintf(stdout,
"(Geocentric Rect Coords Y) for comet Encke %f\n", posn.Y);
fprintf(stdout,
"(Geocentric Rect Coords Z) for comet Encke %f\n", posn.Z);
fprintf(stdout,
"(Heliocentric Rect Coords X) for comet Encke %f\n", posn.X);
fprintf(stdout,
"(Heliocentric Rect Coords Y) for comet Encke %f\n", posn.Y);
fprintf(stdout,
"(Heliocentric Rect Coords Z) for comet Encke %f\n", posn.Z);
fprintf(stdout, "(RA) for comet Encke %f\n", equ.ra);
fprintf(stdout, "(Dec) for comet Encke %f\n", equ.dec);
fprintf(stdout, "(Orbit Length) for comet Encke in AU %f\n", l);
fprintf(stdout,
"(Orbit Perihelion Vel) for comet Encke in kms %f\n", V);
fprintf(stdout, "(Orbit Aphelion Vel) for comet Encke in kms %f\n", V);
fprintf(stdout, "(Orbit Vel JD) for comet Encke in kms %f\n", V);
fprintf(stdout, "(Body Solar Dist) for comet Encke in AU %f\n", dist);
fprintf(stdout, "(Body Earth Dist) for comet Encke in AU %f\n", dist);
fprintf(stdout, "Comet is circumpolar\n");
else {
ln_get_local_date(rst.rise, &rise);
ln_get_local_date(rst.transit, &transit);
ln_get_local_date(rst.set, &set);
print_date("Rise", &rise);
print_date("Transit", &transit);
print_date("Set", &set);
}
return 0;
}
double ln_get_julian_day(struct ln_date *date)
Calculate the julian day from date.
Definition: julian_day.c:45
double ln_get_julian_from_sys()
Calculate julian day from system time.
Definition: julian_day.c:256
double ln_solve_kepler(double e, double M)
Calculate the eccentric anomaly.
Definition: elliptic_motion.c:53
double ln_get_ell_true_anomaly(double e, double E)
Calculate the true anomaly.
Definition: elliptic_motion.c:109
double ln_get_ell_mean_anomaly(double n, double delta_JD)
Calculate the mean anomaly.
Definition: elliptic_motion.c:96
double ln_get_ell_orbit_avel(struct ln_ell_orbit *orbit)
Calculate the orbital velocity at aphelion in km/s.
Definition: elliptic_motion.c:365
double ln_get_ell_body_solar_dist(double JD, struct ln_ell_orbit *orbit)
Calculate the distance between a body and the Sun.
Definition: elliptic_motion.c:382
double ln_get_ell_orbit_len(struct ln_ell_orbit *orbit)
Calculate the orbital length in AU.
Definition: elliptic_motion.c:311
void ln_get_ell_geo_rect_posn(struct ln_ell_orbit *orbit, double JD, struct ln_rect_posn *posn)
Calculate the objects rectangular geocentric position.
Definition: elliptic_motion.c:244
void ln_get_ell_helio_rect_posn(struct ln_ell_orbit *orbit, double JD, struct ln_rect_posn *posn)
Calculate the objects rectangular heliocentric position.
Definition: elliptic_motion.c:179
void ln_get_ell_body_equ_coords(double JD, struct ln_ell_orbit *orbit, struct ln_equ_posn *posn)
Calculate a bodies equatorial coords.
Definition: elliptic_motion.c:271
double ln_get_ell_orbit_vel(double JD, struct ln_ell_orbit *orbit)
Calculate orbital velocity in km/s.
Definition: elliptic_motion.c:333
int ln_get_ell_body_rst(double JD, struct ln_lnlat_posn *observer, struct ln_ell_orbit *orbit, struct ln_rst_time *rst)
Calculate the time of rise, set and transit for a body with an elliptic orbit.
Definition: elliptic_motion.c:502
double ln_get_ell_mean_motion(double a)
Calculate the mean daily motion (degrees/day).
Definition: elliptic_motion.c:165
double ln_get_ell_radius_vector(double a, double e, double E)
Calculate the radius vector.
Definition: elliptic_motion.c:129
double ln_get_ell_body_earth_dist(double JD, struct ln_ell_orbit *orbit)
Calculate the distance between a body and the Earth.
Definition: elliptic_motion.c:405
double ln_get_ell_orbit_pvel(struct ln_ell_orbit *orbit)
Calculate orbital velocity at perihelion in km/s.
Definition: elliptic_motion.c:350
Human readable Date and time used by libnova.
Definition: ln_types.h:79
Elliptic Orbital elements.
Definition: ln_types.h:265
Equatorial Coordinates.
Definition: ln_types.h:176
Ecliptical (or celestial) Longitude and Latitude.
Definition: ln_types.h:204
Rectangular coordinates.
Definition: ln_types.h:239
Rise, Set and Transit times.
Definition: ln_types.h:314
Human readable Date and time with timezone information used by libnova.
Definition: ln_types.h:98
int minutes
Definition: ln_types.h:103
int months
Definition: ln_types.h:100
int hours
Definition: ln_types.h:102
int years
Definition: ln_types.h:99
int days
Definition: ln_types.h:101
long gmtoff
Definition: ln_types.h:105
double seconds
Definition: ln_types.h:104