Looking into the mathematics of the distance calculation, you may notice something interesting. The formula used for distance is as follows:
However, if we only need to compare the distance between points, the squared distance is all we need, as the following formula shows:
As the std::sqrt() operation is not required if we just want to compare distances to each other, we can omit it. The nice thing is, std::sqrt() is a relatively slow operation, meaning that if we compare a lot of distances between points, we can ...