Skip to content

Commit

Permalink
Merge pull request #14 from eric-wieser/patch-1
Browse files Browse the repository at this point in the history
Better use of numpy
  • Loading branch information
vrabaud authored Jul 22, 2017
2 parents df0be56 + 40d39e4 commit c9cbfc6
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 c9cbfc6

Please sign in to comment.