Project

General

Profile

SO3Engine
SO3Astronomy.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
25/*
26Taken from Caelum (http://www.ogre3d.org/wiki/index.php/Caelum)
27Planetary position computation from http://stjarnhimlen.se/comp/ppcomp.html#5
28Sunrise/sunset & moonrise/moonset computation from http://stjarnhimlen.se/comp/riset.html
29There's also usefull informations in "A physically-based night sky model" concerning the moon position calculation.
30*/
31
32#ifndef __SO3_ASTRONOMY_H__
33#define __SO3_ASTRONOMY_H__
34
36
37namespace SO3
38{
39
48class _SO3_Export SAstronomy
49{
50public:
51 static const double J2000;
52protected:
53private:
54 static const double PI;
55
56public:
61 static double NormalizeDegrees(const double& x);
62
66 static double RadToDeg(const double& x);
67
71 static double DegToRad(const double& x);
72
75 static double SinDeg(const double& x);
76
79 static double CosDeg(const double& x);
80
83 static double Atan2Deg(const double& y, const double& x);
84
93 static void ConvertEclipticToEquatorialRad(const double& lon, const double& lat, double& rasc, double& decl);
94
97 static void ConvertRectangularToSpherical(const double& x, const double& y, const double& z, double& rasc, double& decl, double& dist);
98
101 static void ConvertSphericalToRectangular(const double& rasc, const double& decl, const double& dist, double& x, double& y, double& z);
102
114 static void ConvertEquatorialToHorizontal(const double& jday, const double& longitude, const double& latitude, const double& rasc, const double& decl, double& azimuth, double& altitude);
115
118 static void GetEclipticSunPosition(const double& jday, double& lambda, double& beta);
119
122 static void GetEquatorialSunPosition(const double& jday, double& sunRightAscension, double& sunDeclinaison);
123
132 static void GetHorizontalSunPosition(const double& jday, const double& longitude, const double& latitude, double& azimuth, double& altitude);
133
136 static void GetHorizontalSunPosition(const double& jday, const Ogre::Degree& longitude, const Ogre::Degree& latitude, Ogre::Degree& azimuth, Ogre::Degree& altitude);
137
143 static void GetEclipticMoonPositionRad(const double& jday, double& lon, double& lat);
144
147 static void GetHorizontalMoonPosition(const double& jday, const double& longitude, const double& latitude, double& azimuth, double& altitude);
148
151 static void GetHorizontalMoonPosition(const double& jday, const Ogre::Degree& longitude, const Ogre::Degree& latitude, Ogre::Degree& azimuth, Ogre::Degree& altitude);
152
156 static void GetMoonPhase(const double& jday, float& moonPhase);
157
163 static int GetJulianDayFromGregorianDate(const int& year, const int& month, const int& day);
164
171 static double GetJulianDayFromGregorianDateTime(const int& year, const int& month, const int& day, const int& hour, const int& minute, const double& second);
172
176 static double GetJulianDayFromGregorianDateTime(const int& year, const int& month, const int& day, const double& secondsFromMidnight);
177
181 static void GetGregorianDateFromJulianDay(const int& julianDay, int& year, int& month, int& day);
182
186 static void GetGregorianDateTimeFromJulianDay(const double& julianDay, int& year, int& month, int& day, int& hour, int& minute, double& second);
187
191 static void GetGregorianDateFromJulianDay(const double& julianDay, int& year, int& month, int& day);
192
203 static int EnterHighPrecissionFloatingPointMode();
204
205 /*
206 Restore old floating point precission.
207 @see EnterHighPrecissionFloatingPointMode.
208 */
209 static void RestoreFloatingPointMode(const int& oldMode);
210
213 static void GetEclipticSunMeanLongitude(const double& jday, double& sunlon);
214protected:
215private:
219 SAstronomy();
220};
221
230{
231public:
232protected:
233private:
234 int mOldFpMode;
235
236public:
243
250protected:
251private:
252};
253
254}
255
256#endif
librairies include
static int EnterHighPrecissionFloatingPointMode()
static const double J2000
January 1, 2000, noon.
static void RestoreFloatingPointMode(const int &oldMode)