Interpolate 3D Illumination

I would like to interpolate a surface using C #. The situation is as follows:

Given the set of coordinates x, y, z. Now I would like to interpolate between these points using a finer mesh. Actually, I would like to know the z coordinate at a certain point, for example. x = 2.2, y = 1.6 z = Ξ΄.

I managed to solve the interpolation using MatLab but could not use C # .. Also, I was able to draw surfaces using ilnumerics and tried to find some information on my home page.

EDIT:

I think I need to clarify some things - sorry for the confusing way to ask your question

here you can see how I draw a surface from some points:

using System; using System.Drawing; using System.Windows.Forms; using ILNumerics; using ILNumerics.Drawing; using ILNumerics.Drawing.Plotting; namespace Surface { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void ilPanel1_Load(object sender, EventArgs e) { using (ILScope.Enter()) { ILArray<float> R = ILMath.linspace<float>(0, 5, 5); ILArray<float> R1 = ILMath.linspace<float>(0, 25, 5); ILArray<float> y = 1; ILArray<float> x = ILMath.meshgrid(R, R, y); ILArray<float> z = ILMath.meshgrid(R * R, R, y); ILArray<float> Z = ILMath.zeros<float>(xS[0], xS[1], 3); Z[":;:;1"] = x; Z[":;:;2"] = y; Z[":;:;0"] = z; ilPanel1.Scene.Add(new ILPlotCube(twoDMode: false) { new ILSurface(Z, colormap: Colormaps.Cool) { Colors = 1.4f * x * x * x + 0.13f * y * y, Childs = { new ILColorbar() } } }); } } } } 

The x and y coordinates are linearly distributed from 0 to 5, and the z coordinate is quadratic. I would now like to evaluate the value of the z coordinate at a specific x, y coordinate, for example. x = 2.2, y = 1.6 z = - which is definitely not a point of knowledge on my surface. So I thought it would be a good idea to interpolate a surface with a β€œfiner” grid so that I can read the value of the z coordinate ...

+4
source share
2 answers

The z coordinate of your function is calculated on this line:

  ILArray<float> z = ILMath.meshgrid(R * R, R, y); 

Since meshgrid is actually used to create the X and Y coordinates for estimating a two-dimensional function, only the result R * R goes to z. After this line, x, y, and z look like this:

 x <Single> [5,5] [0]: 0,00000 1,25000 2,50000 3,75000 5,00000 [1]: 0,00000 1,25000 2,50000 3,75000 5,00000 [2]: 0,00000 1,25000 2,50000 3,75000 5,00000 [3]: 0,00000 1,25000 2,50000 3,75000 5,00000 [4]: 0,00000 1,25000 2,50000 3,75000 5,00000 y <Single> [5,5] [0]: 0,00000 0,00000 0,00000 0,00000 0,00000 [1]: 1,25000 1,25000 1,25000 1,25000 1,25000 [2]: 2,50000 2,50000 2,50000 2,50000 2,50000 [3]: 3,75000 3,75000 3,75000 3,75000 3,75000 [4]: 5,00000 5,00000 5,00000 5,00000 5,00000 z <Single> [5,5] [0]: 0,00000 1,56250 6,25000 14,06250 25,00000 [1]: 0,00000 1,56250 6,25000 14,06250 25,00000 [2]: 0,00000 1,56250 6,25000 14,06250 25,00000 [3]: 0,00000 1,56250 6,25000 14,06250 25,00000 [4]: 0,00000 1,56250 6,25000 14,06250 25,00000 

Obviously, z depends only on x, which becomes clear from the resulting surface:

Surface

So, the value of z will be: x * x. Or for your specific example:

 x=2.2, y=1.6 z =4.84 

Edit: if the underlying function is unknown, you can either

  • try to find out this function (using ridge_regression () or pinv ()) or
  • interpolate according to neighboring grid points.

ILNumerics does not currently have a corresponding function (for example, 'interp2'). However, in your case, when you need to interpolate only one point (?), You can find neighboring grid points and use one of the general interpolation methods.

Change With the release of > interpolation tools, it has become much easier. Now you can interpolate in any dimension with high speed and with one line.

+1
source

There are various interpolation methods to choose from. I would suggest starting with Bilinear interpolation:

http://en.wikipedia.org/wiki/Bilinear_interpolation

or divide each square into two triangles and use barycentric interpolation:

http://en.wikipedia.org/wiki/Barycentric_coordinate_system_(mathematics)

+1
source

Source: https://habr.com/ru/post/1502591/


All Articles