If you use the following at evolution page:
dvx/dt =  f/m*Math.cos(cta+pi/2)
dvy/dt = f/m*Math.sin(cta+pi/2)

But the above equations need "cta" value during the evolution page.
If you use cta at constraint page, the "cta" will be at t-dt;
You will find much larger calculation error.
It has something to do with how the evolution were done numerically.
The program need to calculate several values between t to t+dt to know how to changed variables to next time step with high preission (You can check out [u]Runge-Kutta's 4-th order method[/u] if you are interested in how it was done).


If you do not like xid;
You can also define two functions:
public double calfx(double vx,double vy){
cta=Math.atan2(vy,vx);
return f*Math.cos(cta+pi/2);
else return f*Math.sin(cta+pi/2);
}
public double calfy(double vx,double vy){
cta=Math.atan2(vy,vx);
return f*Math.sin(cta+pi/2);
}

combined with
dvx/dt =  (fx=calfx(vx,vy)/m);
dvy/dt = ( fy=calfy(vx,vy)/m);