The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
(41) Intersection points between circles
11-25-2020, 03:07 PM (This post was last modified: 03-20-2021 08:39 PM by Gene.)
Post: #1
(41) Intersection points between circles
Hi,

if somebody else already did a program to find the intersection points of two circles I could not find it.

So here is mine:

Program CIP
Program to determine the intersection points of two circles. Circles are defined by coordinates of central point and radius. 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.

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)

A revised version that is shorter and does not use Flag 02 is below. Thanks to Albert Chan who showed me ways to improve the program!

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


Messages In This Thread
(41) Intersection points between circles - rawi - 11-25-2020 03:07 PM



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