Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · File Structure

core/StelUtils.hpp

00001 /*
00002  * Stellarium
00003  * Copyright (C) 2002 Fabien Chereau
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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 // astonomical unit (km)
00030 #define AU 149597870.691
00031 // Parsec (km)
00032 #define PARSEC 30.857e12
00033 // speed of light (km/sec)
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     // New Qt based General Calendar Functions.
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_

Generated on Mon Mar 22 09:55:38 2010 for Stellarium by  doxygen 1.5.5