## circles of Apollonius

Expand Messages
• OK, if the subject got your attention, I REALLY need your help.. My geometric and algebraic abilities usually get me by, but I cannot seem to get my head
Message 1 of 9 , Jul 4, 2006
OK, if the subject got your attention, I REALLY need your help..

My geometric and algebraic abilities usually get me by, but I cannot
seem to get my head around this problem:

Given the coordinates and radii of three circles, find the center of a
circle tangent to all three.. of the 8 possible solutions I want the
one where the original circles are all OUTSIDE the unknown circle.

Or better yet, given the coordinates and radii of two circles and a
point on the circumference of the third circle, find the center point
of the third circle tangent to the first two. of the four(?) possible
solutions, I again want the one where the original circles are OUTSIDE
the unknown circle.

All of the stuff I find on the net is theory and comes far short of
giving me what I need to solve this.. with my limited algebra, I
really need a specific formula. or better yet, a code snippet!

I know we have some mathematic giants here...

I need this to construct a working 'keyboard' from a chunk of anything
solid.. ( for instance, A chunk of wood with the keys drawn on in
crayon!) If anyone wants to know more, I will elaborate.

Thanks much!
• ... After reading the text below I think it is possible to make a program that will give you the x,y,r given three known circles. Stefan Hesseling Let given
Message 2 of 9 , Jul 4, 2006
--- In libertybasic@yahoogroups.com, "glitz486" <glitz486@...> wrote:
>
> OK, if the subject got your attention, I REALLY need your help..
>
> My geometric and algebraic abilities usually get me by, but I cannot
> seem to get my head around this problem:
>
> Given the coordinates and radii of three circles, find the center of a
> circle tangent to all three.. of the 8 possible solutions I want the
> one where the original circles are all OUTSIDE the unknown circle.
>

After reading the text below I think it is possible to make a program
that will give you the x,y,r given three known circles.

Stefan Hesseling

"
Let given circles have radii r1, r2, and r3, and centers at (x1, y1),
(x2, y2), and (x3, y3). We are looking for a circle of (unknown)
radius r centered at (an unknown point) (x, y). The conditions of
tangency result in three quadratic equations:
(x - x1)2 + (y - y1)2 = (r ± r1)2
(x - x2)2 + (y - y2)2 = (r ± r2)2
(x - x3)2 + (y - y3)2 = (r ± r3)2

The signs in the three equations can be chosen independently of each
other. Therefore the problem may have as many as 2·2·2 = 8 solutions,
but does not always have that many. In a general case, subtracting one
of the equations from the remaining two results in a system of 2
linear equations, from which x and y may be expressed in terms of r.
that the unknown quantities x, y, r can be expressed in terms of
"

From:

http://www.cut-the-knot.org/Curriculum/Geometry/ApolloniusSolution.shtml
• Have a look at my solution at http://atschool.eduweb.co.uk/taunton/LB/Apollonius7.bas or try the following (usual caution about linewraps) It kept me happy for
Message 3 of 9 , Jul 6, 2006
Have a look at my solution at
http://atschool.eduweb.co.uk/taunton/LB/Apollonius7.bas
or try the following (usual caution about linewraps)
It kept me happy for hours 'cos I kept getting terms wrong... I must try
the general case some time

' Apollonius7- generate in-circle

' NB This does NOT check for intersecting circles or other special cases

nomainwin

UpperLeftX = 50
UpperLeftY = 50
WindowWidth =600
WindowHeight =640

button #w.b, "Find", [calc], LL, 10, 100

statictext #w.st1, "Circle1", 10, 20, 40, 15
statictext #w.st1, "x", 60, 40, 40, 15
statictext #w.st1, "y", 60, 70, 40, 15
statictext #w.st1, "r", 60, 100, 40, 15
textbox #w.t1x, 10, 40, 40, 20
textbox #w.t1y, 10, 70, 40, 20
textbox #w.t1r, 10,100, 40, 20

statictext #w.st1, "Circle2", 10, 160, 40, 15
statictext #w.st1, "x", 60, 180, 40, 15
statictext #w.st1, "y", 60, 210, 40, 15
statictext #w.st1, "r", 60, 240, 40, 15
textbox #w.t2x, 10,180, 40, 20
textbox #w.t2y, 10,210, 40, 20
textbox #w.t2r, 10,240, 40, 20

statictext #w.st1, "Circle3", 10, 310, 40, 15
statictext #w.st1, "x", 60, 330, 40, 15
statictext #w.st1, "y", 60, 360, 40, 15
statictext #w.st1, "r", 60, 390, 40, 15
textbox #w.t3x, 10,330, 40, 20
textbox #w.t3y, 10,360, 40, 20
textbox #w.t3r, 10,390, 40, 20

texteditor #w.te1, 120, 440, 420, 140

graphicbox #w.g, 120, 10, 420, 420

BackgroundColor\$ = "lightgray"

open "Apollonius rolls OK! Show in-circle only, out of the
eight possibles." for window as #w
#w, "trapclose [quit]"

#w.t1x, "100"' Initial values for three circles...
#w.t1y, "100"
#w.t1r, "50"

#w.t2x, "300"
#w.t2y, "100"
#w.t2r, "80"' 50

#w.t3x, "200"
#w.t3y, "330"' str\$( int(( 100 *( 1 +tan( 60 /360 *2 *3.14159)))))
#w.t3r, "30"' 50

#w.g, "down ; fill black ; up"

#w.te1, "!font arial 10"
#w.te1, " Keep centre x, y between 0 and 400, and radius below say 300."
#w.te1, " Top left is ( 0, 0) and bottom right is ( 400, 400)"
#w.te1, " Edit as desired then press 'Find' button."
wait

[quit]
notice "Calculation finished..." +chr\$( 13) +"I hope they fitted!"
close #w
end

[calc]
#w.g, "cls ; size 1"

#w.t1x, "!contents? s\$";
x1 =val( s\$)
#w.t1y, "!contents? s\$";
y1 =val( s\$)
#w.t1r, "!contents? s\$";
r1 =val( s\$)
#w.g, "backcolor yellow ; goto "; str\$( x1) ; " "; str\$( y1); " ; down ;
circlefilled "; str\$( r1); " ; up"

#w.t2x, "!contents? s\$";
x2 =val( s\$)
#w.t2y, "!contents? s\$";
y2 =val( s\$)
#w.t2r, "!contents? s\$";
r2 =val( s\$)
#w.g, "goto "; str\$( x2) ; " "; str\$( y2); " ; down ; circlefilled ";
str\$( r2); " ; up"

#w.t3x, "!contents? s\$";
x3 =val( s\$)
#w.t3y, "!contents? s\$";
y3 =val( s\$)
#w.t3r, "!contents? s\$";
r3 =val( s\$)
#w.g, "goto "; str\$( x3) ; " "; str\$( y3); " ; down ; circlefilled ";
str\$( r3); " ; up"

a = 2*( x1 -x2)
b = 2*( y1 -y2)
c = 2*( r1 -r2)
d =( x1^2 +y1^2 -r1^2) -( x2^2 +y2^2 -r2^2)

aa = 2*( x1 -x3)
bb = 2*( y1 -y3)
cc = 2*( r1 -r3)
dd =( x1^2 +y1^2 -r1^2) -( x3^2 +y3^2 -r3^2)

A = ( cc *a -c *aa)^2_'
coeff't of r^2
+( bb *c -b *cc)^2_
-( a *bb -b *aa)^2

B =-2 *( bb *c -b *cc) *( ( bb *d -b *dd) -x1 *( a *bb -b *aa))_'
coeff't of r
-2 *( a *cc -aa *c) *( ( a *dd -aa *d) -y1 *( a *bb -aa *b))_
-2 *r1 *( a *bb -b *aa)^2

C = ( ( bb *d -b *dd) -x1 *( a *bb -b *aa))^2_'
const. coeff't
+( ( a *dd -aa *d) -y1 *( a *bb -b *aa))^2_
-r1^2 *( a *bb -b *aa)^2

#w.te1, " A, B, C="; A; ", "; B; ", "; C' now use ( -B +/-SQRT( B^2
-4AC)) /2A
#w.te1, " Discriminant B^2 -4AC ="; (B^2 -4 *A *C)

if B^2 > 4 *A *C then
R1 =( -1 *B +(B^2 -4 *A *C)^0.5) /( 2 *A)'
First root

X1 =( bb *d -b *dd -bb *c *R1 +b *cc *R1) /(a *bb -b *aa)
Y1 =(-1 *aa *d +a *dd +aa *c *R1 -a *cc *R1) /(a *bb -b *aa)

R2 =( -1 *B -(B^2 -4 *A *C)^0.5) /( 2 *A)'
Second root

X2 =( bb *d -b *dd -bb *c *R2 +b *cc *R2) /(a *bb -b *aa)
Y2 =(-1 *aa *d +a *dd +aa *c *R2 -a *cc *R2) /(a *bb -aa *b)
#w.g, "color pink"
'for rrr =5 to 500 step 10
'#w.g, "up ; goto "; str\$( X1); " "; str\$( Y1); " ; down ;
circle "; str\$( rrr); " up"
'next rrr
#w.g, "up ; goto "; str\$( X1); " "; str\$( Y1); " ; down ; color red
; size 4 ; circle "; str\$( R1); " up ; color cyan ; size 1"
'for rrr =5 to 500 step 10
'#w.g, "up ; goto "; str\$( X2); " "; str\$( Y2); " ; down ;
circle "; str\$( rrr); " up"
'next rrr
#w.g, "up ; goto "; str\$( X2); " "; str\$( Y2); " ; down ; color blue
; size 4 ; circle "; str\$( R2); " up ; color black"
else' no real solutions in this case...
X1 =0
Y1 =0
R1 =0
X2 =0
Y2 =0
R2 =0
end if

#w.te1, " Circles were ( "; x1; ", "; y1; ", "; r1; "), ";
#w.te1, "( "; x2; ", "; y2; ", "; r2; "), ";
#w.te1, "and ( "; x3; ", "; y3; ", "; r3; ")"
#w.te1, " Solutions were ("; int( X1); ", "; int( Y1); ", "; int( R1);
") and ";
#w.te1, "("; int( X2); ", "; int( Y2); ", "; int( R2); ")"

wait

end
• Sorry- something funny in formatting the exponentiation sign!! I hope this is better... Apollonius7- generate in-circle NB This does NOT check for
Message 4 of 9 , Jul 6, 2006
'Sorry- something funny in formatting the exponentiation sign!!
' I hope this is better...

' Apollonius7- generate in-circle

' NB This does NOT check for intersecting circles or other special cases

nomainwin

UpperLeftX = 50
UpperLeftY = 50
WindowWidth =600
WindowHeight =640

button #w.b, "Find", [calc], LL, 10, 100

statictext #w.st1, "Circle1", 10, 20, 40, 15
statictext #w.st1, "x", 60, 40, 40, 15
statictext #w.st1, "y", 60, 70, 40, 15
statictext #w.st1, "r", 60, 100, 40, 15
textbox #w.t1x, 10, 40, 40, 20
textbox #w.t1y, 10, 70, 40, 20
textbox #w.t1r, 10,100, 40, 20

statictext #w.st1, "Circle2", 10, 160, 40, 15
statictext #w.st1, "x", 60, 180, 40, 15
statictext #w.st1, "y", 60, 210, 40, 15
statictext #w.st1, "r", 60, 240, 40, 15
textbox #w.t2x, 10,180, 40, 20
textbox #w.t2y, 10,210, 40, 20
textbox #w.t2r, 10,240, 40, 20

statictext #w.st1, "Circle3", 10, 310, 40, 15
statictext #w.st1, "x", 60, 330, 40, 15
statictext #w.st1, "y", 60, 360, 40, 15
statictext #w.st1, "r", 60, 390, 40, 15
textbox #w.t3x, 10,330, 40, 20
textbox #w.t3y, 10,360, 40, 20
textbox #w.t3r, 10,390, 40, 20

texteditor #w.te1, 120, 440, 420, 140

graphicbox #w.g, 120, 10, 420, 420

BackgroundColor\$ = "lightgray"

open "Apollonius rolls OK! Show in-circle only, out of the
eight possibles." for window as #w
#w, "trapclose [quit]"

#w.t1x, "100"' Initial values for three circles...
#w.t1y, "100"
#w.t1r, "50"

#w.t2x, "300"
#w.t2y, "100"
#w.t2r, "80"' 50

#w.t3x, "200"
#w.t3y, "330"' str\$( int(( 100 *( 1 +tan( 60 /360 *2 *3.14159)))))
#w.t3r, "30"' 50

#w.g, "down ; fill black ; up"

#w.te1, "!font arial 10"
#w.te1, " Keep centre x, y between 0 and 400, and radius below say 300."
#w.te1, " Top left is ( 0, 0) and bottom right is ( 400, 400)"
#w.te1, " Edit as desired then press 'Find' button."
wait

[quit]
notice "Calculation finished..." +chr\$( 13) +"I hope they fitted!"
close #w
end

[calc]
#w.g, "cls ; size 1"

#w.t1x, "!contents? s\$";
x1 =val( s\$)
#w.t1y, "!contents? s\$";
y1 =val( s\$)
#w.t1r, "!contents? s\$";
r1 =val( s\$)
#w.g, "backcolor yellow ; goto "; str\$( x1) ; " "; str\$( y1); " ; down ;
circlefilled "; str\$( r1); " ; up"

#w.t2x, "!contents? s\$";
x2 =val( s\$)
#w.t2y, "!contents? s\$";
y2 =val( s\$)
#w.t2r, "!contents? s\$";
r2 =val( s\$)
#w.g, "goto "; str\$( x2) ; " "; str\$( y2); " ; down ; circlefilled ";
str\$( r2); " ; up"

#w.t3x, "!contents? s\$";
x3 =val( s\$)
#w.t3y, "!contents? s\$";
y3 =val( s\$)
#w.t3r, "!contents? s\$";
r3 =val( s\$)
#w.g, "goto "; str\$( x3) ; " "; str\$( y3); " ; down ; circlefilled ";
str\$( r3); " ; up"

a = 2*( x1 -x2)
b = 2*( y1 -y2)
c = 2*( r1 -r2)
d =( x1^2 +y1^2 -r1^2) -( x2^2 +y2^2 -r2^2)

aa = 2*( x1 -x3)
bb = 2*( y1 -y3)
cc = 2*( r1 -r3)
dd =( x1^2 +y1^2 -r1^2) -( x3^2 +y3^2 -r3^2)

A = ( cc *a -c *aa)^2_'
coeff't of r^2
+( bb *c -b *cc)^2_
-( a *bb -b *aa)^2

B =-2 *( bb *c -b *cc) *( ( bb *d -b *dd) -x1 *( a *bb -b *aa))_'
coeff't of r
-2 *( a *cc -aa *c) *( ( a *dd -aa *d) -y1 *( a *bb -aa *b))_
-2 *r1 *( a *bb -b *aa)^2

C = ( ( bb *d -b *dd) -x1 *( a *bb -b *aa))^2_'
const. coeff't
+( ( a *dd -aa *d) -y1 *( a *bb -b *aa))^2_
-r1^2 *( a *bb -b *aa)^2

#w.te1, " A, B, C="; A; ", "; B; ", "; C' now use ( -B +/-SQRT( B^2
-4AC)) /2A
#w.te1, " Discriminant B^2 -4AC ="; (B^2 -4 *A *C)

if B^2 > 4 *A *C then
R1 =( -1 *B +(B^2 -4 *A *C)^0.5) /( 2 *A)'
First root

X1 =( bb *d -b *dd -bb *c *R1 +b *cc *R1) /(a *bb -b *aa)
Y1 =(-1 *aa *d +a *dd +aa *c *R1 -a *cc *R1) /(a *bb -b *aa)

R2 =( -1 *B -(B^2 -4 *A *C)^0.5) /( 2 *A)'
Second root

X2 =( bb *d -b *dd -bb *c *R2 +b *cc *R2) /(a *bb -b *aa)
Y2 =(-1 *aa *d +a *dd +aa *c *R2 -a *cc *R2) /(a *bb -aa *b)
#w.g, "color pink"
'for rrr =5 to 500 step 10
'#w.g, "up ; goto "; str\$( X1); " "; str\$( Y1); " ; down ;
circle "; str\$( rrr); " up"
'next rrr
#w.g, "up ; goto "; str\$( X1); " "; str\$( Y1); " ; down ; color red
; size 4 ; circle ";_
str\$( R1); " up ; color cyan ; size 1"
'for rrr =5 to 500 step 10
'#w.g, "up ; goto "; str\$( X2); " "; str\$( Y2); " ; down ;
circle "; str\$( rrr); " up"
'next rrr
#w.g, "up ; goto "; str\$( X2); " "; str\$( Y2); " ; down ; color blue
; size 4 ; circle ";_
str\$( R2); " up ; color black"
#w.g, "up"
else' no real solutions in this case...
X1 =0
Y1 =0
R1 =0
X2 =0
Y2 =0
R2 =0
end if

#w.te1, " Circles were ( "; x1; ", "; y1; ", "; r1; "), ";
#w.te1, "( "; x2; ", "; y2; ", "; r2; "), ";
#w.te1, "and ( "; x3; ", "; y3; ", "; r3; ")"
#w.te1, " Solutions were ("; int( X1); ", "; int( Y1); ", "; int( R1);
") and ";
#w.te1, "("; int( X2); ", "; int( Y2); ", "; int( R2); ")"

print #w.g, "getbmp apollonius 1 1 400 400"
filedialog "Save as bmp file", "*.bmp", fileName\$
bmpsave "apollonius", fileName\$

wait

end
• John, very impressive demonstration of math. Here are just some hints about the syntax of LB commands:You can write numbers directly to text boxes:
Message 5 of 9 , Jul 6, 2006
John,
very impressive demonstration of math.
Here are just some hints about the syntax of LB commands:

You can write numbers directly to text boxes:
> #w.t1y, "100"
Is the same as:
#w.t1y, 100

You can get numbers directly from text boxes:
> #w.t1x, "!contents? s\$";
> x1 =val( s\$)
Is the same as:
#w.t1x, "!contents? x1"
Notice the omitted unnecessary tailing semicolon

Use the place command if you want to move the pen without drawing, you can
then keep the pen down everytime.
> #w.g, "backcolor yellow ; goto "; str\$( x1) ; " "; str\$( y1);
> " ; down ; circlefilled "; str\$( r1); " ; up"
Is the same as:
#w.g, "backcolor yellow ; place "; x1; " "; y1; " ; circlefilled ";
r1
Notice the use of numerical variables, it is just a print statement.

These hints will reduce line width and amount of code to type ;-D

---
Stefan Pendl

___________________________________________________________
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
• Message 6 of 9 , Jul 6, 2006
>
> print #w.g, "getbmp apollonius 1 1 400 400"
> filedialog "Save as bmp file", "*.bmp", fileName\$
> bmpsave "apollonius", fileName\$
>

For anyone not wanting to be asked to save after each try, include the
following line after the window dimensions:

The save branch looks as follows, including extension checker:
[save]
print #w.g, "getbmp apollonius 1 1 400 400"
filedialog "Save as bmp file", "*.bmp", fileName\$
if lower\$(right\$(fileName\$, 4)) <> ".bmp" then fileName\$ = fileName\$;
".bmp"
bmpsave "apollonius", fileName\$
wait

---
Stefan Pendl

___________________________________________________________
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
• Thanks for the comment- I was aware I d been a bit verbose but some of your suggestionss I d not appreciated before. I ll use them in future I m sure.. I d
Message 7 of 9 , Jul 6, 2006
Thanks for the comment- I was aware I'd been a bit verbose
but some of your suggestionss I'd not appreciated before.
I'll use them in future I'm sure..

I'd been playing for ages and kept getting one or more signs
or terms wrong- hence the lines which draw a family of
circles in case it was NEARLY right! Most times it was NOT!
As always, debugging syntax is easy- but doesn't help if
the algorithm is wrong!

I'll keep working on it and update the online copy. Just

Incidentally you can set one radius to zero for the case of
in-circle touching two circles and a point...
• ... cases ... down ; ... blue ... R2); ) ... WOW! I can t thank you enough! This obviously took you some time. If I can get it (The hardware) to work, I ll
Message 8 of 9 , Jul 10, 2006
--- In libertybasic@yahoogroups.com, John Fisher <taunton@...> wrote:
>
> 'Sorry- something funny in formatting the exponentiation sign!!
> ' I hope this is better...
>
> ' Apollonius7- generate in-circle
>
> ' NB This does NOT check for intersecting circles or other special
cases
>
> nomainwin
>
> UpperLeftX = 50
> UpperLeftY = 50
> WindowWidth =600
> WindowHeight =640
>
> button #w.b, "Find", [calc], LL, 10, 100
>
> statictext #w.st1, "Circle1", 10, 20, 40, 15
> statictext #w.st1, "x", 60, 40, 40, 15
> statictext #w.st1, "y", 60, 70, 40, 15
> statictext #w.st1, "r", 60, 100, 40, 15
> textbox #w.t1x, 10, 40, 40, 20
> textbox #w.t1y, 10, 70, 40, 20
> textbox #w.t1r, 10,100, 40, 20
>
> statictext #w.st1, "Circle2", 10, 160, 40, 15
> statictext #w.st1, "x", 60, 180, 40, 15
> statictext #w.st1, "y", 60, 210, 40, 15
> statictext #w.st1, "r", 60, 240, 40, 15
> textbox #w.t2x, 10,180, 40, 20
> textbox #w.t2y, 10,210, 40, 20
> textbox #w.t2r, 10,240, 40, 20
>
> statictext #w.st1, "Circle3", 10, 310, 40, 15
> statictext #w.st1, "x", 60, 330, 40, 15
> statictext #w.st1, "y", 60, 360, 40, 15
> statictext #w.st1, "r", 60, 390, 40, 15
> textbox #w.t3x, 10,330, 40, 20
> textbox #w.t3y, 10,360, 40, 20
> textbox #w.t3r, 10,390, 40, 20
>
> texteditor #w.te1, 120, 440, 420, 140
>
> graphicbox #w.g, 120, 10, 420, 420
>
> BackgroundColor\$ = "lightgray"
>
> open "Apollonius rolls OK! Show in-circle only, out of the
> eight possibles." for window as #w
> #w, "trapclose [quit]"
>
> #w.t1x, "100"' Initial values for three circles...
> #w.t1y, "100"
> #w.t1r, "50"
>
> #w.t2x, "300"
> #w.t2y, "100"
> #w.t2r, "80"' 50
>
> #w.t3x, "200"
> #w.t3y, "330"' str\$( int(( 100 *( 1 +tan( 60 /360 *2 *3.14159)))))
> #w.t3r, "30"' 50
>
> #w.g, "down ; fill black ; up"
>
> #w.te1, "!font arial 10"
> #w.te1, " Keep centre x, y between 0 and 400, and radius below say 300."
> #w.te1, " Top left is ( 0, 0) and bottom right is ( 400, 400)"
> #w.te1, " Edit as desired then press 'Find' button."
> wait
>
> [quit]
> notice "Calculation finished..." +chr\$( 13) +"I hope they fitted!"
> close #w
> end
>
> [calc]
> #w.g, "cls ; size 1"
>
> #w.t1x, "!contents? s\$";
> x1 =val( s\$)
> #w.t1y, "!contents? s\$";
> y1 =val( s\$)
> #w.t1r, "!contents? s\$";
> r1 =val( s\$)
> #w.g, "backcolor yellow ; goto "; str\$( x1) ; " "; str\$( y1); " ;
down ;
> circlefilled "; str\$( r1); " ; up"
>
> #w.t2x, "!contents? s\$";
> x2 =val( s\$)
> #w.t2y, "!contents? s\$";
> y2 =val( s\$)
> #w.t2r, "!contents? s\$";
> r2 =val( s\$)
> #w.g, "goto "; str\$( x2) ; " "; str\$( y2); " ; down ; circlefilled ";
> str\$( r2); " ; up"
>
> #w.t3x, "!contents? s\$";
> x3 =val( s\$)
> #w.t3y, "!contents? s\$";
> y3 =val( s\$)
> #w.t3r, "!contents? s\$";
> r3 =val( s\$)
> #w.g, "goto "; str\$( x3) ; " "; str\$( y3); " ; down ; circlefilled ";
> str\$( r3); " ; up"
>
> a = 2*( x1 -x2)
> b = 2*( y1 -y2)
> c = 2*( r1 -r2)
> d =( x1^2 +y1^2 -r1^2) -( x2^2 +y2^2 -r2^2)
>
> aa = 2*( x1 -x3)
> bb = 2*( y1 -y3)
> cc = 2*( r1 -r3)
> dd =( x1^2 +y1^2 -r1^2) -( x3^2 +y3^2 -r3^2)
>
> A = ( cc *a -c *aa)^2_'
> coeff't of r^2
> +( bb *c -b *cc)^2_
> -( a *bb -b *aa)^2
>
> B =-2 *( bb *c -b *cc) *( ( bb *d -b *dd) -x1 *( a *bb -b *aa))_'
> coeff't of r
> -2 *( a *cc -aa *c) *( ( a *dd -aa *d) -y1 *( a *bb -aa *b))_
> -2 *r1 *( a *bb -b *aa)^2
>
> C = ( ( bb *d -b *dd) -x1 *( a *bb -b *aa))^2_'
> const. coeff't
> +( ( a *dd -aa *d) -y1 *( a *bb -b *aa))^2_
> -r1^2 *( a *bb -b *aa)^2
>
> #w.te1, " A, B, C="; A; ", "; B; ", "; C' now use ( -B +/-SQRT( B^2
> -4AC)) /2A
> #w.te1, " Discriminant B^2 -4AC ="; (B^2 -4 *A *C)
>
> if B^2 > 4 *A *C then
> R1 =( -1 *B +(B^2 -4 *A *C)^0.5) /( 2 *A)'
> First root
>
> X1 =( bb *d -b *dd -bb *c *R1 +b *cc *R1) /(a *bb -b *aa)
> Y1 =(-1 *aa *d +a *dd +aa *c *R1 -a *cc *R1) /(a *bb -b *aa)
>
> R2 =( -1 *B -(B^2 -4 *A *C)^0.5) /( 2 *A)'
> Second root
>
> X2 =( bb *d -b *dd -bb *c *R2 +b *cc *R2) /(a *bb -b *aa)
> Y2 =(-1 *aa *d +a *dd +aa *c *R2 -a *cc *R2) /(a *bb -aa *b)
> #w.g, "color pink"
> 'for rrr =5 to 500 step 10
> '#w.g, "up ; goto "; str\$( X1); " "; str\$( Y1); " ; down ;
> circle "; str\$( rrr); " up"
> 'next rrr
> #w.g, "up ; goto "; str\$( X1); " "; str\$( Y1); " ; down ; color red
> ; size 4 ; circle ";_
> str\$( R1); " up ; color cyan ; size 1"
> 'for rrr =5 to 500 step 10
> '#w.g, "up ; goto "; str\$( X2); " "; str\$( Y2); " ; down ;
> circle "; str\$( rrr); " up"
> 'next rrr
> #w.g, "up ; goto "; str\$( X2); " "; str\$( Y2); " ; down ; color
blue
> ; size 4 ; circle ";_
> str\$( R2); " up ; color black"
> #w.g, "up"
> else' no real solutions in this case...
> X1 =0
> Y1 =0
> R1 =0
> X2 =0
> Y2 =0
> R2 =0
> end if
>
> #w.te1, " Circles were ( "; x1; ", "; y1; ", "; r1; "), ";
> #w.te1, "( "; x2; ", "; y2; ", "; r2; "), ";
> #w.te1, "and ( "; x3; ", "; y3; ", "; r3; ")"
> #w.te1, " Solutions were ("; int( X1); ", "; int( Y1); ", "; int( R1);
> ") and ";
> #w.te1, "("; int( X2); ", "; int( Y2); ", "; int(
R2); ")"
>
> print #w.g, "getbmp apollonius 1 1 400 400"
> filedialog "Save as bmp file", "*.bmp", fileName\$
> bmpsave "apollonius", fileName\$
>
> wait
>
> end
>

WOW! I can't thank you enough! This obviously took you some time.

If I can get it (The hardware) to work, I'll definitely send you one
of my 'wooden' keyboards if u want...
• Thanks for the kind words- I enjoyed the mind-bending exercise. I m still trying to visualise what you are making!
Message 9 of 9 , Jul 10, 2006
Thanks for the kind words- I enjoyed the mind-bending exercise.
I'm still trying to visualise what you are making!
Your message has been successfully submitted and would be delivered to recipients shortly.