风力图样式是这样的:
?
我用的海流的数据,绘制海流的流线,但我的数据是海流的U分量和V分量,做了UV转RG的转换,B为0,?代码如下:
void UV2RG(float fU, float fV, int &nR, int &nG)
{
double dPI = 3.1415926;
//流向
float direction = (float)((((float)atan2(fU, fV)) * 180 / dPI));
if (direction < 0)
direction = 360 + direction;
if (direction >= 0.0f && direction < 45.0f)
{
nR = 127 + 127 * (direction / (45 - 0));
nG = 255;
}
else if (direction >= 45.0f && direction < 135.0f)
{
nR = 255;
nG = 255 - 255 * ((direction-45) / (135 - 45));
}
else if (direction >= 135.0f && direction < 225.0f)
{
nR = 255 - 255 * ((direction - 135) / (225 - 135));
nG = 0;
}
else if (direction >= 225.0f && direction < 315.0f)
{
nR = 0;
nG = 0 + 255 * ((direction - 225) / (315 - 225));
}
else if (direction >= 315.0f && direction < 360.0f)
{
nR = 127 * ((direction - 315) / (360 - 315));
nG = 255;
}
}
最终绘制出图片效果如下:
?
|