Functions
coord.c File Reference

This file contains functions for performing coordinate transformations. More...

#include <ctype.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "aephem.h"

Functions

void ae_rect_to_polar (const double rect[], double *ra, double *dec, double *radius)
 Convert an equatorial rectangular unit vector to ra/dec/radius. More...
 
void ae_rect_to_polar_with_jd (double pp[], double jd, char ofdate, double polar[])
 Convert equatorial rectangular coordinates to polar coordinates. More...
 
void ae_polar_to_rect (double ra, double dec, double radius, double rect[])
 Convert ra/dec/radius to a rectangular vector. More...
 
void ae_radec_to_altaz (double last, double glat, double ra, double dec, double *alt, double *az)
 Convert ra/dec to alt/az. More...
 
void ae_altaz_to_radec (double last, double glat, double alt, double az, double *ra, double *dec)
 Convert alt/az to ra/dec. More...
 
void ae_radec_to_gal (double ra, double dec, double *l, double *b, int fk5)
 Convert ra/dec to l/b (galactic coordinates). More...
 
void ae_gal_to_radec (double l, double b, double *ra, double *dec, int fk5)
 Convert l/b (galactic coordinates) to ra/dec. More...
 
void ae_geocentric_lat (double glat, double height, double *tlat, double *trho)
 Calculate the geocentric latitude and the distance to the earth's centre. More...
 
void ae_delta_q (double q0[], double q1[], double *dra, double *ddec)
 Convert change in rectangular coordinatates to change in ra/dec. More...
 

Detailed Description

This file contains functions for performing coordinate transformations.

Function Documentation

void ae_altaz_to_radec ( double  last,
double  glat,
double  alt,
double  az,
double *  ra,
double *  dec 
)

Convert alt/az to ra/dec.

Parameters
lastThe local aparent sidereal time, in degrees.
glatThe geodetic latitude, in degrees.
altThe altitude, in degrees.
azThe azimuth, in degrees.
raFor returning the right ascension, in degrees.
decFor returning the declination, in degrees.

References AE_DTR, ae_mod_360(), AE_RTD, and ae_zatan2().

Referenced by ae_topocentric().

void ae_delta_q ( double  q0[],
double  q1[],
double *  dra,
double *  ddec 
)

Convert change in rectangular coordinatates to change in ra/dec.

For changes greater than about 0.1 degree, the coordinates are converted directly to ra and dec and the results subtracted. For small changes, the change is calculated to first order by differentiating $tan(ra) = y/x$ to obtain

\[\frac{dra}{\cos^2(ra)} = \frac{dy}{x} - \frac{y dx}{x^2},\]

where

\[\cos^2(ra) = \frac{1}{1 + (y/x)^2}.\]

The change in declination $arcsin(z/R)$ is

\[d\arcsin(u) = \frac{du}{\sqrt{1-u^2}},\]

where $u = z/R.$

Parameters
q0The initial object - earth vector.
q1The vector after motion or aberration.
draThe change in right ascension.
ddecThe change in declination.

References ae_zatan2().

void ae_gal_to_radec ( double  l,
double  b,
double *  ra,
double *  dec,
int  fk5 
)

Convert l/b (galactic coordinates) to ra/dec.

Parameters
lThe galactic longitude, in degrees.
bThe galactic latitude, in degrees.
raFor returning the right ascension, in degrees.
decFor returning the declination, in degrees.
fk5If non-zero, assume FK5 system (i.e., J2000 compatible); if zero, use the old FK4 (B1950 compatible) galactic pole.

References AE_DTR, ae_mod_360(), and AE_RTD.

void ae_geocentric_lat ( double  glat,
double  height,
double *  tlat,
double *  trho 
)

Calculate the geocentric latitude and the distance to the earth's centre.

This function uses the reciprocal of flattening and the earth's radius (or, more precisely, semi-major axis) from from the WGS84 definition. (See AE_FLAT and AE_R_EARTH.)

Parameters
glatThe geodetic latitude of the observer, in degrees.
heightThe height of the observer above sea level, in metres.
tlatFor returning the geocentric latitude, in degrees.
trhoFor returning the distance to the earth's centre, in earth radii.

References AE_DTR, AE_FLAT, AE_R_EARTH, and AE_RTD.

Referenced by aes_topocentric().

void ae_polar_to_rect ( double  ra,
double  dec,
double  radius,
double  rect[] 
)

Convert ra/dec/radius to a rectangular vector.

Parameters
raThe right ascension, in degrees.
decThe declination, in degrees.
radiusThe radius; the units of radius will determine the units of the output.
rectFor returning the rectangular vector.

References AE_DTR.

Referenced by ae_coord_to_constel_index(), ae_phys_pole(), ae_subobs_point(), and aes_subobs_point().

void ae_radec_to_altaz ( double  last,
double  glat,
double  ra,
double  dec,
double *  alt,
double *  az 
)

Convert ra/dec to alt/az.

Parameters
lastThe local aparent sidereal time, in degrees.
glatThe geodetic latitude, in degrees.
raThe right ascension, in degrees.
decThe declination, in degrees.
altFor returning the altitude, in degrees.
azFor returning the azimuth, in degrees.

References AE_DTR, AE_RTD, and ae_zatan2().

Referenced by ae_topocentric().

void ae_radec_to_gal ( double  ra,
double  dec,
double *  l,
double *  b,
int  fk5 
)

Convert ra/dec to l/b (galactic coordinates).

Parameters
raThe right ascension, in degrees.
decThe declination, in degrees.
lFor returning the galactic longitude, in degrees.
bFor returning the galactic latitude, in degrees.
fk5If non-zero, assume FK5 system (i.e., J2000 compatible); if zero, use the old FK4 (B1950 compatible) galactic pole.

References AE_DTR, ae_mod_360(), and AE_RTD.

void ae_rect_to_polar ( const double  rect[],
double *  ra,
double *  dec,
double *  radius 
)

Convert an equatorial rectangular unit vector to ra/dec/radius.

Parameters
rectAn equatorial rectangular vector.
raFor returning the right ascension, in degrees.
decFor returning the declination, in degrees.
radiusFor returning the radius. Set to NULL if you do not need this value.

References AE_RTD, and ae_zatan2().

Referenced by ae_geocentric(), ae_geocentric_from_cat(), ae_geocentric_moon_from_orbit(), and ae_subobs_point().

void ae_rect_to_polar_with_jd ( double  pp[],
double  jd,
char  ofdate,
double  polar[] 
)

Convert equatorial rectangular coordinates to polar coordinates.

This routine is similar to ae_rect_to_polar(), except that it also performs //! any necessary precession.

Parameters
ppThe equatorial rectangular coordinates.
jdThe Julian date.
ofdateIf 1, precess from J2000.0 to jd.
polarFor returning the polar coordinates.

References ae_epsilon(), AE_FROM_J2000, ae_precess(), AE_STR, and ae_zatan2().