summaryrefslogtreecommitdiff
path: root/abcd.m
blob: 814615cc083fe52ab5b245a328a4178a895664cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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_afteer_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 it x position increases with number
	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)
	for i=1:size(q,2)
		waste(i)=sqrt (-lambda/pi/imag(1/q(i)));
	endfor
endfunction

function radius =q2radius(q, lambda)
	for i=1:size(q,2)
		radius(i)=(1/real(1/q(i)));
	endfor
endfunction

function q=waste_r2q(waste,R,lambda)
	q=1/(1/R-I*lambda/pi/waste/waste);
endfunction