Given a point with x, y coordinates, I would like to understand in which sector are the points near it.
Check this image:

My Point is like this:
public class Node {
public final int id;
public final double coordinates[];
public ArrayList<Node> candidateList;
public Node(int id,double... values){
this.id=id;
this.coordinates=values;
}
public int distance(Node other){
double result = 0;
for (int x = 0; x<this.coordinates.length;x++){
result+=(this.coordinates[x]-other.coordinates[x])*(this.coordinates[x]-other.coordinates[x]); //TODO time difference with pow
}
return (int) Math.round(Math.sqrt((result)));
}
}
You picture shows 8 sectors, and you can find sector number with three simple conditions (x and y are coordinates relative to center):
x < 0
y < 0
abs(x) < abs(y)
These three conditions give three bits of information to define 2^3=8 possible states (sector number). So you just have to make a table to match every combinations of condition results to the sector number. For example:
0 0 1 => your sector 1 //x positive, y positive, abs(y)>abs(x)
0 1 0 => your sector 3
If you want more sectors, it would simpler to use angle-based approach. For example, for 16 sectors:
//note reverse argument order due to your sector numbering
angle = atan2(x, y)
if angle < 0 then
angle = angle + 2 * Pi
sector = 1 + Floor(angle * 8.0 / Pi)