function fs_abcd = abcd_free_space( distance) fs_abcd=[1, distance; 0,1]; endfunction function lens_abcd =abcd_lens(focal_distance) lens_abcd = [1, 0; -1/focal_distance, 1]; endfunction function qnew=q_after_element(q_old,abcd) qnew=(q_old*abcd(1,1)+abcd(1,2))/(q_old*abcd(2,1)+abcd(2,2)); endfunction function optics = arrange_optics_along_x(optics_unsorted) % arrange optics in proper order so its x position increases with consequent index N=length(optics_unsorted); % assign x positions x=zeros(1,N); for i=1:N x(i)=optics_unsorted{i}.x; end [xs,indx]=sort(x); cntr=1; for i=indx optics{cntr}=optics_unsorted{i}; cntr=cntr+1; end end function waste =q2waste(q, lambda) waste=sqrt (-lambda./pi./imag(1./q)); endfunction function radius =q2radius(q, lambda) radius=(1./real(1./q)); endfunction function q=waste_r2q(waste,R,lambda) q=1./(1./R-1i.*lambda./pi./(waste.^2)); endfunction