Skip to content

Instantly share code, notes, and snippets.

~~setting up~~

Ben Pyrik bryik

~~setting up~~
Block or report user

Report or block bryik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jupdike / IntersectTwoCircles.js
Last active Oct 8, 2019
Find the intersections (two points) of two circles, if they intersect at all
View IntersectTwoCircles.js
// based on the math here:
// x1,y1 is the center of the first circle, with radius r1
// x2,y2 is the center of the second ricle, with radius r2
function intersectTwoCircles(x1,y1,r1, x2,y2,r2) {
var centerdx = x1 - x2;
var centerdy = y1 - y2;
var R = Math.sqrt(centerdx * centerdx + centerdy * centerdy);
if (!(Math.abs(r1 - r2) <= R && R <= r1 + r2)) { // no intersection
You can’t perform that action at this time.