Trilinear interpolation is a method of multivariate interpolation on a 3-dimensional regular grid. It approximates the value of a function at an intermediate point
within the local axial rectangular prism linearly, using function data on the lattice points.
Trilinear interpolation is frequently used in numerical analysis, data analysis, and computer graphics.
Trilinear interpolation is the extension of linear interpolation, which operates in spaces with dimension
, and bilinear interpolation, which operates with dimension
, to dimension
. These interpolation schemes all use polynomials of order 1, giving an accuracy of order 2, and it requires
adjacent pre-defined values surrounding the interpolation point. There are several ways to arrive at trilinear interpolation, which 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.
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.
On a periodic and cubic lattice, let
,
, and
be the differences between each of
,
,
and the smaller coordinate related, that is:

where
indicates the lattice point below
, and
indicates the lattice point above
and similarly for
and
.
First one interpolates along
(imagine one is "pushing" the face of the cube defined by
to the opposing face, defined by
), giving:

Where
means the function value of
Then one interpolates these values (along
, "pushing" from
to
), giving:

Finally one interpolates these values along
(walking through a line):

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
, then along
, and finally along
, produces the same value.
Algorithm visualization
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
,
,
,
,
,
,
,
.
Next, we perform linear interpolation between
and
to find
,
and
to find
,
and
to find
,
and
to find
.
Now we do interpolation between
and
to find
,
and
to find
. Finally, we calculate the value
via linear interpolation of
and
In practice, a trilinear interpolation is identical to two bilinear interpolation combined with a linear interpolation:

Alternative algorithm
An alternative way to write the solution to the interpolation problem is

where the coefficients are found by solving the linear system

yielding the result
![{\displaystyle {\begin{aligned}a_{0}={}&{\frac {-c_{000}x_{1}y_{1}z_{1}+c_{001}x_{1}y_{1}z_{0}+c_{010}x_{1}y_{0}z_{1}-c_{011}x_{1}y_{0}z_{0}}{(x_{0}-x_{1})(y_{0}-y_{1})(z_{0}-z_{1})}}+{}\\&{\frac {c_{100}x_{0}y_{1}z_{1}-c_{101}x_{0}y_{1}z_{0}-c_{110}x_{0}y_{0}z_{1}+c_{111}x_{0}y_{0}z_{0}}{(x_{0}-x_{1})(y_{0}-y_{1})(z_{0}-z_{1})}},\\[4pt]a_{1}={}&{\frac {c_{000}y_{1}z_{1}-c_{001}y_{1}z_{0}-c_{010}y_{0}z_{1}+c_{011}y_{0}z_{0}}{(x_{0}-x_{1})(y_{0}-y_{1})(z_{0}-z_{1})}}+{}\\&{\frac {-c_{100}y_{1}z_{1}+c_{101}y_{1}z_{0}+c_{110}y_{0}z_{1}-c_{111}y_{0}z_{0}}{(x_{0}-x_{1})(y_{0}-y_{1})(z_{0}-z_{1})}},\\[4pt]a_{2}={}&{\frac {c_{000}x_{1}z_{1}-c_{001}x_{1}z_{0}-c_{010}x_{1}z_{1}+c_{011}x_{1}z_{0}}{(x_{0}-x_{1})(y_{0}-y_{1})(z_{0}-z_{1})}}+{}\\&{\frac {-c_{100}x_{0}z_{1}+c_{101}x_{0}z_{0}+c_{110}x_{0}z_{1}-c_{111}x_{0}z_{0}}{(x_{0}-x_{1})(y_{0}-y_{1})(z_{0}-z_{1})}},\\[4pt]a_{3}={}&{\frac {c_{000}x_{1}y_{1}-c_{001}x_{1}y_{1}-c_{010}x_{1}y_{0}+c_{011}x_{1}y_{0}}{(x_{0}-x_{1})(y_{0}-y_{1})(z_{0}-z_{1})}}+{}\\&{\frac {-c_{100}x_{0}y_{1}+c_{101}x_{0}y_{1}+c_{110}x_{0}y_{0}-c_{111}x_{0}y_{0}}{(x_{0}-x_{1})(y_{0}-y_{1})(z_{0}-z_{1})}},\\[4pt]a_{4}={}&{\frac {-c_{000}z_{1}+c_{001}z_{0}+c_{010}z_{1}-c_{011}z_{0}+c_{100}z_{1}-c_{101}z_{0}-c_{110}z_{1}+c_{111}z_{0}}{(x_{0}-x_{1})(y_{0}-y_{1})(z_{0}-z_{1})}},\\[4pt]a_{5}=&{\frac {-c_{000}y_{1}+c_{001}y_{1}+c_{010}y_{0}-c_{011}y_{0}+c_{100}y_{1}-c_{101}y_{1}-c_{110}y_{0}+c_{111}y_{0}}{(x_{0}-x_{1})(y_{0}-y_{1})(z_{0}-z_{1})}},\\[4pt]a_{6}={}&{\frac {-c_{000}x_{1}+c_{001}x_{1}+c_{010}x_{1}-c_{011}x_{1}+c_{100}x_{0}-c_{101}x_{0}-c_{110}x_{0}+c_{111}x_{0}}{(x_{0}-x_{1})(y_{0}-y_{1})(z_{0}-z_{1})}},\\[4pt]a_{7}={}&{\frac {c_{000}-c_{001}-c_{010}+c_{011}-c_{100}+c_{101}+c_{110}-c_{111}}{(x_{0}-x_{1})(y_{0}-y_{1})(z_{0}-z_{1})}}.\end{aligned}}}](./2017eb73468e519de26c930bdde4137584100afb.svg)
See also
External links
- pseudo-code from NASA, describes an iterative inverse trilinear interpolation (given the vertices and the value of C find Xd, Yd and Zd).
- Paul Bourke, Interpolation methods, 1999. Contains a very clever and simple method to find trilinear interpolation that is based on binary logic and can be extended to any dimension (Tetralinear, Pentalinear, ...).
- Kenwright, Free-Form Tetrahedron Deformation. International Symposium on Visual Computing. Springer International Publishing, 2015 [1].