Java atan2() Method |
-- Learning is not just about technology, but also about dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
Java Tutorial
Java Tutorial Java Introduction Java Development Environment Setup Java Basic Syntax Java Comments Java Objects and Classes Java Basic Data Types Java Variable Types Java Variable Naming Rules Java Modifier Types Java Operators Java Loop Structures β for, while, and doβ¦while Java Conditional Statements β ifβ¦else Java switch case Statement Java Number & Math Class Java Character Class Java String Class Java StringBuffer and StringBuilder Class Java Arrays Java Date and Time Java Regular Expressions Java Methods Java Constructors Java Stream, File, and IO Java Scanner Class Java Exception Handling
Java Object-Oriented
Java Inheritance Java Override/Overload Java Polymorphism Java Abstraction Java Encapsulation Java Interfaces Java Enum Java Package Java Reflection
Java Advanced Tutorial
Java Data Structures Java Collections Framework Java ArrayList Java LinkedList Java HashSet Java HashMap Java Iterator Java Object Java NIO Files Java Generics Java Serialization Java Networking Java Sending Email Java Multithreading Java Applet Basics Java Documentation Comments Java Examples Java 8 New Features Java MySQL Connection Java 9 New Features Java Quiz Java Common Libraries
Java atan2() Method
The atan2() method is used to convert rectangular coordinates (x, y) to polar coordinates (r, theta) and returns the resulting angle theta. This method calculates the phase angle theta by computing the arctangent of y/x, with a range from -pi to pi.
Syntax
double atan2(double y, double x)
Parameters
- y -- The ordinate (y-coordinate).
- x -- The abscissa (x-coordinate).
Return Value
The theta component of the point (r, theta) in polar coordinates that corresponds to the point (x, y) in Cartesian coordinates.
Example
public class Test{
public static void main(String args[]){
double x = 45.0;
double y = 30.0;
System.out.println(Math.atan2(x, y));
}
}
Compile and run the above program, the output result is:
0.982793723247329
Click to Share Notes
Write notes...
Image URL
Image Description
Share Notes
- Nickname (Required)
- Email (Required)
- Reference URL
YouTip