http://acm.hdu.edu.cn/discuss/public/post/reply.php?postid=2124&messageid=2&deep=1
private bool intersect(double xa1, double ya1, double xa2, double ya2,
double xb1, double yb1, double xb2, double yb2)
{
if (((xa2 - xa1) * (yb1 - ya1) - (xb1 - xa1) * (ya2 - ya1)) *
((xa2 - xa1) * (yb2 - ya1) - (xb2 - xa1) * (ya2 - ya1)) > 0)
return false;
if (((xb2 - xb1) * (ya1 - yb1) - (xa1 - xb1) * (yb2 - yb1)) *
((xb2 - xb1) * (ya2 - yb1) - (xa2 - xb1) * (yb2 - yb1)) > 0)
return false;
return true;
}