Post Reply 
(42S) Determine Circle From Three Given Points
07-17-2018, 01:21 PM
Post: #6
RE: (42S) Determine Circle From Three Given Points
The HP-42S allows to use complex numbers to solve the problem.

Formula
The three complex number \(a\), \(b\) and \(c\) represent the vertices of the triangle.
Define the following:
\[ \begin{eqnarray}
p=c+a \\
P=c-a \\
\\
q=a+b \\
Q=a-b
\end{eqnarray} \]
Then for the center \(z\) of the circle the following holds true:
(The \(\cdot\) is for the dot-product.)
\[ \begin{eqnarray}
P\cdot(z-\frac{p}{2})=0 \\
Q\cdot(z-\frac{q}{2})=0
\end{eqnarray} \]
This means that the vector from the center to the midpoint is perpendicular to the sides of the triangle.

Given:
\[ \begin{eqnarray}
u=P\cdot p \\
v=Q\cdot q
\end{eqnarray} \]

We can rewrite these equations:
\[ \begin{eqnarray}
P\cdot z=P\cdot\frac{p}{2}=\frac{u}{2} \\
Q\cdot z=Q\cdot\frac{p}{2}=\frac{v}{2}
\end{eqnarray} \]

Or then:
\[ \begin{eqnarray}
P\cdot 2z=u \\
Q\cdot 2z=v
\end{eqnarray} \]

Using:
\[ \begin{eqnarray}
P=P_x+iP_y \\
Q=Q_x+iP_y \\
\\
z=x+iy \\
w=v+iu
\end{eqnarray} \]

This equation can be written using matrix notation:
\[ \begin{bmatrix}
P_x & P_y \\
Q_x & Q_y
\end{bmatrix}

\begin{bmatrix}
2x \\
2y
\end{bmatrix}
=
\begin{bmatrix}
u \\
v
\end{bmatrix} \]

If we transpose this matrix we can rewrite the equation as:
\[ \begin{eqnarray}
g=Q_x+iP_x \\
h=Q_y+iP_y \\
\\
2x\cdot g+2y\cdot h=w
\end{eqnarray} \]

This equation can be cross multiplied both by \(h\) and \(g\):
(Reminder: \(h\times h=g\times g=0\).)
\[ \begin{eqnarray}
2x\cdot h\times g=h\times w \\
2y\cdot h\times g=w\times g=-g\times w
\end{eqnarray} \]

The determinant is:
\[
D=h\times g
\]

We end up with:
\[ \begin{eqnarray}
x=\frac{h\times w}{2D} \\
y=-\frac{g\times w}{2D}
\end{eqnarray} \]

Program
Code:
00 { 69-Byte Prgm }  ; X Y Z T
01 LBL "CENTER"      ; c b a
02 ENTER             ; c c b a
03 R↑                ; a c c b
04 STO+ ST Z         ; a c c+a=p b
05 -                 ; c-a=P p b b
06 LASTX             ; a P p b
07 R↓                ; P p b a
08 DOT               ; u b a a
09 STO 00            ; u b a a
10 X<> ST L          ; P b a a
11 R↓                ; b a a P
12 STO+ ST Z         ; b a a+b=q P
13 -                 ; a-b=Q q P P
14 DOT               ; v P P P
15 STO 01            ; v P P P
16 X<> ST L          ; Q P P P
17 COMPLEX           ; Qy Qx P P
18 R↑                ; P Qy Qx P
19 COMPLEX           ; Py Px Qy Qx
20 X<>Y              ; Px Py Qy Qx
21 R↓                ; Py Qy Qx Px
22 COMPLEX           ; h Qx Px Px
23 X<> ST Z          ; Px Qx h Px
24 COMPLEX           ; g h Px Px
25 RCL 01            ; v g h Px
26 RCL 00            ; u v g h
27 COMPLEX           ; w g h h
28 R↓                ; g h h w
29 CROSS             ; h×g=D h w w
30 STO÷ ST Z         ; D h w/D w
31 X<> ST L          ; g h w/D w
32 X<> ST Z          ; w/D g h w
33 CROSS             ; g×w/D=2x h w w
34 X<>Y              ; h 2x w w
35 LASTX             ; w/D h 2x w
36 CROSS             ; h×w/D=-2y 2x w w
37 +/-               ; 2y 2x w w
38 COMPLEX           ; 2z w w w
39 2                 ; 2 2z w w
40 ÷                 ; z w w w
41 END               ; z w w w

The radius of the circle isn't calculated. But that should be easy now that we know the center.

Example:
A = (1, 4)
B = (-1, 2)
C = (4, -3)

1 ENTER 4 COMPLEX
-1 ENTER 2 COMPLEX
4 ENTER -3 COMPLEX
XEQ "CENTER"
2.5 i0.5


Kind regards
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (42S) Determine Circle From Three Given Points - Thomas Klemm - 07-17-2018 01:21 PM



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