Examples of how to use asteroid functions.
#include <stdio.h>
#include <libnova/asteroid.h>
#include <libnova/julian_day.h>
#include <libnova/rise_set.h>
#include <libnova/transform.h>
#include <libnova/elliptic_motion.h>
void print_date (
char * title,
struct ln_zonedate* date)
{
printf ("\n%s\n",title);
printf (
" Year : %d\n", date->
years);
printf (
" Month : %d\n", date->
months);
printf (
" Day : %d\n", date->
days);
printf (
" Hours : %d\n", date->
hours);
printf (
" Minutes : %d\n", date->
minutes);
printf (
" Seconds : %f\n", date->
seconds);
}
int main (int argc, char * argv[])
{
double JD, M_JD;
double l,V,dist;
double H, G;
double mag, elong, ph;
char* M_epoch = "K036A";
observer.lat = 55.92;
observer.lng = -3.18;
JD = ln_get_julian_from_sys();
printf ("JD (sys) %f\n", JD);
orbit.a = 2.7730346;
orbit.e = 0.2299839;
orbit.i = 34.84989;
orbit.omega = 173.16479;
orbit.w = 310.45917;
orbit.n =0.21343771;
H = 4.13;
G = 0.11;
M_JD = ln_get_julian_from_mpc(M_epoch);
orbit.JD = ln_get_ell_last_perihelion (M_JD, 260.69458, orbit.n);
printf ("JD (Perihelion) %f\n", orbit.JD);
ln_get_ell_geo_rect_posn (&orbit, JD, &posn);
printf ("(Geocentric Rect Coords X) for Pallas %f\n", posn.X);
printf ("(Geocentric Rect Coords Y) for Pallas %f\n", posn.Y);
printf ("(Geocentric Rect Coords Z) for Pallas %f\n", posn.Z);
ln_get_ell_helio_rect_posn (&orbit, JD, &posn);
printf ("(Heliocentric Rect Coords X) for Pallas %f\n", posn.X);
printf ("(Heliocentric Rect Coords Y) for Pallas %f\n", posn.Y);
printf ("(Heliocentric Rect Coords Z) for Pallas %f\n", posn.Z);
ln_get_ell_body_equ_coords (JD, &orbit, &equ_posn);
printf ("(RA) for Pallas %f\n", equ_posn.ra);
printf ("(Dec) for Pallas %f\n", equ_posn.dec);
ln_get_hrz_from_equ (&equ_posn, &observer, JD, &hrz);
printf ("Az %f\n",hrz.az);
printf ("Alt %f\n", hrz.alt);
l = ln_get_ell_orbit_len (&orbit);
printf ("(Orbit Length) for Pallas in AU %f\n", l);
V = ln_get_ell_orbit_pvel (&orbit);
printf ("(Orbit Perihelion Vel) for Pallas in kms %f\n", V);
V = ln_get_ell_orbit_avel (&orbit);
printf ("(Orbit Aphelion Vel) for Pallas in kms %f\n", V);
V = ln_get_ell_orbit_vel (JD, &orbit);
printf ("(Orbit Vel JD) for Pallas in kms %f\n", V);
dist = ln_get_ell_body_solar_dist (JD, &orbit);
printf ("Solar Dist (AU) : %f\n", dist);
dist = ln_get_ell_body_earth_dist (JD, &orbit);
printf ("Earth Dist (AU) : %f\n", dist);
ph = ln_get_ell_body_phase_angle(JD, &orbit);
printf ("Phase angle : %f\n",ph);
elong = ln_get_ell_body_elong(JD, &orbit);
printf ("Elongation : %f\n",elong);
mag = ln_get_asteroid_mag (JD, &orbit, H, G);
printf ("Magnitude : %f\n", mag);
if (ln_get_ell_body_rst (JD, &observer, &orbit, &rst) == 1)
printf ("Pallas 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;
}
Elliptic Orbital elements.
Definition ln_types.h:266
Equatorial Coordinates.
Definition ln_types.h:171
Horizontal Coordinates.
Definition ln_types.h:185
Ecliptical (or celestial) Longitude and Latitude.
Definition ln_types.h:201
Rectangular coordinates.
Definition ln_types.h:238
Rise, Set and Transit times.
Definition ln_types.h:318
Human readable Date and time with timezone information used by libnova.
Definition ln_types.h:87
int minutes
Definition ln_types.h:92
int months
Definition ln_types.h:89
int hours
Definition ln_types.h:91
int years
Definition ln_types.h:88
int days
Definition ln_types.h:90
double seconds
Definition ln_types.h:93