internal bool IsLeftOf(Vector2 p)
{
Site topSite;
bool rightOfSite, above, fast;
float dxp, dyp, dxs, t1, t2, t3, yl;
topSite = edge.RightSite;
rightOfSite = p.x > topSite.X;
if (rightOfSite && this.leftRight == LR.LEFT)
{
return true;
}
if (!rightOfSite && this.leftRight == LR.RIGHT)
{
return false;
}
if (edge.a == 1.0)
{
dyp = p.y - topSite.Y;
dxp = p.x - topSite.X;
fast = false;
if ((!rightOfSite && edge.b < 0.0) || (rightOfSite && edge.b >= 0.0))
{
above = dyp >= edge.b * dxp;
fast = above;
}
else
{
above = p.x + p.y * edge.b > edge.c;
if (edge.b < 0.0)
{
above = !above;
}
if (!above)
{
fast = true;
}
}
if (!fast)
{
dxs = topSite.X - edge.LeftSite.X;
above = edge.b * (dxp * dxp - dyp * dyp) <
dxs * dyp * (1.0 + 2.0 * dxp / dxs + edge.b * edge.b);
if (edge.b < 0.0)
{
above = !above;
}
}
}
else /* edge.b == 1.0 */
{
yl = edge.c - edge.a * p.x;
t1 = p.y - yl;
t2 = p.x - topSite.X;
t3 = yl - topSite.Y;
above = t1 * t1 > t2 * t2 + t3 * t3;
}
return this.leftRight == LR.LEFT ? above : !above;
}