Skip to content

Instantly share code, notes, and snippets.

@jesty
Last active August 29, 2015 14:23
Show Gist options
  • Save jesty/4f5224d80806f6a1ce08 to your computer and use it in GitHub Desktop.
Save jesty/4f5224d80806f6a1ce08 to your computer and use it in GitHub Desktop.
Route with same direction
/*
* Starting from two route, this algorithm, verify if they are the same direction.
* The computeHeading function is defined in https://gist.github.com/jesty/7b2a8e31d56c13a6adff
*/
var sameDirection = function(startA, endA, startB, endB){
var headingA = computeHeading(startA, endA);
var headingA = computeHeading(startB, endB);
return Math.abs(headingA - headingA) < 45
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment