kstars
dms.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef DMS_H
00019 #define DMS_H
00020
00021 #include <math.h>
00022 #include <qstring.h>
00023 #include <kdebug.h>
00024
00025
00026 #define J2000 2451545.0 //Julian Date for noon on Jan 1, 2000 (epoch J2000)
00027
00028 #define B1950 2433282.4235 // Julian date for Jan 0.9235, 1950
00029
00046 class dms {
00047 public:
00056 dms( const int &d=0, const int &m=0, const int &s=0, const int &ms=0 ) { setD( d, m, s, ms ); }
00057
00063 dms( const double &x ) { setD( x ); }
00064
00078 dms( const QString &s, bool isDeg=true ) { setFromString( s, isDeg ); }
00079
00082 ~dms() {}
00083
00086 const int degree() const { return int( D ) ; }
00087
00091 const int arcmin() const;
00092
00096 const int arcsec() const;
00097
00101 const int marcsec() const;
00102
00105 const double& Degrees() const { return D; }
00106
00111 const int hour() const { return int( reduce().Degrees()/15.0 ); }
00112
00116 const int minute() const;
00117
00121 const int second() const;
00122
00126 const int msecond() const;
00127
00132 const double Hours() const { return reduce().Degrees()/15.0; }
00133
00138 void setDeg( const int &d ) { setD( d, arcmin(), arcsec() ); }
00139
00144 void setArcMin( const int &m ) { setD( degree(), m, arcsec() ); }
00145
00150 void setArcSec( const int &s ) { setD( degree(), arcmin(), s ); }
00151
00155 void setD( const double &x );
00156
00171 void setD( const int &d, const int &m, const int &s, const int &ms=0 );
00172
00178 void setHour( const int &h ) { setH( h, minute(), second() ); }
00179
00185 void setHMin( const int &m ) { setH( hour(), m, second() ); }
00186
00192 void setHSec( const int &s ) { setH( hour(), minute(), s ); }
00193
00201 void setH( const double &x );
00202
00215 void setH( const int &h, const int &m, const int &s, const int &ms=0 );
00216
00220 void set( const dms &d ) { setD( d.Degrees() ); }
00221
00227 void set( const double &d ) { setD( d ); }
00228
00237 bool setFromString( const QString &s, bool isDeg=true );
00238
00244
00250
00258
00264
00265
00277 void SinCos( double &s, double &c ) const;
00278
00287 const double& sin( void ) const;
00288
00297 const double& cos( void ) const;
00298
00305 const double& radians( void ) const;
00306
00313 void setRadians( const double &a );
00314
00318 const dms reduce( void ) const;
00319
00323 const QString toDMSString(const bool forceSign = false) const;
00324
00328 const QString toHMSString() const;
00329
00333 static const double PI;
00334
00338 static const double DegToRad;
00339
00354 static dms fromString(QString & s, bool deg);
00355
00356 private:
00357 double D;
00358
00359 mutable double Radians;
00360 mutable double Sin, Cos;
00361 mutable bool scDirty, rDirty;
00362 };
00363
00364 #endif