Skip to content

Instantly share code, notes, and snippets.

@nimdraugsael
Created July 15, 2013 07:44
Show Gist options
  • Save nimdraugsael/5998124 to your computer and use it in GitHub Desktop.
Save nimdraugsael/5998124 to your computer and use it in GitHub Desktop.
angular.module('Map').service 'MapGeometry', ['Underscore', (_) ->
get: (point_a, point_b) ->
delta_x = point_b[0] - point_a[0]
delta_y = point_b[1] - point_a[1]
cos_alpha = delta_x / Math.sqrt(delta_x*delta_x + delta_y*delta_y)
Math.acos(cos_alpha) * ((delta_y > 0) ? 1 : -1 )
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment