Skip to content
Related Articles

Related Articles

Improve Article
Calculate arc tangent of a value in R programming – atan2(y, x) function
  • Last Updated : 10 May, 2020

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:




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

Output:

[1] 0.4636476 0.3217506 0.2449787

Example 2:




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

Output:

[1] 0.4823479 0.3358424 0.8084488
My Personal Notes arrow_drop_up
Recommended Articles
Page :