This shows you the differences between two versions of the page.
— |
cpp:cmath:atan2 [2024/02/16 01:04] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | {{keywords>wiki library source code example reference}} | ||
+ | ====== atan2 ====== | ||
+ | |||
+ | <code cpp> | ||
+ | double atan2(double , double ); | ||
+ | </code> | ||
+ | calculates arctangent from 2 numbers | ||
+ | |||
+ | ===== cpp Sourcecode Example ===== | ||
+ | |||
+ | <code cpp> | ||
+ | #include <iostream> /* including standard library */ | ||
+ | #include <cmath> /* including math library */ | ||
+ | |||
+ | using namespace std; | ||
+ | int main ( void ){ | ||
+ | double a=1.2, b=-2.6, res; | ||
+ | res = atan2(a, b) * 90 / 3.17; | ||
+ | |||
+ | //cout.setf(ios::fixed, ios::floatfield); | ||
+ | cout.precision(7); | ||
+ | |||
+ | cout << "atan2 from " << a << " and " << b << " is " << res << endl; | ||
+ | return 0; | ||
+ | } | ||
+ | </code> | ||
+ | ===== output ===== | ||
+ | atan2 from 1.2 and -2.6 is 76.91692 | ||