ID:195156
 
//Title: Arc Tangent Snippet
//Credit to: Lummox JR
//Contributed by: Jtgibson


/*
Arc tangents are useful for converting x/y offsets into angles.
You can find a lot of use from them in many instances.
*/



proc/arctan(x,y)
// corresponds to standard x=cos, y=sin mapping
// tangent is y/x
if(!x && !y) return 0 // the only special case
var/a=arccos(x/sqrt(x*x+y*y))
return (y>=0)?(a):(-a)