I'd like to create a function that calculates the distance between two pairs of lat/longs using the pythag theorem instead of the haversine great-circle formula. Since this will be over relative short distances (3km), I think this version that assumes a flat earth should be OK. How can I do this? I asked the internet and didn't come up with anything useful. :)
Thanks.
Tom
EDIT:
Here's what I came up with (seems to be working):
def get_dist(lat0, lng0, lat1, lng1)
begin
d_ew = (lng1.to_f - lng0.to_f) * Math.cos(lat0.to_f)
d_ns = (lat1.to_f - lat0.to_f)
d_lu = Math.sqrt(d_ew.to_f * d_ew.to_f + d_ns.to_f * d_ns.to_f)
d_mi = ((2*Math::PI*3961.3)/360)*d_lu
return d_mi
rescue Exception => ex
logger.debug "[get_dist] An exception occurred: #{ex.message}"
return -1
end
end
Thanks Evan!