diff options
-rw-r--r-- | gbeam_propagation.m | 8 |
1 files changed, 5 insertions, 3 deletions
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) |