[Kstars-devel] KDE/kdeedu/kstars/kstars
Alexey Khudyakov
alexey.skladnoy at gmail.com
Tue Jun 29 18:50:39 CEST 2010
SVN commit 1144325 by khudyakov:
Remove old code for calculating refration from SkyMap and use new
in SkyPoint.
I'm not sure that it is correct.
CCMAIL: kstars-devel at kde.org
M +5 -5 kstarsactions.cpp
M +7 -60 skymap.cpp
M +0 -20 skymap.h
--- trunk/KDE/kdeedu/kstars/kstars/kstarsactions.cpp #1144324:1144325
@@ -826,7 +826,7 @@
if ( map()->focusObject() ) //simply update focus to focusObject's position
map()->setFocus( map()->focusObject() );
else { //need to recompute focus for unrefracted position
- map()->setFocusAltAz( map()->refract( map()->focus()->alt(), false ).Degrees(),
+ map()->setFocusAltAz( SkyPoint::unrefract( map()->focus()->alt() ).Degrees(),
map()->focus()->az().Degrees() );
map()->focus()->HorizontalToEquatorial( data()->lst(), data()->geo()->lat() );
}
@@ -835,7 +835,7 @@
} else {
Options::setUseAltAz( true );
if ( Options::useRefraction() ) {
- map()->setFocusAltAz( map()->refract( map()->focus()->alt(), true ).Degrees(),
+ map()->setFocusAltAz( map()->focus()->altRefracted().Degrees(),
map()->focus()->az().Degrees() );
}
actionCollection()->action("coordsys")->setText( i18n("Horizontal &Coordinates") );
@@ -1013,9 +1013,9 @@
void KStars::slotShowPositionBar(SkyPoint* p ) {
if ( Options::showAltAzField() ) {
- dms a( p->alt().Degrees() );
- if ( Options::useAltAz() && Options::useRefraction() )
- a = SkyMap::refract( p->alt(), true ); //true: compute apparent alt from true alt
+ dms a = p->alt();
+ if ( Options::useAltAz() )
+ a = p->altRefracted();
QString s = QString("%1, %2").arg( p->az().toDMSString(true), //true: force +/- symbol
a.toDMSString(true) ); //true: force +/- symbol
statusBar()->changeItem( s, 1 );
--- trunk/KDE/kdeedu/kstars/kstars/skymap.cpp #1144324:1144325
@@ -117,8 +117,6 @@
SkyMap* SkyMap::pinstance = 0;
-double SkyMap::RefractCorr1[184];
-double SkyMap::RefractCorr2[184];
SkyMap* SkyMap::Create()
@@ -174,15 +172,6 @@
connect( &TransientTimer, SIGNAL( timeout() ), this, SLOT( slotTransientTimeout() ) );
connect( this, SIGNAL( destinationChanged() ), this, SLOT( slewFocus() ) );
- //Initialize Refraction correction lookup table arrays. RefractCorr1 is for calculating
- //the apparent altitude from the true altitude, and RefractCorr2 is for the reverse.
- for( int index = 0; index <184; ++index ) {
- double alt = -1.75 + index*0.5; //start at -1.75 degrees to get midpoint value for each interval.
-
- RefractCorr1[index] = 1.02 / tan( dms::PI*( alt + 10.3/(alt + 5.11) )/180.0 ) / 60.0; //correction in degrees.
- RefractCorr2[index] = -1.0 / tan( dms::PI*( alt + 7.31/(alt + 4.4) )/180.0 ) / 60.0;
- }
-
// Time infobox
m_timeBox = new InfoBoxWidget( Options::shadeTimeBox(),
Options::positionTimeBox(),
@@ -306,7 +295,7 @@
//Do not show a transient label if the map is in motion, or if the mouse
//pointer is below the opaque horizon, or if the object has a permanent label
if ( ! slewing && ! ( Options::useAltAz() && Options::showHorizon() && Options::showGround() &&
- refract( mousePoint()->alt(), true ).Degrees() < 0.0 ) ) {
+ SkyPoint::refract(mousePoint()->alt()).Degrees() < 0.0 ) ) {
double maxrad = 1000.0/Options::zoomFactor();
SkyObject *so = data->skyComposite()->objectNearest( mousePoint(), maxrad );
@@ -408,10 +397,7 @@
//update the destination to the selected coordinates
if ( Options::useAltAz() ) {
- if ( Options::useRefraction() )
- setDestinationAltAz( refract( focusPoint()->alt(), true ).Degrees(), focusPoint()->az().Degrees() );
- else
- setDestinationAltAz( focusPoint()->alt().Degrees(), focusPoint()->az().Degrees() );
+ setDestinationAltAz( focusPoint()->altRefracted().Degrees(), focusPoint()->az().Degrees() );
} else {
setDestination( focusPoint() );
}
@@ -752,9 +738,7 @@
if ( Options::isTracking() && focusObject() != NULL ) {
if ( Options::useAltAz() ) {
//Tracking any object in Alt/Az mode requires focus updates
- double dAlt = focusObject()->alt().Degrees();
- if ( Options::useRefraction() )
- dAlt = refract( focusObject()->alt(), true ).Degrees();
+ double dAlt = focusObject()->altRefracted().Degrees();
setFocusAltAz( dAlt, focusObject()->az().Degrees() );
focus()->HorizontalToEquatorial( data->lst(), data->geo()->lat() );
setDestination( focus() );
@@ -942,7 +926,7 @@
if ( Options::useAltAz() ) {
if ( oRefract )
- Y = refract( o->alt(), true ).radians(); //account for atmospheric refraction
+ Y = SkyPoint::refract( o->alt() ).radians(); //account for atmospheric refraction
else
Y = o->alt().radians();
dX = focus()->az().reduce().radians() - o->az().reduce().radians();
@@ -1074,7 +1058,7 @@
alt.setRadians( dy + focus()->alt().radians() );
result.setAz( az.reduce() );
if ( Options::useRefraction() )
- alt = refract( alt, false ); //find true alt from apparent alt
+ alt = SkyPoint::unrefract( alt );
result.setAlt( alt );
result.HorizontalToEquatorial( LST, lat );
return result;
@@ -1131,7 +1115,7 @@
alt.setRadians( Y );
az.setRadians( A + focus()->az().radians() );
if ( Options::useRefraction() )
- alt = refract( alt, false ); //find true alt from apparent alt
+ alt = SkyPoint::unrefract( alt );
result.setAlt( alt );
result.setAz( az );
result.HorizontalToEquatorial( LST, lat );
@@ -1146,40 +1130,6 @@
return result;
}
-dms SkyMap::refract( const dms& alt, bool findApparent ) {
- if (!Options::showGround())
- return alt;
- if ( alt.Degrees() <= -2.000 ) return dms( alt.Degrees() );
-
- int index = int( ( alt.Degrees() + 2.0 )*2. ); //RefractCorr arrays start at alt=-2.0 degrees.
- int index2( index + 1 );
-
- //compute dx, normalized distance from nearest position in lookup table
- double x1 = 0.5*float(index) - 1.75;
- if ( alt.Degrees()<x1 ) index2 = index - 1;
- if ( index2 < 0 ) index2 = index + 1;
- if ( index2 > 183 ) index2 = index - 1;
-
- //Failsafe: if indices are out of range, return the input altitude
- if ( index < 0 || index > 183 || index2 < 0 || index2 > 183 ) {
- return dms( alt.Degrees() );
- }
-
- double x2 = 0.5*float(index2) - 1.75;
- double dx = (alt.Degrees() - x1)/(x2 - x1);
-
- double y1 = RefractCorr1[index];
- double y2 = RefractCorr1[index2];
- if ( !findApparent ) {
- y1 = RefractCorr2[index];
- y2 = RefractCorr2[index2];
- }
-
- //linear interpolation to find refracted altitude
- dms result( alt.Degrees() + y2*dx + y1*(1.0-dx) );
- return result;
-}
-
//---------------------------------------------------------------------------
@@ -1220,10 +1170,7 @@
if ( useAltAz && Options::showHorizon() && Options::showGround() && p->alt().Degrees() < -1.0 ) return false;
if ( useAltAz ) {
- if ( Options::useRefraction() )
- dY = fabs( refract( p->alt(), true ).Degrees() - focus()->alt().Degrees() );
- else
- dY = fabs( p->alt().Degrees() - focus()->alt().Degrees() );
+ dY = p->altRefracted().Degrees() - focus()->alt().Degrees();
} else {
dY = fabs( p->dec().Degrees() - focus()->dec().Degrees() );
}
--- trunk/KDE/kdeedu/kstars/kstars/skymap.h #1144324:1144325
@@ -461,24 +461,6 @@
*/
void forceUpdateNow() { forceUpdate( true ); }
- /**Estimate the effect of atmospheric refraction on object positions. Refraction
- * affects only the Altitude angle of objects. Also, the correction should not be applied
- * to the horizon, which is not beyond the atmosphere.
- *
- * To estimate refraction, we use a simple analytic equation. To save time, we store
- * values of the correction for 0.5-degree Altitude intervals. Individual objects are then
- * simply assigned the nearest stored value. The precaclulated values are stored in the
- * RefractCorr1 and RefractCorr2 arrays, and these are initialized in the SkyMap constructor.
- *
- * There are two cases: the true altitude is known, and the apparent altitude is needed;
- * or the apparent altitude is known and the true altitude is needed.
- * @param alt The input altitude
- * @param findApparent if true, then alt is the true altitude, and we'll find the apparent alt.
- * @return the corrected altitude, as a dms object.
- */
- // FIXME: move out of SkyMap
- static dms refract( const dms& alt, bool findApparent );
-
/** Toggle visibility of geo infobox */
void slotToggleGeoBox(bool);
@@ -831,8 +813,6 @@
bool computeSkymap; //if false only old pixmap will repainted with bitBlt(), this saves a lot of cpu usage
bool angularDistanceMode;
int scrollCount;
- static double RefractCorr1[184];
- static double RefractCorr2[184];
double y0;
double m_Scale;
More information about the Kstars-devel
mailing list