Post Reply 
(41) Intersection points between circles
11-30-2020, 05:19 PM (This post was last modified: 12-01-2020 04:28 PM by rawi.)
Post: #6
RE: Intersection points between circles
Hi Albert,

thank you very much for the interesting discussion.
The solution that is used in my program indeed uses as well the Law of Cosine. The difference between your solution and mine is that I use directly the coordinates given. You first transfer it to an easier problem by setting one midpoint to (0;0) and the other to (d;0), but then you have it to transfer back. I am not yet sure which solution is easier.

Unfortunately I do not know how to insert a image that is not on a website. So I try to describe it without a picture.

Let
(x1,y1) be the coordinates of the first midpoint
(x2,y2) be the coordinates of the second midpoint
r1 be the radius of the first circle
r2 be the radius of the second circle

First the distance between midpoints is computed (steps 16-30): z=((x1-x2)^2+(y1-y2)^2)^0.5

Then we compute the angle between line between midpoints and paralell to x-axis (steps31-38):
alpha = arcsin((y2-y1)/z)

The triangle made by the midpoints and the first intersection have the sides z, r1 and r2. Therefore we can compute the angle between line between midpoints and line from midpoint of first circle to first intersection point by using the Law of Cosine (steps 39-54):

beta = arccos((z²+r1²-r2²)/(2*z*r1))

Now we must take into account, whether x2<x1 or x2>=x1 and analogue with y1 and y2.
We set sg1 = 1 if x2>=x1 and sg1 = -1 if x2<x1
and likewise sg2 = 1 fi y2 >= y1 and sg2 = -1 if y2 < y1.
This is done by using flag 01 and flag 02.
Then we can compute the coordinates of the two intersection points (sx1, sy1) (steps 55-73) and (sx2, sy2) (steps 75-95):

sx1 = x1 + r1*(cos(alpha+beta))*sg1
sy1 = y1 + r1*(sin(alpha+beta))*sg2
sx2 = x1 + r1*(cos(alpha-beta))*sg1
sy2 = y1 + r1*(sin(alpha-beta))*sg2

This is the solution given.
I hope this makes it a little more transparent.

Best

Raimund
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Intersection points between circles - rawi - 11-30-2020 05:19 PM



User(s) browsing this thread: 3 Guest(s)