← Back to challenges

Simple Circle Collision Detection

JavaScriptHardgamesalgebraalgorithmsmath

Instructions

Create a function that returns true if the given circular areas are intersecting, otherwise return false. The circles are given as two arrays containing the values in the following order:

  1. Radius of the circle.
  2. Center position on the x-axis.
  3. Center position on the y-axis.

Examples

isCircleCollision([10, 0, 0], [10, 10, 10]) ➞ true

isCircleCollision([1, 0, 0], [1, 10, 10]) ➞ false

Notes

  • You can expect useable input and positive radii.
  • The given coordinates are the centers of the circles.
  • We are looking for intersecting areas, not intersection outlines.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Perfect Square Patch