Skip to content

Commit

Permalink
Better use of numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-wieser committed Feb 21, 2016
1 parent df0be56 commit 40d39e4
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/laser_geometry/laser_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 40d39e4

Please sign in to comment.