Finding Points on a Irregular 2D Shape

Started by
3 comments, last by Sigvatr 10 years, 7 months ago

Hi, can anyone give me a suggestion ?

For various reasons I have a 3D mesh projected orthoganally into a 2D representation so that it shows the "front" of my object as if it were going to be rendered. I want to work out which of my mass of vertexes represent the hull of the shape. The hull isn't neccessarily convex, but I have the triangle indexes and all the vertexes have been welded, so I know "what connects with what". I need to bear in mind that the vertexes that make up the visible hull of the shape aren't neccessarily connected to each other (i.e. they are not part of the same triangle) since the triangles are 3D projected onto a 2D surface.

I could just render the image onto a surface and use simple edge finding to locate the vertexes, but this seems a low quality approach. I hoped there might be a better solution.

Does anyone have any suggestions ?

Thanks

Phillip

Advertisement

I think the rendering and subsequent edge-detection method might be the best way, if that achieves what you want. The first problem that springs to my mind is that mesh edges could overlap at different depths in such a way that the corners of you're silhouette are formed by intersecting edges, rather than by vertices.

If you project the mesh as a group of triangles to the 2D surface you'll have a series of segments and triangles. Sort the triangles by axis aligned left-most points. Remove segments, the degenerate case. Then loop through your triangles and maintain a list of shapes. For each new triangle attempt to merge against any of the maintained shapes. If it merges, attempt to see if the newly merged shape can be merged with other shapes on the list. If no new shapes can be merged grab the next triangle. Continue until you have your projected image. All points on the border of your image are external points. If a point is not on this list then it's one of two things: (1) an existing internal point that you want to remove, or (2) a newly created point that is constructed from two triangles that intersect somewhere other than their endpoints.

If your original 3D shape is convex in 3D then its project should also be convex and you only need to take the convex hull of your points.

I'm guessing the above might be computationally expensive.

I guess if you can find the the external points like Cosmic314 said, you can also use the Ramer Douglas Peucker algorithm.

Here's a link for that:

http://www.emanueleferonato.com/2013/03/13/from-png-to-box2d-first-attempt/

Hope it helps you.

GLM has a function for finding the nearest point on a line.

This topic is closed to new replies.

Advertisement