Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'For-Function in Animate-Function' topicStudent Support Forum > General > Archives > "For-Function in Animate-Function"

Next Comment >Help | Reply To Topic
Author Comment/Response
Andrew
02/28/12 09:40am

Hey all,
I'm Andrew, 2nd semestre mechanical engineering at ETH zurich. Sorry for my english, it may not always be correct. This week we had a little entering in Mathematica in our Ingeneer-tools section.
There for as final work we're building a planetary gear animation for various radius and angular speed. So far so good, I could do almost everything on my own until one little problem (wasted over 16h yet with that -.-):

To do the choppers of the gears, I need a Do[] function to multiply each chopper(chopper=disk[]). This comes inside my Animate[Show[Graphics[{...}]] function.

a chopper looks like this:

Disk[{Sin[2*t + k*(2Pi/9)] + Cos[2*t + k*(2Pi/9)]}, GZahn]

Now I do a Do[] function to get my 10 choppers:

Do[Print[Disk[{Sin[2*t + k*(2Pi/9)] + Cos[2*t + k*(2Pi/9)]}, GZahn]], {k, 0,9}]

If I put this into my Animate[] function, it doesn't draw me the disk but open a message board and write it in there.
If I just copy all the outup into my Animate[] function, it works perfectly. But I need it for various amount of choppers. So I did research and tries till I almost died ^^, tried it with e.g.

Do[CellPrint[TextCell[Disk[{Sin[2*t + k*(2Pi/9)] + Cos[2*t + k*(2Pi/9)],"Input"]}, GZahn]], {k, 0,9}]

but this just writes it as input at end of Animate[] and not inside it so doesnt draw my graphics. I tried it with different brackets and quotation marks, with functions like InputForm, Evaluate, Write, Sow, Throw.........and so many more.

Then I got one little step forward with (all in one cell):

m = 3;
Do[funktionxyz[k + 1] =
Disk[{Sin[2*t + k*(2 Pi/9)], Cos[2*t + k*(2 Pi/9)]}, GZahn] +
funktionxyz[k], {k, 1, m}];
funktionxyz[m]

The output of this is:

Disk[{Cos[\[Pi]/18 - 2 t], Sin[\[Pi]/18 - 2 t]}, GZahn] +
Disk[{Sin[2 t], Cos[2 t]}, GZahn] +
Disk[{Sin[(2 \[Pi])/9 + 2 t], Cos[(2 \[Pi])/9 + 2 t]}, GZahn]

So it's right, but the "+" should be a ",". I tried hours again with quotation marks, &&, ;, [],{},(),'',/[RawComma],/[InvisibleComma] to get that *** comma in, but every of the tries gives me errors in the Do[]
function.
Now I can't anymore, burned out of motivation and energy and hope you can help me. I mean in PHP, Java, C++ it would be sooo easy, just put the For[] in and declare where to do it. I don't know why this isnt possible in Mathematica, to put the Do[{k,0,10}]{..........................} and just put for every k inside brackets and fine...

Rly appreciate every help TY ;)
Andrew



URL: ,

Subject (listing for 'For-Function in Animate-Function')
Author Date Posted
For-Function in Animate-Function Andrew 02/28/12 09:40am
Re: For-Function in Animate-Function Stefan Salan... 02/28/12 2:54pm
Re: For-Function in Animate-Function Bill 02/28/12 4:07pm
Re: For-Function in Animate-Function Andrew 03/02/12 11:46am
Next Comment >Help | Reply To Topic