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

StelUtils Namespace Reference

contains general purpose utility functions. More...

Functions

QString getApplicationName ()
 Return the full name of stellarium, i.e. "stellarium 0.9.0".
QString getApplicationVersion ()
 Return the version of stellarium, i.e. "0.9.0".
double hmsToRad (unsigned int h, unsigned int m, double s)
 Convert an angle in hms format to radian.
double dmsToRad (int d, unsigned int m, double s)
 Convert an angle in +-dms format to radian.
void radToHms (double rad, unsigned int &h, unsigned int &m, double &s)
 Convert an angle in radian to hms format.
void radToDms (double rad, bool &sign, unsigned int &d, unsigned int &m, double &s)
 Convert an angle in radian to +-dms format.
QString radToHmsStrAdapt (double angle)
 Convert an angle in radian to a hms formatted string.
QString radToHmsStr (double angle, bool decimal=false)
 Convert an angle in radian to a hms formatted string.
QString radToDmsStrAdapt (double angle, bool useD=false)
 Convert an angle in radian to a dms formatted string.
QString radToDmsStr (double angle, bool decimal=false, bool useD=false)
 Convert an angle in radian to a dms formatted string.
double dmsStrToRad (const QString &s)
 Convert a dms formatted string to an angle in radian.
Vec3f strToVec3f (const QStringList &s)
 Obtains a Vec3f from a string.
Vec3f strToVec3f (const QString &s)
QString vec3fToHtmlColor (const Vec3f &v)
 Converts a Vec3f to HTML color notation.
Vec3f htmlColorToVec3f (const QString &c)
 Converts a color in HTML notation to a Vec3f.
void spheToRect (double lng, double lat, Vec3d &v)
 Convert from spherical coordinates to Rectangular direction.
void spheToRect (float lng, float lat, Vec3f &v)
 Convert from spherical coordinates to Rectangular direction.
void rectToSphe (double *lng, double *lat, const Vec3d &v)
 Convert from spherical coordinates to Rectangular direction.
void rectToSphe (float *lng, float *lat, const Vec3d &v)
 Convert from spherical coordinates to Rectangular direction.
void ctRadec2Ecl (const double raRad, const double decRad, const double eclRad, double *lambdaRad, double *betaRad)
 Coordinate Transformation from equatorial to ecliptical.
double getDecAngle (const QString &str)
 Convert a string longitude, latitude, RA or Declination angle to radians.
bool isPowerOfTwo (int value)
 Check if a number is a power of 2.
int smallestPowerOfTwoGreaterOrEqualTo (int value)
 Return the first power of two greater or equal to the given value.
QSize smallestPowerOfTwoSizeGreaterOrEqualTo (const QSize base)
 Return the smallest size with power-of two dimensions at least as large as given size.
double asinh (double z)
 Return the inverse sinus hyperbolic of z.
void getDateFromJulianDay (double julianDay, int *year, int *month, int *day)
 Make from julianDay a year, month, day for the Julian Date julianDay represents.
void getTimeFromJulianDay (double julianDay, int *hour, int *minute, int *second)
 Make from julianDay an hour, minute, second.
bool getDateTimeFromISO8601String (const QString &iso8601Date, int *y, int *m, int *d, int *h, int *min, float *s)
 Parse an ISO8601 date string.
QString julianDayToISO8601String (double jd)
 Format the given Julian Day in (UTC) ISO8601 date string.
double getJulianDayFromISO8601String (const QString &iso8601Date, bool *ok)
 Return the Julian Date matching the ISO8601 date string.
QString localeDateString (int year, int month, int day, int dayOfWeek, QString fmt)
 Format the date and day-of-week per the format in fmt (see QDateTime::toString()).
QString localeDateString (int year, int month, int day, int dayOfWeek)
 Format the date and day-of-week per the system locale's QLocale::ShortFormat.
double getJDFromSystem ()
 Get the current Julian Date from system time.
double qTimeToJDFraction (const QTime &time)
 Convert a time of day to the fraction of a Julian Day.
QTime jdFractionToQTime (double jd)
 Convert a fraction of a Julian Day to a QTime.
float getGMTShiftFromQT (double jd)
 Return number of hours offset from GMT, using Qt functions.
double qDateTimeToJd (const QDateTime &dateTime)
 Convert a QT QDateTime class to julian day.
QDateTime jdToQDateTime (const double &jd)
 Convert a julian day to a QDateTime.
bool getJDFromDate (double *newjd, int y, int m, int d, int h, int min, int s)
int numberOfDaysInMonthInYear (int month, int year)
bool changeDateTimeForRollover (int oy, int om, int od, int oh, int omin, int os, int *ry, int *rm, int *rd, int *rh, int *rmin, int *rs)
void debugQVariantMap (const QVariant &m, const QString &indent="", const QString &key="")
 Output a QVariantMap to qDebug(). Formats like a tree where there are nested objects.
float fastAcos (float x)
 Compute acos(x) The taylor serie is not accurate around x=1 and x=-1.
float fastExp (float x)
 Compute exp(x) for small exponents x.
Vec3f getNightColor (const Vec3f &dayColor)
 Get a night mode version of a color.
double calculateSiderealPeriod (double SemiMajorAxis)
 Calculate and getting sidereal period in days from semi-major axis (in AU).
double calculateSolarDay (double siderealPeriod, double siderealDay, bool forwardDirection)
 Calculate duration of mean solar day.
QString hoursToHmsStr (double hours)
long double secondsSinceStart ()
 Get the number of seconds since program start.
double getDeltaT (double jDay)
 Get Delta-T estimation for a given date.
double getMoonSecularAcceleration (double jDay)
 Get Secular Acceleration estimation for a given year.

Detailed Description

contains general purpose utility functions.


Function Documentation

double StelUtils::asinh ( double  z  ) 

Return the inverse sinus hyperbolic of z.

double StelUtils::calculateSiderealPeriod ( double  SemiMajorAxis  ) 

Calculate and getting sidereal period in days from semi-major axis (in AU).

double StelUtils::calculateSolarDay ( double  siderealPeriod,
double  siderealDay,
bool  forwardDirection 
)

Calculate duration of mean solar day.

void StelUtils::ctRadec2Ecl ( const double  raRad,
const double  decRad,
const double  eclRad,
double *  lambdaRad,
double *  betaRad 
)

Coordinate Transformation from equatorial to ecliptical.

void StelUtils::debugQVariantMap ( const QVariant &  m,
const QString &  indent = "",
const QString &  key = "" 
)

Output a QVariantMap to qDebug(). Formats like a tree where there are nested objects.

double StelUtils::dmsStrToRad ( const QString &  s  ) 

Convert a dms formatted string to an angle in radian.

Parameters:
s The input string
double StelUtils::dmsToRad ( int  d,
unsigned int  m,
double  s 
)

Convert an angle in +-dms format to radian.

Parameters:
d degree component
m arcmin component
s arcsec component
Returns:
angle in radian
float StelUtils::fastAcos ( float  x  )  [inline]

Compute acos(x) The taylor serie is not accurate around x=1 and x=-1.

Definition at line 254 of file StelUtils.hpp.

float StelUtils::fastExp ( float  x  )  [inline]

Compute exp(x) for small exponents x.

Definition at line 260 of file StelUtils.hpp.

QString StelUtils::getApplicationName (  ) 

Return the full name of stellarium, i.e. "stellarium 0.9.0".

QString StelUtils::getApplicationVersion (  ) 

Return the version of stellarium, i.e. "0.9.0".

void StelUtils::getDateFromJulianDay ( double  julianDay,
int *  year,
int *  month,
int *  day 
)

Make from julianDay a year, month, day for the Julian Date julianDay represents.

bool StelUtils::getDateTimeFromISO8601String ( const QString &  iso8601Date,
int *  y,
int *  m,
int *  d,
int *  h,
int *  min,
float *  s 
)

Parse an ISO8601 date string.

Also handles negative and distant years.

double StelUtils::getDecAngle ( const QString &  str  ) 

Convert a string longitude, latitude, RA or Declination angle to radians.

Parameters:
str the angle in format something like these:

  • +53d 51'21.6" - +53d51'21.6"
  • -1d 10'31.8" - +46d6'31"
  • 50D46'0"N - 123D47'59"W
  • 123.567 N
  • 123.567W
  • -123.567
  • 12h 14m 6s The degree separator may be a degree symbol (\xBA) in addition to a 'd' or 'D'.
Returns:
the angle in radians. Latitude: North are positive, South are negative. Longitude: East is positive, West is negative. Note: if there is a N, S, E or W suffix, any leading + or - characters are ignored.
double StelUtils::getDeltaT ( double  jDay  ) 

Get Delta-T estimation for a given date.

Note that this method is valid for the year range: -1999 to +3000, outside of which "0" will be returned.

Parameters:
jDay the date and time expressed as a julian day
Returns:
Delta-T in seconds
float StelUtils::getGMTShiftFromQT ( double  jd  ) 

Return number of hours offset from GMT, using Qt functions.

double StelUtils::getJDFromSystem (  ) 

Get the current Julian Date from system time.

Returns:
the current Julian Date
double StelUtils::getJulianDayFromISO8601String ( const QString &  iso8601Date,
bool *  ok 
)

Return the Julian Date matching the ISO8601 date string.

Also handles negative and distant years.

double StelUtils::getMoonSecularAcceleration ( double  jDay  ) 

Get Secular Acceleration estimation for a given year.

Parameters:
jDay the JD
Returns:
SecularAcceleration in seconds
Vec3f StelUtils::getNightColor ( const Vec3f dayColor  )  [inline]

Get a night mode version of a color.

That is find the brightness of a color and set that in the red channel only

Definition at line 269 of file StelUtils.hpp.

void StelUtils::getTimeFromJulianDay ( double  julianDay,
int *  hour,
int *  minute,
int *  second 
)

Make from julianDay an hour, minute, second.

double StelUtils::hmsToRad ( unsigned int  h,
unsigned int  m,
double  s 
)

Convert an angle in hms format to radian.

Parameters:
h hour component
m minute component
s second component
Returns:
angle in radian
Vec3f StelUtils::htmlColorToVec3f ( const QString &  c  ) 

Converts a color in HTML notation to a Vec3f.

Parameters:
c The HTML spec color string
bool StelUtils::isPowerOfTwo ( int  value  ) 

Check if a number is a power of 2.

QTime StelUtils::jdFractionToQTime ( double  jd  ) 

Convert a fraction of a Julian Day to a QTime.

QDateTime StelUtils::jdToQDateTime ( const double &  jd  ) 

Convert a julian day to a QDateTime.

Parameters:
jd to convert
Returns:
the matching UTC QDateTime
QString StelUtils::julianDayToISO8601String ( double  jd  ) 

Format the given Julian Day in (UTC) ISO8601 date string.

Also handles negative and distant years.

QString StelUtils::localeDateString ( int  year,
int  month,
int  day,
int  dayOfWeek 
)

Format the date and day-of-week per the system locale's QLocale::ShortFormat.

Returns:
QString representing the formatted date
QString StelUtils::localeDateString ( int  year,
int  month,
int  day,
int  dayOfWeek,
QString  fmt 
)

Format the date and day-of-week per the format in fmt (see QDateTime::toString()).

Uses the system locale, not the one set in Stellarium.

Returns:
QString representing the formatted date
double StelUtils::qDateTimeToJd ( const QDateTime &  dateTime  ) 

Convert a QT QDateTime class to julian day.

Parameters:
dateTime the UTC QDateTime to convert
Returns:
the matching decimal Julian Day
double StelUtils::qTimeToJDFraction ( const QTime &  time  ) 

Convert a time of day to the fraction of a Julian Day.

Note that a Julian Day starts at 12:00, not 0:00, and so 12:00 == 0.0 and 0:00 == 0.5

void StelUtils::radToDms ( double  rad,
bool &  sign,
unsigned int &  d,
unsigned int &  m,
double &  s 
)

Convert an angle in radian to +-dms format.

Parameters:
rad input angle in radian
sign true if positive, false otherwise
d degree component
m minute component
s second component
QString StelUtils::radToDmsStr ( double  angle,
bool  decimal = false,
bool  useD = false 
)

Convert an angle in radian to a dms formatted string.

Parameters:
angle input angle in radian
useD Define if letter "d" must be used instead of deg sign
decimal output decimal second value
QString StelUtils::radToDmsStrAdapt ( double  angle,
bool  useD = false 
)

Convert an angle in radian to a dms formatted string.

If the second, minute part is == 0, it is not output

Parameters:
angle input angle in radian
useD Define if letter "d" must be used instead of deg sign
void StelUtils::radToHms ( double  rad,
unsigned int &  h,
unsigned int &  m,
double &  s 
)

Convert an angle in radian to hms format.

Parameters:
rad input angle in radian
h hour component
m minute component
s second component
QString StelUtils::radToHmsStr ( double  angle,
bool  decimal = false 
)

Convert an angle in radian to a hms formatted string.

Parameters:
angle input angle in radian
decimal output decimal second value
QString StelUtils::radToHmsStrAdapt ( double  angle  ) 

Convert an angle in radian to a hms formatted string.

If the second, minute part is == 0, it is not output

Parameters:
angle input angle in radian
void StelUtils::rectToSphe ( float *  lng,
float *  lat,
const Vec3d v 
)

Convert from spherical coordinates to Rectangular direction.

Parameters:
lng float* to store longitude in radian
lat float* to store latitude in radian
v the input 3D vector
void StelUtils::rectToSphe ( double *  lng,
double *  lat,
const Vec3d v 
)

Convert from spherical coordinates to Rectangular direction.

Parameters:
lng double* to store longitude in radian
lat double* to store latitude in radian
v the input 3D vector
long double StelUtils::secondsSinceStart (  ) 

Get the number of seconds since program start.

Note:
This is implemented in platform-specific ways to be as precise as possible, but there is a fallback for other platforms that might not be precise at all. This is currently used e.g. to measure FPS, but it should never be used for critical functionality.
int StelUtils::smallestPowerOfTwoGreaterOrEqualTo ( int  value  ) 

Return the first power of two greater or equal to the given value.

QSize StelUtils::smallestPowerOfTwoSizeGreaterOrEqualTo ( const QSize  base  ) 

Return the smallest size with power-of two dimensions at least as large as given size.

void StelUtils::spheToRect ( float  lng,
float  lat,
Vec3f v 
)

Convert from spherical coordinates to Rectangular direction.

Parameters:
lng longitude in radian
lat latitude in radian
v the resulting 3D unti vector
void StelUtils::spheToRect ( double  lng,
double  lat,
Vec3d v 
)

Convert from spherical coordinates to Rectangular direction.

Parameters:
lng longitude in radian
lat latitude in radian
v the resulting 3D unit vector
Vec3f StelUtils::strToVec3f ( const QStringList &  s  ) 

Obtains a Vec3f from a string.

Parameters:
s the string describing the Vector with the form "x,y,z"
Returns:
The corresponding vector
Deprecated:
Use the >> operator from Vec3f class
QString StelUtils::vec3fToHtmlColor ( const Vec3f v  ) 

Converts a Vec3f to HTML color notation.

Parameters:
v The vector
Returns:
The string in HTML color notation "#rrggbb".
Generated on Thu Jan 31 14:05:47 2013 for Stellarium by  doxygen 1.6.3