Returns the arctangent of two values (x,y).

ret atan2(y, x)





[in] The y value.


[in] The x value.


Return Value

The arctangent of (y,x).


The signs of the x and y parameters are used to determine the quadrant of the return values within the range of -Π to Π. The atan2 HLSL intrinsic function is well-defined for every point other than the origin, even if y equals 0 and x does not equal 0.

Type Description

Name Template Type Component Type Size
ysame as input x float same dimension(s) as input x
xscalar, vector, or matrix float any
retsame as input x float same dimension(s) as input x


Minimum Shader Model

This function is supported in the following shader models.

Shader ModelSupported
Shader Model 2 (DirectX HLSL) and higher shader modelsyes
Shader Model 1 (DirectX HLSL) vs_1_1


See also

Intrinsic Functions (DirectX HLSL)