atan2

Navigation:  Language Reference > Functions > Trigonometric >

atan2

Previous pageReturn to chapter overviewNext page

Syntax

R = atan2(Y,X);

Description

This is the four quadrant arctangent of the elements of Y and X. Unlike arctangent function, atan2 does distinguish between diametrically opposite directions.

Examples

X, Y

arctan(Y/X);

atan2(Y, X);

1,1

π/4

π/4

-1,-1

π/4

−3π/4

0,1

-

π/2

0,0

-

set to 0 instead of undefined.

 

y = sin(time);

x = cos(time);

r = atan2(y,x);

 

X = [ramp(0);ramp(1)];

Y = [1;1];

R = atan2(Y,X);

Limitations

r, x and y must have the same size. It produces results in the range (−π, π].

Atan2(0, 0) is defined as 0 instead of undefined.