# MathF.Atan2() Method in C# with Examples

MathF.Atan2(Single, Single) Method is used to return the angle whose tangent is the quotient of two specified numbers. Basically, it returns an angle θ (measured in radian) whose value lies between -π and π. This is a counterclockwise angle lies between the positive x-axis, and the point (x, y).

Syntax: public static float Atan2 (float y, float x);

Parameters:
y: The y coordinate of a point of type System.Single.
x: The x coordinate of a point System.Single.

Return Value: This method returns the angle Θ of type System.Single.

Note: An angle, θ(measured in radians), such that -π ≤ θ ≤ π, and tan(θ) = value1 / value2, where (value1, value2) are the points in the cartesian plane. There are two conditions for the return values:

• When the points lies in the Cartesian plane
• When the points lies on the boundaries of the quadrants

Example 1:

 `// C# program to demonstrate the  ` `// MathF.Atan2(Single, Single) Method ` `using` `System;  ` `   `  `class` `Geeks {  ` `      `  `    ``// Main method  ` `    ``public` `static` `void` `Main()  ` `    ``{  ` `        ``// using MathF.Atan2(Single, Single) Method  ` `        ``// and converting result into degree  ` `        ``Console.Write(MathF.Atan2(10f, 10f) * (180 / MathF.PI));  ` `    ``}  ` `}  `

Output:

```45
```

Example 2:

 `// C# program to demonstrate the  ` `// MathF.Atan2(Single, Single) Method ` `using` `System;  ` `   `  `class` `Geeks {  ` `      `  `    ``// Main method  ` `    ``public` `static` `void` `Main()  ` `    ``{  ` `        ``// using MathF.Atan2(Single, Single) Method  ` `        ``// and converting result into degree  ` `        ``Console.Write(MathF.Atan2(0f, -7f) * (180 / MathF.PI));  ` `    ``}  ` `}  `

Output:

```180
```

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.