19 Solar(
float prmLatitude,
float prmLongitude,
float prmAltitudeFeet,
float prmZenithDegrees)
27 float calculateSunrise(
int year,
int month,
int day,
int localOffset,
int daylightSavings)
const 34 float N1 = floor(275.0f * month / 9.0f);
35 float N2 = floor((month + 9.0f) / 12.0f);
36 float N3 = 1.0f + floor((year - 4.0f * floor(year / 4.0f) + 2.0f) / 3.0f);
37 float N = N1 - (N2 * N3) + day - 30.0f;
40 float lngHour =
lng / 15.0f;
41 float t = N + ((6.0f - lngHour) / 24.0f);
44 float M = (0.9856f * t) - 3.289f;
47 float L = fmod(M + (1.916f * sin((
PI / 180.0f)*M)) + (0.020f * sin(2.0f * (
PI / 180.0f) * M)) + 282.634f, 360.0f);
50 float RA = fmod(180.0f /
PI*atan(0.91764f * tan((
PI / 180.0f)*L)), 360.0f);
53 float Lquadrant = floor(L / 90.0f) * 90.0f;
54 float RAquadrant = floor(RA / 90.0f) * 90.0f;
55 RA = RA + (Lquadrant - RAquadrant);
61 float sinDec = 0.39782f * sin((
PI / 180.0f)*L);
62 float cosDec = cos(asin(sinDec));
65 float altAdj = 1.15f * sqrtf(
ALTITUDE) / 60.0f;
66 float cosH = (cos((
PI / 180.0f)*(
ZENITH + altAdj)) - (sinDec * sin((
PI / 180.0f)*
lat))) / (cosDec * cos((
PI / 180.0f)*
lat));
69 assert(cosH <= 1.0f && cosH >= -1.0f);
72 float H = 360.0f - (180.0f /
PI)*acos(cosH);
76 float T = H + RA - (0.06571f * t) - 6.622f;
79 float UT = T - lngHour;
82 float LT = UT + localOffset + daylightSavings;
83 if (LT < 0.0f) LT += 24.0f;
84 if (LT >= 24.0f) LT -= 24.0f;
88 float calculateSunset(
int year,
int month,
int day,
int localOffset,
int daylightSavings)
const 95 float N1 = floor(275.0f * month / 9.0f);
96 float N2 = floor((month + 9.0f) / 12.0f);
97 float N3 = (1.0f + floor((year - 4.0f * floor(year / 4.0f) + 2.0f) / 3.0f));
98 float N = N1 - (N2 * N3) + day - 30.0f;
101 float lngHour =
lng / 15.0f;
102 float t = N + ((18 - lngHour) / 24.0f);
105 float M = (0.9856f * t) - 3.289f;
108 float L = fmod(M + (1.916f * sin((
PI / 180.0f)*M)) + (0.020f * sin(2.0f * (
PI / 180.0f) * M)) + 282.634f, 360.0f);
111 float RA = fmod(180.0f /
PI*atan(0.91764f * tan((
PI / 180.0f)*L)), 360.0f);
114 float Lquadrant = floor(L / 90.0f) * 90.0f;
115 float RAquadrant = floor(RA / 90.0f) * 90.0f;
116 RA = RA + (Lquadrant - RAquadrant);
122 float sinDec = 0.39782f * sin(
PI / 180.0f*L);
123 float cosDec = cos(asin(sinDec));
126 float altAdj = 1.15f * sqrtf(
ALTITUDE) / 60.0f;
127 float cosH = (cos(
PI / 180.0f*(
ZENITH + altAdj)) - (sinDec * sin(
PI / 180.0f*
lat))) / (cosDec * cos(
PI / 180.0f*
lat));
130 assert(cosH <= 1.0f && cosH >= -1.0f);
133 float H = (180.0f /
PI)*acos(cosH);
137 float T = H + RA - (0.06571f * t) - 6.622f;
140 float UT = T - lngHour;
143 float LT = UT + localOffset + daylightSavings;
144 if (LT < 0.0f) LT += 24.0f;
145 if (LT >= 24.0f) LT -= 24.0f;
float calculateSunrise(int year, int month, int day, int localOffset, int daylightSavings) const
float calculateSunset(int year, int month, int day, int localOffset, int daylightSavings) const
Solar(float prmLatitude, float prmLongitude, float prmAltitudeFeet, float prmZenithDegrees)