This is rather conceptual, and I'm hoping someone can help. I have a script, that when you insert coordinates (x,y, from 0 -> 800) in to it, it'll return lists of pre-plotted coordinates that are within 3 separate ranges.
ie: I enter 200,200. I receive a list for each of the following: Plots that are within a radius of 25, a radius of 60, a radius of 150.
The code if you're curious / for context:
display(coords[n][1] + ", " + coords[n][2]);
if(n==0){
for(var i=0; i < data.length; i++) {
var xs = 0;
var xy = 0;
xs = xPlot - data[i][0];
ys = yPlot - data[i][1];
xs = xs * xs;
ys = ys * ys;
distance = Math.sqrt(xs + ys);
if (distance <= 25){
display2(data[i][0] + ", " + data[i][1] + " - " + alliance);
}
else if(distance <= 60){
display3(data[i][0] + ", " + data[i][1] + " - " + alliance);
}
else if(distance <= 150){
display4(data[i][0] + ", " + data[i][1] + " - " + alliance);
}
}
Easy enough.
Now, when I input another set of coordinates another multidimensional array is created, I want to check for intersecting points within the two (well, 6) circles.
I thought of using an array for my checking. If 2 coords are entered, and a point is found within both inner (green) circles, a = [g,g]. If a point is found within an inner of one, but a mid (blue) of the other, set a = [g,b] You get the idea. Red being the outer circle.
When 3 coords are entered things get trickier. Let's say a point is within two inners, and one mid. Then a = [g,g,b]. The purpose of the 3 lists, is to organize the returned values in groups of best to worst. So in an example with 4 inputs, the lists are to be organised in the following way:
List 1 / List 2 / List 3
gggg / gggb / bbbr
------- / ggbb / bbrr
------- / gbbb / brrr
------- / bbbb / rrrr
How would I build check my array in a scalable way so if I had 5 inputs, I'd be able to place my results in the appropriate columns?
I've started with this sofar:
else if(n>0){
for(var i=0; i < data.length; i++) {
for(var j=0; j < coords.length; j++) {
var xs = 0;
var ys = 0;
xs = coords[j][1] - data[i][0];
ys = coords[j][2] - data[i][1];
xs = xs * xs;
ys = ys * ys;
distance = Math.sqrt(xs + ys);
if (distance <= 25){
a[j] = [,[g]];
}
else if (distance <= 60){
a[j] = [,[b]];
}
else if (distance <= 150){
a[j] = [,[r]];
}
}
if($.inArray('g', a) && (!($.inArray('b', a)))){
display2(data[i][0] + ", " + data[i][1] + " - " + alliance);
}
Would this last line execute if a contained g, but NOT b?? (jquery) Am I on the right track?