Problem 58852. Intersection(s) of Circles
Do two given circles intersect in Zero, One, or Two points and provide the intersection(s). The Stafford method may provide some guidance and alternate solution method. I will elaborate a more geometric solution utilizing Matlab specific functions, rotation matrix, and translation matrix. Assumption is that Matlab function circcirc is not available.
Given circles [x1,y1,R] and [x2,y2,P] return the intersections [], [x y], or [x y;x y].
The below figure is created based upon d=distance([x1,y1],[x2,y2]), translating (x1,y1) to (0,0), and rotating (x2,y2) to be on the Y-axis. From this manipulation two right triangles are apparent: [X,Y,R] and [X,d-Y,P]. Subtracting and simplifying these triangles leads to Y and two X values after substituting back into R^2=X^+Y^2 equation.
P^2=X^2+(d-Y)^2 and R^2=X^2+Y^2 after subtraction gives R^2-P^2=Y^2-(d-Y)^2 = Y^2-d^2+2dY-Y^2=2dY-d^2 thus
Y=(R^2-P^2+d^2)/(2d) and X=+/- (R^2-Y^2)^.5
The trick is to now un-rotate and translate this solution matrix using t=atan2(dx,dy), [cos(t) -sin(t);sin(t) cos(t)] and [x1 y1]
Diagram showing a normalization of posed problem where (x1,y1) is placed at origin and (x2,y2) is placed on Y-axis at distance d. Final (x,y) values will require rotation and shifting.
Solution Stats
Problem Comments
-
1 Comment
Richard Zapor
on 11 Aug 2023
Test cases updated 8/11/23 to include the top single point case. Revised template and my solution. Re-scoring not activated. The function norm is nice and sloow. I like the old days when scoring could be based on time and other creator functions.
Solution Comments
Show commentsProblem Recent Solvers6
Suggested Problems
-
22255 Solvers
-
260 Solvers
-
Sum the numbers on the main diagonal
581 Solvers
-
1309 Solvers
-
129 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!