Skip to content

Commit c9cbfc6

Browse files
authored
Merge pull request #14 from eric-wieser/patch-1
Better use of numpy
2 parents df0be56 + 40d39e4 commit c9cbfc6

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/laser_geometry/laser_geometry.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def __projectLaser(self, scan_in, range_cutoff, channel_options):
103103
N = len(scan_in.ranges)
104104

105105
ranges = np.array(scan_in.ranges)
106-
ranges = np.array([ranges, ranges])
107106

108107
if (self.__cos_sin_map.shape[1] != N or
109108
self.__angle_min != scan_in.angle_min or
@@ -112,13 +111,9 @@ def __projectLaser(self, scan_in, range_cutoff, channel_options):
112111

113112
self.__angle_min = scan_in.angle_min
114113
self.__angle_max = scan_in.angle_max
115-
116-
cos_map = [np.cos(scan_in.angle_min + i * scan_in.angle_increment)
117-
for i in range(N)]
118-
sin_map = [np.sin(scan_in.angle_min + i * scan_in.angle_increment)
119-
for i in range(N)]
120-
121-
self.__cos_sin_map = np.array([cos_map, sin_map])
114+
115+
angles = scan_in.angle_min + np.arange(N) * scan_in.angle_increment
116+
self.__cos_sin_map = np.array([np.cos(angles), np.sin(angles)])
122117

123118
output = ranges * self.__cos_sin_map
124119

0 commit comments

Comments
 (0)