Skip to content

Instantly share code, notes, and snippets.

@BoeseB
Last active July 13, 2017 13:15
Show Gist options
  • Save BoeseB/e8ecf8605c9270e9bff612bce4cf406a to your computer and use it in GitHub Desktop.
Save BoeseB/e8ecf8605c9270e9bff612bce4cf406a to your computer and use it in GitHub Desktop.
public bool failsHoleConditions(HoleInfo holeOne, HoleInfo holeTwo)
{
var radiusSum = (holeOne.Diameter + holeTwo.Diameter) /2;
var distanceX = Math.Abs(holeOne.X - holeTwo.X);
var distanceY = Math.Abs(holeOne.Y - holeTwo.Y);
var distanceHolesSquare = (distanceX * distanceX) + (distanceY * distanceY) - (radiusSum * radiusSum);
if (distanceHolesSquare <= 0)
{
//Overlaping
return true;
}
else if (distanceHolesSquare <= minimumSpaceSquare)
{
//Distance too small
holeMinSpaceFailed = true;
return true;
}
return false;
}
internal struct HoleInfo
{
public int Diameter { get; internal set; }
public float X { get; internal set; }
public float Y { get; internal set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment