DP QC DP QC ASINACOSATANATAN2TAN

From Quake Wiki

Constant definitions:

float DEG2RAD = 0.0174532925199432957692369076848861271344287188854172545609719144;
float RAD2DEG = 57.2957795130823208767981548141051703324054724665643215491602438612;
float PI      = 3.1415926535897932384626433832795028841971693993751058209749445923;

Builtin definitions:

float(float s) asin = #471; // Returns angle in radians for a given sin() value,
                            // the result is in the range -PI*0.5 to PI*0.5
float(float c) acos = #472; // Returns angle in radians for a given cos() value,
                            // the result is in the range 0 to PI
float(float t) atan = #473; // Returns angle in radians for a given tan() value,
                            //the result is in the range -PI*0.5 to PI*0.5
float(float c, float s) atan2 = #474; // Returns angle in radians for a given cos()
                                      // and sin() value pair, the result is in the
                                      // range -PI to PI (this is identical to vectoyaw
                                      // except it returns radians rather than degrees)
float(float a) tan = #475; // Returns tangent value (which is simply sin(a)/cos(a))
                           // for the given angle in radians, the result is in the
                           // range -infinity to +infinity

Useful math functions for analyzing vectors, note that these all use angles in radians (just like the cos/sin functions) not degrees unlike makevectors/vectoyaw/vectoangles, so be sure to do the appropriate conversions (multiply by DEG2RAD or RAD2DEG as needed).

Note:

  • atan2 can take unnormalized vectors (just like vectoyaw), and the function was included only for completeness (more often you want vectoyaw or vectoangles), atan2(v_x,v_y) * RAD2DEG gives the same result as vectoyaw(v)