In my application I have a list of points(x,y) coming from the GUI. Given the list of points I should be able to decide whether it is a polyline or polygon(It could be rectangle also, thts why I said polygon).

For Example:

I have list of points say p1(10,20), p2(50,60), p3(30,70), p4(50,30), p5(15,25).

Based on these points how can I determine the shape? Any ideas... Thanks in advance.

I'm not sure I understand the question. Given the list of points [p1, p2, ... pn] what do you need to do? Are the points connected as listed p1 -> ... -> pn or do you trying to decide how the points should be connected to form a polygon? [ December 28, 2006: Message edited by: Garrett Rowe ]

Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter

Ravi Kotha
Ranch Hand

Joined: Mar 02, 2006
Posts: 53

posted

0

Points are already connected in the given order. But I want to know whether the shape formed is a "Polyline" or "Polygon"(it could be rectangle also).Did you get me?

I think that it is a bit more complex than that. To be a valid polygon, I don't think that the line segments (sides of the polygon) are allowed to cross each other.

This means that you need to check each pair of sides (line segment). Lots of Algebra involved. Create algebraic equation that represent each line. Use simulaneous equations to solve for common point. etc. etc.