function s = h3d_scan_convert_points(s) % function s = h3d_scan_convert_points(s) % creates the array of 3d points from s % % adds the member "p3d" (cells) to s. % fix wrong theta % s.readings = fliplr(s.readings); nrays = numel(s.thetas_deg); nscans = numel(s.tilt_deg); if not(size(s.readings, 1) == nscans) || not(size(s.readings, 2) == nrays) error('Size mismatch.'); end % Counter for valid points np = 1; s.points = zeros(3, nrays*nscans); s.p3d = cell(nscans,nrays); s.valid = s.readings > 0; for k=1:nscans for i=1:nrays rho = s.readings(k,i); if s.valid == 0 continue; end theta = deg2rad(s.thetas_deg(i)); tilt = deg2rad(s.tilt_deg(k)); % Find (x,y) in the 2d laser plane: % remember x is forward % and we rotate around z axis direction = h3d_scan_tt2dir(tilt, theta); p3d = rho * direction; s.points(:,np) = p3d; s.p3d{k,i} = p3d; np = np + 1; end end s.points = s.points(1:3,1:(np-1));