Hopefully this should be a quick one. I’m using a function at the moment which returns a boolean depending upon a passed position and radius as such:
Public Shared Function IsInCircle(Position As Vector2, radius As Integer) As Boolean If Position.X ^ 2 + Position.Y ^ 2 <= Radius ^ 2 Then Return True Else Return False End If End Function
This is a pretty simple equation, but I’m using it for many, many objects. I’ve read that you should really check if the position is within a box before going any further, this would be really easy to add to this function, but the question is; If checking within a box is the quickest thing to do, why not look within 3 boxes rotated 0 degrees, 30, 60? Or if the collision point isn’t of huge importance, why not check within a 0 and 45 degree box? Matrix transforms seem to be hugely fast compared to squares and roots.
I’d want to use this approach where actual contact of two objects is not essential, just proximity.