From e6ed1e5dbd41e95190f5015e2c5b2aeaa88e0efb Mon Sep 17 00:00:00 2001 From: ulteq Date: Fri, 15 May 2015 19:00:11 +0200 Subject: [PATCH] Added utility functions to calculate heat index and wind chill --- addons/weather/XEH_preInit.sqf | 2 ++ .../functions/fnc_calculateHeatIndex.sqf | 23 +++++++++++++++++++ .../functions/fnc_calculateWindChill.sqf | 22 ++++++++++++++++++ addons/weather/script_component.hpp | 11 +++++++++ 4 files changed, 58 insertions(+) create mode 100644 addons/weather/functions/fnc_calculateHeatIndex.sqf create mode 100644 addons/weather/functions/fnc_calculateWindChill.sqf diff --git a/addons/weather/XEH_preInit.sqf b/addons/weather/XEH_preInit.sqf index 85166ce356..453c7e57b4 100644 --- a/addons/weather/XEH_preInit.sqf +++ b/addons/weather/XEH_preInit.sqf @@ -5,8 +5,10 @@ ADDON = false; PREP(calculateAirDensity); PREP(calculateBarometricPressure); +PREP(calculateHeatIndex); PREP(calculateRoughnessLength); PREP(calculateTemperatureAtHeight); +PREP(calculateWindChill); PREP(calculateWindSpeed); PREP(displayWindInfo); PREP(getMapData); diff --git a/addons/weather/functions/fnc_calculateHeatIndex.sqf b/addons/weather/functions/fnc_calculateHeatIndex.sqf new file mode 100644 index 0000000000..4515a85a7a --- /dev/null +++ b/addons/weather/functions/fnc_calculateHeatIndex.sqf @@ -0,0 +1,23 @@ +/* + * Author: Ruthberg + * + * Calculates heat index based on temperature and humidity + * + * Arguments: + * 0: temperature - degrees celcius + * 2: relativeHumidity - value between 0.0 and 1.0 + * + * Return Value: + * 0: heat index + * + * Return value: + * None + */ +#include "script_component.hpp" + +PARAMS_2(_t, _rh); + +_rh = _rh * 100; // relative humidity in % + +// Source: https://en.wikipedia.org/wiki/Heat_index +(__C1 + __C2 * _t + __C3 * _rh + __C4 * _t * _rh + __C5 * _t^2 + __C6 * _rh^2 + __C7 * _t^2 * _rh + __C8 * _t * _rh^2 + __C9 * _t^2 * _rh^2) diff --git a/addons/weather/functions/fnc_calculateWindChill.sqf b/addons/weather/functions/fnc_calculateWindChill.sqf new file mode 100644 index 0000000000..0eb63e9701 --- /dev/null +++ b/addons/weather/functions/fnc_calculateWindChill.sqf @@ -0,0 +1,22 @@ +/* + * Author: Ruthberg + * + * Calculates wind chill based on temperature and wind speed + * + * Arguments: + * 0: temperature - degrees celcius + * 2: wind speed - m/s + * + * Return Value: + * 0: wind chill + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_t, _v); + +_v = _v * 3,6; // wind speed in km/h + +// Source: https://en.wikipedia.org/wiki/Wind_chill +(13.12 + 0.06215 * _t - 11.37 * _v ^ 0.16 + 0.3965 * _t * _v^0.16) diff --git a/addons/weather/script_component.hpp b/addons/weather/script_component.hpp index edc1ac64d0..e5a7a74f39 100644 --- a/addons/weather/script_component.hpp +++ b/addons/weather/script_component.hpp @@ -18,3 +18,14 @@ #define WATER_VAPOR_MOLAR_MASS 0.018016 #define DRY_AIR_MOLAR_MASS 0.028964 #define SPECIFIC_GAS_CONSTANT_DRY_AIR 287.058 + +// Heat index coefficients +#define __C1 −8.784695 +#define __C2 1.61139411 +#define __C3 2.338549 +#define __C4 −0.14611605 +#define __C5 −1.2308094 · 10^(−2) +#define __C6 −1.6424828 · 10^(−2) +#define __C7 2.211732 · 10^(−3) +#define __C8 7.2546 · 10^(−4) +#define __C9 −3.582 · 10^(−6)