C = A-B

sqrt(C dot C)

C = A-B

sqrt(C dot C)

It's essentially just the Pythagorean theorem.

EDIT:

If you're only comparing distances, then you can leave out the

`sqrt`, keep the distances squared, and only

`sqrt`when you need to. This is because a < b and sqrt(a) < sqrt(b) is always true, for a and b >= 0.