[英]Why is the Cos function in C# giving me wrong answers?
I have a method, in which I am using the Cos() Function from the namespace "Mathf".我有一个方法,我使用命名空间“Mathf”中的 Cos() Function。 Sadly, when I give, for example the in put of 45 it returns 0,52532 , which is wrong.
可悲的是,当我给出例如45的输入时,它返回0,52532 ,这是错误的。 Using a calculator I get the correct answer of 6.283185 Radians.
使用计算器,我得到了6.283185弧度的正确答案。
float angle = 45;
Debug.Log(Mathf.Cos(angle));
Prints out:打印出来:
0,525322
Can anyone help me out here?有谁可以帮我离开这里吗? I am very confused right now
我现在很困惑
You need to convert to radians.您需要转换为弧度。
float angle = 45;
Debug.Log(Mathf.Cos(angle * Math.PI / 180.0f));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.