Friday, May 12, 2017

Trilinear interpolation

Interpolate a value between eight values, typically corners of a cube. Lerp
Usage:

my_value=trilinear_lerp( 9,12,3,34, 25,16,7,18, 0.1,0.6,0.5 );

function trilinear_lerp(
V000,V100,V010,V001,
V101,V011,V110,V111,
bias_x,bias_y,bias_z)=
lerp(
    lerp(
        lerp(V000,V001,bias_z),
        lerp(V010,V011,bias_z),
    bias_y
    ),
    lerp(
        lerp(V100,V101,bias_z),
        lerp(V110,V111,bias_z),
    bias_y
    )
    ,bias_x
);
function lerp(start, end, bias) = (end * bias + start * (1 - bias));

d

No comments:

Post a Comment