Open In App
Related Articles

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

Improve Article
Improve
Save Article
Save
Like Article
Like

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
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 10 May, 2020
Like Article
Save Article
Previous
Next
Similar Reads