Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const den = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
- if(den != 0) {
- const t = ((x1 - x3) * (y3 - y4) - (y1 - y3) * (x3 - x4)) / den;
- const u = - ((x1 - x2) * (y1 - y3) - (y1 - y2) * (x1 - x3)) / den;
- if(t > 0 && t < 1 && u > 0) {
- const new_x = x1 + t * (x2 - x1);
- const new_y = y1 + t * (y2 - y1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement