#### Archived

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

# Sort points in poly

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

## 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 on other sites
EDIT: Nevermind...

[edited by - CWizard on August 28, 2002 6:12:30 PM]

##### Share on other sites
They aren''t even in order. How do you know which points connects to which?

##### 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 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 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 on other sites
smanches:

This is only one polygon, and each vertex have 2 neighbours.

##### Share on other sites
Sorry, I meant faces. Replace every poly with face. I screw that up a lot.

##### 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 on other sites
George2: Yeah, exactly the solution I find to.

1. 1
Rutin
44
2. 2
3. 3
4. 4
5. 5

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632996
• Total Posts
3009778
• ### Who's Online (See full list)

There are no registered users currently online

×