aboutsummaryrefslogtreecommitdiff
path: root/abcd2self_repeating_q.m
blob: cd60aafe19365723826deed1d174d6115ab7cf64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function [q] = abcd2self_repeating_q( abcd_cavity )
% this find q such that q = (A*q+B)/(C*q+D)
% i.e q after abcd is exactly the same
% very handy for cavity mode calculations

% spelling out abcd coefficients
[A, B, C, D] = abcd2ABCD( abcd_cavity );

if ~isCavityStable(abcd_cavity)
    display('ABCD is unstable !');
    display('We should stop now. There is no stable self-repeating mode with such ABCD');
    error('Not possible to calculate a self-repeating mode with the unstable ABCD');
end

% q is the solution of quadratic equation, we chose one with positive waist size
q = ( -(D-A) - sqrt( (D-A)^2 + 4*C*B ) ) / (2*C);

end