37const double SAstronomy::PI = 3.1415926535897932384626433832795029L;
42 return value * 180 / PI;
47 return value * PI / 180;
67 double value = fmod(val, 360);
68 if (value <
double(0))
78 double x = cos(lon) * cos(lat);
79 double y = cos(ecl) * sin(lon) * cos(lat) - sin(ecl) * sin(lat);
80 double z = sin(ecl) * sin(lon) * cos(lat) + cos(ecl) * sin(lat);
82 double r = sqrt(x * x + y * y);
89 dist = sqrt (x * x + y * y + z * z);
91 decl =
Atan2Deg(z, sqrt (x * x + y * y));
103 double d = jday - 2451543.5;
104 double w = double(282.9404 + 4.70935E-5 * d);
105 double M = double(356.0470 + 0.9856002585 * d);
111 double UT = double(fmod(d, 1) * 360);
112 double hourAngle = longitude + L + double(180) + UT - rasc;
118 double xhor = x *
SinDeg(latitude) - z *
CosDeg(latitude);
120 double zhor = x *
CosDeg(latitude) + z *
SinDeg(latitude);
122 azimuth =
Atan2Deg(yhor, xhor) + double(180);
123 altitude =
Atan2Deg (zhor, sqrt (xhor * xhor + yhor * yhor));
130 double d = jday - 2451543.5;
134 double w = double(282.9404 + 4.70935E-5 * d);
136 double e = 0.016709 - 1.151E-9 * d;
138 double M = double(356.0470 + 0.9856002585 * d);
146 double xv =
CosDeg(E) - e;
147 double yv =
SinDeg(E) * sqrt(1 - e * e);
153 double sunlon, sunlat = 0;
165 sunRightAscension =
RadToDeg(sunRightAscension);
166 sunDeclinaison =
RadToDeg(sunDeclinaison);
172 double sunRightAscension, sunDeclinaison;
181 azimuth = Ogre::Degree(
static_cast<float>(az));
182 altitude = Ogre::Degree(
static_cast<float>(al));
188 double T = (jday - 2451545.0L) / 36525.0L;
189 double lprim = 3.8104L + 8399.7091L * T;
190 double mprim = 2.3554L + 8328.6911L * T;
191 double m = 6.2300L + 648.3019L * T;
192 double d = 5.1985L + 7771.3772L * T;
193 double f = 1.6280L + 8433.4663L * T;
195 + 0.1098L * sin(mprim)
196 + 0.0222L * sin(2.0L * d - mprim)
197 + 0.0115L * sin(2.0L * d)
198 + 0.0037L * sin(2.0L * mprim)
200 - 0.0020L * sin(2.0L * f)
201 + 0.0010L * sin(2.0L * d - 2.0L * mprim)
202 + 0.0010L * sin(2.0L * d - m - mprim)
203 + 0.0009L * sin(2.0L * d + mprim)
204 + 0.0008L * sin(2.0L * d - m)
205 + 0.0007L * sin(mprim - m)
207 - 0.0005L * sin(m + mprim);
209 lat = + 0.0895L * sin(f)
210 + 0.0049L * sin(mprim + f)
211 + 0.0048L * sin(mprim - f)
212 + 0.0030L * sin(2.0L * d - f)
213 + 0.0010L * sin(2.0L * d + f - mprim)
214 + 0.0008 * sin(2.0L * d - f - mprim)
215 + 0.0006L * sin(2.0L * d + f);
221 double lonecl, latecl;
240 azimuth = Ogre::Degree(
static_cast<float>(az));
241 altitude = Ogre::Degree(
static_cast<float>(al));
248 double T = (jday - 2454473.984722L) / 29.531026L;
250 float phaseFloat =
static_cast<float>(fabs(fmod(T, 1)));
251 moonPhase = ((phaseFloat - 0.5f) * 2.0f);
259 int a = (14 - month) / 12;
260 int y = year + 4800 - a;
261 int m = month + 12 * a - 3;
262 return day + (153 * m + 2) / 5 + 365 * y + y / 4 - y / 100 + y / 400 - 32045;
271 double jd = jdn + (hour - 12) / 24.0 + minute / 1440.0 + second / 86400.0;
278 double jd = jdn + secondsFromMidnight / 86400.0 - 0.5;
289 int c = (dg / 36524 + 1) * 3 / 4;
290 int dc = dg - c * 36524;
293 int a = (db / 365 + 1) * 3 / 4;
294 int da = db - a * 365;
295 int y = g * 400 + c * 100 + b * 4 + a;
296 int m = (da * 5 + 308) / 153 - 2;
297 int d = da - (m + 4) * 153 / 5 + 122;
298 year = y - 4800 + (m + 2) / 12;
299 month = (m + 2) % 12 + 1;
308 int ijd =
static_cast<int>(floor(julianDay + 0.5));
311 double s = (julianDay + 0.5 - ijd) * 86400.0;
312 hour =
static_cast<int>(floor(s / 3600));
314 minute =
static_cast<int>(floor(s / 60));
327#if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32) && (OGRE_COMPILER == OGRE_COMPILER_MSVC) && !defined(_WIN64)
330 int oldMode = ::_controlfp (0, 0);
331 ::_controlfp (_PC_64, _MCW_PC);
337 ::_controlfp (oldMode, _MCW_PC);
349 assert(oldMode == 0xC0FFEE);
SCOL_EXPORT int cbmachine w
static void GetEquatorialSunPosition(const double &jday, double &sunRightAscension, double &sunDeclinaison)
static double DegToRad(const double &x)
static int GetJulianDayFromGregorianDate(const int &year, const int &month, const int &day)
static void GetEclipticSunMeanLongitude(const double &jday, double &sunlon)
static void ConvertEclipticToEquatorialRad(const double &lon, const double &lat, double &rasc, double &decl)
static void GetGregorianDateFromJulianDay(const int &julianDay, int &year, int &month, int &day)
static void GetGregorianDateTimeFromJulianDay(const double &julianDay, int &year, int &month, int &day, int &hour, int &minute, double &second)
static int EnterHighPrecissionFloatingPointMode()
static void ConvertEquatorialToHorizontal(const double &jday, const double &longitude, const double &latitude, const double &rasc, const double &decl, double &azimuth, double &altitude)
static void GetEclipticSunPosition(const double &jday, double &lambda, double &beta)
static const double J2000
January 1, 2000, noon.
static double GetJulianDayFromGregorianDateTime(const int &year, const int &month, const int &day, const int &hour, const int &minute, const double &second)
static double Atan2Deg(const double &y, const double &x)
static void GetHorizontalMoonPosition(const double &jday, const double &longitude, const double &latitude, double &azimuth, double &altitude)
static void ConvertSphericalToRectangular(const double &rasc, const double &decl, const double &dist, double &x, double &y, double &z)
static double RadToDeg(const double &x)
static void GetMoonPhase(const double &jday, float &moonPhase)
static void GetHorizontalSunPosition(const double &jday, const double &longitude, const double &latitude, double &azimuth, double &altitude)
static void GetEclipticMoonPositionRad(const double &jday, double &lon, double &lat)
static double CosDeg(const double &x)
static double NormalizeDegrees(const double &x)
static double SinDeg(const double &x)
static void ConvertRectangularToSpherical(const double &x, const double &y, const double &z, double &rasc, double &decl, double &dist)
static void RestoreFloatingPointMode(const int &oldMode)