Archived

This topic is now archived and is closed to further replies.

Sort points in poly

This topic is 5589 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! These points are corners in a polygon but they are not sorted in any order. I need to find a method to sort them in clockwize order starting from point 1. Thanks, [edited by - farbror_fantasy on August 28, 2002 6:10:49 PM] [edited by - farbror_fantasy on August 28, 2002 6:11:53 PM]

Share this post


Link to post
Share on other sites
If you have something like a list that says, point 1-2, 2-5, 5-7, etc, then you just build a list of them sorted that way. You have two choices to go for the clockwise order, but how to find that which way that is, I can''t pull out of my head now. Go check the reference section on complex polys, as this involves to solve the problem of what is "inside" the poly.

Share this post


Link to post
Share on other sites
thank you,

the question why I ask this is because I want to transform the polygon to a triangle strip and to to that I need to have the vertices in order...

As you can see, the triangles in the polygon in the first row are crossing each other. They are not supposed to do that.


Thanks,


[edited by - farbror_fantasy on August 28, 2002 6:35:14 PM]

Share this post


Link to post
Share on other sites
Start by find a face that has only one or two neighbors. Faces that are on the edge of a model only have two neighbors, or one in some instances. Then make a list of neighbors with only one or two edges. This list will contain the outer faces of the model.

EDIT: Changed Polys to Faces for better clairfication.

[edited by - smanches on August 29, 2002 3:25:15 PM]

Share this post


Link to post
Share on other sites
Find the lowest point (call it l) and for every other point (call them p1 to pn) in the poly, calculate the angle between a horizontal line and the line l-pi (where i is between 1 and n). Then all you have to do is sort the angles (descending will give you clockwise order, I think)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
george2 solution will work for concave shapes but not necesarily for convex.

ie:


x---------------------x
| |
| |
x-------x x---------x
\ /
\ /
x

hth

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
george2 solution will work for concave shapes but not necesarily for convex.

ie:


x---------------------x
| |
| |
x-------x x---------x
\ /
\ /
x

hth



You mean it will work for convex shapes and not for concave, that''s true. Anybody know how we can do it with concave shapes ?

PS: are there any html tag''s which preserve spaces ?

Share this post


Link to post
Share on other sites
quote:
Original post by George2
You mean it will work for convex shapes and not for concave, that''s true. Anybody know how we can do it with concave shapes ?


With concave shapes, there are multiple solutions. I don''t know how to find them, but I don''t think it''s what you want.

quote:
PS: are there any html tag''s which preserve spaces ?


The [ code ] tags.

Cédric

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
george2 solution will work for concave shapes but not necesarily for convex.

ie:


x---------------------x
| |
| |
x-------x x---------x
\ /
\ /
x


hth


testing

Share this post


Link to post
Share on other sites