Calculate arc tangent of a value in R programming – atan2(y, x) function

With the help of atan2(y, x) method, we can get the arc tangent between x axis and a vector from origin to (x, y) in R programming.

Syntax: atan2(y, x)
Return: Returns the arc tangent value.

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

x <- c(2, 3, 4)
  
# Using atan2(y, x) method
gfg <- atan2(1, x)
  
print(gfg)

chevron_right


Output:

[1] 0.4636476 0.3217506 0.2449787

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

x <- c(2, 3, 1)
  
# Using atan2(y, x) method
gfg <- atan2(pi/3, x)
  
print(gfg)

chevron_right


Output:

[1] 0.4823479 0.3358424 0.8084488
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.