本文介绍了将Math.sin(x)的结果转换为Java中度的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Math.sin(x)(其中x以弧度表示)转换为以x为度而不是弧度的结果.

I would like to convert the Math.sin(x), where x in radians to a result which will give me as x in degrees not radians.

我已经使用了普通的方法和度数和弧度之间的java内置方法进行转换,但是我传递给Math.sin()方法的任何参数都被视为弧度,从而使转换工作徒劳无功.

I have used the normal method and java built in method of conversion between degrees and radians, but any argument I pass to the Math.sin() method is being treated as radians, thereby causing my conversion to be a futile effort.

我希望给定sin输入的输出,就好像输入的度数不是Math.sin()方法那样以弧度表示.

I want the output of a sin Input to be given as if the input is treated in degrees not radians like the Math.sin() method does.

推荐答案

Java的Math库为您提供了在度和弧度之间转换的方法: toRadians toDegrees :

Java's Math library gives you methods to convert between degrees and radians: toRadians and toDegrees:

public class examples
{
    public static void main(String[] args)
    {
         System.out.println( Math.toRadians( 180 ) ) ;
         System.out.println( Math.toDegrees( Math.PI ) ) ;
    }
}

如果输入的单位是度,则需要将输入到sin的数字转换为弧度:

If your input is in degrees, you need to convert the number going in to sin to radians:

double angle = 90 ;
double result  = Math.sin( Math.toRadians( angle ) ) ;
System.out.println( result ) ;

这篇关于将Math.sin(x)的结果转换为Java中度的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 11:23