Skip to content

Instantly share code, notes, and snippets.

@morganherlocker
Last active August 29, 2015 14:09
Show Gist options
  • Select an option

  • Save morganherlocker/8fd7ce0f4cafa52ebb4f to your computer and use it in GitHub Desktop.

Select an option

Save morganherlocker/8fd7ce0f4cafa52ebb4f to your computer and use it in GitHub Desktop.

x1,y1,x2,y2 | x3,y3,x4,y4

vertical into horizontal

return x1, y3

horizontal into segment

var low
var high
if(y3 <= y4) {
  low = y3
  high = y4
}
else {
  low = y4
  high = y3
}

// no intersect
if(low > y1 && high <y1) {
  return;
} else {
  // horizontal line intercept of some sort? 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment