ELASTICPATHING/SOURCECODE/UbiComp2014/Elastic_Pathing_Code/path_decisions.rb
def haversine_mi(node_a, node_b)
  lat1 = node_a.lat
  lon1 = node_a.lon
  lat2 = node_b.lat
  lon2 = node_b.lon
  @d2r = Math::PI / 180.0
  dlon = (lon2 - lon1) * @d2r;
  dlat = (lat2 - lat1) * @d2r;
  a = Math.sin(dlat/2.0)**2 + Math.cos(lat1*@d2r) * Math.cos(lat2*@d2r) * Math.sin(dlon/2.0)**2;
  c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
  #Multiply by the radius of the earth (in miles here)
  return 3956 * c; 
end
#Haversine distance in miles (used to find actual distances between GSP coordinates)
Haversine distance in miles (used to find actual distances between GSP coordinates)
Haversine distance in miles ( used to find actual distances between GSP coordinates )
def haversine_mi(node_a, node_b)
  lat1 = node_a.lat
  lon1 = node_a.lon
  lat2 = node_b.lat
  lon2 = node_b.lon
  @d2r = Math::PI / 180.0
  dlon = (lon2 - lon1) * @d2r;
  dlat = (lat2 - lat1) * @d2r;
  a = Math.sin(dlat/2.0)**2 + Math.cos(lat1*@d2r) * Math.cos(lat2*@d2r) * Math.sin(dlon/2.0)**2;
  c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
  return 3956 * c; 
end
def haversine_mi ( node_a , node_b ) lat1 = node_a . lat lon1 = node_a . lon lat2 = node_b . lat lon2 = node_b . lon @d2r = Math :: PI / 180.0 dlon = ( lon2 - lon1 ) * @d2r ; dlat = ( lat2 - lat1 ) * @d2r ; a = Math . sin ( dlat / 2.0 ) ** 2 + Math . cos ( lat1 * @d2r ) * Math . cos ( lat2 * @d2r ) * Math . sin ( dlon / 2.0 ) ** 2 ; c = 2 * Math . atan2 ( Math . sqrt ( a ) , Math . sqrt ( 1 - a ) ) ; return 3956 * c ; end
Haversine distance in miles (used to find actual distances between GSP coordinates)
Haversine distance in miles ( used to find actual distances between GSP coordinates )
#Multiply by the radius of the earth (in miles here)
node_a
node_b