1. Get the center of mass of the points ( average x, average y)
  2. get the angle of each point in relation to the center of mass
  (basic trigonometry)
  3. sort the array by the angle


Blair

On 12/21/06, bmsterling <[EMAIL PROTECTED]> wrote:


Guys and gals,
I am working on something that requires a person be able to click in an
area
and create a hot area.  Here is a link to you can understand
(http://ov.informationexperts.com/test.htm)

The problem that i have is how do I sort a multidimensional array so that
if
a person clicks on four or more points that it makes a square or polygon
and
not an 8.  To better illustrate what I am talking about, go to the link
above and click in the grey box (in firefox with firebug you will get
messeges logged there, on pc you will get a list form below it) and you
will
see points and its coordinates like [[75, 42], [257, 51], [71, 258], [323,
84], [329, 233]] (firebug).  Those points makes don't make a correct box,
so
how should I sort it to make it a box.  Below is the latest attempt to
figure out how to sort it with no luck.

[code]
function mysortfn(a,b) {
  $.log("Comparing "+a+" and "+b);
  if (a[0]+a[1]<b[0]+b[1]) return -1;
  if (a[0]+a[1]>b[0]+b[1]) return 1;
  return 0;
}
[/code]

any help is greatly appreciated.
--
View this message in context:
http://www.nabble.com/login-help-tf2862831.html#a8000052
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to