YouTip LogoYouTip

Number Atan2

Java atan2() Method |

-- Learning is not just about technology, but also about dreams!

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 switch case Statement

Java Character Class

Java atan2() Method

Java Number Class Java Number Class


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

Java Number Class Java Number Class

Java switch case Statement

Java Character Class

iFlytek Star Coding Plan includes free model call quota, DeepSeek, GLM, Kimi, MiniMax, one-stop experience and deployment platform. Configuration Guide Β₯3.9/ month Subscribe Now

Click to Share Notes

Cancel

Write notes...

Image URL

Image Description

Image Size Γ—

Share Notes

  • Nickname (Required)
  • Email (Required)
  • Reference URL

Category Navigation

← Pandas JsonMet Win Getselection β†’