F focusrocker Member Sep 7, 2009 #1 I am having trouble with trig function. my code: result = atan(1) msgbox(result) the msgbox returns a result value of 0.785..... result should = 45. I have tested other trig functions, and all result seem off. what i am doing wrong?
I am having trouble with trig function. my code: result = atan(1) msgbox(result) the msgbox returns a result value of 0.785..... result should = 45. I have tested other trig functions, and all result seem off. what i am doing wrong?
Erel B4X founder Staff member Licensed User Longtime User Sep 7, 2009 #2 These functions expect radians or return radians rather than degrees. So your code should be: B4X: resultInDegrees = 180 / cpi * atan(1) msgbox(resultInDegrees) Another example: B4X: result = Sin(45 * cPI / 180) msgbox(result) '0.707 = Sqrt(2)/2
These functions expect radians or return radians rather than degrees. So your code should be: B4X: resultInDegrees = 180 / cpi * atan(1) msgbox(resultInDegrees) Another example: B4X: result = Sin(45 * cPI / 180) msgbox(result) '0.707 = Sqrt(2)/2