Compare squared distances, not lengths

A vector magnitude is a few adds and multiplies, but mainly a square root; and that last bit is expensive, particularly when you&#x27;re doing it inside a loop over thousands of entities, possibly multiple times per frame. In reality, we use a vector’s magnitude in lots of different contexts. For example (and this happens a lot), grabbing the entity closest to the player, like this: length :: (…