Skip to content

Commit f410844

Browse files
committed
remove np.matrix
1 parent 7ec2f68 commit f410844

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

PathPlanning/InformedRRTStar/informed_rrt_star.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@ def InformedRRTStarSearch(self, animation=True):
4646
# Computing the sampling space
4747
cMin = math.sqrt(pow(self.start.x - self.goal.x, 2) +
4848
pow(self.start.y - self.goal.y, 2))
49-
xCenter = np.matrix([[(self.start.x + self.goal.x) / 2.0],
50-
[(self.start.y + self.goal.y) / 2.0], [0]])
51-
a1 = np.matrix([[(self.goal.x - self.start.x) / cMin],
52-
[(self.goal.y - self.start.y) / cMin], [0]])
49+
xCenter = np.array([[(self.start.x + self.goal.x) / 2.0],
50+
[(self.start.y + self.goal.y) / 2.0], [0]])
51+
a1 = np.array([[(self.goal.x - self.start.x) / cMin],
52+
[(self.goal.y - self.start.y) / cMin], [0]])
53+
5354
etheta = math.atan2(a1[1], a1[0])
5455
# first column of idenity matrix transposed
55-
id1_t = np.matrix([1.0, 0.0, 0.0])
56-
M = np.dot(a1, id1_t)
56+
id1_t = np.array([1.0, 0.0, 0.0]).reshape(1, 3)
57+
M = a1 @ id1_t
5758
U, S, Vh = np.linalg.svd(M, 1, 1)
5859
C = np.dot(np.dot(U, np.diag(
5960
[1.0, 1.0, np.linalg.det(U) * np.linalg.det(np.transpose(Vh))])), Vh)
@@ -285,9 +286,9 @@ def plot_ellipse(self, xCenter, cBest, cMin, etheta):
285286
t = np.arange(0, 2 * math.pi + 0.1, 0.1)
286287
x = [a * math.cos(it) for it in t]
287288
y = [b * math.sin(it) for it in t]
288-
R = np.matrix([[math.cos(angle), math.sin(angle)],
289-
[-math.sin(angle), math.cos(angle)]])
290-
fx = R * np.matrix([x, y])
289+
R = np.array([[math.cos(angle), math.sin(angle)],
290+
[-math.sin(angle), math.cos(angle)]])
291+
fx = R @ np.array([x, y])
291292
px = np.array(fx[0, :] + cx).flatten()
292293
py = np.array(fx[1, :] + cy).flatten()
293294
plt.plot(cx, cy, "xc")

0 commit comments

Comments
 (0)