# Given a set of points and a normal, how can I arrange the points in a CCW order?

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

## Recommended Posts

If I have a set of random points and a normal, is it possible to order the points counter clockwise based on the direction of the normal?

##### Share on other sites
No you need a point of reference around which to order the points along with a normal. A ray for instance would suffice. Once you have one though projecting to the plane then ordering the points is simple. One way I've done it before was to use a quicksort algorithm that partitions via a dot product. (Cuts the number of points in which to order by half every time).

##### Share on other sites
That's cool. I have a point of collision and a normal so I can now create a ray.

How would I proceed from here?

EDIT: You must have edited your post during my reply or maybe I didn't catch the quicksort algorithm sentence when reading your post.

Would you mind posting the point sorting algorithm?

[Edited by - Spa8nky on March 13, 2010 8:38:24 PM]

##### Share on other sites
Oh man you got lucky. I wrote a test for it apparently. Source for 2D circle sort. There's probably a better way actually. I wrote that algorithm without researching really. You should be able to throw it into whatever algorithm you're writing though.

##### Share on other sites
Thank you very much. I'm delving into it now and it will no doubt come in handy as part of my geometry toolset.

1. 1
2. 2
Rutin
23
3. 3
JoeJ
20
4. 4
5. 5

• 22
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631732
• Total Posts
3001926
×