00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _STELUTILS_HPP_
00021 #define _STELUTILS_HPP_
00022
00023 #include "VecMath.hpp"
00024
00025 #include <QVariantMap>
00026 #include <QDateTime>
00027 #include <QString>
00028
00029
00030 #define AU 149597870.691
00031
00032 #define PARSEC 30.857e12
00033
00034 #define SPEED_OF_LIGHT 299792.458
00035
00037 namespace StelUtils
00038 {
00040 QString getApplicationName();
00041
00043 QString getApplicationVersion();
00044
00050 double hmsToRad(unsigned int h, unsigned int m, double s);
00051
00057 double dmsToRad(int d, unsigned int m, double s);
00058
00064 void radToHms(double rad, unsigned int& h, unsigned int& m, double& s);
00065
00072 void radToDms(double rad, bool& sign, unsigned int& d, unsigned int& m, double& s);
00073
00077 QString radToHmsStrAdapt(double angle);
00078
00082 QString radToHmsStr(double angle, bool decimal=false);
00083
00088 QString radToDmsStrAdapt(double angle, bool useD=false);
00089
00094 QString radToDmsStr(double angle, bool decimal=false, bool useD=false);
00095
00100 Vec3f strToVec3f(const QStringList& s);
00101 Vec3f strToVec3f(const QString& s);
00102
00106 QString vec3fToHtmlColor(const Vec3f& v);
00107
00110 Vec3f htmlColorToVec3f(const QString& c);
00111
00116 void spheToRect(double lng, double lat, Vec3d& v);
00117
00122 void spheToRect(float lng, float lat, Vec3f& v);
00123
00128 void rectToSphe(double *lng, double *lat, const Vec3d& v);
00129
00134 void rectToSphe(float *lng, float *lat, const Vec3d& v);
00135
00156 double getDecAngle(const QString& str);
00157
00159 bool isPowerOfTwo(int value);
00160
00162 int getBiggerPowerOfTwo(int value);
00163
00165 double asinh(double z);
00166
00168
00170 void getDateFromJulianDay(double julianDay, int *year, int *month, int *day);
00171
00173 void getTimeFromJulianDay(double julianDay, int *hour, int *minute, int *second);
00174
00176 QString sixIntsToIsoString( int year, int month, int day, int hour, int minute, int second );
00177
00178 QString jdToIsoString(double jd);
00179
00182 QString localeDateString(int year, int month, int day, int dayOfWeek, QString fmt);
00183
00186 QString localeDateString(int year, int month, int day, int dayOfWeek);
00187
00190 double getJDFromSystem(void);
00191
00195 double qTimeToJDFraction(const QTime& time);
00196
00198 QTime jdFractionToQTime(const double jd);
00199
00201 float getGMTShiftFromQT(double JD);
00202
00206 double qDateTimeToJd(const QDateTime& dateTime);
00207
00211 QDateTime jdToQDateTime(const double& jd);
00212
00213 bool getJDFromDate(double* newjd, int y, int m, int d, int h, int min, int s);
00214
00215 int numberOfDaysInMonthInYear(int month, int year);
00216 bool changeDateTimeForRollover(int oy, int om, int od, int oh, int omin, int os,
00217 int* ry, int* rm, int* rd, int* rh, int* rmin, int* rs);
00218
00220 void debugQVariantMap(const QVariant& m, const QString& indent="", const QString& key="");
00221
00223 QList<int> getIntsFromISO8601String(const QString& iso8601Date);
00224
00227 inline float fastAcos(float x)
00228 {
00229 return M_PI_2 - (x + x*x*x * (1.f/6.f + x*x * (3.f/40.f + 5.f/112.f * x*x)) );
00230 }
00231
00233 inline float fastExp(float x)
00234 {
00235 return (x>=0)?
00236 (1.f + x*(1.f+ x/2.f*(1.f+ x/3.f*(1.f+x/4.f*(1.f+x/5.f))))):
00237 1.f / (1.f -x*(1.f -x/2.f*(1.f- x/3.f*(1.f-x/4.f*(1.f-x/5.f)))));
00238 }
00239 }
00240
00241 #endif // _STELUTILS_HPP_