Post Reply 
(41) Intersection points between circles
12-01-2020, 02:04 PM (This post was last modified: 12-01-2020 04:29 PM by rawi.)
Post: #12
RE: Intersection points between circles
Hi Albert,

I tried it and you are totally right. Thanks for pointing that out to me.

Here is the improved method description:

Let (x1, y1) be the coordinates of midpoint of circle 1 and (x2, y2) be the coordinates of midpoint of circle 2 and r1 resp. r2 be the radii.
Let z be the distance between the midpoints: z=((x1-x2)²+(y1-y2)²)^0.5
The angle alpha between the line between the midpoints and the parallel to the x-axis through (x1, y1) using the sinus-function is:

alpha = arcsin((y2-y1)/z)
Beta can be computed by using the Law of Cosine:

beta = arccos((z²+r1²-r2²)/(2*z*r1))
We must take into account, whether x2<x1 or x2>=x1.
We set sg = 1 if x2>=x1 and sg1 = -1 if x2<x1
Then the coordinates of the two intersection points are:

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

And here is the improved code, which is shorter and easier than the previous one:

Code:
01 LBL „CIP“
02 CF 01
03 “CIRCLE1?”
04 PROMPT        Input of midpoint and radius of circle 1
05 STO 03
06 RDN
07 STO 02
08 RDN
09 STO 01
10 “CIRCLE2?”
11 PROMPT        Input of midpoint and radius of circle 2
12 STO 06
13 RDN
14 STO 05
15 RCL 02
16 -
17 X²
18 X<>Y
19 STO 04
20 RCL 01 
21 X>Y?
22 SF 01
23 -
24 X²
25 +
26 SQRT
27 STO 07        Distance between midpoints
28 RCL 05
29 RCL 02
30 -
31 X<>Y
32 /
33 ASIN
34 STO 08        Angle between line between midpoints and x-axis
35 RCL 07
36 X²
37 RCL 03
38 X²
39 +
40 RCL 06
41 X²
42 -
43 2
44 /
45 RCL 07
46 /
47 RCL 03
48 /
49 ACOS
55 STO 09
51 +
52 COS
53 LASTX
54 SIN
55 RCL 03
56 *
57 RCL 02
58 +
59 STO 12
60 X<>Y
61 RCL 03
62 *
63 FS? 01
64 CHS
65 RCL 01 
66 +
67 STO 11
68 STOP        X-register: x-coordinate, Y register: y-coordinate of first intersection point
69 RCL 08
70 RCL 09
71 -
72 COS
73 LASTX
74 SIN
75 RCL 03
76 *
77 RCL 02
78 +
79 STO 14
80 X<>Y
81 RCL 03
82 *
83 FS? 01
84 CHS
85 RCL 01
86 +
87 STO 13
88 GTO 02
89 LBL 01
90 “NO SOLUTION”
91 AON
92 STOP
93 AOFF
94 LBL 02
95 CF 01
96 END
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Intersection points between circles - rawi - 12-01-2020 02:04 PM



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