Say I have an array of 5x5. If I know the following points [1,1] = 40, [1,3] = 50, [3,1] = 60, [3,3] = 70, how do I calculate each unknown point in the array? Basically I'm doing an algorithm for a gradient map, of say, temperatures on a map开发者_如何学C.
Thanks
I'll lay out the algorithm for you in pseudo code to find the weight of any point 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
Let me know if anything is unclear.
EDIT: This assumes linear interpolation in between points.
精彩评论