2D Shape approximations

Started by
9 comments, last by DarkMatter2008 15 years, 10 months ago
Hi all, Does anybody know of any sort of algorythm that can guess what shape something is given a list of vertices? Thanks in advance
Advertisement
What sort of shapes are you thinking of? Concave shapes? Regular triangles, quads, pentagons, etc?
Just simple convex primatives, circles, triangles, sqaures etc.
You may need to write some form of AI or algorithm that can recognize a specific pattern (such as a circle, or a square).
You could create a hull from the vertex soup (Drop all vertices that are inside the shape), and then just count the number of vertices remaining. You'd need to add a certain threshold for circles though.
Quote:Original post by Evil Steve
You could create a hull from the vertex soup (Drop all vertices that are inside the shape), and then just count the number of vertices remaining. You'd need to add a certain threshold for circles though.


Could you elaborate on that, I don't fully understand what your suggesting, what do the remaining vertices tell me?

Cheers
Quote:Original post by DarkMatter2008
Quote:Original post by Evil Steve
You could create a hull from the vertex soup (Drop all vertices that are inside the shape), and then just count the number of vertices remaining. You'd need to add a certain threshold for circles though.


Could you elaborate on that, I don't fully understand what your suggesting, what do the remaining vertices tell me?

Cheers


It's just clicked now, feeling really slow this morning. The vertices being passed would be of varying scales depending on how big the user decides to draw a shape, could I still apply this method? If the shape drawn is at a certain angle this may not work?
Quote:Original post by DarkMatter2008
It's just clicked now, feeling really slow this morning. The vertices being passed would be of varying scales depending on how big the user decides to draw a shape, could I still apply this method? If the shape drawn is at a certain angle this may not work?
What exactly are you trying to do? A shape with 3 vertices will always be a triangle, a shape with 4 will always be a quad, etc. Or do you want the shapes to be more like a "normal" triangle, quad, etc?
Quote:Original post by Evil Steve
Quote:Original post by DarkMatter2008
It's just clicked now, feeling really slow this morning. The vertices being passed would be of varying scales depending on how big the user decides to draw a shape, could I still apply this method? If the shape drawn is at a certain angle this may not work?
What exactly are you trying to do? A shape with 3 vertices will always be a triangle, a shape with 4 will always be a quad, etc. Or do you want the shapes to be more like a "normal" triangle, quad, etc?


Well, what the user has is a free hand draw tool, which the user draws a shape. The vertices collected by that are simplified using the Douglas-Peucker line simplification algorithm, at the end of it you may have something that looks like a trianlge but may have four vertices, so counting the vertices won't really work.
Quote:Original post by DarkMatter2008
Well, what the user has is a free hand draw tool, which the user draws a shape. The vertices collected by that are simplified using the Douglas-Peucker line simplification algorithm, at the end of it you may have something that looks like a trianlge but may have four vertices, so counting the vertices won't really work.
You could remove vertices that have a shallow angle between the two neighboring vertices in that case. So if the angle formed by 3 vertices is less than 5 or 10 degrees, just drop it. That'll smooth out any gentle bends.

This topic is closed to new replies.

Advertisement