From 40d39e44dc49f6432e59a2d8a173819b225d3cfa Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Sun, 21 Feb 2016 15:49:15 -0500 Subject: [PATCH] Better use of numpy --- src/laser_geometry/laser_geometry.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/laser_geometry/laser_geometry.py b/src/laser_geometry/laser_geometry.py index b857b3b0..af2452ea 100644 --- a/src/laser_geometry/laser_geometry.py +++ b/src/laser_geometry/laser_geometry.py @@ -103,7 +103,6 @@ def __projectLaser(self, scan_in, range_cutoff, channel_options): N = len(scan_in.ranges) ranges = np.array(scan_in.ranges) - ranges = np.array([ranges, ranges]) if (self.__cos_sin_map.shape[1] != N or self.__angle_min != scan_in.angle_min or @@ -112,13 +111,9 @@ def __projectLaser(self, scan_in, range_cutoff, channel_options): self.__angle_min = scan_in.angle_min self.__angle_max = scan_in.angle_max - - cos_map = [np.cos(scan_in.angle_min + i * scan_in.angle_increment) - for i in range(N)] - sin_map = [np.sin(scan_in.angle_min + i * scan_in.angle_increment) - for i in range(N)] - - self.__cos_sin_map = np.array([cos_map, sin_map]) + + angles = scan_in.angle_min + np.arange(N) * scan_in.angle_increment + self.__cos_sin_map = np.array([np.cos(angles), np.sin(angles)]) output = ranges * self.__cos_sin_map