Skip to content

Instantly share code, notes, and snippets.

View vasrap's full-sized avatar

Vasilis Raptakis vasrap

  • San Francisco, California
View GitHub Profile
### Keybase proof
I hereby claim:
* I am scaraveos on github.
* I am scaraveos (https://keybase.io/scaraveos) on keybase.
* I have a public key whose fingerprint is B854 018E 7C5C C6EB 393F E19F D07F 0280 53AA 7543
To claim this, I am signing this object:
@vasrap
vasrap / android_distance_port.rb
Created April 27, 2013 17:12
Calculates distance in meters between 2 GPS coordinates (Android port)
# Calculates distance in meters between 2 GPS coordinates
# Ported to Ruby from the Android SDK source
# Original paper explaning the process: http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf
# Arguments p1, p2 are instances of the class Point below:
# class Point
# attr_accessor :lat, :lon
# end
def android_distance_port(p1, p2)
@vasrap
vasrap / haversine_distance.rb
Created April 27, 2013 17:05
Calculates the distance in meters between 2 GPS coordinates using the haversine formula
# Calculates the distance in meters between 2 GPS coordinates
# http://en.wikipedia.org/wiki/Haversine_formula
# Arguments p1, p2 are instances of the class Point below:
# class Point
# attr_accessor :lat, :lon
# end
def haversine_distance(p1, p2)
lat1 = p1.lat
@vasrap
vasrap / mercator-latlon-to-meters.rb
Last active March 15, 2021 15:54
Lat/Lon to Meters using Mercator projection
puts "Enter latitude in decimal degrees:"
lat_deg = gets.to_f
puts "Enter longitude in decimal degrees:"
lon_deg = gets.to_f
lon_rad = (lon_deg / 180.0 * Math::PI)
lat_rad = (lat_deg / 180.0 * Math::PI)
sm_a = 6378137.0
x = sm_a * lon_rad
y = sm_a * Math.log((Math.sin(lat_rad) + 1) / Math.cos(lat_rad))