数据大小用云图表示的具体算法
有一批数据,0 <= x <= 1,用RGB表示其大小,最大值1用红色(1,0,0)表示,最小值0用蓝色(0,0,1)表示,中间值0.5用绿色(0,1,0)表示,如何线性得到象0.3, 0.79这些数据的颜色值?
附图片一幅,见
http://www.cfluid.com/bbs/viewthread.php?tid=111498&extra=page%3D1&frombbs=1
[解决办法]
water
int color( double v, double *r, double *g, double *b ) { const double t = 2 * v - 1; if ( !( r & g & b ) || v<0 || v>1 ) return -1; *r = t >= 0 ? 0 : -t; *g = t > 0 ? 1 - t : 1 + t; *b = t <= 0 ? 0 : t; return 0;}
[解决办法]
water output:
0.00 -> (1.00,0.00,0.00)0.10 -> (0.80,0.20,0.00)0.20 -> (0.60,0.40,0.00)0.30 -> (0.40,0.60,0.00)0.40 -> (0.20,0.80,0.00)0.50 -> (0.00,1.00,0.00)0.60 -> (0.00,0.80,0.20)0.70 -> (0.00,0.60,0.40)0.80 -> (0.00,0.40,0.60)0.90 -> (0.00,0.20,0.80)1.00 -> (0.00,0.00,1.00)
[解决办法]
draw a graph on your paper or in excel
e.g.
linear-color-graph.xlsx