function [w0, z0] = cavity_abcd2its_waist_and_position( abcd_cavity, lambda, cavity_length ) display('WARNING: cavity_abcd2its_waist_and_position sometimes it gives crazy results'); display('WARNING: it is sensitive to lens, mirrors order.'); display('WARNING: You better double check results or better fix the logic of this code'); % Notation follows % % "Laser resonators with several mirrors and lenses with the bow-tie laser % resonator with compensation for astigmatism and thermal lens effects as an % example" by Haim Abitan and Torben Skettrup 2005 J. Opt. A: Pure Appl. Opt. 7 7 % doi:10.1088/1464-4258/7/1/002 % http://dx.doi.org/10.1088/1464-4258/7/1/002 % spelling out abcd coefficients [A, B, C, D] = abcd2ABCD( abcd_cavity ); if ~isCavityStable(abcd_cavity) display('Cavity is unstable !'); display('We should stop now. There is no stable mode in this cavity'); error('Not possible to calculate a cavity mode in the unstable cavity'); end % stability parameter see eq.4 u = (A+D+2)/4; % resonator waist eq.10 w0 = sqrt ( 2*lambda/(pi*abs(C))*sqrt(u*(1-u)) ); % resonator waist location along 1st arm eq.11 z0 = (A-D)/(2*C); % Everything is periodic with respect to cavity length % so by taking modulus with respect to its length % we get rid of nasty virtual waist condition z0 = mod(z0, cavity_length); end