Last active
July 13, 2017 13:15
-
-
Save BoeseB/e8ecf8605c9270e9bff612bce4cf406a to your computer and use it in GitHub Desktop.
DistanceCheck https://stackoverflow.com/q/45078206/4369295
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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