Skip to content

Commit 26cff8e

Browse files
committed
Replaced sqrt(x**2+y**2) with hypot in PathPlanning/RRT/rrt.py
1 parent bc2b7c9 commit 26cff8e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

PathPlanning/RRT/rrt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def generate_final_course(self, goal_ind):
126126
def calc_dist_to_goal(self, x, y):
127127
dx = x - self.end.x
128128
dy = y - self.end.y
129-
return math.sqrt(dx ** 2 + dy ** 2)
129+
return math.hypot(dx, dy)
130130

131131
def get_random_node(self):
132132
if random.randint(0, 100) > self.goal_sample_rate:
@@ -186,7 +186,7 @@ def check_collision(node, obstacleList):
186186
def calc_distance_and_angle(from_node, to_node):
187187
dx = to_node.x - from_node.x
188188
dy = to_node.y - from_node.y
189-
d = math.sqrt(dx ** 2 + dy ** 2)
189+
d = math.hypot(dx, dy)
190190
theta = math.atan2(dy, dx)
191191
return d, theta
192192

0 commit comments

Comments
 (0)