source: trunk/Mars/mcore/nova.h@ 17748

Last change on this file since 17748 was 16974, checked in by tbretz, 11 years ago
Fixed a typo in the last commit.
File size: 4.2 KB
Line 
1#ifndef MARS_Nova
2#define MARS_Nova
3
4#include <libnova/solar.h>
5#include <libnova/lunar.h>
6#include <libnova/rise_set.h>
7#include <libnova/transform.h>
8#include <libnova/angular_separation.h>
9
10namespace Nova
11{
12 typedef ln_lnlat_posn LnLatPosn;
13 typedef ln_rst_time RstTime; // Note that times are in JD not Mjd
14 //typedef ln_hrz_posn HrzPosn;
15 //typedef ln_equ_posn EquPosn;
16
17 struct ZdAzPosn;
18 struct RaDecPosn;
19
20
21 // Warning: 0deg=South, 90deg=W
22 struct HrzPosn : public ln_hrz_posn
23 {
24 HrzPosn() { }
25 HrzPosn(const ZdAzPosn &);
26 };
27
28 struct ZdAzPosn
29 {
30 double zd; // [deg]
31 double az; // [deg]
32
33 ZdAzPosn(double z=0, double a=0) : zd(z), az(a) { }
34 ZdAzPosn(const HrzPosn &hrz) : zd(90-hrz.alt), az(hrz.az-180) { }
35
36 // This crahsed cint, but it could save up the dedicate structure HrzPosn :(
37 //operator HrzPosn() const { const HrzPosn p = { az-180, 90-zd}; return p; }
38 };
39
40 HrzPosn::HrzPosn(const ZdAzPosn &za) { alt = 90-za.zd; az = za.az-180; }
41
42
43 // Note that right ascension is stored in degree
44 struct EquPosn : public ln_equ_posn
45 {
46 EquPosn() { }
47 EquPosn(const RaDecPosn &);
48 };
49
50 struct RaDecPosn
51 {
52 double ra; // [h]
53 double dec; // [deg]
54
55 RaDecPosn(double r=0, double d=0) : ra(r), dec(d) { }
56 RaDecPosn(const EquPosn &equ) : ra(equ.ra/15), dec(equ.dec) { }
57
58 // This crahsed cint, but it could save up the dedicate structure HrzPosn :(
59 //operator HrzPosn() const { const HrzPosn p = { az-180, 90-zd}; return p; }
60 };
61
62 EquPosn::EquPosn(const RaDecPosn &rd) { ra = rd.ra*15; dec = rd.dec; }
63
64
65
66 const LnLatPosn &ORM()
67 {
68 //static LnLatPosn obs;
69 //obs.lng = -(17.+53./60+26.525/3600);
70 //obs.lat = 28.+45./60+42.462/3600;
71 const static LnLatPosn obs = { -(17.+53./60+26.525/3600), 28.+45./60+42.462/3600 };
72 return obs;
73 }
74
75 HrzPosn GetHrzFromEqu(const EquPosn &equ, const LnLatPosn &obs, double jd)
76 {
77 HrzPosn hrz;
78 ln_get_hrz_from_equ(const_cast<EquPosn*>(&equ), const_cast<LnLatPosn*>(&obs), jd, &hrz);
79 return hrz;
80 }
81 HrzPosn GetHrzFromEqu(const EquPosn &equ, double jd)
82 {
83 return GetHrzFromEqu(equ, ORM(), jd);
84 }
85
86 EquPosn GetEquFromHrz(const HrzPosn &hrz, const LnLatPosn &obs, double jd)
87 {
88 EquPosn equ;
89 ln_get_equ_from_hrz(const_cast<HrzPosn*>(&hrz), const_cast<LnLatPosn*>(&obs), jd, &equ);
90 return equ;
91 }
92 EquPosn GetEquFromHrz(const HrzPosn &hrz, double jd)
93 {
94 return GetEquFromHrz(hrz, ORM(), jd);
95 }
96
97 RstTime GetSolarRst(double jd, const LnLatPosn &obs, double hrz=LN_SOLAR_STANDART_HORIZON)
98 {
99 RstTime rst;
100 ln_get_solar_rst_horizon(jd, const_cast<LnLatPosn*>(&obs), hrz, &rst);
101 return rst;
102 }
103 RstTime GetSolarRst(double jd, double hrz=LN_SOLAR_STANDART_HORIZON)
104 {
105 return GetSolarRst(jd, ORM(), hrz);
106 }
107
108 RstTime GetLunarRst(double jd, const LnLatPosn &obs=ORM())
109 {
110 RstTime rst;
111 ln_get_lunar_rst(jd, const_cast<LnLatPosn*>(&obs), &rst);
112 return rst;
113 }
114 EquPosn GetSolarEquCoords(double jd)
115 {
116 EquPosn equ;
117 ln_get_solar_equ_coords(jd, &equ);
118 return equ;
119 }
120
121 double GetLunarDisk(double jd)
122 {
123 return ln_get_lunar_disk(jd);
124 }
125
126 double GetLunarSdiam(double jd)
127 {
128 return ln_get_lunar_sdiam(jd);
129 }
130
131 double GetLunarPhase(double jd)
132 {
133 return ln_get_lunar_phase(jd);
134 }
135
136 EquPosn GetLunarEquCoords(double jd, double precision=0)
137 {
138 EquPosn equ;
139 ln_get_lunar_equ_coords_prec(jd, &equ, precision);
140 return equ;
141 }
142
143 double GetLunarEarthDist(double jd)
144 {
145 return ln_get_lunar_earth_dist(jd);
146 }
147
148 double GetAngularSeparation(const EquPosn &p1, const EquPosn &p2)
149 {
150 return ln_get_angular_separation(const_cast<EquPosn*>(&p1), const_cast<EquPosn*>(&p2));
151 }
152
153 double GetAngularSeparation(const HrzPosn &h1, const HrzPosn &h2)
154 {
155 EquPosn p1; p1.ra=h1.az; p1.dec=h1.alt;
156 EquPosn p2; p2.ra=h2.az; p2.dec=h2.alt;
157 return ln_get_angular_separation(&p1, &p2);
158 }
159}
160
161#endif
Note: See TracBrowser for help on using the repository browser.