pi=Pi//N;
theta1:=ArcTan[Tan[phi] - u/Cos[phi]];
theta2:=If[phi<pi/2,theta1,theta1+c1 pi];
theta:=If[phi<3/2 pi,theta2,theta2+c2 pi];
c1:=If[u<1,1,-1]; c2:=If[u<-1,-1,1];
bild=Plot3D[theta,{phi,0,2 pi},{u,-2,2},
PlotPoints->30,ImageSize->{400,300},
AxesLabel->{"phi","u","theta"}];