Replaced sqrt(x**2+y**2) with hypot in PathPlanning/Dijkstra/dijkstra.py

This commit is contained in:
Guillaume Jacquenot
2019-12-07 22:53:08 +01:00
parent 4c73cada9b
commit 4c6fe30fb3

View File

@@ -123,7 +123,7 @@ class Dijkstra:
def calc_heuristic(self, n1, n2):
w = 1.0 # weight of heuristic
d = w * math.sqrt((n1.x - n2.x)**2 + (n1.y - n2.y)**2)
d = w * math.hypot(n1.x - n2.x, n1.y - n2.y)
return d
def calc_position(self, index, minp):
@@ -178,7 +178,7 @@ class Dijkstra:
for iy in range(self.ywidth):
y = self.calc_position(iy, self.miny)
for iox, ioy in zip(ox, oy):
d = math.sqrt((iox - x)**2 + (ioy - y)**2)
d = math.hypot(iox - x, ioy - y)
if d <= self.rr:
self.obmap[ix][iy] = True
break