int main (int argc, char* argv[]) { double JD; struct ln_rect_posn moon; struct ln_equ_posn equ; struct ln_lnlat_posn ecl; struct ln_lnlat_posn observer; struct ln_rst_time rst; struct ln_zonedate rise, transit, set; /* observers location (Edinburgh), used to calc rst */ observer.lat = 55.92; /* 55.92 N */ observer.lng = -3.18; /* 3.18 W */ /* get the julian day from the local system time */ JD = ln_get_julian_from_sys(); printf ("JD %f\n",JD); /* get the lunar geopcentric position in km, earth is at 0,0,0 */ ln_get_lunar_geo_posn (JD, &moon, 0); printf ("lunar x %f y %f z %f\n",moon.X, moon.Y, moon.Z); /* Long Lat */ ln_get_lunar_ecl_coords (JD, &ecl, 0); printf ("lunar long %f lat %f\n",ecl.lng, ecl.lat); /* RA, DEC */ ln_get_lunar_equ_coords (JD, &equ); printf ("lunar RA %f Dec %f\n",equ.ra, equ.dec); /* moon earth distance */ printf ("lunar distance km %f\n", ln_get_lunar_earth_dist(JD)); /* lunar disk, phase and bright limb */ printf ("lunar disk %f\n", ln_get_lunar_disk(JD)); printf ("lunar phase %f\n", ln_get_lunar_phase(JD)); printf ("lunar bright limb %f\n", ln_get_lunar_bright_limb(JD)); /* rise, set and transit time */ if (ln_get_lunar_rst (JD, &observer, &rst) == 1) printf ("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); } /* rise, set and transit time */ if (ln_get_lunar_rst (JD - 24, &observer, &rst) == 1) printf ("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); } /* rise, set and transit time */ if (ln_get_lunar_rst (JD - 25, &observer, &rst) == 1) printf ("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; }
void MainWindow::setSunRiseAndSetVectors(const QDateTime &dateTime) { struct ln_equ_posn equ; struct ln_rst_time rst; struct ln_zonedate rise, set, transit; struct ln_lnlat_posn observer; struct ln_hrz_posn hpos; double JD; observer.lat = ui->latEdit->text().toFloat(); observer.lng = ui->lngEdit->text().toFloat(); ln_date date; date.years = dateTime.date().year(); date.months = dateTime.date().month(); date.days = dateTime.date().day(); date.hours = dateTime.time().hour(); date.minutes = dateTime.time().minute(); date.seconds = dateTime.time().second(); JD = ln_get_julian_day(&date); /* ra, dec */ ln_get_solar_equ_coords (JD, &equ); ln_get_hrz_from_equ(&equ, &observer, JD, &hpos); double a = ln_range_degrees(hpos.az - 180); QString s; s.sprintf("Azimut: %0.3f", a); ui->listWidget->addItem(s); s.sprintf("Evaluation: %0.3f", hpos.alt); ui->listWidget->addItem(s); /* rise, set and transit */ if (ln_get_solar_rst (JD, &observer, &rst) == 1) { ui->listWidget->addItem(QString("Zirkumpolar")); } else { ln_get_local_date (rst.rise, &rise); ln_get_local_date (rst.transit, &transit); ln_get_local_date (rst.set, &set); s.sprintf("Aufgang: %02d:%02d:%02d", rise.hours, rise.minutes, (int)rise.seconds); ui->listWidget->addItem(s); s.sprintf("Transit: %02d:%02d:%02d", transit.hours, transit.minutes, (int)transit.seconds); ui->listWidget->addItem(s); s.sprintf("Untergang: %02d:%02d:%02d", set.hours, set.minutes, (int)set.seconds); ui->listWidget->addItem(s); } //sunHeading->setVisible(false); setSunVectors(&rise, &observer, sunRise); setSunVectors(&set, &observer, sunSet); mc->setView(QPointF(observer.lng, observer.lat)); //overlay->addGeometry(); }