atan2.3Cg

Langue: en

Version: 341751 (ubuntu - 24/10/10)

Section: 3 (Bibliothèques de fonctions)

NAME

atan2 - returns arctangent of scalars and vectors.

SYNOPSIS

   float  atan2(float y, float x);
   float1 atan2(float1 y, float1 x);
   float2 atan2(float2 y, float2 x);
   float3 atan2(float3 y, float3 x);
   float4 atan2(float4 y, float4 x);
 
 
 
   half   atan2(half y, half x);
   half1  atan2(half1 y, half1 x);
   half2  atan2(half2 y, half2 x);
   half3  atan2(half3 y, half3 x);
   half4  atan2(half4 y, half4 x);
 
 
 
   fixed  atan2(fixed y, fixed x);
   fixed1 atan2(fixed1 y, fixed1 x);
   fixed2 atan2(fixed2 y, fixed2 x);
   fixed3 atan2(fixed3 y, fixed3 x);
   fixed4 atan2(fixed4 y, fixed4 x);
 
 
 

PARAMETERS


y
Vector or scalar for numerator of ratio of which to determine the arctangent.
x
Vector or scalar of denominator of ratio of which to determine the arctangent.

DESCRIPTION

atan2 calculates the arctangent of y/x. atan2 is well defined for every point other than the origin, even if x equals 0 and y does not equal 0.

For vectors, the returned vector contains the arctangent of each element of the input vector.

REFERENCE IMPLEMENTATION

atan2 for a float2 scalar could be implemented as an approximation like this.
   float2 atan2(float2 y, float2 x)
   {
     float2 t0, t1, t2, t3, t4;
 
 
 
     t3 = abs(x);
     t1 = abs(y);
     t0 = max(t3, t1);
     t1 = min(t3, t1);
     t3 = float(1) / t0;
     t3 = t1 * t3;
 
 
 
     t4 = t3 * t3;
     t0 =         - float(0.013480470);
     t0 = t0 * t4 + float(0.057477314);
     t0 = t0 * t4 - float(0.121239071);
     t0 = t0 * t4 + float(0.195635925);
     t0 = t0 * t4 - float(0.332994597);
     t0 = t0 * t4 + float(0.999995630);
     t3 = t0 * t3;
 
 
 
     t3 = (abs(y) > abs(x)) ? float(1.570796327) - t3 : t3;
     t3 = (x < 0) ?  float(3.141592654) - t3 : t3;
     t3 = (y < 0) ? -t3 : t3;
 
 
 
     return t3;
   }
 
 
 

PROFILE SUPPORT

atan2 is supported in all profiles but fp20.

SEE ALSO

abs, acos, asin, atan. sqrt, tan