(since C11) double asin (double arg ); (2) (3) long double asin (long double arg ). If no errors occur, the arc sine of arg (arcsin(arg)). Applies the function std::asin to each element of valarray (function template) C documentation for asin. C library function - asin - The C library function double asin(double x) returns the arc sine of x in radians.
Trigonometric functions in C — and, indeed, in all programming languages — use radians, not degrees. What’s a radian? Glad you asked. A radian is a measurement of a circle, or, specifically, an arc. It uses the value ð (pi) instead of degrees, where ð is a handy circle measurement.
So instead of a circle having 360 degrees, it has 2ð radians. That works out to 6.2831 (which is 2 × 3.1415) radians in a circle.
For your trigonometric woes, one radian equals 57.2957795 degrees, and one degree equals 0.01745329 radians. So when you do your trig math, you need to translate between human degrees and C language radians.
CONVERT DEGREES TO RADIANS
Exercise 1: Type the source code from Convert Degrees to Radians into your editor. Line 10 is split so that it’s more readable on this page. You don’t need to split that line when you type it. Build and run. Test with the value 180, which should be equal to ð radians (3.14).
Exercise 2: Write a program that converts from radians to degrees.
Though C has many trigonometric functions, the three basic ones are sin(), cos(), and tan(), which calculate the sine, cosine, and tangent of an angle, respectively. Remember that those angles are measured in radians, not degrees.
Oh, and remember that you need the math.h header file to make the compiler happy about using the trig functions.
HAVING FUN WITH TRIGONOMETRY
Exercise 3: Type the source code from Having Fun with Trigonometry into your editor. Before you build and run, try to guess what the output could be.
Exercise 4: Modify the code from Having Fun with Trigonometry so that a cosine wave is displayed. Don’t get lazy on me! A cosine wave looks best when you cycle from 0 to 2ð. Modify your code so that you get a good, albeit character-based, representation of the curve.
No, Exercise 4 isn’t easy. You need to compensate for the negative cosine values when drawing the graph.
Description
The C library function double asin(double x) returns the arc sine of x in radians.
Declaration
Following is the declaration for asin() function.
ParametersDev C++ 5.11
Return Value
This function returns the arc sine of x, in the interval [-pi/2,+pi/2] radians.
Example
The following example shows the usage of asin() function.
Dev C++ For Windows 10
Let us compile and run the above program that will produce the following result −
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2020
Categories |