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

Last change on this file since 16815 was 16374, checked in by tbretz, 11 years ago
Added ln_get_lunar_phase
File size: 2.9 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
9namespace Nova
10{
11 typedef ln_lnlat_posn LnLatPosn;
12 //typedef ln_hrz_posn HrzPosn;
13 typedef ln_equ_posn EquPosn;
14 typedef ln_rst_time RstTime;
15
16 struct ZdAzPosn;
17
18 // Warning: 0deg=South, 90deg=W
19 struct HrzPosn : public ln_hrz_posn
20 {
21 HrzPosn() { }
22 HrzPosn(const ZdAzPosn &);
23 };
24
25 struct ZdAzPosn
26 {
27 double zd;
28 double az;
29
30 ZdAzPosn() : zd(0), az(0) { }
31 ZdAzPosn(const HrzPosn &hrz) : zd(90-hrz.alt), az(hrz.az-180) { }
32
33 // This crahsed cint, but it could save up the dedicate structure HrzPosn :(
34 //operator HrzPosn() const { const HrzPosn p = { az-180, 90-zd}; return p; }
35 };
36
37 HrzPosn::HrzPosn(const ZdAzPosn &za) { alt = 90-za.zd; az = za.az-180; }
38
39
40
41 const LnLatPosn &ORM()
42 {
43 //static LnLatPosn obs;
44 //obs.lng = -(17.+53./60+26.525/3600);
45 //obs.lat = 28.+45./60+42.462/3600;
46 const static LnLatPosn obs = { -(17.+53./60+26.525/3600), 28.+45./60+42.462/3600 };
47 return obs;
48 }
49
50 HrzPosn GetHrzFromEqu(const EquPosn &equ, const LnLatPosn &obs, double jd)
51 {
52 HrzPosn hrz;
53 ln_get_hrz_from_equ(const_cast<EquPosn*>(&equ), const_cast<LnLatPosn*>(&obs), jd, &hrz);
54 return hrz;
55 }
56 HrzPosn GetHrzFromEqu(const EquPosn &equ, double jd)
57 {
58 return GetHrzFromEqu(equ, ORM(), jd);
59 }
60
61 EquPosn GetEquFromHrz(const HrzPosn &hrz, const LnLatPosn &obs, double jd)
62 {
63 EquPosn equ;
64 ln_get_equ_from_hrz(const_cast<HrzPosn*>(&hrz), const_cast<LnLatPosn*>(&obs), jd, &equ);
65 return equ;
66 }
67 EquPosn GetEquFromHrz(const HrzPosn &hrz, double jd)
68 {
69 return GetEquFromHrz(hrz, ORM(), jd);
70 }
71
72 RstTime GetSolarRst(double jd, const LnLatPosn &obs, double hrz=LN_SOLAR_STANDART_HORIZON)
73 {
74 RstTime rst;
75 ln_get_solar_rst_horizon(jd, const_cast<LnLatPosn*>(&obs), hrz, &rst);
76 return rst;
77 }
78 RstTime GetSolarRst(double jd, double hrz=LN_SOLAR_STANDART_HORIZON)
79 {
80 return GetSolarRst(jd, ORM(), hrz);
81 }
82
83 RstTime GetLunarRst(double jd, const LnLatPosn &obs=ORM())
84 {
85 RstTime rst;
86 ln_get_lunar_rst(jd, const_cast<LnLatPosn*>(&obs), &rst);
87 return rst;
88 }
89 EquPosn GetSolarEquCoords(double jd)
90 {
91 EquPosn equ;
92 ln_get_solar_equ_coords(jd, &equ);
93 return equ;
94 }
95
96 double GetLunarDisk(double jd)
97 {
98 return ln_get_lunar_disk(jd);
99 }
100
101 double GetLunarSdiam(double jd)
102 {
103 return ln_get_lunar_sdiam(jd);
104 }
105
106 double GetLunarPhase(double jd)
107 {
108 return ln_get_lunar_phase(jd);
109 }
110
111 EquPosn GetLunarEquCoords(double jd, double precision=0)
112 {
113 EquPosn equ;
114 ln_get_lunar_equ_coords_prec(jd, &equ, precision);
115 return equ;
116 }
117}
118
119#endif
Note: See TracBrowser for help on using the repository browser.