123 {
126 float dayLight = approxSunset - approxSunrise;
127 float nightTime = 24.0 - dayLight;
128 int tempArrayIndex = Math.Floor(monthday) - 1;
129 int tempArrayIndexToLerp = tempArrayIndex + 1;
130 if ( tempArrayIndexToLerp >= 12 )
131 tempArrayIndexToLerp = 0;
132 float tempArrayLerp = monthday - Math.Floor(monthday);
134 float minTempB =
m_MinTemps[tempArrayIndexToLerp];
136 float maxTempB =
m_MaxTemps[tempArrayIndexToLerp];
137 float eveningMinA = minTempA + ( 0.5 * Math.AbsFloat( minTempA - maxTempA ) );
138 float eveningMinB = minTempB + ( 0.5 * Math.AbsFloat( minTempB - maxTempB ) );
139
140 if ( ( daytime >= approxSunrise ) && ( daytime <= approxSunset ) ) {
141 if ( daytime <= ( approxSunrise + ( dayLight * 0.75 ) ) )
142 return Math.Lerp(
143 Math.Lerp( minTempA, minTempB, tempArrayLerp ),
144 Math.Lerp( maxTempA, maxTempB, tempArrayLerp ),
145 ( ( daytime - approxSunrise ) / ( dayLight * 0.75 ) ) );
146 else
147 return Math.Lerp(
148 Math.Lerp( maxTempA, maxTempB, tempArrayLerp ),
149 Math.Lerp( eveningMinA, eveningMinB, tempArrayLerp ),
150 ( ( ( daytime - approxSunrise ) - ( dayLight * 0.75 ) ) / ( dayLight - ( dayLight * 0.75 ) ) ) );
151 } else {
152 if ( ( daytime > approxSunset ) && ( daytime < 24 ) )
153 return Math.Lerp(
154 Math.Lerp( eveningMinA, eveningMinB, tempArrayLerp ),
155 Math.Lerp( minTempA, minTempB, tempArrayLerp ),
156 ( ( daytime - approxSunset ) / ( 24 - approxSunset ) ) / 2.0 );
157 else
158 return Math.Lerp(
159 Math.Lerp( eveningMinA, eveningMinB, tempArrayLerp ),
160 Math.Lerp( minTempA, minTempB, tempArrayLerp ),
161 ( ( ( daytime + ( 24 - approxSunset ) ) / nightTime ) / 2.0 ) + 0.5 );
162 }
163 }
float GetApproxSunriseTime(float monthday)
float GetApproxSunsetTime(float monthday)