Playing with Rudolf's code, it became apparent to me that natural splines
may not the best choice for droftarts' problem.
If we take the following input data:
A = [ // coarse data of surface
[ 1, 2, 0.1, 1, 2],
[ 2, 2, 4, 2, 1],
[0.2, 0.2, 2, 1, 3],
[ 1, 1, 1, 1, 4],
];
the overshoot tendency of natural spline will produce a graph with negative
values (although all data values are positive) and the graph volume itself
has self-intersections. As this is in the very nature of the natural
splines I would not recommend it to general terrain modelling.
There are some spline interpolation methods that keep the solution in the
bounds of the input data but I never studied them.
Wrong example, sorry. That is the corrected one:
A = [ // coarse data of surface
[ 1, 2, 0.1, 1, 2],
[ 4, 3, 4, 2, 1],
[0.1, 0.1, 3, 2, 3],
[ 1, 2, 1, 1, 4],
];