Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool intersectLines(Vec p0, Vec p1, Vec p2, Vec p3) {
- vec_dimension s1_x, s1_y, s2_x, s2_y;
- s1_x = p1.x - p0.x; s1_y = p1.y - p0.y;
- s2_x = p3.x - p2.x; s2_y = p3.y - p2.y;
- vec_dimension s, t;
- s = (-s1_y * (p0.x - p2.x) + s1_x * (p0.y - p2.y)) / (-s2_x * s1_y + s1_x * s2_y);
- t = ( s2_x * (p0.y - p2.y) - s2_y * (p0.x - p2.x)) / (-s2_x * s1_y + s1_x * s2_y);
- return (s >= 0 && s <= 1 && t >= 0 && t <= 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement