# Trilinear interpolation

Jump to navigation Jump to search

Trilinear interpolation is a method of multivariate interpolation on a 3-dimensional regular grid. It approximates the value of an intermediate point ${\displaystyle (x,y,z)}$ within the local axial rectangular prism linearly, using data on the lattice points. For an arbitrary, unstructured mesh (as used in finite element analysis), other methods of interpolation must be used; if all the mesh elements are tetrahedra (3D simplices), then barycentric coordinates provide a straightforward procedure.

Trilinear interpolation is frequently used in numerical analysis, data analysis, and computer graphics.

## Compared to linear and bilinear interpolation

Trilinear interpolation is the extension of linear interpolation, which operates in spaces with dimension ${\displaystyle D=1}$, and bilinear interpolation, which operates with dimension ${\displaystyle D=2}$, to dimension ${\displaystyle D=3}$. The order of accuracy is 1 for all these interpolation schemes, and it requires ${\displaystyle (1+n)^{D}=8}$ adjacent pre-defined values surrounding the interpolation point. There are several ways to arrive at trilinear interpolation, it is equivalent to 3-dimensional tensor B-spline interpolation of order 1, and the trilinear interpolation operator is also a tensor product of 3 linear interpolation operators.

## Method

Eight corner points on a cube surrounding the interpolation point C
Depiction of 3D interpolation
A geometric visualisation of trilinear interpolation. The product of the value at the desired point and the entire volume is equal to the sum of the products of the value at each corner and the partial volume diagonaly opposite the corner.

On a periodic and cubic lattice, let ${\displaystyle x_{d}}$, ${\displaystyle y_{d}}$, and ${\displaystyle z_{d}}$ be the differences between each of ${\displaystyle x}$, ${\displaystyle y}$, ${\displaystyle z}$ and the smaller coordinate related, that is:

${\displaystyle \ x_{d}=(x-x_{0})/(x_{1}-x_{0})}$
${\displaystyle \ y_{d}=(y-y_{0})/(y_{1}-y_{0})}$
${\displaystyle \ z_{d}=(z-z_{0})/(z_{1}-z_{0})}$

where ${\displaystyle x_{0}}$ indicates the lattice point below ${\displaystyle x}$, and ${\displaystyle x_{1}}$ indicates the lattice point above ${\displaystyle x}$ and similarly for ${\displaystyle y_{0},y_{1},z_{0}}$ and ${\displaystyle z_{1}}$.

First we interpolate along ${\displaystyle x}$ (imagine we are pushing the front face of the cube to the back), giving:

${\displaystyle \ c_{00}=V[x_{0},y_{0},z_{0}](1-x_{d})+V[x_{1},y_{0},z_{0}]x_{d}}$
${\displaystyle \ c_{10}=V[x_{0},y_{1},z_{0}](1-x_{d})+V[x_{1},y_{1},z_{0}]x_{d}}$
${\displaystyle \ c_{01}=V[x_{0},y_{0},z_{1}](1-x_{d})+V[x_{1},y_{0},z_{1}]x_{d}}$
${\displaystyle \ c_{11}=V[x_{0},y_{1},z_{1}](1-x_{d})+V[x_{1},y_{1},z_{1}]x_{d}}$

Where ${\displaystyle V[x_{0},y_{0},z_{0}]}$ means the function value of ${\displaystyle (x_{0},y_{0},z_{0}).}$ Then we interpolate these values (along ${\displaystyle y}$, as we were pushing the top edge to the bottom), giving:

${\displaystyle \ c_{0}=c_{00}(1-y_{d})+c_{10}y_{d}}$
${\displaystyle \ c_{1}=c_{01}(1-y_{d})+c_{11}y_{d}}$

Finally we interpolate these values along ${\displaystyle z}$(walking through a line):

${\displaystyle \ c=c_{0}(1-z_{d})+c_{1}z_{d}.}$

This gives us a predicted value for the point.

The result of trilinear interpolation is independent of the order of the interpolation steps along the three axes: any other order, for instance along ${\displaystyle x}$, then along ${\displaystyle y}$, and finally along ${\displaystyle z}$, produces the same value.

The above operations can be visualized as follows: First we find the eight corners of a cube that surround our point of interest. These corners have the values C000, C100, C010, C110, C001, C101, C011, C111.

Next, we perform linear interpolation between C000 and C100 to find C00, C001 and C101 to find C01, C011 and C111 to find C11, C010 and C110 to find C10.

Now we do interpolation between C00 and C10 to find C0, C01 and C11 to find C1. Finally, we calculate the value C via linear interpolation of C0 and C1

In practice, a trilinear interpolation is identical to three successive linear interpolations, or a bilinear interpolation combined with a linear interpolation:

${\displaystyle C\approx \ l(b(C_{000},C_{010},C_{100},C_{110}),b(C_{001},C_{011},C_{101},C_{111}))}$