Distance
Related terms: magnitude, displacement, squared distance
How far apart two positions are. Subtract the positions to get the displacement from one to the other, then take its length. Use positions in the same coordinate space.
Useful for pickup ranges, nearby enemies and arrival checks. If you only need to test a radius, compare squared distance with squared radius to avoid a square root. Straight-line distance does not account for walls; pathfinding does.
dot(B - A, B - A) <= radius * radius
- Further reading
- Python documentation: math.dist: Euclidean distance