| Author |
Comment/Response |
Andrew
|
03/02/12 11:46am
Hey Bill,
Simple said the problem is:
I have a Animation with 3 Disks like this:
Animate[Show[Graphics[{
Gray,
Disk[{1,1*t},1],
Disk[{2,2*t},1],
Disk[{3,3*t},1]
}]], {t, 0, 10}]
For 3 Disks this is ok. But now I have let's say 100 Disks. It's rly hard work to do all the 100. So I make a Do[] Function that looks like this:
Do[Disk[{k,k*t},1],{k, 0, 3}]
This does nothing, so I need a Print-Function:
Do[CellPrint[TextCell["Disk[{k,k*t},1]],"Input"],{k, 0, 3}]
This gives me the text in Input Form and I can copy it into my graphics function.
Okey, next step is: I want to do that for various Numbers instead of 3 or 100. Let's say I want it k-times. I can do the function above again:
t=100;
Do[CellPrint[TextCell["Disk[{k,k*t},1]],"Input"],{k, 0, t}]
This gives me the Text again in Input form. But now I want this to be included in the Graphics Object:
t=100;
Animate[Show[Graphics[{
Gray, Do[CellPrint[TextCell["Disk[{k,k*t},1]],"Input"],{k, 0, t}]
}]], {t, 0, 10}]
But this doesn't work, it just prints the code at the end of the cell. Now I tried several things (see my first post) but it didnt work.
I mean in Java or any other programm it would be that easy, just sth like:
k=100;
Animate[Show[Graphics[{
Gray,
For(i=0,i<(k+1),i++)
{
Disk[{k,k*t},1]]
}
}]], {t, 0, 10}]
(syntax not correct). But I didnt get it working on mathematica.
Now to your answer. Indeed the List-function helped me, I could ( a little complicated) realise what I intended to do but I think it should be possible easier.
I have my little code in the attachement so you can see what I meant, it's perfectly working now.
Thx
Andrew
Attachment: planetary-code-support.nb, URL: , |
|