Funkcja asin () w C ++ zwraca odwrotny sinus liczby w radianach.
Ta funkcja jest zdefiniowana w pliku nagłówkowym.
(Matematyka) sin -1 x = asin (x) (W programowaniu w C ++);
asin () prototyp (w standardzie C ++ 11)
podwójne asin (podwójne x); float asin (float x); długi podwójny asin (długi podwójny x); podwójny asin (T x);
asin () Parametry
Funkcja asin () przyjmuje jeden obowiązkowy argument z zakresu (-1, 1) .
Dzieje się tak, ponieważ wartość sinusa mieści się w przedziale od 1 do -1.
asin () Wartość zwracana
Biorąc pod uwagę, że argument należy do zakresu (-1, 1), funkcja asin () zwraca wartość z zakresu (-π / 2, π / 2) .
Jeśli argument jest większy niż 1 lub mniejszy niż -1, asin () zwraca NaN
tj. Nie jest liczbą.
Parametr (x) | Wartość zwracana |
---|---|
x = (-1, 1) | (-π /, π / 2) w radianach |
-1> x lub x> 1 | NaN (nie jest liczbą) |
Przykład 1: Jak działa asin ()?
#include #include using namespace std; int main() ( double x = 0.25, result; result = asin(x); cout << "asin(x) = " << result << " radians" << endl; // result in degrees cout << "asin(x) = " << result*180/3.1415 << " degrees" << endl; return 0; )
Po uruchomieniu programu wynik będzie następujący:
asin (x) = 0,25268 radianów asin (x) = 14,4779 stopni
Przykład 2: funkcja asin () z typem całkowitym
#include #include #define PI 3.141592654 using namespace std; int main() ( int x = 1; double result; result = asin(x); cout << "asin(x) = " << result << " radians" << endl; // Converting result to degrees cout << "asin(x) = " << result*180/PI << " degrees"; return 0; )
Po uruchomieniu programu wynik będzie następujący:
asin (x) = 1,5708 radianów asin (x) = 90 stopni