我使用的是Math.cos和Math.sin,但它返回的结果出乎意料,如下所示:
Angle Sin Cos
354 0.8414 -0.5403
352 0.1411 0.98998
350 -0.958 -0.2836为什么我会得到这些结果?
发布于 2012-12-19 19:15:05
你是在尝试使用学位吗?请记住,sin和cos预期的是弧度。
Math.cos(Math.toRadians(354))发布于 2012-12-19 19:15:14
Math.cos和Math.sin学习的是angles in radians,而不是学位。因此,您可以使用:
double angleInDegree = 354;
double angleInRadian = Math.toRadians(angleInDegree);
double cos = Math.cos(angleInRadian); // cos = 0.9945218953682733发布于 2012-12-19 19:16:00
public static double sin(double a)
Parameters:
a - an angle, in radians.
Returns:
the sine of the argument.https://stackoverflow.com/questions/13951136
复制相似问题