1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2014-2019 CEA/DEN, EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 # -----------------------------------------------------------------------------
24 # --- calcul de distance carree entre deux points, jeux de coordonnees x,y,z
26 def distance2(xyz1, xyz2):
28 carré de la distance entre deux points donnés par des triplets [x,y,z]
30 #logging.info("start")
34 d2 += (xyz1[i]-xyz2[i])*(xyz1[i]-xyz2[i])
35 logging.debug('d2=%s', d2)
38 # -----------------------------------------------------------------------------
42 class Test_distance2(unittest.TestCase):
49 def test_calcul(self):
50 self.assertEqual(distance2(self.a, self.b), distance2(self.b, self.a))
51 self.assertEqual(distance2(self.a, self.b), distance2(self.a, self.c))
52 self.assertEqual(distance2(self.b, self.b), 0)
53 self.assertEqual(distance2(self.a, self.b), 50)