forked from brandon-rhodes/pyephem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastro.h
821 lines (695 loc) · 27.5 KB
/
astro.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
#ifndef _ASTRO_H
#define _ASTRO_H
/* for PyEphem: silence Windows complaints about sprintf() */
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
#ifndef PI
#define PI 3.141592653589793
#endif
/* conversions among hours (of ra), degrees and radians. */
#define degrad(x) ((x)*PI/180.)
#define raddeg(x) ((x)*180./PI)
#define hrdeg(x) ((x)*15.)
#define deghr(x) ((x)/15.)
#define hrrad(x) degrad(hrdeg(x))
#define radhr(x) deghr(raddeg(x))
/* ratio of from synodic (solar) to sidereal (stellar) rate */
#define SIDRATE .9972695677
/* manifest names for planets.
* N.B. must coincide with usage in pelement.c and plans.c.
* N.B. only the first 8 are valid for use with plans().
*/
typedef enum {
MERCURY,
VENUS,
MARS,
JUPITER,
SATURN,
URANUS,
NEPTUNE,
PLUTO,
SUN,
MOON,
NOBJ /* total number of basic objects */
} PLCode;
/* moon constants for pl_moon */
typedef enum {
X_PLANET = 0, /* use to mean planet itself */
PHOBOS = NOBJ, DEIMOS,
IO, EUROPA, GANYMEDE, CALLISTO,
MIMAS, ENCELADUS, TETHYS, DIONE, RHEA, TITAN, HYPERION, IAPETUS,
ARIEL, UMBRIEL, TITANIA, OBERON, MIRANDA,
NBUILTIN
} MCode;
/* starting point for MJD calculations
*/
#define MJD0 2415020.0
#define J2000 (2451545.0 - MJD0) /* yes, 2000 January 1 at 12h */
/* the Now and Obj typedefs.
* also, a few miscellaneous constants and declarations.
*/
#define SPD (24.0*3600.0) /* seconds per day */
#define MAU (1.4959787e11) /* m / au */
#define LTAU 499.005 /* seconds light takes to travel 1 AU */
#define ERAD (6.37816e6) /* earth equitorial radius, m */
#define MRAD (1.740e6) /* moon equitorial radius, m */
#define SRAD (6.95e8) /* sun equitorial radius, m */
#define FTPM 3.28084 /* ft per m */
#define ESAT_MAG 2 /* default satellite magnitude */
#define FAST_SAT_RPD 0.25 /* max earth sat rev/day considered "fast" */
#define EOD (-9786) /* special epoch flag: use epoch of date */
/* info about the local observing circumstances and misc preferences */
typedef struct {
double n_mjd; /* modified Julian date, ie, days since
* Jan 0.5 1900 (== 12 noon, Dec 30, 1899), utc.
* enough precision to get well better than 1 second.
* N.B. if not first member, must move NOMJD inits.
*/
double n_lat; /* geographic (surface-normal) lt, >0 north, rads */
double n_lng; /* longitude, >0 east, rads */
double n_tz; /* time zone, hrs behind UTC */
double n_temp; /* atmospheric temp, degrees C */
double n_pressure; /* atmospheric pressure, mBar */
double n_elev; /* elevation above sea level, earth radii */
double n_dip; /* dip of sun below hzn at twilight, >0 below, rads */
double n_epoch; /* desired precession display ep as an mjd, or EOD */
char n_tznm[8]; /* time zone name; 7 chars or less, always 0 at end */
} Now;
/* handy shorthands for fields in a Now pointer, np */
#define mjd np->n_mjd
#define lat np->n_lat
#define lng np->n_lng
#define tz np->n_tz
#define temp np->n_temp
#define pressure np->n_pressure
#define elev np->n_elev
#define dip np->n_dip
#define epoch np->n_epoch
#define tznm np->n_tznm
#define mjed mm_mjed(np)
/* structures to describe objects of various types.
*/
/* magnitude values in two different systems */
typedef struct {
float m1, m2; /* either g/k or H/G, depending on... */
int whichm; /* one of MAG_gk or MAG_HG */
} Mag;
/* whichm */
#define MAG_HG 0 /* using 0 makes HG the initial default */
#define MAG_gk 1
/* we actually store magnitudes times this scale factor in a short int */
#define MAGSCALE 100.0
#define set_smag(op,m) ((op)->s_mag = (short)floor((m)*MAGSCALE + 0.5))
#define set_fmag(op,m) ((op)->f_mag = (short)floor((m)*MAGSCALE + 0.5))
#define get_mag(op) ((op)->s_mag / MAGSCALE)
#define get_fmag(op) ((op)->f_mag / MAGSCALE)
/* longest object name, including trailing '\0' */
#define MAXNM 21
typedef unsigned char ObjType_t;
typedef unsigned char ObjAge_t;
typedef unsigned char byte;
/* Obj is a massive union.
* many fields are in common so we use macros to make things a little easier.
*/
/* fields common to *all* structs in the Obj union */
#define OBJ_COMMON_FLDS \
ObjType_t co_type; /* current object type; see flags, below */ \
byte co_flags; /* FUSER*... used by others */ \
ObjAge_t co_age; /* update aging code; see db.c */ \
char co_name[MAXNM];/* name, including \0 */ \
double co_ra; /* geo/topo app/mean ra, rads */ \
double co_dec; /* geo/topo app/mean dec, rads */ \
double co_gaera; /* geo apparent ra, rads */ \
double co_gaedec; /* geo apparent dec, rads */ \
double co_astrora; /* geo astrometric ra, rads */ \
double co_astrodec; /* geo astrometric dec, rads */ \
float co_az; /* azimuth, >0 e of n, rads */ \
float co_alt; /* altitude above topocentric horizon, rads */ \
float co_elong; /* angular sep btwen obj and sun, >0 E, degs */ \
float co_size; /* angular size, arc secs */ \
short co_mag /* visual magnitude * MAGSCALE */
/* fields common to all solar system objects in the Obj union */
#define OBJ_SOLSYS_FLDS \
OBJ_COMMON_FLDS; /* all the fixed ones plus ... */ \
float so_sdist; /* dist from object to sun, au */ \
float so_edist; /* dist from object to earth, au */ \
float so_hlong; /* heliocentric longitude, rads */ \
float so_hlat; /* heliocentric latitude, rads */ \
float so_phase /* phase, % */
/* fields common to all fixed objects in the Obj union */
#define OBJ_FIXED_FLDS \
char fo_spect[2]; /* spectral codes, if appropriate */ \
double fo_epoch; /* eq of ra/dec and time when pm=0; mjd */ \
double fo_ra; /* ra, rads, in epoch frame */ \
double fo_dec; /* dec, rads, in epoch frame */ \
float fo_pmra; /* ra proper motion, rads/day/cos(dec) */ \
float fo_pmdec; /* dec proper motion, rads/day */ \
char fo_class /* object class */
/* a generic object */
typedef struct {
OBJ_COMMON_FLDS;
} ObjAny;
/* a generic sol system object */
typedef struct {
OBJ_SOLSYS_FLDS;
} ObjSS;
/* basic Fixed object info.
*/
typedef struct {
OBJ_COMMON_FLDS;
OBJ_FIXED_FLDS;
/* following are for galaxies */
byte fo_ratio; /* minor/major diameter ratio. use s/get_ratio() */
byte fo_pa; /* position angle, E of N, rads. use s/get_pa() */
} ObjF;
/* true-orbit parameters of binary-star object type */
typedef struct {
float bo_T; /* epoch of periastron, years */
float bo_e; /* eccentricity */
float bo_o; /* argument of periastron, degress */
float bo_O; /* longitude of node, degrees */
float bo_i; /* inclination to plane of sky, degrees */
float bo_a; /* semi major axis, arc secs */
float bo_P; /* period, years */
/* companion position, computed by obj_cir() iff b_2compute */
float bo_pa; /* position angle @ ep, rads E of N */
float bo_sep; /* separation @ ep, arc secs */
float bo_ra; /* geo/topo app/mean ra, rads */
float bo_dec; /* geo/topo app/mean dec, rads */
} BinOrbit;
typedef struct {
float bp_ep; /* epoch of pa/sep, year */
float bp_pa; /* position angle @ ep, rads E of N */
float bp_sep; /* separation @ ep, arc secs */
/* companion position, computed by obj_cir() iff b_2compute */
float bp_ra; /* geo/topo app/mean ra, rads */
float bp_dec; /* geo/topo app/mean dec, rads */
} BinPos;
#define MAXBINPOS 2 /* max discrete epochs to store when no elements */
typedef struct {
OBJ_COMMON_FLDS;
OBJ_FIXED_FLDS;
byte b_2compute; /* whether to compute secondary positions */
byte b_nbp; /* number of b_bp[] or 0 to use b_bo */
short b_2mag; /* secondary's magnitude * MAGSCALE */
char b_2spect[2]; /* secondary's spectrum */
/* either a real orbit or a set of discrete pa/sep */
union {
BinOrbit b_bo; /* orbital elements */
BinPos b_bp[MAXBINPOS]; /* table of discrete positions */
} u;
} ObjB;
#define fo_mag co_mag /* pseudonym for so_mag since it is not computed */
#define fo_size co_size /* pseudonym for so_size since it is not computed */
/* macros to pack/unpack some fields */
#define SRSCALE 255.0 /* galaxy size ratio scale */
#define PASCALE (255.0/(2*PI)) /* pos angle scale factor */
#define get_ratio(op) (((int)(op)->f_ratio)/SRSCALE)
#define set_ratio(op,maj,min) ((op)->f_ratio = (byte)(((maj) > 0) \
? ((min)*SRSCALE/(double)(maj)+0.5) \
: 0))
#define get_pa(op) ((double)(op)->f_pa/PASCALE)
#define set_pa(op,s) ((op)->f_pa = (byte)((s)*PASCALE + 0.5))
#define NCLASSES 128 /* n potential fo_classes -- allow for all ASCII */
/* basic planet object info */
typedef struct {
OBJ_SOLSYS_FLDS;
PLCode plo_code; /* which planet */
MCode plo_moon; /* which moon, or X_PLANET if planet */
char plo_evis, plo_svis; /* if moon: whether visible from earth, sun */
double plo_x, plo_y, plo_z; /* if moon: eq dist from center, planet radii */
double plo_aux1, plo_aux2; /* various values, depending on type */
} ObjPl;
/* basic info about an object in elliptical heliocentric orbit */
typedef struct {
OBJ_SOLSYS_FLDS;
float eo_inc; /* inclination, degrees */
float eo_Om; /* longitude of ascending node, degrees */
float eo_om; /* argument of perihelion, degress */
float eo_a; /* mean distance, aka,semi-maj axis,AU */
float eo_M; /* mean anomaly, ie, degrees from perihelion at cepoch*/
float eo_size; /* angular size, in arc seconds at 1 AU */
float eo_startok; /* nominal first mjd this set is ok, else 0 */
float eo_endok; /* nominal last mjd this set is ok, else 0 */
double eo_e; /* eccentricity (double for when near 1 computing q) */
double eo_cepoch; /* epoch date (M reference), as an mjd */
double eo_epoch; /* equinox year (inc/Om/om reference), as an mjd. */
Mag eo_mag; /* magnitude */
} ObjE;
/* basic info about an object in hyperbolic heliocentric orbit */
typedef struct {
OBJ_SOLSYS_FLDS;
double ho_epoch; /* equinox year (inc/Om/om reference), as an mjd */
double ho_ep; /* epoch of perihelion, as an mjd */
float ho_startok; /* nominal first mjd this set is ok, else 0 */
float ho_endok; /* nominal last mjd this set is ok, else 0 */
float ho_inc; /* inclination, degs */
float ho_Om; /* longitude of ascending node, degs */
float ho_om; /* argument of perihelion, degs. */
float ho_e; /* eccentricity */
float ho_qp; /* perihelion distance, AU */
float ho_g, ho_k; /* magnitude model coefficients */
float ho_size; /* angular size, in arc seconds at 1 AU */
} ObjH;
/* basic info about an object in parabolic heliocentric orbit */
typedef struct {
OBJ_SOLSYS_FLDS;
double po_epoch; /* reference epoch, as an mjd */
double po_ep; /* epoch of perihelion, as an mjd */
float po_startok; /* nominal first mjd this set is ok, else 0 */
float po_endok; /* nominal last mjd this set is ok, else 0 */
float po_inc; /* inclination, degs */
float po_qp; /* perihelion distance, AU */
float po_om; /* argument of perihelion, degs. */
float po_Om; /* longitude of ascending node, degs */
float po_g, po_k; /* magnitude model coefficients */
float po_size; /* angular size, in arc seconds at 1 AU */
} ObjP;
/* basic earth satellite object info */
typedef struct {
OBJ_COMMON_FLDS;
double eso_epoch; /* reference epoch, as an mjd */
double eso_n; /* mean motion, rev/day
* N.B. we need double due to a sensitive differencing
* operation used to compute MeanAnomaly in
* esat_main()/satellite.c.
*/
float eso_startok; /* nominal first mjd this set is ok, else 0 */
float eso_endok; /* nominal last mjd this set is ok, else 0 */
float eso_inc; /* inclination, degs */
float eso_raan; /* RA of ascending node, degs */
float eso_e; /* eccentricity */
float eso_ap; /* argument of perigee at epoch, degs */
float eso_M; /* mean anomaly, ie, degrees from perigee at epoch */
float eso_decay; /* orbit decay rate, rev/day^2 */
float eso_drag; /* object drag coefficient, (earth radii)^-1 */
int eso_orbit; /* integer orbit number of epoch */
/* computed "sky" results unique to earth satellites */
float ess_elev; /* height of satellite above sea level, m */
float ess_range; /* line-of-site distance from observer to satellite, m*/
float ess_rangev; /* rate-of-change of range, m/s */
float ess_sublat; /* latitude below satellite, >0 north, rads */
float ess_sublng; /* longitude below satellite, >0 east, rads */
int ess_eclipsed;/* 1 if satellite is in earth's shadow, else 0 */
} ObjES;
typedef union {
ObjAny any; /* these fields valid for all types */
ObjSS anyss; /* these fields valid for all solar system types */
ObjPl pl; /* planet */
ObjF f; /* fixed object, plus proper motion */
ObjB b; /* bona fide binary stars (doubles are stored in f) */
ObjE e; /* object in heliocentric elliptical orbit */
ObjH h; /* object in heliocentric hyperbolic trajectory */
ObjP p; /* object in heliocentric parabolic trajectory */
ObjES es; /* earth satellite */
} Obj;
/* for o_flags -- everybody must agree */
#define FUSER0 0x01
#define FUSER1 0x02
#define FUSER2 0x04
#define FUSER3 0x08
#define FUSER4 0x10
#define FUSER5 0x20
#define FUSER6 0x40
#define FUSER7 0x80
/* mark an object as being a "field star" */
#define FLDSTAR FUSER3
/* mark an object as circum calculation failed */
#define NOCIRCUM FUSER7
/* Obj shorthands: */
#define o_type any.co_type
#define o_name any.co_name
#define o_flags any.co_flags
#define o_age any.co_age
#define s_ra any.co_ra
#define s_dec any.co_dec
#define s_gaera any.co_gaera
#define s_gaedec any.co_gaedec
#define s_astrora any.co_astrora
#define s_astrodec any.co_astrodec
#define s_az any.co_az
#define s_alt any.co_alt
#define s_elong any.co_elong
#define s_size any.co_size
#define s_mag any.co_mag
#define s_sdist anyss.so_sdist
#define s_edist anyss.so_edist
#define s_hlong anyss.so_hlong
#define s_hlat anyss.so_hlat
#define s_phase anyss.so_phase
#define s_elev es.ess_elev
#define s_range es.ess_range
#define s_rangev es.ess_rangev
#define s_sublat es.ess_sublat
#define s_sublng es.ess_sublng
#define s_eclipsed es.ess_eclipsed
#define f_class f.fo_class
#define f_spect f.fo_spect
#define f_ratio f.fo_ratio
#define f_pa f.fo_pa
#define f_epoch f.fo_epoch
#define f_RA f.fo_ra
#define f_pmRA f.fo_pmra
#define f_dec f.fo_dec
#define f_pmdec f.fo_pmdec
#define f_mag f.fo_mag
#define f_size f.fo_size
#define e_cepoch e.eo_cepoch
#define e_epoch e.eo_epoch
#define e_startok e.eo_startok
#define e_endok e.eo_endok
#define e_inc e.eo_inc
#define e_Om e.eo_Om
#define e_om e.eo_om
#define e_a e.eo_a
#define e_e e.eo_e
#define e_M e.eo_M
#define e_size e.eo_size
#define e_mag e.eo_mag
#define h_epoch h.ho_epoch
#define h_startok h.ho_startok
#define h_endok h.ho_endok
#define h_ep h.ho_ep
#define h_inc h.ho_inc
#define h_Om h.ho_Om
#define h_om h.ho_om
#define h_e h.ho_e
#define h_qp h.ho_qp
#define h_g h.ho_g
#define h_k h.ho_k
#define h_size h.ho_size
#define p_epoch p.po_epoch
#define p_startok p.po_startok
#define p_endok p.po_endok
#define p_ep p.po_ep
#define p_inc p.po_inc
#define p_qp p.po_qp
#define p_om p.po_om
#define p_Om p.po_Om
#define p_g p.po_g
#define p_k p.po_k
#define p_size p.po_size
#define es_epoch es.eso_epoch
#define es_startok es.eso_startok
#define es_endok es.eso_endok
#define es_inc es.eso_inc
#define es_raan es.eso_raan
#define es_e es.eso_e
#define es_ap es.eso_ap
#define es_M es.eso_M
#define es_n es.eso_n
#define es_decay es.eso_decay
#define es_drag es.eso_drag
#define es_orbit es.eso_orbit
#define pl_code pl.plo_code
#define pl_moon pl.plo_moon
#define pl_evis pl.plo_evis
#define pl_svis pl.plo_svis
#define pl_x pl.plo_x
#define pl_y pl.plo_y
#define pl_z pl.plo_z
#define pl_aux1 pl.plo_aux1
#define pl_aux2 pl.plo_aux2
#define b_2compute b.b_2compute
#define b_2spect b.b_2spect
#define b_2mag b.b_2mag
#define b_bo b.u.b_bo
#define b_bp b.u.b_bp
#define b_nbp b.b_nbp
/* insure we always refer to the fields and no monkey business */
#undef OBJ_COMMON_FLDS
#undef OBJ_SOLSYS_FLDS
/* o_type code.
* N.B. names are assigned in order in objmenu.c
* N.B. if add one add switch in obj_cir().
* N.B. UNDEFOBJ must be zero so new objects are undefinied by being zeroed.
* N.B. maintain the bitmasks too.
*/
enum ObjType {
UNDEFOBJ=0,
FIXED, BINARYSTAR, ELLIPTICAL, HYPERBOLIC, PARABOLIC, EARTHSAT, PLANET,
NOBJTYPES
};
/* types as handy bitmasks too */
#define OBJTYPE2MASK(t) (1<<(t))
#define FIXEDM OBJTYPE2MASK(FIXED)
#define BINARYSTARM OBJTYPE2MASK(BINARYSTAR)
#define ELLIPTICALM OBJTYPE2MASK(ELLIPTICAL)
#define HYPERBOLICM OBJTYPE2MASK(HYPERBOLIC)
#define PARABOLICM OBJTYPE2MASK(PARABOLIC)
#define EARTHSATM OBJTYPE2MASK(EARTHSAT)
#define PLANETM OBJTYPE2MASK(PLANET)
#define ALLM (~0)
/* rise, set and transit information.
*/
typedef struct {
int rs_flags; /* info about what has been computed and any
* special conditions; see flags, below.
*/
double rs_risetm; /* mjd time of rise today */
double rs_riseaz; /* azimuth of rise, rads E of N */
double rs_trantm; /* mjd time of transit today */
double rs_tranalt; /* altitude of transit, rads up from horizon */
double rs_tranaz; /* azimuth of transit, rads E of N */
double rs_settm; /* mjd time of set today */
double rs_setaz; /* azimuth of set, rads E of N */
} RiseSet;
/* RiseSet flags */
#define RS_NORISE 0x0001 /* object does not rise as such today */
#define RS_NOSET 0x0002 /* object does not set as such today */
#define RS_NOTRANS 0x0004 /* object does not transit as such today */
#define RS_CIRCUMPOLAR 0x0010 /* object stays up all day today */
#define RS_NEVERUP 0x0020 /* object never up at all today */
#define RS_ERROR 0x1000 /* can't figure out anything! */
#define RS_RISERR (0x0100|RS_ERROR) /* error computing rise */
#define RS_SETERR (0x0200|RS_ERROR) /* error computing set */
#define RS_TRANSERR (0x0400|RS_ERROR) /* error computing transit */
#define is_type(op,m) (OBJTYPE2MASK((op)->o_type) & (m))
/* any planet or its moons */
#define is_planet(op,p) (is_type(op,PLANETM) && op->pl_code == (p))
/* any solar system object */
#define is_ssobj(op) is_type(op,PLANETM|HYPERBOLICM|PARABOLICM|ELLIPTICALM)
/* natural satellite support */
typedef struct {
char *full; /* full name */
char *tag; /* Roman numeral tag */
float x, y, z; /* sky loc in planet radii: +x:east +y:south +z:front */
float ra, dec; /* sky location in ra/dec */
float mag; /* magnitude */
int evis; /* whether geometrically visible from earth */
int svis; /* whether in sun light */
int pshad; /* whether moon is casting shadow on planet */
int trans; /* whether moon is transiting */
float sx, sy; /* shadow sky loc in planet radii: +x:east +y:south */
} MoonData;
/* separate set for each planet -- use in pl_moon */
enum _marsmoons {
M_MARS = 0, /* == X_PLANET */
M_PHOBOS, M_DEIMOS,
M_NMOONS /* including planet at 0 */
};
enum _jupmoons {
J_JUPITER = 0, /* == X_PLANET */
J_IO, J_EUROPA, J_GANYMEDE, J_CALLISTO,
J_NMOONS /* including planet */
};
enum _satmoons {
S_SATURN = 0, /* == X_PLANET */
S_MIMAS, S_ENCELADUS, S_TETHYS, S_DIONE,
S_RHEA, S_TITAN, S_HYPERION, S_IAPETUS,
S_NMOONS /* including planet */
};
enum _uramoons {
U_URANUS = 0, /* == X_PLANET */
U_ARIEL, U_UMBRIEL, U_TITANIA, U_OBERON, U_MIRANDA,
U_NMOONS /* including planet */
};
#define X_MAXNMOONS S_NMOONS /* N.B. chosen by hand */
/* global function declarations */
/* aa_hadec.c */
extern void aa_hadec (double lt, double alt, double az, double *ha,
double *dec);
extern void hadec_aa (double lt, double ha, double dec, double *alt,
double *az);
/* aberration.c */
extern void ab_ecl (double m, double lsn, double *lam, double *bet);
extern void ab_eq (double m, double lsn, double *ra, double *dec);
/* airmass.c */
extern void airmass (double aa, double *Xp);
/* anomaly.c */
extern void anomaly (double ma, double s, double *nu, double *ea);
/* ap_as.c */
extern void ap_as ( Now *np, double Mjd, double *rap, double *decp);
extern void as_ap ( Now *np, double Mjd, double *rap, double *decp);
/* atlas.c */
extern char *um_atlas (double ra, double dec);
extern char *u2k_atlas (double ra, double dec);
extern char *msa_atlas (double ra, double dec);
/* aux.c */
extern double mm_mjed (Now *np);
/* chap95.c */
extern int chap95 (double m, int obj, double prec, double *ret);
/* chap95_data.c */
/* circum.c */
extern int obj_cir (Now *np, Obj *op);
/* comet.c */
extern void comet (double m, double ep, double inc, double ap, double qp,
double om, double *lpd, double *psi, double *rp, double *rho, double *lam,
double *bet);
/* constel.c */
#define NCNS 89
extern int cns_pick (double r, double d, double e);
extern int cns_id (char *abbrev);
extern char *cns_name (int id);
extern int cns_edges (double e, double **ra0p, double **dec0p, double **ra1p,
double **dec1p);
extern int cns_list (double ra, double dec, double e, double rad, int ids[]);
extern int cns_figure (int id, double e, double ra[],double dec[],int dcodes[]);
extern int cns_loadfigs (FILE *fp, char msg[]);
/* dbfmt.c */
extern int db_crack_line (char s[], Obj *op, char nm[][MAXNM], int nnm,
char whynot[]);
extern void db_write_line (Obj *op, char *lp);
extern int dbline_candidate (char line[]);
extern int get_fields (char *s, int delim, char *fields[]);
extern int db_tle (char *name, char *l1, char *l2, Obj *op);
extern int dateRangeOK (Now *np, Obj *op);
/* deltat.c */
extern double deltat (double m);
/* earthsat.c */
extern int obj_earthsat (Now *np, Obj *op);
/* eq_ecl.c */
extern void eq_ecl (double m, double ra, double dec, double *lt,double *lg);
extern void ecl_eq (double m, double lt, double lg, double *ra,double *dec);
/* eq_gal.c */
extern void eq_gal (double m, double ra, double dec, double *lt,double *lg);
extern void gal_eq (double m, double lt, double lg, double *ra,double *dec);
/* formats.c */
extern int fs_sexa (char *out, double a, int w, int fracbase);
extern int fs_date (char out[], int format, double jd);
extern int f_scansexa (const char *str, double *dp);
extern void f_sscandate (char *bp, int pref, int *m, double *d, int *y);
/* helio.c */
extern void heliocorr (double jd, double ra, double dec, double *hcp);
/* jupmoon.c */
extern void jupiter_data (double Mjd, char dir[], Obj *sop, Obj *jop,
double *jupsize, double *cmlI, double *cmlII, double *polera,
double *poledec, MoonData md[J_NMOONS]);
extern void meeus_jupiter (double d, double *cmlI, double *cmlII,
MoonData md[J_NMOONS]);
/* libration.c */
extern void llibration (double JD, double *llatp, double *llonp);
/* magdecl.c */
extern int magdecl (double l, double L, double e, double y, char *dir,
double *dp, char *err);
/* marsmoon.c */
extern void marsm_data (double Mjd, char dir[], Obj *sop, Obj *mop,
double *marssize, double *polera, double *poledec, MoonData md[M_NMOONS]);
/* misc.c */
extern void zero_mem (void *loc, unsigned len);
extern int tickmarks (double min, double max, int numdiv, double ticks[]);
extern int lc (int cx, int cy, int cw, int x1, int y1, int x2, int y2,
int *sx1, int *sy1, int *sx2, int *sy2);
extern void hg_mag (double h, double g, double rp, double rho, double rsn,
double *mp);
extern int magdiam (int fmag, int magstp, double scale, double mag,
double size);
extern void gk_mag (double g, double k, double rp, double rho, double *mp);
extern double atod (char *buf);
extern void solve_sphere (double A, double b, double cc, double sc,
double *cap, double *Bp);
extern double delra (double dra);
extern void now_lst (Now *np, double *lstp);
extern void radec2ha (Now *np, double ra, double dec, double *hap);
extern void gha (Now *np, Obj *op, double *ghap);
extern char *obj_description (Obj *op);
extern int is_deepsky (Obj *op);
/* mjd.c */
extern void cal_mjd (int mn, double dy, int yr, double *m);
extern void mjd_cal (double m, int *mn, double *dy, int *yr);
extern int mjd_dow (double m, int *dow);
extern int isleapyear (int year);
extern void mjd_dpm (double m, int *ndays);
extern void mjd_year (double m, double *yr);
extern void year_mjd (double y, double *m);
extern void rnd_second (double *t);
extern void mjd_dayno (double jd, int *yr, double *dy);
extern double mjd_day (double jd);
extern double mjd_hr (double jd);
extern void range (double *v, double r);
extern void radecrange (double *ra, double *dec);
/* moon.c */
extern void moon (double m, double *lam, double *bet, double *rho,
double *msp, double *mdp);
/* mooncolong.c */
extern void moon_colong (double jd, double lt, double lg, double *cp,
double *kp, double *ap, double *sp);
/* moonnf.c */
extern void moonnf (double mj, double *mjn, double *mjf);
/* nutation.c */
extern void nutation (double m, double *deps, double *dpsi);
extern void nut_eq (double m, double *ra, double *dec);
/* obliq.c */
extern void obliquity (double m, double *eps);
/* parallax.c */
extern void ta_par (double tha, double tdec, double phi, double ht,
double *rho, double *aha, double *adec);
/* parallactic.c */
extern double parallacticLDA (double lt, double dec, double alt);
extern double parallacticLHD (double lt, double ha, double dec);
/* plans.c */
extern void plans (double m, PLCode p, double *lpd0, double *psi0,
double *rp0, double *rho0, double *lam, double *bet, double *dia,
double *mag);
/* plshadow.c */
extern int plshadow (Obj *op, Obj *sop, double polera,
double poledec, double x, double y, double z, float *sxp, float *syp);
/* plmoon_cir.c */
extern int plmoon_cir (Now *np, Obj *moonop);
extern int getBuiltInObjs (Obj **opp);
extern void setMoonDir (char *dir);
/* precess.c */
extern void precess (double mjd1, double mjd2, double *ra, double *dec);
/* reduce.c */
extern void reduce_elements (double mjd0, double m, double inc0,
double ap0, double om0, double *inc, double *ap, double *om);
/* refract.c */
extern void unrefract (double pr, double tr, double aa, double *ta);
extern void refract (double pr, double tr, double ta, double *aa);
/* rings.c */
extern void satrings (double sb, double sl, double sr, double el, double er,
double JD, double *etiltp, double *stiltp);
/* riset.c */
extern void riset (double ra, double dec, double lt, double dis,
double *lstr, double *lsts, double *azr, double *azs, int *status);
/* riset_cir.c */
extern void riset_cir (Now *np, Obj *op, double dis, RiseSet *rp);
extern void twilight_cir (Now *np, double dis, double *dawn, double *dusk,
int *status);
/* satmoon.c */
extern void saturn_data (double Mjd, char dir[], Obj *eop, Obj *sop,
double *satsize, double *etilt, double *stlit, double *polera,
double *poledec, MoonData md[S_NMOONS]);
/* sphcart.c */
extern void sphcart (double l, double b, double r, double *x, double *y,
double *z);
extern void cartsph (double x, double y, double z, double *l, double *b,
double *r);
/* sun.c */
extern void sunpos (double m, double *lsn, double *rsn, double *bsn);
/* twobody.c */
extern int vrc (double *v, double *r, double tp, double e, double q);
/* umoon.c */
extern void uranus_data (double Mjd, char dir[], Obj *sop, Obj *uop,
double *usize, double *polera, double *poledec, MoonData md[U_NMOONS]);
/* utc_gst.c */
extern void utc_gst (double m, double utc, double *gst);
extern void gst_utc (double m, double gst, double *utc);
/* vsop87.c */
extern int vsop87 (double m, int obj, double prec, double *ret);
#endif /* _ASTRO_H */
/* For RCS Only -- Do Not Edit
* @(#) $RCSfile: astro.h,v $ $Date: 2013/01/06 01:12:57 $ $Revision: 1.33 $ $Name: $
*/