求大圆证明圆心移动距离等于弧长离

*4.2(几何:最大圆距离)最大圆距离是指球面上两个点之间的距离。假设(x1,y1)和(x2,y2)是两个点的地理经纬度。两个点之间的最大圆距离可以使用以下公式计算:编写一个程序,提示用户以度为单位输入地球上两个点的经纬度,显示其最大圆距离值。地球的平均半径为6371.01km。注意,你需要使用Math.toRadians方法将度转换为弧度值。公式中的经纬度是相对北边和西边的,使用负数表示相对南边和东边的度数。下面是一个运行示例:Enter point 1 (latitude and longitude) in degrees: 39.55 -116.25Enter point 2 (latitude and longitude) in degrees: 41.5 87.37The distance between the two points is 10691.79183231593 km*4.2(Geometry: great circle distance) The great circle distance is the distance between two points on the surface of a sphere. Let (x1, y1) and (x2, y2) be the geographical latitude and longitude of two points. The great circle distance between the twopoints can be computed using the following formula:Write a program that prompts the user to enter the latitude and longitude of two points on the earth in degrees and displays its great circle distance. The average radius of the earth is 6,371.01 km. Note you need to convert the degrees into radians using the Math.toRadians method since the Java trigonometric methods use radians. The latitude and longitude degrees in the formula are for north and west. Use negative to indicate south and east degrees.Here is a sample run:Enter point 1 (latitude and longitude) in degrees: 39.55 -116.25Enter point 2 (latitude and longitude) in degrees: 41.5 87.37The distance between the two points is 10691.79183231593 km参考代码:package chapter04;
import java.util.Scanner;
public class Code_02 {
public static void main(String[] args) {
double x1, y1, x2, y2, greatDistance;
double x1Radian, y1Radian, x2Radian, y2Radian;
final double EARTH_AVERAGE_RADIUS = 6371.01;
System.out.print("Enter point 1 (latitude and longitude) in degrees: ");
Scanner input = new Scanner(System.in);
x1 = input.nextDouble();
y1 = input.nextDouble();
System.out.print("Enter point 2 (latitude and longitude) in degrees: ");
x2 = input.nextDouble();
y2 = input.nextDouble();
x1Radian = Math.toRadians(x1);
y1Radian = Math.toRadians(y1);
x2Radian = Math.toRadians(x2);
y2Radian = Math.toRadians(y2);
greatDistance = EARTH_AVERAGE_RADIUS * Math.acos(Math.sin(x1Radian) * Math.sin(x2Radian)
+ Math.cos(x1Radian) * Math.cos(x2Radian) * Math.cos(y1Radian - y2Radian));
System.out.println("The distance between the two points is " + greatDistance + "km");;
input.close();
}
}
结果显示:Enter point 1 (latitude and longitude) in degrees: 39.55 -116.25
Enter point 2 (latitude and longitude) in degrees: 41.5 87.37
The distance between the two points is 10691.79183231593km
Process finished with exit code 0

我要回帖

更多关于 圆的位移怎么算 的文章

 

随机推荐