Introduction
Nines years old my father gifted me wonderful original Meccano metalic construction system, which made me fond of mechanical systems till now, 6 years later I owned my first home computer connected to the TV, I started to write codes in BASIC languge for some problems in mechanics and analytic geometry, one of them was to simulate point move on the planet gear and generates nice shapes, these days I remembered this code to publish it as a useful article but unfortunately I found similar one on the site which use simpler equation than what I deduced earlier, that's
y(t) = A Sin(n t) (on polar coordinates)
So I decided to add something new and doesn’t take much time too, that’s I added extra third gear to be inside the second gear inside the first gear to see what is the result that was impressive as shown.
These shapes in not nonsense as some of us may think, with simple equations game & graphic designers can generate such complex shapes, and decoration designer can do the same,, in one of the big hospitals entrance I saw one of them on the floor of curved mosaic granite tiles which is made by the waterJet cutting machines, if you would like to add to your knowledge please refer to these links :
http://en.wikipedia.org/wiki/Mohamed_Hashish, (inventor of the abrasive waterjet cutting)<o:p>
https://www.flickr.com/search/?q=spirograph,<o:p>
http://www.syrstone.com/Syrstone/Award_WINNING_Culinary_Institute.html, <o:p>
,also it can be used for printing patterns on fabrics, logos design and similars...
You may refer to these videos as well :
Linkogram drawing machine
Drawing Machine II
Background
This is a picture of simple planet Gear engaged with Ring gear , its name comes from the similarity with planets motion around each others, now imagine the inner red Arm is forced to rotate around the center of the ring gear, this will make the planet gear to rotate around its own center too with fixed ratio between the two rotations :
seta_2 = seta_1 * R1 / R2 * slider4.Value;
This Ratio can be varied by the slider4
value,
This Ratio comes from the equation of the rotation seta angle in radians:
Ɵ = that Arc in front of this angle / Radius .
and because the two gears are egaged so both of the swiped arcs will be identical, so :
Arc_{1} = Arc_{2}
Ɵ_{1} / R_{1}= Ɵ_{2 }/ R_{2} ................ as written in the code ( seta_2/R2= seta1/R1 )
Check the following diagram and let's describe the position of the blue center point of the planet gear relative to the black center point of the ring gear
this position can be described by the components of point P(x2,y2) in the Cartesian plan as follows :
X2 = R1 * Math.Cos(seta_1) + R2 * Math.Cos(seta_2) + X1;
Y2 = R1 * Math.Sin(seta_1) + R2 * Math.Sin (seta_2) + Y1;
where
R_{1} is the first radius.
R_{2} is the second Radius.
Ɵ_{1} the red angle is the rotation angle of the Arm.
Ɵ_{2} the green angle is the result rotation angle of the planet gear that can be as (seta_2 = seta_1 * R1 / R2).
plotting the location of the rotating red point against the red angle Ɵ_{1} will gives such spirograph shapes :
Now let’s introduce extra new gear, if we put this gear assembly into a big ring gear, we shall have two rotating gears inside it as shown in the next diagram :
The position of the red point relative to the new gear center can be calculated by the summation of the vectors R1
,R2
,R3
or can be calculated as follows :
X3 = R2 * Math.Cos(seta_2) + R3 * Math.Cos(seta_3) + X2;
Y3 = R2 * Math.Sin(seta_2) + R3 * Math.Sin(seta_3) + Y2;
Plotting this equation to calculate the point location X3
,Y3
against seta1
and varying its parameters will give these new amazing Graphs :
Using the Code
Most of the code is easy to understand but here let's highlight on these lines :
Let’s get red off the gears teeth and let the planet gears rotate and slip with a ratio of seta1 to give us new shapes, so recalculate as follows :
seta_2 = seta_1 * R1 / R2 * slider4.Value;
seta_3 = seta_2 * R2 / R3 * slider5.Value;
which gives us the following effects :
Strings shape
Flower heart
I added slide bars to control the three radius but I noted that a very small change may be in range of 0.1 can alter the shape, and here next is a useful principle related to this issue.
Useful Principle
Physically it is hard to control any physical amount in a big values with very high accuracy at the same time, usually the accuracy is limited within range, for example to control the position of a mass in a range of kilometers, you can't expect to have accuracy in micrometers.
The same here we can’t control the slider position by our hand easily on a certain position with a fraction of ten or less, so I added another slider beside each "parameter control slider" to provide the control of the fraction value.
under each of all these sliders you can find textBlock to show the silder value (Silder.Value), text of these textBlocks are all binded to its top sliders, as shown in the sample code of textBlock1 :
<TextBlock Height="23" Name="textBlock1" Width="57"
Text="{Binding Path=Value}" DataContext="{Binding ElementName=slider1}"
Canvas.Left="10" Canvas.Top="606" />
Another idea for the gradient color which gives the shadow effect to the graph,
As we go from the center toward outside, the blue color get darker by adding the following Lines :
double D = Math.Sqrt( Math.Pow(PtsX[n]  X1 , 2) + Math.Pow(PtsY[n]  Y1,2) );
Byte LineColor = (Byte) (180((D *Scale)/ (canvas2.Height/2 )) * 140);
myLine.Stroke = new SolidColorBrush(Color.FromRgb(00,LineColor,255));
I added the most right two sliders the "scale slider" to view the shape in different sizes, and the other one is "history slider", for the "history slider" it came to me from similar idea to that I used since long time while I was designing simple storage oscilloscope circuit connected via parallel port of the computer, to leave the computer collect the data then store it in an array as fast as possible (not to make it busy to graph the data) , so the graph can be checked separately to see the history of what happened, and as the slider go up and down the history of drawing can be reviewed and you can review the shape while it was drawing to pick the best one.
Last, I preferred to connect the point with lines instead of curves, because I found it easier and faster to be drawn, this you can find it in the following drwaing loop which drawing connected series of finit lines :
for (int n=1; n<cnt; n+=1)
{
myLine = new Line();
myLine.Stroke = System.Windows.Media.Brushes.Violet;
double D = Math.Sqrt( Math.Pow(PtsX[n]  X1 , 2) + Math.Pow(PtsY[n]  Y1,2) );
Byte LineColor = (Byte) (180((D *Scale)/ (canvas2.Height/2 )) * 140);
myLine.Stroke = new SolidColorBrush(Color.FromRgb(00,LineColor,255));
myLine.X1 = PtsX[n1] * Scale + canvas2.Width/2;
myLine.Y1 = PtsY[n1] * Scale + canvas2.Height/2;
myLine.X2 = PtsX[n] * Scale + canvas2.Width/2;
myLine.Y2 = PtsY[n] * Scale + canvas2.Height/2;
myLine.StrokeThickness = 1;
canvas2.Children.Add(myLine);
}
Apply the following slider values and check the graphs :
180
 181
 30
 100
 1
 1

180
 181
 40
 100
 1
 1

180
 182
 30
 100
 1
 1

180
 182
 30
 40
 1.91
 1.4

180
 119.07
 50.5
 41
 1.21
 1.6

180
 181
 30.27
 100
 1
 1

180
 181
 30.30
 100
 1
 1

180
 181
 30.35
 100
 1
 1

177
 179
 29.9
 55.8
 1
 1

99
 176
 0
 100
 1
 1

103
 97
 30
 100
 1
 1

183
 150
 13.4
 50
 1
 1

There are many Ideas can be added to generate more amazing shapes as adding gradient colors which should make it alive and more worderful, varing line strokes too and so on..
History
First code was written since 27 years ago, and this one is a developed version of it.
I'm Automatic Control Engineer,interested in Programming since I was 14 yeas old started with"Basic" then C++ then finally 2003 I moved to C#, recently I learned WPF to shine my Softwares like CAD s/w, I used to use programming languages to solve the mathematical problems,
17yrs ago I wrote a code to build an assembler for 8051, I made 64 bit I/O board for digital projects too, and code downloader testing board, both I designed on Protel PCB designer, I used them to make motor speed drive working with 8951 for a press machine..
I like physics too, it seems like a glasses when you wear, you see the world differently and know something you have never imagine..and you can understand, expect, find the answers more better.
I am using my analytic power to be creative for the new things and I prefer working for complex problems than easy ones.
I like reading, scientific applications, Hand works, wood works, documentaries, general history, history of the science ..
[Email : ehabnourm@yahoo.com]