We often have an image on a coarse mesh that we would like to use on a refined mesh.
This regridding chore reoccurs on many occasions
so I present reusable code.
When a continuum is being mapped to a mesh,
it is best to allocate to each mesh point
an equal area on the continuum.
Thus we take an equal interval between each point,
and a half an interval beyond the end points.
Given `n` points,
there are `n-1` intervals between them,
so we have

min = o - d/2 max = o + d/2 + (n-1)*d

which may be back solved to

d = (max-min)/n o = (min*(n-.5) + max/2)/n

which is a memorable result for `d` and a less memorable one for `o`.
With these not-quite-trivial results, we can invoke
the linear interpolation operator `lint2`.
It is designed for data points at irregular locations,
but we can use it for regular locations too.
Operator `refine2` defines pseudoirregular coordinates
for the bin centers on the fine mesh
and then invokes `lint2` to
carry data values from the coarse regular mesh to
the pseudoirregular finer mesh.
Upon exiting from `refine2`,
the data space (normally irregular)
is a model space (always regular) on the finer mesh.
refine2refine 2-D mesh
Finally, here is the 2-D linear interpolation operator `lint2`,
which is a trivial extension of the 1-D version `lint1` .
lint22-D linear interpolation

4/27/2004