home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume19 / xephem / part08 / circum.h next >
Encoding:
C/C++ Source or Header  |  1993-05-15  |  10.7 KB  |  309 lines

  1. /* the Now and Obj typedefs.
  2.  * also, a few miscellaneous constants and declarations.
  3.  */
  4.  
  5. #define    SPD    (24.0*3600.0)    /* seconds per day */
  6. #define    MJD0    2415020L    /* JD at noon Dec 31, 1899 */
  7. #define    LTAU    499.005        /* seconds light takes to travel 1 AU */
  8. #define    ERAD    (6.37816e6)    /* earth equitorial radius, m */
  9. #define    FTPM    3.28084        /* ft per m */
  10.  
  11. #define    EOD    (-9786)        /* special epoch flag: use epoch of date */
  12. #define    RTC    (-1324)        /* special tminc flag: use rt clock */
  13. #define STDREF  degrad(34./60.) /* nominal horizon refraction amount */
  14.  
  15. /* info about the local observing circumstances and misc preferences */
  16. typedef struct {
  17.     double n_mjd;    /* modified Julian date, ie, days since
  18.              * Jan 0.5 1900 (== 12 noon, Dec 30, 1899), utc.
  19.              * enough precision to get well better than 1 second.
  20.              * N.B. if not first member, must move NOMJD inits.
  21.              */
  22.     double n_lat;    /* latitude, >0 north, rads */
  23.     double n_lng;    /* longitude, >0 east, rads */
  24.     double n_tz;    /* time zone, hrs behind UTC */
  25.     double n_temp;    /* atmospheric temp, degrees C */
  26.     double n_pressure; /* atmospheric pressure, mBar */
  27.     double n_elev;    /* elevation above sea level, earth radii */
  28.     double n_dip;    /* dip of sun below hzn at twilight, >0 below, rads */
  29.     double n_epoch;    /* desired precession display epoch as an mjd, or EOD */
  30.     char n_tznm[4];    /* time zone name; 3 chars or less, always 0 at end */
  31. } Now;
  32.  
  33. /* handy shorthands for fields a Now pointer, np */
  34. #define mjd    np->n_mjd
  35. #define lat    np->n_lat
  36. #define lng    np->n_lng
  37. #define tz    np->n_tz
  38. #define temp    np->n_temp
  39. #define pressure np->n_pressure
  40. #define elev    np->n_elev
  41. #define    dip    np->n_dip
  42. #define epoch    np->n_epoch
  43. #define tznm    np->n_tznm
  44.  
  45. /* structures to describe objects of various types.
  46.  */
  47.  
  48. /* magnitude values in two different systems */
  49. typedef struct {
  50.     float m1, m2;    /* either g/k or H/G, depending on... */
  51.     int whichm;        /* one of MAG_gk or MAG_HG */
  52. } Mag;
  53.  
  54. /* whichm */
  55. #define MAG_HG          0       /* using 0 makes HG the initial default */
  56. #define MAG_gk          1
  57.  
  58. /* we actually store magnitudes times this scale factor in a short int */
  59. #define    MAGSCALE    100.0
  60.  
  61. /* longest object name, including trailing '\0' */
  62. #define    MAXNM    14
  63.  
  64. /* Obj is a massize union.
  65.  * we break it basically into two kinds of objects:
  66.  *   fixed, which don't move and have no sol system coords;
  67.  *   solar system objects which do.
  68.  * much work is common to all objects, so we want the unions to overlap as
  69.  * much as pssible. Therefore, we collect some fields into macros to make
  70.  * this easier to maintain.
  71.  */
  72.  
  73. typedef unsigned char Objtype_t;
  74. typedef unsigned short Objage_t;
  75.  
  76. /* fields common to *all* structs in the Obj union.
  77.  * N.B. type must be first because it appears explicitly in the Obj union.
  78.  */
  79. #define    OBJ_COMMON_FLDS                            \
  80.     Objtype_t type;    /* current object type; see flags, below */    \
  81.     unsigned char co_flags;/* used by others */                \
  82.     char co_name[MAXNM];/* primary name */                \
  83.     Objage_t co_age;    /* s_* current code; see db.c */        \
  84.     float co_ra;    /* ra, rads (precessed to n_epoch) */        \
  85.     float co_dec;    /* dec, rads (precessed to n_epoch) */        \
  86.     float co_az;    /* azimuth, >0 e of n, rads */            \
  87.     float co_alt;    /* altitude above topocentric horizon, rads */    \
  88.     float co_elong;    /* angular sep btwen obj and sun, >0 if east */    \
  89.     unsigned short co_size; /* angular size, arc secs */        \
  90.     short co_mag    /* visual magnitude * MAGSCALE */
  91.  
  92. /* fields common to all solar system objects in the Obj union */
  93. #define    OBJ_SOLSYS_FLDS                            \
  94.     OBJ_COMMON_FLDS;    /* all the fixed ones plus ... */        \
  95.     float so_sdist;    /* dist from object to sun, au */        \
  96.     float so_edist;    /* dist from object to earth, au */        \
  97.     float so_hlong;    /* heliocentric longitude, rads */        \
  98.     float so_hlat;    /* heliocentric latitude, rads */        \
  99.     float so_phase    /* phase, % */
  100.  
  101.  
  102. /* a generic object */
  103. typedef struct {
  104.     OBJ_COMMON_FLDS;
  105. } ObjAny;
  106.  
  107. /* a generic sol system object */
  108. typedef struct {
  109.     OBJ_SOLSYS_FLDS;
  110. } ObjSS;
  111.  
  112. /* basic Fixed object info */
  113. typedef struct {
  114.     OBJ_COMMON_FLDS;
  115.     char  fo_class;    /* object class --  see db.c:db_set_field() et al */
  116.     char  fo_spect[2];    /* spectral codes, if appropriate */
  117.     float fo_epoch;    /* epoch of f_RA/dec */
  118.     float fo_ra;    /* ra, rads, at given epoch */
  119.     float fo_dec;    /* dec, rads, at given epoch */
  120. } ObjF;
  121. #define    fo_mag    co_mag    /* pseudonym for so_mag */
  122. #define    fo_size    co_size    /* pseudonym for so_size */
  123.  
  124. /* basic planet object info */
  125. typedef struct {
  126.     OBJ_SOLSYS_FLDS;
  127.     int code;        /* one of the codes in astro.h */
  128. } ObjPl;
  129.  
  130. /* basic info about an object in elliptical heliocentric orbit */
  131. typedef struct {
  132.     OBJ_SOLSYS_FLDS;
  133.     double eo_cepoch;    /* epoch date (M reference), as an mjd */
  134.     double eo_epoch;    /* equinox year (inc/Om/om reference), as an mjd. */
  135.     float  eo_inc;    /* inclination, degrees */
  136.     float  eo_Om;    /* longitude of ascending node, degrees */
  137.     float  eo_om;    /* argument of perihelion, degress */
  138.     float  eo_a;    /* mean distance, aka,semi-maj axis,AU */
  139.     float  eo_n;    /* daily motion, degrees/day */
  140.     float  eo_e;    /* eccentricity */
  141.     float  eo_M;    /* mean anomaly, ie, degrees from perihelion at cepoch*/
  142.     float  eo_size;    /* angular size, in arc seconds at 1 AU */
  143.     Mag    eo_mag;    /* magnitude */
  144. } ObjE;
  145.  
  146. /* basic info about an object in hyperbolic heliocentric orbit */
  147. typedef struct {
  148.     OBJ_SOLSYS_FLDS;
  149.     double ho_epoch;    /* equinox year (inc/Om/om reference), as an mjd */
  150.     double ho_ep;    /* epoch of perihelion, as an mjd */
  151.     float  ho_inc;    /* inclination, degs */
  152.     float  ho_Om;    /* longitude of ascending node, degs */
  153.     float  ho_om;    /* argument of perihelion, degs. */
  154.     float  ho_e;    /* eccentricity */
  155.     float  ho_qp;    /* perihelion distance, AU */
  156.     float  ho_g, ho_k;    /* magnitude model coefficients */
  157.     float  ho_size;    /* angular size, in arc seconds at 1 AU */
  158. } ObjH;
  159.  
  160. /* basic info about an object in parabolic heliocentric orbit */
  161. typedef struct {
  162.     OBJ_SOLSYS_FLDS;
  163.     double po_epoch;    /* reference epoch, as an mjd */
  164.     double po_ep;    /* epoch of perihelion, as an mjd */
  165.     float  po_inc;    /* inclination, degs */
  166.     float  po_qp;    /* perihelion distance, AU */
  167.     float  po_om;    /* argument of perihelion, degs. */
  168.     float  po_Om;    /* longitude of ascending node, degs */
  169.     float  po_g, po_k;    /* magnitude model coefficients */
  170.     float  po_size;    /* angular size, in arc seconds at 1 AU */
  171. } ObjP;
  172.  
  173. typedef union {
  174.     Objtype_t type;    /* union discriminator -- one of ObjType enum */
  175.     ObjAny  any;    /* these fields valid when type==FIXED */
  176.     ObjSS   anyss;    /* these fields valid when type other than FIXED */
  177.     ObjPl   pl;        /* planet */
  178.     ObjF    f;        /* fixed object */
  179.     ObjE    e;        /* object in heliocentric elliptical orbit */
  180.     ObjH    h;        /* object in heliocentric hyperbolic trajectory */
  181.     ObjP    p;        /* object in heliocentric parabolic trajectory */
  182. } Obj;
  183.  
  184. /* Obj shorthands: */
  185. #define    o_name    any.co_name
  186. #define    o_flags    any.co_flags
  187. #define    o_age    any.co_age
  188. #define    s_ra    any.co_ra
  189. #define    s_dec    any.co_dec
  190. #define    s_az    any.co_az
  191. #define    s_alt    any.co_alt
  192. #define    s_elong    any.co_elong
  193. #define    s_size    any.co_size
  194. #define    s_mag    any.co_mag
  195.  
  196. #define    s_sdist    anyss.so_sdist
  197. #define    s_edist    anyss.so_edist
  198. #define    s_hlong    anyss.so_hlong
  199. #define    s_hlat    anyss.so_hlat
  200. #define    s_phase anyss.so_phase
  201.  
  202. #define    f_class    f.fo_class
  203. #define    f_spect    f.fo_spect
  204. #define    f_epoch    f.fo_epoch
  205. #define    f_RA    f.fo_ra
  206. #define    f_dec    f.fo_dec
  207. #define    f_mag    f.fo_mag
  208. #define    f_size    f.fo_size
  209.  
  210. #define    e_cepoch e.eo_cepoch
  211. #define    e_epoch    e.eo_epoch
  212. #define    e_inc    e.eo_inc
  213. #define    e_Om    e.eo_Om
  214. #define    e_om    e.eo_om
  215. #define    e_a    e.eo_a
  216. #define    e_n    e.eo_n
  217. #define    e_e    e.eo_e
  218. #define    e_M    e.eo_M
  219. #define    e_size    e.eo_size
  220. #define    e_mag    e.eo_mag
  221.  
  222. #define    h_epoch    h.ho_epoch
  223. #define    h_ep    h.ho_ep
  224. #define    h_inc    h.ho_inc
  225. #define    h_Om    h.ho_Om
  226. #define    h_om    h.ho_om
  227. #define    h_e    h.ho_e
  228. #define    h_qp    h.ho_qp
  229. #define    h_g    h.ho_g
  230. #define    h_k    h.ho_k
  231. #define    h_size    h.ho_size
  232.  
  233. #define    p_epoch    p.po_epoch
  234. #define    p_ep    p.po_ep
  235. #define    p_inc    p.po_inc
  236. #define    p_qp    p.po_qp
  237. #define    p_om    p.po_om
  238. #define    p_Om    p.po_Om
  239. #define    p_g    p.po_g
  240. #define    p_k    p.po_k
  241. #define    p_size    p.po_size
  242.  
  243. /* insure we always refer to the fields and no monkey business */
  244. #undef OBJ_COMMON_FLDS
  245. #undef OBJ_SOLSYS_FLDS
  246.  
  247. /* type.
  248.  * N.B. names are assigned in order in objmenu.c
  249.  */
  250. enum ObjType {
  251.     UNDEFOBJ=0, FIXED, ELLIPTICAL, HYPERBOLIC, PARABOLIC,
  252.     PLANET    /* means code is one of those in astro.h. */
  253. };
  254. #define    NOBJTYPES    6    /* including UNDEFOBJ */
  255.  
  256. /* define a code for each member in each object type struct.
  257.  * making them globally unique avoids a nested switch in db_set_field() and
  258.  * helps with dynamic prompting based on preferences.
  259.  */
  260. enum {
  261.     O_TYPE, O_NAME,
  262.     F_RA, F_DEC, F_EPOCH, F_MAG, F_SIZE, F_CLASS, F_SPECT,
  263.     E_INC, E_LAN, E_AOP, E_A, E_N, E_E, E_M, E_CEPOCH, E_EPOCH,E_M1,E_M2,E_SIZE,
  264.     H_EP, H_INC, H_LAN, H_AOP, H_E, H_QP, H_EPOCH, H_G, H_K, H_SIZE,
  265.     P_EP, P_INC, P_AOP, P_QP, P_LAN, P_EPOCH, P_G, P_K, P_SIZE
  266. };
  267.  
  268. /* rise, set and transit information.
  269.  */
  270. typedef struct {
  271.     int rs_flags;    /* info about what has been computed and any
  272.              * special conditions; see flags, below.
  273.              */
  274.     double rs_risetm;    /* time of upper limb rise, 24 hr local hrs */
  275.     double rs_riseaz;    /* azimuth of upper limb rise, rads E of N */
  276.     double rs_trantm;    /* time of transit, 24 hr local hrs */
  277.     double rs_tranalt;    /* altitude of transit, rads up from horizon */
  278.     double rs_settm;    /* time of upper limb set, 24 hr local hrs */
  279.     double rs_setaz;    /* azimuth of upper limb set, rads E of N */
  280. } RiseSet;
  281.  
  282. /* RiseSet flags */
  283. #define    RS_RISE        0x0001    /* risetm/az have been attempted */
  284. #define    RS_TRANS    0x0002    /* trantm/alt have been attempted */
  285. #define    RS_SET        0x0004    /* settm/az have been attempted */
  286. #define    RS_NORISE    0x0008    /* object does not rise as such today */
  287. #define    RS_2RISES    0x0010    /* object rises more than once today */
  288. #define    RS_RISERR    0x0020    /* error computing rise info */
  289. #define    RS_NOSET    0x0040    /* object does not set as such today */
  290. #define    RS_2SETS    0x0080    /* object sets more than once today */
  291. #define    RS_CIRCUMPOLAR    0x0100    /* object stays up all day today */
  292. #define    RS_2TRANS    0x0200    /* transits twice in one day */
  293. #define    RS_NEVERUP    0x0400    /* object never rises today */
  294. #define    RS_NOTRANS    0x0800    /* doesn't transit today */
  295. #define    RS_ERROR    0x1000    /* can't figure out anything! */
  296.  
  297. #define    is_planet(op,p)    ((op)->type == PLANET && ((ObjPl *)op)->code == (p))
  298. #define    is_ssobj(op)    ((op)->type == PLANET             \
  299.                 || (op)->type == HYPERBOLIC        \
  300.                 || (op)->type == PARABOLIC         \
  301.                 || (op)->type == ELLIPTICAL)
  302.  
  303. /* flags for use with db_next */
  304. typedef enum {
  305.     OBJS_JUST_BASIC,    /* just the next among the ones in astro.h */
  306.     OBJS_ALLBUT_BASIC,    /* all objs *except* those in astro.h */
  307.     OBJS_ALL        /* all objs */
  308. } HowNext;
  309.