0

I am given a bunch of points in 3D-space and want to analyze their convex hull. What I am interested in is what kinds of polygons appear on the surface of the convex hull (probably mostly triangles, but maybe there are also quadrilaterals, etc). To get a picture of this, I tried to plot it in Matlab, but I was not able to compute the polygons that form the surface. The best I could do is to plot the surface triangulated (using "convhull").

Does anyone know whether it is possible to compute the polygons and not just get the surface triangulated? I fear that it is not possible; if not, is there an alternative plotting software that might be able to do this?

Edit: Following John's answer below, I finally got a solution to this problem. Basically, I use "convhull" to get the convex hull as a triangulated surface, then I compute the face normals (using "faceNormals") and use them to color all triangles with the same normals in the same color.

Lucas Mann
  • 1,813

1 Answers1

1

Matlab wants to draw triangles, not polygons, generally. (In the plane, it'll draw polygons).

One solution: draw the triangles using surf or patch, but set the EdgeColor to 'none'; then draw all the edges that you want, preferably with a LineWidth that's a little bit large, so that it won't get hidden by the polygons. Better still is to offset the lines ever so slightly; since your surface is convex, you can do this by expanding it by, say, 1% about its center of mass. I'd use plot3 to draw the lines, by the way.

John Hughes
  • 93,729
  • Thank you for your answer. I am not sure whether I understand you correctly, but my core problem is to compute the polygons that form the surface. The best I could do is to use "convhull", but this function automatically triangulates the surface. – Lucas Mann Sep 23 '14 at 11:47
  • 1
    Your question said "plotting", not "computing", so I misunderstod. For computing it, you could use "convhull" and then search for edges whose two adjacent triangles have the same normal vector (within some small tolerance) and then omit those edges when you draw the edge-list. Aggregating such coplanar polygons into groups would give you a list of all the face polygons. For example, if triangles (1,2,4) and (1, 3, 4) are parallel (but no others are parallel and share an edge with either of them) then your output contains the convex polygon whose vertices are (1,3,2,4) in some order. – John Hughes Sep 23 '14 at 11:53
  • Ok, I will try to implement what you said (could take a while since I started using Matlab today, although I have some programming skills). I have edited the question to clarify what I mean. Thanks so far! – Lucas Mann Sep 23 '14 at 11:58
  • OK. You've got a bit of an uphill climb ahead. Good luck! – John Hughes Sep 23 '14 at 12:00
  • I figured it out (finally) and added a brief description of what I did to the question. – Lucas Mann Sep 23 '14 at 14:13