void SkyPoint::findEcliptic( const dms *Obliquity, dms &EcLong, dms &EcLat ) { double sinRA, cosRA, sinOb, cosOb, sinDec, cosDec, tanDec; ra().SinCos( sinRA, cosRA ); dec().SinCos( sinDec, cosDec ); Obliquity->SinCos( sinOb, cosOb ); tanDec = sinDec/cosDec; // FIXME: -jbb div by zero? double y = sinRA*cosOb + tanDec*sinOb; double ELongRad = atan2( y, cosRA ); EcLong.setRadians( ELongRad ); EcLong.reduce(); EcLat.setRadians( asin( sinDec*cosOb - cosDec*sinOb*sinRA ) ); }
void SkyPoint::setFromEcliptic( const dms *Obliquity, const dms& EcLong, const dms& EcLat ) { double sinLong, cosLong, sinLat, cosLat, sinObliq, cosObliq; EcLong.SinCos( sinLong, cosLong ); EcLat.SinCos( sinLat, cosLat ); Obliquity->SinCos( sinObliq, cosObliq ); double sinDec = sinLat*cosObliq + cosLat*sinObliq*sinLong; double y = sinLong*cosObliq - (sinLat/cosLat)*sinObliq; double RARad = atan2( y, cosLong ); RA.setRadians( RARad ); RA.reduce(); Dec.setRadians( asin(sinDec) ); }
QString KSUtils::toDirectionString( dms angle ) { // TODO: Instead of doing it this way, it would be nicer to // compute the string to arbitrary precision. Although that will // not be easy to localize. (Consider, for instance, Indian // languages that have special names for the intercardinal points) // -- asimha static const char *directions[] = { I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "N"), I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "NNE"), I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "NE"), I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "ENE"), I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "E"), I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "ESE"), I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "SE"), I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "SSE"), I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "S"), I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "SSW"), I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "SW"), I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "WSW"), I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "W"), I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "WNW"), I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "NW"), I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "NNW"), I18N_NOOP2( "Abbreviated cardinal / intercardinal etc. direction", "N"), }; int index = (int)( (angle.Degrees() + 11.25) / 22.5); // A number between 0 and 16 (inclusive), 16 meaning the same thing as zero. return i18nc( "Abbreviated cardinal / intercardinal etc. direction", directions[ index ] ); }
void SkyPoint::Equatorial1950ToGalactic(dms &galLong, dms &galLat) { double a = 192.25; double sinb, cosb, sina_RA, cosa_RA, sinDEC, cosDEC, tanDEC; dms c(303.0); dms b(27.4); tanDEC = tan( Dec.radians() ); b.SinCos(sinb,cosb); dms( a - RA.Degrees() ).SinCos(sina_RA,cosa_RA); Dec.SinCos(sinDEC,cosDEC); galLong.setRadians( c.radians() - atan2( sina_RA, cosa_RA*sinb-tanDEC*cosb) ); galLong = galLong.reduce(); galLat.setRadians( asin(sinDEC*sinb+cosDEC*cosb*cosa_RA) ); }
bool SkyPoint::checkBendLight() { // First see if we are close enough to the sun to bother about the // gravitational lensing effect. We correct for the effect at // least till b = 10 solar radii, where the effect is only about // 0.06". Assuming min. sun-earth distance is 200 solar radii. static const dms maxAngle( 1.75 * ( 30.0 / 200.0) / dms::DegToRad ); if( !m_Sun ) m_Sun = (KSSun*) KStarsData::Instance()->skyComposite()->findByName( "Sun" ); // TODO: This can be optimized further. We only need a ballpark estimate of the distance to the sun to start with. return ( fabs( angularDistanceTo( static_cast<const SkyPoint *>(m_Sun) ).Degrees() ) <= maxAngle.Degrees() ); // NOTE: dynamic_cast is slow and not important here. }
QTime KStarsDateTime::GSTtoUT( dms GST ) const { dms gst0 = GSTat0hUT(); //dt is the number of sidereal hours since UT 0h. double dt = GST.Hours() - gst0.Hours(); while ( dt < 0.0 ) dt += 24.0; while ( dt >= 24.0 ) dt -= 24.0; //convert to solar time. dt is now the number of hours since 0h UT. dt /= SIDEREALSECOND; int hr = int( dt ); int mn = int( 60.0*( dt - double( hr ) ) ); int sc = int( 60.0*( 60.0*( dt - double( hr ) ) - double( mn ) ) ); int ms = int( 1000.0*( 60.0*( 60.0*( dt - double(hr) ) - double(mn) ) - double(sc) ) ); return( QTime( hr, mn, sc, ms ) ); }
QString KSUtils::getDSSURL( const dms &ra, const dms &dec, float width, float height, const QString & type) { const QString URLprefix( "http://archive.stsci.edu/cgi-bin/dss_search?v=poss2ukstu_blue" ); QString URLsuffix = QString( "&e=J2000&f=%1&c=none&fov=NONE" ).arg(type); const double dss_default_size = Options::defaultDSSImageSize(); char decsgn = ( dec.Degrees() < 0.0 ) ? '-' : '+'; int dd = abs( dec.degree() ); int dm = abs( dec.arcmin() ); int ds = abs( dec.arcsec() ); // Infinite and NaN sizes are replaced by the default size if( !qIsFinite( height ) ) height = dss_default_size; if( !qIsFinite( width ) ) width = dss_default_size; // Negative / zero sizes are replaced by the default size if( height <= 0.0 ) height = dss_default_size; if( width <= 0.0 ) width = dss_default_size; // DSS accepts images that are no larger than 75 arcminutes if( height > 75.0 ) height = 75.0; if( width > 75.0 ) width = 75.0; QString RAString, DecString, SizeString; DecString = DecString.sprintf( "&d=%c%02d+%02d+%02d", decsgn, dd, dm, ds ); RAString = RAString.sprintf( "&r=%02d+%02d+%02d", ra.hour(), ra.minute(), ra.second() ); SizeString = SizeString.sprintf( "&h=%02.1f&w=%02.1f", height, width ); return ( URLprefix + RAString + DecString + SizeString + URLsuffix ); }
void dmsBox::showInHours (dms d) { double seconds = d.second() + d.msecond()/1000.; setDMS( QString().sprintf( "%02d %02d %05.2f", d.hour(), d.minute(), seconds ) ); }
void dmsBox::showInDegrees (dms d) { double seconds = d.arcsec() + d.marcsec()/1000.; setDMS( QString().sprintf( "%02d %02d %05.2f", d.degree(), d.arcmin(), seconds ) ); }
/// Can be constructed with an EAST dms-class inline explicit longitude(const dms<east, T>& v) : detail::graticule<T>(v.as_value()) {}
/// Can be constructed with a SOUTH dms-class inline explicit latitude(const dms<south,T>& v) : detail::graticule<T>(v.as_value()) {}
/// Can be constructed with a WEST dms-class inline explicit longitude(dms<west, T> const& v) : detail::graticule<T>(v.as_value()) {}
/// Can be constructed with a NORTH dms-class inline explicit latitude(dms<north,T> const& v) : detail::graticule<T>(v.as_value()) {}