1 # -*- coding: utf-8 -*-
5 # -----------------------------------------------------------------------------
6 # --- calcul de distance carree entre deux points, jeux de coordonnees x,y,z
8 def distance2(xyz1, xyz2):
10 carré de la distance entre deux points donnés par des triplets [x,y,z]
12 #logging.info("start")
16 d2 += (xyz1[i]-xyz2[i])*(xyz1[i]-xyz2[i])
17 logging.debug('d2=%s', d2)
20 # -----------------------------------------------------------------------------
24 class Test_distance2(unittest.TestCase):
31 def test_calcul(self):
32 self.assertEqual(distance2(self.a, self.b), distance2(self.b, self.a))
33 self.assertEqual(distance2(self.a, self.b), distance2(self.a, self.c))
34 self.assertEqual(distance2(self.b, self.b), 0)
35 self.assertEqual(distance2(self.a, self.b), 50)