This little program is to determine the intersection points of two circles. Circles are defined by coordinates of midpoint and radius. Midpoints have to be different.
Output is coordinates of the intercept points of the two circles. If there is no solution message is given. If both solutions are the same there is only 1 solution.
Program works without any changes as well for DM42.
Use of registers:
Circle 1: Coordinates of midpoint: x: 01, y: 02
Radius: 03
Circle 2: Coordinates of midpoint: x: 04, y: 05
Radius: 06
07: Distance between the two midpoints.
08: Angle between x-axis and line between midpoints
09: Angle at midpoint of first circle of the triangle formed by midpoints and first intersection of cycles
10: For computation
Output:
Coordinates of intersection points: Point 1: x: 11, y: 12; Point 2: x: 13, y: 14
Flags used: 01, 02
Example:
Circle 1 has the central point x=13, y=4 and the radius 6.8
Circle 2 has the central point x=6, y=10 and the radius 4
Keystrokes:
XEQ Alpha CIP Alpha
-> CIRCLE1? 13 ENTER 4 ENTER 6.8 R/S
-> CIRCLE2? 6 ENTER 10 ENTER 4 R/S
-> 9.9987 (x-value of 1st intersection point) X<>Y 10.1018 (y-value of 1st intersection point) – R/S -
-> 6.5109 (x-value of 2nd intersection point) X<>Y 6.0328 (y-value of 2nd intersection point)
Dec. 1st 2020: Code was replaced by a shorter and simpler version due to hints from Albert Chan from HPmuseum.org
Code: Select all
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