Question: Solving for intersect of two circles

If if solve for two circles intersecting the general solution conteint a factor of (xc1-xc2) i.e. x co-ors of the circle centres in both numerator and denominator. So the solution fails if they are equal i.e circles vertically aligned.
I can get arount the problem using  "RealDomain" but that introduces Signum which I dont like and is much slower to solve. I substitued out substitued signum out signum(xc1-xc2)=1. Works.

Just looking for is neater solution approach.
 

restart

NULL

eq1 := (x-xc1)^2+(y-yc1)^2 = R1^2

(x-xc1)^2+(y-yc1)^2 = R1^2

(1)

eq2 := (x-xc2)^2+(y-yc2)^2 = R2^2

(x-xc2)^2+(y-yc2)^2 = R2^2

(2)

eq3 := (xc1-xc2)^2-(yc1-yc2)^2 < (R1+R2)^2

(xc1-xc2)^2-(yc1-yc2)^2 < (R1+R2)^2

(3)

Sol1 := `~`[simplify](solve({eq1, eq2}, [x, y], explicit))[]

[x = (1/2)*((-yc1+yc2)*(-(xc1-xc2)^2*(-xc1^2+2*xc1*xc2-xc2^2+(R1-R2+yc1-yc2)*(R1-R2-yc1+yc2))*(-xc1^2+2*xc1*xc2-xc2^2+(R1+R2+yc1-yc2)*(R1+R2-yc1+yc2)))^(1/2)-(xc1-xc2)*(-xc1^3+xc1^2*xc2+(R1^2-R2^2+xc2^2-yc1^2+2*yc1*yc2-yc2^2)*xc1-xc2*(R1^2-R2^2+xc2^2+yc1^2-2*yc1*yc2+yc2^2)))/((xc1^2-2*xc1*xc2+xc2^2+(yc1-yc2)^2)*(xc1-xc2)), y = ((-(xc1-xc2)^2*(-xc1^2+2*xc1*xc2-xc2^2+(R1-R2+yc1-yc2)*(R1-R2-yc1+yc2))*(-xc1^2+2*xc1*xc2-xc2^2+(R1+R2+yc1-yc2)*(R1+R2-yc1+yc2)))^(1/2)+yc1^3-yc1^2*yc2+(-R1^2+R2^2+xc1^2-2*xc1*xc2+xc2^2-yc2^2)*yc1+yc2^3+(R1^2-R2^2+xc1^2-2*xc1*xc2+xc2^2)*yc2)/(2*yc1^2-4*yc1*yc2+2*yc2^2+2*(xc1-xc2)^2)], [x = (1/2)*((yc1-yc2)*(-(xc1-xc2)^2*(-xc1^2+2*xc1*xc2-xc2^2+(R1-R2+yc1-yc2)*(R1-R2-yc1+yc2))*(-xc1^2+2*xc1*xc2-xc2^2+(R1+R2+yc1-yc2)*(R1+R2-yc1+yc2)))^(1/2)-(xc1-xc2)*(-xc1^3+xc1^2*xc2+(R1^2-R2^2+xc2^2-yc1^2+2*yc1*yc2-yc2^2)*xc1-xc2*(R1^2-R2^2+xc2^2+yc1^2-2*yc1*yc2+yc2^2)))/((xc1^2-2*xc1*xc2+xc2^2+(yc1-yc2)^2)*(xc1-xc2)), y = (-(-(xc1-xc2)^2*(-xc1^2+2*xc1*xc2-xc2^2+(R1-R2+yc1-yc2)*(R1-R2-yc1+yc2))*(-xc1^2+2*xc1*xc2-xc2^2+(R1+R2+yc1-yc2)*(R1+R2-yc1+yc2)))^(1/2)+yc1^3-yc1^2*yc2+(-R1^2+R2^2+xc1^2-2*xc1*xc2+xc2^2-yc2^2)*yc1+yc2^3+(R1^2-R2^2+xc1^2-2*xc1*xc2+xc2^2)*yc2)/(2*yc1^2-4*yc1*yc2+2*yc2^2+2*(xc1-xc2)^2)]

(4)

eval(Sol1[1], [R1 = 85, R2 = 30, xc2 = 200, yc2 = 144.85, xc1 = 130, yc1 = 95.7071])

[x = 178.3493912, y = 165.6165872]

(5)

eval(Sol1[2], [R1 = 85, R2 = 30, xc2 = 200, yc2 = 144.85, xc1 = 130, yc1 = 95.7071])

[x = 212.1767210, y = 117.4323513]

(6)

NULL

NULL

NULL

NULL

Sol2 := `assuming`([`~`[simplify](solve({eq1, eq2}, [x, y], explicit))[]], [eq3])

[x = (1/2)*((-yc1+yc2)*(-(xc1-xc2)^2*(-xc1^2+2*xc1*xc2-xc2^2+(R1-R2+yc1-yc2)*(R1-R2-yc1+yc2))*(-xc1^2+2*xc1*xc2-xc2^2+(R1+R2+yc1-yc2)*(R1+R2-yc1+yc2)))^(1/2)-(xc1-xc2)*(-xc1^3+xc1^2*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c2))*(-xc1^2+2*xc1*xc2-xc2^2+(R1+R2+yc1-yc2)*(R1+R2-yc1+yc2)))^(1/2)+(yc1+yc2)*xc1^2-2*xc2*(yc1+yc2)*xc1+(yc1+yc2)*xc2^2-(yc1-yc2)*(R1^2-R2^2-yc1^2+yc2^2))/(2*xc1^2-4*xc1*xc2+2*xc2^2+2*(yc1-yc2)^2)]

(8)

eval(Sol3[1], [R1 = 85, R2 = 30, xc2 = 200, yc2 = 144.85, xc1 = 130, yc1 = 95.7071])

[x = 178.3493912, y = 165.6165871]

(9)

eval(Sol3[2], [R1 = 85, R2 = 30, xc2 = 200, yc2 = 144.85, xc1 = 130, yc1 = 95.7071])

[x = 212.1767209, y = 117.4323512]

(10)

Sol3a := subs(signum(xc1-xc2) = 1, Sol3[1])

[x = (-(yc1-yc2)*(-(-xc1^2+2*xc1*xc2-xc2^2+(R1-R2+yc1-yc2)*(R1-R2-yc1+yc2))*(-xc1^2+2*xc1*xc2-xc2^2+(R1+R2+yc1-yc2)*(R1+R2-yc1+yc2)))^(1/2)+xc1^3-xc1^2*xc2+(-R1^2+R2^2-xc2^2+yc1^2-2*yc1*yc2+yc2^2)*xc1+xc2*(R1^2-R2^2+xc2^2+yc1^2-2*yc1*yc2+yc2^2))/(2*xc1^2-4*xc1*xc2+2*xc2^2+2*(yc1-yc2)^2), y = ((xc1-xc2)*(-(-xc1^2+2*xc1*xc2-xc2^2+(R1-R2+yc1-yc2)*(R1-R2-yc1+yc2))*(-xc1^2+2*xc1*xc2-xc2^2+(R1+R2+yc1-yc2)*(R1+R2-yc1+yc2)))^(1/2)+(yc1+yc2)*xc1^2-2*xc2*(yc1+yc2)*xc1+(yc1+yc2)*xc2^2-(yc1-yc2)*(R1^2-R2^2-yc1^2+yc2^2))/(2*xc1^2-4*xc1*xc2+2*xc2^2+2*(yc1-yc2)^2)]

(11)

Sol3b := subs(signum(xc1-xc2) = 1, Sol3[2])

[x = ((yc1-yc2)*(-(-xc1^2+2*xc1*xc2-xc2^2+(R1-R2+yc1-yc2)*(R1-R2-yc1+yc2))*(-xc1^2+2*xc1*xc2-xc2^2+(R1+R2+yc1-yc2)*(R1+R2-yc1+yc2)))^(1/2)+xc1^3-xc1^2*xc2+(-R1^2+R2^2-xc2^2+yc1^2-2*yc1*yc2+yc2^2)*xc1+xc2*(R1^2-R2^2+xc2^2+yc1^2-2*yc1*yc2+yc2^2))/(2*xc1^2-4*xc1*xc2+2*xc2^2+2*(yc1-yc2)^2), y = (-(xc1-xc2)*(-(-xc1^2+2*xc1*xc2-xc2^2+(R1-R2+yc1-yc2)*(R1-R2-yc1+yc2))*(-xc1^2+2*xc1*xc2-xc2^2+(R1+R2+yc1-yc2)*(R1+R2-yc1+yc2)))^(1/2)+(yc1+yc2)*xc1^2-2*xc2*(yc1+yc2)*xc1+(yc1+yc2)*xc2^2-(yc1-yc2)*(R1^2-R2^2-yc1^2+yc2^2))/(2*xc1^2-4*xc1*xc2+2*xc2^2+2*(yc1-yc2)^2)]

(12)

eval(Sol3a, [R1 = 85, R2 = 30, xc2 = 200, yc2 = 144.85, xc1 = 130, yc1 = 95.7071])

[x = 212.1767209, y = 117.4323512]

(13)

eval(Sol3b, [R1 = 85, R2 = 30, xc2 = 200, yc2 = 144.85, xc1 = 130, yc1 = 95.7071])

[x = 178.3493912, y = 165.6165871]

(14)

NULL


 

Download 28-10-28_Q_Circles_Intersect.mw

 

Please Wait...