Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Circle by Circumference
#1
I’m back… once more looking for assistance.

Recently I was thinking of taking three pieces of flexible sheet goods (4x8) and forming an on-end circle. However, I had great difficulty in drawing the prescribed circle. I finally researched circles and generated the following formula to insert in the ‘Draw a circle with center and radius’ in place of a radius. It worked out like this...

48 x 3 = 144 = Circumference
Circumference = pi x Diameter
Circumference / pi = Diameter
Circumference / pi / 2 = Radius

Substituting 144 for Circumference and entering (144 / π / 2gave a radius of 22.918 and resulted in a correctly dimensioned circle.

What I’m asking is…
Does anyone know of a simpler/easier way of achieving the same results?
Reply
#2
Smile 
Get somebody else to calculate it. Smile


(  Circumference / pi / 2 = Radius  ) is the simplest and easiest formula to calculate the Radius of a known Circumference.


Here is a macro that will create a circle with a known circumference.

Code:
Cir = InputBox ("Enter Circumference","Create a Circle with known Circumference")
r=Cir / 3.1415926 / 2
dcCreateCircle 0, 0, r
dcViewAll
End
Reply
#3
Smile 
Get somebody else to calculate it. [Image: smile.gif] " I was hoping it was going to be you. [Image: grinning-face-with-big-eyes_1f603.png]

However, I was thinking more along the lines of "Ctrl/Shift Cr" to insert said text into the text box.

Thanks for the Macro Al, works like a champ.

Question... how could the text box be altered to accept formulas that calculate the circumference?

i.e.
(48*3) would cause 144 to be entered into the text box.

You know me, I never stop. [Image: smile.gif] [Image: smile.gif] [Image: smile.gif]
Reply
#4
Have the macro ask how many segments in the circumference then ask for the segments length.
Code:
NumSegs = InputBox ("Enter number of segments","Create a Circle with known Circumference")
SegLen= InputBox ("Segment length","Create a Circle with known Circumference")
Cir=NumSegs*SegLen
r=Cir / 3.1415926 / 2
dcCreateCircle 0, 0, r
dcViewAll

= = = = = = = = = = 

Or have it keep asking for a segment length and when you're done answer 0 to quit asking and then calculate.
Code:
Cir=0
GetSeg: 
SegLen= InputBox ("Segment length","Create a Circle with known Circumference")
If SegLen<>0 Then
   Cir=Cir+SegLen
   GoTo GetSeg
End If
r=Cir / 3.1415926 / 2
dcCreateCircle 0, 0, r
dcViewAll


= = = = = = = = = = 


It could be possible to read in a formula such as (48*3)  but the programming would be more complicated.
Reply
#5
Al, I'm experimenting a little. I'm trying to put two input boxes in a single window. When I try to run the code below I get an error. Is something like that possible in dcMacro?

dcCreateBox -x, 0, x, 3

Cir = InputBox ("Enter ArcLen", "Length of Circle Segment"

        InputBox ("Enter ArcNum", "Number of Circle Segments")

r=Cir ArcLen * ArcNum / 3.1415926 / 2
dcCreateCircle 0, 0, r
dcViewAll
End
Reply
#6
This should help - I use it all the time.


Link:
pi = 3
Reply
#7
I believe this is what you are wanting:

Code:
Sub Main
Begin Dialog MakeCircumference 78,2, 200, 100, "Create Circle with Arc Length and No. of Segments", .Enable
  Text 11,6,105,8, "Length of Circle Segment"
  TextBox 108,4,48,12, .SegLen
  Text 11,26,105,8, "Number of Circle Segments"
  TextBox 108,24,48,12, .SegNum
'*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  PushButton 4,80,36,12, "Calculate", .SaveInfo
  PushButton 44,80,72,12, "Abort", .Quit
End Dialog
'*= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Dim Dlg1 As MakeCircumference
GetButton:
   Button1 = Dialog (Dlg1)
   Select Case Button1 
'*- - - - - - - - - - - - - - - - - Select Button - - - - - - - - - - - - - - -
      Case 1
        Cir = Dlg1.SegNum * Dlg1.SegLen
        r = Cir / 3.1415926 / 2
        dcCreateCircle 0, 0, r
        dcViewAll
     Case 2 
        MsgBox "Abort"
   End Select
End Sub

P.S.
I never heard of the Indiana Pi Bill
I'm sticking to 3.1415926
Reply
#8
Great job Al, but I never meant for you to do all of the work. Thank you.

Do you know where I can find basic tutorials on writing macros? Back in the day, I used to mess with DOS. But since then I've just about forgotten everything.

(observation) - that doesn't appear to be DCbasic.
Reply
#9
The macro commands are from Basic Scripting Engine provided by Cypress Software Inc.
It is similar to IBM CognosScript language

You could start with Jim Brown's DC macro tutorial

In the DC Macro Editor Help each command has sample code.
There are commands very similar to MS basic and then there are commands only used with DC they begin with dc _ _ _ _ _ _ _ _
And then there is the Dialog Editor which let's you visually design a dialog box then it has you paste the code to your main macro program.

I was getting rusty on my macro programming I needed the practice.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)