aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--abcd.m41
1 files changed, 22 insertions, 19 deletions
diff --git a/abcd.m b/abcd.m
index 7e02200..ac9b1db 100644
--- a/abcd.m
+++ b/abcd.m
@@ -10,12 +10,32 @@ 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 q = prop_forward(x_pos, q_in, x_in, optics_elements)
% calculate the 'q' parameter of the Gaussian beam propagating through optical
-% 'optics_elements' array along 'x' axis at points 'x_pos'
+% 'optics_elements' only in the positive direction along 'x' axis at points 'x_pos'
% takes the gaussian beam with initial q_in parameter at x_in
%
% all x_pos must be to the right of x_in
+% x_pos must be monotonic!
if (any(x_pos < x_in))
error('all beam positions must be to the right of the x_in');
end
@@ -50,28 +70,11 @@ function q = prop_forward(x_pos, q_in, x_in, optics_elements)
endfor
end
-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 q = prop(x_pos, q_in, x_in, optics_elements)
% calculate the 'q' parameter of the Gaussian beam propagating through optical
% 'optics_elements' array along 'x' axis at points 'x_pos'
% takes the gaussian beam with initial q_in parameter at x_in
+% x_pos must be monotonic!
q=0*x_pos; % q vector initialization