Documente Academic
Documente Profesional
Documente Cultură
Multi-Linear Interpolation
Rick Wagner
1 Abstract
A standard linear algebra method of interpolation that scales to any dimensionality is described.
2 Description
Given an array (or table) of values for a function of one or more variables, it is often desired to find a value between two given points. If the given function is not linear, then the interpolated value will be an approximation. Computation of error terms for the nonlinear case is covered in standard mathematics texts [1]. If the array has more than two dimensions, the value sought will be at a point within the interior of the corresponding polytope. In the descriptions below, the functions for interpolation are assumed to be sufficiently close to linear.
Page 1
y1 y2
B
(x1, y1)
C
(x2, y2)
y0
A
(x0, y0) y = f(x)
x1 - x0 x2 - x0 x1 - x2
X
x0 x2 x1
Figure 1: Linear interpolation: given points A and B and x2, compute y2, yielding point C.
To interpolate the value (y2) of f at point C (given at x2) we find the slope (m) of the line between points A and B. Then y 2 = y 0 + m (x 2 x0 ) where
m= y1 y 0 x1 x 0
(2)
(3)
(4)
(5)
The segment of the X axis designated by x1 x0 is the projection of segment AB onto the X axis. Dividing by this length in equation (5) normalizes the sum of the projections of Page 2
Beach Cities Robotics FIRST Team 294 segments AC and CB to a unit segment. So equation (5) is saying that the interpolated value, y2, is y0 times the normalized projection of segment CB plus y1 times the normalized projection of segment AC. Note that the normalized segments that serve as factors for the y-values of the vertices A and B are opposite from (not adjacent to) their corresponding vertices. This interpretation of linear interpolation allows us to easily extend it to higher dimensionality.
z = f(x, y)
y1
A
(x0, y1, z0)
Nd = ((x2 - x1)(y1 - y2)) / ((x1 - x0)(y1 - y0)) Nc = ((x1 - x2)(y1 - y2)) / ((x1 - x0)(y1 - y0))
B
(x1, y1, z1)
y2
E
(x2, y2, z4)
y0
C
(x0, y0, z2)
D
(x1, y0, z3)
X
x0 x2 x1
Figure 2: Bilinear interpolation. The rectangle ABCD is partitioned into four areas by the lines x = x2 and y = y2.
The rectangle ABCD is partitioned into four areas by the lines x = x2 and y = y2. To interpolate the value (z4) of f at point E (given at x2 and y2) we first find the normalized areas of the partitions of the rectangle ABCD. The four areas are normalized by dividing them each by the area of rectangle ABCD. Page 3
Beach Cities Robotics FIRST Team 294 The four normalized areas, Na, Nb, Nc, and Nd, each diagonally opposite from its naming rectangle vertex, are given by
Na =
Nb = Nc = Nd
(x1 x2 ) ( y2 y0 ) (x1 x0 ) ( y1 y0 )
(x2 x0 ) ( y 2 y 0 ) (x1 x0 ) ( y1 y 0 )
(7)
(8)
(9)
(10)
z 4 = z 0 N a + z1 N b + z 2 N c + z 3 N d
(11)
v = f(x, y, z)
(12)
and we are given eight points, A, B, C, D, E, F, G, and H defining a right rectangular prism as shown below in Figure 3:
Page 4
v = f(x, y, z)
C
z0 (x2, y2, z2, v8)
B
(x0, y1, z1, v1)
I
(x0, y0, z0, v4)
G
x2 x1
x0
y2 y1
H Y
Figure 3: Trilinear interpolation. The right rectangular prism ABCDEFGH is partitioned into eight volumes by the three orthogonal planes passing through point I.
The prism ABCDEFGH is partitioned into eight volumes by the planes x = x2, y = y2, and z = z2 To interpolate the value (v8) of f at point I (given at x2, y2, and z2) we first find the normalized volumes of the partitions of the prism ABCDEFGH. The eight volumes are normalized by dividing them each by the volume of prism ABCDEFGH. The eight normalized volumes Na, Nb, Nc, Nd Ne, Nf, Ng, and Nh, each diagonally opposite from its naming prism vertex, are given by
(13) (14)
(x2 x0 ) ( y1 y2 ) (z2 z0 ) (x1 x0 ) ( y1 y0 ) (z1 z0 ) (x x0 ) ( y2 y0 ) (z2 z0 ) Nd = 2 (x1 x0 ) ( y1 y0 ) (z1 z0 ) (x x ) ( y1 y2 ) (z1 z2 ) Ne = 1 2 (x1 x0 ) ( y1 y0 ) (z1 z0 ) (x x ) ( y2 y0 ) (z1 z2 ) Nf = 1 2 (x1 x0 ) ( y1 y0 ) (z1 z0 ) (x x0 ) ( y1 y2 ) (z1 z2 ) Ng = 2 (x1 x0 ) ( y1 y0 ) (z1 z0 ) (x x0 ) ( y2 y0 ) (z1 z2 ) Nh = 2 (x1 x0 ) ( y1 y0 ) (z1 z0 )
Nc =
Then z8 is computed by the equation
z8 = z0 N a + z1 N b + z2 N c + z3 N d + z4 N e + z5 N f + z6 N g + z7 N h
(21)
y = f ( x1 , x 2 , K x n )
(22)
and we are given 2n points that are the vertices of a right rectangular polytope. If we are given a point (x12 , x 22 ,K , x n 2 ) in the interior of the polytope, the polytope is divided into 2n partitions by n m-dimensional branes passing through the given interior point where m = n 1. Each partition has a normalized quantity given by
(x11 x12 ) (x21 x 22 ) K (xn1 x n 2 ) (x11 x10 ) (x21 x 20 ) K (x n1 x n0 ) (x x12 ) (x21 x22 ) K (x n 2 x n0 ) N 00K1 = 11 (x11 x10 ) (x21 x20 ) K (x n1 x n0 )
N 00K0 =
(23)
Page 6
(x12 x10 ) (x22 x20 ) K (x n 2 x n0 ) (x11 x10 ) (x21 x20 ) K (x n1 x n0 ) Where point (x10 , x 20 ,K , x n 0 ) is the polytope vertex nearest the origin and point (x11 , x21 ,K, xn1 ) is the vertex farthest from the origin. The y-value of the point in the
N 11K1 =
y = x1 N 1 + x 2 N 2 + K + x n N n
(24)
3 Conclusion
A generic n-dimensional linear interpolation method has been described with specific low-dimensional examples.
4 References
[1] [2] Kreysig, Erwin, Advanced Engineering Mathematics, Third Edition, John Wiley and Sons, Inc., 1972. Safro, Ilya, Resampling Using Bilinear Interpolation, http://www.wisdom.weizmann.ac.il/~maksimf/ex5/Resample.html, 2004. Web page:
Page 7