First of all math.cos expects angle argument in radians. To convert from degrees to radians you need to do:
rad_avg = avg * math.pi / 180
Or even:
math.radians(<angle_in_degrees>)
Basically it means you're mapping 180º with pi
and taking the portion for your angle.
I assume then that you want to compute distance between both points by converting it first to "xy" coordinates (according to your reference).
You need to get first both points in the same coordinate system. As the link states, for small areas, they can be estimated by:
So you need to do:
import math
point1 = (-37.8206195, 144.9837765) # Lat/Long (lambda/phi)
point2 = (-37.8193712, 144.9837765) # Lat/Long (lambda/phi)
r = 6371000 # meters
phi_0 = point1[1]
cos_phi_0 = math.cos(math.radians(phi_0))
def to_xy(point, r, cos_phi_0):
lam = point[0]
phi = point[1]
return (r * math.radians(lam) * cos_phi_0, r * math.radians(phi))
point1_xy = to_xy(point1, r, cos_phi_0)
point2_xy = to_xy(point2, r, cos_phi_0)
Finally, to compute distance in cartesian coordinates you need to use the Pitagoras Theorem d = sqrt(delta_x^2 + delta_y^2)
In your example:
dist = math.sqrt((point1_xy[0] - point2_xy[0])**2 + (point1_xy[1] - point2_xy[1])**2)
Which results: 113.67954606562853
. Closer to what you're looking for.
Plus, there's a shortcut to get it right to the distance formula:
d = r * sqrt(x² + y²)
where x = (λ2 - λ1) * math.cos(φ0)
and y = (φ2 - φ1)