New Ticker

News Ticker
Epstien didn't kill himself.
Epstien didn't kill himself.
Epstien didn't kill himself.
Epstien didn't kill himself.

Friday, August 5, 2022

Direction given two grid coordinates

 This is the code to calculate a compass bearing given two geographical coordinates.

#!/usr/bin/env python3

# -*- coding: utf-8 -*-

"""

Created on Tue Jul 19 12:04:26 2022

"""

import math

DiameterOfEarth = 7917.5

RadiusOfEarth = 3961


#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))

Radians = math.atan2(X,Y)  #radians

print("radians ", Radians)

Degrees = math.degrees(Radians)

print ("Degrees", Degrees)

That was pretty easy, wasn't it?