December 2005
Beginner to intermediate
618 pages
20h 19m
English
asin
Calculates the inverse sine of a number
#include <math.h> doubleasin( doublex); floatasinf( floatx); (C99) long doubleasinl( long doublex); (C99)
asin() implements the
inverse sine function, commonly called arc
sine. The argument x must be
between -1 and 1, inclusive: -1 ≤ x ≤ 1.
If x is outside the function’s
domain—that is, if x is greater than 1 or
less than −1—the function incurs a domain error.
The return value is given in radians, and is thus in the range
-π/2 ≤ asin(x) ≤ π/2.
/*
* Calculate the altitude of the sun (its angle upward from the horizon)
* given the height of a vertical object and the length of the object's
* shadow.
*/
#define PI 3.141593
#define DEG_PER_RAD (180.0/PI)
float height = 2.20F;
float length = 1.23F;
float altitude =asinf( height / sqrtf( height*height + length*length ));
printf( "The sun's altitude is %2.0f\xB0.\n", altitude * DEG_PER_RAD );This code produces the following output:
The sun's altitude is 61°.
Arcsine functions for complex numbers: casin(), casinf(), and casinl()
Read now
Unlock full access