TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

C++ Math atan2() Function

C++ Math atan2() Function with tutorial for beginners and professionals with examples on isgreaterequal(), less(), islessequal(), islessgreater(), isunordered(), exp(), frexp(), ldexp(), log(), log10(), modf(), exp2(), expm1(), log1p(), log2(), logb(), scalbn(), scalbln() etc.

<< Back to CPP

C++ Math atan2()

The function finds the inverse tangent of a coordinate.

Suppose the coordinate is (x,y):

atan2(y,x) = tan-1(y/x);

Syntax

Suppose the coordinate is (x,y). Syntax would be:

float atan2(float y, float x);
double atan2(double y, double x);
long double atan2(long double y, long double x);
Promoted atan2(Arithmetic1 y, Arithmetic x );

Parameter

y: It represents the y-coordinate value.

x: It represents the x-coordinate value.

Return value

It returns the value in the range[-?, ?] and if the values of both x and y are zero then it returns zero value.

  • If any argument is of integral type, it is cast to double.
  • If any argument is of long double type, it is cast to long double.

Example 1

Let's see a simple example when both x and y are zero.

#include 
#include
using namespace std;
int main()
{
    int x=0;
    int y=0;
    cout<<"Value of tan(y/x) is : "<

Output:

Value of tan(y/x) is : 0
Value of tan-1(y/x) is : 0

In this example, atan2() calculates the inverse tangent when both 'x' and 'y' are zero.

Example 2

Let's see a simple example when both 'x' and 'y' are of different type.

#include 
#include
using namespace std;
int main()
{
    int x=6;
    float y=7.8;
    cout<<"Value of tan(y/x) is : "<

Output:

Value of tan(y/x) is : 3.6021
Value of tan1(y/x) is : 0.915101

In this example, atan2() function finds the inverse of a tangent when x is of integer type and y is of float type.


Next TopicC++ Math Functions




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf