Skip to content

Instantly share code, notes, and snippets.

@rowanwins
Created April 29, 2020 23:07
Show Gist options
  • Save rowanwins/f665fa7be671827e0def6d6d475d926a to your computer and use it in GitHub Desktop.
Save rowanwins/f665fa7be671827e0def6d6d475d926a to your computer and use it in GitHub Desktop.
function crossProduct (a, b) {
return (a.x * b.y) - (a.y * b.x)
}
const ab = crossProduct(A, B)
const ac = crossProduct(A, C)
const bd = crossProduct(B, D)
const cd = crossProduct(C, D)
const isInRange = (ab * bd < 0 && ac * cd > 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment