我知道如何开始,我知道如何放入扫描仪和所有东西,但在学校里,我从来没有真正了解经度和纬度公式以及如何将这些点转换为弧度。所以我几乎被困在这个Java问题上。这是我到目前为止所拥有的:
import java.util.*;
class DistanceCalculator {
// Radius of the earth in km; this is the class constant.
public static final double Radius = 6372.795;
/**
* This program computes the spherical distance between two points on the surface of the Earth.
*/
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
intro();
System.out.print("Longitude (degrees.minutes) ");
double Longitude = console.nextDouble();
System.out.print("Latitude (degrees.minutes) ");
double Latitude = console.nextDouble();
}
public static double distFrom(double lat1, double lng1, double lat2, double lng2);
double Latitude = Math.toRadians(...);
}
public static void intro() {
System.out.println("This program computes the spherical distance between two points on the surface of the Earth.");
System.out.println("\tPlease start by entering the longitude and the latitude of location 1.");
}
}
在 Java IDE 中,他们说intro();
没有使用经度和纬度点(下面的),我知道为什么,因为我还没有真正定义它们。我知道我错过了经度和纬度的公式。在我的书中,它要我使用余弦的球面定律,由于我在学校从未学过这个,所以无论我如何从我寻找的网站上学习这个公式,我都不知道如何转移它成Java语言。
另一个问题是,如何将度数和分钟数从经度/纬度点转换为弧度?我必须使用Math.toRadians
东西吗?哦,是的,而且,我的答案必须以公里为单位。
更新:你们中的一些人正在谈论的数学函数让我非常困惑。在学校(我是一名高中生),甚至在 Math IB SL,我的老师也从未教过我们如何找到经度/纬度。点...然而。所以我很难掌握。由于余弦公式的球面定律在线,我基本上只是将那个公式转换为“java语言”并将其插入我的程序吗?