Math.cos()提供了错误的结果 [英] Math.cos() delivers wrong result

查看:121
本文介绍了Math.cos()提供了错误的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用cos函数从给定角度计算cosinus,但结果与我的计算器不同,后者设置为度。

I'm using the cos-function to calculate cosinus from an given angle, but the result is different to my calculator, which is set to degree.

angle: -42.5367183824978 
Math.cos(angle)  -> 0.12489059200057782

应该是:0.74

出了什么问题?

推荐答案

Math.cos()假设为弧度,转换为弧度:

Math.cos() assumes radians, to convert to radians:

var rad = angle * Math.PI / 180

这篇关于Math.cos()提供了错误的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆