Skip to content

Commit 4c6fe30

Browse files
committed
Replaced sqrt(x**2+y**2) with hypot in PathPlanning/Dijkstra/dijkstra.py
1 parent 4c73cad commit 4c6fe30

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

PathPlanning/Dijkstra/dijkstra.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def calc_final_path(self, ngoal, closedset):
123123

124124
def calc_heuristic(self, n1, n2):
125125
w = 1.0 # weight of heuristic
126-
d = w * math.sqrt((n1.x - n2.x)**2 + (n1.y - n2.y)**2)
126+
d = w * math.hypot(n1.x - n2.x, n1.y - n2.y)
127127
return d
128128

129129
def calc_position(self, index, minp):
@@ -178,7 +178,7 @@ def calc_obstacle_map(self, ox, oy):
178178
for iy in range(self.ywidth):
179179
y = self.calc_position(iy, self.miny)
180180
for iox, ioy in zip(ox, oy):
181-
d = math.sqrt((iox - x)**2 + (ioy - y)**2)
181+
d = math.hypot(iox - x, ioy - y)
182182
if d <= self.rr:
183183
self.obmap[ix][iy] = True
184184
break

0 commit comments

Comments
 (0)