Program "XY-Function"

Graphical representation and interpolation of XY functions given on unstructured grids of XY-points

Copyright:   Helm Ing. 1999-2000


  1. Short Description of the Program
  2. Delaunay Triangulation
  3. Program Structure
  4. File Format
  5. Grid to Grid Interpolation
  6. Short Tutorial

Short Description of the Program


Delaunay Triangulation

Values will be given (or measured) often on points which are randomly distributed in two dimensions:


Here a function was determined at 102 points given within the range: -1 < x,y < 1.
To represent this data as a continuous function the XY-plane may be divided into triangles by using the DELAUNAY triangulation:

The following conditions should be fulfilled at this:
Calculations of contour lines can be executed for each triangle one by one. This requires only linear interpolations.:

The triangulation is also usefull for applications of OpenGL or Direct3D which can calculate 3D presentations of 2D-functions based on meshes of triangles.


Program Structure

The XY-Function main form comprises the following fields:

1. Tool Buttons

  1. Load a function as text file (cfg. File Format, for example load file1.txt),
  2. Save the function as text file,
  3. Delete all XY-points and the corresponding values,
  4. Copy the actual picture to clipboard,
  5. Grid to grid interpolation,
  6. Example: Generates random points of a GAUSS distribution as long as the button is pressed,
  7. Open this help file.

2. Mode Register

It consists of two sheets:

2D (Contour Lines) 3D (OpenGL)
The distance to the 3D-Image of the function may be changed with the trackbar Focal Length. Furthermore the the 3D-Image can be rotated by mouse dragging (tilting of the Z-Axis) or changing the trackbar Turn around Z. The coordinate axis X,Y and Z may be displayed marking the check box Show Axis.

3. Status Bar

2D: XY-coordinates and the interpolated values on the mouse position in the 2D-image,
3D: direction of the Z-axis and the turn angle about the Z-axis.


File Format

For each data point one line must be filled with three values for X,Y and F:

For the input file for the Grid to Grid Interpolation only two values for X and Y are necessary for each line.


Grid to Grid Interpolation

Before pressing the corresponding tool button 5 You have to prepare a file in which the new set of points is described (two numbers for each line, cfg. file format). These points should be within the convex hull of the point set of the starting (current) function. Values of points near but outside the convex hull will be roughly estimated only. After loading this file the current function will be interpolated to the new set of points.

The result is decribed in a message box:
... points were read in,
... values were interpolated correctly,
... values were estimated roughly,
... values could not be estimated.

The interpolated values will be inserted in the grid file:


Short Tutorial

1. Loading a function

There are four examples named file1.txt ... file4.txt, you can load and view. Before loading a new file You should delete the old data by pressing the Delete button 3.

2. Changing 3D-Parameters
  1. Load an example file and set the mode register on 3D (OpenGL),
  2. Testing the effect of setting the Focal Length, Turn around Z and Show Axis elements,
  3. Rotate the 3D-Image by tilting the Z-Axis (mouse dragg).
3. Changing 2D-Parameters
  1. Load an example file and set the mode register on 2D (Contour Lines),
  2. Testing the effect of setting the parameter registers XY-Range, Show, Iso-Colors and Design,
  3. The visible range of the function may be zoomed by mouse dragging (with the left mouse button) from above on the left to down on the right. Inverse mouse dragging from down on the right to above on the left restores the choosen XY-Range.
4. Manual addition of data
  1. Set mode register on 2D (Contour Lines),
  2. Choose a initial file or press the Delete button 3 to generate a new data set.
  3. Add a new data point with a click of the right mouse button on the corresponding position of the 2D-Image field.
5. Example: Random points of a GAUSS function

As long as the Example button 6 is pressed random points of a GAUSS function at x = -0.5 and y = -0.33 will be generated. If the mouse points to the centre of the distribution presented in the 2D-Image, You can read out the maximum parameter from the status bar .

6. Generation of a reguar grid

Set the 2D-Parameter register on Regular Grid. A regular grid with arbitrary X- and Y-steps (with respect to the actual default range) can be generated and saved. The actual data set will be deleted at this.

7. Grid to Grid Interpolation
  1. Generate a XY-function by pressing the Example button 6 for a short time,
  2. Save this function Save button 2,
  3. Generate and save a regular grid of points with X steps= 10,Y steps= 10 (i.e. 11 * 11 points, ) - the XY-range should be unchanged at this,
  4. Reload the function and press the Interpolation button 5,
  5. Choose the generated grid, the corresponding file will be modified as described above (cfg. Grid to Grid Interpolation).