I can't for the life of me figure out how to get it to return true if the segments cross. Any help would be greatly appreciated.
bool doCross(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
bool cross = true;
double denom, uA, uB;
denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
if(denom == 0)
{
cross = false;
}
else
{
uA = (x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3) / denom;
uB = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3) / denom;
}
if (abs(0 < uA) && abs(uA < 1) && abs(0 < uB) && abs(uB < 1))
{
cross = true;
}
else
{
cross = false;
}
return cross;
}