dem-net/DEM.Net

Wrong y direction in HyperbolicInterpolator

g0ro opened this issue · 3 comments

g0ro commented

double h1 = southWestHeight, h2 = southEastHeight, h3 = northWestHeight, h4 = northEastHeight;

If x is from west to east and y is from north to south, then (0,0) point should be at NW, not SW

Hi @g0ro, thanks for reporting this. Can you submit a test case for that ? Which data set did you use ?

g0ro commented

It does not depend on a dataset.
HyperbolicInterpolator's y is just inversed compared to BilinearInterpolator. The later seems to be right.

To test it, we may get height values of corner points, they should be the same:


        private static void TestInterpolators()
        {
            var iplBl = new BilinearInterpolator();
            var iplHb = new HyperbolicInterpolator();

            for (var x = 0; x<=1; x++)
            {
                for (var y = 0; y <= 1; y++)
                {
                    var hBl = iplBl.Interpolate(1, 2, 3, 4, x, y);
                    var hHb = iplHb.Interpolate(1, 2, 3, 4, x, y);
                    Console.WriteLine($"x={x} y={y} hBl={hBl} hHb={hHb}");
                }

            }

        }

But the result is inverted:

x=0 y=0 hBl=3 hHb=1
x=0 y=1 hBl=1 hHb=3
x=1 y=0 hBl=4 hHb=2
x=1 y=1 hBl=2 hHb=4

OK thanks for pointing this out. Will fix it