/// <summary>
///
/// </summary>
/// <param name="vertices1"></param>
/// <param name="vertices2"></param>
/// <returns></returns>
public bool Overlap(Vector2[] vertices1, Vector2[] vertices2)
{
Vector2[] axes1 = GetAxes(vertices1);
Vector2[] axes2 = GetAxes(vertices2);
// loop over the axes1
for (int i = 0; i < axes1.Length; i++)
{
Vector2 axis = axes1[i];
// project both shapes onto the axis
Projection p1 = Project(vertices1, axis);
Projection p2 = Project(vertices2, axis);
// do the projections overlap?
if (!p1.Overlap(p2))
{
// then we can guarantee that the shapes do not overlap
return(false);
}
}
// loop over the axes2
for (int i = 0; i < axes2.Length; i++)
{
Vector2 axis = axes2[i];
// project both shapes onto the axis
Projection p1 = Project(vertices1, axis);
Projection p2 = Project(vertices2, axis);
// do the projections overlap?
if (!p1.Overlap(p2))
{
// then we can guarantee that the shapes do not overlap
return(false);
}
}
// if we get here then we know that every axis had overlap on it
// so we can guarantee an intersection
return(true);
}