Merge lp:~georg-zotti/stellarium/extinction into lp:stellarium
- extinction
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 5101 |
Proposed branch: | lp:~georg-zotti/stellarium/extinction |
Merge into: | lp:stellarium |
Diff against target: |
1234 lines (+444/-174) 29 files modified
CHANGES-FROM-TRUNK.txt (+34/-28) data/default_config.ini (+1/-0) plugins/Quasars/src/Quasar.cpp (+34/-10) plugins/Quasars/src/Quasar.hpp (+1/-1) plugins/Satellites/src/Satellite.cpp (+10/-2) plugins/Satellites/src/Satellite.hpp (+1/-1) plugins/Supernovae/src/Supernova.cpp (+19/-5) plugins/Supernovae/src/Supernova.hpp (+1/-1) src/core/RefractionExtinction.cpp (+16/-3) src/core/RefractionExtinction.hpp (+29/-22) src/core/StelObject.cpp (+24/-13) src/core/StelObject.hpp (+1/-1) src/core/StelSkyDrawer.cpp (+14/-4) src/core/modules/Comet.cpp (+18/-4) src/core/modules/Comet.hpp (+1/-1) src/core/modules/Constellation.cpp (+1/-1) src/core/modules/ConstellationMgr.hpp (+1/-1) src/core/modules/LandscapeMgr.cpp (+1/-1) src/core/modules/MinorPlanet.cpp (+21/-6) src/core/modules/MinorPlanet.hpp (+1/-1) src/core/modules/Nebula.cpp (+23/-4) src/core/modules/Nebula.hpp (+1/-1) src/core/modules/Planet.cpp (+115/-28) src/core/modules/Planet.hpp (+1/-1) src/core/modules/StarMgr.cpp (+8/-3) src/core/modules/StarMgr.hpp (+1/-1) src/core/modules/StarWrapper.cpp (+18/-6) src/core/modules/StarWrapper.hpp (+10/-3) src/core/modules/ZoneArray.cpp (+38/-21) |
To merge this branch: | bzr merge lp:~georg-zotti/stellarium/extinction |
Related bugs: | |
Related blueprints: |
Atmospheric extinction (completion)
(Medium)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
gzotti | Needs Resubmitting | ||
Alexander Wolf | Approve | ||
Bogdan Marinov | Needs Fixing | ||
Review via email: mp+86985@code.launchpad.net |
Commit message
Extinction for point-like objects
Description of the change
Extinction (reduced symbol size) and textual info on reduced magnitudes work for all (?) point-like and planetary objects.
I don't know how to process Milky Way and the nebulous images, help welcome!
Extinction introduces a new entry in config.ini:
[astro]
[edited to follow Bogdan's suggestion]
If true, objects lower than -2 degrees are extincted with 42 airmasses (just below horizontal... ;-), if false, 0, i.e., they are bright again below the horizon.
Bogdan Marinov (daggerstab) wrote : | # |
Also, for consistency, it should be something like "astro/
Alexander Wolf (alexwolf) wrote : | # |
Work looks is very good!
gzotti (georg-zotti) wrote : | # |
@Alex: OK, I was not aware of the default_config.ini. Quasars is done.
@Bogdan: OK, name changed
I hope it's all done now for the point sources.
Note that I also implemented 2 more sets of planetary magnitude computation (I forgot that already...), including the missing Saturn's rings magnitude contribution which was marked TODO. For Stellarium, I think the classical naked-eye "visual" magnitudes are preferrable over instrumental "V" magnitudes. Whichever solution you choose, please do not delete the other implementations.
Yours, Georg.
gzotti (georg-zotti) wrote : | # |
Oops, we crossed...
The last changes are small, mostly docfixes and cosmetics.
Preview Diff
1 | === modified file 'CHANGES-FROM-TRUNK.txt' |
2 | --- CHANGES-FROM-TRUNK.txt 2010-12-07 15:22:03 +0000 |
3 | +++ CHANGES-FROM-TRUNK.txt 2011-12-29 12:15:27 +0000 |
4 | @@ -1,35 +1,44 @@ |
5 | -REFRACTION branch: |
6 | +EXTINCTION branch: |
7 | |
8 | -Introduces changes necessary for refraction and extinction effects. |
9 | +Introduces changes necessary for extinction effects. |
10 | |
11 | Status: Partial solution, needs help. |
12 | |
13 | Contributor: Georg.Zotti@univie.ac.at |
14 | All changes are donated to the Stellarium project for distribution under opensource licenses like GNU. |
15 | |
16 | -COMPUTING: core/RefractionExtinction. DONE |
17 | -STARS: core/modules/ZoneArray::draw |
18 | - BUG: stars appear to have a problem after magnitude loss. |
19 | -+SELECT-MARK: StarMgr.cpp::drawPointer(). DONE |
20 | -CLICK-IDENTIFY: core/StelObjectMgr::cleverFind(core, x, y) DONE |
21 | -INFOSTRING: core/StelObject.cpp::getPositionInfoString(core, flags) DONE |
22 | - new core/StelObject.cpp::getSideralPosRefr(core) DONE |
23 | -DEEPSKY: NebulaMgr::draw(). Influences symbols and labels only. |
24 | -+DSO TEXTURES: ---TODO. May require a vertex shader program, beyond my knowledge. |
25 | -+SELECT-MARK: NebulaMgr::drawPointer(). DONE |
26 | -+MILKY WAY: Should become dimmer in low sky. May require a vertex shader program, beyond my knowledge. |
27 | -PLANETS: ---TODO. Involves StelPainter, 3D spheres, full matrices. |
28 | - May require a vertex shader program, beyond my knowledge, sorry. |
29 | -+SELECT-MARK: SolarSystem::drawPointer. DONE |
30 | -RA-DEC+GAL.GRIDS: core/GridLinesMgr. TODO OR LEAVE-AS-IS |
31 | - Requires changes in StelPainter's arc drawing methods. |
32 | - Currently this seems not viable and will not be changed. |
33 | -SATELLITES: Not required, practically unobservable on horizon, orbital parameters unsure, etc. |
34 | - Should be easy, however. |
35 | -CONSTELLATIONS: Large-scale items. Vertices could be refracted. Extinction would be a nice effect. |
36 | - Not urgent, later. |
37 | -METEORS NOT NECESSARY. |
38 | -OTHER? ??? |
39 | + |
40 | + |
41 | + |
42 | +2011-Oct: A new attempt in Extinction: |
43 | +========================================= |
44 | + |
45 | +StelObject and derived classes: getVMagnitude() has new optional arg: withExtinction. |
46 | +This should be set to true only for determining magnitude for drawing (draw()) and also for textual info (getInfoString()), |
47 | +not e.g. for selection (getSelectPriority()). |
48 | +It will also only change the result if atmosphere rendering is ON. |
49 | + |
50 | +StelSkyDrawer::drawPointSource |
51 | +StelObject::getVMagnitude |
52 | +Satellite::getVMagnitude, ::getInfoString |
53 | +Supernova::getVMagnitude, ::getInfoString |
54 | +Quasar::getVMagnitude, ::getInfoString |
55 | +Satellite::getVMagnitude |
56 | +Planet::getVMagnitude, ::getInfoString |
57 | +Comet::getVMagnitude, ::getInfoString |
58 | +MinorPlanet::getVMagnitude, ::getInfoString |
59 | +Nebula::getVMagnitude, ::getInfoString |
60 | +StarWrapper::getInfoString |
61 | + |
62 | +I currently have no solution for extended objects! Therefore ... |
63 | + |
64 | +TODO: Milky Way, Nebula figures, Constellations?? |
65 | + |
66 | + |
67 | + |
68 | +================================================================================ |
69 | + |
70 | +TODO, but maybe in yet another branch: See implementation in abandoned refraction branch! |
71 | |
72 | CHANGES IN LANDSCAPE HANDLING: |
73 | 1) Moved config.ini:[stars].init_bortle_scale to [landscape] section |
74 | @@ -43,9 +52,6 @@ |
75 | LandscapeMgr forwards those settings to the respective recipients. |
76 | TODO: make GUI aware of changed values (how?). |
77 | |
78 | -GUI changes: ViewDialog.ui |
79 | -added 3 DoubleSpinBoxes for temperature, pressure, extinction coefficient into atmosphereGroupBox |
80 | -ViewDialog.cpp: TODO: when switching landscapes, new data only load partially into GUI. No idea why! |
81 | |
82 | CHANGES IN ASTR.COMPUTATIONS |
83 | planetsephems/sideral_time.[hc]: added get_mean_ecliptical_obliquity(double JDE), |
84 | |
85 | === modified file 'data/default_config.ini' |
86 | --- data/default_config.ini 2011-12-18 20:43:39 +0000 |
87 | +++ data/default_config.ini 2011-12-29 12:15:27 +0000 |
88 | @@ -221,6 +221,7 @@ |
89 | flag_nebula_name = false |
90 | flag_nebula_long_name = false |
91 | flag_nebula_display_no_texture = false |
92 | +flag_extinction_below_horizon = true |
93 | max_mag_nebula_name = 8 |
94 | nebula_scale = 1 |
95 | flag_milky_way = true |
96 | |
97 | === modified file 'plugins/Quasars/src/Quasar.cpp' |
98 | --- plugins/Quasars/src/Quasar.cpp 2011-12-18 15:37:49 +0000 |
99 | +++ plugins/Quasars/src/Quasar.cpp 2011-12-29 12:15:27 +0000 |
100 | @@ -75,31 +75,47 @@ |
101 | float Quasar::getSelectPriority(const StelCore* core) const |
102 | { |
103 | //Same as StarWrapper::getSelectPriority() |
104 | - return getVMagnitude(core); |
105 | + return getVMagnitude(core, false); |
106 | } |
107 | |
108 | QString Quasar::getInfoString(const StelCore* core, const InfoStringGroup& flags) const |
109 | { |
110 | QString str; |
111 | QTextStream oss(&str); |
112 | - double mag = getVMagnitude(core); |
113 | + double mag = getVMagnitude(core, false); |
114 | |
115 | if (flags&Name) |
116 | { |
117 | oss << "<h2>" << designation << "</h2>"; |
118 | } |
119 | - |
120 | if (flags&Magnitude && mag <= core->getSkyDrawer()->getLimitMagnitude()) |
121 | { |
122 | - if (bV!=0) |
123 | + if (core->getSkyDrawer()->getFlagHasAtmosphere()) |
124 | + { |
125 | + if (bV!=0) |
126 | { |
127 | - oss << q_("Magnitude: <b>%1</b> (B-V: %2)").arg(mag, 0, 'f', 2).arg(bV, 0, 'f', 2) << "<br>"; |
128 | + oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>. B-V: <b>%3</b>)").arg(QString::number(mag, 'f', 2), |
129 | + QString::number(getVMagnitude(core, true), 'f', 2), |
130 | + QString::number(bV, 'f', 2)) << "<br>"; |
131 | } |
132 | else |
133 | { |
134 | - oss << q_("Magnitude: <b>%1</b>").arg(mag, 0, 'f', 2) << "<br>"; |
135 | + oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)").arg(QString::number(mag, 'f', 2), |
136 | + QString::number(getVMagnitude(core, true), 'f', 2)) << "<br>"; |
137 | } |
138 | - if (AMagnitude!=0) |
139 | + } |
140 | + else |
141 | + { |
142 | + if (bV!=0) |
143 | + { |
144 | + oss << q_("Magnitude: <b>%1</b> (B-V: <b>%2</b>)").arg(mag, 0, 'f', 2).arg(bV, 0, 'f', 2) << "<br>"; |
145 | + } |
146 | + else |
147 | + { |
148 | + oss << q_("Magnitude: <b>%1</b>").arg(mag, 0, 'f', 2) << "<br>"; |
149 | + } |
150 | + } |
151 | + if (AMagnitude!=0) |
152 | { |
153 | oss << q_("Absolute Magnitude: %1").arg(AMagnitude, 0, 'f', 2) << "<br>"; |
154 | } |
155 | @@ -126,9 +142,17 @@ |
156 | return StelApp::getInstance().getVisionModeNight() ? Vec3f(0.6, 0.0, 0.0) : Vec3f(1.0, 1.0, 1.0); |
157 | } |
158 | |
159 | -float Quasar::getVMagnitude(const StelCore* core) const |
160 | +float Quasar::getVMagnitude(const StelCore* core, bool withExtinction) const |
161 | { |
162 | - return VMagnitude; |
163 | + float extinctionMag=0.0; // track magnitude loss |
164 | + if (withExtinction && core->getSkyDrawer()->getFlagHasAtmosphere()) |
165 | + { |
166 | + Vec3d altAz=getAltAzPosApparent(core); |
167 | + altAz.normalize(); |
168 | + core->getSkyDrawer()->getExtinction().forward(&altAz[2], &extinctionMag); |
169 | + } |
170 | + |
171 | + return VMagnitude + extinctionMag; |
172 | } |
173 | |
174 | double Quasar::getAngularSize(const StelCore*) const |
175 | @@ -150,7 +174,7 @@ |
176 | double mag; |
177 | |
178 | StelUtils::spheToRect(qRA, qDE, XYZ); |
179 | - mag = getVMagnitude(core); |
180 | + mag = getVMagnitude(core, true); |
181 | |
182 | if (mag <= sd->getLimitMagnitude()) |
183 | { |
184 | |
185 | === modified file 'plugins/Quasars/src/Quasar.hpp' |
186 | --- plugins/Quasars/src/Quasar.hpp 2011-12-11 12:51:25 +0000 |
187 | +++ plugins/Quasars/src/Quasar.hpp 2011-12-29 12:15:27 +0000 |
188 | @@ -65,7 +65,7 @@ |
189 | { |
190 | return XYZ; |
191 | } |
192 | - virtual float getVMagnitude(const StelCore* core) const; |
193 | + virtual float getVMagnitude(const StelCore* core, bool withExtinction=false) const; |
194 | virtual double getAngularSize(const StelCore* core) const; |
195 | virtual QString getNameI18n(void) const |
196 | { |
197 | |
198 | === modified file 'plugins/Satellites/src/Satellite.cpp' |
199 | --- plugins/Satellites/src/Satellite.cpp 2011-12-17 07:51:42 +0000 |
200 | +++ plugins/Satellites/src/Satellite.cpp 2011-12-29 12:15:27 +0000 |
201 | @@ -326,9 +326,17 @@ |
202 | return StelApp::getInstance().getVisionModeNight() ? Vec3f(0.6, 0.0, 0.0) : hintColor; |
203 | } |
204 | |
205 | -float Satellite::getVMagnitude(const StelCore*) const |
206 | +float Satellite::getVMagnitude(const StelCore* core, bool withExtinction) const |
207 | { |
208 | - return 5.0; |
209 | + float extinctionMag=0.0; // track magnitude loss |
210 | + if (withExtinction && core->getSkyDrawer()->getFlagHasAtmosphere()) |
211 | + { |
212 | + Vec3d altAz=getAltAzPosApparent(core); |
213 | + altAz.normalize(); |
214 | + core->getSkyDrawer()->getExtinction().forward(&altAz[2], &extinctionMag); |
215 | + } |
216 | + |
217 | + return 5.0 + extinctionMag; |
218 | } |
219 | |
220 | double Satellite::getAngularSize(const StelCore*) const |
221 | |
222 | === modified file 'plugins/Satellites/src/Satellite.hpp' |
223 | --- plugins/Satellites/src/Satellite.hpp 2011-12-14 10:31:15 +0000 |
224 | +++ plugins/Satellites/src/Satellite.hpp 2011-12-29 12:15:27 +0000 |
225 | @@ -84,7 +84,7 @@ |
226 | { |
227 | return XYZ; |
228 | } |
229 | - virtual float getVMagnitude(const StelCore* core=NULL) const; |
230 | + virtual float getVMagnitude(const StelCore* core=NULL, bool withExtinction=false) const; |
231 | virtual double getAngularSize(const StelCore* core) const; |
232 | virtual QString getNameI18n(void) const |
233 | { |
234 | |
235 | === modified file 'plugins/Supernovae/src/Supernova.cpp' |
236 | --- plugins/Supernovae/src/Supernova.cpp 2011-08-28 16:38:25 +0000 |
237 | +++ plugins/Supernovae/src/Supernova.cpp 2011-12-29 12:15:27 +0000 |
238 | @@ -77,14 +77,14 @@ |
239 | float Supernova::getSelectPriority(const StelCore* core) const |
240 | { |
241 | //Same as StarWrapper::getSelectPriority() |
242 | - return getVMagnitude(core); |
243 | + return getVMagnitude(core, false); |
244 | } |
245 | |
246 | QString Supernova::getInfoString(const StelCore* core, const InfoStringGroup& flags) const |
247 | { |
248 | QString str; |
249 | QTextStream oss(&str); |
250 | - double mag = getVMagnitude(core); |
251 | + double mag = getVMagnitude(core, false); |
252 | |
253 | if (flags&Name) |
254 | { |
255 | @@ -96,7 +96,13 @@ |
256 | } |
257 | |
258 | if (flags&Magnitude && mag <= core->getSkyDrawer()->getLimitMagnitude()) |
259 | + { |
260 | + if (core->getSkyDrawer()->getFlagHasAtmosphere()) |
261 | + oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)").arg(QString::number(getVMagnitude(core, false), 'f', 2), |
262 | + QString::number(getVMagnitude(core, true), 'f', 2)) << "<br>"; |
263 | + else |
264 | oss << q_("Magnitude: <b>%1</b>").arg(mag, 0, 'f', 2) << "<br>"; |
265 | + } |
266 | |
267 | // Ra/Dec etc. |
268 | oss << getPositionInfoString(core, flags); |
269 | @@ -117,8 +123,16 @@ |
270 | return StelApp::getInstance().getVisionModeNight() ? Vec3f(0.6, 0.0, 0.0) : Vec3f(1.0, 1.0, 1.0); |
271 | } |
272 | |
273 | -float Supernova::getVMagnitude(const StelCore* core) const |
274 | +float Supernova::getVMagnitude(const StelCore* core, bool withExtinction) const |
275 | { |
276 | + float extinctionMag=0.0; // track magnitude loss |
277 | + if (withExtinction && core->getSkyDrawer()->getFlagHasAtmosphere()) |
278 | + { |
279 | + Vec3d altAz=getAltAzPosApparent(core); |
280 | + altAz.normalize(); |
281 | + core->getSkyDrawer()->getExtinction().forward(&altAz[2], &extinctionMag); |
282 | + } |
283 | + |
284 | double vmag = 20; |
285 | double currentJD = core->getJDay(); |
286 | double deltaJD = std::abs(peakJD-currentJD); |
287 | @@ -172,7 +186,7 @@ |
288 | if (vmag<maxMagnitude) |
289 | vmag = maxMagnitude; |
290 | |
291 | - return vmag; |
292 | + return vmag + extinctionMag; |
293 | } |
294 | |
295 | double Supernova::getAngularSize(const StelCore*) const |
296 | @@ -194,7 +208,7 @@ |
297 | double mag; |
298 | |
299 | StelUtils::spheToRect(snra, snde, XYZ); |
300 | - mag = getVMagnitude(core); |
301 | + mag = getVMagnitude(core, true); |
302 | |
303 | if (mag <= sd->getLimitMagnitude()) |
304 | { |
305 | |
306 | === modified file 'plugins/Supernovae/src/Supernova.hpp' |
307 | --- plugins/Supernovae/src/Supernova.hpp 2011-07-25 17:29:18 +0000 |
308 | +++ plugins/Supernovae/src/Supernova.hpp 2011-12-29 12:15:27 +0000 |
309 | @@ -65,7 +65,7 @@ |
310 | { |
311 | return XYZ; |
312 | } |
313 | - virtual float getVMagnitude(const StelCore* core) const; |
314 | + virtual float getVMagnitude(const StelCore* core, bool withExtinction=false) const; |
315 | virtual double getAngularSize(const StelCore* core) const; |
316 | virtual QString getNameI18n(void) const |
317 | { |
318 | |
319 | === modified file 'src/core/RefractionExtinction.cpp' |
320 | --- src/core/RefractionExtinction.cpp 2011-06-10 11:31:13 +0000 |
321 | +++ src/core/RefractionExtinction.cpp 2011-12-29 12:15:27 +0000 |
322 | @@ -20,17 +20,21 @@ |
323 | * Principal implementation: 2010-03-23 GZ=Georg Zotti, Georg.Zotti@univie.ac.at |
324 | */ |
325 | |
326 | +#include <qsettings.h> |
327 | +#include "StelApp.hpp" |
328 | #include "RefractionExtinction.hpp" |
329 | |
330 | |
331 | // To be decided: The following should be either 0 or 40 (or 42? ;-) |
332 | -const float Extinction::SUBHORIZONTAL_AIRMASS=0.0f; |
333 | +float Extinction::SUBHORIZONTAL_AIRMASS=0.0f; |
334 | |
335 | Extinction::Extinction() : ext_coeff(0.20f) |
336 | { |
337 | + QSettings* conf = StelApp::getInstance().getSettings(); |
338 | + SUBHORIZONTAL_AIRMASS = (conf->value("astro/flag_extinction_below_horizon", true).toBool()? 42.0f : 0.0f); |
339 | } |
340 | |
341 | -// altAzPos is the normalized star position vector AFTER REFRACTION, and its z component sin(altitude). |
342 | +// altAzPos is the NORMALIZED (!!!) star position vector AFTER REFRACTION, and its z component sin(altitude). |
343 | void Extinction::forward(const Vec3d *altAzPos, float *mag, const int num) const |
344 | { |
345 | for (int i=0; i<num; ++i) mag[i] += airmass(altAzPos[i][2], true) * ext_coeff; |
346 | @@ -48,6 +52,14 @@ |
347 | { |
348 | for (int i=0; i<num; ++i) mag[i] += airmass(sinAlt[i], true) * ext_coeff; |
349 | } |
350 | +void Extinction::forward(const double *sinAlt, float *mag) const |
351 | +{ |
352 | + *mag += airmass(*sinAlt, true) * ext_coeff; |
353 | +} |
354 | +void Extinction::forward(const float *sinAlt, float *mag) const |
355 | +{ |
356 | + *mag += airmass(*sinAlt, true) * ext_coeff; |
357 | +} |
358 | // from observed magnitude in apparent (observed) altitude to atmosphere-free mag, still in apparent, refracted altitude. |
359 | void Extinction::backward(const Vec3d *altAzPos, float *mag, const int num) const |
360 | { |
361 | @@ -70,7 +82,7 @@ |
362 | // airmass computation for cosine of zenith angle z |
363 | float Extinction::airmass(const float cosZ, const bool apparent_z) const |
364 | { |
365 | - if (cosZ<-0.035f) |
366 | + if (cosZ<-0.035f) // about -2 degrees. Here, RozenbergZ>574 and climbs fast! |
367 | return Extinction::SUBHORIZONTAL_AIRMASS; // Safety: 0 or 40 for below -2 degrees. |
368 | |
369 | float X; |
370 | @@ -89,6 +101,7 @@ |
371 | return X; |
372 | } |
373 | |
374 | +/* ***************************************************************************************************** */ |
375 | |
376 | // The following 4 are to be configured, the rest is derived. |
377 | // Recommendations: -4.9/-4.3/0.1/0.1: sharp but continuous transition, no effects below -5. |
378 | |
379 | === modified file 'src/core/RefractionExtinction.hpp' |
380 | --- src/core/RefractionExtinction.hpp 2011-06-10 11:31:13 +0000 |
381 | +++ src/core/RefractionExtinction.hpp 2011-12-29 12:15:27 +0000 |
382 | @@ -31,41 +31,39 @@ |
383 | #include "VecMath.hpp" |
384 | #include "StelProjector.hpp" |
385 | |
386 | -//! @class RefractionExtinction |
387 | -//! This class performs refraction and extinction computations, following literature from atmospheric optics and astronomy. |
388 | -//! Airmass computations are limited to meaningful altitudes, |
389 | -//! and refraction solutions can only be aproximate, given the turbulent, unpredictable real atmosphere. |
390 | +//! @class Extinction |
391 | +//! This class performs extinction computations, following literature from atmospheric optics and astronomy. |
392 | +//! Airmass computations are limited to meaningful altitudes. |
393 | //! The solution provided here will [hopefully!] result in a visible "zone of avoidance" near the horizon down to altitude -2, |
394 | -//! and will show stars in their full brightness at their geometrical positions below -5 degrees. |
395 | -//! Of course, plotting stars below the horizon could be coupled to setting of horizon foreground, |
396 | -//! it's another usability issue. Typical horizons do not go down below -1, so strange effects between -2 and -5 should be covered. |
397 | +//! and may show stars in their full brightness below -2 degrees. |
398 | +//! Typical horizons do not go down below -1, so all natural sites should be covered. |
399 | //! Note that forward/backward are no absolute reverse operations! |
400 | //! All the computations should be in effect |
401 | //! (1) only if atmosphere effects are true |
402 | -//! (2) only for celestial objects, never for landscape coordinates |
403 | -//! (3) only for terrestrial locations, not on Moon/Mars/Saturn etc |
404 | +//! (2) only for terrestrial locations, not on Moon/Mars/Saturn etc |
405 | +//! config.ini:astro/flag_extinction_below_horizon=true|false controls if extinction kills objects below -2 degrees altitude by setting airmass to 42. |
406 | class Extinction |
407 | { |
408 | public: |
409 | Extinction(); |
410 | //! Compute extinction effect for arrays of size @param num position vectors and magnitudes. |
411 | - //! @param altAzPos are the normalized (apparent) star position vectors, and their z components sin(apparent_altitude). |
412 | + //! @param altAzPos are the NORMALIZED (!!) (apparent) star position vectors, and their z components sin(apparent_altitude). |
413 | //! This call must therefore be done after application of Refraction, and only if atmospheric effects are on. |
414 | //! Note that forward/backward are no absolute reverse operations! |
415 | - void forward(const Vec3d *altAzPos, float *mag, const int num) const; |
416 | - void forward(const Vec3f *altAzPos, float *mag, const int num) const; |
417 | - //! Convenience method for the same |
418 | + void forward(const Vec3d *altAzPos, float *mag, const int num=1) const; |
419 | + void forward(const Vec3f *altAzPos, float *mag, const int num=1) const; |
420 | void forward(const double *sinAlt, float *mag, const int num) const; |
421 | void forward(const float *sinAlt, float *mag, const int num) const; |
422 | + void forward(const double *sinAlt, float *mag) const; |
423 | + void forward(const float *sinAlt, float *mag) const; |
424 | |
425 | - //! Compute extinction effect for arrays of size @param size position vectors and magnitudes. |
426 | - //! @param altAzPos are the normalized (apparent) star position vectors, and their z components sin(apparent_altitude). |
427 | + //! Compute inverse extinction effect for arrays of size @param num position vectors and magnitudes. |
428 | + //! @param altAzPos are the NORMALIZED (!!) (apparent) star position vectors, and their z components sin(apparent_altitude). |
429 | //! Note that forward/backward are no absolute reverse operations! |
430 | - void backward(const Vec3d *altAzPos, float *mag, const int num) const; |
431 | - void backward(const Vec3f *altAzPos, float *mag, const int num) const; |
432 | - //! Convenience method for the same |
433 | - void backward(const double *sinAlt, float *mag, const int num) const; |
434 | - void backward(const float *sinAlt, float *mag, const int num) const; |
435 | + void backward(const Vec3d *altAzPos, float *mag, const int num=1) const; |
436 | + void backward(const Vec3f *altAzPos, float *mag, const int num=1) const; |
437 | + void backward(const double *sinAlt, float *mag, const int num=1) const; |
438 | + void backward(const float *sinAlt, float *mag, const int num=1) const; |
439 | |
440 | //! Set visual extinction coefficient (mag/airmass), influences extinction computation. |
441 | //! @param k= 0.1 for highest mountains, 0.2 for very good lowland locations, 0.35 for typical lowland, 0.5 in humid climates. |
442 | @@ -84,11 +82,20 @@ |
443 | |
444 | //! k, magnitudes/airmass, in [0.00, ... 1.00], (default 0.20). |
445 | float ext_coeff; |
446 | - //! should be either 0.0 (stars visible in full brightness below horizon) or 40.0 (practically invisible) |
447 | + //! should be either 0.0 (stars visible in full brightness below horizon) or 40.0 (or 42? ;-) practically invisible) |
448 | //! Maybe make this a user-configurable option? |
449 | - static const float SUBHORIZONTAL_AIRMASS; |
450 | + static float SUBHORIZONTAL_AIRMASS; |
451 | }; |
452 | |
453 | +//! @class Refraction |
454 | +//! This class performs refraction computations, following literature from atmospheric optics and astronomy. |
455 | +//! Refraction solutions can only be aproximate, given the turbulent, unpredictable real atmosphere. |
456 | +//! Typical horizons do not go down below -1, so strange effects (distortion) between -2 and -5 should be covered. |
457 | +//! Note that forward/backward are no absolute reverse operations! |
458 | +//! All the computations should be in effect |
459 | +//! (1) only if atmosphere effects are true |
460 | +//! (2) only for celestial objects, never for landscape images |
461 | +//! (3) only for terrestrial locations, not on Moon/Mars/Saturn etc |
462 | |
463 | class Refraction: public StelProjector::ModelViewTranform |
464 | { |
465 | |
466 | === modified file 'src/core/StelObject.cpp' |
467 | --- src/core/StelObject.cpp 2011-06-08 15:08:06 +0000 |
468 | +++ src/core/StelObject.cpp 2011-12-29 12:15:27 +0000 |
469 | @@ -71,6 +71,7 @@ |
470 | // Format the positional info string contain J2000/of date/altaz/hour angle positions for the object |
471 | QString StelObject::getPositionInfoString(const StelCore *core, const InfoStringGroup& flags) const |
472 | { |
473 | + bool withAtmosphere=core->getSkyDrawer()->getFlagHasAtmosphere(); |
474 | QString res; |
475 | if (flags&RaDecJ2000) |
476 | { |
477 | @@ -88,13 +89,18 @@ |
478 | |
479 | if (flags&HourAngle) |
480 | { |
481 | - double dec_sideral, ra_sideral; |
482 | - StelUtils::rectToSphe(&ra_sideral,&dec_sideral,getSideralPosGeometric(core)); |
483 | - ra_sideral = 2.*M_PI-ra_sideral; |
484 | - res += q_("Hour angle/DE: %1/%2").arg(StelUtils::radToHmsStr(ra_sideral), StelUtils::radToDmsStr(dec_sideral)) + " " + q_("(geometric)") + "<br>"; |
485 | - StelUtils::rectToSphe(&ra_sideral,&dec_sideral,getSideralPosApparent(core)); |
486 | - ra_sideral = 2.*M_PI-ra_sideral; |
487 | - res += q_("Hour angle/DE: %1/%2").arg(StelUtils::radToHmsStr(ra_sideral), StelUtils::radToDmsStr(dec_sideral)) + " " + q_("(apparent)") + "<br>"; |
488 | + double dec_sidereal, ra_sidereal; |
489 | + StelUtils::rectToSphe(&ra_sidereal,&dec_sidereal,getSideralPosGeometric(core)); |
490 | + ra_sidereal = 2.*M_PI-ra_sidereal; |
491 | + if (withAtmosphere) |
492 | + { |
493 | + res += q_("Hour angle/DE: %1/%2").arg(StelUtils::radToHmsStr(ra_sidereal), StelUtils::radToDmsStr(dec_sidereal)) + " " + q_("(geometric)") + "<br>"; |
494 | + StelUtils::rectToSphe(&ra_sidereal,&dec_sidereal,getSideralPosApparent(core)); |
495 | + ra_sidereal = 2.*M_PI-ra_sidereal; |
496 | + res += q_("Hour angle/DE: %1/%2").arg(StelUtils::radToHmsStr(ra_sidereal), StelUtils::radToDmsStr(dec_sidereal)) + " " + q_("(apparent)") + "<br>"; |
497 | + } |
498 | + else |
499 | + res += q_("Hour angle/DE: %1/%2").arg(StelUtils::radToHmsStr(ra_sidereal), StelUtils::radToDmsStr(dec_sidereal)) + " " + "<br>"; |
500 | } |
501 | |
502 | if (flags&AltAzi) |
503 | @@ -105,13 +111,18 @@ |
504 | az = 3.*M_PI - az; // N is zero, E is 90 degrees |
505 | if (az > M_PI*2) |
506 | az -= M_PI*2; |
507 | - res += q_("Az/Alt: %1/%2").arg(StelUtils::radToDmsStr(az), StelUtils::radToDmsStr(alt)) + " " + q_("(geometric)") + "<br>"; |
508 | + if (withAtmosphere) |
509 | + { |
510 | + res += q_("Az/Alt: %1/%2").arg(StelUtils::radToDmsStr(az), StelUtils::radToDmsStr(alt)) + " " + q_("(geometric)") + "<br>"; |
511 | |
512 | - StelUtils::rectToSphe(&az,&alt,getAltAzPosApparent(core)); |
513 | - az = 3.*M_PI - az; // N is zero, E is 90 degrees |
514 | - if (az > M_PI*2) |
515 | - az -= M_PI*2; |
516 | - res += q_("Az/Alt: %1/%2").arg(StelUtils::radToDmsStr(az), StelUtils::radToDmsStr(alt)) + " " + q_("(apparent)") + "<br>"; |
517 | + StelUtils::rectToSphe(&az,&alt,getAltAzPosApparent(core)); |
518 | + az = 3.*M_PI - az; // N is zero, E is 90 degrees |
519 | + if (az > M_PI*2) |
520 | + az -= M_PI*2; |
521 | + res += q_("Az/Alt: %1/%2").arg(StelUtils::radToDmsStr(az), StelUtils::radToDmsStr(alt)) + " " + q_("(apparent)") + "<br>"; |
522 | + } |
523 | + else |
524 | + res += q_("Az/Alt: %1/%2").arg(StelUtils::radToDmsStr(az), StelUtils::radToDmsStr(alt)) + " " + "<br>"; |
525 | } |
526 | return res; |
527 | } |
528 | |
529 | === modified file 'src/core/StelObject.hpp' |
530 | --- src/core/StelObject.hpp 2011-06-03 09:45:50 +0000 |
531 | +++ src/core/StelObject.hpp 2011-12-29 12:15:27 +0000 |
532 | @@ -120,7 +120,7 @@ |
533 | Vec3d getAltAzPosAuto(const StelCore* core) const; |
534 | |
535 | //! Return object's apparent V magnitude as seen from observer |
536 | - virtual float getVMagnitude(const StelCore*) const {return 99;} |
537 | + virtual float getVMagnitude(const StelCore*, bool withExtinction=false) const {return 99;} |
538 | |
539 | //! Return a priority value which is used to discriminate objects by priority |
540 | //! As for magnitudes, the lower is the higher priority |
541 | |
542 | === modified file 'src/core/StelSkyDrawer.cpp' |
543 | --- src/core/StelSkyDrawer.cpp 2011-05-31 13:06:03 +0000 |
544 | +++ src/core/StelSkyDrawer.cpp 2011-12-29 12:15:27 +0000 |
545 | @@ -106,7 +106,7 @@ |
546 | ok = true; |
547 | } |
548 | |
549 | - //GZ: load 3 values from config for now. TODO: make adjustable with GUI! |
550 | + //GZ: load 3 values from config. |
551 | setExtinctionCoefficient(conf->value("landscape/atmospheric_extinction_coefficient",0.2).toDouble(&ok)); |
552 | if (!ok) |
553 | { |
554 | @@ -242,6 +242,16 @@ |
555 | fov = minAdaptFov; |
556 | } |
557 | |
558 | + // GZ: Light pollution must take global atmosphere setting into acount! |
559 | + // moved parts from setBortleScale() here |
560 | + // These value have been calibrated by hand, looking at the faintest star in stellarium at around 40 deg FOV |
561 | + // They should roughly match the scale described at http://en.wikipedia.org/wiki/Bortle_Dark-Sky_Scale |
562 | + static const float bortleToInScale[9] = {2.45, 1.55, 1.0, 0.63, 0.40, 0.24, 0.23, 0.145, 0.09}; |
563 | + if (getFlagHasAtmosphere()) |
564 | + setInputScale(bortleToInScale[bortleScaleIndex-1]); |
565 | + else |
566 | + setInputScale(bortleToInScale[0]); |
567 | + |
568 | // This factor is fully arbitrary. It corresponds to the collecting area x exposure time of the instrument |
569 | // It is based on a power law, so that it varies progressively with the FOV to smoothly switch from human |
570 | // vision to binocculares/telescope. Use a max of 0.7 because after that the atmosphere starts to glow too much! |
571 | @@ -731,11 +741,11 @@ |
572 | } |
573 | |
574 | bortleScaleIndex = bIndex; |
575 | - |
576 | + // GZ: I moved this block to update() |
577 | // These value have been calibrated by hand, looking at the faintest star in stellarium at around 40 deg FOV |
578 | // They should roughly match the scale described at http://en.wikipedia.org/wiki/Bortle_Dark-Sky_Scale |
579 | - static const float bortleToInScale[9] = {2.45, 1.55, 1.0, 0.63, 0.40, 0.24, 0.23, 0.145, 0.09}; |
580 | - setInputScale(bortleToInScale[bIndex-1]); |
581 | + // static const float bortleToInScale[9] = {2.45, 1.55, 1.0, 0.63, 0.40, 0.24, 0.23, 0.145, 0.09}; |
582 | + // setInputScale(bortleToInScale[bIndex-1]); |
583 | } |
584 | |
585 | |
586 | |
587 | === modified file 'src/core/modules/Comet.cpp' |
588 | --- src/core/modules/Comet.cpp 2011-11-25 13:51:35 +0000 |
589 | +++ src/core/modules/Comet.cpp 2011-12-29 12:15:27 +0000 |
590 | @@ -115,7 +115,13 @@ |
591 | } |
592 | |
593 | if (flags&Magnitude) |
594 | - oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core), 0, 'f', 2) << "<br>"; |
595 | + { |
596 | + if (core->getSkyDrawer()->getFlagHasAtmosphere()) |
597 | + oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)").arg(QString::number(getVMagnitude(core, false), 'f', 2), |
598 | + QString::number(getVMagnitude(core, true), 'f', 2)) << "<br>"; |
599 | + else |
600 | + oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core, false), 0, 'f', 2) << "<br>"; |
601 | + } |
602 | |
603 | if (flags&AbsoluteMagnitude) |
604 | { |
605 | @@ -157,13 +163,21 @@ |
606 | return str; |
607 | } |
608 | |
609 | -float Comet::getVMagnitude(const StelCore* core) const |
610 | +float Comet::getVMagnitude(const StelCore* core, bool withExtinction) const |
611 | { |
612 | //If the two parameter system is not used, |
613 | //use the default radius/albedo mechanism |
614 | if (slopeParameter < 0) |
615 | { |
616 | - return Planet::getVMagnitude(core); |
617 | + return Planet::getVMagnitude(core, withExtinction); |
618 | + } |
619 | + |
620 | + float extinctionMag=0.0; // track magnitude loss |
621 | + if (withExtinction && core->getSkyDrawer()->getFlagHasAtmosphere()) |
622 | + { |
623 | + Vec3d altAz=getAltAzPosApparent(core); |
624 | + altAz.normalize(); |
625 | + core->getSkyDrawer()->getExtinction().forward(&altAz[2], &extinctionMag); |
626 | } |
627 | |
628 | //Calculate distances |
629 | @@ -178,5 +192,5 @@ |
630 | //http://www.ayton.id.au/gary/Science/Astronomy/Ast_comets.htm#Comet%20facts: |
631 | double apparentMagnitude = absoluteMagnitude + 5 * std::log10(observerCometDistance) + 2.5 * slopeParameter * std::log10(cometSunDistance); |
632 | |
633 | - return apparentMagnitude; |
634 | + return apparentMagnitude + extinctionMag; |
635 | } |
636 | |
637 | === modified file 'src/core/modules/Comet.hpp' |
638 | --- src/core/modules/Comet.hpp 2011-06-12 15:30:54 +0000 |
639 | +++ src/core/modules/Comet.hpp 2011-12-29 12:15:27 +0000 |
640 | @@ -65,7 +65,7 @@ |
641 | //was not designed to handle different types of objects. |
642 | //virtual QString getType() const {return "Comet";} |
643 | //! \todo Find better sources for the g,k system |
644 | - virtual float getVMagnitude(const StelCore* core) const; |
645 | + virtual float getVMagnitude(const StelCore* core, bool withExtinction=false) const; |
646 | |
647 | //! \brief sets absolute magnitude and slope parameter. |
648 | //! These are the parameters in the IAU's two-parameter magnitude system |
649 | |
650 | === modified file 'src/core/modules/Constellation.cpp' |
651 | --- src/core/modules/Constellation.cpp 2011-05-31 13:06:03 +0000 |
652 | +++ src/core/modules/Constellation.cpp 2011-12-29 12:15:27 +0000 |
653 | @@ -220,7 +220,7 @@ |
654 | // so check all segment endpoints: |
655 | for (int i=2*numberOfSegments-1;i>=0;i--) |
656 | { |
657 | - const float Mag = asterism[i]->getVMagnitude(0); |
658 | + const float Mag = asterism[i]->getVMagnitude(0, false); |
659 | if (Mag < maxMag) |
660 | { |
661 | brightest = asterism[i]; |
662 | |
663 | === modified file 'src/core/modules/ConstellationMgr.hpp' |
664 | --- src/core/modules/ConstellationMgr.hpp 2011-05-31 13:06:03 +0000 |
665 | +++ src/core/modules/ConstellationMgr.hpp 2011-12-29 12:15:27 +0000 |
666 | @@ -189,7 +189,7 @@ |
667 | //! the boundary separates. |
668 | //! @param conCatFile the path to the file which contains the constellation boundary data. |
669 | bool loadBoundaries(const QString& conCatFile); |
670 | - //! Draw the constellation lines at the epoch given by the StelNavigator. |
671 | + //! Draw the constellation lines at the epoch given by the StelCore. |
672 | void drawLines(StelPainter& sPainter, const StelCore* core) const; |
673 | //! Draw the constellation art. |
674 | void drawArt(StelPainter& sPainter) const; |
675 | |
676 | === modified file 'src/core/modules/LandscapeMgr.cpp' |
677 | --- src/core/modules/LandscapeMgr.cpp 2011-09-29 07:14:01 +0000 |
678 | +++ src/core/modules/LandscapeMgr.cpp 2011-12-29 12:15:27 +0000 |
679 | @@ -239,7 +239,7 @@ |
680 | else |
681 | landscapeBrightness = (0.01 + 1.5*(sinSunAngleRad+0.1/1.5)); |
682 | if (moonPos[2] > -0.1/1.5) |
683 | - landscapeBrightness += qMax(0.2/-12.*ssystem->getMoon()->getVMagnitude(core),0.)*moonPos[2]; |
684 | + landscapeBrightness += qMax(0.2/-12.*ssystem->getMoon()->getVMagnitude(core, true),0.)*moonPos[2]; |
685 | |
686 | // TODO make this more generic for non-atmosphere planets |
687 | if(atmosphere->getFadeIntensity() == 1) |
688 | |
689 | === modified file 'src/core/modules/MinorPlanet.cpp' |
690 | --- src/core/modules/MinorPlanet.cpp 2011-11-25 13:51:35 +0000 |
691 | +++ src/core/modules/MinorPlanet.cpp 2011-12-29 12:15:27 +0000 |
692 | @@ -190,7 +190,14 @@ |
693 | } |
694 | |
695 | if (flags&Magnitude) |
696 | - oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core), 0, 'f', 2) << "<br>"; |
697 | + { |
698 | + if (core->getSkyDrawer()->getFlagHasAtmosphere()) |
699 | + oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)").arg(QString::number(getVMagnitude(core, false), 'f', 2), |
700 | + QString::number(getVMagnitude(core, true), 'f', 2)) << "<br>"; |
701 | + else |
702 | + oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core, false), 0, 'f', 2) << "<br>"; |
703 | + |
704 | + } |
705 | |
706 | if (flags&AbsoluteMagnitude) |
707 | { |
708 | @@ -198,7 +205,7 @@ |
709 | //If the H-G system is not used, use the default radius/albedo mechanism |
710 | if (slopeParameter < 0) |
711 | { |
712 | - oss << q_("Absolute Magnitude: %1").arg(getVMagnitude(core) - 5. * (std::log10(getJ2000EquatorialPos(core).length()*AU/PARSEC)-1.), 0, 'f', 2) << "<br>"; |
713 | + oss << q_("Absolute Magnitude: %1").arg(getVMagnitude(core, false) - 5. * (std::log10(getJ2000EquatorialPos(core).length()*AU/PARSEC)-1.), 0, 'f', 2) << "<br>"; |
714 | } |
715 | else |
716 | { |
717 | @@ -241,17 +248,25 @@ |
718 | return str; |
719 | } |
720 | |
721 | -float MinorPlanet::getVMagnitude(const StelCore* core) const |
722 | +float MinorPlanet::getVMagnitude(const StelCore* core, bool withExtinction) const |
723 | { |
724 | + float extinctionMag=0.0; // track magnitude loss |
725 | + if (withExtinction) |
726 | + { |
727 | + Vec3d altAz=getAltAzPosApparent(core); |
728 | + altAz.normalize(); |
729 | + core->getSkyDrawer()->getExtinction().forward(&altAz[2], &extinctionMag); |
730 | + } |
731 | + |
732 | //If the H-G system is not used, use the default radius/albedo mechanism |
733 | if (slopeParameter < 0) |
734 | { |
735 | - return Planet::getVMagnitude(core); |
736 | + return Planet::getVMagnitude(core, withExtinction); |
737 | } |
738 | |
739 | //Calculate phase angle |
740 | //(Code copied from Planet::getVMagnitude()) |
741 | - //(LOL, this is actually vector substraction + the cosine theorem :)) |
742 | + //(LOL, this is actually vector subtraction + the cosine theorem :)) |
743 | const Vec3d& observerHelioPos = core->getObserverHeliocentricEclipticPos(); |
744 | const double observerRq = observerHelioPos.lengthSquared(); |
745 | const Vec3d& planetHelioPos = getHeliocentricEclipticPos(); |
746 | @@ -270,7 +285,7 @@ |
747 | //TODO: See if you can "collapse" some calculations |
748 | double apparentMagnitude = reducedMagnitude + 5 * std::log10(std::sqrt(planetRq * observerPlanetRq)); |
749 | |
750 | - return apparentMagnitude; |
751 | + return apparentMagnitude+extinctionMag; |
752 | } |
753 | |
754 | void MinorPlanet::translateName(StelTranslator &translator) |
755 | |
756 | === modified file 'src/core/modules/MinorPlanet.hpp' |
757 | --- src/core/modules/MinorPlanet.hpp 2011-06-12 15:30:54 +0000 |
758 | +++ src/core/modules/MinorPlanet.hpp 2011-12-29 12:15:27 +0000 |
759 | @@ -70,7 +70,7 @@ |
760 | //was not designed to handle different types of objects. |
761 | // \todo Decide if this is going to be "MinorPlanet" or "Asteroid" |
762 | //virtual QString getType() const {return "MinorPlanet";} |
763 | - virtual float getVMagnitude(const StelCore* core) const; |
764 | + virtual float getVMagnitude(const StelCore* core, bool withExtinction=false) const; |
765 | //! sets the nameI18 property with the appropriate translation. |
766 | //! Function overriden to handle the problem with name conflicts. |
767 | virtual void translateName(StelTranslator& trans); |
768 | |
769 | === modified file 'src/core/modules/Nebula.cpp' |
770 | --- src/core/modules/Nebula.cpp 2011-05-31 13:06:03 +0000 |
771 | +++ src/core/modules/Nebula.cpp 2011-12-29 12:15:27 +0000 |
772 | @@ -96,8 +96,13 @@ |
773 | oss << q_("Type: <b>%1</b>").arg(getTypeString()) << "<br>"; |
774 | |
775 | if (mag < 50 && flags&Magnitude) |
776 | - oss << q_("Magnitude: <b>%1</b>").arg(mag, 0, 'f', 2) << "<br>"; |
777 | - |
778 | + { |
779 | + if (core->getSkyDrawer()->getFlagHasAtmosphere()) |
780 | + oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)").arg(QString::number(getVMagnitude(core, false), 'f', 2), |
781 | + QString::number(getVMagnitude(core, true), 'f', 2)) << "<br>"; |
782 | + else |
783 | + oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core, false), 0, 'f', 2) << "<br>"; |
784 | + } |
785 | oss << getPositionInfoString(core, flags); |
786 | |
787 | if (angularSize>0 && flags&Size) |
788 | @@ -108,6 +113,20 @@ |
789 | return str; |
790 | } |
791 | |
792 | +float Nebula::getVMagnitude(const StelCore* core, bool withExtinction) const |
793 | +{ |
794 | + float extinctionMag=0.0; // track magnitude loss |
795 | + if (withExtinction && core->getSkyDrawer()->getFlagHasAtmosphere()) |
796 | + { |
797 | + Vec3d altAz=getAltAzPosApparent(core); |
798 | + altAz.normalize(); |
799 | + core->getSkyDrawer()->getExtinction().forward(&altAz[2], &extinctionMag); |
800 | + } |
801 | + |
802 | + return mag+extinctionMag; |
803 | +} |
804 | + |
805 | + |
806 | float Nebula::getSelectPriority(const StelCore* core) const |
807 | { |
808 | if( ((NebulaMgr*)StelApp::getInstance().getModuleMgr().getModule("NebulaMgr"))->getFlagHints() ) |
809 | @@ -117,8 +136,8 @@ |
810 | } |
811 | else |
812 | { |
813 | - if (getVMagnitude(core)>20.f) return 20.f; |
814 | - return getVMagnitude(core); |
815 | + if (getVMagnitude(core, false)>20.f) return 20.f; |
816 | + return getVMagnitude(core, false); |
817 | } |
818 | } |
819 | |
820 | |
821 | === modified file 'src/core/modules/Nebula.hpp' |
822 | --- src/core/modules/Nebula.hpp 2011-05-31 13:06:03 +0000 |
823 | +++ src/core/modules/Nebula.hpp 2011-12-29 12:15:27 +0000 |
824 | @@ -53,7 +53,7 @@ |
825 | virtual QString getType() const {return "Nebula";} |
826 | virtual Vec3d getJ2000EquatorialPos(const StelCore*) const {return XYZ;} |
827 | virtual double getCloseViewFov(const StelCore* core = NULL) const; |
828 | - virtual float getVMagnitude(const StelCore* core = NULL) const {Q_UNUSED(core); return mag;} |
829 | + virtual float getVMagnitude(const StelCore* core, bool withExtinction=false) const; |
830 | virtual float getSelectPriority(const StelCore* core) const; |
831 | virtual Vec3f getInfoColor() const; |
832 | virtual QString getNameI18n() const {return nameI18;} |
833 | |
834 | === modified file 'src/core/modules/Planet.cpp' |
835 | --- src/core/modules/Planet.cpp 2011-11-25 13:51:35 +0000 |
836 | +++ src/core/modules/Planet.cpp 2011-12-29 12:15:27 +0000 |
837 | @@ -118,10 +118,15 @@ |
838 | } |
839 | |
840 | if (flags&Magnitude) |
841 | - oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core), 0, 'f', 2) << "<br>"; |
842 | - |
843 | + { |
844 | + if (core->getSkyDrawer()->getFlagHasAtmosphere()) |
845 | + oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)").arg(QString::number(getVMagnitude(core, false), 'f', 2), |
846 | + QString::number(getVMagnitude(core, true), 'f', 2)) << "<br>"; |
847 | + else |
848 | + oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core, false), 0, 'f', 2) << "<br>"; |
849 | + } |
850 | if (flags&AbsoluteMagnitude) |
851 | - oss << q_("Absolute Magnitude: %1").arg(getVMagnitude(core)-5.*(std::log10(getJ2000EquatorialPos(core).length()*AU/PARSEC)-1.), 0, 'f', 2) << "<br>"; |
852 | + oss << q_("Absolute Magnitude: %1").arg(getVMagnitude(core, false)-5.*(std::log10(getJ2000EquatorialPos(core).length()*AU/PARSEC)-1.), 0, 'f', 2) << "<br>"; |
853 | |
854 | oss << getPositionInfoString(core, flags); |
855 | |
856 | @@ -185,11 +190,11 @@ |
857 | if( ((SolarSystem*)StelApp::getInstance().getModuleMgr().getModule("SolarSystem"))->getFlagHints() ) |
858 | { |
859 | // easy to select, especially pluto |
860 | - return getVMagnitude(core)-15.f; |
861 | + return getVMagnitude(core, false)-15.f; |
862 | } |
863 | else |
864 | { |
865 | - return getVMagnitude(core) - 8.f; |
866 | + return getVMagnitude(core, false) - 8.f; |
867 | } |
868 | } |
869 | |
870 | @@ -478,13 +483,22 @@ |
871 | } |
872 | |
873 | // Computation of the visual magnitude (V band) of the planet. |
874 | -float Planet::getVMagnitude(const StelCore* core) const |
875 | +float Planet::getVMagnitude(const StelCore* core, bool withExtinction) const |
876 | { |
877 | + float extinctionMag=0.0; // track magnitude loss |
878 | + if (withExtinction && core->getSkyDrawer()->getFlagHasAtmosphere()) |
879 | + { |
880 | + Vec3d altAz=getAltAzPosApparent(core); |
881 | + altAz.normalize(); |
882 | + core->getSkyDrawer()->getExtinction().forward(&altAz[2], &extinctionMag); |
883 | + } |
884 | + |
885 | + |
886 | if (parent == 0) |
887 | { |
888 | // sun, compute the apparent magnitude for the absolute mag (4.83) and observer's distance |
889 | const double distParsec = std::sqrt(core->getObserverHeliocentricEclipticPos().lengthSquared())*AU/PARSEC; |
890 | - return 4.83 + 5.*(std::log10(distParsec)-1.); |
891 | + return 4.83 + 5.*(std::log10(distParsec)-1.) + extinctionMag; |
892 | } |
893 | |
894 | // Compute the angular phase |
895 | @@ -529,45 +543,118 @@ |
896 | } |
897 | |
898 | // Use empirical formulae for main planets when seen from earth |
899 | - // Algorithm provided by Pere Planesas (Observatorio Astronomico Nacional) |
900 | if (core->getCurrentLocation().planetName=="Earth") |
901 | { |
902 | - phase*=180./M_PI; |
903 | + const double phaseDeg=phase*180./M_PI; |
904 | const double d = 5. * log10(sqrt(observerPlanetRq*planetRq)); |
905 | - double f1 = phase/100.; |
906 | + //double f1 = phaseDeg/100.; |
907 | |
908 | + /* |
909 | + // Algorithm provided by Pere Planesas (Observatorio Astronomico Nacional) |
910 | if (englishName=="Mercury") |
911 | { |
912 | - if ( phase > 150. ) f1 = 1.5; |
913 | - return -0.36 + d + 3.8*f1 - 2.73*f1*f1 + 2*f1*f1*f1; |
914 | + if ( phaseDeg > 150. ) f1 = 1.5; |
915 | + return -0.36 + d + 3.8*f1 - 2.73*f1*f1 + 2*f1*f1*f1 + extinctionMag; |
916 | } |
917 | if (englishName=="Venus") |
918 | - return -4.29 + d + 0.09*f1 + 2.39*f1*f1 - 0.65*f1*f1*f1; |
919 | + return -4.29 + d + 0.09*f1 + 2.39*f1*f1 - 0.65*f1*f1*f1 + extinctionMag; |
920 | if (englishName=="Mars") |
921 | - return -1.52 + d + 0.016*phase; |
922 | + return -1.52 + d + 0.016*phaseDeg + extinctionMag; |
923 | if (englishName=="Jupiter") |
924 | - return -9.25 + d + 0.005*phase; |
925 | + return -9.25 + d + 0.005*phaseDeg + extinctionMag; |
926 | if (englishName=="Saturn") |
927 | { |
928 | // TODO re-add rings computation |
929 | // double rings = -2.6*sinx + 1.25*sinx*sinx; |
930 | - return -8.88 + d + 0.044*phase;// + rings; |
931 | - } |
932 | - |
933 | - if (englishName=="Uranus") |
934 | - return -7.19 + d + 0.0028*phase; |
935 | - if (englishName=="Neptune") |
936 | - return -6.87 + d; |
937 | - if (englishName=="Pluto") |
938 | - return -1.01 + d + 0.041*phase; |
939 | - |
940 | - phase/=180./M_PI; |
941 | + return -8.88 + d + 0.044*phaseDeg + extinctionMag;// + rings; |
942 | + } |
943 | + if (englishName=="Uranus") |
944 | + return -7.19 + d + 0.0028*phaseDeg + extinctionMag; |
945 | + if (englishName=="Neptune") |
946 | + return -6.87 + d + extinctionMag; |
947 | + if (englishName=="Pluto") |
948 | + return -1.01 + d + 0.041*phaseDeg + extinctionMag; |
949 | + */ |
950 | + // GZ: I prefer the values given by Meeus, Astronomical Algorithms (1992). |
951 | + // There are two solutions: |
952 | + // (1) G. Müller, based on visual observations 1877-91. [Expl.Suppl.1961] |
953 | + // (2) Astronomical Almanac 1984 and later. These give V (instrumental) magnitudes. |
954 | + // The structure is almost identical, just the numbers are different! |
955 | + // I activate (1) for now, because we want to simulate the eye's impression. (Esp. Venus!) |
956 | + // (1) |
957 | + if (englishName=="Mercury") |
958 | + { |
959 | + double ph50=phaseDeg-50.0; |
960 | + return 1.16 + d + 0.02838*ph50 + 0.0001023*ph50*ph50 + extinctionMag; |
961 | + } |
962 | + if (englishName=="Venus") |
963 | + return -4.0 + d + 0.01322*phaseDeg + 0.0000004247*phaseDeg*phaseDeg*phaseDeg + extinctionMag; |
964 | + if (englishName=="Mars") |
965 | + return -1.3 + d + 0.01486*phaseDeg + extinctionMag; |
966 | + if (englishName=="Jupiter") |
967 | + return -8.93 + d + extinctionMag; |
968 | + if (englishName=="Saturn") |
969 | + { |
970 | + // TODO re-add rings computation |
971 | + // GZ: implemented from Meeus, Astr.Alg.1992 |
972 | + const double jd=core->getJDay(); |
973 | + const double T=(jd-2451545.0)/36525.0; |
974 | + const double i=((0.000004*T-0.012998)*T+28.075216)*M_PI/180.0; |
975 | + const double Omega=((0.000412*T+1.394681)*T+169.508470)*M_PI/180.0; |
976 | + static SolarSystem *ssystem=GETSTELMODULE(SolarSystem); |
977 | + const Vec3d saturnEarth=getHeliocentricEclipticPos() - ssystem->getEarth()->getHeliocentricEclipticPos(); |
978 | + double lambda=atan2(saturnEarth[1], saturnEarth[0]); |
979 | + double beta=atan2(saturnEarth[2], sqrt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1])); |
980 | + const double sinB=sin(i)*cos(beta)*sin(lambda-Omega)-cos(i)*sin(beta); |
981 | + double rings = -2.6*fabs(sinB) + 1.25*sinB*sinB; // sinx=sinB, saturnicentric latitude of earth. longish, see Meeus. |
982 | + return -8.68 + d + 0.044*phaseDeg + rings + extinctionMag; |
983 | + } |
984 | + if (englishName=="Uranus") |
985 | + return -6.85 + d + extinctionMag; |
986 | + if (englishName=="Neptune") |
987 | + return -7.05 + d + extinctionMag; |
988 | + if (englishName=="Pluto") |
989 | + return -1.0 + d + extinctionMag; |
990 | + /* |
991 | + // (2) |
992 | + if (englishName=="Mercury") |
993 | + return 0.42 + d + .038*phaseDeg - 0.000273*phaseDeg*phaseDeg + 0.000002*phaseDeg*phaseDeg*phaseDeg + extinctionMag; |
994 | + if (englishName=="Venus") |
995 | + return -4.40 + d + 0.0009*phaseDeg + 0.000239*phaseDeg*phaseDeg - 0.00000065*phaseDeg*phaseDeg*phaseDeg + extinctionMag; |
996 | + if (englishName=="Mars") |
997 | + return -1.52 + d + 0.016*phaseDeg + extinctionMag; |
998 | + if (englishName=="Jupiter") |
999 | + return -9.40 + d + 0.005*phaseDeg + extinctionMag; |
1000 | + if (englishName=="Saturn") |
1001 | + { |
1002 | + // TODO re-add rings computation |
1003 | + // GZ: implemented from Meeus, Astr.Alg.1992 |
1004 | + const double jd=core->getJDay(); |
1005 | + const double T=(jd-2451545.0)/36525.0; |
1006 | + const double i=((0.000004*T-0.012998)*T+28.075216)*M_PI/180.0; |
1007 | + const double Omega=((0.000412*T+1.394681)*T+169.508470)*M_PI/180.0; |
1008 | + static SolarSystem *ssystem=GETSTELMODULE(SolarSystem); |
1009 | + const Vec3d saturnEarth=getHeliocentricEclipticPos() - ssystem->getEarth()->getHeliocentricEclipticPos(); |
1010 | + double lambda=atan2(saturnEarth[1], saturnEarth[0]); |
1011 | + double beta=atan2(saturnEarth[2], sqrt(saturnEarth[0]*saturnEarth[0]+saturnEarth[1]*saturnEarth[1])); |
1012 | + const double sinB=sin(i)*cos(beta)*sin(lambda-Omega)-cos(i)*sin(beta); |
1013 | + double rings = -2.6*fabs(sinB) + 1.25*sinB*sinB; // sinx=sinB, saturnicentric latitude of earth. longish, see Meeus. |
1014 | + return -8.88 + d + 0.044*phaseDeg + rings + extinctionMag; |
1015 | + } |
1016 | + if (englishName=="Uranus") |
1017 | + return -7.19f + d + extinctionMag; |
1018 | + if (englishName=="Neptune") |
1019 | + return -6.87f + d + extinctionMag; |
1020 | + if (englishName=="Pluto") |
1021 | + return -1.00f + d + extinctionMag; |
1022 | + */ |
1023 | + // TODO: decide which set of formulae is best? |
1024 | } |
1025 | |
1026 | // This formula seems to give wrong results |
1027 | const double p = (1.0 - phase/M_PI) * cos_chi + std::sqrt(1.0 - cos_chi*cos_chi) / M_PI; |
1028 | double F = 2.0 * albedo * radius * radius * p / (3.0*observerPlanetRq*planetRq) * shadowFactor; |
1029 | - return -26.73 - 2.5 * std::log10(F); |
1030 | + return -26.73 - 2.5 * std::log10(F) + extinctionMag; |
1031 | } |
1032 | |
1033 | double Planet::getAngularSize(const StelCore* core) const |
1034 | @@ -742,7 +829,7 @@ |
1035 | |
1036 | StelPainter sPainter(core->getProjection(StelCore::FrameJ2000)); |
1037 | Vec3d tmp = getJ2000EquatorialPos(core); |
1038 | - core->getSkyDrawer()->postDrawSky3dModel(&sPainter, Vec3f(tmp[0], tmp[1], tmp[2]), surfArcMin2, getVMagnitude(core), color); |
1039 | + core->getSkyDrawer()->postDrawSky3dModel(&sPainter, Vec3f(tmp[0], tmp[1], tmp[2]), surfArcMin2, getVMagnitude(core, true), color); |
1040 | } |
1041 | |
1042 | |
1043 | |
1044 | === modified file 'src/core/modules/Planet.hpp' |
1045 | --- src/core/modules/Planet.hpp 2011-05-31 15:56:59 +0000 |
1046 | +++ src/core/modules/Planet.hpp 2011-12-29 12:15:27 +0000 |
1047 | @@ -119,7 +119,7 @@ |
1048 | virtual double getCloseViewFov(const StelCore* core) const; |
1049 | virtual double getSatellitesFov(const StelCore* core) const; |
1050 | virtual double getParentSatellitesFov(const StelCore* core) const; |
1051 | - virtual float getVMagnitude(const StelCore* core) const; |
1052 | + virtual float getVMagnitude(const StelCore* core, bool withExtinction=false) const; |
1053 | virtual float getSelectPriority(const StelCore* core) const; |
1054 | virtual Vec3f getInfoColor(void) const; |
1055 | virtual QString getType(void) const {return "Planet";} |
1056 | |
1057 | === modified file 'src/core/modules/StarMgr.cpp' |
1058 | --- src/core/modules/StarMgr.cpp 2011-10-28 07:57:30 +0000 |
1059 | +++ src/core/modules/StarMgr.cpp 2011-12-29 12:15:27 +0000 |
1060 | @@ -644,13 +644,18 @@ |
1061 | skyDrawer->preDrawPointSource(&sPainter); |
1062 | |
1063 | // draw all the stars of all the selected zones |
1064 | - float rcmag_table[2*256]; |
1065 | + // GZ: This table must be enlarged from 2x256 to many more entries. CORRELATE IN Zonearray.cpp! |
1066 | + //float rcmag_table[2*256]; |
1067 | + //float rcmag_table[2*16384]; |
1068 | + float rcmag_table[2*4096]; |
1069 | |
1070 | for (ZoneArrayMap::const_iterator it(zoneArrays.constBegin()); it!=zoneArrays.constEnd();++it) |
1071 | { |
1072 | const float mag_min = 0.001f*it.value()->mag_min; |
1073 | - const float k = (0.001f*it.value()->mag_range)/it.value()->mag_steps; |
1074 | - for (int i=it.value()->mag_steps-1;i>=0;--i) |
1075 | + const float k = (0.001f*it.value()->mag_range)/it.value()->mag_steps; // MagStepIncrement |
1076 | + // GZ: add a huge number of entries to rcMag |
1077 | + //for (int i=it.value()->mag_steps-1;i>=0;--i) |
1078 | + for (int i=4096-1;i>=0;--i) |
1079 | { |
1080 | const float mag = mag_min+k*i; |
1081 | if (skyDrawer->computeRCMag(mag,rcmag_table + 2*i)==false) |
1082 | |
1083 | === modified file 'src/core/modules/StarMgr.hpp' |
1084 | --- src/core/modules/StarMgr.hpp 2011-05-31 13:06:03 +0000 |
1085 | +++ src/core/modules/StarMgr.hpp 2011-12-29 12:15:27 +0000 |
1086 | @@ -82,7 +82,7 @@ |
1087 | virtual void init(); |
1088 | |
1089 | //! Draw the stars and the star selection indicator if necessary. |
1090 | - virtual void draw(StelCore* core); //! Draw all the stars |
1091 | + virtual void draw(StelCore* core); |
1092 | |
1093 | //! Update any time-dependent features. |
1094 | //! Includes fading in and out stars and labels when they are turned on and off. |
1095 | |
1096 | === modified file 'src/core/modules/StarWrapper.cpp' |
1097 | --- src/core/modules/StarWrapper.cpp 2011-05-31 13:06:03 +0000 |
1098 | +++ src/core/modules/StarWrapper.cpp 2011-12-29 12:15:27 +0000 |
1099 | @@ -48,9 +48,14 @@ |
1100 | QTextStream oss(&str); |
1101 | |
1102 | if (flags&Magnitude) |
1103 | - oss << q_("Magnitude: <b>%1</b> (B-V: %2)").arg(QString::number(getVMagnitude(core), 'f', 2), QString::number(getBV(), 'f', 2)) << "<br>"; |
1104 | - |
1105 | - oss << getPositionInfoString(core, flags); |
1106 | + { |
1107 | + oss << q_("Magnitude: <b>%1</b> (B-V: %2)").arg(QString::number(getVMagnitude(core, false), 'f', 2), QString::number(getBV(), 'f', 2)) << "<br>"; |
1108 | + if (core->getSkyDrawer()->getFlagHasAtmosphere()) |
1109 | + { |
1110 | + oss << q_("Apparent Magnitude: <b>%1</b> (by extinction)").arg(QString::number(getVMagnitude(core, true), 'f', 2)) << "<br>"; |
1111 | + } |
1112 | + } |
1113 | + oss << getPositionInfoString(core, flags); |
1114 | |
1115 | StelObject::postProcessInfoString(str, flags); |
1116 | |
1117 | @@ -105,11 +110,18 @@ |
1118 | } |
1119 | |
1120 | if (flags&Magnitude) |
1121 | - oss << q_("Magnitude: <b>%1</b> (B-V: %2)").arg(QString::number(getVMagnitude(core), 'f', 2), |
1122 | - QString::number(s->getBV(), 'f', 2)) << "<br>"; |
1123 | + { |
1124 | + if (core->getSkyDrawer()->getFlagHasAtmosphere()) |
1125 | + oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>. B-V: <b>%3</b>)").arg(QString::number(getVMagnitude(core, false), 'f', 2), |
1126 | + QString::number(getVMagnitude(core, true), 'f', 2), |
1127 | + QString::number(s->getBV(), 'f', 2)) << "<br>"; |
1128 | + else |
1129 | + oss << q_("Magnitude: <b>%1</b> (B-V: <b>%2</b>)").arg(QString::number(getVMagnitude(core, false), 'f', 2), |
1130 | + QString::number(s->getBV(), 'f', 2)) << "<br>"; |
1131 | + } |
1132 | |
1133 | if ((flags&AbsoluteMagnitude) && s->plx && !isNan(s->plx) && !isInf(s->plx)) |
1134 | - oss << q_("Absolute Magnitude: %1").arg(getVMagnitude(core)+5.*(1.+std::log10(0.00001*s->plx)), 0, 'f', 2) << "<br>"; |
1135 | + oss << q_("Absolute Magnitude: %1").arg(getVMagnitude(core, false)+5.*(1.+std::log10(0.00001*s->plx)), 0, 'f', 2) << "<br>"; |
1136 | |
1137 | oss << getPositionInfoString(core, flags); |
1138 | |
1139 | |
1140 | === modified file 'src/core/modules/StarWrapper.hpp' |
1141 | --- src/core/modules/StarWrapper.hpp 2011-05-31 13:06:03 +0000 |
1142 | +++ src/core/modules/StarWrapper.hpp 2011-12-29 12:15:27 +0000 |
1143 | @@ -85,11 +85,18 @@ |
1144 | { |
1145 | return StelApp::getInstance().getVisionModeNight() ? Vec3f(0.8, 0.2, 0.2) : StelSkyDrawer::indexToColor(s->bV); |
1146 | } |
1147 | - float getVMagnitude(const StelCore*) const |
1148 | + float getVMagnitude(const StelCore* core, bool withExtinction=false) const |
1149 | { |
1150 | - return 0.001f*a->mag_min + s->mag*(0.001f*a->mag_range)/a->mag_steps; |
1151 | + float extinctionMag=0.0; // track magnitude loss |
1152 | + if (withExtinction && core->getSkyDrawer()->getFlagHasAtmosphere()) |
1153 | + { |
1154 | + double alt=getAltAzPosApparent(core)[2]; |
1155 | + core->getSkyDrawer()->getExtinction().forward(&alt, &extinctionMag); |
1156 | + } |
1157 | + |
1158 | + return 0.001f*a->mag_min + s->mag*(0.001f*a->mag_range)/a->mag_steps + extinctionMag; |
1159 | } |
1160 | - float getSelectPriority(const StelCore* core) const {return getVMagnitude(core);} |
1161 | + float getSelectPriority(const StelCore* core) const {return getVMagnitude(core, false);} |
1162 | float getBV(void) const {return s->getBV();} |
1163 | QString getEnglishName(void) const {return QString();} |
1164 | QString getNameI18n(void) const {return s->getNameI18n();} |
1165 | |
1166 | === modified file 'src/core/modules/ZoneArray.cpp' |
1167 | --- src/core/modules/ZoneArray.cpp 2011-06-23 11:26:56 +0000 |
1168 | +++ src/core/modules/ZoneArray.cpp 2011-12-29 12:15:27 +0000 |
1169 | @@ -476,27 +476,44 @@ |
1170 | void SpecialZoneArray<Star>::draw(StelPainter* sPainter, int index, bool is_inside, const float *rcmag_table, StelCore* core, unsigned int maxMagStarName, |
1171 | float names_brightness) const |
1172 | { |
1173 | - StelSkyDrawer* drawer = core->getSkyDrawer(); |
1174 | - SpecialZoneData<Star> *const z = getZones() + index; |
1175 | - Vec3f vf; |
1176 | - const Star *const end = z->getStars() + z->size; |
1177 | - static const double d2000 = 2451545.0; |
1178 | - const double movementFactor = (M_PI/180)*(0.0001/3600) * ((core->getJDay()-d2000)/365.25) / star_position_scale; |
1179 | - const float* tmpRcmag; |
1180 | - for (const Star *s=z->getStars();s<end;++s) |
1181 | - { |
1182 | - tmpRcmag = rcmag_table+2*s->mag; |
1183 | - if (*tmpRcmag<=0.f) |
1184 | - break; |
1185 | - s->getJ2000Pos(z,movementFactor, vf); |
1186 | - if (drawer->drawPointSource(sPainter, vf, tmpRcmag, s->bV, !is_inside) && s->hasName() && s->mag < maxMagStarName && s->hasComponentID()<=1) |
1187 | - { |
1188 | - const float offset = *tmpRcmag*0.7f; |
1189 | - const Vec3f& colorr = (StelApp::getInstance().getVisionModeNight() ? Vec3f(0.8f, 0.2f, 0.2f) : StelSkyDrawer::indexToColor(s->bV))*0.75f; |
1190 | - sPainter->setColor(colorr[0], colorr[1], colorr[2],names_brightness); |
1191 | - sPainter->drawText(Vec3d(vf[0], vf[1], vf[2]), s->getNameI18n(), 0, offset, offset, false); |
1192 | - } |
1193 | - } |
1194 | + StelSkyDrawer* drawer = core->getSkyDrawer(); |
1195 | + SpecialZoneData<Star> *const z = getZones() + index; |
1196 | + Vec3f vf; |
1197 | + const Star *const end = z->getStars() + z->size; |
1198 | + static const double d2000 = 2451545.0; |
1199 | + const double movementFactor = (M_PI/180)*(0.0001/3600) * ((core->getJDay()-d2000)/365.25) / star_position_scale; |
1200 | + const float* tmpRcmag; // will point to precomputed rC in table |
1201 | + // GZ, added for extinction |
1202 | + Extinction extinction=core->getSkyDrawer()->getExtinction(); |
1203 | + const bool withExtinction=(drawer->getFlagHasAtmosphere() && extinction.getExtinctionCoefficient()>=0.01f); |
1204 | + const float k = (0.001f*mag_range)/mag_steps; // from StarMgr.cpp line 654 |
1205 | + |
1206 | + // go through all stars, which are sorted by magnitude (bright stars first) |
1207 | + for (const Star *s=z->getStars();s<end;++s) |
1208 | + { |
1209 | + tmpRcmag = rcmag_table+2*s->mag; |
1210 | + if (*tmpRcmag<=0.f) break; // no size for this and following (even dimmer, unextincted) stars? --> early exit |
1211 | + s->getJ2000Pos(z,movementFactor, vf); |
1212 | + |
1213 | + // GZ new: |
1214 | + if (withExtinction) |
1215 | + { |
1216 | + //GZ: We must compute position first, then shift magnitude. |
1217 | + Vec3d altAz=core->j2000ToAltAz(Vec3d(vf[0], vf[1], vf[2]), StelCore::RefractionOn); |
1218 | + float extMagShift=0.0f; |
1219 | + extinction.forward(&altAz, &extMagShift); |
1220 | + int extMagShiftStep=qMin((int)floor(extMagShift/k), 4096-mag_steps); // this number muist be equal StarMgr.cpp line 649 |
1221 | + tmpRcmag = rcmag_table+2*(s->mag+extMagShiftStep); |
1222 | + } |
1223 | + |
1224 | + if (drawer->drawPointSource(sPainter, vf, tmpRcmag, s->bV, !is_inside) && s->hasName() && s->mag < maxMagStarName && s->hasComponentID()<=1) |
1225 | + { |
1226 | + const float offset = *tmpRcmag*0.7f; |
1227 | + const Vec3f& colorr = (StelApp::getInstance().getVisionModeNight() ? Vec3f(0.8f, 0.2f, 0.2f) : StelSkyDrawer::indexToColor(s->bV))*0.75f; |
1228 | + sPainter->setColor(colorr[0], colorr[1], colorr[2],names_brightness); |
1229 | + sPainter->drawText(Vec3d(vf[0], vf[1], vf[2]), s->getNameI18n(), 0, offset, offset, false); |
1230 | + } |
1231 | + } |
1232 | } |
1233 | |
1234 | template<class Star> |
You need add [astro] /subhorizontal_ extinction to default_config.ini and set some default setting value. Also we added new plugin with stellar objects - Quasars - I think you can copy code for this plugin from Supernovae plugin.