<html><head></head><body>Hello Rhys,<br>My maths is something like yours in that I did 'A' level 50 years ago, but only remember bits so invariably I end up searching the internet. The likes of GPS were not even on the horizon at that time!<br><br>I do not pretend to fully understand the maths you have presented, but the ActualDistance line seems very suspect. You are using radius where I would have expected circumference. It's then divided by 90, which I assume is 90° or a quarter of a circle. A degree value seems arbitrary. You could possibly mean 0.25 (of a circle), but my memory says you should be using radians (where 2 Pi radians is a full circle)<br><br>I believe you need haversine formulas, but they are at the fringe of my general knowledge so I cannot directly help. Incidentally, some years ago I worked with a robotics chap and I know he often resorted to simplified look up tables rather than repetitive calculation to get useful real-time speeds. <br><br>Kindest regards<br>Alan Gray<br><br><br><div class="gmail_quote">On 19 July 2022 18:01:48 BST, Rhys Sage via Swlug <swlug@mailman.lug.org.uk> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre dir="auto" class="k9mail">I've been working on some maths problems. I can honestly say I detest maths when it gets complicated and usually end up relying upon easy solutions found online.<br><br>I found the solution to calculating compass headings online and it seems pretty believable. The distance however, I'm not sure I have right. I've calculated it on diameter of the earth over 90. I had it over 360 originally but since it's 450km from the Arc de Triomphe to the Tower of London the small figure of 77 miles didn't seem right. Thus I tried 180 and that wasn't right either. 90 is a more believable figure but even so I think it's likely wrong. Does anybody have any navigational expertise to throw in here?<br><br>#!/usr/bin/env python3<br># -*- coding: utf-8 -*-<br>"""<br>Created on Tue Jul 19 12:04:26 2022<br><br><br>@author: rhys<br>"""<br>import math<br>DiameterOfEarth = 7917.5<br><br><br>#Assumung two fixed point - just for the sake of making life easy...<br>#North = positive values. South = negative values<br>#West = Positive values, East = negative values<br>LocationOneV = 51.5081<br>LocationOneH = 0.0759<br>#Tower of London<br><br><br>LocationTwoV = 48.8738<br>LocationTwoH = -2.2950<br>#Arc de Triomph<br><br><br>X = math.cos(LocationTwoV)*math.sin(LocationOneH-LocationTwoH)<br>Y = (math.cos(LocationOneV)*math.sin(LocationTwoV)-math.sin(LocationOneV)*<br> math.cos(LocationTwoV)*math.cos(LocationOneH-LocationTwoH))<br><br><br>Z = math.atan2(X,Y) #radians<br><br>#Compass heading in degrees<br>Degrees = math.degrees(Z)<br>print (Z)<br><br><br>#Distance calculation<br>DistanceV = (LocationOneV - LocationTwoV)<br>DistanceH = (LocationOneH - LocationTwoH)<br>DistanceCalc = (DistanceV*DistanceV)+(DistanceH*DistanceH)<br>ActualDistance = math.sqrt(DistanceCalc)*(DiameterOfEarth / 90)<br><br>#Distance to go in miles<br>print(ActualDistance)<br><br><br><br>Rhys Sage<br><br><div class="k9mail-signature">-- <br>Swlug mailing list<br>Swlug@mailman.lug.org.uk<br><a href="https://mailman.lug.org.uk/mailman/listinfo/swlug">https://mailman.lug.org.uk/mailman/listinfo/swlug</a><br></div></pre></blockquote></div><div style='white-space: pre-wrap'><div class='k9mail-signature'>-- <br>Sent from my Android device with K-9 Mail. Please excuse my brevity.</div></div></body></html>