Loading...
Searching...
No Matches
Sun.h
1/*
2
3MIT License
4
5Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30*/
31
32#ifndef RACK_SUN_H
33#define RACK_SUN_H
34
35
36#include <string>
37
38#include <drain/util/Geo.h>
39
40
41/*
42 * 2001 (C) Harri.Hohti@fmi.fi
43 * Original formulae from: Jean Meeus: Astronomical Formulae for Calculators (1980)
44 */
45
46namespace rack {
47
48struct Equatorial {
49 double RA;
50 double dec;
51};
52
53
55 double lat;
56 double lon;
57};
58
59struct Horizontal {
60 double azm;
61 double elev;
62};
63
64
65//class Sun : public Geographical, public Equatorial, public Horizontal {
66class Sun : public Horizontal {
67
68public:
69
70 Sun(const std::string & datestr = "197001010000", double lon=0.0, double lat=0.0){
71 setStarTime(datestr);
72 setLocation(lon, lat);
73 };
74
76
83 static
84 void getSunPos(const std::string & datestr, double lonDeg, double latDeg, double & azmRad, double & elevRad);
85
86
87
88 inline
89 void setStarTime(const std::string & datestr){
90
91 double jDate = JDate(datestr.c_str());
92
93 /* Tähtiaika radiaaneina auringon tuntikulman laskentaa varten */
94 starTime = Sidereal_GW(jDate) * 15.0 * drain::DEG2RAD;
95 Solar_coords(jDate, equ);
96
97 }
98
99
100 /* Lasketaan auringon horisontaalikoordinaatit paikan ja ajan funktiona */
101 inline
102 void setLocation(double lon, double lat){
103
104 /* Lasketaan auringon horisontaalikoordinaatit paikan ja ajan funktiona */
105 geo.lat = lat;
106 geo.lon = lon;
107 Solar_pos(starTime, geo, equ, *this);
108 }
109
110 Geographical geo;
111
112
113private:
114
115 /* Tähtiaika radiaaneina auringon tuntikulman laskentaa varten */
116 double starTime;
117
118 Equatorial equ;
119
120 //static double DEG_TO_RAD,RAD_TO_DEG;
121
122 /*
123 typedef struct { double RA;
124 double Dec;
125 } Equatorial;
126
128 typedef struct {
129 double A;
130 double h;
131 } Horizontal;
132
134 typedef struct {
135 double lat;
136 double lon;
137 } Geographical;
138 */
139
140 // Equatorial equ;
141
142 // Geographical geo;
143
144 /* Julian date */
145 static double JDate(const char *datestr);
146
147 /* 0-meridian astronomic time */
148 static double Sidereal_GW(double JD);
149
150 /* equatoriali coords */
151 //static Equatorial Solar_coords(double JD);
152 static
153 void Solar_coords(double JD, Equatorial & equ);
154
155 /* Horizontal coords without refraction */
156 /* Auringon horisontaalikoordinaatit (ei refraktiota) */
157 static
158 //Horizontal Solar_pos(double Sd0,
159 void Solar_pos(double Sd0, const Geographical & geo, const Equatorial & equ, Horizontal & hor);
160
161
162};
163
164} // rack::
165
166#endif /* RACK_H_ */
167
168// Rack
Definition Sun.h:66
static void getSunPos(const std::string &datestr, double lonDeg, double latDeg, double &azmRad, double &elevRad)
Returns the sun azimuth and elevation angle at a given time in a geographical position.
Definition Sun.cpp:54
Definition DataSelector.cpp:44
Definition Sun.h:48
Definition Sun.h:54
Definition Sun.h:59