假设我有一个5x5的数组。如果我知道以下几点[1,1] = 40,[1,3] = 50,[3,1] = 60,[3,3] = 70,我如何计算阵列中的每个未知点?基本上我正在做一个渐变映射的算法,比如地图上的温度。
由于
答案 0 :(得分:1)
我将在伪代码中为您列出算法,以找到任何点的权重p
Find the two point p1 and p2 that are on the "left" and "right" of p
distance = distance(p1, p2)
distance_p1 = distance(p, p1)
weight_diff = p1.weight - p2.weight
weight_p = p1.weight + (distance_p1 / distance) * weight_diff
如果有什么不清楚,请告诉我。
编辑:这假定在点之间进行线性插值。