%
%
function [f1,f2,f3]= bobs_fopt_a(beta,s,t,flg)
%
%  s = [r u v]'
%
T = 0.1405; md = 0.07489; rf = 1.5237;
a = T/(1-md*t);
r = s(1); u = s(2); v = s(3); theta = s(4);
c = cos(beta); si = sin(beta); 
%
if flg == 1
   f1 = [u; v^2/r-1/r^2+a*si;-u*v/r+a*c; v/r];  
elseif flg == 2
   f1 = [t; r-rf; u; v-1/sqrt(rf)]; f2 = [0 0 0 0; 1 0 0 0; 0 1 0 0; 0 0 1 0]; f3 = [1; 0 ; 0; 0];
elseif flg == 3
    f1 = [0 1 0 0; -(v/r)^2+2/r^3 0 2*v/r 0; u*v/r^2 -v/r -u/r 0; 0 0 0 0];
    f2 = [0; a*c; -a*si; 0];
end;
      