mirror of
https://github.com/AtsushiSakai/PythonRobotics.git
synced 2026-01-14 16:57:58 -05:00
Replaced sqrt(x**2+y**2) with hypot in PathPlanning/Dijkstra/dijkstra.py
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user