Reputation: 2424
What I have so far is:
public static List<String> getIds(int x, int y, int range) {
int ax = x+range;
int ay = y+range;
int bx = x-range;
int by = y-range;
System.out.println(Point2D.distance(ax, ay, bx, by));
// get all coordinates between those two points above.
// and add them to the string array like "x,y";
return null;
}
I used the Point2D.distance to make sure the range was right, but for this method I need to get all the coordinates (integers not doubles) between [ax,ay]
and [bx,by]
yet I cannot find any utility methods within Point2D which does this.
Upvotes: 2
Views: 1578
Reputation: 5034
If you want all the points, you'd need nested loops like :
for (int i = -range; i <= range; i++) {
for (int j = -range; j <= range; j++) {
System.out.println(String.format("(%d,%d)", x+i, y+j));
}
}
Upvotes: 2