Ravi Kotha

Ranch Hand

Posts: 53

posted 10 years ago

Hi thr,

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).

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

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.

Garrett Rowe

Ranch Hand

Posts: 1296

posted 10 years ago

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 ]

[ 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

Posts: 53

Ulf Dittmer

Rancher

Posts: 42970

73

posted 10 years ago

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.

Henry

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.

Henry