summaryrefslogtreecommitdiffstats
path: root/Sun.h
diff options
context:
space:
mode:
authorConstantin Riß <constantin.riss@dre.de>2010-01-19 20:06:14 +0100
committerConstantin Riß <constantin.riss@dre.de>2010-01-19 20:06:14 +0100
commitfd3c8843d0acc1d27a9bcaea475ea864508fb64d (patch)
treee236bafe40a26aa5396d8c9dcc03d46b975ddaf3 /Sun.h
parent4de0fc7184f74700b68f92ce2acbd54b39b4fedf (diff)
downloadc3d-fd3c8843d0acc1d27a9bcaea475ea864508fb64d.tar
c3d-fd3c8843d0acc1d27a9bcaea475ea864508fb64d.zip
.....
Diffstat (limited to 'Sun.h')
-rw-r--r--Sun.h26
1 files changed, 20 insertions, 6 deletions
diff --git a/Sun.h b/Sun.h
index 218f7fa..e2191c9 100644
--- a/Sun.h
+++ b/Sun.h
@@ -10,12 +10,26 @@ class Sun
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;}
+ 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;
+ }
+ float azimutangle(int day, float time){
+ float tau, sin_tau, cos_tau, sin_phi, cos_phi, tan_dec;
+
+ tau = hourangle(time)*M_PI/180;
+ sin_tau = sin(tau);
+ cos_tau = cos(tau);
+ sin_phi = sin(latitude*M_PI/180);
+ cos_phi = cos(latitude*M_PI/180);
+ tan_dec = tan(declination(day)*M_PI/180);
+
+ return atan2(sin_tau, cos_tau*sin_phi-tan_dec*cos_phi)/180*M_PI;
+ }
private:
float latitude;
};