diff --git a/src/lib.rs b/src/lib.rs index 17dfd50..174f25d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,8 +22,18 @@ impl Temperature { fn to_fahrenheit(&self) -> f32 { self.celsius * 1.8 + 32.0 } + + fn windchill(&self, wind_speed_kph: f32) -> f32 { + // From https://www.weather.gov/media/epz/wxcalc/windChill.pdf + // And https://www.calcunation.com/calculator/wind-chill-celsius.php + 13.12 + (0.6215 * self.celsius) - (11.37 * wind_speed_kph.powf(0.16)) + + (0.3965 * self.celsius * wind_speed_kph.powf(0.16)) + } } +// Refer to: https://www.weather.gov/epz/wxcalc_windchill +// TODO: Add a test that -20 C and 32 kph feels like -32.9 + #[pyfunction] fn batch_converter(temperatures: Vec) -> Vec { temperatures