Thanks, I guess I needed a little nudge to actually get working on the method. If anyone sees a quicker method than the code below, then please say so.
Thanks Ron, A.Cicak & others! function orderClockwise(coll:Array, center:Point):Array { if (!center) center = getCenterPoint(coll); var angleArray:Array = new Array(); var i:Number = coll.length; while (i--) { var point:Point = coll[i]; var dx:Number = point.x-center.x; var dy:Number = point.y-center.y; var angle:Number = Math.atan2(dy, dx); angleArray.push({index:i, angle:angle}); } angleArray.sortOn("angle", Array.NUMERIC); i = angleArray.length; var sortedArray:Array = new Array(); while (i--) sortedArray[i] = coll[angleArray[i].index]; return sortedArray; } 2006/2/27, A.Cicak <[EMAIL PROTECTED]>: > atan2 should do the trick > > "Bart Wttewaall" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > Hi List, > > I'm looking for an algorithm that sorts a collection of points > counter-, or clockwise by (probably) means of comparing each point to > the center point of the collection. Calculating the centerpoint wasn't > too hard, but I'm stuck at the comparing part. It doesn't matter which > point the returning array begins with, but I'd like the method to be > as fast as possible since it will be called every frame. > > I'm not asking for a complete solution (although appreciated) but for > a few tips how to tackle this one. > > Thanks, > Bart Wttewaall > _______________________________________________ > Flashcoders@chattyfig.figleaf.com > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com > > > > _______________________________________________ > Flashcoders@chattyfig.figleaf.com > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com > _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com