如何获得用户友好的值三角函数? [英] How to get user friendly values for trigonometric functions?
问题描述
我正在开发Android应用程序。数学计算。在那里,我有一个像正弦,余弦,谭应表现出各自的三角值一些按钮,对于我使用java.lang.Math类中的相应方法和工作正常。但是,一些测试中,我才知道,之后,它显示了一些成果如下:
I am developing an android app. for mathematical calculations. There I have some buttons like sin,cos,tan which should show their respective trigonometric values, for that I am using corresponding methods of java.lang.Math class and that works fine. But after some tests I came to know that, it shows some results as follows
sin(90)=0.89399........ //I want it to show 1
cos(90)=-0.44807........ //I want it to show 0
tan(90)=-1.995200...... //I want it to show Infinity as sin(90)/cos(90)=1/0=Infinity
像上述例子有许多其显示这样的效果。我应该怎么做这样来的结果如上所述。请帮我。
Like the above examples there are many which show results like this. What should I do this for getting the results as mentioned above. Please help me.
推荐答案
您的问题是,Java使用弧度的不度的。你有角度变换首先弧度。
Your problem is that java uses radians and not degrees. You have to convert the angle to rad first.
Double rad = degrees /180 * pi;
这篇关于如何获得用户友好的值三角函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!