1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Linear interpolation

  1. Feb 18, 2008 #1
    Hi, I'm implimenting a method presented in


    Part of the way through it it presents a linear interpolation method, which I wanted to expand to three dimensions, but I don't understand how it works in two dimensions.

    I've done linear interpolation before, but this seems very different:

    Code (Text):

    void advect ( int N, int b, float * d, float * d0, float * u, float * v, float dt )
    int i, j, i0, j0, i1, j1;
    float x, y, s0, t0, s1, t1, dt0;
    dt0 = dt*N;
    for ( i=1 ; i<=N ; i++ ) {
    for ( j=1 ; j<=N ; j++ ) {
    x = i-dt0*u[IX(i,j)]; y = j-dt0*v[IX(i,j)];
    if (x<0.5) x=0.5; if (x>N+0.5) x=N+ 0.5; i0=(int)x; i1=i0+1;
    if (y<0.5) y=0.5; if (y>N+0.5) y=N+ 0.5; j0=(int)y; j1=j0+1;
    s1 = x-i0; s0 = 1-s1; t1 = y-j0; t0 = 1-t1;


    d[IX(i,j)] = s0*(t0*d0[IX(i0,j0)]+t1*d 0[IX(i0,j1)])+

    set_bnd ( N, b, d );
    (the part in bold is where the linear interpolation takes place, and I don't get what they're doing).
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you help with the solution or looking for help too?
Draft saved Draft deleted

Similar Discussions: Linear interpolation
  1. Lagrange Interpolation (Replies: 14)

  2. Spline interpolation (Replies: 0)