1function isIntersecting(p1, p2, p3, p4) {
2 function CCW(p1, p2, p3) {
3 return (p3.y - p1.y) * (p2.x - p1.x) > (p2.y - p1.y) * (p3.x - p1.x);
4 }
5 return (CCW(p1, p3, p4) != CCW(p2, p3, p4)) && (CCW(p1, p2, p3) != CCW(p1, p2, p4));
6}