Examples of how to use Lunar functions.
#include <stdio.h>
#include <libnova/lunar.h>
#include <libnova/julian_day.h>
#include <libnova/rise_set.h>
#include <libnova/transform.h>
static void print_date(
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);
}
int main(int argc, const char *argv[])
{
double JD;
observer.lat = 55.92;
observer.lng = -3.18;
fprintf(stdout, "JD %f\n",JD);
fprintf(stdout, "lunar x %f y %f z %f\n", moon.X, moon.Y, moon.Z);
fprintf(stdout, "lunar long %f lat %f\n", ecl.lng, ecl.lat);
fprintf(stdout, "lunar RA %f Dec %f\n", equ.ra, equ.dec);
fprintf(stdout, "lunar libration point long %f lat %f\n", ecl.lng, ecl.lat);
ln_get_lunar_subsolar_coords(JD, &ecl);
fprintf(stdout, "lunar subsolar point long %f lat %f\n", ecl.lng, ecl.lat);
fprintf(stdout, "Moon 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);
}
fprintf(stdout, "Moon 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);
}
fprintf(stdout, "Moon 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_from_sys()
Calculate julian day from system time.
Definition: julian_day.c:256
void ln_get_lunar_geo_posn(double JD, struct ln_rect_posn *moon, double precision)
Calculate the rectangular geocentric lunar cordinates.
Definition: lunar.c:1094
double ln_get_lunar_bright_limb(double JD)
Calculate the position angle of the Moon's bright limb.
Definition: lunar.c:1321
void ln_get_lunar_ecl_coords(double JD, struct ln_lnlat_posn *position, double precision)
Calculate lunar ecliptical coordinates.
Definition: lunar.c:1229
int ln_get_lunar_rst(double JD, struct ln_lnlat_posn *observer, struct ln_rst_time *rst)
Calculate the time of rise, set and transit for the Moon.
Definition: lunar.c:1357
double ln_get_lunar_disk(double JD)
Calculate the illuminated fraction of the Moons disk.
Definition: lunar.c:1300
double ln_get_lunar_phase(double JD)
Calculate the phase angle of the Moon.
Definition: lunar.c:1269
void ln_get_lunar_equ_coords(double JD, struct ln_equ_posn *position)
Calculate lunar equatorial coordinates.
Definition: lunar.c:1214
void ln_get_lunar_opt_libr_coords(double JD, struct ln_lnlat_posn *position)
Calculate selenographic optical libration coordinates.
Definition: lunar.c:1476
double ln_get_lunar_earth_dist(double JD)
Calculate the distance between the Earth and the Moon.
Definition: lunar.c:1253
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
double seconds
Definition: ln_types.h:104