# Thread: Creating a surface from points

1. ## Creating a surface from points

I have a data set that is sparse and not organized in any way. I have tried ordering the data based on the X and Z axes. This works, but the surface isn't very useful due to the fact that the data is so sparse it has very sharp peaks and valleys, where I am looking for a nice smooth surface.

The type of data I have is in X, Y, Z format. In my case the ranges for the data along each axis are vastly different. For example the x-axis may be Engine RPM which could go from 1000-8000, where the z-axis could be Pressure Ratio, and be 0.5 - 3. The y-axis, the data I'm interested in plotting, can be any range of number based on what the user selected. What I have decided to do is simply ignore the actual values for the x and z axis, and give them a range from 0 to max and just plot the actual y values. Then I figure I can just draw axes to represent the actual range. That should solve my problem of the chart being unreadable due to differences in range.

I have been doing a lot of reading and keep coming across posts where people mention "Delaunay Triangulation". I've also seen some posts referring to hulls. I have been researching those two concepts, but I'm having trouble understanding how I would go about running the triangulation, what that would output and how I would ultimately render it. I looked into things like MeshLab, Point Cloud Library and various other projects, but those seem to provide far more functionality than I need. What I'm looking for is a way to perform the Delaunay Triangulation on my data, and then display it so the user can pan, tilt and zoom the surface. Any help would be appreciated.

2. Originally Posted by gizmodo
I have been doing a lot of reading and keep coming across posts where people mention "Delaunay Triangulation". I've also seen some posts referring to hulls. I have been researching those two concepts, but I'm having trouble understanding how I would go about running the triangulation, what that would output and how I would ultimately render it. I looked into things like MeshLab, Point Cloud Library and various other projects, but those seem to provide far more functionality than I need. What I'm looking for is a way to perform the Delaunay Triangulation on my data, and then display it so the user can pan, tilt and zoom the surface. Any help would be appreciated.
Actually, it does sound like a situation that calls for the convex hull to be computed and graphically displayed. It's actually not that hard to code up. You may be able to download code for free that will do it for you. If you have the time and interest to code it up yourself, I recommend the 'Incremental Algorithm'. Good luck.

3. Thanks for the reply. In response to your post I've been looking more into convex hulls and I must be misunderstanding how that would help me. From what I can tell a convex hull is basically the shape that contains all other points inside of it.

I apologize if I am not understanding. I'm not new to programming, but this is my first foray into OpenGL and surfaces, so perhaps I'm treading in waters I shouldn't be.

4. If you want to stick to OpenGL, you need to write your own code for displaying the surface. As far as triangulation is concerned, there exist many free delaunay triangulation libraries on the web.

If you just want to achieve your task without restriction on the technology, then I would suggest you to use Visualization ToolKit (VTK). This is based on OpenGL, which has inbuilt classes for triangulating 2D and 3D points and so called creating surface. Several other related classes can be found here. You can find the number of examples here.

Good Luck

5. Originally Posted by gizmodo
Thanks for the reply. In response to your post I've been looking more into convex hulls and I must be misunderstanding how that would help me. From what I can tell a convex hull is basically the shape that contains all other points inside of it.

I apologize if I am not understanding. I'm not new to programming, but this is my first foray into OpenGL and surfaces, so perhaps I'm treading in waters I shouldn't be.
It's probably me that is not understanding exactly what you are trying to do. A convex hull is the smallest (i.e. minimum volume polyhedron), that contains a set of points. It's a surface made up of triangular facets whose vertices would be some of your data points. It is a fairly straightforward way to wrap a surface around a set of points. Imagine a fully inflated balloon with a set of beebees randomly floating in space inside it. The beebees are not moving and are help rigidly in place some sort of force field. When the air is let out of the balloon, it would shrink down until it contacted the outermost beebees. You'd end up with a rubber membrane wrapped around the points, made up of triangular facets. Is this what you need?

6. Originally Posted by rakeshthp
If you want to stick to OpenGL, you need to write your own code for displaying the surface. As far as triangulation is concerned, there exist many free delaunay triangulation libraries on the web.

If you just want to achieve your task without restriction on the technology, then I would suggest you to use Visualization ToolKit (VTK). This is based on OpenGL, which has inbuilt classes for triangulating 2D and 3D points and so called creating surface. Several other related classes can be found here. You can find the number of examples here.I think for learning's sake I am going to try coding myself. I appreciate the response and link though.

Good Luck
Originally Posted by Carmine
It's probably me that is not understanding exactly what you are trying to do. A convex hull is the smallest (i.e. minimum volume polyhedron), that contains a set of points. It's a surface made up of triangular facets whose vertices would be some of your data points. It is a fairly straightforward way to wrap a surface around a set of points. Imagine a fully inflated balloon with a set of beebees randomly floating in space inside it. The beebees are not moving and are help rigidly in place some sort of force field. When the air is let out of the balloon, it would shrink down until it contacted the outermost beebees. You'd end up with a rubber membrane wrapped around the points, made up of triangular facets. Is this what you need?

Here is an image of what I am trying to accomplish.

7. You need to use delaunay triangulation

8. I spent some time today looking at some Delaunay Triangulation algorithms. I was able to get my surface rendering, now I just need to figure out how to color it like above and get some lighting going. Thanks for the help everyone! Hopefully I won't be posting about lighting or colors later.

9. Originally Posted by gizmodo
I spent some time today looking at some Delaunay Triangulation algorithms. I was able to get my surface rendering, now I just need to figure out how to color it like above and get some lighting going. Thanks for the help everyone! Hopefully I won't be posting about lighting or colors later.
I use the older, classic, GL - so no shaders. What I would do is use projective texturing. There are many tutorials and references that show you how to set up lighting.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•