Griffin
Griffin

Reputation: 2517

cmath asin() problems

Hey so i managed to locate the problem in some graphics math i am coding, and apparently when i reach this line of code: float test3= asin(test2); where test2= 0.017409846.

to my understanding 'asin' is 'arc sin' which is 'inverse sin' (what i want) the result of this line of code however is test3 = 0.017410725. when plugging this into my calculator inverse sine of test2 is .997561.

Why isn't asin working?? thanks!

Upvotes: 0

Views: 1306

Answers (3)

lccarrasco
lccarrasco

Reputation: 2051

arcsine return value is expressed in radians, not in degrees (your calculator is probably set to display degrees).

Upvotes: 1

Cat Plus Plus
Cat Plus Plus

Reputation: 129964

It is working, you're using wrong units. asin takes radians, and your calculator is probably in degrees mode.

Upvotes: 1

Greg Hewgill
Greg Hewgill

Reputation: 994589

Your calculator is set to degrees mode. The asin() function returns radians.

Degrees and radians are related by the formula:

degrees = (180/π) * radians

Upvotes: 7

Related Questions