Sun Program 1
Sun Program 1
#include <iostream>
#include <math.h>
#include <time.h>
using std::cout;
using std::cin;
using std::ios;
using std::endl;
double L,RA,g,daylen,delta,x,y,z;
double SunDia = 0.53; // Sunradius degrees
g = FNrange(M * rads);
// eccentricity
double ecc = 0.016709 - 1.151E-9 * d;
int main(void){
double year,m,day,h,latit,longit;
time_t sekunnit;
struct tm *p;
p=localtime(&sekunnit);
year = p->tm_year;
// this is Y2K compliant method
year+= 1900;
m = p->tm_mon + 1;
day = p->tm_mday;
// clock time just now
h = p->tm_hour + p->tm_min/60.0;
double tzone=1.0;
cout << "Input latitude, longitude and timezone\n";
cin >> latit;
cin >> longit;
cin >> tzone;
// testi
// year = 1990; m=4; day=19; h=11.99; // local time
double UT = h - tzone; // universal time
double jd = FNday(year, m, day, UT);
ha = f0(latit,delta);
noont-= 24*(noont>24);
cout.setf(ios::fixed);
cout.precision(0);
cout << " year : " << year << endl;
cout << " month : " << m << endl;
cout << " day : " << day << "\n\n";
cout << " time : " << ctime(&sekunnit) << endl;
cout << "Days since Y2K : " << jd << '\n';
cout.precision(2);
cout << "Latitude : " << latit << ", longitude: " << longit << endl;
cout << "Timezone : " << tzone << "\n\n";
cout << "Declination : " << delta * degs << '\n';
cout << "Daylength : "; showhrmn(daylen); cout << " hours \n";
cout << "Sunrise : ";
showhrmn(riset); cout << '\n';
cout << "Sun altitude at noontime ";
showhrmn(noont); cout << " = " << altmax << " degrees " << (latit>= delta * degs ?
"(S)" : "(N)") << endl;
cout << "Sunset : ";
showhrmn(settm); cout << '\n';
cout << endl << "SUNPOSITION AT THIS MOMENT" << endl;
cout << "Azimuth= " << azim*degs << " degr \n";
cout << "Altitude= " << altit << " degr \n";
return 0;
}