From 91a5cf152b0f7c04d40ef5cb1634eeff330989ad Mon Sep 17 00:00:00 2001 From: Matt Argao Date: Thu, 29 Nov 2012 16:55:14 -0500 Subject: Prearrange optics for backward propagation --- gbeam_propagation.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'gbeam_propagation.m') diff --git a/gbeam_propagation.m b/gbeam_propagation.m index 71fcb74..d81f70e 100644 --- a/gbeam_propagation.m +++ b/gbeam_propagation.m @@ -22,11 +22,13 @@ function q = gbeam_propagation(x_pos, q_in, x_in, optics_elements) x_backw=fliplr(x_backw); % reflected beam means inverted radius of curvature or real part of q parameter q_in_backw = -real(q_in) + 1i*imag(q_in); - optics_elements_backw=optics_elements; + optics_elements_backw=fliplr(optics_elements); % we need to flip all optics elements around x_in as well - for i=1:length(optics_elements_backw) + n_elements = length(optics_elements); + + for i=1:n_elements optics_elements_backw{i}.x=x_in-optics_elements_backw{i}.x; - % there is a tricky case: if position of any optics element coincides + % there is a tricky case: if position of any optics element coincides % with x_in i.e it is 0 in backwards x coordinates (or at index 1) then % we need to apply abcd matrix of that element in advance. if ( optics_elements_backw{i}.x == 0) -- cgit v1.2.3