Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. const den = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
  2. if(den != 0) {
  3. const t = ((x1 - x3) * (y3 - y4) - (y1 - y3) * (x3 - x4)) / den;
  4. const u = - ((x1 - x2) * (y1 - y3) - (y1 - y2) * (x1 - x3)) / den;
  5.  
  6. if(t > 0 && t < 1 && u > 0) {
  7. const new_x = x1 + t * (x2 - x1);
  8. const new_y = y1 + t * (y2 - y1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement