[Swlug] Math Calculations

Alan Gray alan at grayhs.org
Wed Jul 20 11:14:15 UTC 2022


Hello Rhys,
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!

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)

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. 

Kindest regards
Alan Gray


On 19 July 2022 18:01:48 BST, Rhys Sage via Swlug <swlug at mailman.lug.org.uk> wrote:
>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.
>
>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?
>
>#!/usr/bin/env python3
># -*- coding: utf-8 -*-
>"""
>Created on Tue Jul 19 12:04:26 2022
>
>
>@author: rhys
>"""
>import math
>DiameterOfEarth = 7917.5
>
>
>#Assumung two fixed point - just for the sake of making life easy...
>#North = positive values. South = negative values
>#West = Positive values, East = negative values
>LocationOneV = 51.5081
>LocationOneH = 0.0759
>#Tower of London
>
>
>LocationTwoV = 48.8738
>LocationTwoH = -2.2950
>#Arc de Triomph
>
>
>X = math.cos(LocationTwoV)*math.sin(LocationOneH-LocationTwoH)
>Y = (math.cos(LocationOneV)*math.sin(LocationTwoV)-math.sin(LocationOneV)*
>    math.cos(LocationTwoV)*math.cos(LocationOneH-LocationTwoH))
>
>
>Z = math.atan2(X,Y)  #radians
>
>#Compass heading in degrees
>Degrees = math.degrees(Z)
>print (Z)
>
>
>#Distance calculation
>DistanceV = (LocationOneV - LocationTwoV)
>DistanceH = (LocationOneH - LocationTwoH)
>DistanceCalc = (DistanceV*DistanceV)+(DistanceH*DistanceH)
>ActualDistance = math.sqrt(DistanceCalc)*(DiameterOfEarth / 90)
>
>#Distance to go in miles
>print(ActualDistance)
>
>
>
>Rhys Sage
>
>-- 
>Swlug mailing list
>Swlug at mailman.lug.org.uk
>https://mailman.lug.org.uk/mailman/listinfo/swlug

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/swlug/attachments/20220720/183dc205/attachment-0001.htm>


More information about the Swlug mailing list