The following code is what I've gleaned from JS source of the web site
Louise gave me.
I have no idea why the algorythm on that site works. Anyway... My VB
translation don't work :-(
I tested the site calculator by "asking" for the circumference of a circle
of radius 10.
This gave me 62.832.
I halved that and asked for the radius of a circle with a chord length of 20
and a "bow" .. Thanks John .. Of 21.416.
Thee site calculator... Wonder of wonders... Gave me a radius of exactly 10.
My VB code gives 119... Any idea what's going on at all?
Original relevant bit of JS...
--------------------------------
if (chc==0){chord=inp1;arclen=inp2;
arc2crd=inp2/inp1;
centang=4; <!-- radians -->
incr=4;
ct=0;
while (ct<75){
angratio=(centang)/(2*Math.sin(centang/2));
if
(angratio>arc2crd){incr=incr/2;centang=centang-incr}else{incr=incr*2;centang
=centang+incr};
ct=ct+1;}
ct=0;
radius=(chord/2)/(Math.sin(centang/2));
ans[3]=radius;
apo=radius*radius - (chord/2)*(chord/2);apo=Math.sqrt(apo);
ans[4]=apo;
centang=centang*(180/pival); ans[5]=centang;
seghgt=radius-apo;ans[6]=seghgt;
}
----------------------------------
My VBA code
----------------------------------
Sub subCalculateRadius_2()
Const pival = 3.14159265358979
Dim ct As Long
Dim radius As Long
Dim chord As Long
Dim apo As Long
Dim centang As Long
Dim arclen As Long
Dim inp1 As Long
Dim inp2 As Long
Dim chc As Long
Dim sigfig As Integer
Dim incr As Long '<!-- Increment -->
Dim angratio As Long '<!-- Angle Ratio for choice 8 -->
Dim arc2crd As Long '<!-- arc to chord ratio - for choice 8 -->
sigfig = 5
inp1 = 20
inp2 = 31.416
If chc = 0 Then
chord = inp1
arclen = inp2
arc2crd = inp2 / inp1
centang = 4 '<!-- radians -->
incr = 4
ct = 0
Do While ct < 75
angratio = (centang) / (2 * Sin(centang / 2))
If angratio > arc2crd Then
incr = incr / 2
centang = centang - incr
Else
incr = incr * 2
centang = centang + incr
End If
ct = ct + 1
Loop
ct = 0
radius = (chord / 2) / (Sin(centang / 2))
apo = radius * radius - (chord / 2) * (chord / 2)
centang = centang * (180 / pival)
MsgBox "Radius = " & radius & vbCrLf & "Central Angle = " & centang
End If
'********************************************************************
End Sub