novas.h File Reference

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "novascon.h"
#include "solarsystem.h"

Go to the source code of this file.

Classes

struct  body
struct  site_info
struct  cat_entry

Defines

#define BARYC   0
#define HELIOC   1

Functions

short int app_star (double tjd, body *earth, cat_entry *star, double *ra, double *dec)
short int app_planet (double tjd, body *ss_object, body *earth, double *ra, double *dec, double *dis)
short int topo_star (double tjd, body *earth, double deltat, cat_entry *star, site_info *location, double *ra, double *dec)
short int topo_planet (double tjd, body *ss_object, body *earth, double deltat, site_info *location, double *ra, double *dec, double *dis)
short int virtual_star (double tjd, body *earth, cat_entry *star, double *ra, double *dec)
short int virtual_planet (double tjd, body *ss_object, body *earth, double *ra, double *dec, double *dis)
short int local_star (double tjd, body *earth, double deltat, cat_entry *star, site_info *location, double *ra, double *dec)
short int local_planet (double tjd, body *ss_object, body *earth, double deltat, site_info *location, double *ra, double *dec, double *dis)
short int astro_star (double tjd, body *earth, cat_entry *star, double *ra, double *dec)
short int astro_planet (double tjd, body *ss_object, body *earth, double *ra, double *dec, double *dis)
short int mean_star (double tjd, body *earth, double ra, double dec, double *mra, double *mdec)
void sidereal_time (double julianhi, double julianlo, double ee, double *gst)
void pnsw (double tjd, double gast, double x, double y, double *vece, double *vecs)
void spin (double st, double *pos1, double *pos2)
void wobble (double x, double y, double *pos1, double *pos2)
void terra (site_info *locale, double st, double *pos, double *vel)
void earthtilt (double tjd, double *mobl, double *tobl, double *eqeq, double *psi, double *eps)
void cel_pole (double del_dpsi, double del_deps)
short int get_earth (double tjd, body *earth, double *tdb, double *bary_earthp, double *bary_earthv, double *helio_earthp, double *helio_earthv)
void proper_motion (double tjd1, double *pos1, double *vel1, double tjd2, double *pos2)
void bary_to_geo (double *pos, double *earthvector, double *pos2, double *lighttime)
short int sun_field (double *pos, double *earthvector, double *pos2)
short int aberration (double *pos, double *vel, double lighttime, double *pos2)
void precession (double tjd1, double *pos, double tjd2, double *pos2)
short int nutate (double tjd, short int fn1, double *pos, double *pos2)
short int nutation_angles (double tdbtime, double *longnutation, double *obliqnutation)
void fund_args (double t, double a[5])
short int vector2radec (double *pos, double *ra, double *dec)
void radec2vector (double ra, double dec, double dist, double *vector)
void starvectors (cat_entry *star, double *pos, double *vel)
void tdb2tdt (double tdb, double *tdtjd, double *secdiff)
short int set_body (short int type, short int number, const char *name, body *cel_obj)
short int ephemeris (double tjd, body *cel_obj, short int origin, double *pos, double *vel)
short int solarsystem (double tjd, short int body, short int origin, double *pos, double *vel)
double * readeph (int mp, char *name, double jd, int *err)
void make_cat_entry (char catalog[4], char star_name[51], long int star_num, double ra, double dec, double pm_ra, double pm_dec, double parallax, double rad_vel, cat_entry *star)
void transform_hip (cat_entry *hipparcos, cat_entry *fk5)
void transform_cat (short int option, double date_incat, cat_entry *incat, double date_newcat, const char *newcat_id, cat_entry *newcat)
void equ2hor (double tjd, double deltat, double x, double y, site_info *location, double ra, double dec, short int ref_option, double *zd, double *az, double *rar, double *decr)
double refract (site_info *location, short int ref_option, double zd_obs)
double julian_date (short int year, short int month, short int day, double hour)
void cal_date (double tjd, short int *year, short int *month, short int *day, double *hour)

Define Documentation

#define BARYC   0

Definition at line 136 of file novas.h.

Referenced by app_planet(), astro_planet(), get_earth(), local_planet(), topo_planet(), and virtual_planet().

#define HELIOC   1

Definition at line 137 of file novas.h.

Referenced by get_earth().


Function Documentation

short int aberration ( double *  pos,
double *  vel,
double  lighttime,
double *  pos2 
)

Definition at line 2693 of file novas.c.

Referenced by app_planet(), app_star(), local_planet(), local_star(), topo_planet(), topo_star(), virtual_planet(), and virtual_star().

02699           :    
02700       Corrects position vector for aberration of light.  Algorithm
02701       includes relativistic terms.
02702 
02703    REFERENCES: 
02704       Murray, C. A. (1981) Mon. Notices Royal Ast. Society 195, 639-648.
02705       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
02706          pp. 1197-1210.
02707       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
02708          Subroutines"; USNO internal document dated 20 Oct 1988;
02709          revised 15 Mar 1990.
02710 
02711    INPUT
02712    ARGUMENTS:
02713       pos[3] (double)
02714          Position vector, referred to origin at center of mass of the
02715          Earth, components in AU.
02716       ve[3] (double)
02717          Velocity vector of center of mass of the Earth, referred to
02718          origin at solar system barycenter, components in AU/day.
02719       lighttime (double)
02720          Light time from body to Earth in days.
02721 
02722    OUTPUT
02723    ARGUMENTS:
02724       pos2[3] (double)
02725          Position vector, referred to origin at center of mass of the
02726          Earth, corrected for aberration, components in AU
02727 
02728    RETURNED
02729    VALUE:
02730       (short int)
02731          0...Everything OK.
02732 
02733    GLOBALS
02734    USED:
02735       C
02736 
02737    FUNCTIONS
02738    CALLED:
02739       sqrt      math.h
02740       pow       math.h
02741 
02742    VER./DATE/
02743    PROGRAMMER:
02744       V1.0/01-93/TKB (USNO/NRL Optical Interfer.) Translate Fortran.
02745       V1.1/08-93/WTH (USNO/AA) Update to C Standards.
02746 
02747    NOTES:
02748       1. This function is the "C" version of Fortran NOVAS routine
02749       'aberat'.
02750       2. If 'lighttime' = 0 on input, this function will compute it.
02751 
02752 ------------------------------------------------------------------------
02753 */
02754 {
02755    short int j;
02756 
02757    double p1mag, vemag, beta, dot,cosd, gammai, p, q, r;
02758 
02759    if (lighttime == 0.0)
02760    {
02761       p1mag = sqrt (pow (pos[0], 2.0) + pow (pos[1], 2.0)
02762                   + pow (pos[2], 2.0));
02763       lighttime = p1mag / C;
02764    }
02765     else
02766       p1mag = lighttime * C;
02767 
02768    vemag = sqrt (pow (ve[0], 2.0) + pow (ve[1], 2.0) 
02769                + pow (ve[2], 2.0));
02770    beta = vemag / C;
02771    dot = pos[0] * ve[0] + pos[1] * ve[1] + pos[2] * ve[2];
02772 
02773    cosd = dot / (p1mag * vemag);
02774    gammai = sqrt (1.0 - pow (beta, 2.0));
02775    p = beta * cosd;
02776    q = (1.0 + p / (1.0 + gammai)) * lighttime;
02777    r = 1.0 + p;
02778 
02779    for (j = 0; j < 3; j++)
02780       pos2[j] = (gammai * pos[j] + q * ve[j]) / r;
02781 
02782    return 0;
02783 }

short int app_planet ( double  tjd,
body ss_object,
body earth,
double *  ra,
double *  dec,
double *  dis 
)

Definition at line 146 of file novas.c.

References aberration(), bary_to_geo(), BARYC, MuELoss::e, ephemeris(), FN0, get_earth(), nutate(), precession(), sun_field(), T0, and vector2radec().

00152           :    
00153       Compute the apparent place of a planet or other solar system body.
00154 
00155    REFERENCES: 
00156       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
00157          pp. 1197-1210.
00158       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
00159          Subroutines"; USNO internal document dated 20 Oct 1988;
00160          revised 15 Mar 1990.
00161 
00162    INPUT
00163    ARGUMENTS:
00164       tjd (double)
00165          TT (or TDT) Julian date for apparent place.
00166       *ss_object (struct body)
00167          Pointer to structure containing the body designation for the
00168          solar system body (defined in novas.h).
00169       *earth (struct body)
00170          Pointer to structure containing the body designation for the
00171          Earth (defined in novas.h).
00172 
00173    OUTPUT
00174    ARGUMENTS:
00175       *ra (double)
00176          Apparent right ascension in hours, referred to true equator
00177          and equinox of date 'tjd'.
00178       *dec (double)
00179          Apparent declination in degrees, referred to true equator
00180          and equinox of date 'tjd'.
00181       *dis (double)
00182          True distance from Earth to planet at 'tjd' in AU.
00183 
00184    RETURNED
00185    VALUE:
00186       (short int)
00187           0...Everything OK.
00188          >0...See error description in function 'ephemeris'.
00189 
00190    GLOBALS
00191    USED:
00192       BARYC, C, T0, FN0
00193 
00194    FUNCTIONS
00195    CALLED:
00196       get_earth      novas.c
00197       ephemeris      novas.c
00198       bary_to_geo    novas.c
00199       sun_field      novas.c
00200       aberration     novas.c
00201       precession     novas.c
00202       nutate         novas.c
00203       vector2radec   novas.c
00204       fabs           math.h
00205 
00206    VER./DATE/
00207    PROGRAMMER:
00208       V1.0/08-93/WTH (USNO/AA) Translate Fortran.
00209       V1.1/10-95/WTH (USNO/AA) Added call to 'get_earth'.
00210       V1.2/06-97/JAB (USNO/AA) Generalize ephemeris management.
00211       V1.3/12-99/JAB (USNO/AA) Fix error return from 'get_earth'.
00212 
00213    NOTES:
00214       1. This function is the "C" version of Fortran NOVAS routine
00215       'applan'.
00216 
00217 ------------------------------------------------------------------------
00218 */
00219 {
00220    short int error = 0;
00221 
00222    double tdb, peb[3], veb[3], pes[3], ves[3], t2, t3, lighttime,
00223       pos1[3], vel1[3], pos2[3], pos3[3], pos4[3], pos5[3], pos6[3];
00224 
00225 /* add extra ()'s 4/03 S. Kasahara */
00226    if ((error = get_earth (tjd,earth, &tdb,peb,veb,pes,ves)))
00227    {
00228       *ra = 0.0;
00229       *dec = 0.0;
00230       return (error + 10);
00231    }
00232 
00233 /*
00234    Get position of planet wrt barycenter of solar system.
00235 */
00236 
00237 /* add extra ()'s 4/03 S. Kasahara */
00238    if ((error = ephemeris (tdb,ss_object,BARYC, pos1,vel1)))
00239    {
00240       *ra = 0.0;
00241       *dec = 0.0;
00242       *dis = 0.0;
00243       return error;
00244    }
00245 
00246    bary_to_geo (pos1,peb, pos2,&lighttime);
00247    *dis = lighttime * C;
00248    t3 = tdb - lighttime;
00249 
00250    do
00251    {
00252       t2 = t3;
00253 /* add extra ()'s 4/03 S. Kasahara */
00254       if ((error = ephemeris (t2,ss_object,BARYC, pos1,vel1)))
00255       {
00256          *ra = 0.0;
00257          *dec = 0.0;
00258          *dis = 0.0;
00259          return error;
00260       }
00261 
00262       bary_to_geo (pos1,peb, pos2,&lighttime);
00263       t3 = tdb - lighttime;
00264    } while (fabs (t3-t2) > 1.0e-8);
00265 
00266 /*
00267    Finish apparent place computation.
00268 */
00269 
00270    sun_field (pos2,pes, pos3);
00271    aberration (pos3,veb,lighttime, pos4);
00272    precession (T0,pos4,tdb, pos5);
00273    nutate (tdb,FN0,pos5, pos6);
00274    vector2radec (pos6, ra,dec);
00275 
00276    return 0;
00277 }

short int app_star ( double  tjd,
body earth,
cat_entry star,
double *  ra,
double *  dec 
)

Definition at line 34 of file novas.c.

References aberration(), bary_to_geo(), FN0, get_earth(), nutate(), precession(), proper_motion(), starvectors(), sun_field(), T0, and vector2radec().

Referenced by mean_star().

00040           :
00041       Computes the apparent place of a star at date 'tjd', given its
00042       mean place, proper motion, parallax, and radial velocity for
00043       J2000.0.
00044 
00045    REFERENCES:
00046       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
00047          pp. 1197-1210.
00048       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
00049          Subroutines"; USNO internal document dated 20 Oct 1988;
00050          revised 15 Mar 1990.
00051 
00052    INPUT
00053    ARGUMENTS:
00054       tjd (double)
00055          TT (or TDT) Julian date for apparent place.
00056       *earth (struct body)
00057          Pointer to structure containing the body designation for the
00058          Earth (defined in novas.h).
00059       *star (struct cat_entry)
00060          Pointer to catalog entry structure containing J2000.0 catalog
00061          data with FK5-style units (defined in novas.h).
00062 
00063    OUTPUT
00064    ARGUMENTS:
00065       *ra (double)
00066          Apparent right ascension in hours, referred to true equator
00067          and equinox of date 'tjd'.
00068       *dec (double)
00069          Apparent declination in degrees, referred to true equator
00070          and equinox of date 'tjd'.
00071 
00072    RETURNED
00073    VALUE:
00074       (short int)
00075           0...Everything OK.
00076          >0...Error code from function 'solarsystem'.
00077 
00078    GLOBALS
00079    USED:
00080       T0, FN0
00081 
00082    FUNCTIONS
00083    CALLED:
00084       get_earth       novas.c
00085       starvectors     novas.c
00086       proper_motion   novas.c
00087       bary_to_geo     novas.c
00088       sun_field       novas.c
00089       aberration      novas.c
00090       precession      novas.c
00091       nutate          novas.c
00092       vector2radec    novas.c
00093 
00094    VER./DATE/
00095    PROGRAMMER:
00096       V1.0/01-93/TKB (USNO/NRL Optical Interfer.) Translate Fortran.
00097       V1.1/07-93/WTH (USNO/AA) Update to C standards.
00098       V1.2/10-95/WTH (USNO/AA) Added call to 'get_earth'.
00099       V1.3/06-97/JAB (USNO/AA) Incorporate 'body' structure in input.
00100 
00101    NOTES:
00102       1. This function is the "C" version of Fortran NOVAS routine
00103       'apstar'.
00104 
00105 ------------------------------------------------------------------------
00106 */
00107 {
00108    short int error = 0;
00109 
00110    double tdb, time2, peb[3],veb[3], pes[3], ves[3], pos1[3], pos2[3],
00111       pos3[3], pos4[3], pos5[3], pos6[3], pos7[3], vel1[3];
00112 
00113 /*
00114    Get the position and velocity of the Earth w/r/t the solar system
00115    barycenter and the center of mass of the Sun, on the mean equator
00116    and equinox of J2000.0
00117 */
00118 /* add extra ()'s 4/03 S. Kasahara */
00119    if ((error = get_earth (tjd,earth, &tdb,peb,veb,pes,ves))) 
00120    {
00121       *ra = 0.0;
00122       *dec = 0.0;
00123       return error;
00124    }
00125 
00126 /*
00127    Compute apparent place
00128 */
00129 
00130    starvectors (star, pos1,vel1);
00131    proper_motion (T0,pos1,vel1,tdb, pos2);
00132 
00133    bary_to_geo (pos2,peb, pos3,&time2);
00134    sun_field (pos3,pes, pos4);
00135    aberration (pos4,veb,time2, pos5);
00136    precession (T0,pos5,tdb, pos6);
00137    nutate (tdb,FN0,pos6, pos7);
00138 
00139    vector2radec (pos7, ra,dec);
00140 
00141    return 0;
00142 }

short int astro_planet ( double  tjd,
body ss_object,
body earth,
double *  ra,
double *  dec,
double *  dis 
)

Definition at line 1279 of file novas.c.

References bary_to_geo(), BARYC, MuELoss::e, ephemeris(), get_earth(), and vector2radec().

01285           :    
01286       Computes the astrometric place of a planet or other solar system
01287       body.
01288 
01289    REFERENCES: 
01290       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
01291          pp. 1197-1210.
01292       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
01293          Subroutines"; USNO internal document dated 20 Oct 1988;
01294          revised 15 Mar 1990.
01295 
01296    INPUT
01297    ARGUMENTS:
01298       tjd (double)
01299          TT (or TDT) Julian date for calculation.
01300       *ss_object (struct body)
01301          Pointer to structure containing the body designation for the
01302          solar system body (defined in novas.h).
01303       *earth (struct body)
01304          Pointer to structure containing the body designation for the
01305          Earth (defined in novas.h).
01306 
01307    OUTPUT
01308    ARGUMENTS:
01309       *ra (double)
01310          Astrometric right ascension in hours, referred to mean equator
01311          and equinox of J2000.
01312       *dec (double)
01313          Astrometric declination in degrees, referred to mean equator
01314          and equinox of J2000.
01315       *dis (double)
01316          True distance from Earth to planet in AU.
01317 
01318    RETURNED
01319    VALUE:
01320       (short int)
01321           0...Everything OK.
01322          >0...See error description in function 'ephemeris'.
01323 
01324    GLOBALS
01325    USED:
01326       C, BARYC
01327 
01328    FUNCTIONS
01329    CALLED:
01330       get_earth      novas.c
01331       ephemeris      novas.c
01332       bary_to_geo    novas.c
01333       vector2radec   novas.c
01334       fabs           math.h
01335 
01336    VER./DATE/
01337    PROGRAMMER:
01338       V1.0/08-93/WTH (USNO/AA) Translate Fortran.
01339       V1.1/10-95/WTH (USNO/AA) Added call to 'get_earth'.
01340       V1.2/06-97/JAB (USNO/AA) Generalize ephemeris management.
01341       V1.3/12-99/JAB (USNO/AA) Fix error return from 'get_earth'.
01342 
01343    NOTES:
01344       1. This function is the "C" version of Fortran NOVAS routine
01345       'asplan'.
01346 
01347 ------------------------------------------------------------------------
01348 */
01349 {
01350    short int error = 0;
01351 
01352    double t2 = 0.0, t3 = 0.0;
01353    double lighttime, pos1[3], vel1[3], pos2[3], tdb, peb[3], veb[3],
01354       pes[3], ves[3];
01355 
01356 /*
01357    Get position of the Earth wrt center of Sun and barycenter of the
01358    solar system.
01359 */
01360 
01361 /* add extra ()'s 4/03 S. Kasahara */
01362    if ((error = get_earth (tjd,earth, &tdb,peb,veb,pes,ves)))
01363    {
01364       *ra = 0.0;
01365       *dec = 0.0;
01366       return (error + 10);
01367    }
01368 
01369 /*
01370    Get position of planet wrt barycenter of solar system.
01371 */
01372 
01373 /* add extra ()'s 4/03 S. Kasahara */
01374    if ((error = ephemeris (tdb,ss_object,BARYC, pos1,vel1)))
01375    {
01376       *ra = 0.0;
01377       *dec = 0.0;
01378       *dis = 0.0;
01379       return error;
01380    }
01381    bary_to_geo (pos1,peb, pos2,&lighttime);
01382    *dis = lighttime * C;
01383    t3 = tdb - lighttime;
01384    do
01385    {
01386       t2 = t3;
01387 /* add extra ()'s 4/03 S. Kasahara */
01388       if ((error = ephemeris (t2,ss_object,BARYC, pos1,vel1)))
01389       {
01390          *ra = 0.0;
01391          *dec = 0.0;
01392          *dis = 0.0;
01393          return error;
01394       }
01395       bary_to_geo (pos1,peb, pos2,&lighttime);
01396       t3 = tdb - lighttime;
01397    } while (fabs (t3 - t2) > 1.0e-8);
01398 
01399 /*
01400    Finish astrometric place computation.
01401 */
01402 
01403    vector2radec (pos2, ra,dec);
01404 
01405    return 0;
01406 }

short int astro_star ( double  tjd,
body earth,
cat_entry star,
double *  ra,
double *  dec 
)

Definition at line 1177 of file novas.c.

References bary_to_geo(), get_earth(), proper_motion(), starvectors(), T0, and vector2radec().

01183           :    
01184       Computes the astrometric place of a star, given its mean place,
01185       proper motion, parallax, and radial velocity for J2000.0.
01186 
01187    REFERENCES: 
01188       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
01189          pp. 1197-1210.
01190       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
01191          Subroutines"; USNO internal document dated 20 Oct 1988;
01192          revised 15 Mar 1990.
01193 
01194    INPUT
01195    ARGUMENTS:
01196       tjd (double)
01197          TT (or TDT) Julian date for astrometric place.
01198       *earth (struct body)
01199          Pointer to structure containing the body designation for the
01200          Earth (defined in novas.h).
01201       *star (struct cat_entry)
01202          Pointer to catalog entry structure containing J2000.0 catalog
01203          data with FK5-style units (defined in novas.h).
01204 
01205    OUTPUT
01206    ARGUMENTS:
01207       *ra (double)
01208          Astrometric right ascension in hours, referred to mean equator
01209          and equinox of J2000.
01210       *dec (double)
01211          Astrometric declination in degrees, referred to mean equator
01212          and equinox of J2000.
01213 
01214    RETURNED
01215    VALUE:
01216       (short int)
01217           0...Everything OK.
01218          >0...Error code from function 'solarsystem'.
01219 
01220    GLOBALS
01221    USED:
01222       T0
01223 
01224    FUNCTIONS
01225    CALLED:
01226       get_earth       novas.c
01227       starvectors     novas.c
01228       proper_motion   novas.c
01229       bary_to_geo     novas.c
01230       vector2radec    novas.c
01231 
01232    VER./DATE/
01233    PROGRAMMER:
01234       V1.0/08-93/WTH (USNO/AA) Translate Fortran.
01235       V1.1/10-95/WTH (USNO/AA) Added call to 'get_earth'.
01236       V1.2/06-97/JAB (USNO/AA) Incorporate 'body' structure in input.
01237 
01238    NOTES:
01239       1. This function is the "C" version of Fortran NOVAS routine
01240       'asstar'.
01241 
01242 ------------------------------------------------------------------------
01243 */
01244 {
01245    short int error=0;
01246 
01247    double lighttime, pos1[3], vel1[3], pos2[3], pos3[3], tdb, peb[3],
01248       veb[3], pes[3], ves[3];
01249 
01250 /*
01251    Get the position and velocity of the Earth w/r/t the solar system
01252    barycenter and the center of mass of the Sun, on the mean equator
01253    and equinox of J2000.0
01254 */
01255 
01256 /* add extra ()'s 4/03 S. Kasahara */
01257    if ((error = get_earth (tjd,earth, &tdb,peb,veb,pes,ves)))
01258    {
01259       *ra = 0.0;
01260       *dec = 0.0;
01261       return error;
01262    }
01263 
01264 /*
01265    Compute astrometric place.
01266 */
01267 
01268    starvectors (star, pos1,vel1);
01269    proper_motion (T0,pos1,vel1,tdb, pos2);
01270    bary_to_geo (pos2,peb, pos3,&lighttime);
01271 
01272    vector2radec (pos3, ra,dec);
01273 
01274    return 0;
01275 }

void bary_to_geo ( double *  pos,
double *  earthvector,
double *  pos2,
double *  lighttime 
)

Definition at line 2446 of file novas.c.

Referenced by app_planet(), app_star(), astro_planet(), astro_star(), local_planet(), local_star(), topo_planet(), topo_star(), virtual_planet(), and virtual_star().

02452           :    
02453       Moves the origin of coordinates from the barycenter of the
02454       solar system to the center of mass of the Earth; i.e. corrects
02455       for parallax.
02456 
02457    REFERENCES: 
02458       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
02459          pp. 1197-1210.
02460       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
02461          Subroutines"; USNO internal document dated 20 Oct 1988;
02462          revised 15 Mar 1990.
02463 
02464    INPUT
02465    ARGUMENTS:
02466       pos1[3] (double)
02467          Position vector, referred to origin at solar system barycenter,
02468          components in AU.
02469       earthvector[3] (double)
02470          Position vector of center of mass of the Earth, referred to
02471          origin at solar system barycenter, components in AU.
02472 
02473    OUTPUT
02474    ARGUMENTS:
02475       pos2[3] (double)
02476          Position vector, referred to origin at center of mass of the
02477          Earth, components in AU.
02478       *lighttime (double)
02479          Light time from body to Earth in days.
02480 
02481    RETURNED
02482    VALUE:
02483       None.
02484 
02485    GLOBALS
02486    USED:
02487       C
02488 
02489    FUNCTIONS
02490    CALLED:
02491       pow     math.h
02492       sqrt    math.h
02493 
02494    VER./DATE/
02495    PROGRAMMER:
02496       V1.0/01-93/TKB (USNO/NRL Optical Interfer.) Translate Fortran.
02497       V1.1/08-93/WTH (USNO/AA) Update to C Standards.
02498 
02499    NOTES:
02500       1. This function is the "C" version of Fortran NOVAS routine
02501       'geocen'.
02502 
02503 ------------------------------------------------------------------------
02504 */
02505 {
02506    short int j;
02507 
02508    double sum_of_squares;
02509 
02510 /*
02511    Translate vector to geocentric coordinates.
02512 */
02513 
02514    for (j = 0; j < 3; j++)
02515       pos2[j] = pos[j] - earthvector[j];
02516 
02517 /*
02518    Calculate length of vector in terms of light time.
02519 */
02520 
02521    sum_of_squares = pow (pos2[0], 2.0) + pow (pos2[1], 2.0)
02522                   + pow (pos2[2], 2.0);
02523 
02524    *lighttime = sqrt (sum_of_squares) / C;
02525 
02526    return;
02527 }

void cal_date ( double  tjd,
short int *  year,
short int *  month,
short int *  day,
double *  hour 
)

Definition at line 4935 of file novas.c.

References Munits::m, and n.

04942           :    
04943       This function will compute a date on the Gregorian calendar given
04944       the Julian date.
04945 
04946    REFERENCES: 
04947       Fliegel & Van Flandern, Comm. of the ACM, Vol. 11, No. 10,
04948          October 1968, p. 657.
04949 
04950    INPUT
04951    ARGUMENTS:
04952       tjd (double)
04953          Julian date.
04954 
04955    OUTPUT
04956    ARGUMENTS:
04957       *year (short int)
04958          Year.
04959       *month (short int)
04960          Month number.
04961       *day (short int)
04962          Day-of-month.
04963       *hour (double)
04964          Hour-of-day.
04965 
04966    RETURNED
04967    VALUE:
04968       None.
04969 
04970    GLOBALS
04971    USED:
04972       None.
04973 
04974    FUNCTIONS
04975    CALLED:
04976       fmod     math.h
04977 
04978    VER./DATE/
04979    PROGRAMMER:
04980       V1.0/06-98/JAB (USNO/AA)
04981 
04982    NOTES:
04983       1. This routine valid for any 'jd' greater than zero.
04984       2. Input julian date can be based on any UT-like time scale
04985       (UTC, UT1, TT, etc.) - output time value will have same basis.
04986       3. This function is the "C" version of Fortran NOVAS routine
04987       'caldat'.
04988 
04989 
04990 ------------------------------------------------------------------------
04991 */
04992 {
04993    long int jd, k, m, n;
04994 
04995    double djd;
04996 
04997    djd = tjd + 0.5;
04998    jd = (long int) djd;
04999 
05000    *hour = fmod (djd,1.0) * 24.0;
05001 
05002    k     = jd + 68569L;
05003    n     = 4L * k / 146097L;
05004 
05005    k     = k - (146097L * n + 3L) / 4L;
05006    m     = 4000L * (k + 1L) / 1461001L;
05007    k     = k - 1461L * m / 4L + 31L;
05008 
05009    *month = (short int) (80L * k / 2447L);
05010    *day   = (short int) (k - 2447L * (long int) *month / 80L);
05011    k      = (long int) *month / 11L;
05012 
05013    *month = (short int) ((long int) *month + 2L - 12L * k);
05014    *year  = (short int) (100L * (n - 49L) + m + k);
05015 
05016    return;
05017 }

void cel_pole ( double  del_dpsi,
double  del_deps 
)

Definition at line 2189 of file novas.c.

References EPS_COR, and PSI_COR.

02193           :
02194       This function allows for the specification of celestial pole
02195       offsets for high-precision applications.  These are added
02196       to the nutation parameters delta psi and delta epsilon.
02197 
02198    REFERENCES:
02199       None.
02200 
02201    INPUT
02202    ARGUMENTS:
02203       del_dpsi (double)
02204          Value of offset in delta psi (dpsi) in arcseconds.
02205       del_deps (double)
02206          Value of offset in delta epsilon (deps) in arcseconds.
02207 
02208 
02209    OUTPUT
02210    ARGUMENTS:
02211       None.
02212 
02213    RETURNED
02214    VALUE:
02215       None.
02216 
02217    GLOBALS
02218    USED:
02219       PSI_COR, EPS_COR
02220 
02221    FUNCTIONS
02222    CALLED:
02223       None.
02224 
02225    VER./DATE/
02226    PROGRAMMER:
02227       V1.0/06-98/JAB (USNO/AA)
02228 
02229    NOTES:
02230       1. This function sets the values of global variables 'PSI_COR'
02231       and 'EPS_COR' declared at the top of file 'novas.c'.  These
02232       global variables are used only in NOVAS function 'earthtilt'.
02233       2. This function, if used, should be called before any other 
02234       NOVAS functions for a given date.  Values of the pole offsets 
02235       specified via a call to this function will be used until 
02236       explicitly changed.
02237       3. Daily values of the offsets are published, for example, in 
02238       IERS Bulletins A and B.
02239       4. This function is the "C" version of Fortran NOVAS routine
02240       'celpol'.
02241 
02242 ------------------------------------------------------------------------
02243 */
02244 {
02245    PSI_COR = del_dpsi;
02246    EPS_COR = del_deps;
02247 
02248    return;
02249 }

void earthtilt ( double  tjd,
double *  mobl,
double *  tobl,
double *  eqeq,
double *  psi,
double *  eps 
)

Definition at line 2034 of file novas.c.

References DEG2RAD, EPS_COR, fund_args(), nutation_angles(), PSI_COR, and T0.

Referenced by equ2hor(), AstUtil::JulianToGAST(), local_planet(), local_star(), nutate(), topo_planet(), topo_star(), and virtual_planet().

02041           :    
02042       Computes quantities related to the orientation of the Earth's
02043       rotation axis at Julian date 'tjd'.
02044 
02045    REFERENCES: 
02046       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
02047          pp. 1197-1210.
02048       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
02049          Subroutines"; USNO internal document dated 20 Oct 1988;
02050          revised 15 Mar 1990.
02051       Transactions of the IAU (1994). Resolution C7; Vol. XXIIB, p. 59.
02052       McCarthy, D. D. (ed.) (1996). IERS Technical Note 21. IERS
02053          Central Bureau, Observatoire de Paris), pp. 21-22.
02054 
02055    INPUT
02056    ARGUMENTS:
02057       tjd (double)
02058          TDB Julian date of the desired time
02059 
02060    OUTPUT
02061    ARGUMENTS:
02062       *mobl (double)
02063          Mean obliquity of the ecliptic in degrees at 'tjd'.
02064       *tobl (double)
02065          True obliquity of the ecliptic in degrees at 'tjd'.
02066       *eq (double)
02067          Equation of the equinoxes in seconds of time at 'tjd'.
02068       *dpsi (double)
02069          Nutation in longitude in arcseconds at 'tjd'.
02070       *deps (double)
02071          Nutation in obliquity in arcseconds at 'tjd'.
02072 
02073    RETURNED
02074    VALUE:
02075       None.
02076 
02077    GLOBALS
02078    USED:
02079       PSI_COR, EPS_COR, DEG2RAD 
02080 
02081    FUNCTIONS
02082    CALLED:
02083       nutation_angles  novas.c
02084       fund_args        novas.c
02085       fabs             math.h
02086       pow              math.h
02087       cos              math.h
02088 
02089    VER./DATE/
02090    PROGRAMMER:
02091       V1.0/08-93/WTH (USNO/AA) Translate Fortran.
02092       V1.1/06-97/JAB (USNO/AA) Incorporate IAU (1994) and IERS (1996) 
02093                                adjustment to the "equation of the 
02094                                equinoxes".
02095       V1.2/10-97/JAB (USNO/AA) Implement function that computes 
02096                                arguments of the nutation series.
02097       V1.3/07-98/JAB (USNO/AA) Use global variables 'PSI_COR' and 
02098                                'EPS_COR' to apply celestial pole offsets
02099                                for high-precision applications.
02100 
02101    NOTES:
02102       1. This function is the "C" version of Fortran NOVAS routine
02103       'etilt'.
02104       2. Values of the celestial pole offsets 'PSI_COR' and 'EPS_COR'
02105       are set using function 'cel_pole', if desired.  See the prolog
02106       of 'cel_pole' for details.
02107 
02108 ------------------------------------------------------------------------
02109 */
02110 {
02111    static double tjd_last = 0.0;
02112    static double t, dp, de;
02113    double d_psi, d_eps, mean_obliq, true_obliq, eq_eq, args[5];
02114 
02115 /*
02116    Compute time in Julian centuries from epoch J2000.0.
02117 */
02118 
02119   t = (tjd - T0) / 36525.0;
02120 
02121 /*
02122    Compute the nutation angles (arcseconds) from the standard nutation 
02123    model if the input Julian date is significantly different from the 
02124    last Julian date.
02125 */
02126 
02127   if (fabs (tjd - tjd_last) > 1.0e-6)
02128       nutation_angles (t, &dp,&de);
02129 
02130 /*
02131    Apply observed celestial pole offsets.
02132 */
02133 
02134    d_psi = dp + PSI_COR;
02135    d_eps = de + EPS_COR;
02136 
02137 /*
02138    Compute mean obliquity of the ecliptic in arcseconds.
02139 */
02140 
02141    mean_obliq = 84381.4480 - 46.8150 * t - 0.00059 * pow (t, 2.0)
02142       + 0.001813 * pow (t, 3.0);
02143 
02144 /*
02145    Compute true obliquity of the ecliptic in arcseconds.
02146 */
02147 
02148    true_obliq = mean_obliq + d_eps;
02149 
02150 /*
02151    Convert obliquity values to degrees.
02152 */
02153 
02154    mean_obliq /= 3600.0;
02155    true_obliq /= 3600.0;
02156 
02157 /*
02158    Compute equation of the equinoxes in seconds of time.
02159 
02160    'args[4]' is "omega", the longitude of the ascending node of the 
02161    Moon's mean orbit on the ecliptic in radians.  This is also an 
02162    argument of the nutation series.
02163 */
02164 
02165    fund_args (t, args);
02166 
02167    eq_eq = d_psi * cos (mean_obliq * DEG2RAD) +
02168       (0.00264  * sin (args[4]) + 0.000063 * sin (2.0 * args[4]));
02169 
02170    eq_eq /= 15.0;
02171                            
02172 /*
02173    Reset the value of the last Julian date and set the output values.
02174 */
02175 
02176    tjd_last = tjd;
02177 
02178    *dpsi = d_psi;
02179    *deps = d_eps;
02180    *eq = eq_eq;
02181    *mobl = mean_obliq;
02182    *tobl = true_obliq;
02183 
02184    return;
02185 }

short int ephemeris ( double  tjd,
body cel_obj,
short int  origin,
double *  pos,
double *  vel 
)

Definition at line 3790 of file novas.c.

References err(), body::name, body::number, readeph(), solarsystem(), and body::type.

Referenced by app_planet(), astro_planet(), local_planet(), topo_planet(), and virtual_planet().

03796           :    
03797       Retrieves the position and velocity of a body from a fundamental
03798       ephemeris.
03799 
03800    REFERENCES:
03801       None.
03802 
03803    INPUT
03804    ARGUMENTS:
03805       tjd (double)
03806          TDB Julian date.
03807       *cel_obj (struct body)
03808          Pointer to structure containing the designation of the body
03809          of interest (defined in novas.h).
03810       origin (int)
03811          Origin code; solar system barycenter   = 0,
03812                       center of mass of the Sun = 1.
03813 
03814    OUTPUT
03815    ARGUMENTS:
03816       pos[3] (double)
03817          Position vector of 'body' at tjd; equatorial rectangular
03818          coordinates in AU referred to the mean equator and equinox
03819          of J2000.0.
03820       vel[3] (double)
03821          Velocity vector of 'body' at tjd; equatorial rectangular
03822          system referred to the mean equator and equinox of J2000.0,
03823          in AU/Day.
03824 
03825    RETURNED
03826    VALUE:
03827       (short int)
03828          0    ... Everything OK.
03829          1    ... Invalid value of 'origin'.
03830          2    ... Invalid value of 'type' in 'cel_obj'.
03831          3    ... Unable to allocate memory.
03832          10+n ... where n is the error code from 'solarsystem'.
03833          20+n ... where n is the error code from 'readeph'.
03834 
03835    GLOBALS
03836    USED:
03837       None.
03838 
03839    FUNCTIONS
03840    CALLED:
03841       solarsystem         novas.c
03842       readeph             readeph.c
03843       strlen              string.h
03844       strcpy              string.h
03845       malloc              stdlib.h
03846       free                stdlib.h
03847 
03848    VER./DATE/
03849    PROGRAMMER:
03850       V1.0/06-97/JAB (USNO/AA)
03851       V1.1/10-97/JAB (USNO/AA): Support error code from 'readeph'.
03852       V1.2/08-98/JAB (USNO/AA): Add computation of barycentric
03853                                 coordinates of a minor planet; support
03854                                 new 'readeph' argument list.
03855       V1.3/12-99/JAB (USNO/AA): Add error handling to call to 
03856                                 'solarsystem' (case 1).
03857 
03858    NOTES:
03859       1. It is recommended that the input structure 'cel_obj' be
03860       created using function 'set_body' in file novas.c.
03861 
03862 ------------------------------------------------------------------------
03863 */
03864 {
03865    char *mp_name;
03866 
03867    int err = 0;
03868    int mp_number;
03869 
03870    short int error = 0;
03871    short int ss_number, i;
03872 
03873    double *posvel, *sun_pos, *sun_vel;
03874 
03875    size_t name_len;
03876 
03877 /*
03878    Check the value of 'origin'.
03879 */
03880 
03881    if ((origin < 0) || (origin > 1))
03882       return (error = 1);
03883 
03884 /*
03885    Invoke the appropriate ephemeris access software depending upon the
03886    type of object.
03887 */
03888 
03889    switch (cel_obj->type)
03890    {
03891 
03892 /*
03893    Get the position and velocity of a major planet, Sun, or Moon,
03894 */
03895 
03896       case 0:
03897          ss_number = cel_obj->number;
03898          if ((error = solarsystem (tjd,ss_number,origin, pos,vel))
03899                != 0)
03900             error += 10;
03901          break;
03902 
03903 /*
03904    Get the position and velocity of a minor planet. 
03905    
03906 */
03907 
03908       case 1:
03909          mp_number = (int) cel_obj->number;
03910 
03911          name_len = (strlen (cel_obj->name) + 1L) * sizeof (char);
03912          mp_name = (char *) malloc (name_len);
03913          if (mp_name == NULL )
03914             return (error = 3);
03915          strcpy (mp_name, cel_obj->name);
03916 
03917          posvel = (double *) malloc (6L * sizeof (double));
03918          if (posvel == NULL )
03919          {
03920             free (mp_name);
03921                 return (error = 3);
03922          }
03923 
03924 /*  The USNO minor planet software returns heliocentric positions and 
03925     velocities.
03926 */
03927 
03928          posvel = readeph (mp_number,mp_name,tjd, &err);
03929          if (err != 0)
03930             return ((short int) (20 + err));
03931 
03932 /*  Barycentric coordinates of the minor planet, if desired, are 
03933     computed via the barycentric coordinates of the Sun, obtained 
03934     from the solar system ephemeris.
03935 */
03936 
03937          if (origin == 0)
03938          {
03939             sun_pos = (double *) malloc (3L * sizeof (double));
03940             if (sun_pos == NULL )
03941             {
03942                free (mp_name);
03943                free (posvel);
03944                return (error = 3);
03945             }
03946 
03947             sun_vel = (double *) malloc (3L * sizeof (double));
03948             if (sun_vel == NULL )
03949             {
03950                free (mp_name);
03951                free (posvel);
03952                free (sun_pos);
03953                return (error = 3);
03954             }
03955 
03956             if ((error = solarsystem (tjd,10,0, sun_pos,sun_vel)) != 0)
03957             {
03958                free (mp_name);
03959                free (posvel);
03960                free (sun_pos);
03961                free (sun_vel);
03962                return (error + 10);
03963             }
03964 
03965             for (i = 0; i < 3; i++)
03966             {
03967                posvel[i] += sun_pos[i];
03968                posvel[i+3] += sun_vel[i];
03969             }
03970 
03971             free (sun_pos);
03972             free (sun_vel);
03973          }
03974 
03975 /*
03976    Break up 'posvel' into separate position and velocity vectors.
03977 */
03978 
03979          for (i = 0; i < 3; i++)
03980          {
03981             pos[i] = posvel[i];
03982             vel[i] = posvel[i+3];
03983          }
03984 
03985          free (mp_name);
03986          free (posvel);
03987          break;
03988 
03989 /*
03990    Invalid type of object.
03991 */
03992 
03993       default:
03994          error = 2;
03995          break;
03996 
03997    }
03998 
03999    return (error);
04000 }

void equ2hor ( double  tjd,
double  deltat,
double  x,
double  y,
site_info location,
double  ra,
double  dec,
short int  ref_option,
double *  zd,
double *  az,
double *  rar,
double *  decr 
)

Definition at line 4468 of file novas.c.

References DEG2RAD, MuELoss::e, earthtilt(), site_info::latitude, site_info::longitude, pnsw(), RAD2DEG, refract(), sidereal_time(), and tdb2tdt().

04476           :
04477       This function transforms apparent equatorial coordinates (right 
04478       ascension and declination) to horizon coordinates (zenith 
04479       distance and azimuth).  It uses a method that properly accounts 
04480       for polar motion, which is significant at the sub-arcsecond 
04481       level.  This function can also adjust coordinates for atmospheric 
04482       refraction.
04483 
04484    REFERENCES:
04485       None.
04486 
04487    INPUT
04488    ARGUMENTS:
04489       tjd (double)
04490          TT (or TDT) Julian date.
04491       deltat (double)
04492          Difference TT (or TDT)-UT1 at 'tjd', in seconds.
04493       x (double)
04494          Conventionally-defined x coordinate of celestial ephemeris 
04495          pole with respect to IERS reference pole, in arcseconds. 
04496       y (double)
04497          Conventionally-defined y coordinate of celestial ephemeris 
04498          pole with respect to IERS reference pole, in arcseconds.
04499       *location (struct site_info)
04500          Pointer to structure containing observer's location (defined
04501          in novas.h).
04502       ra (double)
04503          Topocentric right ascension of object of interest, in hours, 
04504          referred to true equator and equinox of date.
04505       dec (double)
04506          Topocentric declination of object of interest, in degrees, 
04507          referred to true equator and equinox of date.
04508       ref_option (short int)
04509          = 0 ... no refraction
04510          = 1 ... include refraction, using 'standard' atmospheric
04511                  conditions.
04512          = 2 ... include refraction, using atmospheric parameters 
04513                  input in the 'location' structure.
04514  
04515    OUTPUT
04516    ARGUMENTS:
04517       *zd (double)
04518          Topocentric zenith distance in degrees, affected by 
04519          refraction if 'ref_option' is non-zero.
04520       *az (double)
04521          Topocentric azimuth (measured east from north) in degrees.
04522       *rar (double)
04523          Topocentric right ascension of object of interest, in hours, 
04524          referred to true equator and equinox of date, affected by 
04525          refraction if 'ref_option' is non-zero.
04526       *decr (double)
04527          Topocentric declination of object of interest, in degrees, 
04528          referred to true equator and equinox of date, affected by 
04529          refraction if 'ref_option' is non-zero.
04530 
04531    RETURNED
04532    VALUE:
04533       None.
04534 
04535    GLOBALS
04536    USED:
04537       DEG2RAD, RAD2DEG
04538 
04539    FUNCTIONS
04540    CALLED:
04541       tdb2tdt           novas.c
04542       sidereal_time     novas.c
04543       psnw              novas.c
04544       refract           novas.c
04545       sin               math.h
04546       cos               math.h
04547       sqrt              math.h
04548       atan2             math.h
04549       fabs              math.h
04550 
04551    VER./DATE/
04552    PROGRAMMER:
04553       V1.0/06-98/JAB (USNO/AA)
04554 
04555    NOTES:
04556       1. 'x' and 'y' can be set to zero if sub-arcsecond accuracy is  
04557       not needed.  'ra' and 'dec' can be obtained from functions 
04558       'tpstar' or 'tpplan'.
04559       2. The directons 'zd'= 0 (zenith) and 'az'= 0 (North) are here 
04560       considered fixed in the terrestrial frame.  Specifically, the 
04561       zenith is along the geodetic normal, and North is toward
04562       the IERS reference pole.
04563       3. If 'ref_option'= 0, then 'rar'='ra' and 'decr'='dec'.
04564       4. This function is the "C" version of Fortran NOVAS routine
04565       'zdaz' written by G. H. Kaplan (USNO).
04566 
04567 ------------------------------------------------------------------------
04568 */
04569 {
04570    short int j;
04571 
04572    double ujd, dummy, secdiff, tdb, mobl, tobl, ee, dpsi, deps, gast,
04573       sinlat, coslat, sinlon, coslon, sindc, cosdc, sinra, cosra, 
04574       uze[3], une[3], uwe[3], uz[3], un[3], uw[3], p[3], pz, pn, pw, 
04575       proj, zd0, zd1, refr, cosr, prlen, rlen, pr[3];
04576 
04577 /*
04578    Compute 'ujd', the UT1 Julian date corresponding to 'tjd'.
04579 */
04580 
04581    ujd = tjd - (deltat / 86400.0);
04582 
04583 /*
04584    Compute 'tdb', the TDB Julian date corresponding to 'tjd'.
04585 */
04586 
04587    tdb2tdt (tjd, &dummy,&secdiff);
04588    tdb = tjd + secdiff / 86400.0;
04589 
04590 /*
04591    Compute the equation of the equinoxes.
04592 */
04593 
04594    earthtilt (tdb, &mobl,&tobl,&ee,&dpsi,&deps);
04595 
04596 /*
04597    Compute the Greenwich apparent sidereal time at 'ujd'.
04598 */
04599 
04600    sidereal_time (ujd,0.0,ee, &gast);
04601 
04602 /*
04603    Preliminaries.
04604 */
04605 
04606    *rar = ra;
04607    *decr = dec;
04608 
04609    sinlat = sin (location->latitude * DEG2RAD);
04610    coslat = cos (location->latitude * DEG2RAD);
04611    sinlon = sin (location->longitude * DEG2RAD);
04612    coslon = cos (location->longitude * DEG2RAD);
04613    sindc = sin (dec * DEG2RAD);
04614    cosdc = cos (dec * DEG2RAD);
04615    sinra = sin (ra * 15.0 * DEG2RAD);
04616    cosra = cos (ra * 15.0 * DEG2RAD);
04617 
04618 /*
04619    Set up orthonormal basis vectors in local Earth-fixed system.
04620 
04621    Define vector toward local zenith in Earth-fixed system (z axis).
04622 */
04623    uze[0] = coslat * coslon;
04624    uze[1] = coslat * sinlon;
04625    uze[2] = sinlat;
04626 
04627 /*
04628    Define vector toward local north in Earth-fixed system (x axis).
04629 */
04630    
04631    une[0] = -sinlat * coslon;
04632    une[1] = -sinlat * sinlon;
04633    une[2] = coslat;
04634 
04635 /*
04636    Define vector toward local west in Earth-fixed system (y axis).
04637 */
04638 
04639    uwe[0] = sinlon;
04640    uwe[1] = -coslon;
04641    uwe[2] = 0.0;
04642 
04643 /*
04644    Obtain vectors in celestial system.
04645 
04646    Rotate Earth-fixed orthonormal basis vectors to celestial system
04647    (wrt equator and equinox of date).
04648 */
04649 
04650    pnsw (0.0,gast,x,y,uze, uz);
04651    pnsw (0.0,gast,x,y,une, un);
04652    pnsw (0.0,gast,x,y,uwe, uw);
04653 
04654 /*
04655    Define unit vector 'p' toward object in celestial system
04656    (wrt equator and equinox of date).
04657 */
04658 
04659    p[0] = cosdc * cosra;
04660    p[1] = cosdc * sinra;
04661    p[2] = sindc;
04662 
04663 /*
04664    Compute coordinates of object wrt orthonormal basis.
04665 
04666    Compute components of 'p' - projections of 'p' onto rotated
04667    Earth-fixed basis vectors.
04668 */
04669 
04670    pz = p[0] * uz[0] + p[1] * uz[1] + p[2] * uz[2];
04671    pn = p[0] * un[0] + p[1] * un[1] + p[2] * un[2];
04672    pw = p[0] * uw[0] + p[1] * uw[1] + p[2] * uw[2];
04673 
04674 /*
04675    Compute azimuth and zenith distance.
04676 */
04677 
04678    proj = sqrt (pn * pn + pw * pw);
04679 
04680    if (proj > 0.0)
04681       *az = -atan2 (pw, pn) * RAD2DEG;
04682 
04683    if (*az < 0.0)
04684       *az += 360.0;
04685 
04686    if (*az >= 360.0)
04687       *az -= 360.0;
04688 
04689    *zd = atan2 (proj, pz) * RAD2DEG;
04690 
04691 /*
04692    Apply atmospheric refraction if requested.
04693 */
04694 
04695    if (ref_option != 0)
04696    {
04697 
04698 /*
04699    Get refraction in zenith distance.
04700 
04701    Iterative process is required because refraction algorithms are
04702    always a function of observed (not computed) zenith distance.
04703    Require convergence to 0.2 arcsec (actual accuracy less).
04704 */
04705 
04706       zd0 = *zd;
04707 
04708       do
04709       {
04710          zd1 = *zd;
04711          refr = refract (location,ref_option,*zd);
04712          *zd = zd0 - refr;
04713       } while (fabs (*zd - zd1) > 5.0e-5);
04714 
04715 /*
04716    Apply refraction to celestial coordinates of object.
04717 */
04718       if ((refr > 0.0) && (*zd > 0.01))
04719       {
04720 
04721 /*
04722    Shift position vector of object in celestial system to account 
04723    for for refraction (see USNO/AA Technical Note 9).
04724 */
04725 
04726          cosr  = cos (refr * DEG2RAD);
04727          prlen = sin (zd0 * DEG2RAD) / sin (*zd * DEG2RAD);
04728          rlen  = sqrt (1.0 + prlen * prlen - 2.0 * prlen * cosr);
04729 
04730 /*
04731    Add small refraction displacement vector to 'p'.
04732 */
04733 
04734          for (j = 0; j < 3; j++)
04735             pr[j] = (p[j] + rlen * uz[j]) / prlen;
04736 
04737 /*
04738    Compute refracted right ascension and declination.
04739 */
04740 
04741          proj = sqrt (pr[0] * pr[0] + pr[1] * pr[1]);
04742 
04743          if (proj > 0.0)
04744            *rar = atan2 (pr[1],pr[0]) * RAD2DEG / 15.0;
04745 
04746          if (*rar < 0.0)
04747            *rar += 24.0;
04748 
04749          if (*rar >= 24.0)
04750            *rar -= 24.0;
04751 
04752          *decr = atan2 (pr[2],proj) * RAD2DEG;
04753       }
04754    }
04755 
04756    return;
04757 }

void fund_args ( double  t,
double  a[5] 
)

Definition at line 3256 of file novas.c.

References TWOPI.

Referenced by earthtilt(), and nutation_angles().

03262           :
03263       To compute the fundamental arguments.
03264 
03265    REFERENCES:
03266       Seidelmann, P.K. (1982) Celestial Mechanics 27, 79-106 (1980 IAU 
03267          Theory of Nutation).
03268 
03269    INPUT
03270    ARGUMENTS:
03271       t (double)
03272          TDB time in Julian centuries since J2000.0
03273 
03274    OUTPUT
03275    ARGUMENTS:
03276       a[5] (double)
03277          Fundamental arguments, in radians:
03278           a[0] = l (mean anomaly of the Moon)
03279           a[1] = l' (mean anomaly of the Sun)
03280           a[2] = F (L - omega; L = mean longitude of the Moon)
03281           a[3] = D (mean elongation of the Moon from the Sun)
03282           a[4] = omega (mean longitude of the Moon's ascending node)
03283 
03284    RETURNED
03285    VALUE:
03286       None.
03287 
03288    GLOBALS
03289    USED:
03290       TWOPI
03291 
03292    FUNCTIONS
03293    CALLED:
03294       fmod     math.h
03295 
03296    VER./DATE/
03297    PROGRAMMER:
03298       V1.0/10-97/JAB (USNO/AA)
03299       V1.1/07-98/JAB (USNO/AA): Place arguments in the range 0-TWOPI
03300                                 radians.
03301 
03302    NOTES:
03303       1. The fundamental arguments are used in computing the nutation
03304       angles and in the expression for sidereal time.
03305 
03306 ------------------------------------------------------------------------
03307 */
03308 {
03309    short int i;
03310 
03311    a[0] = 2.3555483935439407 + t * (8328.691422883896
03312                              + t * (1.517951635553957e-4
03313                              + 3.1028075591010306e-7 * t));
03314    a[1] = 6.240035939326023 + t * (628.3019560241842
03315                             + t * (-2.7973749400020225e-6
03316                             - 5.817764173314431e-8 * t));
03317    a[2] = 1.6279019339719611 + t * (8433.466158318453 
03318                              + t * (-6.427174970469119e-5
03319                              + 5.332950492204896e-8 * t));
03320    a[3] = 5.198469513579922 + t * (7771.377146170642
03321                             + t * (-3.340851076525812e-5
03322                             + 9.211459941081184e-8 * t));
03323    a[4] = 2.1824386243609943 + t * (-33.75704593375351
03324                              + t * (3.614285992671591e-5
03325                              + 3.878509448876288e-8 * t));
03326 
03327    for (i = 0; i < 5; i++)
03328    {
03329       a[i] = fmod (a[i],TWOPI);
03330       if (a[i] < 0.0)
03331          a[i] += TWOPI; 
03332    }
03333 
03334    return;
03335 }

short int get_earth ( double  tjd,
body earth,
double *  tdb,
double *  bary_earthp,
double *  bary_earthv,
double *  helio_earthp,
double *  helio_earthv 
)

Definition at line 2253 of file novas.c.

References BARYC, MuELoss::e, HELIOC, body::number, solarsystem(), and tdb2tdt().

Referenced by app_planet(), app_star(), astro_planet(), astro_star(), local_planet(), local_star(), topo_planet(), topo_star(), virtual_planet(), and virtual_star().

02261           :
02262       Obtains the barycentric & heliocentric positions and velocities
02263       of the Earth from the solar system ephemeris.
02264 
02265    REFERENCES:
02266       None.
02267 
02268    INPUT
02269    ARGUMENTS:
02270       tjd (double)
02271          TT (or TDT) Julian date.
02272       *earth (struct body)
02273          Pointer to structure containing the body designation for the
02274          Earth (defined in novas.h).
02275 
02276    OUTPUT
02277    ARGUMENTS:
02278       *tdb (double)
02279          TDB Julian date corresponding to 'tjd'.
02280       *bary_earthp (double)
02281          Barycentric position vector of Earth at 'tjd'; equatorial
02282          rectangular coordinates in AU referred to the mean equator
02283          and equinox of J2000.0.
02284       *bary_earthv (double)
02285          Barycentric velocity vector of Earth at 'tjd'; equatorial
02286          rectangular system referred to the mean equator and equinox 
02287          of J2000.0, in AU/Day.
02288       *helio_earthp (double)
02289          Heliocentric position vector of Earth at 'tjd'; equatorial
02290          rectangular coordinates in AU referred to the mean equator
02291          and equinox of J2000.0.
02292       *helio_earthv (double)
02293          Heliocentric velocity vector of Earth at 'tjd'; equatorial
02294          rectangular system referred to the mean equator and equinox
02295          of J2000.0, in AU/Day.
02296 
02297    RETURNED
02298    VALUE:
02299       (short int)
02300           0...Everything OK.
02301          >0...Error code from function 'solarsystem'.
02302 
02303    GLOBALS
02304    USED:
02305       BARYC, HELIOC
02306 
02307    FUNCTIONS
02308    CALLED:
02309       tdb2tdt             novas.c
02310       solarsystem         (user's choice)
02311       fabs                math.h
02312 
02313    VER./DATE/
02314    PROGRAMMER:
02315       V1.0/10-95/WTH (USNO/AA)
02316       V1.1/06-97/JAB (USNO/AA): Incorporate 'body' structure in input.
02317 
02318    NOTES:
02319       None.
02320 
02321 ------------------------------------------------------------------------
02322 */
02323 {
02324    short int error = 0;
02325    short int earth_num, i;
02326 
02327    static double tjd_last = 0.0;
02328    static double time1,  peb[3], veb[3], pes[3], ves[3];
02329    double dummy, secdiff;
02330 
02331 /*
02332    Compute the TDB Julian date corresponding to 'tjd'.
02333 */
02334 
02335    if (fabs (tjd - tjd_last) > 1.0e-6)
02336    {
02337       tdb2tdt (tjd, &dummy,&secdiff);
02338       time1 = tjd + secdiff / 86400.0;
02339 
02340 
02341 /*
02342    Get position and velocity of the Earth wrt barycenter of solar system
02343    and wrt center of the sun.
02344 */
02345 
02346       earth_num = earth->number;
02347 
02348 /* add extra ()'s 4/03 S. Kasahara */
02349       if ((error = solarsystem (time1,earth_num,BARYC, peb,veb)))
02350       {
02351          tjd_last = 0.0;
02352          return error;
02353       }
02354 
02355 /* add extra ()'s 4/03 S. Kasahara */
02356       if ((error = solarsystem (time1,earth_num,HELIOC, pes,ves)))
02357       {
02358          tjd_last = 0.0;
02359          return error;
02360       }
02361       tjd_last = tjd;
02362    }
02363 
02364    *tdb = time1;
02365    for (i = 0; i < 3; i++)
02366    {
02367       bary_earthp[i] = peb[i];
02368       bary_earthv[i] = veb[i];
02369       helio_earthp[i] = pes[i];
02370       helio_earthv[i] = ves[i];
02371    }
02372 
02373    return error;
02374 }

double julian_date ( short int  year,
short int  month,
short int  day,
double  hour 
)

Definition at line 4866 of file novas.c.

Referenced by AstUtil::CalendarToJulian().

04871           :
04872       This function will compute the Julian date for a given calendar
04873       date (year, month, day, hour).
04874 
04875    REFERENCES: 
04876       Fliegel & Van Flandern, Comm. of the ACM, Vol. 11, No. 10, October
04877       1968, p. 657.
04878 
04879    INPUT
04880    ARGUMENTS:
04881       year (short int)
04882          Year.
04883       month (short int)
04884          Month number.
04885       day (short int)
04886          Day-of-month.
04887       hour (double)
04888          Hour-of-day.
04889 
04890    OUTPUT
04891    ARGUMENTS:
04892       None.
04893 
04894    RETURNED
04895    VALUE:
04896       (double)
04897          Julian date.
04898 
04899    GLOBALS
04900    USED:
04901       None.
04902 
04903    FUNCTIONS
04904    CALLED:
04905       None.
04906 
04907    VER./DATE/
04908    PROGRAMMER:
04909       V1.0/06-98/JAB (USNO/AA)
04910 
04911    NOTES:
04912       1. This function is the "C" version of Fortran NOVAS routine
04913       'juldat'.
04914       2. This function makes no checks for a valid input calendar
04915       date.
04916 ------------------------------------------------------------------------
04917 */
04918 {
04919    long int jd12h;
04920 
04921    double tjd;
04922 
04923    jd12h = (long) day - 32075L + 1461L * ((long) year + 4800L
04924       + ((long) month - 14L) / 12L) / 4L
04925       + 367L * ((long) month - 2L - ((long) month - 14L) / 12L * 12L)
04926       / 12L - 3L * (((long) year + 4900L + ((long) month - 14L) / 12L)
04927       / 100L) / 4L;
04928    tjd = (double) jd12h - 0.5 + hour / 24.0;
04929 
04930    return (tjd);
04931 }

short int local_planet ( double  tjd,
body ss_object,
body earth,
double  deltat,
site_info location,
double *  ra,
double *  dec,
double *  dis 
)

Definition at line 995 of file novas.c.

References aberration(), bary_to_geo(), BARYC, MuELoss::e, earthtilt(), ephemeris(), FN1, get_earth(), nutate(), precession(), sidereal_time(), sun_field(), T0, terra(), and vector2radec().

01002           :    
01003       Computes the local place of a planet or other solar system body,
01004       given the location of the observer.
01005 
01006    REFERENCES: 
01007       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
01008          pp. 1197-1210.
01009       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
01010          Subroutines"; USNO internal document dated 20 Oct 1988;
01011          revised 15 Mar 1990.
01012 
01013    INPUT
01014    ARGUMENTS:
01015       tjd (double)
01016          TT (or TDT) Julian date for local place.
01017       *ss_object (struct body)
01018          Pointer to structure containing the body designation for the
01019          solar system body (defined in novas.h).
01020       *earth (struct body)
01021          Pointer to structure containing the body designation for the
01022          Earth (defined in novas.h).
01023       deltat (double)
01024          Difference TT(or TDT)-UT1 at 'tjd', in seconds.
01025       *location (struct site_info)
01026          Pointer to structure containing observer's location (defined
01027          in novas.h).
01028 
01029    OUTPUT
01030    ARGUMENTS:
01031       *ra (double)
01032          Local right ascension in hours, referred to mean equator and
01033          equinox of J2000.
01034       *dec (double)
01035          Local declination in degrees, referred to mean equator and
01036          equinox of J2000.
01037       *dis (double)
01038          True distance from Earth to planet in AU.
01039 
01040    RETURNED
01041    VALUE:
01042       (short int)
01043           0...Everything OK.
01044          >0...See error description in function 'ephemeris'.
01045 
01046    GLOBALS
01047    USED:
01048       T0, BARYC, FN1
01049 
01050    FUNCTIONS
01051    CALLED:
01052       get_earth       novas.c
01053       earthtilt       novas.c
01054       sidereal_time   novas.c
01055       terra           novas.c
01056       nutate          novas.c
01057       precession      novas.c
01058       bary_to_geo     novas.c
01059       sun_field       novas.c
01060       aberration      novas.c
01061       vector2radec    novas.c
01062       ephemeris       novas.c
01063       fabs            math.h
01064 
01065    VER./DATE/
01066    PROGRAMMER:
01067       V1.0/08-93/WTH (USNO/AA) Translate Fortran.
01068       V1.1/10-95/WTH (USNO/AA) Added call to 'get_earth'.
01069       V1.2/06-97/JAB (USNO/AA) Generalize ephemeris management.
01070       V1.3/12-99/JAB (USNO/AA) Fix error return from 'get_earth'.
01071 
01072    NOTES:
01073       1. This function is the "C" version of Fortran NOVAS routine
01074       'lpplan'.
01075 
01076 ------------------------------------------------------------------------
01077 */
01078 {
01079 
01080    short int error = 0;
01081    short int j;
01082 
01083    double t2 = 0.0, t3 = 0.0;
01084    double gast, lighttime, ujd, pog[3], vog[3], pb[3], vb[3], ps[3],
01085       vs[3], pos1[3], vel1[3], pos2[3], vel2[3], pos3[3], pos4[3],
01086       tdb, peb[3], veb[3], pes[3], ves[3], oblm, oblt, eqeq, psi, eps;
01087 
01088 /*
01089    Compute 'ujd', the UT1 Julian date corresponding to 'tjd'.
01090 */
01091 
01092    ujd = tjd - (deltat / 86400.0);
01093 
01094 /*
01095    Get position of Earth wrt the center of the Sun and the barycenter
01096    of solar system.
01097 */
01098 
01099 /* add extra ()'s 4/03 S. Kasahara */
01100    if ((error = get_earth (tjd,earth, &tdb,peb,veb,pes,ves)))
01101    {
01102       *ra = 0.0;
01103       *dec = 0.0;
01104       return (error + 10);
01105    }
01106 
01107    earthtilt (tdb, &oblm,&oblt,&eqeq,&psi,&eps);
01108 
01109 /*
01110    Get position and velocity of observer wrt center of the Earth.
01111 */
01112 
01113    sidereal_time (ujd,0.0,eqeq, &gast);
01114    terra (location,gast, pos1,vel1);
01115    nutate (tdb,FN1,pos1, pos2);
01116    precession (tdb,pos2,T0, pog);
01117    nutate(tdb,FN1,vel1, vel2);
01118    precession (tdb,vel2,T0, vog);
01119 
01120 /*
01121    Get position and velocity of observer wrt barycenter of solar system
01122    and wrt center of the sun.
01123 */
01124 
01125    for (j = 0; j < 3; j++)
01126    {
01127       pb[j] = peb[j] + pog[j];
01128       vb[j] = veb[j] + vog[j];
01129       ps[j] = pes[j] + pog[j];
01130       vs[j] = ves[j] + vog[j];
01131    }
01132 
01133 /*
01134    Get position of planet wrt barycenter of solar system.
01135 */
01136 
01137 /* add extra ()'s 4/03 S. Kasahara */
01138    if ((error = ephemeris (tdb,ss_object,BARYC, pos1,vel1)))
01139    {
01140       *ra= 0.0;
01141       *dec = 0.0;
01142       *dis = 0.0;
01143       return error;
01144    }
01145    bary_to_geo (pos1,pb, pos2,&lighttime);
01146 
01147    *dis = lighttime * C;
01148    t3 = tdb - lighttime;
01149 
01150    do
01151    {
01152       t2 = t3;
01153 /* add extra ()'s 4/03 S. Kasahara */
01154       if ((error = ephemeris (t2,ss_object,BARYC, pos1,vel1)))
01155       {
01156          *ra = 0.0;
01157          *dec = 0.0;
01158          return error;
01159       }
01160       bary_to_geo (pos1,pb, pos2,&lighttime);
01161       t3 = tdb - lighttime;
01162    } while (fabs (t3 - t2) > 1.0e-8);
01163 
01164 /*
01165    Finish local place computation.
01166 */
01167 
01168    sun_field (pos2,ps, pos3);
01169    aberration (pos3,vb,lighttime, pos4);
01170    vector2radec (pos4, ra,dec);
01171 
01172    return 0;
01173 }

short int local_star ( double  tjd,
body earth,
double  deltat,
cat_entry star,
site_info location,
double *  ra,
double *  dec 
)

Definition at line 852 of file novas.c.

References aberration(), bary_to_geo(), earthtilt(), FN1, get_earth(), nutate(), precession(), proper_motion(), sidereal_time(), starvectors(), sun_field(), T0, terra(), and vector2radec().

00859           :    
00860       Computes the local place of a star, given its mean place, proper
00861       motion, parallax, and radial velocity for J2000.0, and the
00862       location of the observer.
00863 
00864    REFERENCES: 
00865       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
00866          pp. 1197-1210.
00867       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
00868          Subroutines"; USNO internal document dated 20 Oct 1988;
00869          revised 15 Mar 1990.
00870 
00871    INPUT
00872    ARGUMENTS:
00873       tjd (double)
00874          TT (or TDT) Julian date for local place.
00875       *earth (struct body)
00876          Pointer to structure containing the body designation for the
00877          Earth (defined in novas.h).
00878       deltat (double)
00879          Difference TT(or TDT)-UT1 at 'tjd', in seconds.
00880       *star (struct cat_entry)
00881          Pointer to catalog entry structure containing J2000.0 catalog
00882          data with FK5-style units (defined in novas.h).
00883       *location (struct site_info)
00884          Pointer to structure containing observer's location (defined
00885          in novas.h).
00886 
00887    OUTPUT
00888    ARGUMENTS:
00889       *ra (double)
00890          Local right ascension in hours, referred to mean equator and
00891          equinox of J2000.
00892       *dec (double)
00893          Local declination in degrees, referred to mean equator and
00894          equinox of J2000.
00895 
00896    RETURNED
00897    VALUE:
00898       (short int)
00899           0...Everything OK.
00900          >0...Error code from function 'solarsystem'.
00901 
00902    GLOBALS
00903    USED:
00904       T0, FN1
00905 
00906    FUNCTIONS
00907    CALLED:
00908       get_earth        novas.c
00909       earthtilt        novas.c
00910       sidereal_time    novas.c
00911       terra            novas.c
00912       nutate           novas.c
00913       precession       novas.c
00914       starvectors      novas.c
00915       proper_motion    novas.c
00916       bary_to_geo      novas.c
00917       sun_field        novas.c
00918       aberration       novas.c
00919       vector2radec     novas.c
00920 
00921    VER./DATE/
00922    PROGRAMMER:
00923       V1.0/08-93/WTH (USNO/AA) Translate Fortran.
00924       V1.1/10-95/WTH (USNO/AA) Added call to 'get_earth'.
00925       V1.3/06-97/JAB (USNO/AA) Incorporate 'body' structure in input.
00926 
00927    NOTES:
00928       1. This function is the "C" version of Fortran NOVAS routine
00929       'lpstar'.
00930 
00931 ------------------------------------------------------------------------
00932 */
00933 {
00934    short int error = 0;
00935    short int j;
00936 
00937    double gast, lighttime, ujd, pog[3], vog[3], pb[3], vb[3], ps[3],
00938       vs[3], pos1[3], vel1[3], pos2[3], vel2[3], pos3[3], pos4[3],
00939       pos5[3], tdb, peb[3], veb[3], pes[3], ves[3], oblm, oblt, eqeq,
00940       psi, eps;
00941 
00942 /*
00943    Compute 'ujd', the UT1 Julian date corresponding to 'tjd'.
00944 */
00945 
00946    ujd = tjd - (deltat / 86400.0);
00947 
00948 /*
00949    Get position and velocity of observer wrt barycenter of solar system
00950    and wrt center of the sun.
00951 */
00952 
00953 /* add extra ()'s 4/03 S. Kasahara */
00954    if ((error = get_earth (tjd,earth, &tdb,peb,veb,pes,ves)))
00955    {
00956       *ra = 0.0;
00957       *dec = 0.0;
00958       return error;
00959    }
00960 
00961    earthtilt (tdb, &oblm,&oblt,&eqeq,&psi,&eps);
00962 
00963    sidereal_time (ujd,0.0,eqeq, &gast);
00964    terra (location,gast, pos1,vel1);
00965    nutate (tdb,FN1,pos1, pos2);
00966    precession (tdb,pos2,T0, pog);
00967    nutate (tdb,FN1,vel1, vel2);
00968    precession (tdb,vel2,T0, vog);
00969 
00970    for (j = 0; j < 3; j++)
00971    {
00972       pb[j] = peb[j] + pog[j];
00973       vb[j] = veb[j] + vog[j];
00974       ps[j] = pes[j] + pog[j];
00975       vs[j] = ves[j] + vog[j];
00976    }
00977 
00978 /*
00979    Compute local place.
00980 */
00981 
00982    starvectors (star, pos1,vel1);
00983    proper_motion (T0,pos1,vel1,tdb, pos2);
00984    bary_to_geo (pos2,pb, pos3,&lighttime);
00985    sun_field (pos3,ps, pos4);
00986    aberration (pos4,vb,lighttime, pos5);
00987 
00988    vector2radec (pos5, ra,dec);
00989 
00990    return 0;
00991 }

void make_cat_entry ( char  catalog[4],
char  star_name[51],
long int  star_num,
double  ra,
double  dec,
double  pm_ra,
double  pm_dec,
double  parallax,
double  rad_vel,
cat_entry star 
)

Definition at line 4004 of file novas.c.

References cat_entry::catalog, cat_entry::dec, cat_entry::parallax, cat_entry::promodec, cat_entry::promora, cat_entry::ra, cat_entry::radialvelocity, cat_entry::starname, and cat_entry::starnumber.

04013           :
04014       To create a structure of type 'cat_entry' containing catalog
04015       data for a star or "star-like" object.
04016 
04017    REFERENCES:
04018       None.
04019 
04020    INPUT
04021    ARGUMENTS:
04022       catalog[4] (char)
04023          Three-character catalog identifier (e.g. HIP = Hipparcos, FK5 =
04024          FK5).  This identifier also specifies the reference system
04025          and units of the data; i.e. they are the same as the
04026          specified catalog.
04027       star_name[51] (char)
04028          Object name (50 characters maximum).
04029       star_num (long int)
04030          Object number in the catalog.
04031       ra (double)
04032          Right ascension of the object.
04033       dec (double)
04034          Declination of the object.
04035       pm_ra (double)
04036          Proper motion in right ascension.
04037       pm_dec (double)
04038          Proper motion in declination.
04039       parallax (double)
04040          Parallax.
04041       rad_vel (double)
04042          Radial velocity.
04043 
04044    OUTPUT
04045    ARGUMENTS:
04046       *star (struct cat_entry)
04047          Structure containing the input data (structure defined in
04048          novas.h).
04049 
04050    RETURNED
04051    VALUE:
04052       None.
04053 
04054    GLOBALS
04055    USED:
04056       None.
04057 
04058    FUNCTIONS
04059    CALLED:
04060       None.
04061 
04062    VER./DATE/
04063    PROGRAMMER:
04064       V1.0/03-98/JAB (USNO/AA)
04065 
04066    NOTES:
04067       1. This utility function simply creates a single data structure 
04068       encapsulating the input data.  The units, etc. of the data can be
04069       arbitrary, but are defined by the catalog to which the data
04070       belongs.
04071 
04072 ------------------------------------------------------------------------
04073 */
04074 {
04075    short int i;
04076 
04077    for (i = 0; i < 4; i++)
04078    {
04079       star->catalog[i] = catalog[i];
04080       if (catalog[i] == '\0')
04081          break;
04082    }
04083    star->catalog[i] = '\0';
04084 
04085    for (i = 0; i < 51; i++)
04086    {
04087       star->starname[i] = star_name[i];
04088       if (star_name[i] == '\0')
04089          break;
04090    }
04091    star->starname[i] = '\0';
04092 
04093    star->starnumber = star_num;
04094    star->ra = ra;
04095    star->dec = dec;
04096    star->promora = pm_ra;
04097    star->promodec = pm_dec;
04098    star->parallax = parallax;
04099    star->radialvelocity = rad_vel;
04100 
04101    return;
04102 }

short int mean_star ( double  tjd,
body earth,
double  ra,
double  dec,
double *  mra,
double *  mdec 
)

Definition at line 1410 of file novas.c.

References app_star(), cat_entry::dec, MuELoss::e, and cat_entry::ra.

01416           :    
01417       Computes the mean place of a star for J2000.0, given its apparent
01418       place at date 'tjd'.  Proper motion, parallax and radial velocity
01419       are assumed to be zero.
01420 
01421    REFERENCES: 
01422       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
01423          pp. 1197-1210.
01424       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
01425          Subroutines"; USNO internal document dated 20 Oct 1988;
01426          revised 15 Mar 1990.
01427 
01428    INPUT
01429    ARGUMENTS:
01430       tjd (double)
01431          TT (or TDT) Julian date of apparent place.
01432       *earth (struct body)
01433          Pointer to structure containing the body designation for the
01434          Earth (defined in novas.h).
01435       ra (double)
01436          Apparent right ascension in hours, referred to true equator
01437          and equinox of date 'tjd'.
01438       dec (double)
01439          Apparent declination in degrees, referred to true equator
01440          and equinox of date 'tjd'.
01441 
01442    OUTPUT
01443    ARGUMENTS:
01444       *mra (double)
01445          Mean right ascension J2000.0 in hours.
01446       *mdec (double)
01447          Mean declination J2000.0 in degrees.
01448 
01449    RETURNED
01450    VALUE:
01451       (short int)
01452            0...Everything OK.
01453            1...Iterative process did not converge after 20 iterations.
01454          >10...Error from function 'app_star'.
01455 
01456    GLOBALS
01457    USED:
01458       None.
01459 
01460    FUNCTIONS
01461    CALLED:
01462       app_star     novas.c
01463       fmod         math.h
01464       fabs         math.h
01465 
01466    VER./DATE/
01467    PROGRAMMER:
01468       V1.0/08-93/WTH (USNO/AA) Translate Fortran.
01469       V1.2/06-97/JAB (USNO/AA) Incorporate 'body' structure in input.
01470 
01471    NOTES:
01472       1. This function is the "C" version of Fortran NOVAS routine
01473       'mpstar'.
01474 
01475 ------------------------------------------------------------------------
01476 */
01477 {
01478    short int iter = 0, error = 0;
01479 
01480    double newmra, newdec, oldmra, olddec, ra2, dec2, deltara, deltadec;
01481 
01482    cat_entry tempstar = {"CAT","dummy",0,0.0,0.0,0.0,0.0,0.0,0.0};
01483 
01484    newmra = fmod (ra,24.0);
01485    if (newmra < 0.0) 
01486       newmra += 24.0;
01487    newdec = dec;
01488 
01489    do
01490    {
01491       oldmra = newmra;
01492       olddec = newdec;
01493       tempstar.ra = oldmra;
01494       tempstar.dec = olddec;
01495 /* add extra ()'s 4/03 S. Kasahara */
01496       if ((error = app_star (tjd,earth,&tempstar, &ra2,&dec2)))
01497       {
01498          *mra = 0.0;
01499          *mdec = 0.0;
01500          return (error + 10);
01501       }
01502       deltara = ra2 - oldmra;
01503       deltadec = dec2 - olddec;
01504       if (deltara < -12.0)
01505          deltara += 24.0;
01506       if (deltara > 12.0)
01507          deltara -= 24.0;
01508       newmra = ra - deltara;
01509       newdec = dec - deltadec;
01510 
01511       if (iter >= 20)
01512       {
01513          *mra = 0.0;
01514          *mdec = 0.0;
01515          return 1;
01516       }
01517        else
01518          iter++;
01519 
01520    } while ((fabs (newmra - oldmra) > 1.0e-10) && 
01521             (fabs (newdec - olddec) > 1.0e-9));
01522 
01523    *mra = newmra;
01524    *mdec = newdec;
01525    if (*mra < 0.0) 
01526       *mra += 24.0;
01527    if (*mra >= 24.0) 
01528       *mra -= 24.0;
01529 
01530    return 0;
01531 }

short int nutate ( double  tjd,
short int  fn1,
double *  pos,
double *  pos2 
)

Definition at line 2922 of file novas.c.

References DEG2RAD, earthtilt(), and RAD2SEC.

Referenced by app_planet(), app_star(), local_planet(), local_star(), pnsw(), topo_planet(), and topo_star().

02928           :    
02929       Nutates equatorial rectangular coordinates from mean equator and
02930       equinox of epoch to true equator and equinox of epoch. Inverse
02931       transformation may be applied by setting flag 'fn'.
02932 
02933    REFERENCES: 
02934       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
02935          pp. 1197-1210.
02936       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
02937          Subroutines"; USNO internal document dated 20 Oct 1988;
02938          revised 15 Mar 1990.
02939 
02940    INPUT
02941    ARGUMENTS:
02942       tdb (double)
02943          TDB julian date of epoch.
02944       fn (short int)
02945          Flag determining 'direction' of transformation;
02946             fn  = 0 transformation applied, mean to true.
02947             fn != 0 inverse transformation applied, true to mean.
02948       pos[3] (double)
02949          Position vector, geocentric equatorial rectangular coordinates,
02950          referred to mean equator and equinox of epoch.
02951 
02952    OUTPUT
02953    ARGUMENTS:
02954       pos2[3] (double)
02955          Position vector, geocentric equatorial rectangular coordinates,
02956          referred to true equator and equinox of epoch.
02957 
02958    RETURNED
02959    VALUE:
02960       (short int)
02961          0...Everything OK.
02962 
02963    GLOBALS
02964    USED:
02965       DEG2RAD, RAD2SEC
02966 
02967    FUNCTIONS
02968    CALLED:
02969       earthtilt     novas.c
02970       cos           math.h
02971       sin           math.h
02972 
02973    VER./DATE/
02974    PROGRAMMER:
02975       V1.0/01-93/TKB (USNO/NRL Optical Interfer.) Translate Fortran.
02976       V1.1/08-93/WTH (USNO/AA) Update to C Standards.
02977 
02978    NOTES:
02979       1. This function is the "C" version of Fortran NOVAS routine
02980       'nutate'.
02981 
02982 ------------------------------------------------------------------------
02983 */
02984 {
02985    double cobm, sobm, cobt, sobt, cpsi, spsi, xx, yx, zx, xy, yy, zy,
02986       xz, yz, zz, oblm, oblt, eqeq, psi, eps;
02987 
02988    earthtilt (tjd, &oblm,&oblt,&eqeq,&psi,&eps);
02989 
02990    cobm = cos (oblm * DEG2RAD);
02991    sobm = sin (oblm * DEG2RAD);
02992    cobt = cos (oblt * DEG2RAD);
02993    sobt = sin (oblt * DEG2RAD);
02994    cpsi = cos (psi / RAD2SEC);
02995    spsi = sin (psi / RAD2SEC);
02996 
02997 /*
02998    Nutation rotation matrix follows.
02999 */
03000 
03001    xx = cpsi;
03002    yx = -spsi * cobm;
03003    zx = -spsi * sobm;
03004    xy = spsi * cobt;
03005    yy = cpsi * cobm * cobt + sobm * sobt;
03006    zy = cpsi * sobm * cobt - cobm * sobt;
03007    xz = spsi * sobt;
03008    yz = cpsi * cobm * sobt - sobm * cobt;
03009    zz = cpsi * sobm * sobt + cobm * cobt;
03010 
03011    if (!fn)
03012    {
03013 
03014 /*
03015    Perform rotation.
03016 */
03017 
03018       pos2[0] = xx * pos[0] + yx * pos[1] + zx * pos[2];
03019       pos2[1] = xy * pos[0] + yy * pos[1] + zy * pos[2];
03020       pos2[2] = xz * pos[0] + yz * pos[1] + zz * pos[2];
03021    }
03022     else
03023    {
03024 
03025 /*
03026    Perform inverse rotation.
03027 */
03028 
03029       pos2[0] = xx * pos[0] + xy * pos[1] + xz * pos[2];
03030       pos2[1] = yx * pos[0] + yy * pos[1] + yz * pos[2];
03031       pos2[2] = zx * pos[0] + zy * pos[1] + zz * pos[2];
03032    }
03033 
03034    return 0;
03035 }

short int nutation_angles ( double  tdbtime,
double *  longnutation,
double *  obliqnutation 
)

Definition at line 3039 of file novas.c.

References MuELoss::a, Anp::angle(), and fund_args().

Referenced by earthtilt().

03045           :    
03046       Provides fast evaluation of the nutation components according to
03047       the 1980 IAU Theory of Nutation.
03048 
03049    REFERENCES: 
03050       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
03051          pp. 1197-1210, and references therein.
03052       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
03053          Subroutines"; USNO internal document dated 20 Oct 1988;
03054          revised 15 Mar 1990.
03055       Miller, B. R. (1989). Proceedings of the ACM-SIGSAM International
03056          Symposium on Symbolic and Algebraic Computation; pp. 199-206.
03057 
03058    INPUT
03059    ARGUMENTS:
03060       t (double)
03061          TDB time in Julian centuries since J2000.0
03062 
03063    OUTPUT
03064    ARGUMENTS:
03065       *longnutation (double)
03066          Nutation in longitude in arcseconds.
03067       *obliqnutation (double)
03068          Nutation in obliquity in arcseconds.
03069 
03070    RETURNED
03071    VALUE:
03072       (short int)
03073          0...Everything OK.
03074 
03075    GLOBALS
03076    USED:
03077       None.
03078 
03079    FUNCTIONS
03080    CALLED:
03081       fund_args         novas.c
03082       sin               math.h
03083       cos               math.h
03084 
03085    VER./DATE/
03086    PROGRAMMER:
03087       V1.0/11-88/BRM (NIST)
03088       V1.1/08-93/WTH (USNO/AA): Translate Fortran.
03089       V1.2/10-97/JAB (USNO/AA): Add function to compute arguments.
03090 
03091    NOTES:
03092       1. This function is based on computer-generated Fortran code.
03093       Original Fortran code generated on 11/29/88 16:35:35 at the
03094       National Institutes of Standards and Technology (NIST), by 
03095       Bruce R. Miller.
03096       2. This function is the "C" version of Fortran NOVAS routine
03097       'nod', member 'vanut1f'.
03098 
03099 ------------------------------------------------------------------------
03100 */
03101 {
03102    double clng[106] = {1.0,   1.0,  -1.0, -1.0,   1.0,  -1.0,  -1.0,
03103                       -1.0,  -1.0,  -1.0, -1.0,   1.0,  -1.0,   1.0,
03104                       -1.0,   1.0,   1.0, -1.0,  -1.0,   1.0,   1.0,
03105                       -1.0,   1.0,  -1.0,  1.0,  -1.0,  -1.0,  -1.0,
03106                        1.0,  -1.0,  -1.0,  1.0,  -1.0,   1.0,   2.0,
03107                        2.0,   2.0,   2.0,  2.0,  -2.0,   2.0,   2.0,
03108                        2.0,   3.0,  -3.0, -3.0,   3.0,  -3.0,   3.0,
03109                       -3.0,   3.0,   4.0,  4.0,  -4.0,  -4.0,   4.0,
03110                       -4.0,   5.0,   5.0,  5.0,  -5.0,   6.0,   6.0,
03111                        6.0,  -6.0,   6.0, -7.0,   7.0,   7.0,  -7.0,
03112                       -8.0,  10.0,  11.0, 12.0, -13.0, -15.0, -16.0,
03113                      -16.0,  17.0, -21.0,-22.0,  26.0,  29.0,  29.0,
03114                      -31.0, -38.0, -46.0, 48.0, -51.0,  58.0,  59.0,
03115                       63.0,  63.0,-123.0,129.0,-158.0,-217.0,-301.0,
03116                     -386.0,-517.0, 712.0,1426.0,2062.0,-2274.0,
03117                   -13187.0,-171996.0},
03118       clngx[14]={ 0.1,-0.1,0.1,0.1,0.1,0.1,0.2,-0.2,-0.4,0.5,1.2,
03119                  -1.6,-3.4,-174.2},
03120        cobl[64]={    1.0,    1.0,    1.0,   -1.0,   -1.0,   -1.0,
03121                      1.0,    1.0,    1.0,    1.0,    1.0,   -1.0,
03122                      1.0,   -1.0,    1.0,   -1.0,   -1.0,   -1.0,
03123                      1.0,   -1.0,    1.0,    1.0,   -1.0,   -2.0,
03124                     -2.0,   -2.0,    3.0,    3.0,   -3.0,    3.0,
03125                      3.0,   -3.0,    3.0,    3.0,   -3.0,    3.0,
03126                      3.0,    5.0,    6.0,    7.0,   -7.0,    7.0,
03127                     -8.0,    9.0,  -10.0,  -12.0,   13.0,   16.0,
03128                    -24.0,   26.0,   27.0,   32.0,  -33.0,  -53.0,
03129                     54.0,  -70.0,  -95.0,  129.0,  200.0,  224.0,
03130                   -895.0,  977.0, 5736.0,92025.0},
03131        coblx[8]={ -0.1, -0.1,  0.3,  0.5, -0.5, -0.6, -3.1,  8.9};
03132 
03133    short int i, ii, i1, i2, iop;
03134    short int nav1[10]={0,0,1,0,2,1,3,0,4,0},
03135        nav2[10]={ 0, 0, 0, 5, 1, 1, 3, 3, 4, 4},
03136        nav[183]={ 2, 0, 1, 1, 5, 2, 2, 0, 2, 1, 0, 3, 2, 5, 8, 1,17, 8,
03137                   1,18, 0, 2, 0, 8, 0, 1, 3, 2, 1, 8, 0,17, 1, 1,15, 1,
03138                   2,21, 1, 1, 2, 8, 2, 0,29, 1,21, 2, 2, 1,29, 2, 0, 9,
03139                   2, 5, 4, 2, 0, 4, 0, 1, 9, 2, 1, 4, 0, 2, 9, 2, 2, 4,
03140                   1,14,44, 2, 0,45, 2, 5,44, 2,50, 0, 1,36, 2, 2, 5,45,
03141                   1,37, 2, 2, 1,45, 2, 1,44, 2,53, 1, 2, 8, 4, 1,40, 3,
03142                   2,17, 4, 2, 0,64, 1,39, 8, 2,27, 4, 1,50,18, 1,21,47,
03143                   2,44, 3, 2,44, 8, 2,45, 8, 1,46, 8, 0,67, 2, 1, 5,74,
03144                   1, 0,74, 2,50, 8, 1, 5,78, 2,17,53, 2,53, 8, 2, 0,80,
03145                   2, 0,81, 0, 7,79, 1, 7,81, 2, 1,81, 2,24,44, 1, 1,79,
03146                   2,27,44},
03147       llng[106]={ 57, 25, 82, 34, 41, 66, 33, 36, 19, 88, 18,104, 93,
03148                   84, 47, 28, 83, 86, 69, 75, 89, 30, 58, 73, 46, 77,
03149                   23, 32, 59, 72, 31, 16, 74, 22, 98, 38, 62, 96, 37,
03150                   35,  6, 76, 85, 51, 26, 10, 13, 63,105, 52,102, 67,
03151                   99, 15, 24, 14,  3,100, 65, 11, 55, 68, 20, 87, 64,
03152                   95, 27, 60, 61, 80, 91, 94, 12, 43, 71, 42, 97, 70,
03153                    7, 49, 29,  2,  5, 92, 50, 78, 56, 17, 48, 40, 90,
03154                    8, 39, 54, 81, 21,103, 53, 45,101,  0,  1,  9, 44,
03155                   79,  4},
03156       llngx[14]={ 81, 7, 97, 0, 39, 40, 9, 44, 45,103,101, 79, 1, 4},
03157       lobl[64]={  51, 98, 17, 21,  5,  2, 63,105, 38, 52,102, 62, 96,
03158                   37, 35, 76, 36, 88, 85,104, 93, 84, 83, 67, 99,  8,
03159                   68,100, 60, 61, 91, 87, 64, 80, 95, 65, 55, 94, 43,
03160                   97,  0, 71, 70, 42, 49, 92, 50, 78, 56, 90, 48, 40,
03161                   39, 54,  1, 81,103, 53, 45,101,  9, 44, 79,  4},
03162       loblx[8] ={ 53,  1,103,  9, 44,101, 79,  4};
03163 
03164    double a[5], angle, cc, ss1, cs, sc, c[106], s[106], lng, lngx, obl,
03165       oblx;
03166 
03167 /*
03168    Compute the arguments of the nutation series in radians.
03169 */
03170 
03171    fund_args (t, a);
03172 
03173 /*
03174    Evaluate the series.
03175 */
03176 
03177    i = 0;
03178    for (ii = 0; ii < 10; ii += 2)
03179    {
03180       angle = a[nav1[ii]] * (double) (nav1[1+ii]+1);
03181       c[i] = cos (angle);
03182       s[i] = sin (angle);
03183       i += 1;
03184    }
03185 
03186    i = 5;
03187    for (ii = 0; ii < 10; ii += 2)
03188    {
03189       i1 = nav2[ii];
03190       i2 = nav2[1+ii];
03191 
03192       c[i] = c[i1] * c[i2] - s[i1] * s[i2];
03193       s[i] = s[i1] * c[i2] + c[i1] * s[i2];
03194       i += 1;
03195    }
03196 
03197    i = 10;
03198    for (ii = 0; ii < 183; ii += 3)
03199    {
03200       iop = nav[ii];
03201       i1 = nav[1+ii];
03202       i2 = nav[2+ii];
03203       switch (iop)
03204       {
03205          case 0:
03206             c[i] = c[i1] * c[i2] - s[i1] * s[i2];
03207             s[i] = s[i1] * c[i2] + c[i1] * s[i2];
03208             i += 1;
03209             break;
03210          case 1:
03211             c[i] = c[i1] * c[i2] + s[i1] * s[i2];
03212             s[i] = s[i1] * c[i2] - c[i1] * s[i2];
03213             i += 1;
03214             break;
03215          case 2:
03216             cc = c[i1] * c[i2];
03217             ss1 = s[i1] * s[i2];
03218             sc = s[i1] * c[i2];
03219             cs = c[i1] * s[i2];
03220             c[i] = cc - ss1;
03221             s[i] = sc + cs;
03222             i += 1;
03223             c[i] = cc + ss1;
03224             s[i] = sc - cs;
03225             i += 1;
03226             break;
03227       }
03228       if (iop == 3)
03229          break;
03230    }
03231 
03232    lng = 0.0;
03233    for (i = 0; i < 106; i++)
03234       lng += clng[i] * s[llng[i]];
03235 
03236    lngx = 0.0;
03237    for (i = 0; i < 14; i++)
03238       lngx += clngx[i] * s[llngx[i]];
03239 
03240    obl = 0.0;
03241    for (i = 0; i < 64; i++)
03242       obl += cobl[i] * c[lobl[i]];
03243 
03244    oblx = 0.0;
03245    for (i = 0; i < 8; i++)
03246       oblx += coblx[i] * c[loblx[i]];
03247 
03248    *longnutation = (lng + t * lngx) / 10000.0;
03249    *obliqnutation = (obl + t * oblx) / 10000.0;
03250 
03251    return 0;
03252 }

void pnsw ( double  tjd,
double  gast,
double  x,
double  y,
double *  vece,
double *  vecs 
)

Definition at line 1620 of file novas.c.

References FN1, nutate(), precession(), spin(), T0, tdb2tdt(), and wobble().

Referenced by equ2hor().

01626           :    
01627       Transforms a vector from an Earth-fixed geographic system to a
01628       space-fixed system based on mean equator and equinox of J2000.0;
01629       applies rotations for wobble, spin, nutation, and precession.
01630 
01631    REFERENCES: 
01632       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
01633          pp. 1197-1210.
01634       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
01635          Subroutines"; USNO internal document dated 20 Oct 1988;
01636          revised 15 Mar 1990.
01637 
01638    INPUT
01639    ARGUMENTS:
01640       tjd (double)
01641          TT (or TDT) Julian date
01642       gast (double)
01643          Greenwich apparent sidereal time, in hours.
01644       x (double)
01645          Conventionally-defined X coordinate of rotational pole with
01646          respect to CIO, in arcseconds.
01647       y (double)
01648          Conventionally-defined Y coordinate of rotational pole with
01649          respect to CIO, in arcseconds.
01650       vece[3] (double)
01651          Vector in geocentric rectangular Earth-fixed system,
01652          referred to geographic equator and Greenwich meridian.
01653 
01654    OUTPUT
01655    ARGUMENTS:
01656       vecs[3] (double)
01657          Vector in geocentric rectangular space-fixed system,
01658          referred to mean equator and equinox of J2000.0.
01659 
01660    RETURNED
01661    VALUE:
01662       None.
01663 
01664    GLOBALS
01665    USED:
01666       T0, FN0
01667 
01668    FUNCTIONS
01669    CALLED:
01670       tdb2tdt           novas.c
01671       wobble            novas.c
01672       spin              novas.c
01673       nutate            novas.c
01674       precession        novas.c
01675 
01676    VER./DATE/
01677    PROGRAMMER:
01678       V1.0/08-93/WTH (USNO/AA) Translate Fortran.
01679 
01680    NOTES:
01681       1. This function is the "C" version of Fortran NOVAS routine
01682       'pnsw'.
01683       2. 'tjd' = 0 means no precession/nutation transformation.
01684       3. 'gast' = 0 means no spin transformation.
01685       4. 'x' = 'y' = 0 means no wobble transformation.
01686 
01687 ------------------------------------------------------------------------
01688 */
01689 {
01690    double dummy, secdiff, v1[3], v2[3], v3[3], tdb = 0;
01691 
01692    short int j;
01693 
01694 /*
01695    Compute 'tdb', the TDB Julian date corresponding to 'tjd'.
01696 */
01697 
01698    if (tjd != 0.0)
01699    {
01700       tdb2tdt (tjd, &dummy,&secdiff);
01701       tdb = tjd + secdiff / 86400.0;
01702    }
01703 
01704    if ((x == 0.0) && (y == 0.0))
01705    {
01706       for (j = 0; j < 3; j++)
01707          v1[j] = vece[j];
01708    }
01709     else
01710       wobble (x,y,vece, v1);
01711 
01712    if (gast == 0.0)
01713    {
01714       for (j = 0; j < 3; j++)
01715          v2[j] = v1[j];
01716    }
01717     else
01718       spin (gast,v1, v2);
01719 
01720    if (tjd == 0.0)
01721    {
01722       for (j = 0; j < 3; j++)
01723          vecs[j] = v2[j];
01724    }
01725     else
01726    {
01727       nutate (tdb,FN1,v2, v3);
01728       precession (tdb,v3,T0, vecs);
01729    }
01730 
01731    return;
01732 }

void precession ( double  tjd1,
double *  pos,
double  tjd2,
double *  pos2 
)

Definition at line 2787 of file novas.c.

References RAD2SEC, and T0.

Referenced by app_planet(), app_star(), local_planet(), local_star(), pnsw(), solarsystem(), topo_planet(), topo_star(), and transform_cat().

02793           :    
02794       Precesses equatorial rectangular coordinates from one epoch to
02795       another.  The coordinates are referred to the mean equator and
02796       equinox of the two respective epochs.
02797 
02798    REFERENCES:
02799       Explanatory Supplement to AE and AENA (1961); pp. 30-34.
02800       Lieske, J., et al. (1977). Astron. & Astrophys. 58, 1-16. 
02801       Lieske, J. (1979). Astron. & Astrophys. 73, 282-284. 
02802       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
02803          pp. 1197-1210.
02804       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
02805          Subroutines"; USNO internal document dated 20 Oct 1988;
02806          revised 15 Mar 1990.
02807 
02808    INPUT
02809    ARGUMENTS:
02810       tjd1 (double)
02811          TDB Julian date of first epoch.
02812       pos[3] (double)
02813          Position vector, geocentric equatorial rectangular coordinates,
02814          referred to mean equator and equinox of first epoch.
02815       tjd2 (double)
02816          TDB Julian date of second epoch.
02817 
02818    OUTPUT
02819    ARGUMENTS:
02820       pos2[3] (double)
02821          Position vector, geocentric equatorial rectangular coordinates,
02822          referred to mean equator and equinox of second epoch.
02823 
02824    RETURNED
02825    VALUE:
02826       None.
02827 
02828    GLOBALS
02829    USED:
02830       T0, RAD2SEC
02831 
02832    FUNCTIONS
02833    CALLED:
02834       sin    math.h
02835       cos    math.h
02836 
02837    VER./DATE/
02838    PROGRAMMER:
02839       V1.0/01-93/TKB (USNO/NRL Optical Interfer.) Translate Fortran.
02840       V1.1/08-93/WTH (USNO/AA) Update to C Standards.
02841       V1.2/03-98/JAB (USNO/AA) Change function type from 'short int' to
02842                                'void'.
02843       V1.3/12-99/JAB (USNO/AA) Precompute trig terms for greater 
02844                                efficiency.
02845 
02846    NOTES:
02847       1. This function is the "C" version of Fortran NOVAS routine
02848       'preces'.
02849 
02850 ------------------------------------------------------------------------
02851 */
02852 {
02853    double xx, yx, zx, xy, yy, zy, xz, yz, zz, t, t1, t02, t2, t3,
02854       zeta0, zee, theta, cz0, sz0, ct, st, cz, sz;
02855 
02856 /*
02857    't' and 't1' below correspond to Lieske's "big T" and "little t".
02858 */
02859 
02860    t = (tjd1 - T0) / 36525.0;
02861    t1 = (tjd2 - tjd1) / 36525.0;
02862    t02 = t * t;
02863    t2 = t1 * t1;
02864    t3 = t2 * t1;
02865 
02866 /*
02867    'zeta0', 'zee', 'theta' below correspond to Lieske's "zeta-sub-a",
02868    "z-sub-a", and "theta-sub-a".
02869 */
02870 
02871    zeta0 = (2306.2181 + 1.39656 * t - 0.000139 * t02) * t1
02872          + (0.30188 - 0.000344 * t) * t2 + 0.017998 * t3;
02873 
02874    zee = (2306.2181 + 1.39656 * t - 0.000139 * t02) * t1
02875        + (1.09468 + 0.000066 * t) * t2 + 0.018203 * t3;
02876 
02877    theta = (2004.3109 - 0.85330 * t - 0.000217 * t02) * t1
02878          + (-0.42665 - 0.000217 * t) * t2 - 0.041833 * t3;
02879 
02880    zeta0 /= RAD2SEC;
02881    zee /= RAD2SEC;
02882    theta /= RAD2SEC;
02883 
02884 /*
02885    Precalculate trig terms.
02886 */
02887 
02888    cz0 = cos (zeta0);
02889    sz0 = sin (zeta0);
02890    ct = cos (theta);
02891    st = sin (theta);
02892    cz = cos (zee);
02893    sz = sin (zee);
02894 
02895 /*
02896    Precession rotation matrix follows.
02897 */
02898 
02899    xx =  cz0 * ct * cz - sz0 * sz;
02900    yx = -sz0 * ct * cz - cz0 * sz;
02901    zx = -st * cz;
02902    xy = cz0 * ct * sz + sz0 * cz;
02903    yy = -sz0 * ct * sz + cz0 * cz;
02904    zy = -st * sz;
02905    xz = cz0 * st;
02906    yz = -sz0 * st;
02907    zz = ct;
02908 
02909 /*
02910    Perform rotation.
02911 */
02912 
02913    pos2[0] = xx * pos[0] + yx * pos[1] + zx * pos[2];
02914    pos2[1] = xy * pos[0] + yy * pos[1] + zy * pos[2];
02915    pos2[2] = xz * pos[0] + yz * pos[1] + zz * pos[2];
02916 
02917    return;
02918 }

void proper_motion ( double  tjd1,
double *  pos1,
double *  vel1,
double  tjd2,
double *  pos2 
)

Definition at line 2378 of file novas.c.

Referenced by app_star(), astro_star(), local_star(), topo_star(), and virtual_star().

02385           :    
02386       Applies proper motion, including foreshortening effects, to a
02387       star's position.
02388 
02389    REFERENCES: 
02390       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
02391          pp. 1197-1210.
02392       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
02393          Subroutines"; USNO internal document dated 20 Oct 1988;
02394          revised 15 Mar 1990.
02395 
02396    INPUT
02397    ARGUMENTS:
02398       tjd1 (double)
02399          TDB Julian date of first epoch.
02400       pos[3] (double)
02401          Position vector at first epoch.
02402       vel[3] (double)
02403          Velocity vector at first epoch.
02404       tjd2 (double)
02405          TDB Julian date of second epoch.
02406 
02407    OUTPUT
02408    ARGUMENTS:
02409       pos2[3] (double)
02410          Position vector at second epoch.
02411 
02412    RETURNED
02413    VALUE:
02414       None.
02415 
02416    GLOBALS
02417    USED:
02418       None.
02419 
02420    FUNCTIONS
02421    CALLED:
02422       None.
02423 
02424    VER./DATE/
02425    PROGRAMMER:
02426       V1.0/01-93/TKB (USNO/NRL Optical Interfer.) Translate Fortran.
02427       V1.1/08-93/WTH (USNO/AA) Updated to C programming standards.
02428 
02429    NOTES:
02430       1. This function is the "C" version of Fortran NOVAS routine
02431       'propmo'.
02432 
02433 ------------------------------------------------------------------------
02434 */
02435 {
02436     short int j;
02437 
02438     for (j = 0; j < 3; j++)
02439        pos2[j] = pos[j] + (vel[j] * (tjd2 - tjd1));
02440 
02441     return;
02442 }

void radec2vector ( double  ra,
double  dec,
double  dist,
double *  vector 
)

Definition at line 3429 of file novas.c.

References DEG2RAD.

Referenced by solarsystem().

03435           :    
03436       Converts equatorial spherical coordinates to a vector (equatorial
03437       rectangular coordinates).
03438 
03439    REFERENCES: 
03440       None.
03441 
03442    INPUT
03443    ARGUMENTS:
03444       ra (double)
03445          Right ascension (hours).
03446       dec (double)
03447          Declination (degrees).
03448 
03449    OUTPUT
03450    ARGUMENTS:
03451       vector[3] (double)
03452          Position vector, equatorial rectangular coordinates (AU).
03453 
03454    RETURNED
03455    VALUE:
03456       (short int)
03457          0...Everything OK.
03458 
03459    GLOBALS
03460    USED:
03461       DEG2RAD
03462 
03463    FUNCTIONS
03464    CALLED:
03465       cos     math.h
03466       sin     math.h
03467 
03468    VER./DATE/
03469    PROGRAMMER:
03470       V1.0/05-92/TKB (USNO/NRL Optical Interfer.) Translate Fortran.
03471       V1.1/08-93/WTH (USNO/AA) Update to C Standards.
03472 
03473    NOTES:
03474       None.
03475 
03476 ------------------------------------------------------------------------
03477 */
03478 {
03479 
03480    vector[0] = dist * cos (DEG2RAD * dec) * cos (DEG2RAD * 15.0 * ra);
03481    vector[1] = dist * cos (DEG2RAD * dec) * sin (DEG2RAD * 15.0 * ra);
03482    vector[2] = dist * sin (DEG2RAD * dec);
03483 
03484    return;
03485 }

double * readeph ( int  mp,
char *  name,
double  jd,
int *  err 
)

Definition at line 27 of file readeph0.c.

Referenced by ephemeris().

00031           :
00032       This is a dummy version of function 'readeph'.  It serves as a 
00033       stub for the "real" 'readeph' (part of the USNO/AE98 minor 
00034       planet ephemerides) when NOVAS-C is used without the 
00035       minor planet ephemerides.
00036 
00037    REFERENCES:
00038       None.
00039 
00040    INPUT
00041    ARGUMENTS:
00042       mp (int)
00043          The number of the asteroid for which the position in desired.
00044       name (char*)
00045          The name of the asteroid.
00046       jd (double)
00047          The Julian date on which to find the position and velocity.
00048     
00049    OUTPUT
00050    ARGUEMENTS:
00051       *error (int)
00052          Error code; set equal to 9 (see note below).
00053 
00054    RETURNED
00055    VALUE:
00056       (double *)
00057          Pointer to the 6-element 'pv' array, with all elements set to
00058          zero.
00059 
00060    GLOBALS
00061    USED:
00062       None.
00063 
00064    FUNCTIONS
00065    CALLED:
00066       malloc      stdlib.c
00067 
00068    VER./DATE/
00069    PROGRAMMER:
00070       V1.0/06-97/JAB (USNO/AA)
00071       V1.1/08-98/JAB (USNO/AA): Support new 'readeph' argument list.
00072       V1.2/10-99/JAB (USNO/AA): Return a pointer to a double, rather 
00073                                 than an array of doubles.  Add error 
00074                                 9 on return.  Basic code courtesy JLH.
00075 
00076    NOTES:
00077       1.  This dummy function is not intended to be called.  It merely 
00078       serves as a stub for the "real" 'readeph' when NOVAS-C is used 
00079       without the minor planet ephemerides.  If this function is 
00080       called, an error of 9 will be returned.
00081 
00082 ------------------------------------------------------------------------
00083 */
00084 {
00085    int i;
00086 
00087   /* Add code to quite compiler warnings about unused variables. S.K. 5/6/03 */
00088    int tmpint;
00089    char* tmpchar;
00090    double tmpdouble;
00091    double *pv;
00092 
00093    tmpint = mp;
00094    tmpchar = name;
00095    tmpdouble = jd;
00096 
00097 
00098    pv = (double *) malloc (6L * sizeof (double));
00099 
00100    for (i = 0; i < 6; i++)
00101       pv[i] = 0.0;
00102 
00103    *error = 9;
00104 
00105    return pv;
00106 }
}

double refract ( site_info location,
short int  ref_option,
double  zd_obs 
)

Definition at line 4761 of file novas.c.

References DEG2RAD, site_info::height, site_info::pressure, and site_info::temperature.

Referenced by equ2hor(), and PhotonUtil::InteractWithCylinder().

04766           :
04767       This function computes atmospheric refraction in zenith
04768       distance.  This version computes approximate refraction for
04769       optical wavelengths.
04770 
04771    REFERENCES:
04772       Explanatory Supplement to the Astronomical Almanac, p. 144.
04773       Bennett (1982), Journal of Navigation (Royal Institute) 35, 
04774          pp. 255-259.
04775 
04776    INPUT
04777    ARGUMENTS:
04778       *location (struct site_info)
04779          Pointer to structure containing observer's location.  This
04780          structure also contains weather data (optional) for the 
04781          observer's location (defined in novas.h).
04782       ref_option (short int)
04783          = 1 ... Use 'standard' atmospheric conditions.
04784          = 2 ... Use atmospheric parameters input in the 'location' 
04785                  structure.
04786       zd_obs (double)
04787          Observed zenith distance, in degrees.
04788 
04789    OUTPUT
04790    ARGUMENTS:
04791       None.
04792 
04793    RETURNED
04794    VALUE:
04795       (double)
04796          Atmospheric refraction, in degrees.
04797 
04798    GLOBALS
04799    USED:
04800       DEG2RAD
04801 
04802    FUNCTIONS
04803    CALLED:
04804       exp      math.h
04805       tan      math.h
04806 
04807    VER./DATE/
04808    PROGRAMMER:
04809       V1.0/06-98/JAB (USNO/AA)
04810 
04811    NOTES:
04812       1. This function can be used for planning observations or 
04813       telescope pointing, but should not be used for the reduction
04814       of precise observations.
04815       2. This function is the "C" version of Fortran NOVAS routine
04816       'refrac' written by G. H. Kaplan (USNO).
04817 
04818 ------------------------------------------------------------------------
04819 */
04820 {
04821 
04822 /*
04823    's' is the approximate scale height of atmosphere in meters.
04824 */
04825 
04826    double s = 9.1e3;
04827    double refr, p, t, h, r;
04828 
04829 /*
04830    Compute refraction only for zenith distances between 0.1 and 
04831    91 degrees.
04832 */
04833 
04834    if ((zd_obs < 0.1) || (zd_obs > 91.0))
04835       refr = 0.0;
04836 
04837     else
04838    {
04839 
04840 /*
04841    If observed weather data are available, use them.  Otherwise, use 
04842    crude estimates of average conditions.
04843 */
04844 
04845       if (ref_option == 2)
04846       {
04847          p = location->pressure;
04848          t = location->temperature;
04849       }
04850        else
04851       {
04852          p = 1010.0 * exp (-location->height / s);
04853          t = 10.0;
04854       }
04855 
04856       h = 90.0 - zd_obs;
04857       r = 0.016667 / tan ((h + 7.31 / (h + 4.4)) * DEG2RAD);
04858       refr = r * (0.28 * p / (t + 273.0));
04859    }
04860 
04861    return (refr);     
04862 }

short int set_body ( short int  type,
short int  number,
const char *  name,
body cel_obj 
)

Definition at line 3675 of file novas.c.

References body::name, body::number, and body::type.

Referenced by main().

03680           :    
03681       Sets up a structure of type 'body' - defining a celestial object-
03682       based on the input parameters.
03683 
03684    REFERENCES: 
03685       None.
03686 
03687    INPUT
03688    ARGUMENTS:
03689       type (short int)
03690          Type of body
03691             = 0 ... major planet, Sun, or Moon
03692             = 1 ... minor planet
03693       number (short int)
03694          Body number
03695             For 'type' = 0: Mercury = 1,...,Pluto = 9, Sun = 10, 
03696                             Moon = 11
03697             For 'type' = 1: minor planet number
03698       *name (char)
03699          Name of the body.
03700 
03701    OUTPUT
03702    ARGUMENTS:
03703       struct body *cel_obj
03704          Structure containg the body definition (defined in novas.h)
03705 
03706    RETURNED
03707    VALUE:
03708       (short int)
03709          = 0 ... everything OK
03710          = 1 ... invalid value of 'type'
03711          = 2 ... 'number' out of range
03712 
03713    GLOBALS
03714    USED:
03715       None.
03716 
03717    FUNCTIONS
03718    CALLED:
03719       strcpy        string.h
03720       tolower       ctype.h
03721       toupper       ctype.h
03722 
03723    VER./DATE/
03724    PROGRAMMER:
03725       V1.0/06-97/JAB (USNO/AA)
03726       V1.1/10-98/JAB (USNO/AA): Change body name to mixed case.
03727 
03728    NOTES:
03729       None.
03730 
03731 ------------------------------------------------------------------------
03732 */
03733 {
03734    char temp;
03735 
03736    short int error = 0;
03737    short int i;
03738 
03739 /*
03740    Initialize the structure.
03741 */
03742 
03743    cel_obj->type = 0;
03744    cel_obj->number = 0;
03745    strcpy (cel_obj->name, "  ");
03746 
03747 /*
03748    Set the body type.
03749 */
03750 
03751    if ((type < 0) || (type > 1))
03752       return (error = 1);
03753     else
03754       cel_obj->type = type;
03755 
03756 /*
03757    Set the body number.
03758 */
03759 /* Brackets added S.Kasahara 4/1/03 */
03760    if (type == 0) { 
03761       if ((number <= 0) || (number > 11))
03762          return (error = 2);
03763    }
03764    else {
03765       if (number <= 0)
03766          return (error = 2);
03767    }
03768    cel_obj->number = number;
03769 
03770 /*
03771    Set the body name in mixed case.
03772 */
03773 
03774     i = 0;
03775     while (name[i] != 0)
03776     {
03777        if (i == 0)
03778           temp = toupper (name[i]);
03779         else
03780           temp = tolower (name[i]);
03781        cel_obj->name[i++] = temp;
03782     }
03783     cel_obj->name[i] = '\0';
03784 
03785     return (error);
03786 }

void sidereal_time ( double  julianhi,
double  julianlo,
double  ee,
double *  gst 
)

Definition at line 1535 of file novas.c.

References T0.

Referenced by equ2hor(), AstUtil::JulianToGAST(), AstUtil::JulianToGMST(), local_planet(), local_star(), topo_planet(), and topo_star().

01541           :    
01542       Computes the Greenwich apparent sidereal time, at Julian date
01543       'jd_high' + 'jd_low'.
01544 
01545    REFERENCES: 
01546       Aoki, et al. (1982) Astronomy and Astrophysics 105, 359-361.
01547       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
01548          Subroutines"; USNO internal document dated 20 Oct 1988;
01549          revised 15 Mar 1990.
01550 
01551    INPUT
01552    ARGUMENTS:
01553       jd_high (double)
01554          Julian date, integral part.
01555       jd_low (double)
01556          Julian date, fractional part.
01557       ee (double)
01558          Equation of the equinoxes (seconds of time). [Note: this 
01559          quantity is computed by function 'earthtilt'.]
01560 
01561    OUTPUT
01562    ARGUMENTS:
01563       *gst (double)
01564          Greenwich apparent sidereal time, in hours.
01565 
01566    RETURNED
01567    VALUE:
01568       None.
01569 
01570    GLOBALS
01571    USED:
01572       T0
01573 
01574    FUNCTIONS
01575    CALLED:
01576       fmod    math.h
01577 
01578    VER./DATE/
01579    PROGRAMMER:
01580       V1.0/06-92/TKB (USNO/NRL Optical Interfer.) Translate Fortran.
01581       V1.1/08-93/WTH (USNO/AA) Update to C programing standards.
01582       V1.2/03-98/JAB (USNO/AA) Expand documentation.
01583       V1.3/08-98/JAB (USNO/AA) Match flow of the Fortran counterpart.
01584 
01585    NOTES:
01586       1. The Julian date may be split at any point, but for highest
01587       precision, set 'jd_high' to be the integral part of the Julian
01588       date, and set 'jd_low' to be the fractional part.
01589       2. For Greenwich mean sidereal time, set input variable 'ee'
01590       equal to zero.
01591       3. This function is based on Fortran NOVAS routine 'sidtim'.
01592 
01593 ------------------------------------------------------------------------
01594 */
01595 {
01596    double t_hi, t_lo, t, t2, t3, st;
01597 
01598    t_hi = (jd_high -  T0) / 36525.0;
01599    t_lo = jd_low / 36525.0;
01600    t = t_hi + t_lo;
01601    t2 = t * t;
01602    t3 = t2 * t;
01603 
01604    st =  ee - 6.2e-6 * t3 + 0.093104 * t2 + 67310.54841
01605       + 8640184.812866 * t_lo 
01606       + 3155760000.0 * t_lo
01607       + 8640184.812866 * t_hi 
01608       + 3155760000.0 * t_hi;
01609 
01610    *gst = fmod ((st / 3600.0), 24.0);
01611 
01612    if (*gst < 0.0)
01613       *gst += 24.0;
01614 
01615    return;
01616 }

short int solarsystem ( double  tjd,
short int  body,
short int  origin,
double *  pos,
double *  vel 
)

Definition at line 34 of file solsys3.c.

Referenced by ephemeris(), and get_earth().

00040           :    
00041       Provides the position and velocity of the Earth at epoch 'tjd'
00042       by evaluating a closed-form theory without reference to an 
00043       external file.  This function can also provide the position
00044       and velocity of the Sun.
00045 
00046    REFERENCES: 
00047       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
00048          Subroutines"; USNO internal document dated 20 Oct 1988;
00049          revised 15 Mar 1990.
00050       Explanatory Supplement to The Astronomical Almanac (1992).
00051 
00052    INPUT
00053    ARGUMENTS:
00054       tjd (double)
00055          TDB Julian date.
00056       body (short int)
00057          Body identification number.
00058          Set 'body' = 0 or 'body' = 1 or 'body' = 10 for the Sun.
00059          Set 'body' = 2 or 'body' = 3 for the Earth.
00060       origin (short int)
00061          Origin code; solar system barycenter   = 0,
00062                       center of mass of the Sun = 1.
00063 
00064    OUTPUT
00065    ARGUMENTS:
00066       pos[3] (double)
00067          Position vector of 'body' at 'tjd'; equatorial rectangular
00068          coordinates in AU referred to the mean equator and equinox
00069          of J2000.0.
00070       vel[3] (double)
00071          Velocity vector of 'body' at 'tjd'; equatorial rectangular
00072          system referred to the mean equator and equinox of J2000.0,
00073          in AU/Day.
00074 
00075    RETURNED
00076    VALUE:
00077       (short int)
00078          0...Everything OK.
00079          1...Input Julian date ('tjd') out of range.
00080          2...Invalid value of 'body'.
00081 
00082    GLOBALS
00083    USED:
00084       T0, TWOPI.
00085 
00086    FUNCTIONS
00087    CALLED:
00088       sun_eph          solsys3.c
00089       radec2vector     novas.c
00090       precession       novas.c
00091       sin              math.h
00092       cos              math.h
00093       fabs             math.h
00094       fmod             math.h
00095 
00096    VER./DATE/
00097    PROGRAMMER:
00098       V1.0/05-96/JAB (USNO/AA) Convert to C; substitute new theory of
00099                                Sun.
00100       V1.1/06-98/JAB (USNO/AA) Updated planetary masses & mean elements.
00101 
00102    NOTES:
00103       1. This function is the "C" version of Fortran NOVAS routine
00104       'solsys' version 3.
00105 
00106 ------------------------------------------------------------------------
00107 */
00108 {
00109    short int ierr = 0;
00110    short int i;
00111 
00112 /*
00113    The arrays below contain data for the four largest planets.  Masses
00114    are DE405 values; elements are from Explanatory Supplement, p. 316). 
00115    These data are used for barycenter computations only.
00116 */
00117 
00118    const double pm[4] = {1047.349, 3497.898, 22903.0, 19412.2};
00119    const double pa[4] = {5.203363, 9.537070, 19.191264, 30.068963};
00120    const double pl[4] = {0.600470, 0.871693, 5.466933, 5.321160};
00121    const double pn[4] = {1.450138e-3, 5.841727e-4, 2.047497e-4, 
00122                          1.043891e-4};
00123 
00124 /*
00125    'obl' is the obliquity of ecliptic at epoch J2000.0 in degrees.
00126 */
00127 
00128    const double obl = 23.43929111;
00129 
00130    static double tlast = 0.0;
00131    static double sine, cose, tmass, pbary[3], vbary[3];
00132 
00133    double oblr, qjd, ras, decs, diss, pos1[3], p[3][3], dlon, sinl,
00134       cosl, x, y, z, xdot, ydot, zdot, f;
00135 
00136 /*
00137    Initialize constants.
00138 */
00139 
00140    if (tlast == 0.0)
00141    {
00142       oblr = obl * TWOPI / 360.0;
00143       sine = sin (oblr);
00144       cose = cos (oblr);
00145       tmass = 1.0;
00146       for (i = 0; i < 4; i++)
00147          tmass += 1.0 / pm[i];
00148       tlast = 1.0;
00149    }
00150 
00151 /*
00152    Check if input Julian date is within range.
00153 */
00154 
00155    if ((tjd < 2340000.5) || (tjd > 2560000.5))
00156       return (ierr = 1);
00157 
00158 /*
00159    Form helicentric coordinates of the Sun or Earth, depending on
00160    'body'.
00161 */
00162 
00163    if ((body == 0) || (body == 1) || (body == 10))
00164       for (i = 0; i < 3; i++)
00165          pos[i] = vel[i] = 0.0;
00166 
00167     else if ((body == 2) || (body == 3))
00168     {
00169       for (i = 0; i < 3; i++)
00170       {
00171          qjd = tjd + (double) (i - 1) * 0.1;
00172          sun_eph (qjd, &ras,&decs,&diss);
00173          radec2vector (ras,decs,diss, pos1);
00174          precession (qjd,pos1,T0, pos);
00175          p[i][0] = -pos[0];
00176          p[i][1] = -pos[1];
00177          p[i][2] = -pos[2];
00178       }
00179       for (i = 0; i < 3; i++)
00180       {
00181          pos[i] = p[1][i];
00182          vel[i] = (p[2][i] - p[0][i]) / 0.2;
00183       }
00184     }
00185 
00186     else
00187       return (ierr = 2);
00188            
00189 /*
00190    If 'origin' = 0, move origin to solar system barycenter.
00191 
00192    Solar system barycenter coordinates are computed from rough
00193    approximations of the coordinates of the four largest planets.
00194 */
00195 
00196    if (origin == 0)
00197    {
00198       if (fabs (tjd - tlast) >= 1.0e-06)
00199       {
00200          for (i = 0; i < 3; i++)
00201             pbary[i] = vbary[i] = 0.0;
00202 
00203 /*
00204    The following loop cycles once for each of the four planets.
00205 
00206    'sinl' and 'cosl' are the sine and cosine of the planet's mean
00207    longitude.
00208 */
00209 
00210          for (i = 0; i < 4; i++)
00211          {
00212             dlon = pl[i] + pn[i] * (tjd - T0);
00213             dlon = fmod (dlon, TWOPI);
00214             sinl = sin (dlon);
00215             cosl = cos (dlon);
00216 
00217             x =  pa[i] * cosl;
00218             y =  pa[i] * sinl * cose;
00219             z =  pa[i] * sinl * sine;
00220             xdot = -pa[i] * pn[i] * sinl;
00221             ydot =  pa[i] * pn[i] * cosl * cose;
00222             zdot =  pa[i] * pn[i] * cosl * sine;
00223 
00224             f = 1.0 / (pm[i] * tmass);
00225 
00226             pbary[0] += x * f;
00227             pbary[1] += y * f;
00228             pbary[2] += z * f;
00229             vbary[0] += xdot * f;
00230             vbary[1] += ydot * f;
00231             vbary[2] += zdot * f;
00232          }
00233 
00234          tlast = tjd;
00235       }
00236 
00237       for (i = 0; i < 3; i++)
00238       {
00239          pos[i] -= pbary[i];
00240          vel[i] -= vbary[i];
00241       }
00242    }
00243 
00244    return (ierr);
00245 }

void spin ( double  st,
double *  pos1,
double *  pos2 
)

Definition at line 1736 of file novas.c.

References DEG2RAD.

Referenced by pnsw().

01742           :    
01743       Transforms geocentric rectangular coordinates from rotating system
01744       based on rotational equator and orthogonal reference meridian to 
01745       non-rotating system based on true equator and equinox of date.
01746 
01747    REFERENCES: 
01748       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
01749          pp. 1197-1210.
01750       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
01751          Subroutines"; USNO internal document dated 20 Oct 1988;
01752          revised 15 Mar 1990.
01753 
01754    INPUT
01755    ARGUMENTS:
01756       st (double)
01757          Local apparent sidereal time at reference meridian, in hours.
01758       pos1[3] (double)
01759          Vector in geocentric rectangular rotating system, referred
01760          to rotational equator and orthogonal reference meridian.
01761 
01762    OUTPUT
01763    ARGUMENTS:
01764       pos2[3] (double)
01765          Vector in geocentric rectangular non-rotating system,
01766          referred to true equator and equinox of date.
01767 
01768    RETURNED
01769    VALUE:
01770       None.
01771 
01772    GLOBALS
01773    USED:
01774       DEG2RAD
01775 
01776    FUNCTIONS
01777    CALLED:
01778       sin     math.h
01779       cos     math.h
01780 
01781    VER./DATE/
01782    PROGRAMMER:
01783       V1.0/08-93/WTH (USNO/AA) Translate Fortran.
01784 
01785    NOTES:
01786       1. This function is the "C" version of Fortran NOVAS routine
01787       'spin'.
01788 
01789 ------------------------------------------------------------------------
01790 */
01791 {
01792    double str, cosst, sinst, xx, yx, xy, yy;
01793 
01794    str = st * 15.0 * DEG2RAD;
01795    cosst = cos (str);
01796    sinst = sin (str);
01797 
01798 /*
01799    Sidereal time rotation matrix follows.
01800 */
01801 
01802    xx =  cosst;
01803    yx = -sinst;
01804    xy =  sinst;
01805    yy =  cosst;
01806 
01807 /*
01808    Perform rotation.
01809 */
01810 
01811    pos2[0] = xx * pos1[0] + yx * pos1[1];
01812    pos2[1] = xy * pos1[0] + yy * pos1[1];
01813    pos2[2] = pos1[2];
01814 
01815    return;
01816 }

void starvectors ( cat_entry star,
double *  pos,
double *  vel 
)

Definition at line 3489 of file novas.c.

References cat_entry::dec, DEG2RAD, KMAU, cat_entry::parallax, cat_entry::promodec, cat_entry::promora, cat_entry::ra, RAD2SEC, and cat_entry::radialvelocity.

Referenced by app_star(), astro_star(), local_star(), topo_star(), and virtual_star().

03495           :    
03496       Converts angular quanities for stars to vectors.
03497 
03498    REFERENCES: 
03499       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
03500          pp. 1197-1210.
03501       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
03502          Subroutines"; USNO internal document dated 20 Oct 1988;
03503          revised 15 Mar 1990.
03504 
03505    INPUT
03506    ARGUMENTS:
03507       *star (struct cat_entry)
03508          Pointer to catalog entry structure containing J2000.0 catalog
03509          data with FK5-style units (defined in novas.h).
03510 
03511    OUTPUT
03512    ARGUMENTS:
03513       pos[3] (double)
03514          Position vector, equatorial rectangular coordinates,
03515          components in AU.
03516       vel[3] (double)
03517          Velocity vector, equatorial rectangular coordinates,
03518          components in AU/Day.
03519 
03520    RETURNED
03521    VALUE:
03522       None.
03523 
03524    GLOBALS
03525    USED:
03526       RAD2SEC, DEG2RAD, KMAU
03527 
03528    FUNCTIONS
03529    CALLED:
03530       sin     math.h
03531       cos     math.h
03532 
03533    VER./DATE/
03534    PROGRAMMER:
03535       V1.0/01-93/TKB (USNO/NRL Optical Interfer.) Translate Fortran.
03536       V1.1/08-93/WTH (USNO/AA) Updated to C programming standards.
03537 
03538    NOTES:
03539       1. This function is the "C" version of Fortran NOVAS routine
03540       'vectrs'.
03541 
03542 ------------------------------------------------------------------------
03543 */
03544 {
03545    double paralx, dist, r, d, cra, sra, cdc, sdc, pmr, pmd, rvl;
03546 
03547 /*
03548    If parallax is unknown, undetermined, or zero, set it to 1e-7 second
03549    of arc, corresponding to a distance of 10 megaparsecs.
03550 */
03551 
03552    paralx = star->parallax;
03553 
03554    if (star->parallax <= 0.0)
03555       paralx = 1.0e-7;
03556 
03557 /*
03558    Convert right ascension, declination, and parallax to position vector
03559    in equatorial system with units of AU.
03560 */
03561 
03562    dist = RAD2SEC / paralx;
03563    r = (star->ra) * 15.0 * DEG2RAD;
03564    d = (star->dec) * DEG2RAD;
03565    cra = cos (r);
03566    sra = sin (r);
03567    cdc = cos (d);
03568    sdc = sin (d);
03569 
03570    pos[0] = dist * cdc * cra;
03571    pos[1] = dist * cdc * sra;
03572    pos[2] = dist * sdc;
03573 
03574 /*
03575    Convert proper motion and radial velocity to orthogonal components of
03576    motion with units of AU/Day.
03577 */
03578 
03579    pmr = star->promora * 15.0 * cdc / (paralx * 36525.0);
03580    pmd = star->promodec / (paralx * 36525.0);
03581    rvl = star->radialvelocity * 86400.0 / KMAU;
03582 
03583 /*
03584    Transform motion vector to equatorial system.
03585 */
03586 
03587    vel[0] = - pmr * sra - pmd * sdc * cra + rvl * cdc * cra;
03588    vel[1] =   pmr * cra - pmd * sdc * sra + rvl * cdc * sra;
03589    vel[2] =   pmd * cdc + rvl * sdc;
03590 
03591    return;
03592 }

short int sun_field ( double *  pos,
double *  earthvector,
double *  pos2 
)

Definition at line 2531 of file novas.c.

References GS, and MAU.

Referenced by app_planet(), app_star(), local_planet(), local_star(), topo_planet(), topo_star(), virtual_planet(), and virtual_star().

02537           :    
02538       Corrects position vector for the deflection of light in the
02539       gravitational field of the Sun.  This function is valid for
02540       bodies within the solar system as well as for stars.
02541 
02542    REFERENCES:
02543       Misner, C., Thorne, K., and Wheeler, J. (1973). Gravitation;
02544          pp. 184-185. 
02545       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
02546          pp. 1197-1210.
02547       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
02548          Subroutines"; USNO internal document dated 20 Oct 1988;
02549          revised 15 Mar 1990.
02550 
02551    INPUT
02552    ARGUMENTS:
02553       pos[3] (double)
02554          Position vector, referred to origin at center of mass of the
02555          Earth, components in AU.
02556       earthvector[3] (double)
02557          Position vector of center of mass of the Earth, referred to
02558          origin at center of mass of the Sun, components in AU.
02559 
02560    OUTPUT
02561    ARGUMENTS:
02562       pos2[3] (double)
02563          Position vector, referred to origin at center of mass of the
02564          Earth, corrected for gravitational deflection, components
02565          in AU.
02566 
02567    RETURNED
02568    VALUE:
02569       (short int)
02570          0...Everything OK.
02571 
02572    GLOBALS
02573    USED:
02574       C, MAU, GS
02575 
02576    FUNCTIONS
02577    CALLED:
02578       fabs    math.h
02579       sqrt    math.h
02580       pow     math.h
02581 
02582    VER./DATE/
02583    PROGRAMMER:
02584       V1.0/01-93/TKB (USNO/NRL Optical Interfer.) Translate Fortran.
02585       V1.1/08-93/WTH (USNO/AA) Update to C Standards.
02586 
02587    NOTES:
02588       1. This function is the "C" version of Fortran NOVAS routine
02589       'sunfld', member 'vasun1'.
02590 
02591 ------------------------------------------------------------------------
02592 */
02593 {
02594    short int j;
02595 
02596    double f = 0.0;
02597    double p1mag, pemag,  cosd, sind, b, bm, pqmag, zfinl, zinit,
02598       xifinl, xiinit, delphi, delphp, delp, p1hat[3], pehat[3];
02599 
02600 /*
02601    c = speed of light in meters/second.
02602 */
02603 
02604    double c = (C * MAU) / 86400.0;
02605 
02606 /*
02607    Compute vector magnitudes and unit vectors.
02608 */
02609 
02610    p1mag = sqrt (pow (pos[0], 2.0) + pow (pos[1], 2.0)
02611                + pow (pos[2], 2.0));
02612    pemag = sqrt (pow (earthvector[0], 2.0) + pow (earthvector[1], 2.0) 
02613                + pow (earthvector[2], 2.0));
02614 
02615    for (j = 0; j < 3; j++)
02616    {
02617       p1hat[j] = pos[j] / p1mag;
02618       pehat[j] = earthvector[j] / pemag;
02619    }
02620 
02621 /*
02622    Compute geometrical quantities.
02623 
02624    'cosd' and 'sind' are cosine and sine of d, the angular separation
02625    of the body from the Sun as viewed from the Earth.
02626 */
02627 
02628    cosd = - pehat[0] * p1hat[0] - pehat[1] * p1hat[1] 
02629           - pehat[2] * p1hat[2];
02630 
02631    if (fabs (cosd) > 0.9999999999)
02632    {
02633       for (j = 0; j < 3; j++)
02634          pos2[j] = pos[j];
02635    }
02636     else
02637    {
02638       sind = sqrt (1.0 - pow (cosd, 2.0));
02639 
02640 /*
02641    'b' is the impact parameter for the ray.
02642 */
02643 
02644       b = pemag * sind;
02645       bm = b * MAU;
02646 
02647 /*
02648    'pqmag' is the distance of the body from the sun.
02649 */
02650 
02651       pqmag = sqrt (pow (p1mag, 2.0) + pow (pemag, 2.0) 
02652                  - 2.0 * p1mag * pemag * cosd);
02653 
02654 /*
02655    Compute 'delphi', the angle of deflection of the ray.
02656 */
02657 
02658       zfinl = pemag * cosd;
02659       zinit = -p1mag + zfinl;
02660       xifinl = zfinl / b;
02661       xiinit = zinit / b;
02662 
02663       delphi = 2.0 * GS / (bm * c * c) * (xifinl / 
02664                 sqrt (1.0 + pow (xifinl, 2.0)) - xiinit /
02665                 sqrt (1.0 + pow (xiinit, 2.0)));
02666 
02667 /*
02668    Compute 'delphp', the change in angle as seen at the Earth.
02669 */
02670 
02671       delphp = delphi / (1.0 + (pemag / pqmag));
02672 
02673 /*
02674    Fix up position vector.
02675    'pos2' is 'pos' rotated through angle 'delphp' in plane defined by
02676    'pos' and 'earthvector'.
02677 */
02678 
02679       f = delphp * p1mag / sind;
02680 
02681       for (j = 0; j < 3; j++)
02682       {
02683          delp = f * (cosd * p1hat[j] + pehat[j]);
02684          pos2[j] = pos[j] + delp;
02685       }
02686    }
02687 
02688    return 0;
02689 }

void tdb2tdt ( double  tdb,
double *  tdtjd,
double *  secdiff 
)

Definition at line 3596 of file novas.c.

References MuELoss::e, Munits::m, RAD2SEC, and T0.

Referenced by equ2hor(), get_earth(), and pnsw().

03602           :    
03603       Computes the terrestrial time (TT) or terrestrial dynamical time 
03604       (TDT) Julian date corresponding to a barycentric dynamical time 
03605       (TDB) Julian date.
03606 
03607    REFERENCES: 
03608       Explanatory Supplement to the Astronomical Almanac, pp. 42-44 and 
03609          p. 316.
03610 
03611    INPUT
03612    ARGUMENTS:
03613       tdb (double)
03614          TDB Julian date.
03615 
03616    OUTPUT
03617    ARGUMENTS:
03618       *tdtjd (double)
03619          TT (or TDT) Julian date.
03620       *secdiff (double)
03621          Difference tdbjd-tdtjd, in seconds.
03622 
03623    RETURNED
03624    VALUE:
03625       None.
03626 
03627    GLOBALS
03628    USED:
03629       RAD2SEC, T0
03630 
03631    FUNCTIONS
03632    CALLED:
03633       sin   math.h
03634       fmod  math.h
03635 
03636    VER./DATE/
03637    PROGRAMMER:
03638       V1.0/07-92/TKB (USNO/NRL Optical Interfer.) Translate Fortran.
03639       V1.1/08-93/WTH (USNO/AA) Update to C Standards.
03640       V1.2/06-98/JAB (USNO/AA) New algorithm (see reference).
03641 
03642    NOTES:
03643       1. Expressions used in this version are approximations resulting
03644       in accuracies of about 20 microseconds.
03645       2. This function is the "C" version of Fortran NOVAS routine
03646       'times'.
03647 ------------------------------------------------------------------------
03648 */
03649 {
03650 
03651 /*
03652    'ecc' = eccentricity of earth-moon barycenter orbit.
03653 */
03654 
03655    double ecc = 0.01671022;
03656    double rev = 1296000.0;
03657    double tdays, m, l, lj, e;
03658 
03659    tdays = tdb - T0;
03660    m = ( 357.51716 + 0.985599987 * tdays ) * 3600.0;
03661    l = ( 280.46435 + 0.985609100 * tdays ) * 3600.0;
03662    lj = ( 34.40438 + 0.083086762 * tdays ) * 3600.0;
03663    m = fmod (m,rev) / RAD2SEC;
03664    l = fmod (l,rev) / RAD2SEC;
03665    lj = fmod (lj,rev) / RAD2SEC;
03666    e = m + ecc * sin (m) + 0.5 * ecc * ecc * sin (2.0 * m);
03667    *secdiff = 1.658e-3 * sin (e) + 20.73e-6 * sin (l - lj);
03668    *tdtjd = tdb - *secdiff / 86400.0;
03669 
03670     return;
03671 }

void terra ( site_info locale,
double  st,
double *  pos,
double *  vel 
)

Definition at line 1907 of file novas.c.

References DEG2RAD, EARTHRAD, F, site_info::height, KMAU, site_info::latitude, site_info::longitude, and OMEGA.

Referenced by local_planet(), local_star(), topo_planet(), and topo_star().

01913           :
01914       Computes the position and velocity vectors of a terrestrial
01915       observer with respect to the center of the Earth.
01916 
01917    REFERENCES:
01918       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
01919          pp. 1197-1210.
01920       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
01921          Subroutines"; USNO internal document dated 20 Oct 1988;
01922          revised 15 Mar 1990.
01923 
01924    INPUT
01925    ARGUMENTS:
01926       glon (double)
01927          Longitude of observer with respect to reference meridian
01928          (East +) in degrees.
01929       glat (double)
01930          Geodetic latitude (North +) of observer in degrees.
01931       ht (double)
01932          Height of observer in meters.
01933       st (double)
01934          Local apparent sidereal time at reference meridian in hours.
01935 
01936    OUTPUT
01937    ARGUMENTS:
01938       pos[3] (double)
01939          Position vector of observer with respect to center of Earth,
01940          equatorial rectangular coordinates, referred to true equator
01941          and equinox of date, components in AU.
01942       vel[3] (double)
01943          Velocity vector of observer with respect to center of Earth,
01944          equatorial rectangular coordinates, referred to true equator
01945          and equinox of date, components in AU/Day.
01946 
01947    RETURNED
01948    VALUE:
01949       None.
01950 
01951    GLOBALS
01952    USED:
01953       KMAU, EARTHRAD, F, OMEGA, DEG2RAD
01954 
01955    FUNCTIONS
01956    CALLED:
01957       pow    math.h
01958       sin    math.h
01959       cos    math.h
01960       sqrt   math.h
01961 
01962    VER./DATE/
01963    PROGRAMMER:
01964       V1.0/04-93/WTH (USNO/AA):  Translate Fortran.
01965       V1.1/06-98/JAB (USNO/AA):  Move constants 'f' and 'omega' to
01966                                  file 'novascon.c'.
01967 
01968    NOTES:
01969       1. If reference meridian is Greenwich and st=0, 'pos' is
01970       effectively referred to equator and Greenwich.
01971       2. This function is the "C" version of Fortran NOVAS routine
01972       'terra'.
01973 
01974 ------------------------------------------------------------------------
01975 */
01976 {
01977    short int j;
01978 
01979    double df2, sinphi, cosphi, c, s, ach, ash, stlocl, sinst, cosst;
01980 
01981 /*
01982    Compute parameters relating to geodetic to geocentric conversion.
01983 */
01984 
01985    df2 = pow ((1.0 - F),2);
01986 
01987    sinphi = sin (locale->latitude * DEG2RAD);
01988    cosphi = cos (locale->latitude * DEG2RAD);
01989    c = 1.0 / sqrt (pow (cosphi,2.0) + df2 * pow (sinphi,2.0));
01990    s = df2 * c;
01991    ach = EARTHRAD * c + (locale->height / 1000.0);
01992    ash = EARTHRAD * s + (locale->height / 1000.0);
01993 
01994 /*
01995    Compute local sidereal time factors at the observer's longitude.
01996 */
01997 
01998    stlocl = (st * 15.0 + locale->longitude) * DEG2RAD;
01999    sinst = sin (stlocl);
02000    cosst = cos (stlocl);
02001 
02002 /*
02003    Compute position vector components in kilometers.
02004 */
02005 
02006    pos[0] = ach * cosphi * cosst;
02007    pos[1] = ach * cosphi * sinst;
02008    pos[2] = ash * sinphi;
02009 
02010 /*
02011    Compute velocity vector components in kilometers/sec.
02012 */
02013 
02014    vel[0] = -OMEGA * ach * cosphi * sinst;
02015    vel[1] =  OMEGA * ach * cosphi * cosst;
02016    vel[2] =  0.0;
02017 
02018 /*
02019    Convert position and velocity components to AU and AU/DAY.
02020 */
02021 
02022    for (j = 0; j < 3; j++)
02023    {
02024       pos[j] /= KMAU;
02025       vel[j] /= KMAU;
02026       vel[j] *= 86400.0;
02027    }
02028 
02029    return;
02030 }

short int topo_planet ( double  tjd,
body ss_object,
body earth,
double  deltat,
site_info location,
double *  ra,
double *  dec,
double *  dis 
)

Definition at line 427 of file novas.c.

References aberration(), bary_to_geo(), BARYC, MuELoss::e, earthtilt(), ephemeris(), FN0, FN1, get_earth(), nutate(), precession(), sidereal_time(), sun_field(), T0, terra(), and vector2radec().

00434           :    
00435       Computes the topocentric place of a planet, given the location of
00436       the observer.
00437 
00438    REFERENCES: 
00439       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
00440          pp. 1197-1210.
00441       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
00442          Subroutines"; USNO internal document dated 20 Oct 1988;
00443          revised 15 Mar 1990.
00444 
00445    INPUT
00446    ARGUMENTS:
00447       tjd (double)
00448          TT (or TDT) Julian date for topocentric place.
00449       *ss_object (struct body)
00450          Pointer to structure containing the body designation for the
00451          solar system body (defined in novas.h).
00452       *earth (struct body)
00453          Pointer to structure containing the body designation for the
00454          Earth (defined in novas.h).
00455       deltat (double)
00456          Difference TT(or TDT)-UT1 at 'tjd', in seconds.
00457       *location (struct site_info)
00458          Pointer to structure containing observer's location (defined
00459          in novas.h).
00460 
00461    OUTPUT
00462    ARGUMENTS:
00463       *ra (double)
00464          Topocentric right ascension in hours, referred to true
00465          equator and equinox of date 'tjd'.
00466       *dec (double)
00467          Topocentric declination in degrees, referred to true equator
00468          and equinox of date 'tjd'.
00469       *dis (double)
00470          True distance from observer to planet at 'tjd' in AU.
00471 
00472    RETURNED
00473    VALUE:
00474       (short int)
00475           0...Everything OK.
00476          >0...See error description in function 'ephemeris'.
00477 
00478    GLOBALS
00479    USED:
00480       T0, FN0, FN1, BARYC
00481 
00482    FUNCTIONS
00483    CALLED:
00484       get_earth        novas.c
00485       earthtilt        novas.c
00486       sidereal_time    novas.c
00487       terra            novas.c
00488       nutate           novas.c
00489       precession       novas.c
00490       bary_to_geo      novas.c
00491       sun_field        novas.c
00492       aberration       novas.c
00493       vector2radec     novas.c
00494       ephemeris        novas.c
00495       fabs             math.h
00496 
00497    VER./DATE/
00498    PROGRAMMER:
00499       V1.0/08-93/WTH (USNO/AA) Translate Fortran.
00500       V1.1/10-95/WTH (USNO/AA) Added call to 'get_earth'.
00501       V1.2/06-97/JAB (USNO/AA) Generalize ephemeris management.
00502       V1.3/12-99/JAB (USNO/AA) Fix error return from 'get_earth'.
00503 
00504    NOTES:
00505       1. This function is the "C" version of Fortran NOVAS routine
00506       'tpplan'. 
00507 
00508 ------------------------------------------------------------------------
00509 */
00510 {
00511    short int error = 0;
00512    short int j;
00513 
00514    double ujd, t2, t3, gast, pos1[3], pos2[3], pos4[3], pos5[3],
00515       pos6[3], pos7[3], vel1[3], vel2[3], pog[3], vog[3], pob[3],
00516       vob[3], pos[3], lighttime, tdb, peb[3], veb[3], pes[3], ves[3],
00517       oblm, oblt, eqeq, psi, eps;
00518 
00519 /*
00520    Compute 'ujd', the UT1 Julian date corresponding to 'tjd'.
00521 */
00522 
00523    ujd = tjd - (deltat / 86400.0);
00524 
00525 /*
00526    Compute position and velocity of the observer, on mean equator
00527    and equinox of J2000.0, wrt the solar system barycenter and
00528    wrt to the center of the Sun.
00529 */
00530 
00531 /* add extra ()'s 4/03 S. Kasahara */
00532    if ((error = get_earth (tjd,earth, &tdb,peb,veb,pes,ves)))
00533    {
00534       *ra = 0.0;
00535       *dec = 0.0;
00536       *dis = 0.0;
00537       return (error + 10);
00538    }
00539 
00540    earthtilt (tdb, &oblm,&oblt,&eqeq,&psi,&eps);
00541 
00542    sidereal_time (ujd,0.0,eqeq, &gast);
00543    terra (location,gast, pos1,vel1);
00544    nutate (tdb,FN1,pos1, pos2);
00545    precession (tdb,pos2,T0, pog);
00546 
00547    nutate (tdb,FN1,vel1, vel2);
00548    precession (tdb,vel2,T0, vog);
00549 
00550    for (j = 0; j < 3; j++)
00551    {
00552       pob[j] = peb[j] + pog[j];
00553       vob[j] = veb[j] + vog[j];
00554       pos[j] = pes[j] + pog[j];
00555    }
00556 
00557 /*
00558    Compute the apparent place of the planet using the position and
00559    velocity of the observer.
00560 
00561    Get position of planet wrt barycenter of solar system.
00562 */
00563 
00564 /* add extra ()'s 4/03 S. Kasahara */
00565    if ((error = ephemeris (tdb,ss_object,BARYC, pos1,vel1)))
00566    {
00567       *ra = 0.0;
00568       *dec = 0.0;
00569       *dis = 0.0;
00570       return error;
00571    }
00572 
00573    bary_to_geo (pos1,pob, pos2,&lighttime);
00574    *dis = lighttime * C;
00575    t3 = tdb - lighttime;
00576 
00577    do
00578    {
00579       t2 = t3;
00580 
00581 /* add extra ()'s 4/03 S. Kasahara */
00582       if ((error = ephemeris (t2,ss_object,BARYC, pos1,vel1)))
00583       {
00584          *ra = 0.0;
00585          *dec = 0.0;
00586          *dis = 0.0;
00587          return error;
00588       }
00589       bary_to_geo (pos1,pob, pos2,&lighttime);
00590       t3 = tdb - lighttime;
00591 
00592    } while (fabs (t3-t2) > 1.0e-8);
00593 
00594 /*
00595    Finish topocentric place.
00596 */
00597 
00598    sun_field (pos2,pos, pos4);
00599    aberration (pos4,vob,lighttime, pos5);
00600    precession (T0,pos5,tdb, pos6);
00601    nutate (tdb,FN0,pos6, pos7);
00602    vector2radec (pos7, ra,dec);
00603 
00604    return error ;
00605 }

short int topo_star ( double  tjd,
body earth,
double  deltat,
cat_entry star,
site_info location,
double *  ra,
double *  dec 
)

Definition at line 281 of file novas.c.

References aberration(), bary_to_geo(), earthtilt(), FN0, FN1, get_earth(), nutate(), precession(), proper_motion(), sidereal_time(), starvectors(), sun_field(), T0, terra(), and vector2radec().

Referenced by main().

00288           :    
00289       Computes the topocentric place of a star at date 'tjd', given its
00290       mean place, proper motion, parallax, and radial velocity for
00291       J2000.0 and the location of the observer.
00292 
00293    REFERENCES: 
00294       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
00295          pp. 1197-1210.
00296       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
00297          Subroutines"; USNO internal document dated 20 Oct 1988;
00298          revised 15 Mar 1990.
00299 
00300    INPUT
00301    ARGUMENTS:
00302       tjd (double)
00303          TT (or TDT) Julian date for topocentric place.
00304       *earth (struct body)
00305          Pointer to structure containing the body designation for the
00306          Earth (defined in novas.h).
00307       deltat (double)
00308          Difference TT (or TDT)-UT1 at 'tjd', in seconds.
00309       *star (struct cat_entry)
00310          Pointer to catalog entry structure containing J2000.0 catalog
00311          data with FK5-style units (defined in novas.h).
00312       *location (struct site_info)
00313          Pointer to structure containing observer's location (defined
00314          in novas.h).
00315 
00316    OUTPUT
00317    ARGUMENTS:
00318       *ra (double)
00319          Topocentric right ascension in hours, referred to true equator
00320          and equinox of date 'tjd'.
00321       *dec (double)
00322          Topocentric declination in degrees, referred to true equator
00323          and equinox of date 'tjd'.
00324 
00325    RETURNED
00326    VALUE:
00327       (short int)
00328           0...Everything OK.
00329          >0...Error code from function 'solarsystem'.
00330 
00331    GLOBALS
00332    USED:
00333       T0, FN1, FN0
00334 
00335    FUNCTIONS
00336    CALLED:
00337       get_earth       novas.c
00338       earthtilt       novas.c
00339       sidereal_time   novas.c
00340       terra           novas.c
00341       nutate          novas.c
00342       precession      novas.c
00343       starvectors     novas.c
00344       proper_motion   novas.c
00345       bary_to_geo     novas.c
00346       sun_field       novas.c
00347       aberration      novas.c
00348       vector2radec    novas.c
00349 
00350    VER./DATE/
00351    PROGRAMMER:
00352       V1.0/08-93/WTH (USNO/AA) Translate Fortran.
00353       V1.1/10-95/WTH (USNO/AA) Added call to 'get_earth'.
00354       V1.2/06-97/JAB (USNO/AA) Incorporate 'body' structure in input.
00355 
00356    NOTES:
00357       1. This function is the "C" version of Fortran NOVAS routine
00358       'tpstar'.
00359 
00360 ------------------------------------------------------------------------
00361 */
00362 {
00363    short int error = 0;
00364    short int j;
00365 
00366    double lighttime, ujd, pob[3], pog[3], vob[3], vog[3], pos[3], gast,
00367       pos1[3], pos2[3], pos3[3], pos4[3], pos5[3], pos6[3], pos7[3],
00368       vel1[3], vel2[3], tdb, peb[3], veb[3], pes[3], ves[3], oblm,
00369       oblt, eqeq, psi, eps;
00370 
00371 /*
00372    Compute 'ujd', the UT1 Julian date corresponding to 'tjd'.
00373 */
00374 
00375    ujd = tjd - (deltat / 86400.0);
00376 
00377 /*
00378    Compute position and velocity of the observer, on mean equator
00379    and equinox of J2000.0, wrt the solar system barycenter and
00380    wrt to the center of the Sun.
00381 */
00382 
00383 /* add extra ()'s 4/03 S. Kasahara */
00384    if ((error = get_earth (tjd,earth, &tdb,peb,veb,pes,ves)))
00385    {
00386       *ra = 0.0;
00387       *dec = 0.0;
00388       return error;
00389    }
00390 
00391    earthtilt (tdb, &oblm,&oblt,&eqeq,&psi,&eps);
00392 
00393    sidereal_time (ujd,0.0,eqeq, &gast);
00394    terra (location,gast, pos1,vel1);
00395    nutate (tdb,FN1,pos1, pos2);
00396    precession (tdb,pos2,T0, pog);
00397 
00398    nutate (tdb,FN1,vel1, vel2);
00399    precession (tdb,vel2,T0, vog);
00400 
00401    for (j = 0; j < 3; j++)
00402    {
00403       pob[j] = peb[j] + pog[j];
00404       vob[j] = veb[j] + vog[j];
00405       pos[j] = pes[j] + pog[j];
00406    }
00407 
00408 /*
00409    Finish topocentric place calculation.
00410 */
00411 
00412    starvectors (star, pos1,vel1);
00413    proper_motion (T0,pos1,vel1,tdb, pos2);
00414    bary_to_geo (pos2,pob, pos3,&lighttime);
00415    sun_field (pos3,pos, pos4);
00416    aberration (pos4,vob,lighttime, pos5);
00417    precession (T0,pos5,tdb, pos6);
00418    nutate (tdb,FN0,pos6, pos7);
00419 
00420    vector2radec (pos7, ra,dec);
00421 
00422    return 0;
00423  }

void transform_cat ( short int  option,
double  date_incat,
cat_entry incat,
double  date_newcat,
const char *  newcat_id,
cat_entry newcat 
)

Definition at line 4214 of file novas.c.

References cat_entry::catalog, cat_entry::dec, KMAU, cat_entry::parallax, precession(), cat_entry::promodec, cat_entry::promora, cat_entry::ra, RAD2SEC, cat_entry::radialvelocity, cat_entry::starname, cat_entry::starnumber, and T0.

Referenced by transform_hip().

04221           :
04222       To transform a star's catalog quantities for a change of epoch 
04223       and/or equator and equinox.
04224 
04225    REFERENCES:
04226       None.
04227 
04228    INPUT
04229    ARGUMENTS:
04230       option (short int)
04231          Transformation option
04232             = 1 ... change epoch; same equator and equinox
04233             = 2 ... change equator and equinox; same epoch
04234             = 3 ... change equator and equinox and epoch
04235       date_incat (double)
04236          TT Julian date, or year, of input catalog data.
04237       *incat (struct cat_entry)
04238          An entry from the input catalog (struct defined in novas.h).
04239       date_newcat (double)
04240          TT Julian date, or year, of transformed catalog data.
04241       newcat_id[4] (char)
04242          Three-character abbreviated name of the transformed catalog.
04243 
04244    OUTPUT
04245    ARGUMENTS:
04246       newcat (struct cat_entry)
04247          The transformed catalog entry (struct defined in novas.h).
04248 
04249 
04250    RETURNED
04251    VALUE:
04252       None.
04253 
04254    GLOBALS
04255    USED:
04256       T0, RAD2SEC, KMAU
04257 
04258    FUNCTIONS
04259    CALLED:
04260       precession   novas.c
04261       sin          math.h
04262       cos          math.h
04263       sqrt         math.h
04264       atan2        math.h
04265       strcpy       string.h
04266 
04267    VER./DATE/
04268    PROGRAMMER:
04269       V1.0/03-98/JAB (USNO/AA)
04270 
04271    NOTES:
04272       1. 'date_incat' and 'date_newcat' may be specified either as a 
04273       Julian date (e.g., 2433282.5) or a Julian year and fraction 
04274       (e.g., 1950.0).  Values less than 10000 are assumed to be years.
04275       2. 'option' = 1 updates the star's data to account for the 
04276       star's space motion between the first and second dates, within a 
04277       fixed reference frame.
04278          'option' = 2 applies a rotation of the reference frame 
04279       corresponding to precession between the first and second dates, 
04280       but leaves the star fixed in space.
04281          'option' = 3 provides both transformations.
04282       3. This subroutine cannot be properly used to bring data from 
04283       old (pre-FK5) star catalogs into the modern system, because old 
04284       catalogs were compiled using a set of constants that are 
04285       incompatible with the IAU (1976) system.
04286       4. This function uses TDB Julian dates internally, but no 
04287       distinction between TDB and TT is necessary.
04288       5. This function is based on subroutine 'gethip' from NOVAS 
04289       Fortran.
04290 
04291 ------------------------------------------------------------------------
04292 */
04293 {
04294    short int j;
04295 
04296    double jd_incat, jd_newcat, paralx, dist, r, d, cra, sra, cdc, sdc, 
04297       pos1[3], term1, pmr, pmd, rvl, vel1[3], pos2[3], vel2[3], xyproj;
04298 
04299 /*
04300    If necessary, compute Julian dates.
04301 */
04302 
04303    if (date_incat < 10000.0)
04304       jd_incat = T0 + (date_incat - 2000.0) * 365.25;
04305     else
04306       jd_incat = date_incat;
04307 
04308    if (date_newcat < 10000.0)
04309       jd_newcat = T0 + (date_newcat - 2000.0) * 365.25;
04310     else
04311       jd_newcat = date_newcat;
04312 
04313 /*
04314    Convert input angular components to vectors
04315 
04316    If parallax is unknown, undetermined, or zero, set it to 1.0e-7 
04317    second of arc, corresponding to a distance of 10 megaparsecs.
04318 */
04319 
04320    paralx = incat->parallax;
04321    if (paralx <= 0.0)
04322       paralx = 1.0e-7;
04323 
04324 /*
04325    Convert right ascension, declination, and parallax to position 
04326    vector in equatorial system with units of AU.
04327 */
04328 
04329    dist = RAD2SEC / paralx;
04330    r = incat->ra * 54000.0 / RAD2SEC;
04331    d = incat->dec * 3600.0 / RAD2SEC;
04332    cra = cos (r);
04333    sra = sin (r);
04334    cdc = cos (d);
04335    sdc = sin (d);
04336    pos1[0] = dist * cdc * cra;
04337    pos1[1] = dist * cdc * sra;
04338    pos1[2] = dist * sdc;
04339 
04340 /*
04341    Convert proper motion and radial velocity to orthogonal components 
04342    of motion, in spherical polar system at star's original position, 
04343    with units of AU/day.
04344 */
04345 
04346    term1 = paralx * 36525.0;
04347    pmr = incat->promora * 15.0 * cdc / term1;
04348    pmd = incat->promodec             / term1;
04349    rvl = incat->radialvelocity * 86400.0 / KMAU;
04350 
04351 /*
04352    Transform motion vector to equatorial system.
04353 */
04354 
04355    vel1[0] = - pmr * sra - pmd * sdc * cra + rvl * cdc * cra;
04356    vel1[1] =   pmr * cra - pmd * sdc * sra + rvl * cdc * sra;
04357    vel1[2] =               pmd * cdc       + rvl * sdc;
04358 
04359 /*
04360    Update star's position vector for space motion (only if 'option' = 1 
04361    or 'option' = 3).
04362 */
04363 
04364    if ((option == 1) || (option == 3))
04365    {
04366       for (j = 0; j < 3; j++)
04367       {
04368          pos2[j] = pos1[j] + vel1[j] * (jd_newcat - jd_incat);
04369          vel2[j] = vel1[j];
04370       }
04371    }
04372     else
04373    {
04374       for (j = 0; j < 3; j++)
04375       {
04376            pos2[j] = pos1[j];
04377            vel2[j] = vel1[j];
04378       }
04379    }
04380 
04381 /*
04382    Precess position and velocity vectors (only if 'option' = 2 or 
04383    'option' = 3).
04384 */
04385 
04386    if ((option == 2) || (option == 3))
04387    {
04388       for (j = 0; j < 3; j++)
04389       {
04390            pos1[j] = pos2[j];
04391            vel1[j] = vel2[j];
04392       }
04393       precession (jd_incat,pos1,jd_newcat, pos2);
04394       precession (jd_incat,vel1,jd_newcat, vel2);
04395    }
04396 
04397 /*
04398    Convert vectors back to angular components for output.
04399 
04400    From updated position vector, obtain star's new position expressed 
04401    as angular quantities.
04402 */
04403 
04404    xyproj = sqrt (pos2[0] * pos2[0] + pos2[1] * pos2[1]);
04405    r = atan2 (pos2[1], pos2[0]);
04406    d = atan2 (pos2[2], xyproj);
04407    newcat->ra = r * RAD2SEC / 54000.0;
04408    newcat->dec = d * RAD2SEC / 3600.0;
04409    if (newcat->ra < 0.0 )
04410       newcat->ra += 24.0;
04411 
04412    dist = sqrt (pos2[0] * pos2[0] + pos2[1] * pos2[1] + 
04413       pos2[2] * pos2[2]);
04414    paralx = RAD2SEC / dist;
04415    newcat->parallax = paralx;
04416 
04417 /*
04418    Transform motion vector back to spherical polar system at star's 
04419    new position.
04420 */
04421 
04422    cra = cos (r);
04423    sra = sin (r);
04424    cdc = cos (d);
04425    sdc = sin (d);
04426    pmr = - vel2[0] * sra       + vel2[1] * cra;
04427    pmd = - vel2[0] * cra * sdc - vel2[1] * sra * sdc + vel2[2] * cdc;
04428    rvl =   vel2[0] * cra * cdc + vel2[1] * sra * cdc + vel2[2] * sdc;
04429 
04430 /*
04431    Convert components of motion to from AU/day to normal catalog units.
04432 */
04433 
04434    newcat->promora  = pmr * paralx * 36525.0 / (15.0 * cdc);
04435    newcat->promodec = pmd * paralx * 36525.0;
04436    newcat->radialvelocity = rvl * KMAU / 86400.0;
04437 
04438 /*
04439   Take care of zero-parallax case.
04440 */
04441 
04442    if (newcat->parallax <= 1.01e-7)
04443    {
04444       newcat->parallax = 0.0;
04445       newcat->radialvelocity = incat->radialvelocity;
04446    }
04447 
04448 /*
04449    Set the catalog identification code for the transformed catalog
04450    entry.
04451 */
04452 
04453    strcpy (newcat->catalog,newcat_id);
04454 
04455 /*
04456    Copy unchanged quantities from the input catalog entry to the
04457    transformed catalog entry.
04458 */
04459 
04460    strcpy (newcat->starname, incat->starname);
04461    newcat->starnumber = incat->starnumber;
04462 
04463    return;
04464 }

void transform_hip ( cat_entry hipparcos,
cat_entry fk5 
)

Definition at line 4106 of file novas.c.

References cat_entry::catalog, cat_entry::dec, DEG2RAD, cat_entry::parallax, cat_entry::promodec, cat_entry::promora, cat_entry::ra, cat_entry::radialvelocity, cat_entry::starname, cat_entry::starnumber, and transform_cat().

04112           :
04113       To convert Hipparcos data at epoch J1991.25 to epoch J2000.0 and
04114       FK5-style units.  To be used only for Hipparcos or Tycho stars 
04115       with linear space motion.
04116 
04117    REFERENCES:
04118       None.
04119 
04120    INPUT
04121    ARGUMENTS:
04122       *hipparcos (struct cat_entry)
04123          An entry from the Hipparcos catalog, at epoch J1991.25, with 
04124          all members having Hipparcos catalog units.  See Note 1
04125          below (struct defined in novas.h).
04126 
04127    OUTPUT
04128    ARGUMENTS:
04129       *fk5 (struct cat_entry)
04130          The transformed input entry, at epoch J2000.0, with all 
04131          members having FK5 catalog units.  See Note 2 below (struct 
04132          defined in novas.h).
04133 
04134 
04135    RETURNED
04136    VALUE:
04137       None.
04138 
04139    GLOBALS
04140    USED:
04141       DEG2RAD
04142 
04143    FUNCTIONS
04144    CALLED:
04145       transform_cat  novas.c
04146       cos            math.h
04147 
04148    VER./DATE/
04149    PROGRAMMER:
04150       V1.0/03-98/JAB (USNO/AA)
04151 
04152    NOTES:
04153       1. Hipparcos epoch and units:
04154          Epoch: J1991.25
04155          Right ascension (RA): degrees
04156          Declination (Dec): degrees
04157          Proper motion in RA * cos (Dec): milliarcseconds per year
04158          Proper motion in Dec: milliarcseconds per year
04159          Parallax: milliarcseconds
04160          Radial velocity: kilometers per second (not in catalog)
04161       2. FK5 epoch and units:
04162          Epoch: J2000.0
04163          Right ascension: hours
04164          Declination: degrees
04165          Proper motion in RA: seconds of time per Julian century
04166          Proper motion in Dec: arcseconds per Julian century
04167          Parallax: arcseconds
04168          Radial velocity: kilometers per second
04169       3. This function based on subroutine 'gethip' from NOVAS Fortran.
04170 
04171 ------------------------------------------------------------------------
04172 */
04173 {
04174    double epoch_hip = 2448349.0625;
04175    double epoch_fk5 = 2451545.0000;
04176 
04177    cat_entry scratch;
04178 
04179 /*
04180    The "scratch" catalog entry contains data with FK5-like units at 
04181    epoch J1991.25.  Copy the catalog entry quantities that don't 
04182    change from the Hipparcos catalog entry to the "scratch" entry.
04183 */
04184 
04185    strcpy (scratch.starname, hipparcos->starname);
04186    scratch.starnumber = hipparcos->starnumber;
04187    scratch.dec = hipparcos->dec;
04188    scratch.radialvelocity = hipparcos->radialvelocity;
04189 
04190    strcpy (scratch.catalog, "SCR");
04191 
04192 /*
04193    Convert Hipparcos units to FK5-like units; insert transformed
04194    quantities into the "scratch" catalog entry.
04195 */
04196 
04197    scratch.ra = hipparcos->ra / 15.0;
04198    scratch.promora = hipparcos->promora / (150.0 * 
04199       cos (hipparcos->dec * DEG2RAD));
04200    scratch.promodec = hipparcos->promodec / 10.0;
04201    scratch.parallax = hipparcos->parallax / 1000.0;
04202 
04203 /*
04204    Change the epoch of the Hipparcos data from J1991.25 to J2000.0.
04205 */
04206 
04207    transform_cat (1,epoch_hip,&scratch,epoch_fk5,"FK5", fk5);
04208 
04209    return;
04210 }

short int vector2radec ( double *  pos,
double *  ra,
double *  dec 
)

Definition at line 3339 of file novas.c.

References RAD2SEC.

Referenced by app_planet(), app_star(), astro_planet(), astro_star(), local_planet(), local_star(), topo_planet(), topo_star(), virtual_planet(), and virtual_star().

03345           :    
03346       Converts an vector in equatorial rectangular coordinates to
03347       equatorial spherical coordinates.
03348 
03349    REFERENCES: 
03350       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
03351          pp. 1197-1210.
03352       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
03353          Subroutines"; USNO internal document dated 20 Oct 1988;
03354          revised 15 Mar 1990.
03355 
03356    INPUT
03357    ARGUMENTS:
03358       pos[3] (double)
03359          Position vector, equatorial rectangular coordinates.
03360 
03361    OUTPUT
03362    ARGUMENTS:
03363       *rightascension (double)
03364          Right ascension in hours.
03365       *declination (double)
03366          Declination in degrees.
03367 
03368    RETURNED
03369    VALUE:
03370       (short int)
03371          0...Everything OK.
03372          1...All vector components are zero; 'ra' and 'dec' are
03373              indeterminate.
03374          2...Both vec[0] and vec[1] are zero, but vec[2] is nonzero;
03375              'ra' is indeterminate.
03376    GLOBALS
03377    USED:
03378       RAD2SEC
03379 
03380    FUNCTIONS
03381    CALLED:
03382       sqrt     math.h
03383       pow      math.h
03384       atan2    math.h
03385 
03386    VER./DATE/
03387    PROGRAMMER:
03388       V1.0/01-93/TKB (USNO/NRL Optical Interfer.) Translate Fortran.
03389       V1.1/08-93/WTH (USNO/AA) Update to C Standards.
03390 
03391    NOTES:
03392       1. This function is the "C" version of Fortran NOVAS routine
03393       'angles'.
03394 
03395 ------------------------------------------------------------------------
03396 */
03397 {
03398    double xyproj;
03399 
03400    xyproj = sqrt (pow (pos[0], 2.0) + pow (pos[1], 2.0));
03401    if ((xyproj == 0.0) && (pos[2] == 0))
03402    {
03403       *ra = 0.0;
03404       *dec = 0.0;
03405       return 1;
03406    }
03407     else if (xyproj == 0.0)
03408    {
03409       *ra = 0.0;
03410       if (pos[2] < 0.0)
03411          *dec = -90.0;
03412        else
03413          *dec = 90.0;
03414       return 2;
03415    }
03416     else
03417    {
03418       *ra = atan2 (pos[1], pos[0]) * RAD2SEC / 54000.0;
03419       *dec = atan2 (pos[2], xyproj) * RAD2SEC / 3600.0;
03420 
03421       if (*ra < 0.0)
03422          *ra += 24.0;
03423    }
03424    return 0;
03425 }

short int virtual_planet ( double  tjd,
body ss_object,
body earth,
double *  ra,
double *  dec,
double *  dis 
)

Definition at line 717 of file novas.c.

References aberration(), bary_to_geo(), BARYC, MuELoss::e, earthtilt(), ephemeris(), get_earth(), sun_field(), and vector2radec().

00723           :    
00724       Computes the virtual place of a planet or other solar system body.
00725 
00726    REFERENCES: 
00727       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
00728          pp. 1197-1210.
00729       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
00730          Subroutines"; USNO internal document dated 20 Oct 1988;
00731          revised 15 Mar 1990.
00732 
00733    INPUT
00734    ARGUMENTS:
00735       tjd (double)
00736          TT (or TDT) Julian date for virtual place.
00737       *ss_object (struct body)
00738          Pointer to structure containing the body designation for the
00739          solar system body (defined in novas.h).
00740       *earth (struct body)
00741          Pointer to structure containing the body designation for the
00742          Earth (defined in novas.h).
00743 
00744    OUTPUT
00745    ARGUMENTS:
00746       *ra (double)
00747          Virtual right ascension in hours, referred to mean equator
00748          and equinox of J2000.
00749       *dec (double)
00750          Virtual declination in degrees, referred to mean equator
00751          and equinox of J2000.
00752       *dis (double)
00753          True distance from Earth to planet in AU.
00754 
00755    RETURNED
00756    VALUE:
00757       (short int)
00758           0...Everything OK.
00759          >0...See error description in function 'ephemeris'.
00760 
00761    GLOBALS
00762    USED:
00763       BARYC, C 
00764 
00765    FUNCTIONS
00766    CALLED:
00767       ephemeris      novas.c
00768       bary_to_geo    novas.c
00769       sun_field      novas.c
00770       aberration     novas.c
00771       vector2radec   novas.c
00772       get_earth      novas.c
00773       earthtilt      novas.c
00774       fabs           math.h
00775 
00776    VER./DATE/
00777    PROGRAMMER:
00778       V1.0/08-93/WTH (USNO/AA) Translate Fortran.
00779       V1.1/10-95/WTH (USNO/AA) Added call to 'get_earth'.
00780       V1.2/06-97/JAB (USNO/AA) Generalize ephemeris management.
00781       V1.3/12-99/JAB (USNO/AA) Fix error return from 'get_earth'.
00782 
00783    NOTES:
00784       1. This function is the "C" version of Fortran NOVAS routine
00785       'vpplan'.
00786 
00787 ------------------------------------------------------------------------
00788 */
00789 {
00790    short int error = 0;
00791 
00792    double t2 = 0.0, t3 = 0.0;
00793    double lighttime, pos1[3], vel1[3], pos2[3], pos3[3], pos4[3],
00794       tdb, peb[3], veb[3], pes[3], ves[3], oblm, oblt, eqeq, psi, eps;
00795 
00796 /*
00797    Get position of Earth wrt barycenter of solar system.
00798 */
00799 
00800 /* add extra ()'s 4/03 S. Kasahara */
00801    if ((error = get_earth (tjd,earth, &tdb,peb,veb,pes,ves)))
00802    {
00803       *ra = 0.0;
00804       *dec = 0.0;
00805       return (error + 10);
00806    }
00807 
00808    earthtilt (tdb, &oblm,&oblt,&eqeq,&psi,&eps);
00809 
00810 /*
00811    Get position of planet wrt barycenter of solar system.
00812 */
00813 
00814 /* add extra ()'s 4/03 S. Kasahara */
00815    if ((error = ephemeris (tdb,ss_object,BARYC, pos1,vel1)))
00816    {
00817       *ra = 0.0;
00818       *dec = 0.0;
00819       return error;
00820    }
00821    bary_to_geo (pos1,peb, pos2,&lighttime);
00822    *dis = lighttime * C;
00823    t3 = tdb - lighttime;
00824 
00825    do
00826    {
00827       t2 = t3;
00828 /* add extra ()'s 4/03 S. Kasahara */
00829       if ((error = ephemeris (t2,ss_object,BARYC, pos1,vel1)))
00830       {
00831          *ra = 0.0;
00832          *dec = 0.0;
00833          return error;
00834       }
00835       bary_to_geo (pos1,peb, pos2,&lighttime);
00836       t3 = tdb - lighttime;
00837    } while (fabs (t3 - t2) > 1.0e-8);
00838 
00839 /*
00840    Finish virtual place computation.
00841 */
00842 
00843    sun_field (pos2,pes, pos3);
00844    aberration (pos3,veb,lighttime, pos4);
00845    vector2radec (pos4, ra,dec);
00846 
00847    return 0;
00848 }

short int virtual_star ( double  tjd,
body earth,
cat_entry star,
double *  ra,
double *  dec 
)

Definition at line 610 of file novas.c.

References aberration(), bary_to_geo(), get_earth(), proper_motion(), starvectors(), sun_field(), T0, and vector2radec().

00616           :    
00617       Computes the virtual place of a star at date 'tjd', given its
00618       mean place, proper motion, parallax, and radial velocity for
00619       J2000.0.
00620 
00621    REFERENCES: 
00622       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
00623          pp. 1197-1210.
00624       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
00625          Subroutines"; USNO internal document dated 20 Oct 1988;
00626          revised 15 Mar 1990.
00627 
00628    INPUT
00629    ARGUMENTS:
00630       tjd (double)
00631          TT (or TDT) Julian date for virtual place.
00632       *earth (struct body)
00633          Pointer to structure containing the body designation for the
00634          Earth (defined in novas.h).
00635       *star (struct cat_entry)
00636          Pointer to catalog entry structure containing J2000.0 catalog
00637          data with FK5-style units (defined in novas.h).
00638 
00639    OUTPUT
00640    ARGUMENTS:
00641       *ra (double)
00642          Virtual right ascension in hours, referred to mean equator
00643          and equinox of J2000.
00644       *dec (double)
00645          Virtual declination in degrees, referred to mean equator
00646          and equinox of J2000.
00647 
00648    RETURNED
00649    VALUE:
00650       (short int)
00651           0...Everything OK.
00652          >0...Error code from function 'solarsystem'.
00653 
00654    GLOBALS
00655    USED:
00656       T0
00657 
00658    FUNCTIONS
00659    CALLED:
00660       get_earth       novas.c
00661       starvectors     novas.c
00662       proper_motion   novas.c
00663       bary_to_geo     novas.c
00664       sun_field       novas.c
00665       aberration      novas.c
00666       vector2radec    novas.c
00667 
00668    VER./DATE/
00669    PROGRAMMER:
00670       V1.0/08-93/WTH (USNO/AA) Translate Fortran.
00671       V1.1/10-95/WTH (USNO/AA) Added call to 'get_earth'.
00672       V1.2/06-97/JAB (USNO/AA) Incorporate 'body' structure in input.
00673 
00674    NOTES:
00675       1. This function is the "C" version of Fortran NOVAS routine
00676       'vpstar'.
00677 
00678 ------------------------------------------------------------------------
00679 */
00680 {
00681    short int error = 0;
00682 
00683    double pos1[3], vel1[3], pos2[3], pos3[3], pos4[3], pos5[3],
00684       tdb, peb[3], veb[3], pes[3], ves[3], lighttime;
00685 
00686 /*
00687    Get the position and velocity of the Earth w/r/t the solar system
00688    barycenter and the center of mass of the Sun, on the mean equator
00689    and equinox of J2000.0
00690 */
00691 
00692 /* add extra ()'s 4/03 S. Kasahara */
00693    if ((error = get_earth (tjd,earth, &tdb,peb,veb,pes,ves)))
00694    {
00695       *ra = 0.0;
00696       *dec = 0.0;
00697       return error;
00698    }
00699 
00700 /*
00701    Compute virtual place.
00702 */
00703 
00704    starvectors (star, pos1,vel1);
00705    proper_motion (T0,pos1,vel1,tdb, pos2);
00706    bary_to_geo (pos2,peb, pos3,&lighttime);
00707    sun_field (pos3,pes, pos4);
00708    aberration (pos4,veb,lighttime, pos5);
00709 
00710    vector2radec (pos5, ra,dec);
00711 
00712    return 0;
00713  }

void wobble ( double  x,
double  y,
double *  pos1,
double *  pos2 
)

Definition at line 1820 of file novas.c.

References RAD2SEC.

Referenced by pnsw().

01826           :    
01827       Corrects Earth-fixed geocentric rectangular coordinates for polar
01828       motion.  Transforms a vector from Earth-fixed geographic system to
01829       rotating system based on rotational equator and orthogonal
01830       Greenwich meridian through axis of rotation.
01831 
01832    REFERENCES: 
01833       Kaplan, G. H. et. al. (1989). Astron. Journ. Vol. 97, 
01834          pp. 1197-1210.
01835       Kaplan, G. H. "NOVAS: Naval Observatory Vector Astrometry
01836          Subroutines"; USNO internal document dated 20 Oct 1988;
01837          revised 15 Mar 1990.
01838 
01839    INPUT
01840    ARGUMENTS:
01841       x (double)
01842          Conventionally-defined X coordinate of rotational pole with
01843          respect to CIO, in arcseconds.
01844       y (double)
01845          Conventionally-defined Y coordinate of rotational pole with
01846          respect to CIO, in arcseconds.
01847       pos1[3] (double)
01848          Vector in geocentric rectangular Earth-fixed system,
01849          referred to geographic equator and Greenwich meridian.
01850 
01851    OUTPUT
01852    ARGUMENTS:
01853       pos2[3] (double)
01854          Vector in geocentric rectangular rotating system, referred
01855          to rotational equator and orthogonal Greenwich meridian
01856 
01857    RETURNED
01858    VALUE:
01859       None.
01860 
01861    GLOBALS
01862    USED:
01863       RAD2SEC
01864 
01865    FUNCTIONS
01866    CALLED:
01867       None.
01868 
01869    VER./DATE/
01870    PROGRAMMER:
01871       V1.0/08-93/WTH (USNO/AA) Translate Fortran.
01872 
01873    NOTES:
01874       1. This function is the "C" version of Fortran NOVAS routine
01875       'wobble'.
01876 
01877 ------------------------------------------------------------------------
01878 */
01879 {
01880    double xpole, ypole, zx, zy, xz, yz;
01881 
01882    xpole = x / RAD2SEC;
01883    ypole = y / RAD2SEC;
01884    
01885 /*
01886    Wobble rotation matrix follows.
01887 */
01888 
01889    zx = -xpole;
01890    zy =  ypole;
01891    xz =  xpole;
01892    yz = -ypole;
01893 
01894 /*
01895    Perform rotation.
01896 */
01897 
01898    pos2[0] = pos1[0] + zx * pos1[2];
01899    pos2[1] = pos1[1] + zy * pos1[2];
01900    pos2[2] = xz * pos1[0] + yz * pos1[1] + pos1[2];
01901 
01902    return;
01903 }


Generated on 2 Nov 2017 for loon by  doxygen 1.6.1