function [visible, rho, singular] = h3d_scan_whats_your_view(scan, p) % function [visible, rho, singular] = h3d_scan_whats_your_view(scan1, direction) % % p is a point in the scan's frame of reference % We want to know what the scan is seeing in that direction. % % visible is 1 if it is inside the field of view % singular is 1 if more than one point might corrispond to more than one point [tilt, theta, singular] = h3d_scan_dir2tt(p); thetas = deg2rad(scan.thetas_deg); tilts = deg2rad(scan.tilt_deg); % adjust for numerical errors, otherwise unit-tests do not pass epsilon = 1e-4; thetas(1) = thetas(1)-epsilon; thetas(end) = thetas(end)+epsilon; tilts(1) = tilts(1)-epsilon; tilts(end) = tilts(end)+epsilon; if (theta < thetas(1)) || (theta > thetas(end)) || (tilttilts(end)) % fprintf(' %f, %f not in [%f,%f] [%f,%f]\n\n', tilt,theta, tilts(1),tilts(end),thetas(1),thetas(end)); visible = 0; rho = NaN; return end index_theta = 1 + round( (numel(thetas)-1) * (theta-thetas(1)) / (thetas(end)-thetas(1))); index_tilt = 1 + round( (numel(tilts)-1) * (tilt-tilts(1)) / (tilts(end)-tilts(1))); assert( (index_theta >= 1) && (index_theta <= numel(thetas))); assert( (index_tilt >= 1) && (index_tilt <= numel(tilts))); rho = scan.readings(index_tilt, index_theta); visible = 1;