diff --git a/geometry.go b/geometry.go index 80682ab..882a282 100644 --- a/geometry.go +++ b/geometry.go @@ -483,15 +483,12 @@ func (c Circle) Intersect(d Circle) Circle { // - An edge of the Rect is a tangent to the Circle func (c Circle) IntersectsRect(r Rect) bool { // Checks if the c.Center is not in the diagonal quadrants of the rectangle - var grownR Rect if (r.Min.X <= c.Center.X && c.Center.X <= r.Max.X) || (r.Min.Y <= c.Center.Y && c.Center.Y <= r.Max.Y) { // 'grow' the Rect by c.Radius in each diagonal - grownR = Rect{ + return Rect{ Min: r.Min.Sub(V(c.Radius, c.Radius)), Max: r.Max.Add(V(c.Radius, c.Radius)), - } - - return grownR.Contains(c.Center) + }.Contains(c.Center) } // The center is in the diagonal quadrants return c.Center.To(r.Min).Len() <= c.Radius || c.Center.To(r.Max).Len() <= c.Radius