PyGeM

Tutorial 5: Inverse Distance Weighting interpolation technique on a cube

In this tutorial we will show how to use the Inverse Distance Weighting interpolation technique to deform a cube.

First of all, we import the required class, the numpy package and we set matplotlib for the notebook.

We need to set the deformation parameters: we can set manually, by editing the IDW attributes, or we can read them by parsing a file. We remark that it is possible to save the parameters (for example, after set them manually) to a file in order to edit this for the future deformations.

The following is the parameters file for this particular case. The Inverse Distance Weighting section describes the power parameter (see the documentation of the IDW class for more details). As control points we consider the 8 vertices of the cube (the first one is not exactly the vertex), and we move 3 of them. In the Control points section there are all the coordinates of the control points.

Here we create a $10 \times 10 \times 10$ lattice to mimic a cube.

Now we plot the points to see what we are doing.

Finally we perform the IDW interpolation using the IDW class.

We can plot the new points in order to see the deformation. Try different powers to better fit your specific problem.