private int LinePointLocation(double x1, double y1, double x2, double y2, double x, double y)
{
double z;
if (Math.Atan((y2 - y1) / (x2 - x1)) * 180.0 / Math.PI == 90.0)
{
if (Math.Abs(x1 - x) <= 0.00000000001)
return 0;
}
else
{
if (Math.Abs(y1 + (((y2 - y1) * (x - x1)) / (x2 - x1)) - y) <= EPS)
return 0;
}
// third component of the 3 dimensional product
z = (x2 - x1) * (y - y1) - (y2 - y1) * (x - x1);
if (Math.Abs(z - 0.0) <= 0.00000000001)
{
return 0;
}
else if (z > 0)
{
return 1;
}
else
{
return 2;
}
}