A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: How to find points "clockwise" relative to origin?

Threaded View

  1. #6
    Senior Member rachil0's Avatar
    Join Date
    Jul 2007
    Location
    Columbus, OH.
    Posts
    465
    I gave it some more thought, and I think you can avoid the winding/overflow issues by minimizing the dot product over the pairs which have positive cross product. New pseudocode:

    Code:
    Number smallest_dot = 1.0;
    Array[2] best_vertex_pair;
    for (a = first vertex to last)
      for (b = first vertex to last)
         if (a != b && cross2D(a,b) > 0)
           {
           Number current_dot = dot2D( normalize(a), normalize(b) );
           if (current_dot < smallest_dot)
             { smallest_dot = current_dot; best_vertex_pair = [a,b]; }
           }
    Last edited by rachil0; 07-10-2009 at 08:30 PM. Reason: Initial value of smallest_dot should be 1.0, and vectors should be normalized before dotting.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center