kupo15
Member
I'm trying to find the intersection of two circles (I only need the bottom one or left one) and its obvious you need to do some different methods to solve it. I found this on a java site and it should be able to work here but I'm not not quite getting it to work? Has anyone done this before and can help out?
I was using this site
https://fypandroid.wordpress.com/2011/07/03/how-to-calculate-the-intersection-of-two-circles-java/
I was using this site
https://fypandroid.wordpress.com/2011/07/03/how-to-calculate-the-intersection-of-two-circles-java/
Code:
// scr_intersection(x1,y1,r1,x2,y2,r2);
var x1,y1,r1,x2,y2,r2;
x1 = argument0;
y1 = argument1;
r1 = argument2;
x2 = argument3;
y2 = argument4;
r2 = argument5;
var apart,d1,h;
apart = point_distance(x1,y1,x2,y2); // distance between two circles
d1 = (sqr(r1)-sqr(r2)+sqr(apart))/(2*apart);
h = sqrt(sqr(r1)-sqr(d1));
var x3,y3;
x3 = x1+(d1*(x2-x1))/apart;
y3 = y1+(y1*(y2-y1))/apart;
// intersection 1
var x4,y4;
x4 = x3+(h*(y2-y1))/apart;
y4 = y3-(h*(x2-x1))/apart;