(15C) Haversine Navigation
|
11-12-2019, 12:55 AM
(This post was last modified: 11-12-2019 12:56 AM by SlideRule.)
Post: #1
|
|||
|
|||
(15C) Haversine Navigation
An extract from Haversine Navigation 8 pgs.
"Abstract This is to provide a practical means for cruise planning using … the hand held calculator … … Background … The spherical trigonometry equations taught left an ambiguity when the initial course was close to due east or west. Further solutions using the Spherical Law of Cosines fall apart when the distances are very small; short distances are most important to the vast majority of weekend sailors. Haversines resolved these issues. Today there are dozens of websites that will give you the course and distance between two points on the earth given the Latitude and Longitude of each. Many of these sites report the distance in kilometers which require a definition of the radius of the earth. The haversine method herein described uses a unit radius; thus, a distance as an angle readily resolves to nautical miles; therefore, I am going to limit this to a simple definition of the haversine and practical topics for cruise planning … on the handheld calculator … … 2. Calculator The equations shown earlier are easily implemented into any handheld calculator with memory storage. I have chosen to show an application using the HP 15C calculator that uses RPN … You only have to program your device once. The RPN programming steps are shown …" BEST! SlideRule |
|||
11-05-2022, 11:13 PM
(This post was last modified: 11-06-2022 12:38 AM by Thomas Klemm.)
Post: #2
|
|||
|
|||
RE: (15C) Haversine Navigation
Motivation
Quote:Further solutions using the Spherical Law of Cosines fall apart when the distances are very small; short distances are most important to the vast majority of weekend sailors. Haversines resolved these issues. Haversine Function \( \begin{align} \operatorname {hav} (\theta) = \sin^2\left(\frac{\theta}{2}\right) = \frac{1 - \cos(\theta)}{2} \end{align} \) To avoid cancellation for small angles only the expression using the sine function should be used. Haversine Formula This formula can be used to calculate the great-circle distance between two points on a sphere: \( \begin{align} \operatorname {hav} \left(\theta \right) = \operatorname {hav} \left(\varphi_2 - \varphi_1\right) + \cos \left(\varphi_1\right)\cos \left(\varphi_2\right)\operatorname {hav} \left(\lambda_2-\lambda_1\right) \end{align} \) We can see that this avoids cancellation since only \( \operatorname {hav} \) is used for small differences. This happens if the two points are close which appears to be common in sailing. Compare this to the common formula: \( \begin{align} \cos(\theta) = \sin(\varphi_1) \sin(\varphi_2) + \cos(\varphi_1) \cos(\varphi_2) \cos(\lambda_{2}-\lambda_{1}) \end{align} \) Here cancellation happens if \(\cos(\Delta \lambda) \) is calculated for small \( \Delta \lambda = \lambda_2-\lambda_1 \). A similar problem arises if \( \theta \) is small. Program This is the original program: Code: 001 - 42,21,11 LBL A Assume that the coordinates are stored in the following registers: R5: \(φ_1\) R6: \(λ_1\) R8: \(φ_2\) R9: \(λ_2\) Let's start with the first few lines: Code: 002 - 45 5 RCL 5 The subroutine 2 calculates the complement of the angle: Code: 075 - 42,21, 2 LBL 2 But instead of calculating \((90^{\circ} - \varphi_1) - (90^{\circ} - \varphi_2)\) we could calculate \(\varphi_2 - \varphi_1\) directly. Quote:Complementing an angle takes less programming steps with the Sin aCos method than subtracting the angle from 90°. It is used again when calculating \(\cos \left(\varphi_1\right)\cos \left(\varphi_2\right)\): Code: 008 - 45 5 RCL 5 Then I had a look at the implementation of the haversine function: Code: 059 - 42,21, 0 LBL 0 Unfortunately the variant where cancellation for small angles occur was chosen. This invalidates the reason to use the haversine function. So I came up with this improved version: Code: 001 - 42,21,13 LBL C When I analysed the accuracy of the different approaches I noticed that with 10 digits it doesn't really matter. The coordinates are a couple of minutes appart which translates to a few nautical miles. Here's a typical example: \(φ_1\) = 41.6258 \(φ_2\) = 41.6683 \(λ_1\) = -71.9950 \(λ_2\) = -71.8650 However we'd notice the difference if either the differences were smaller or then we would use a calculator with fewer digits. Can we do better? Great Circle Navigation To match the drawing with our problem consider the following: \( \begin{align} A &= \lambda_2-\lambda_1 \, \text{(the angle at w)} \\ b &= 90^{\circ} - φ_1 \\ c &= 90^{\circ} - φ_2 \\ \end{align} \) Here \(a\) is the great-circle distance while \(C\) is the bearing. Spherical Law of Sines \( \begin{align} \frac{\sin A}{\sin a} = \frac{\sin B}{\sin b} = \frac{\sin C}{\sin c} \end{align} \) Spherical Law of Cosines \( \begin{align} \cos c=\cos a\cos b+\sin a\sin b\cos C \end{align} \) With a little rearrangement we get: \( \begin{align} \cos C&= \frac{\cos c-\cos a\cos b}{\sin a\sin b} \\ \end{align} \) This leads to: \( \begin{align} \sin C &= \sin c \frac{\sin A}{\sin a} \\ \\ \cos C &= \frac{\cos c - \cos a \cos b}{\sin a \sin b} \\ \\ \cos a & = \cos b \cos c + \sin b \sin c \cos A \\ \end{align} \) Or then by multiplying the first two equations by \( \sin a \): \( \begin{align} \sin a \sin C &= \sin c \sin A \\ \\ \sin a \cos C &= \frac{\cos c - \cos a \cos b}{ \sin b} \\ \\ \cos a & = \cos b \cos c + \sin b \sin c \cos A \\ \end{align} \) The goal is to use a rectangular to polar transformation to calculate \(a\) and \(C\) from: \( \begin{align} y &= \sin a \sin C \\ x &= \sin a \cos C \\ z &= \cos a \\ \end{align} \) For this we have to substitute \( \cos a \) in the 2nd equation: \( \begin{align} \sin a \cos C &= \frac{\cos c - \cos a \cos b}{ \sin b} \\ \\ &= \frac{\cos c - (\cos b \cos c + \sin b \sin c \cos A) \cos b}{ \sin b} \\ \\ &= \frac{\cos c - \cos^2 b \cos c - \sin b \cos b \sin c \cos A}{ \sin b} \\ \\ &= \frac{\sin^2 b \cos c - \sin b \cos b \sin c \cos A}{ \sin b} \\ \\ &= \sin b \cos c - \cos b \sin c \cos A \\ \end{align} \) We can define the following polar to rectangular transformation: \( \begin{align} u &= \sin c \cos A \\ v &= \sin c \sin A \\ w &= \cos c \end{align} \) Pluging all this into the equations leads to: \( \begin{align} y &= \sin a \sin C &= \sin c \sin A & = v \\ x &= \sin a \cos C &= \sin b \cos c - \cos b \sin c \cos A &= w \sin b - u \cos b \\ z &= \cos a &= \cos b \cos c + \sin b \sin c \cos A &= w \cos b + u \sin b \\ \end{align} \) This turns out to be a rotation by the angle \(φ_1 = 90^{\circ} - b\): \( \begin{align} \begin{bmatrix} x \\ z \\ \end{bmatrix} &= \begin{bmatrix} \sin b & - \cos b \\ \cos b & \sin b \\ \end{bmatrix} \cdot \begin{bmatrix} w \\ u \\ \end{bmatrix} \end{align} \) Programs Here's the program for the HP-42S: Code: 00 { 37-Byte Prgm } # This is the same program for the HP-15C: Code: 001 - 42,21,11 LBL A But similar programs work for other calculators as well as longs as they provide →REC, →POL, R↑ and R↓. Example 41.6258 ENTER -71.9950 ENTER 41.6683 ENTER -71.8650 GSB A 6.361974738 x<>y 66.32743461 Pros
Cons
Cancellation The cancellation is avoided since with →REC both cosine and sine are calculated. This allows to keep track of small angles. You can test this with a small angle, say 1.23456789e-5. Compare the result when calculating COS ACOS with 1 →REC →POL R↓. Thank you As always, I'm very grateful for your findings of these programs in the wild. References |
|||
11-06-2022, 05:14 PM
(This post was last modified: 11-06-2022 06:07 PM by C.Ret.)
Post: #3
|
|||
|
|||
RE: (SHARP EL-5150) Haversine Navigation
Hi there,
Once again, my thanks for this very well documented topic. Note that this is always the case. It is therefore always with great pleasure that I scrutinize all this with the keenest interest. Opportunities to study and learn so effectively are unfortunately increasingly rare. If I understand all this correctly, the final multiplication by 60 gives the displacement in nautical miles. So I will also check the following assertion: (11-05-2022 11:13 PM)Thomas Klemm Wrote: But similar programs work for other calculators as well as longs as they provide →REC, →POL, R↑ and R↓. So I'm going to try to translate these clever codes for a SHARP EL-5150 calculator which also has the instructions →REC, →POL, ↑ and ↓ on its keyboard. This is a good thing done, not without effort, hesitation and perseverance. But note that the instructions ↑ and ↓ are not used in the algebraic expressions of the SHARP EL-5150 but are used to select the correct slot in the AER formula pool. Thanks. |
|||
11-06-2022, 11:46 PM
Post: #4
|
|||
|
|||
RE: (15C) Haversine Navigation
(11-06-2022 05:14 PM)C.Ret Wrote: If I understand all this correctly, the final multiplication by 60 gives the displacement in nautical miles.This is correct. From Nautical mile: Quote:Historically, it was defined as the meridian arc length corresponding to one minute (\(\frac{1}{60}\) of a degree) of latitude.While not exactly 1852m it is probably close enough. Even though I've never used this calculator the program is quite readable. Both →REC and →POL appear to use infix notation which is rather unusual. Here's what I came up with for the HP-48: Code: \<< \-> \Gh1 \Gl1 \Gh2 \Gl2 Since the latitude is measured from the north-pole we have to calculate the complement \(c = 90^{\circ} - \theta_2\). And then the transformation between spherical and rectangular coordinates seems a bit awkward. Thus I'm not super happy with it. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)