\( \newcommand{\abcp}[3]{\frc{#1+\sqrt{#2}}{#3}} \newcommand{\chao}[1]{\left\lfloor #1 \right\rfloor } \newcommand{\nPr}[2]{{}^{#1}A_{#2} } \newcommand{\combin}[2]{{}^{#1}C_{#2} } \newcommand{\cmod}[3]{#1 \equiv #2\left(\bmod {}{#3}\right)} \newcommand{\frc}[2]{\displaystyle\frac{#1}{#2}} \newcommand{\mdc}[2]{\left( {#1},{#2}\right)} \newcommand{\mmc}[2]{\left[ {#1},{#2}\right]} \newcommand{\cis}{\mathop{\rm cis}} \newcommand{\ImP}{\mathop{\rm Im}} \newcommand{\ReP}{\mathop{\rm Re}} \newcommand{\sen}{\mathop{\rm sen}} \newcommand{\tg}{\mathop{\rm tg}} \newcommand{\cotg}{\mathop{\rm cotg}} \newcommand{\cosec}{\mathop{\rm cosec}} \newcommand{\cotgh}{\mathop{\rm cotgh}} \newcommand{\cosech}{\mathop{\rm cosech}} \newcommand{\sech}{\mathop{\rm sech}} \newcommand{\sh}{\mathop{\rm sh}} \newcommand{\ch}{\mathop{\rm ch}} \newcommand{\th}{\mathop{\rm th}} \newcommand{\senEL}[1]{\mathop{\rm sen}^{#1}} \newcommand{\tgEL}[1]{\mathop{\rm tg}^{#1}} \newcommand{\cotgEL}[1]{\mathop{\rm cotg}^{#1}} \newcommand{\cosecEL}[1]{\mathop{\rm cosec}^{#1}} \newcommand{\shEL}[1]{\mathop{\rm sh^{#1}}} \newcommand{\chEL}[1]{\mathop{\rm ch^{#1}}} \newcommand{\thEL}[1]{\mathop{\rm th^{#1}}} \newcommand{\cotghEL}[1]{\mathop{\rm cotgh^{#1}}} \newcommand{\cosechEL}[1]{\mathop{\rm cosech^{#1}}} \newcommand{\sechEL}[1]{\mathop{\rm sech^{#1}}} \newcommand{\senq}{\senEL{2}} \newcommand{\tgq}{\tgEL{2}} \newcommand{\cotgq}{\cotgEL{2}} \newcommand{\cosecq}{\cosecEL{2}} \newcommand{\cotghq}{\cotghEL{2}} \newcommand{\cosechq}{\cosechEL{2}} \newcommand{\sechq}{\sechEL{2}} \newcommand{\shq}{\shEL{2}} \newcommand{\chq}{\chEL{2}} \newcommand{\arctg}{\mathop{\rm arctg}} \newcommand{\arcsen}{\mathop{\rm arcsen}} \newcommand{\argsh}{\mathop{\rm argsh}} \newcommand{\argch}{\mathop{\rm argch}} \newcommand{\argth}{\mathop{\rm argth}} \newcommand{\Var}{\mathop{\rm Var}} \newcommand{\vect}[1]{\overrightarrow{#1}} \newcommand{\tr}[1]{ \textnormal{Tr}\left({#1}\right)} \newcommand{\C}{\mathbb{C}} \newcommand{\E}{\mathbb{E}} \newcommand{\H}{\mathbb{H}} \newcommand{\I}{\mathbb{I}} \newcommand{\K}{\mathbb{K}} \newcommand{\N}{\mathbb{N}} \newcommand{\P}{\mathbb{P}} \newcommand{\Q}{\mathbb{Q}} \newcommand{\R}{\mathbb{R}} \newcommand{\Z}{\mathbb{Z}} \newcommand{\til}{\sim} \newcommand{\mdc}{\mathop{\rm m.d.c.}} \newcommand{\mmc}{\mathop{\rm m.m.c.}} \newcommand{\vect}[1]{\overrightarrow{#1}} \newcommand{\dfrc}{\displaystyle\frac} \newcommand{\Mod}[1]{\ (\mathrm{mod}\ #1)} \newcommand{\arc}[1]{\overset{\frown}{#1}} \)

segunda-feira, 22 de junho de 2026

A fórmula do 'haversine'

Vamos lá deduzir a fórmula da imagem:
Consideremos um triângulo esférico, sobre uma esfera com três vértices:
  • Polo Norte $N$
  • Vértice $A$: Latitude $\phi _{1}$, Longitude $\lambda _{1}$
  • Vértice $B$: Latitude $\phi _{2}$, Longitude $\lambda _{2}$
As amplitudes dos três lados deste triângulo são:
  • Lado $a$ (oposto a $A$):$90^\circ - \phi_2$
  • Lado $b$ (oposto a $B$):$90^\circ - \phi_1$
  • Lado $c$ (oposto ao Polo, entre o Ponto 1 e o Ponto 2): $\Delta\lambda = \lambda_2 - \lambda_1$.
Aplicando a Lei dos Cossenos para triângulos esféricos do post anterior ao lado $c$: $$\cos c=\cos a\cos b+\cos A \sen a\sen b$$ $$\Leftrightarrow \cos c=\sen \phi_2\sen\phi_1+\cos (\Delta\lambda)\cos\phi_2\cos\phi_1$$ O comprimento $d$ do arco de amplitude $c$ é $\color{green}d=r\times c$ onde $r$ é o raio daquela esfera. Só que a nossa fórmula ainda não se parece sequer com a da imagem.
Recorrendo à formula $\cos 2\theta= 1-2{\sen}^2\theta$ podemos escrever \[\cos c=1-2{\sen}^2\left(\frc{c}{2}\right)\] \[\cos \left(\Delta\lambda\right)=1-2{\sen}^2\left(\frc{\Delta\lambda}{2}\right)\] e substituir na fórmula que resultou da aplicação da fórmula dos cossenos. $$1-2{\sen} ^{2}\left(\frac{c}{2}\right)=\sen \phi _{1}\sen \phi _{2}+\cos \phi _{1}\cos \phi _{2}\left[1-2{\sen} ^{2}\left(\frac{\Delta \lambda }{2}\right)\right]$$ $$\Leftrightarrow 1-2{\sen}^{2}\left(\frac{c}{2}\right)=\mathbin{\color{red}\sen \phi _{1}\sen \phi _{2}+\cos \phi _{1}\cos \phi _{2}}-2\cos \phi _{1}\cos \phi _{2}{\sen} ^{2}\left(\frac{\Delta \lambda }{2}\right)$$ $$\Leftrightarrow 1-2{\sen}^{2}\left(\frac{c}{2}\right)=\mathbin{\color{red}\cos \left(\phi _{2}- \phi _{1}\right)}-2\cos \phi _{1}\cos \phi _{2}{\sen} ^{2}\left(\frac{\Delta \lambda }{2}\right)$$ $$\Leftrightarrow 1-2{\sen}^{2}\left(\frac{c}{2}\right)=\mathbin{\color{red}1-2{\sen}^2\left(\frc{\phi _{2}- \phi _{1}}{2}\right)}-2\cos \phi _{1}\cos \phi _{2}{\sen} ^{2}\left(\frac{\Delta \lambda }{2}\right)$$ $$\Leftrightarrow {\sen}^{2}\left(\frac{c}{2}\right)={\sen}^2\left(\frc{\phi _{2}- \phi _{1}}{2}\right)+\cos \phi _{1}\cos \phi _{2}{\sen} ^{2}\left(\frac{\Delta \lambda }{2}\right)$$ $$\Leftrightarrow c=2\arcsen \left(\sqrt{{\sen}^2\left(\frc{\phi _{2}- \phi _{1}}{2}\right)+\cos \phi _{1}\cos \phi _{2}{\sen} ^{2}\left(\frac{\Delta \lambda }{2}\right)}\right)$$ $$\Leftrightarrow \mathbin{\color{green}\frac{d}{r}}=2\arcsen \left(\sqrt{{\sen}^2\left(\frc{\phi _{2}- \phi _{1}}{2}\right)+\cos \phi _{1}\cos \phi _{2}{\sen} ^{2}\left(\frac{\Delta \lambda }{2}\right)}\right)$$ $$\Leftrightarrow d=2r\arcsen \left(\sqrt{{\sen}^2\left(\frc{\phi _{2}- \phi _{1}}{2}\right)+\cos \phi _{1}\cos \phi _{2}{\sen} ^{2}\left(\frac{\Delta \lambda }{2}\right)}\right)$$
haversine é a função \[\text{hav } \theta={\sen} ^2\left(\frac{\theta}{2}\right)\] Que permite reescrever a fórmula com outro aspecto: $$\text{hav }\left(\mathbin{\color{green}\frac{d}{r}}\right)=\text{hav }\left(\Delta\phi\right)+\cos \phi _{1}\cos \phi _{2}\text{hav }\left(\Delta \lambda \right)$$

Sem comentários:

Enviar um comentário