From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/numeric%2Fmath%2Fatan2.html | 103 ++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 devdocs/c/numeric%2Fmath%2Fatan2.html (limited to 'devdocs/c/numeric%2Fmath%2Fatan2.html') diff --git a/devdocs/c/numeric%2Fmath%2Fatan2.html b/devdocs/c/numeric%2Fmath%2Fatan2.html new file mode 100644 index 00000000..94dcdd22 --- /dev/null +++ b/devdocs/c/numeric%2Fmath%2Fatan2.html @@ -0,0 +1,103 @@ +

atan2, atan2f, atan2l

Defined in header <math.h>
float       atan2f( float y, float x );
+
(1) (since C99)
double      atan2( double y, double x );
+
(2)
long double atan2l( long double y, long double x );
+
(3) (since C99)
_Decimal32  atan2d32( _Decimal32 y, _Decimal32 x );
+
(4) (since C23)
_Decimal64  atan2d64( _Decimal64 y, _Decimal64 x );
+
(5) (since C23)
_Decimal128 atan2d128( _Decimal128 y, _Decimal128 x );
+
(6) (since C23)
Defined in header <tgmath.h>
#define atan2( y, x )
+
(7) (since C99)
+1-6) Computes the arc tangent of y / x using the signs of arguments to determine the correct quadrant.
+7) Type-generic macro: If any argument has type long double, (3) (atan2l) is called. Otherwise, if any argument has integer type or has type double, (2) (atan2) is called. Otherwise, (1) (atan2f) is called.
+ +

The functions (4-6) are declared if and only if the implementation predefines __STDC_IEC_60559_DFP__ (i.e. the implementation supports decimal floating-point numbers).

+
(since C23)

Parameters

+ +
x, y - floating-point value

Return value

If no errors occur, the arc tangent of y / x (arctan(y/x)) in the range [-π ; +π] radians, is returned.
Y argument
Return value
math-atan2.png
X argument

If a domain error occurs, an implementation-defined value is returned.

+

If a range error occurs due to underflow, the correct result (after rounding) is returned.

+

Error handling

Errors are reported as specified in math_errhandling.

+

Domain error may occur if x and y are both zero.

+

If the implementation supports IEEE floating-point arithmetic (IEC 60559):

+

Notes

atan2(y, x) is equivalent to carg(x + I*y).

+

POSIX specifies that in case of underflow, y / x is the value returned, and if that is not supported, an implementation-defined value no greater than DBL_MIN, FLT_MIN, and LDBL_MIN is returned.

+

Example

#include <math.h>
+#include <stdio.h>
+ 
+int main(void)
+{
+    // normal usage: the signs of the two arguments determine the quadrant
+    // atan2(1,1) = +pi/4, Quad I
+    printf("(+1,+1) cartesian is (%f,%f) polar\n", hypot( 1, 1), atan2( 1, 1));
+    // atan2(1, -1) = +3pi/4, Quad II
+    printf("(+1,-1) cartesian is (%f,%f) polar\n", hypot( 1,-1), atan2( 1,-1));
+    // atan2(-1,-1) = -3pi/4, Quad III
+    printf("(-1,-1) cartesian is (%f,%f) polar\n", hypot(-1,-1), atan2(-1,-1));
+    // atan2(-1,-1) = -pi/4, Quad IV
+    printf("(-1,+1) cartesian is (%f,%f) polar\n", hypot(-1, 1), atan2(-1, 1));
+ 
+    // special values
+    printf("atan2(0, 0) = %f atan2(0, -0)=%f\n", atan2(0,0), atan2(0,-0.0));
+    printf("atan2(7, 0) = %f atan2(7, -0)=%f\n", atan2(7,0), atan2(7,-0.0));
+}

Output:

+
(+1,+1) cartesian is (1.414214,0.785398) polar
+(+1,-1) cartesian is (1.414214,2.356194) polar
+(-1,-1) cartesian is (1.414214,-2.356194) polar
+(-1,+1) cartesian is (1.414214,-0.785398) polar
+atan2(0, 0) = 0.000000 atan2(0, -0)=3.141593
+atan2(7, 0) = 1.570796 atan2(7, -0)=1.570796

References

See also

+ + + + +
+
(C99)(C99)
computes arc sine (\({\small\arcsin{x} }\)arcsin(x))
(function)
+
(C99)(C99)
computes arc cosine (\({\small\arccos{x} }\)arccos(x))
(function)
+
(C99)(C99)
computes arc tangent (\({\small\arctan{x} }\)arctan(x))
(function)
+
(C99)(C99)(C99)
computes the phase angle of a complex number
(function)
C++ documentation for atan2
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/numeric/math/atan2 +

+
-- cgit v1.2.3