# Rolling coins

Discussion in 'Share Your Creations' started by nm7s9, Oct 1, 2008.

JUst a simple program, no instructions, just hit some buttons and see what
shapes emerge.

Equations curtesy of mathworld.wolfram.com

Cheers
Nick

#### Attached Files:

• ###### rolling.sbp
File size:
3 KB
Views:
238

Very nice!

This brougth back so many memories.....
As I was a kid, aged 6 or 7, there was this brand of chocolate powder, wich came with a scantilion, a ruler by wich we could draw on paper Exactly these shapes...
As I did back then, today a spendt hours playing with the values and seeing the shapes being drwan in my screen....
I was 7 again.... Thank you very much...

Very nice work Nick :sign0188:

There is a subtle bug in your code.
You are using an endless loop and therefore the program will not stop until you close it with task manager (optimized compiled version).
A simple correction is to use a global variable as a flag that breaks the loop when the main form is closing:
Code:
`Sub Globals    'Declare the global variables here.    Dim a, b, h, t, t1    Dim x, y, xstart, ystart    Dim showsmall, showlarge, showpole    Dim waittime, inner    Dim stop ' <---End SubSub App_Start'  Equations curtesy of mathworld.wolfram.com    stop = False    Form1.Color = cBlack    xstart = 120 : ystart = 120     xsmall = xstart : ysmall = ystart    a=40:b=10:h=10:t=0:x=0:y=0    showsmall=1 : showlarge=1 : showpole=1    waittime = 20 : inner = 1    SetTransparentColor(cWhite)    form1.ForeLayer = True    Form1.Show    t1=0    Do Until stop        If showlarge = 1 Then            form1.Circle(xstart,ystart,a,cGray)        Else            form1.Circle(xstart,ystart,a,cBlack)            End If        form1.FLine(0,0,400,400,cWhite,BF)        t=t1*cPI/180        If inner = 1 Then            z = a-b            x=z*Cos(t)+h*Cos(z/b*t)        Else            z = a+b            x=z*Cos(t)-h*Cos(z/b*t)        End If        y=z*Sin(t)-h*Sin(z/b*t)        xsmall=z*Cos(t)        ysmall=z*Sin(t)        form1.Line(xstart+x,ystart+y,xstart+x+1,ystart+y+1,cWhite,BF)        If showsmall = 1 Then            form1.FCircle(xstart+xsmall,ystart+ysmall,b,cGray)        End If        If showpole = 1 Then            form1.FLine(xstart+xsmall,ystart+ysmall,xstart+x,ystart+y,cRed)        End If        DoEvents        Sleep(waittime)        t1 = t1 + 1    Loop    End SubSub Form1_Close    stop = TrueEnd Sub`

Dito!
The "game" I had was called Spirograph.

@nm7s9: Really nice program! :sign0060:

specci48

Ok - thanks Erel.

Is there a better way to plot a point than approximate it with a 2x2 block.
A 3x3 block with its centre at the correct point is more accurate than what I've done but is too thick, A 1x1 line didn't show up on my screen at all.

BTW I,40,20,40 shows that if your hula-hoop has a nail in it and is twice as big as your waist, then the nail is going to get you, always in the same place every second time round.

Better get a bigger hula hoop, and better still, make sure it is not a intergral size bigger than your waist.

I,46,20,46 makes some really interesting patterns and ensures that the nail strikes occurr evenly around your waist.

You can use Bitmap.SetPixel from the ImageLib library.
However it will be a little bit more complicated.

Real nice!

Will you be enhancing it?
- different sizes
- different colors (agraham's color picker maybe)
- multiple rings
- a "stop" button
- save as function (I think dzt had a nice image lib)

Yes!
I always wanted to have it as a kid... but never got it :'(

Last edited: Oct 2, 2008

Nice application.

Reminds me also some souvenirs, having programmed something similar quite some years ago.

Specci48, my daughter, once, got a similar game (also some years ago).

I agree with Mr_Gee, you should continue in adding the features discribed by him.

Another suggestions:
- stop the drawing when it beginns to overlap (drawing the same lines)
- by default when changing the small circle, put the drawing radius at the same value.

Best regards.

Very nice effects can be achieved this way as the smaller coin rolls faster, than the drawing radius...
if you Grow the coin to the radius, you will see that the effect is NOT the same...

Ok - thakns all for the usefull sugestions. I've already put in the pole length default, and the stop loop on closure - I wondered why my computer was starting to struggle, task manager showed all those little rollers eating up the cpu.

Mr Gee - I'm not sure what you mean by different sizes ??.

Also by multilpe rings, do you mean multiple moving circles rolling inside or outside the fixed circle, or one inside and one outside or a combination.

Also I have to be careful of pixel-estate since I want to allow the largest graph possible.

PS - Kkaus - I promise to put in some effort with the icon editor to make a nicer icon for this. Still - if anyone has a premade nice one I could borrow ???

Cableguy - I think klas intends that when you change to size of the movable circle you also reset the pole length equal to the new radius. You can still change the pole length again to be different to the new movable radius.

Certainly I have found myself having to make identical changes to the pole after altering the movbable circle more often than I've changed the movable radius and wanted to leave the pole length the same.

Have a look at specci48's link to wikipedia and you will understand Mr_Gee's suggestions.
- You can make a first draw with a certain configuration of the 3 parameters, press Stop
- Begin an other drawing, with an other color and an other configuration, without clearing the screen to superpose it to the first one.
- And a 3rd, 4th and so on.

In this case it would also be interesting to be able to choose the beginning point.

Best regards.

Here the next version with a couple of tiny changes.

Bug fixes - form will now close properly

Changing parameters will not clear previous graph (use clear button to do this).

Lift/draw button added - if you want to make multiple changes to the parameters before starting a new graph then lift the pen, then hit draw to start drawing again when the parameters are all correct.

When resizing the movable radius the drawing radius will default to the new size (this drawing radius can be altered independently afterwards if required)

NB this default will be implemented optionally soon in an ini file.

1)TODO list

Option initialisation:
a) - colours
c) - start parameters

2) Colours:
a) pen
b) background
c) circles/pole ??? ( I think these should stay ghosted)

3) Better graphics - try to use setpixel to get a finer, more accurate line.

4) Graph movement
a) allow centre of drawing to move (Easy)
b) allow "slippy map" functionality and gesturing (Hard)

--------------------------------------------------

BTW This program started since discussing with my father about the envelope
of the sliding ladder situation (see ladder.sbp) we found that the astroid could also be produced by rolling circles.

PS - excuse the primitave nature of my coding - I may get better at it but after 30 years the chances are not all that good :sign0013:

Nick

#### Attached Files:

• ###### rolling.sbp
File size:
3.7 KB
Views:
124
File size:
3.7 KB
Views:
128

PPS
TODO List

Screen snapshot
with and/or without paramater areas.

One more version - before colours appear

If the drawing is too slow on your device even after hitting + a few times then you can choose the otions form (while the pen is lifted) and drop the quality down from the default of 100 (to maybe 50 or so).

On this form you can also disable the "pole sync" which defaults the drawing radius to to movable radius whenever the movable radius is altered.

Colours will be next but will take some time as I want to make it simple yet flexable.

Nick

#### Attached Files:

• ###### rolling.sbp
File size:
4.4 KB
Views:
118

Here's a colour version (for desktop only).

Beware - changing background colour wipes out the drawing.

I've had to move the fixed circle to the forelayer so that it didn't intefere with the drawing bit I can't stop it flickering (any advice appreciated).

Next I'll do the boring stuff such as save/load/snap etc

I intend to allow save/store of a graph (A graph is the set of parameters used while drawing (i.e with pen down) since the last clear command)

E.G
cBack,I,10,40,10,cPen1:O,10,40,10,cPen2:O,10,40,30,cPen2

The graph will be saved, on closing to the savefile as "lastgraph". You can also save it to "favourite" or to a table of savedgraphs.

On startup, lastgraph will load and start drawing. You can reload and redraw any user-named graph from the savedlist or the favourite graph.

I'l also enable a snapshot of the screen, with or without the controls displayed, to disk or printer.

I'll define a file for the user preferences to be created on first execution and used thereafter to save session status etc.

#### Attached Files:

• ###### rollingdesk.sbp
File size:
5.4 KB
Views:
125

While searching for bugs in my program, I came across this one.
It looks a bit like a trilobite. Does anyone know its name.

Its number is
I,10,30,10 ----- deltoid
I,10,40,10 - ----astroid
.
.
.
I,10.90,10

File size:
19.1 KB
Views:
98