Or is it Rayon

Sorry I'm amusing myself

# could just change the coordinates to be input

from math import radians, sin, cos, sqrt, atan2

def haversine_distance(lat1, lon1, lat2, lon2):

# Convert coordinates from degrees to radians

lat1, lon1, lat2, lon2 = map(radians, [lat1, lon1, lat2, lon2])

# Radius of the Earth in kilometers

earth_radius_km = 6371

# Radius of the Earth in miles

earth_radius_miles = 3959

# Conversion factor from kilometers to feet

km_to_feet = 3280.84

# Calculate the differences in latitude and longitude

dlat = lat2 - lat1

dlon = lon2 - lon1

a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2

# Calculate the central angle of the arc

c = 2 * atan2(sqrt(a), sqrt(1-a))

# Calculate the distance in kilometers, miles, and feet

distance_km = earth_radius_km * c

distance_miles = earth_radius_miles * c

distance_feet = distance_km * km_to_feet

return distance_km, distance_miles, distance_feet

# Coordinates of the two points

lat1, lon1 = 67.5, 97.0

lat2, lon2 = 61.951981, 95.829896

# Calculate the distance using the haversine formula

distance_km, distance_miles, distance_feet = haversine_distance(lat1, lon1, lat2, lon2)

print("Distance between the coordinates:")

print("Kilometers:", distance_km)

print("Miles:", distance_miles)

print("Feet:", distance_feet)

Distance between the coordinates:

Kilometers: 619.3792951275177

Miles: 384.88818543554277

Feet: 2032084.3666261653

It's simply lovely. And I'm guessing the terrain isn't flat so maybe 770 miles would be more accurate than 619 \⁠(⁠◎⁠o⁠◎⁠)⁠/

Not bad for off the top of my head... Takes like two seconds to think of... But apparently a week to finish it ... Maybe two.

Reply to this note

Please Login to reply.

Discussion

No replies yet.