If you want to compare distances and save time, use not the distance itself, but its square: (x1-x2) ^ 2 + (y1-y2) ^ 2. Do not take sqrt. Thus, your distances will work exactly the same as regular ones, but quickly. Counting dx = x1-x2 and dx2 = dx * dx is even faster than accepting ABS (you meant this, not MOD really), because the latter is a function, and you have to pay for it.
ABS distance is correct - theoretically. But what is its use if it is crude for your purposes?
Gangnus
source share