and if you insist on using ur own trigonometry you need to write an atan2 function which'll return between +-180 (unless you have the latest A7 private-beta).
it just so happens i have one in my back-pocket (changed to work with c-script but untested):
Code:
function atan2(var x,var y)
{
if(y==0)
{
return (90*sign(x));
}
return(atan(x/y) - (180 * (y<0)));
}
julz