将西经看作负值,东经看作正值,北纬看作负值,南纬看作正值。则纬度的取值范围是 [ − π 2 , π 2 ] [-\frac{\pi}{2}, \frac{\pi}{2}] [−2π,2π] , 经度的取值范围为 [ − π , π ] [-\pi, \pi] [−π,π]. 当然,正负可以根据个人喜好随意规定,并不会影响最终的计算结果。
1. 经纬度与空间直角坐标系的变换关系
假定地球半径为
R
R
R , 对于地面上的任意一点,假定其纬度与经度分别为
θ
\theta
θ,
φ
\varphi
φ, 则转化到三维空间直角坐标系有
{
x
=
R
cos
θ
cos
φ
y
=
R
cos
θ
sin
φ
z
=
R
sin
θ
\left\{\begin{array}{l}x=R \cos \theta \cos \varphi \\ y=R \cos \theta \sin \varphi \\ z=R \sin \theta\end{array}\right.
⎩
⎨
⎧x=Rcosθcosφy=Rcosθsinφz=Rsinθ
2. 在三维直角坐标系中利用向量内积来计算
计地心为 O O O , 地面上的 A A A 点的纬度与经度分别为 θ 1 \theta_{1} θ1, φ 1 \varphi_{1} φ1, B B B 点的纬度与经度分别为 θ 2 \theta_{2} θ2, φ 2 \varphi_{2} φ2, 在空间直角坐标系中的坐标分别为 ( x 1 , y 1 , z 1 ) (x_{1}, y_{1}, z_{1}) (x1,y1,z1), ( x 2 , y 2 , z 2 ) (x_{2}, y_{2}, z_{2}) (x2,y2,z2), 则
cos
∠
A
O
B
=
x
1
x
2
+
y
1
y
2
+
z
1
z
2
R
2
=
cos
θ
1
cos
φ
1
cos
θ
2
cos
φ
2
+
cos
θ
1
sin
φ
1
cos
θ
2
sin
φ
2
+
sin
θ
1
sin
θ
2
=
sin
θ
1
sin
θ
2
+
cos
θ
1
cos
θ
2
cos
(
φ
2
−
φ
1
)
\begin{aligned} & \cos \angle A O B=\frac{x_1 x_2+y_1 y_2+z_1 z_2}{R^2} \\ & =\cos \theta_1 \cos \varphi_1 \cos \theta_2 \cos \varphi_2+\cos \theta_1 \sin \varphi_1 \cos \theta_2 \sin \varphi_2+\sin \theta_1 \sin \theta_2 \\ & =\sin \theta_1 \sin \theta_2+\cos \theta_1 \cos \theta_2 \cos \left(\varphi_2-\varphi_1\right) \end{aligned}
cos∠AOB=R2x1x2+y1y2+z1z2=cosθ1cosφ1cosθ2cosφ2+cosθ1sinφ1cosθ2sinφ2+sinθ1sinθ2=sinθ1sinθ2+cosθ1cosθ2cos(φ2−φ1)
则
S
=
R
∠
A
O
B
=
R
arccos
(
sin
θ
1
sin
θ
2
+
cos
θ
1
cos
θ
2
cos
(
φ
2
−
φ
1
)
)
S=R \angle A O B=R \arccos \left(\sin \theta_1 \sin \theta_2+\cos \theta_1 \cos \theta_2 \cos \left(\varphi_2-\varphi_1\right)\right)
S=R∠AOB=Rarccos(sinθ1sinθ2+cosθ1cosθ2cos(φ2−φ1))
3. 在三维直角坐标系中利用勾股定理来计算
根据勾股定理有
A
B
=
(
x
2
−
x
1
)
2
+
(
y
2
−
y
1
)
2
+
(
z
2
−
z
1
)
2
=
R
(
cos
θ
2
cos
φ
2
−
cos
θ
1
cos
φ
1
)
2
+
(
cos
θ
2
sin
φ
2
−
cos
θ
1
sin
φ
1
)
2
=
R
2
−
2
sin
θ
2
−
sin
θ
1
)
2
\begin{aligned} & A B=\sqrt{\left(x_2-x_1\right)^2+\left(y_2-y_1\right)^2+\left(z_2-z_1\right)^2} \\ & =R \sqrt{\left(\cos \theta_2 \cos \varphi_2-\cos \theta_1 \cos \varphi_1\right)^2+\left(\cos \theta_2 \sin \varphi_2-\cos \theta_1 \sin \varphi_1\right)^2} \\ & =R \sqrt{\left.2-2 \sin \theta_2-\sin \theta_1\right)^2} \end{aligned}
AB=(x2−x1)2+(y2−y1)2+(z2−z1)2=R(cosθ2cosφ2−cosθ1cosφ1)2+(cosθ2sinφ2−cosθ1sinφ1)2=R2−2sinθ2−sinθ1)2
因此
sin
2
∠
A
O
B
2
=
(
A
B
2
R
)
2
=
1
−
sin
θ
1
sin
θ
2
−
cos
θ
1
cos
θ
2
cos
(
φ
2
−
φ
1
)
2
cos
2
∠
A
O
B
2
=
1
−
sin
2
∠
A
O
B
2
=
1
+
sin
θ
1
sin
θ
2
+
cos
θ
1
cos
θ
2
cos
(
φ
2
−
φ
1
)
2
\begin{aligned} & \sin ^2 \frac{\angle A O B}{2}=\left(\frac{A B}{2 R}\right)^2=\frac{1-\sin \theta_1 \sin \theta_2-\cos \theta_1 \cos \theta_2 \cos \left(\varphi_2-\varphi_1\right)}{2} \\ & \cos ^2 \frac{\angle A O B}{2}=1-\sin ^2 \frac{\angle A O B}{2}=\frac{1+\sin \theta_1 \sin \theta_2+\cos \theta_1 \cos \theta_2 \cos \left(\varphi_2-\varphi_1\right)}{2} \end{aligned}
sin22∠AOB=(2RAB)2=21−sinθ1sinθ2−cosθ1cosθ2cos(φ2−φ1)cos22∠AOB=1−sin22∠AOB=21+sinθ1sinθ2+cosθ1cosθ2cos(φ2−φ1)
则
cos
∠
A
O
B
=
cos
2
∠
A
O
B
2
−
sin
2
∠
A
O
B
2
=
sin
θ
1
sin
θ
2
+
cos
θ
1
cos
θ
2
cos
(
φ
2
−
φ
1
)
\cos \angle A O B=\cos ^2 \frac{\angle A O B}{2}-\sin ^2 \frac{\angle A O B}{2}=\sin \theta_1 \sin \theta_2+\cos \theta_1 \cos \theta_2 \cos \left(\varphi_2-\varphi_1\right)
cos∠AOB=cos22∠AOB−sin22∠AOB=sinθ1sinθ2+cosθ1cosθ2cos(φ2−φ1)
因此两地距离
{
S
=
R
∠
A
O
B
=
R
arccos
(
sin
θ
1
sin
θ
2
+
cos
θ
1
cos
θ
2
cos
(
φ
2
−
φ
1
)
S
=
2
R
∠
A
O
B
2
=
2
R
arcsin
(
1
−
sin
θ
1
sin
θ
2
−
cos
θ
1
cos
θ
2
cos
(
φ
2
−
φ
1
)
2
)
S
=
2
R
∠
A
O
B
2
=
2
R
arccos
(
1
+
sin
θ
1
sin
θ
2
+
cos
θ
1
cos
θ
2
cos
(
φ
2
−
φ
1
)
2
)
\left\{\begin{array}{l} S=R \angle A O B=R \arccos \left(\sin \theta_1 \sin \theta_2+\cos \theta_1 \cos \theta_2 \cos \left(\varphi_2-\varphi_1\right)\right. \\ S=2 R \frac{\angle A O B}{2}=2 R \arcsin \left(\sqrt{\frac{1-\sin \theta_1 \sin \theta_2-\cos \theta_1 \cos \theta_2 \cos \left(\varphi_2-\varphi_1\right)}{2}}\right) \\ S=2 R \frac{\angle A O B}{2}=2 R \arccos \left(\sqrt{\frac{1+\sin \theta_1 \sin \theta_2+\cos \theta_1 \cos \theta_2 \cos \left(\varphi_2-\varphi_1\right)}{2}}\right) \end{array}\right.
⎩
⎨
⎧S=R∠AOB=Rarccos(sinθ1sinθ2+cosθ1cosθ2cos(φ2−φ1)S=2R2∠AOB=2Rarcsin(21−sinθ1sinθ2−cosθ1cosθ2cos(φ2−φ1))S=2R2∠AOB=2Rarccos(21+sinθ1sinθ2+cosθ1cosθ2cos(φ2−φ1))
#4.在等腰梯形里计算
如图,假定
A
,
B
,
C
,
D
A,B,C,D
A,B,C,D为地球表面上四点,
A
A
A 点的纬度与经度分别为
θ
1
,
φ
1
\theta_{1}, \varphi_{1}
θ1,φ1,
B
B
B 点的纬度与经度分别为
θ
1
,
φ
2
\theta_{1}, \varphi_{2}
θ1,φ2 ,
C
C
C 点坐标为
θ
2
,
φ
2
\theta_{2}, \varphi_{2}
θ2,φ2,
D
D
D点坐标为
θ
2
,
φ
1
\theta_{2}, \varphi_{1}
θ2,φ1 , 则四边形
A
B
C
D
ABCD
ABCD为等腰梯形。
现在我们要算的是
A
,
C
A,C
A,C两点之间的距离
S
S
S , 显然
{
A
B
=
2
R
sin
φ
2
−
φ
1
2
cos
θ
1
A
D
=
B
C
=
2
R
sin
θ
2
−
θ
1
2
C
D
=
2
R
sin
φ
2
−
φ
1
2
cos
θ
2
\left\{\begin{array}{l} A B=2 R \sin \frac{\varphi_2-\varphi_1}{2} \cos \theta_1 \\ A D=B C=2 R \sin \frac{\theta_2-\theta_1}{2} \\ C D=2 R \sin \frac{\varphi_2-\varphi_1}{2} \cos \theta_2 \end{array}\right.
⎩
⎨
⎧AB=2Rsin2φ2−φ1cosθ1AD=BC=2Rsin2θ2−θ1CD=2Rsin2φ2−φ1cosθ2
由余弦定理在
△
A
B
C
\triangle A B C
△ABC有
A
C
2
=
A
B
2
+
B
C
2
−
2
A
B
⋅
B
C
cos
∠
A
B
C
=
4
R
2
sin
2
φ
2
−
φ
1
2
cos
2
θ
1
+
4
R
2
sin
2
θ
2
−
θ
1
2
−
8
R
2
sin
φ
2
−
φ
1
2
sin
θ
2
−
θ
1
2
cos
θ
1
cos
∠
A
B
C
\begin{aligned} & A C^2=A B^2+B C^2-2 A B \cdot B C \cos \angle A B C \\ & =4 R^2 \sin ^2 \frac{\varphi_2-\varphi_1}{2} \cos ^2 \theta_1+4 R^2 \sin ^2 \frac{\theta_2-\theta_1}{2}-8 R^2 \sin \frac{\varphi_2-\varphi_1}{2} \sin \frac{\theta_2-\theta_1}{2} \cos \theta_1 \cos \angle A B C \end{aligned}
AC2=AB2+BC2−2AB⋅BCcos∠ABC=4R2sin22φ2−φ1cos2θ1+4R2sin22θ2−θ1−8R2sin2φ2−φ1sin2θ2−θ1cosθ1cos∠ABC
同理,在
△
A
C
D
\triangle A C D
△ACD有
A
C
2
=
A
D
2
+
C
D
2
−
2
A
D
⋅
C
D
cos
∠
A
D
C
=
4
R
2
sin
2
φ
2
−
φ
1
2
cos
2
θ
2
+
4
R
2
sin
2
θ
2
−
θ
1
2
−
8
R
2
sin
φ
2
−
φ
1
2
sin
θ
2
−
θ
1
2
cos
θ
2
cos
∠
A
D
C
=
4
R
2
sin
2
φ
2
−
φ
1
2
cos
2
θ
2
+
4
R
2
sin
2
θ
2
−
θ
1
2
+
8
R
2
sin
φ
2
−
φ
1
2
sin
θ
2
−
θ
1
2
cos
θ
2
cos
∠
A
B
C
\begin{aligned} & A C^2=A D^2+C D^2-2 A D \cdot C D \cos \angle A D C \\ & =4 R^2 \sin ^2 \frac{\varphi_2-\varphi_1}{2} \cos ^2 \theta_2+4 R^2 \sin ^2 \frac{\theta_2-\theta_1}{2}-8 R^2 \sin \frac{\varphi_2-\varphi_1}{2} \sin \frac{\theta_2-\theta_1}{2} \cos \theta_2 \cos \angle A D C \\ & =4 R^2 \sin ^2 \frac{\varphi_2-\varphi_1}{2} \cos ^2 \theta_2+4 R^2 \sin ^2 \frac{\theta_2-\theta_1}{2}+8 R^2 \sin \frac{\varphi_2-\varphi_1}{2} \sin \frac{\theta_2-\theta_1}{2} \cos \theta_2 \cos \angle A B C \end{aligned}
AC2=AD2+CD2−2AD⋅CDcos∠ADC=4R2sin22φ2−φ1cos2θ2+4R2sin22θ2−θ1−8R2sin2φ2−φ1sin2θ2−θ1cosθ2cos∠ADC=4R2sin22φ2−φ1cos2θ2+4R2sin22θ2−θ1+8R2sin2φ2−φ1sin2θ2−θ1cosθ2cos∠ABC
联立以上两式消去
cos
∠
A
B
C
\cos \angle A B C
cos∠ABC可得
A
C
2
=
4
R
2
sin
2
φ
2
−
φ
1
2
cos
θ
1
cos
θ
2
+
4
R
2
sin
2
θ
2
−
θ
1
2
A C^2=4 R^2 \sin ^2 \frac{\varphi_2-\varphi_1}{2} \cos \theta_1 \cos \theta_2+4 R^2 \sin ^2 \frac{\theta_2-\theta_1}{2}
AC2=4R2sin22φ2−φ1cosθ1cosθ2+4R2sin22θ2−θ1
则
sin
2
∠
A
O
C
2
=
A
C
2
4
R
2
=
sin
2
φ
2
−
φ
1
2
cos
θ
1
cos
θ
2
+
sin
2
θ
2
−
θ
1
2
cos
2
∠
A
O
C
2
=
1
−
sin
2
∠
A
O
C
2
=
cos
2
θ
2
−
θ
1
2
−
sin
2
φ
2
−
φ
1
2
cos
θ
1
cos
θ
2
\begin{aligned} & \sin ^2 \frac{\angle A O C}{2}=\frac{A C^2}{4 R^2}=\sin ^2 \frac{\varphi_2-\varphi_1}{2} \cos \theta_1 \cos \theta_2+\sin ^2 \frac{\theta_2-\theta_1}{2} \\ & \cos ^2 \frac{\angle A O C}{2}=1-\sin ^2 \frac{\angle A O C}{2}=\cos ^2 \frac{\theta_2-\theta_1}{2}-\sin ^2 \frac{\varphi_2-\varphi_1}{2} \cos \theta_1 \cos \theta_2 \end{aligned}
sin22∠AOC=4R2AC2=sin22φ2−φ1cosθ1cosθ2+sin22θ2−θ1cos22∠AOC=1−sin22∠AOC=cos22θ2−θ1−sin22φ2−φ1cosθ1cosθ2
则
cos
∠
A
O
C
=
cos
2
∠
A
O
C
2
−
sin
2
∠
A
O
C
2
=
sin
θ
1
sin
θ
2
+
cos
θ
1
cos
θ
2
cos
(
φ
2
−
φ
1
)
\cos \angle A O C=\cos ^2 \frac{\angle A O C}{2}-\sin ^2 \frac{\angle A O C}{2}=\sin \theta_1 \sin \theta_2+\cos \theta_1 \cos \theta_2 \cos \left(\varphi_2-\varphi_1\right)
cos∠AOC=cos22∠AOC−sin22∠AOC=sinθ1sinθ2+cosθ1cosθ2cos(φ2−φ1)
与第一种方法得出相同的结果。因此同样有
S
=
R
∠
A
O
C
=
R
arccos
(
sin
θ
1
sin
θ
2
+
cos
θ
1
cos
θ
2
cos
(
φ
2
−
φ
1
)
S
=
2
R
∠
A
O
C
2
=
2
R
arcsin
(
sin
2
φ
2
−
φ
1
2
cos
θ
1
cos
θ
2
+
sin
2
θ
2
−
θ
1
2
)
S
=
2
R
∠
A
O
C
2
=
2
R
arccos
(
cos
2
θ
2
−
θ
1
2
−
sin
2
φ
2
−
φ
1
2
cos
θ
1
cos
θ
2
)
\begin{aligned} & S=R \angle A O C=R \arccos \left(\sin \theta_1 \sin \theta_2+\cos \theta_1 \cos \theta_2 \cos \left(\varphi_2-\varphi_1\right)\right. \\ & S=2 R \frac{\angle A O C}{2}=2 R \arcsin \left(\sqrt{\sin ^2 \frac{\varphi_2-\varphi_1}{2} \cos \theta_1 \cos \theta_2+\sin ^2 \frac{\theta_2-\theta_1}{2}}\right) \\ & S=2 R \frac{\angle A O C}{2}=2 R \arccos \left(\sqrt{\cos ^2 \frac{\theta_2-\theta_1}{2}-\sin ^2 \frac{\varphi_2-\varphi_1}{2} \cos \theta_1 \cos \theta_2}\right) \end{aligned}
S=R∠AOC=Rarccos(sinθ1sinθ2+cosθ1cosθ2cos(φ2−φ1)S=2R2∠AOC=2Rarcsin(sin22φ2−φ1cosθ1cosθ2+sin22θ2−θ1)S=2R2∠AOC=2Rarccos(cos22θ2−θ1−sin22φ2−φ1cosθ1cosθ2)
4. 距离公式的总结
综合上述推导过程,得出以下5个正确结果
{
S
=
R
arccos
(
sin
θ
1
sin
θ
2
+
cos
θ
1
cos
θ
2
cos
(
φ
2
−
φ
1
)
S
=
2
R
arcsin
(
1
−
sin
θ
1
sin
θ
2
−
cos
θ
1
cos
θ
2
cos
(
φ
2
−
φ
1
)
2
)
S
=
2
R
arccos
(
1
+
sin
θ
1
sin
θ
2
+
cos
θ
1
cos
θ
2
cos
(
φ
2
−
φ
1
)
2
)
S
=
2
R
arcsin
(
sin
2
φ
2
−
φ
1
2
cos
θ
1
cos
θ
2
+
sin
2
θ
2
−
θ
1
2
)
S
=
2
R
arccos
(
cos
2
θ
2
−
θ
1
2
−
sin
2
φ
2
−
φ
1
2
cos
θ
1
cos
θ
2
)
\left\{\begin{array}{l} S=R \arccos \left(\sin \theta_1 \sin \theta_2+\cos \theta_1 \cos \theta_2 \cos \left(\varphi_2-\varphi_1\right)\right. \\ S=2 R \arcsin \left(\sqrt{\frac{1-\sin \theta_1 \sin \theta_2-\cos \theta_1 \cos \theta_2 \cos \left(\varphi_2-\varphi_1\right)}{2}}\right) \\ S=2 R \arccos \left(\sqrt{\frac{1+\sin \theta_1 \sin \theta_2+\cos \theta_1 \cos \theta_2 \cos \left(\varphi_2-\varphi_1\right)}{2}}\right) \\ S=2 R \arcsin \left(\sqrt{\sin ^2 \frac{\varphi_2-\varphi_1}{2} \cos \theta_1 \cos \theta_2+\sin ^2 \frac{\theta_2-\theta_1}{2}}\right) \\ S=2 R \arccos \left(\sqrt{\cos ^2 \frac{\theta_2-\theta_1}{2}-\sin ^2 \frac{\varphi_2-\varphi_1}{2} \cos \theta_1 \cos \theta_2}\right) \end{array}\right.
⎩
⎨
⎧S=Rarccos(sinθ1sinθ2+cosθ1cosθ2cos(φ2−φ1)S=2Rarcsin(21−sinθ1sinθ2−cosθ1cosθ2cos(φ2−φ1))S=2Rarccos(21+sinθ1sinθ2+cosθ1cosθ2cos(φ2−φ1))S=2Rarcsin(sin22φ2−φ1cosθ1cosθ2+sin22θ2−θ1)S=2Rarccos(cos22θ2−θ1−sin22φ2−φ1cosθ1cosθ2)
根据上述推导过程,很容易知晓这 5 个结果是相等的,读者也可以自行验证。