diff options
Diffstat (limited to 'gbeam_propagation.m')
-rw-r--r-- | gbeam_propagation.m | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/gbeam_propagation.m b/gbeam_propagation.m new file mode 100644 index 0000000..524d4ae --- /dev/null +++ b/gbeam_propagation.m @@ -0,0 +1,41 @@ +function q = gbeam_propagation(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 + + if any(x_pos >= x_in) + % Forward propagation to the right of x_in + q(x_pos >= x_in) = gbeam_propagation_froward_only(x_pos(x_pos>=x_in), q_in, x_in, optics_elements); + end + + if any(x_pos < x_in) + % Backward propagation part the left of x_in + % do it as forward propagation of the reverse beam + x_backw=x_pos(x_pos<x_in); + % now let's reflect the beam with respect to x_in + % and solve the problem as forward propagating. + x_backw=x_in-x_backw; + % now we need to flip x positions + 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; + % we need to flip all optics elements around x_in as well + for i=1:length(optics_elements_backw) + optics_elements_backw{i}.x=x_in-optics_elements_backw{i}.x; + end + + q_backw = gbeam_propagation_froward_only(x_backw, q_in_backw, 0, optics_elements_backw); + % now we need to flip the radius of curvature again + q_backw = -real(q_backw) + 1i*imag(q_backw); + + % final assignment of the backwards propagating beam + % which we need to flip back + q(x_pos<x_in) = fliplr(q_backw); + end + +endfunction + |