File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/extensions/ams.js
ALMaSS  1.2 (after EcoStack, March 2024)
The Animal, Landscape and Man Simulation System
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sunset.h
Go to the documentation of this file.
1 /*
2  * Provides the ability to calculate the local time for sunrise,
3  * sunset, and moonrise at any point in time at any location in the world
4  *
5  * Original work used with permission maintaining license
6  * Copyright (GPL) 2004 Mike Chirico mchirico@comcast.net
7  * Modifications copyright
8  * Copyright (GPL) 2015 Peter Buelow
9  *
10  * This file is part of the Sunset library
11  *
12  * Sunset is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * Sunset is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 #ifndef __SUNPOSITION_H__
27 #define __SUNPOSITION_H__
28 
29 #include <cmath>
30 #include <ctime>
31 
32 #ifndef M_PI
33  #define M_PI 3.14159265358979323846264338327950288
34 #endif
35 
66 class SunSet {
67 public:
68  SunSet();
69  SunSet(double, double, int);
70  SunSet(double, double, double);
71  ~SunSet();
72 
73  static constexpr double SUNSET_OFFICIAL = 90.833;
74  static constexpr double SUNSET_NAUTICAL = 102.0;
75  static constexpr double SUNSET_CIVIL = 96.0;
76  static constexpr double SUNSET_ASTONOMICAL = 108.0;
78  void setPosition(double, double, int);
79  void setPosition(double, double, double);
80  void setTZOffset(int);
81  void setTZOffset(double);
82  double setCurrentDate(int, int, int);
83  double calcNauticalSunrise() const;
84  double calcNauticalSunset() const;
85  double calcCivilSunrise() const;
86  double calcCivilSunset() const;
87  double calcAstronomicalSunrise() const;
88  double calcAstronomicalSunset() const;
89  double calcCustomSunrise(double) const;
90  double calcCustomSunset(double) const;
91  [[deprecated("UTC specific calls may not be supported in the future")]] double calcSunriseUTC();
92  [[deprecated("UTC specific calls may not be supported in the future")]] double calcSunsetUTC();
93  double calcSunrise() const;
94  double calcSunset() const;
95  int moonPhase(int) const;
96  int moonPhase() const;
97 
98 private:
99  double degToRad(double) const;
100  double radToDeg(double) const;
101  double calcMeanObliquityOfEcliptic(double) const;
102  double calcGeomMeanLongSun(double) const;
103  double calcObliquityCorrection(double) const;
104  double calcEccentricityEarthOrbit(double) const;
105  double calcGeomMeanAnomalySun(double) const;
106  double calcEquationOfTime(double) const;
107  double calcTimeJulianCent(double) const;
108  double calcSunTrueLong(double) const;
109  double calcSunApparentLong(double) const;
110  double calcSunDeclination(double) const;
111  double calcHourAngleSunrise(double, double, double) const;
112  double calcHourAngleSunset(double, double, double) const;
113  double calcJD(int,int,int) const;
114  double calcJDFromJulianCent(double) const;
115  double calcSunEqOfCenter(double) const;
116  double calcAbsSunrise(double) const;
117  double calcAbsSunset(double) const;
118 
119  double m_latitude;
120  double m_longitude;
121  double m_julianDate;
122  double m_tzOffset;
123  int m_year;
124  int m_month;
125  int m_day;
126 };
127 
128 #endif
SunSet::calcAbsSunset
double calcAbsSunset(double) const
Definition: sunset.cpp:334
M_PI
#define M_PI
Definition: sunset.h:33
SunSet::SunSet
SunSet()
Definition: sunset.cpp:35
SunSet::radToDeg
double radToDeg(double) const
Definition: sunset.cpp:131
sunset.h
SunSet::calcHourAngleSunset
double calcHourAngleSunset(double, double, double) const
Definition: sunset.cpp:237
SunSet::calcEquationOfTime
double calcEquationOfTime(double) const
Definition: sunset.cpp:175
SunSet::calcMeanObliquityOfEcliptic
double calcMeanObliquityOfEcliptic(double) const
Definition: sunset.cpp:136
SunSet::SUNSET_ASTONOMICAL
static constexpr double SUNSET_ASTONOMICAL
Definition: sunset.h:76
SunSet::calcSunDeclination
double calcSunDeclination(double) const
Definition: sunset.cpp:218
SunSet::calcAstronomicalSunset
double calcAstronomicalSunset() const
Definition: sunset.cpp:400
SunSet::calcTimeJulianCent
double calcTimeJulianCent(double) const
Definition: sunset.cpp:194
SunSet::m_month
int m_month
Definition: sunset.h:124
SunSet::calcAstronomicalSunrise
double calcAstronomicalSunrise() const
Definition: sunset.cpp:389
SunSet::calcCivilSunrise
double calcCivilSunrise() const
Definition: sunset.cpp:411
SunSet::m_longitude
double m_longitude
Definition: sunset.h:120
SunSet::m_tzOffset
double m_tzOffset
Definition: sunset.h:122
SunSet::calcCustomSunset
double calcCustomSunset(double) const
Definition: sunset.cpp:492
SunSet::calcSunrise
double calcSunrise() const
Definition: sunset.cpp:455
SunSet::calcNauticalSunset
double calcNauticalSunset() const
Definition: sunset.cpp:444
SunSet::setTZOffset
void setTZOffset(int)
Definition: sunset.cpp:530
SunSet::calcCustomSunrise
double calcCustomSunrise(double) const
Definition: sunset.cpp:479
SunSet::calcEccentricityEarthOrbit
double calcEccentricityEarthOrbit(double) const
Definition: sunset.cpp:163
SunSet::setCurrentDate
double setCurrentDate(int, int, int)
Definition: sunset.cpp:508
SunSet::m_day
int m_day
Definition: sunset.h:125
SunSet::calcCivilSunset
double calcCivilSunset() const
Definition: sunset.cpp:422
SunSet::setPosition
void setPosition(double, double, int)
Definition: sunset.cpp:93
SunSet::m_latitude
double m_latitude
Definition: sunset.h:119
SunSet::calcSunset
double calcSunset() const
Definition: sunset.cpp:466
SunSet::calcSunsetUTC
double calcSunsetUTC()
Definition: sunset.cpp:378
SunSet::calcAbsSunrise
double calcAbsSunrise(double) const
Definition: sunset.cpp:299
SunSet::calcNauticalSunrise
double calcNauticalSunrise() const
Definition: sunset.cpp:433
SunSet::calcJDFromJulianCent
double calcJDFromJulianCent(double) const
Definition: sunset.cpp:268
SunSet::m_julianDate
double m_julianDate
Definition: sunset.h:121
SunSet::calcSunTrueLong
double calcSunTrueLong(double) const
Definition: sunset.cpp:200
SunSet::SUNSET_OFFICIAL
static constexpr double SUNSET_OFFICIAL
Definition: sunset.h:73
SunSet::calcGeomMeanAnomalySun
double calcGeomMeanAnomalySun(double) const
Definition: sunset.cpp:169
SunSet::calcObliquityCorrection
double calcObliquityCorrection(double) const
Definition: sunset.cpp:154
SunSet
Definition: sunset.h:66
SunSet::calcSunApparentLong
double calcSunApparentLong(double) const
Definition: sunset.cpp:209
SunSet::calcSunriseUTC
double calcSunriseUTC()
Definition: sunset.cpp:365
SunSet::SUNSET_NAUTICAL
static constexpr double SUNSET_NAUTICAL
Definition: sunset.h:74
SunSet::calcSunEqOfCenter
double calcSunEqOfCenter(double) const
Definition: sunset.cpp:274
SunSet::degToRad
double degToRad(double) const
Definition: sunset.cpp:126
SunSet::calcGeomMeanLongSun
double calcGeomMeanLongSun(double) const
Definition: sunset.cpp:144
SunSet::calcHourAngleSunrise
double calcHourAngleSunrise(double, double, double) const
Definition: sunset.cpp:228
SunSet::moonPhase
int moonPhase() const
Definition: sunset.cpp:582
SunSet::SUNSET_CIVIL
static constexpr double SUNSET_CIVIL
Definition: sunset.h:75
SunSet::m_year
int m_year
Definition: sunset.h:123
SunSet::~SunSet
~SunSet()
Definition: sunset.cpp:72
SunSet::calcJD
double calcJD(int, int, int) const
Definition: sunset.cpp:255