1

Here is another geometric problem:

I have created an 3-dimensional triangulated iso-surface of a point cloud using the marching cubes algorithm. Then I intersect this iso-surface with a plane and get a number of line segments that represent the contour lines of the intersection.

Is there any possibility to sort the vertices of these line segments clockwise so that I can draw them as a closed path and do a flood fill?

Thanks in advance!

stef
  • 69
  • 3
  • In absense of code, I suggest [math.stackexchange.com](http://math.stackexchange.com). Oh, also: the answer is "yes" – sehe Jul 07 '11 at 20:51
  • You know the endpoints, so you can put the segments in order. Is it just a question of putting them in *clockwise* order? – Beta Jul 08 '11 at 01:57

1 Answers1

0

It depends on how complex your isosurface is, but the simplest thing I can think of that might work is:

  • For each point, project to the plane. This will give you a set of points in 2d.
  • Make sure these are centered, via a translation to the centroid or center of the bounding box.
  • For each 2d point, run atan2 and get an angle. atan2 just puts things in the correct quadrant.
  • Order by that angle

If your isosurface/plane is monotonically increasing in angle around the centroid, then this will work fine. If not, then you might need to find the 2 nearest neighbors to each point in the plane, and hope that that makes a simple loop. In face, the simple loop idea might be simpler, because you don't need to project and you don't need to compute angles - just do everything in 3d.

tfinniga
  • 6,693
  • 3
  • 32
  • 37