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
function distance(p1, p2) { | |
// Find the distance between two points | |
return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2)); | |
}; | |
function intersect(c1, r1, c2, r2) { | |
// Find the points of intersection for two circles | |
// Based on: http://stackoverflow.com/a/3349134 | |
var d = distance(c1, c2); | |
if (d > r1 + r2) // Circles do not overlap |