function points = scan2(calibout, laserscans, tbase, tstep) laserdata = calibout(1:3,:); camstats = calibout(4:10,1:3); n = size(laserscans,2); ytotal = size(laserscans,1); points = zeros(ytotal, n, 3); baseline = convert('sbase.jpg'); for i = 1:n xcenter = size(baseline,2)/2; ycenter = size(baseline,1)/2; x = laserscans(:,i)/camstats(5,1); y = ((1:ytotal) - ycenter)'/camstats(5,2); ud = comp_distortion([x y]',camstats(7,1)); xc = ud(1,:)'; yc = ud(2,:)'; thetap = tbase + (i-1)*tstep; tp= calibout(1, 1:4); theta = polyval(tp, thetap); Xlaser = calibout(2,1); Zlaser = calibout(2,2); a1 = xc; a2 = -tan(theta); b2 = (Xlaser - (Zlaser*a2))* ones(size(xc)); Z = b2 ./ (a1 - a2); points(:,i,1) = xc.*Z; points(:,i,2) = yc.*Z; points(:,i,3) = Z; end; z = points(:,:,3); zgrad = points(2:size(points,1),:,3) - points(1:size(points,1)-1,:,3); thresh = 10; zwhich = zeros(size(z)); zwhich(1:size(points,1)-1,:) = zgrad>thresh; zwhich(2:size(points,1),:) = zwhich(2:size(points,1),:) + zgrad>thresh; z(find(zwhich)) = NaN; points(:,:,3) = z; surfl(points(:,:,1),-points(:,:,2),points(:,:,3)); hold on; shading flat; %plot3(points(:,:,1),-points(:,:,2),points(:,:,3));