英文:
trying to calculate vectors with java
问题
我对Java数学和一般数学有一个快速的问题。因此,763.5*cos(70)应该等于261.13237,这是Ax向量的计算方式,然而,在Java中,答案似乎是483.53921155638994。不知道为什么。任何帮助都将不胜感激。
以下是您目前的代码:
package Main;
import java.util.Scanner;
import java.lang.Math;
public class vectors{
public static void main(String[] args) {
double Mag = 763.5;
double Deg = 70;
double Ax;
double Ay;
Ax = Mag*Math.cos(Deg);
System.out.println(Ax);
}
}
英文:
I had a quick question about java math and a little bit about math in general. so 763.5*cos(70) should in equal to 261.13237 that's how the Ax vector is calculated, however, in java the answer seems to be 483.53921155638994. no idea why. any help is much appreciated
here is what I have so far
package Main;
import java.util.Scanner;
import java.lang.Math;
public class vectors{
public static void main(String[] args) {
double Mag = 763.5;
double Deg = 70;
double Ax;
double Ay;
Ax = Mag*Math.cos(Deg);
System.out.println(Ax);
}
}
答案1
得分: 1
Math.cos()的参数单位是弧度:
double Mag = 763.5;
double Deg = 70;
double radians = (Deg / 360) * 2 * Math.PI;
double Ax;
double Ay;
Ax = Mag * Math.cos(radians);
System.out.println(Ax);
261.13237942914816
英文:
Math.cos()'s argument is in radians:
double Mag = 763.5;
double Deg = 70;
double radians = (Deg / 360) * 2 * Math.PI;
double Ax;
double Ay;
Ax = Mag*Math.cos(radians);
System.out.println(Ax);
261.13237942914816
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论