summaryrefslogtreecommitdiffstats
path: root/Sun.h
blob: 218f7fa628dfb180e9508a55f54bad0849c86c7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef _SUN_H_
#define _SUN_H_

#include <math.h>

class Sun
{
  public:
    Sun(float latitude0): latitude(latitude0){};
    
    float declination(int day) {return 23.4*sin(2*M_PI*(284+day)/365);}
    float hourangle(float time) {return 15*(time-12);}
    float evelationangle(int day, float time) {return asin(sin(declination(day)*M_PI/180)*
                                                           sin(latitude*M_PI/180)*
                                                           cos(hourangle(time)*M_PI/180)*
                                                           cos(declination(day)*M_PI/180)*
                                                           cos(latitude*M_PI/180))
                                                           *180/M_PI;}
  private:
    float latitude;
};

#endif /* _SUN_H_ */