Hello: I'm working on an windows app in vb 2005 and it incorporates an autocad api.
My program is placing points in the center of polyline objects that look like letters. (see pic - the points are represented as the small squares).
I need to connect the points; however, in the collection that contains these points, they are not in any paticular order.
One idea I have it to try to find the point that is closest to another point; however, If I have an object that resembles the letter "W", there's the possibility that it will find another point closer that's not in the order that visually looks correct.
I assume that your example is just an example, so perhaps you could elaborate a bit more on what the real bounds of the problem are. After all, in the example you have given, a single straight line would connect all of those dots, and that line is a vertical line through the X coordinate of any of the points. So, for that example, you could sort by the Y coordinate and it would suffice. I assume that such a simplistic solution won't work for the real problem, so there must be more to it.
Hi Shaggy Hiker - thanks for your reply. Yes, there's more for sure....in the above example, I'm getting points for the centerline of the letter "I" however, this program will be detecting the centerline of any letter and in addition to that, each letter could be any font. (but they will be polyline objects). For example, the program might detecting the centerline for the letter "C" or the letter "B". The points that form the centerlines for these letters will not be linear. I hope that helps (sorry for not explaining in more detail).
Ah, I couldn't see the forest for the trees. I wasn't looking at the overall shape, just the lines within it (which didn't look like any particular letter, but it could have been a bunch of Ws on their sides).
I do see the issue, now, as it is clear that just examining the points won't suffice. My first thought was to ask whether you had information about the lines, but that's actually quite irrelevant. Where I was going with that wouldn't work for many letters such as f and t.
The only way that I see that looks promising is to come up with a form of pattern recognition to figure out which letter it is, and have a set of rules for each letter (though they would often be the same). This might work, assuming the font is always the same. You might look for vertical runs and horizontal runs. Since letters tend to be made up of lots of vertical runs, that might give you a series of line segments, and the relationship between them may be sufficient to identify the letter, which may be sufficient to let you know how to connect the other dots.
It's a tough problem for sure. Actually, the letters can be any fonts....so that does deepen the problem; however, I could ask the user to enter the letters so that the system knows what they are. Even if the fonts are different, they should all have generally the same shape and that might help.