Jump to content
  • Advertisement
Sign in to follow this  
Spa8nky

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.

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

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!