私はそれを開始する方法を知っており、スキャナーやその他すべてを配置する方法を知っていますが、学校では、経度と緯度の公式とそれらの点をラジアンに変換する方法について実際に学んだことはありません. だから私はこの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();
) は使用されていないと彼らは言いますが、その理由はわかっています。まだ実際に定義していないからです。経度と緯度の式が不足していることはわかっています。私の本では、余弦の球面法則を使用するように求められています。学校でこれを学んだことがないので、検索した Web サイトから公式をどれだけ勉強しても、それを転送する方法がわかりません。 Java言語に。
別の問題は、経度/緯度のポイントから度と分をラジアンに変換するにはどうすればよいですか? 私はMath.toRadians
物を使わなければなりませんか?そうそう、私の答えはキロメートルでなければなりません。
更新: 何人かが話している数学関数は、私を大いに混乱させます。学校では (私は高校生です)、Math IB SL でさえ、私の先生は長緯度の見つけ方を教えてくれませんでした。ポイント...まだ。だから、私は把握するのが難しいです。コサインの球面法則の公式がオンラインになっているので、基本的にはその公式を「Java言語」に変換してプログラムにプラグインするだけですか?