Source: http://mathematiques.daval.free.fr/IMG/pdf/Algo_fiche1_distance.pdf