View Full Version : hcrisp

10-27-2008, 12:50 PM
Here's another puzzler.

I have a mxn array representing elevation data. To make it simple:

WAVE> m = [10.,20.,30.]
WAVE> n = [20.,30.,40.]
WAVE> elev = [[1.,2.,3.], [1.,3.,5.], [1.,4.,7.]]

Next I take a "walk" across the mxn array using (x,y) pairs that fall in the m and n ranges.

WAVE> walk = [[15.2, 27.3], [21.9, 23.1], [29.3, 20.5]]

How do I evaluate the interpolated elevations at these walk points? Is there a PV-WAVE function that does this?

10-27-2008, 03:20 PM
the following will do bilinear interpolation for this problem

for i=0,2 do pm, intrp(intrp(elev,0,walk(0,i),z=m),1,walk(1,i),z=n)


10-28-2008, 09:58 AM
Thanks, Allan, that looks helpful.

I was also looking at the BILINEAR() function. Can it be used to do this kind of interpolation? It looks like it assumes m = [0, 1, 2, ...] and n = [0, 1, 2, ...]. I guess you could normalize your m and n vectors.

10-28-2008, 11:16 AM
you are welcome, hcrisp;
you are right about bilinear(), but i did not suggest it
because it requires the normalization you mentioned;
also, intrp() can be much faster than bilinear() when
the evaluation points form a grid; for examples see: