> Games calculate square roots and inverse square roots all the time to find the lengths of vectors
A trick here is that one often doesn't have to do the square root. For instance, if you want something to happen when an object is 5 units away from another object, it's normal to do
if sqrt( (x2-x1)^2 - (y2-y1)^2 ) < 5 then ...
but instead you can do if (x2-x1)^2 - (y2-y1)^2 < 5^2 then ...
trading a sqrt for a squaring. And often the square of the distance can be cached or even a constant. So a lot of libraries (for instance vector library from libgdx[0]) contain a dst function, but also a dst2 function that skips the squaring to save some cycles when not needed.[0]: https://libgdx.badlogicgames.com/ci/nightlies/docs/api/com/b...