function th_target = theta_target(beta,theta_optimum,theta_max)

th_target = 0;
if(abs(beta) <= theta_optimum)
   th_target = 0;
end
if( (abs(beta) > theta_optimum) && (abs(beta) <= theta_max) )
   th_target = (abs(beta)-theta_optimum)*theta_max/(theta_max-theta_optimum);
end
if( (abs(beta) <= (pi-theta_optimum)) && (abs(beta) > (theta_max)) )
   th_target = theta_max;
end
if(abs(beta) > pi-theta_optimum)
   th_target = theta_max-(abs(beta)-(pi-theta_optimum))*theta_max/theta_optimum;
end
th_target = th_target*sign(beta);