这里以c#为例将风的uv分量转成风向风速(别的语言类似)
风向是以y轴正方向为零度顺时针转
UV转风速风向
1 double v ;//v分量 2 double u;//u分量 3 double fx= 999.9; //风向 4 5 if (u > 0 & v > 0) 6 { 7 fx = 270 - Math.Atan(v / u) * 180 / Math.PI; 8 } 9 else if (u < 0 & v > 0) 10 { 11 fx = 90 - Math.Atan(v / u) * 180 / Math.PI; 12 } 13 else if (u < 0 & v < 0) 14 { 15 fx = 90 - Math.Atan(v / u) * 180 / Math.PI; 16 } 17 else if (u > 0 & v < 0) 18 { 19 fx = 270 - Math.Atan(v / u) * 180 / Math.PI; 20 } 21 else if (u == 0 & v > 0) 22 { 23 fx = 180; 24 } 25 else if (u == 0 & v < 0) 26 { 27 fx = 0; 28 } 29 else if (u > 0 & v == 0) 30 { 31 fx = 270; 32 } 33 else if (u < 0 & v == 0) 34 { 35 fx = 90; 36 } 37 else if (u == 0 & v == 0) 38 { 39 fx = 999.9; 40 } 41 42 //风速是uv分量的平方和 43 44 double fs= Math.Sqrt(Math.Pow(u, 2) + Math.Pow(v, 2));
//通过风速风向 转换为 UV
double fanU = U(FS, FX);
double fanV = V(FS, FX);
private static double U(double dSp, double dWrd)
{
if (dSp < 0)
return 0;
double d0 = 0;
d0 = dSp * Math.Cos((270 - dWrd) * Math.PI / 180);
return d0;
}
private static double V(double dSp, double dWrd)
{
if (dSp < 0)
return 0;
double d0 = 0;
d0 = dSp * Math.Sin((270 - dWrd) * Math.PI / 180);
return d0;
}