数组C#的双线性插值 [英] bilinear interpolation of an array c#

查看:818
本文介绍了数组C#的双线性插值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数组[160,160] 27测量数据点并希望将整个阵列插值。我发现下面的code,但不明白哪些参数我不得不拱手让这个方法如下:

I have an array[160,160] with 27 measured datapoints and want to interpolate the whole array. I have found the following code, but don't get it which parameters I have to hand over so that this method works:

 public static double BilinearInterpolation(double[] x, double[] y, double[,] z, double xval, double yval)
            {
                //calculates single point bilinear interpolation
                double zval = 0.0;
                for (int i = 0; i < x.Length - 1; i++)
                {
                    for (int j = 0; j < y.Length - 1; j++)
                    {   
                        if(xval>=x[i] && xval<x[i+1] && yval>=y[j] && yval<y[j+1])
                        {
                        zval = z[i,j]*(x[i+1]-xval)*(y[j+1]-yval)/(x[i+1]-x[i])/(y[j+1]-y[j])+
                               z[i+1,j]*(xval-x[i])*(y[j+1]-yval)/(x[i+1]-x[i])/(y[j+1]-y[j])+
                               z[i,j+1]*(x[i+1]-xval)*(yval-y[j])/(x[i+1]-x[i])/(y[j+1]-y[j])+
                               z[i+1,j+1]*(xval-x[i])*(yval-y[j])/(x[i+1]-x[i])/(y[j+1]-y[j]);
                        }
                    }
                }
                return zval;
            }

           public static double[] BilinearInterpolation(double [] x, double[] y, double[,]z,double[] xvals, double[]yvals)
           {
               //calculates multiple point bilinear interpolation
               double[] zvals = new double[xvals.Length];
               for (int i = 0; i < xvals.Length; i++)
                   zvals[i] = BilinearInterpolation(x, y, z, xvals[i], yvals[i]);
               return zvals;
           }

双击[]×? - >我的阵列中的点的X- koordinates

double[] x --> the x koordinates of my points in an array?

双击[]ÿ? - >我点的数组在Y koordinates

double[] y --> the y koordinates of my points in an array?

双[,]张? - >一个数组,其中插值存储

double[,] z --> an array, where the interpolated values get stored?

双XVAL - > ??

double xval --> ??

双利用yval - > ??

double yval --> ??

这是正确的?或者你有一个更简单的方法来插值阵列双线性。

is this correct? or maybe you have a easier way to interpolate the array bilinear.

推荐答案

在我看来就像 XVAL 利用yval 处于要插值的值。这是指您要评估的点的坐标。

Looks to me like xval and yval are the values at which you want to interpolate. These are the coordinates of the point that you want evaluated.

这篇关于数组C#的双线性插值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆