0.3.0 => https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml previous https://en.wikipedia.org/wiki/Heat_index TF = temp in Fahrenheit RH = relative humidity in %
| 79 | // TF = temp in Fahrenheit |
| 80 | // RH = relative humidity in % |
| 81 | float heatIndex(float TF, float RH) |
| 82 | { |
| 83 | // Steadman's formula |
| 84 | // float HI = 0.5 * (TF + 61.0 + ((TF - 68.0) * 1.2) + (RH * 0.094)); |
| 85 | // optimized to: |
| 86 | float HI = TF * 1.1 - 10.3 + RH * 0.047; |
| 87 | |
| 88 | |
| 89 | // Rothfusz regression |
| 90 | if (HI >= 80) |
| 91 | { |
| 92 | const float c1 = -42.379; |
| 93 | const float c2 = 2.04901523; |
| 94 | const float c3 = 10.14333127; |
| 95 | const float c4 = -0.22475541; |
| 96 | const float c5 = -0.00683783; |
| 97 | const float c6 = -0.05481717; |
| 98 | const float c7 = 0.00122874; |
| 99 | const float c8 = 0.00085282; |
| 100 | const float c9 = -0.00000199; |
| 101 | |
| 102 | float A = (( c5 * TF) + c2) * TF + c1; |
| 103 | float B = (((c7 * TF) + c4) * TF + c3) * RH; |
| 104 | float C = (((c9 * TF) + c8) * TF + c6) * RH * RH; |
| 105 | |
| 106 | HI = A + B + C; |
| 107 | if ((RH < 13) && (TF <= 112)) |
| 108 | { |
| 109 | HI -= ((13 - RH) / 4) * sqrt((17 - abs(TF - 95.0)) / 17); |
| 110 | } |
| 111 | if ((RH > 87) && (TF < 87)) |
| 112 | { |
| 113 | HI += ((RH - 85) / 10) * ((87 - TF) / 5); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | return HI; |
| 118 | } |
| 119 | |
| 120 | |
| 121 | // 0.3.0 => https://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml |