StelUtils.hpp   StelUtils.hpp 
skipping to change at line 23 skipping to change at line 23
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#ifndef _STELUTILS_HPP_ #ifndef _STELUTILS_HPP_
#define _STELUTILS_HPP_ #define _STELUTILS_HPP_
#include "vecmath.h" #include "VecMath.hpp"
#include "fixx11h.h" #include "fixx11h.h"
#include <QVariantMap>
#include <QDateTime> #include <QDateTime>
#include <QString> #include <QString>
// astonomical unit (km) // astonomical unit (km)
#define AU 149597870.691 #define AU 149597870.691
// Parsec (km)
#define PARSEC 30.857e12
// speed of light (km/sec) // speed of light (km/sec)
#define SPEED_OF_LIGHT 299792.458 #define SPEED_OF_LIGHT 299792.458
//! @namespace StelUtils contains general purpose utility functions.
namespace StelUtils namespace StelUtils
{ {
//! Convert an angle in hms format to radian. //! Convert an angle in hms format to radian.
//! @param h hour component //! @param h hour component
//! @param m minute component //! @param m minute component
//! @param s second component //! @param s second component
//! @return angle in radian //! @return angle in radian
double hmsToRad(unsigned int h, unsigned int m, double s); double hmsToRad(unsigned int h, unsigned int m, double s);
skipping to change at line 69 skipping to change at line 72
//! Convert an angle in radian to +-dms format. //! Convert an angle in radian to +-dms format.
//! @param rad input angle in radian //! @param rad input angle in radian
//! @param sign true if positive, false otherwise //! @param sign true if positive, false otherwise
//! @param d degree component //! @param d degree component
//! @param m minute component //! @param m minute component
//! @param s second component //! @param s second component
void radToDms(double rad, bool& sign, unsigned int& d, unsigned int& m, double& s); void radToDms(double rad, bool& sign, unsigned int& d, unsigned int& m, double& s);
//! Convert an angle in radian to a hms formatted string. //! Convert an angle in radian to a hms formatted string.
//! If the second, minute part is == 0, it is not output //! If the second, minute part is == 0, it is not output
//! @param rad input angle in radian //! @param angle input angle in radian
QString radToHmsStrAdapt(double angle); QString radToHmsStrAdapt(double angle);
//! Convert an angle in radian to a hms formatted string. //! Convert an angle in radian to a hms formatted string.
//! @param rad input angle in radian //! @param angle input angle in radian
//! @param decimal output decimal second value
QString radToHmsStr(double angle, bool decimal=false); QString radToHmsStr(double angle, bool decimal=false);
//! Convert an angle in radian to a dms formatted string. //! Convert an angle in radian to a dms formatted string.
//! If the second, minute part is == 0, it is not output //! If the second, minute part is == 0, it is not output
//! @param rad input angle in radian //! @param angle input angle in radian
//! @param useD Define if letter "d" must be used instead of deg sig n //! @param useD Define if letter "d" must be used instead of deg sig n
QString radToDmsStrAdapt(double angle, bool useD=false); QString radToDmsStrAdapt(double angle, bool useD=false);
//! Convert an angle in radian to a dms formatted string. //! Convert an angle in radian to a dms formatted string.
//! @param rad input angle in radian //! @param angle input angle in radian
//! @param useD Define if letter "d" must be used instead of deg sig n //! @param useD Define if letter "d" must be used instead of deg sig n
//! @param decimal output decimal second value
QString radToDmsStr(double angle, bool decimal=false, bool useD=fals e); QString radToDmsStr(double angle, bool decimal=false, bool useD=fals e);
//! Obtains a Vec3f from a string. //! Obtains a Vec3f from a string.
//! @param s the string describing the Vector with the form "x,y,z" //! @param s the string describing the Vector with the form "x,y,z"
//! @return The corresponding vector //! @return The corresponding vector
//! @deprecated Use the >> operator from Vec3f class //! @deprecated Use the >> operator from Vec3f class
Vec3f strToVec3f(const QStringList& s); Vec3f strToVec3f(const QStringList& s);
Vec3f strToVec3f(const QString& s); Vec3f strToVec3f(const QString& s);
//! Converts a Vec3f to HTML color notation. //! Converts a Vec3f to HTML color notation.
//! @param v The vector //! @param v The vector
//! @return The string in HTML color notation "#rrggbb". //! @return The string in HTML color notation "#rrggbb".
QString vec3fToHtmlColor(const Vec3f& v); QString vec3fToHtmlColor(const Vec3f& v);
//! Converts a color in HTML notation to a Vec3f.
//! @param c The HTML spec color string
Vec3f htmlColorToVec3f(const QString& c);
//! Convert from spherical coordinates to Rectangular direction. //! Convert from spherical coordinates to Rectangular direction.
//! @param lng longitude in radian //! @param lng longitude in radian
//! @param lat latitude in radian //! @param lat latitude in radian
//! @param v the resulting 3D unit vector
void spheToRect(double lng, double lat, Vec3d& v); void spheToRect(double lng, double lat, Vec3d& v);
//! Convert from spherical coordinates to Rectangular direction. //! Convert from spherical coordinates to Rectangular direction.
//! @param lng longitude in radian //! @param lng longitude in radian
//! @param lat latitude in radian //! @param lat latitude in radian
//! @param v the resulting 3D unti vector
void spheToRect(float lng, float lat, Vec3f& v); void spheToRect(float lng, float lat, Vec3f& v);
//! Convert from spherical coordinates to Rectangular direction. //! Convert from spherical coordinates to Rectangular direction.
//! @param lng double* to store longitude in radian //! @param lng double* to store longitude in radian
//! @param lat double* to store latitude in radian //! @param lat double* to store latitude in radian
//! @param v the input 3D vector
void rectToSphe(double *lng, double *lat, const Vec3d& v); void rectToSphe(double *lng, double *lat, const Vec3d& v);
//! Convert from spherical coordinates to Rectangular direction. //! Convert from spherical coordinates to Rectangular direction.
//! @param lng float* to store longitude in radian //! @param lng float* to store longitude in radian
//! @param lat float* to store latitude in radian //! @param lat float* to store latitude in radian
//! @param v the input 3D vector
void rectToSphe(float *lng, float *lat, const Vec3d& v); void rectToSphe(float *lng, float *lat, const Vec3d& v);
//! Convert a string longitude, latitude, RA or Declination angle //! Convert a string longitude, latitude, RA or Declination angle
//! to radians. //! to radians.
//! @param str the angle in format something like these: //! @param str the angle in format something like these:
//! - +53d 51'21.6" //! - +53d 51'21.6"
//! - +53d51'21.6" //! - +53d51'21.6"
//! - -1d 10'31.8" //! - -1d 10'31.8"
//! - +46d6'31" //! - +46d6'31"
//! - 50D46'0"N //! - 50D46'0"N
//! - 123D47'59"W //! - 123D47'59"W
//! - 123.567 N //! - 123.567 N
//! - 123.567W //! - 123.567W
//! - -123.567 //! - -123.567
//! The degree separator may be a degree symbol (\xBA) in addition //! - 12h 14m 6s
//! The degree separator may be a degree symbol (\\xBA) in addition
//! to a 'd' or 'D'. //! to a 'd' or 'D'.
//! @return the angle in radians. //! @return the angle in radians.
//! Latitude: North are positive, South are negative. //! Latitude: North are positive, South are negative.
//! Longitude: East is positive, West is negative. //! Longitude: East is positive, West is negative.
//! Note: if there is a N, S, E or W suffix, any leading + or - //! Note: if there is a N, S, E or W suffix, any leading + or -
//! characters are ignored. //! characters are ignored.
double getDecAngle(const QString& str); double getDecAngle(const QString& str);
//! Check if a number is a power of 2. //! Check if a number is a power of 2.
bool isPowerOfTwo(int value); bool isPowerOfTwo(int value);
skipping to change at line 201 skipping to change at line 215
//! @param jd to convert //! @param jd to convert
//! @result the matching UTC QDateTime //! @result the matching UTC QDateTime
QDateTime jdToQDateTime(const double& jd); QDateTime jdToQDateTime(const double& jd);
bool getJDFromDate(double* newjd, int y, int m, int d, int h, int mi n, int s); bool getJDFromDate(double* newjd, int y, int m, int d, int h, int mi n, int s);
int numberOfDaysInMonthInYear(int month, int year); int numberOfDaysInMonthInYear(int month, int year);
bool changeDateTimeForRollover(int oy, int om, int od, int oh, int o min, int os, bool changeDateTimeForRollover(int oy, int om, int od, int oh, int o min, int os,
int* ry, int* rm, int* rd, int* rh, i nt* rmin, int* rs); int* ry, int* rm, int* rd, int* rh, i nt* rmin, int* rs);
//! Output a QVariantMap to qDebug(). Formats like a tree where the
re are nested objects.
void debugQVariantMap(const QVariant& m, const QString& indent="", c
onst QString& key="");
//! Use RegExp for final to parse a QString to six ints, use in the
event QDateTime cannot handle the date.
QList<int> getIntsFromISO8601String(const QString& iso8601Date);
} }
#endif // _STELUTILS_HPP_ #endif // _STELUTILS_HPP_
 End of changes. 16 change blocks. 
7 lines changed or deleted 29 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/