什么是风寒公式的程序化表示?

时间:2013-04-12 17:55:44

标签: c++ c weather

我正在尝试以公制来确定风寒。我发现了一些good information from the BBC(它被称为“感觉像温度”),但我无法弄清楚如何将其转换为C代码。

以下是他们的计算信息:

T(wc) = 13.12 + 0.6215T - 11.37V**0.16 + 0.3965TV**0.16

使用这些笔记

  

(其中T(wc)是基于摄氏温标的风寒指数,T是以°C为单位的空气温度,V是以10米(33英尺,标准风速计高度)测量的空气速度,单位为km / h )。

所以我创建了这个,但我得到的输出有时是负面的

float feelslike = 13.12 + 0.6215 * temperature - 11.37 * windSpeed  * 0.16 + 0.3965 * temperature * windSpeed * 0.16;

也许我错过了什么?我假设当它具有“0.6215T”时它意味着“0.6215 * T”,但我不确定如何解释等式中的双“*”。

示例输出:

feelslike 15.126314 temp 19.719999 wind 18.040001
feelslike 15.126314 temp 19.719999 wind 18.040001
feelslike 14.308528 temp 20.070000 wind 20.670000
feelslike 14.308528 temp 20.070000 wind 20.670000
feelslike 12.485908 temp 20.049999 wind 23.930000
feelslike 12.485908 temp 20.049999 wind 23.930000
feelslike 9.340910 temp 19.450001 wind 27.110001
feelslike 9.340910 temp 19.450001 wind 27.110001
feelslike 5.497787 temp 18.330000 wind 28.969999
feelslike 5.497787 temp 18.330000 wind 28.969999
feelslike 2.776235 temp 16.740000 wind 27.400000
feelslike 2.776235 temp 16.740000 wind 27.400000
feelslike 0.058707 temp 14.950000 wind 25.670000
feelslike 0.058707 temp 14.950000 wind 25.670000
feelslike -1.787689 temp 13.130000 wind 23.389999
feelslike -1.787689 temp 13.130000 wind 23.389999
feelslike -1.408279 temp 12.460000 wind 21.650000
feelslike -1.408279 temp 12.460000 wind 21.650000
feelslike -0.960956 temp 11.810000 wind 20.020000
feelslike -0.960956 temp 11.810000 wind 20.020000
feelslike -1.235470 temp 11.550000 wind 19.820000

3 个答案:

答案 0 :(得分:5)

T(wc) = 13.12 + 0.6215T - 11.37V**0.16 + 0.3965TV**0.16

表示:

T(wc) = 13.12 + 0.6215*T - 11.37*pow(V,0.16) + 0.3965*T*pow(V,0.16)

在C / C ++中

答案 1 :(得分:4)

**通常意味着“提升到”的力量。您可以使用pow in math.h。例如:

pow(windSpeed, 0.16)

您的完整计算应该是:

float feelslike = 13.12 + 0.6215 * temperature - 
                  11.37 * pow(windSpeed, 0.16) + 
                  0.3965 * temperature * pow(windSpeed, 0.16);

不要忘记#include <math.h>

答案 2 :(得分:0)

也许我疯了,但是你有没有可以得到负数?它只是意味着感觉它低于冰点?