SkyPoint SkyPoint::timeTransformed( const SkyPoint *p, const KStarsDateTime &dt, const GeoLocation *geo, const double hour ) { Q_ASSERT( p ); if( !p ) return SkyPoint( NaN::d, NaN::d ); // Jasem 2015-08-24 Using correct procedure to find altitude SkyPoint sp = *p; // make a copy KStarsDateTime targetDateTime = dt.addSecs( hour * 3600.0 ); dms LST = geo->GSTtoLST( targetDateTime.gst() ); sp.EquatorialToHorizontal( &LST, geo->lat() ); return sp; }
QTime SkyObject::riseSetTime( const KStarsDateTime &dt, const GeoLocation *geo, bool rst ) { //this object does not rise or set; return an invalid time if ( checkCircumpolar(geo->lat()) ) return QTime( 25, 0, 0 ); //First of all, if the object is below the horizon at date/time dt, adjust the time //to bring it above the horizon KStarsDateTime dt2 = dt; SkyPoint p = recomputeCoords( dt, geo ); p.EquatorialToHorizontal( &(geo->GSTtoLST( dt.gst() )), geo->lat() ); if ( p.alt()->Degrees() < 0.0 ) { if ( p.az()->Degrees() < 180.0 ) { //object has not risen yet dt2 = dt.addSecs( 12.*3600. ); } else { //object has already set dt2 = dt.addSecs( -12.*3600. ); } } return geo->UTtoLT( KStarsDateTime( dt2.date(), riseSetTimeUT( dt2, geo, rst ) ) ).time(); }
QTime SkyObject::transitTimeUT( const KStarsDateTime &dt, const GeoLocation *geo ) { dms LST = geo->GSTtoLST( dt.gst() ); //dSec is the number of seconds until the object transits. dms HourAngle = dms( LST.Degrees() - ra()->Degrees() ); int dSec = int( -3600.*HourAngle.Hours() ); //dt0 is the first guess at the transit time. KStarsDateTime dt0 = dt.addSecs( dSec ); //recompute object's position at UT0 and then find //transit time of this refined position SkyPoint sp = recomputeCoords( dt0, geo ); const dms *ram = sp.ra0(); HourAngle = dms ( LST.Degrees() - ram->Degrees() ); dSec = int( -3600.*HourAngle.Hours() ); return dt.addSecs( dSec ).time(); }
SkyPoint SkyObject::recomputeCoords( const KStarsDateTime &dt, const GeoLocation *geo ) { //store current position SkyPoint original( ra(), dec() ); // compute coords for new time jd KSNumbers num( dt.djd() ); if ( isSolarSystem() && geo ) { dms LST = geo->GSTtoLST( dt.gst() ); updateCoords( &num, true, geo->lat(), &LST ); } else { updateCoords( &num ); } //the coordinates for the date dt: SkyPoint sp = SkyPoint( ra(), dec() ); // restore original coords setRA( original.ra()->Hours() ); setDec( original.dec()->Degrees() ); return sp; }
void modCalcVlsr::slotCompute() { bool ok1(false), ok2(false); SkyPoint sp( RA->createDms(false, &ok1), Dec->createDms(true, &ok2) ); if ( !ok1 || !ok2 ) return; KStarsDateTime dt = Date->dateTime(); double vst[3]; geoPlace->TopocentricVelocity( vst, dt.gst() ); if ( sender()->objectName() == "VLSR" ) velocityFlag = 0; if ( sender()->objectName() == "VHelio" ) velocityFlag = 1; if ( sender()->objectName() == "VGeo" ) velocityFlag = 2; if ( sender()->objectName() == "VTopo" ) velocityFlag = 3; switch ( velocityFlag ) { case 0: //Hold VLSR constant, compute the others { double vlsr = VLSR->text().toDouble(); double vhelio = sp.vHeliocentric( vlsr, dt.djd() ); double vgeo = sp.vGeocentric( vhelio, dt.djd() ); VHelio->setText( QString::number( vhelio ) ); VGeo->setText( QString::number( vgeo ) ); VTopo->setText( QString::number( sp.vTopocentric(vgeo, vst) ) ); break; } case 1: //Hold VHelio constant, compute the others { double vhelio = VHelio->text().toDouble(); double vlsr = sp.vHelioToVlsr( vhelio, dt.djd() ); double vgeo = sp.vGeocentric( vhelio, dt.djd() ); VLSR->setText( QString::number( vlsr ) ); VGeo->setText( QString::number( vgeo ) ); VTopo->setText( QString::number( sp.vTopocentric(vgeo, vst) ) ); break; } case 2: //Hold VGeo constant, compute the others { double vgeo = VGeo->text().toDouble(); double vhelio = sp.vGeoToVHelio( vgeo, dt.djd() ); double vlsr = sp.vHelioToVlsr( vhelio, dt.djd() ); VLSR->setText( QString::number( vlsr ) ); VHelio->setText( QString::number( vhelio ) ); VTopo->setText( QString::number( sp.vTopocentric(vgeo, vst) ) ); break; } case 3: //Hold VTopo constant, compute the others { double vtopo = VTopo->text().toDouble(); double vgeo = sp.vTopoToVGeo( vtopo, vst ); double vhelio = sp.vGeoToVHelio( vgeo, dt.djd() ); double vlsr = sp.vHelioToVlsr( vhelio, dt.djd() ); VLSR->setText( QString::number( vlsr ) ); VHelio->setText( QString::number( vhelio ) ); VGeo->setText( QString::number( vgeo ) ); break; } default: //oops kDebug() << i18n("Error: do not know which velocity to use for input."); break; } }
void DetailsTable::createCoordinatesTable(SkyObject *obj, const KStarsDateTime &ut, GeoLocation *geo) { clearContents(); QTextCursor cursor = m_Document->rootFrame()->firstCursorPosition(); // Set column width constraints QVector<QTextLength> constraints; constraints << QTextLength(QTextLength::PercentageLength, 25) << QTextLength(QTextLength::PercentageLength, 25) << QTextLength(QTextLength::PercentageLength, 25) << QTextLength(QTextLength::PercentageLength, 25); m_TableFormat.setColumnWidthConstraints(constraints); // Insert table & row containing table name QTextTable *table = cursor.insertTable(4, 4, m_TableFormat); table->mergeCells(0, 0, 1, 4); QTextBlockFormat centered; centered.setAlignment(Qt::AlignCenter); table->cellAt(0, 0).firstCursorPosition().setBlockFormat(centered); table->cellAt(0, 0).firstCursorPosition().insertText(i18n("Coordinates"), m_TableTitleCharFormat); //Coordinates Section: //Don't use KLocale::formatNumber() for the epoch string, //because we don't want a thousands-place separator! QString sEpoch = QString::number(ut.epoch(), 'f', 1); //Replace the decimal point with localized decimal symbol sEpoch.replace('.', KGlobal::locale()->decimalSymbol()); table->cellAt(1, 0).firstCursorPosition().insertText(i18n("RA (%1):", sEpoch), m_ItemNameCharFormat); table->cellAt(1, 0).firstCursorPosition().setBlockFormat(centered); table->cellAt(1, 1).firstCursorPosition().insertText(obj->ra().toHMSString(), m_ItemValueCharFormat); table->cellAt(2, 0).firstCursorPosition().insertText(i18n("Dec (%1):", sEpoch), m_ItemNameCharFormat); table->cellAt(2, 0).firstCursorPosition().setBlockFormat(centered); table->cellAt(2, 1).firstCursorPosition().insertText(obj->dec().toDMSString(), m_ItemValueCharFormat); table->cellAt(3, 0).firstCursorPosition().insertText(i18n("Hour angle:"), m_ItemNameCharFormat); table->cellAt(3, 0).firstCursorPosition().setBlockFormat(centered); //Hour Angle can be negative, but dms HMS expressions cannot. //Here's a kludgy workaround: dms lst = geo->GSTtoLST(ut.gst()); dms ha(lst.Degrees() - obj->ra().Degrees()); QChar sgn('+'); if(ha.Hours() > 12.0) { ha.setH(24.0 - ha.Hours()); sgn = '-'; } table->cellAt(3, 1).firstCursorPosition().insertText(QString("%1%2").arg(sgn).arg(ha.toHMSString()), m_ItemValueCharFormat); table->cellAt(1, 2).firstCursorPosition().insertText(i18n("Azimuth:"), m_ItemNameCharFormat); table->cellAt(1, 2).firstCursorPosition().setBlockFormat(centered); table->cellAt(1, 3).firstCursorPosition().insertText(obj->az().toDMSString(), m_ItemValueCharFormat); table->cellAt(2, 2).firstCursorPosition().insertText(i18n("Altitude:"), m_ItemNameCharFormat); table->cellAt(2, 2).firstCursorPosition().setBlockFormat(centered); dms a; if(Options::useAltAz()) { a = obj->alt(); } else { a = obj->altRefracted(); } table->cellAt(2, 3).firstCursorPosition().insertText(a.toDMSString(), m_ItemValueCharFormat); table->cellAt(3, 2).firstCursorPosition().insertText(i18n("Airmass:"), m_ItemNameCharFormat); table->cellAt(3, 2).firstCursorPosition().setBlockFormat(centered); //Airmass is approximated as the secant of the zenith distance, //equivalent to 1./sin(Alt). Beware of Inf at Alt=0! QString aMassStr; if(obj->alt().Degrees() > 0.0) { aMassStr = KGlobal::locale()->formatNumber(1./sin(obj->alt().radians() ), 2); } else { aMassStr = "--"; } table->cellAt(3, 3).firstCursorPosition().insertText(aMassStr, m_ItemValueCharFormat); // Restore the position and other time-dependent parameters obj->recomputeCoords(ut, geo); }
QTime modCalcSidTime::computeLTtoST( QTime lt ) { KStarsDateTime utdt = geo->LTtoUT( KStarsDateTime( Date->date(), lt ) ); dms st = geo->GSTtoLST( utdt.gst() ); return QTime( st.hour(), st.minute(), st.second() ); }
void modCalcAltAz::slotDateTimeChanged(const QDateTime &dt) { KStarsDateTime ut = geoPlace->LTtoUT( KStarsDateTime( dt ) ); LST = geoPlace->GSTtoLST( ut.gst() ); }