.atan2()
Published Jul 20, 2021Updated Aug 24, 2022
Contribute to Docs
The Math.atan2()
method returns the counterclockwise angle, in radians, between a (x,y) point and the positive x-axis.
Syntax
Math.atan2(y, x)
Note that the order of arguments is first the Y coordinate, then the X coordinate.
Example
Use Math.atan2()
to return the angle of point (0.0, 1.0)
and the x-axis:
public class Main {public static void main(String[] args) {double x = 0.0;double y = 1.0;System.out.println(Math.atan2(y, x));// Output: 1.5707963267948966}}
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Java on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Java
Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.Beginner Friendly17 hours