atan2, atan2f, atan2l
|
Definiert in Header
<math.h>
|
||
|
float
atan2f
(
float
y,
float
x
)
;
|
(1) | (seit C99) |
|
double
atan2
(
double
y,
double
x
)
;
|
(2) | |
|
long
double
atan2l
(
long
double
y,
long
double
x
)
;
|
(3) | (seit C99) |
|
_Decimal32 atan2d32
(
_Decimal32 y, _Decimal32 x
)
;
|
(4) | (seit C23) |
|
_Decimal64 atan2d64
(
_Decimal64 y, _Decimal64 x
)
;
|
(5) | (seit C23) |
|
_Decimal128 atan2d128
(
_Decimal128 y, _Decimal128 x
)
;
|
(6) | (seit C23) |
|
Definiert in Header
<tgmath.h>
|
||
|
#define atan2( y, x )
|
(7) | (seit C99) |
atan2l
) wird aufgerufen. Andernfalls, wenn ein Argument ganzzahligen Typ oder den Typ
double
hat,
(2)
(
atan2
) wird aufgerufen. Andernfalls
(1)
(
atan2f
) wird aufgerufen.
|
Die Funktionen
(4-6)
werden genau dann deklariert, wenn die Implementierung
|
(seit C23) |
Inhaltsverzeichnis |
Parameter
| x, y | - | Gleitkommawert |
Rückgabewert
If no errors occur, the arc tangent of y / x ( arctan(| y |
| x |
Wenn ein Domänenfehler auftritt, wird ein implementierungsdefinierter Wert zurückgegeben.
Wenn ein Bereichsfehler aufgrund von Unterlauf auftritt, wird das korrekte Ergebnis (nach Rundung) zurückgegeben.
Fehlerbehandlung
Fehler werden gemeldet, wie in
math_errhandling
festgelegt.
Ein Domänenfehler kann auftreten, wenn x und y beide null sind.
Wenn die Implementierung IEEE-Gleitkommaarithmetik (IEC 60559) unterstützt:
- Wenn x und y beide null sind, tritt kein Domänenfehler auf;
- Wenn x und y beide null sind, tritt auch kein Wertebereichsfehler auf;
- Wenn y null ist, tritt kein Polfehler auf;
-
Wenn
y
±0ist und x negativ oder-0ist, wird±πzurückgegeben; -
Wenn
y
±0ist und x positiv oder+0ist, wird±0zurückgegeben; -
Wenn
y
±∞ist und x endlich ist, wird±π/2zurückgegeben; -
Wenn
y
±∞ist und x-∞ist, wird±3π/4zurückgegeben; -
Wenn
y
±∞ist und x+∞ist, wird±π/4zurückgegeben; -
Wenn
x
±0ist und y negativ ist, wird-π/2zurückgegeben; -
Wenn
x
±0ist und y positiv ist, wird+π/2zurückgegeben; -
Wenn
x
-∞ist und y endlich und positiv ist, wird+πzurückgegeben; -
Wenn
x
-∞ist und y endlich und negativ ist, wird-πzurückgegeben; -
Wenn
x
+∞ist und y endlich und positiv ist, wird+0zurückgegeben; -
Wenn
x
+∞ist und y endlich und negativ ist, wird-0zurückgegeben; - Wenn entweder x NaN oder y NaN ist, wird NaN zurückgegeben.
Hinweise
atan2 ( y, x ) entspricht carg ( x + I * y ) .
POSIX spezifiziert , dass im Fall eines Underflows y / x als Rückgabewert verwendet wird, und falls dies nicht unterstützt wird, ein implementierungsdefinierter Wert zurückgegeben wird, der nicht größer als DBL_MIN , FLT_MIN und LDBL_MIN ist.
Beispiel
#include <math.h> #include <stdio.h> int main(void) { // normale Verwendung: Die Vorzeichen der beiden Argumente bestimmen den Quadranten // atan2(1,1) = +pi/4, Quadrant I printf("(+1,+1) kartesisch ist (%f,%f) polar\n", hypot( 1, 1), atan2( 1, 1)); // atan2(1, -1) = +3pi/4, Quadrant II printf("(+1,-1) kartesisch ist (%f,%f) polar\n", hypot( 1,-1), atan2( 1,-1)); // atan2(-1,-1) = -3pi/4, Quadrant III printf("(-1,-1) kartesisch ist (%f,%f) polar\n", hypot(-1,-1), atan2(-1,-1)); // atan2(-1,-1) = -pi/4, Quadrant IV printf("(-1,+1) kartesisch ist (%f,%f) polar\n", hypot(-1, 1), atan2(-1, 1)); // spezielle Werte 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)); }
Ausgabe:
(+1,+1) kartesisch ist (1.414214,0.785398) polar (+1,-1) kartesisch ist (1.414214,2.356194) polar (-1,-1) kartesisch ist (1.414214,-2.356194) polar (-1,+1) kartesisch ist (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
Referenzen
- C23-Standard (ISO/IEC 9899:2024):
-
- 7.12.4.4 Die atan2-Funktionen (S.: TBD)
-
- 7.25 Typgenerische Mathematik <tgmath.h> (S.: TBD)
-
- F.10.1.4 Die atan2-Funktionen (S.: TBD)
- C17-Standard (ISO/IEC 9899:2018):
-
- 7.12.4.4 Die atan2-Funktionen (S: 174)
-
- 7.25 Typgenerische Mathematik <tgmath.h> (S: 272-273)
-
- F.10.1.4 Die atan2-Funktionen (S: 378)
- C11-Standard (ISO/IEC 9899:2011):
-
- 7.12.4.4 Die atan2-Funktionen (S: 239)
-
- 7.25 Typgenerische Mathematik <tgmath.h> (S: 373-375)
-
- F.10.1.4 Die atan2-Funktionen (S: 519)
- C99-Standard (ISO/IEC 9899:1999):
-
- 7.12.4.4 Die atan2-Funktionen (S. 219)
-
- 7.22 Typgenerische Mathematik <tgmath.h> (S. 335-337)
-
- F.9.1.4 Die atan2-Funktionen (S. 456)
- C89/C90 Standard (ISO/IEC 9899:1990):
-
- 4.5.2.4 Die atan2-Funktion
Siehe auch
|
(C99)
(C99)
|
berechnet den Arkussinus (
arcsin(x)
)
(Funktion) |
|
(C99)
(C99)
|
berechnet den Arkuskosinus (
arccos(x)
)
(Funktion) |
|
(C99)
(C99)
|
berechnet den Arkustangens (
arctan(x)
)
(Funktion) |
|
(C99)
(C99)
(C99)
|
berechnet den Phasenwinkel einer komplexen Zahl
(Funktion) |
|
C++-Dokumentation
für
atan2
|
|