From 855e0053c56bbe2555e87b180f3bf3f3ecccf121 Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Wed, 13 Apr 2011 11:06:02 -0400 Subject: extra comments Ignore-this: 24148ddf66f49e2b8c4f02186a8dbc3b darcs-hash:20110413150602-067c0-b7e0f6ccfca349018b313e5ac53859557e189582 --- abcd.m | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'abcd.m') 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 -- cgit v1.2.3