libnova  v 0.15.0
transforms.c

Examples of how to use transformation functions.

/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Copyright 2004 Liam Girdwood
*/
#include <libnova/transform.h>
#include <libnova/julian_day.h>
#include <libnova/utility.h>
#include <stdio.h>
/*
* Do some RA/DEC <--> ALT/AZ conversions for Alnilam
* in Leon (Spain) on 25/4/2004
*/
int main (int argc, char * argv[])
{
struct lnh_equ_posn hobject, hequ;
struct lnh_lnlat_posn hobserver;
struct ln_equ_posn object, equ;
struct ln_hrz_posn hrz;
struct lnh_hrz_posn hhrz;
struct ln_lnlat_posn observer;
double JD;
struct ln_date date;
/*
* observers position
* longitude is measured positively eastwards
* i.e. Long 5d36m30W (Leon, Spain) = 354d24m30
* Lat for Leon = Lat 42d35m40 N
*/
hobserver.lng.degrees = -5;
hobserver.lng.minutes = 36;
hobserver.lng.seconds = 30;
hobserver.lat.degrees = 42;
hobserver.lat.minutes = 35;
hobserver.lat.seconds = 40;
/* Alnilam */
hobject.ra.hours = 5;
hobject.ra.minutes = 36;
hobject.ra.seconds = 27;
hobject.dec.neg = 1;
hobject.dec.degrees = 1;
hobject.dec.minutes = 12;
hobject.dec.seconds = 0;
/* UT date and time */
date.years = 2004;
date.months = 4;
date.days = 25;
date.hours = 12;
date.minutes = 18;
date.seconds = 49;
JD = ln_get_julian_day (&date);
ln_hequ_to_equ (&hobject, &object);
ln_hlnlat_to_lnlat (&hobserver, &observer);
ln_get_hrz_from_equ (&object, &observer, JD, &hrz);
printf("(Alnilam) Equ to Horiz ALT %f\n", hrz.alt);
printf("(Alnilam) Equ to Horiz AZ %f\n", hrz.az);
ln_hrz_to_hhrz(&hrz, &hhrz);
printf("ALT %d:%d:%f AZ %d:%d:%f\n", hhrz.alt.degrees, hhrz.alt.minutes,
hhrz.alt.seconds, hhrz.az.degrees, hhrz.az.minutes, hhrz.az.seconds);
ln_get_equ_from_hrz (&hrz, &observer, JD, &equ);
printf("(Alnilam) Horiz to Equ RA %f\n", equ.ra);
printf("(Alnilam) Horiz to Equ DEC %f\n", equ.dec);
ln_equ_to_hequ(&equ, &hequ);
printf("RA %d:%d:%f DEC %d:%d:%f\n", hequ.ra.hours, hequ.ra.minutes,
hequ.ra.seconds, hequ.dec.degrees, hequ.dec.minutes, hequ.dec.seconds);
return 0;
}
lnh_equ_posn::ra
struct ln_hms ra
Definition: ln_types.h:132
ln_get_julian_day
double ln_get_julian_day(struct ln_date *date)
Calculate the julian day from date.
Definition: julian_day.c:40
lnh_lnlat_posn::lat
struct ln_dms lat
Definition: ln_types.h:158
ln_date::years
int years
Definition: ln_types.h:68
ln_date::seconds
double seconds
Definition: ln_types.h:73
ln_hrz_posn
Horizontal Coordinates.
Definition: ln_types.h:185
ln_equ_to_hequ
void LIBNOVA_EXPORT ln_equ_to_hequ(struct ln_equ_posn *pos, struct lnh_equ_posn *hpos)
human double equatorial position to human readable equatorial position
Definition: utility.c:342
ln_hrz_to_hhrz
void LIBNOVA_EXPORT ln_hrz_to_hhrz(struct ln_hrz_posn *pos, struct lnh_hrz_posn *hpos)
double horizontal position to human readable horizontal position
Definition: utility.c:362
ln_hrz_posn::az
double az
Definition: ln_types.h:186
ln_hms::minutes
unsigned short minutes
Definition: ln_types.h:120
ln_equ_posn::ra
double ra
Definition: ln_types.h:172
lnh_equ_posn::dec
struct ln_dms dec
Definition: ln_types.h:133
ln_hlnlat_to_lnlat
void LIBNOVA_EXPORT ln_hlnlat_to_lnlat(struct lnh_lnlat_posn *hpos, struct ln_lnlat_posn *pos)
human readable long/lat position to double long/lat position
Definition: utility.c:383
ln_get_equ_from_hrz
void LIBNOVA_EXPORT ln_get_equ_from_hrz(struct ln_hrz_posn *object, struct ln_lnlat_posn *observer, double JD, struct ln_equ_posn *position)
Calculate equatorial coordinates from horizontal coordinates
Definition: transform.c:155
lnh_lnlat_posn
Ecliptical (or celestial) Latitude and Longitude.
Definition: ln_types.h:156
ln_date::days
int days
Definition: ln_types.h:70
ln_hms::seconds
double seconds
Definition: ln_types.h:121
ln_hequ_to_equ
void LIBNOVA_EXPORT ln_hequ_to_equ(struct lnh_equ_posn *hpos, struct ln_equ_posn *pos)
human readable equatorial position to double equatorial position
Definition: utility.c:332
ln_dms::degrees
unsigned short degrees
Definition: ln_types.h:106
lnh_lnlat_posn::lng
struct ln_dms lng
Definition: ln_types.h:157
lnh_equ_posn
Right Ascension and Declination.
Definition: ln_types.h:131
ln_dms::minutes
unsigned short minutes
Definition: ln_types.h:107
ln_date
Human readable Date and time used by libnova.
Definition: ln_types.h:67
lnh_hrz_posn::alt
struct ln_dms alt
Definition: ln_types.h:145
ln_date::hours
int hours
Definition: ln_types.h:71
lnh_hrz_posn
Azimuth and Altitude.
Definition: ln_types.h:143
ln_date::minutes
int minutes
Definition: ln_types.h:72
ln_hrz_posn::alt
double alt
Definition: ln_types.h:188
ln_get_hrz_from_equ
void LIBNOVA_EXPORT ln_get_hrz_from_equ(struct ln_equ_posn *object, struct ln_lnlat_posn *observer, double JD, struct ln_hrz_posn *position)
Calculate horizontal coordinates from equatorial coordinates.
Definition: transform.c:75
ln_dms::neg
unsigned short neg
Definition: ln_types.h:105
ln_dms::seconds
double seconds
Definition: ln_types.h:108
lnh_hrz_posn::az
struct ln_dms az
Definition: ln_types.h:144
ln_date::months
int months
Definition: ln_types.h:69
ln_lnlat_posn
Ecliptical (or celestial) Longitude and Latitude.
Definition: ln_types.h:201
ln_equ_posn
Equatorial Coordinates.
Definition: ln_types.h:171
ln_equ_posn::dec
double dec
Definition: ln_types.h:173
ln_hms::hours
unsigned short hours
Definition: ln_types.h:119