интерполяция 3 точки

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
A = np.matrix([[0, phi(dist(v0[0] - v1[0], v0[1] - v1[1])), phi(dist(v0[0] - v2[0], v0[1] - v2[1]))], [phi(dist(v0[0] - v1[0], v0[1] - v1[1])), 0, phi(dist(v1[0] - v2[0], v1[1] - v2[1]))], [phi(dist(v0[0] - v2[0], v0[1] - v2[1])), phi(dist(v1[0] - v2[0], v1[1] - v2[1])), 0]])
V = np.matrix([[1, 1, 1], [v0[0], v1[0], v2[0]], [v0[1], v1[1], v2[1]]])
Vt = V.getT()
Zer = np.matrix([[0, 0, 0], [0, 0, 0], [0, 0, 0]])
b = np.matrix([[v0[2]], [v1[2]], [v2[2]], [0], [0], [0]])
M = np.matrix([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]])
#print M
M[0:3, 0:3] = A
M[3:6, 0:3] = V
M[0:3, 3:6] = Vt
M[3:6, 3:6] = Zer
#print M
wv = M.getI()*b
sum = 0.0
sum += wv[0][0]*phi(dist(p[0] - v0[0], p[1] - v0[1]))
sum += wv[1][0]*phi(dist(p[0] - v1[0], p[1] - v1[1]))
sum += wv[2][0]*phi(dist(p[0] - v2[0], p[1] - v2[1]))
sum += wv[3][0]*v0[0]
sum += wv[4][0]*v1[1]*p[0]
sum += wv[5][0]*v2[2]*p[1]