View Full Version : Plotting 3d using non-grid data

15th March 2013, 18:49
Does anyone know a qt (or c++) library supports plotting 3d plots using non grid data?

I tried qwtplot3d (using function loadFromData) but the output plot is not smooth.

What I need:

What I did

Thank you very much!

15th March 2013, 19:40
Try using bilinear interpolation to resample your non-uniform data onto a regular uniform grid and then using that in qwtplot3d. I don't think qwtplot3d can handle non-uniform data. Wikipedia has a good discussion of bilinear interpolation.

Note that if your regular grid has larger unit spacing than the non-uniform data, then certain grid cells will contain more than one data point. When you do the interpolation, you add each of these contributions to the values at the four corners of the cell. You have to remember how many data points contribute to each grid point so at the end, you can divide the total sum by the number of contributions. If you don't you will get a spike at any grid point that has more than one data point contributing to it.

By the way, this is a pretty simple way to implement a "level of detail" feature: set the regular grid to a fixed, constant size in pixels (e.g. 1000 x 1000). As you zoom into your data, the number of data points in a grid cell will decrease, so the interpolated result shows a greater level of detail.