ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 08 Jul 2013 05:11:12 -05003d animation with tachyonhttp://ask.sagemath.org/question/8947/3d-animation-with-tachyon/Hello!
I'm trying to create a 3d animations, frame per frame. I've discovered that tachyon plotter is very usefull to create images. But after that, I'm unable to make it as animation.
For example, I have copied a code and generate some scenes with tachyon with this:
saved = []
for j in srange(-0.9,1,0.3):
t = Tachyon(xres=512,yres=512, camera_center=(3,0.3,0))
t.light((4,3,2), 0.2, (1,1,1))
t.texture('t0', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1.0,0,0))
t.texture('t1', ambient=0.1, diffuse=0.9, specular=0.3, opacity=1.0, color=(0,1.0,0))
t.texture('t2', ambient=0.2,diffuse=0.7, specular=0.5, opacity=0.7, color=(0,0,1.0))
k=0
for i in srange(-1,j,0.05):
k += 1
t.sphere((i,i^2-0.5,i^3), 0.1, 't%s'%(k%3))
saved.append(t)
In "saved" array I have all the png of the animation I want to do, and I can view it with saved[i].show().
I tried to unite all the frames with the command animate:
animate(saved[i].show() for i in range(0,len(saved)))
But it didn't work. What other alternatives do I have? (without using ffmpeg)
Thank you!Thu, 17 May 2012 03:35:17 -0500http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/Answer by kcrisman for <p>Hello!</p>
<p>I'm trying to create a 3d animations, frame per frame. I've discovered that tachyon plotter is very usefull to create images. But after that, I'm unable to make it as animation.</p>
<p>For example, I have copied a code and generate some scenes with tachyon with this:</p>
<pre><code>saved = []
for j in srange(-0.9,1,0.3):
t = Tachyon(xres=512,yres=512, camera_center=(3,0.3,0))
t.light((4,3,2), 0.2, (1,1,1))
t.texture('t0', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1.0,0,0))
t.texture('t1', ambient=0.1, diffuse=0.9, specular=0.3, opacity=1.0, color=(0,1.0,0))
t.texture('t2', ambient=0.2,diffuse=0.7, specular=0.5, opacity=0.7, color=(0,0,1.0))
k=0
for i in srange(-1,j,0.05):
k += 1
t.sphere((i,i^2-0.5,i^3), 0.1, 't%s'%(k%3))
saved.append(t)
</code></pre>
<p>In "saved" array I have all the png of the animation I want to do, and I can view it with saved[i].show().</p>
<p>I tried to unite all the frames with the command animate:</p>
<pre><code>animate(saved[i].show() for i in range(0,len(saved)))
</code></pre>
<p>But it didn't work. What other alternatives do I have? (without using ffmpeg)</p>
<p>Thank you!</p>
http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?answer=13584#post-id-13584I see. Well, first off, the things in your `saved` are not actually graphics file, but Tachyon scenes. Secondly, we can access things in the notebook via the `DATA` variable. Borrowing some ideas from the thread mentioned in the other post:
for i in range(len(saved)):
saved[i].save(filename=DATA+'mypic%d.png'%i)
os.system('cd '+DATA+'; convert -delay %s -loop %s *.png "Done.gif"'%(int(100),int(2)))
os.system('ls '+DATA)
This shows that the `Done.gif` is there. If you then go to the "Data..." menu and choose it, you will see it and be able to download it. That's not ideal, but a lot better than nothing.
![where to look](/upfiles/13372715099927898.png)
Naturally, this all assumes you have `animate` working properly (because that requires the `convert` command we are using here). Probably I should also use `sage-native-execute` but I don't really understand that.Thu, 17 May 2012 06:19:01 -0500http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?answer=13584#post-id-13584Comment by Joel Sjögren for <p>I see. Well, first off, the things in your <code>saved</code> are not actually graphics file, but Tachyon scenes. Secondly, we can access things in the notebook via the <code>DATA</code> variable. Borrowing some ideas from the thread mentioned in the other post:</p>
<pre><code>for i in range(len(saved)):
saved[i].save(filename=DATA+'mypic%d.png'%i)
os.system('cd '+DATA+'; convert -delay %s -loop %s *.png "Done.gif"'%(int(100),int(2)))
os.system('ls '+DATA)
</code></pre>
<p>This shows that the <code>Done.gif</code> is there. If you then go to the "Data..." menu and choose it, you will see it and be able to download it. That's not ideal, but a lot better than nothing. </p>
<p><img alt="where to look" src="/upfiles/13372715099927898.png"/></p>
<p>Naturally, this all assumes you have <code>animate</code> working properly (because that requires the <code>convert</code> command we are using here). Probably I should also use <code>sage-native-execute</code> but I don't really understand that.</p>
http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=17333#post-id-17333@Roctiv you're right. This should be used instead: 'mypic%02d.png' % i. Then it is ok if len(saved) < 100. You can of course change 02 to something bigger if desired.Mon, 08 Jul 2013 05:11:12 -0500http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=17333#post-id-17333Comment by Roctiv for <p>I see. Well, first off, the things in your <code>saved</code> are not actually graphics file, but Tachyon scenes. Secondly, we can access things in the notebook via the <code>DATA</code> variable. Borrowing some ideas from the thread mentioned in the other post:</p>
<pre><code>for i in range(len(saved)):
saved[i].save(filename=DATA+'mypic%d.png'%i)
os.system('cd '+DATA+'; convert -delay %s -loop %s *.png "Done.gif"'%(int(100),int(2)))
os.system('ls '+DATA)
</code></pre>
<p>This shows that the <code>Done.gif</code> is there. If you then go to the "Data..." menu and choose it, you will see it and be able to download it. That's not ideal, but a lot better than nothing. </p>
<p><img alt="where to look" src="/upfiles/13372715099927898.png"/></p>
<p>Naturally, this all assumes you have <code>animate</code> working properly (because that requires the <code>convert</code> command we are using here). Probably I should also use <code>sage-native-execute</code> but I don't really understand that.</p>
http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=19779#post-id-19779Thank you!!! That's it! I wanted something simple, because I can only use the notebook (I cannot modify the system). Thank you very muchThu, 17 May 2012 06:35:31 -0500http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=19779#post-id-19779Comment by kcrisman for <p>I see. Well, first off, the things in your <code>saved</code> are not actually graphics file, but Tachyon scenes. Secondly, we can access things in the notebook via the <code>DATA</code> variable. Borrowing some ideas from the thread mentioned in the other post:</p>
<pre><code>for i in range(len(saved)):
saved[i].save(filename=DATA+'mypic%d.png'%i)
os.system('cd '+DATA+'; convert -delay %s -loop %s *.png "Done.gif"'%(int(100),int(2)))
os.system('ls '+DATA)
</code></pre>
<p>This shows that the <code>Done.gif</code> is there. If you then go to the "Data..." menu and choose it, you will see it and be able to download it. That's not ideal, but a lot better than nothing. </p>
<p><img alt="where to look" src="/upfiles/13372715099927898.png"/></p>
<p>Naturally, this all assumes you have <code>animate</code> working properly (because that requires the <code>convert</code> command we are using here). Probably I should also use <code>sage-native-execute</code> but I don't really understand that.</p>
http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=19776#post-id-19776Oh, maybe I should have used %s instead of %d?Thu, 17 May 2012 07:47:43 -0500http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=19776#post-id-19776Comment by Roctiv for <p>I see. Well, first off, the things in your <code>saved</code> are not actually graphics file, but Tachyon scenes. Secondly, we can access things in the notebook via the <code>DATA</code> variable. Borrowing some ideas from the thread mentioned in the other post:</p>
<pre><code>for i in range(len(saved)):
saved[i].save(filename=DATA+'mypic%d.png'%i)
os.system('cd '+DATA+'; convert -delay %s -loop %s *.png "Done.gif"'%(int(100),int(2)))
os.system('ls '+DATA)
</code></pre>
<p>This shows that the <code>Done.gif</code> is there. If you then go to the "Data..." menu and choose it, you will see it and be able to download it. That's not ideal, but a lot better than nothing. </p>
<p><img alt="where to look" src="/upfiles/13372715099927898.png"/></p>
<p>Naturally, this all assumes you have <code>animate</code> working properly (because that requires the <code>convert</code> command we are using here). Probably I should also use <code>sage-native-execute</code> but I don't really understand that.</p>
http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=19777#post-id-19777To the guy who will see this in the future (he could be me tomorrow): that funtion is ok if len(saved) < 10, if it's bigger the names of the should have more digits.Thu, 17 May 2012 06:53:13 -0500http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=19777#post-id-19777Answer by kcrisman for <p>Hello!</p>
<p>I'm trying to create a 3d animations, frame per frame. I've discovered that tachyon plotter is very usefull to create images. But after that, I'm unable to make it as animation.</p>
<p>For example, I have copied a code and generate some scenes with tachyon with this:</p>
<pre><code>saved = []
for j in srange(-0.9,1,0.3):
t = Tachyon(xres=512,yres=512, camera_center=(3,0.3,0))
t.light((4,3,2), 0.2, (1,1,1))
t.texture('t0', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1.0,0,0))
t.texture('t1', ambient=0.1, diffuse=0.9, specular=0.3, opacity=1.0, color=(0,1.0,0))
t.texture('t2', ambient=0.2,diffuse=0.7, specular=0.5, opacity=0.7, color=(0,0,1.0))
k=0
for i in srange(-1,j,0.05):
k += 1
t.sphere((i,i^2-0.5,i^3), 0.1, 't%s'%(k%3))
saved.append(t)
</code></pre>
<p>In "saved" array I have all the png of the animation I want to do, and I can view it with saved[i].show().</p>
<p>I tried to unite all the frames with the command animate:</p>
<pre><code>animate(saved[i].show() for i in range(0,len(saved)))
</code></pre>
<p>But it didn't work. What other alternatives do I have? (without using ffmpeg)</p>
<p>Thank you!</p>
http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?answer=13583#post-id-13583You say without ffmpeg, but [apparently](http://ask.sagemath.org/question/99/animate-3d-plots?answer=243#243) that's the only obvious way to do it. You might also find [Trac 7298](http://trac.sagemath.org/sage_trac/ticket/7298) helpful, though apparently that has unresolved issues.
Note that this "answer" is really just Marshall's from [the other ask.sagemath.org question](http://ask.sagemath.org/question/99/animate-3d-plots).
Edit: [Trac 12827](http://trac.sagemath.org/sage_trac/ticket/12827) actually is about adding more types to the animate command, such as Tachyon-generated pictures.Thu, 17 May 2012 04:53:43 -0500http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?answer=13583#post-id-13583Comment by kcrisman for <p>You say without ffmpeg, but <a href="http://ask.sagemath.org/question/99/animate-3d-plots?answer=243#243">apparently</a> that's the only obvious way to do it. You might also find <a href="http://trac.sagemath.org/sage_trac/ticket/7298">Trac 7298</a> helpful, though apparently that has unresolved issues.</p>
<p>Note that this "answer" is really just Marshall's from <a href="http://ask.sagemath.org/question/99/animate-3d-plots">the other ask.sagemath.org question</a>.</p>
<p>Edit: <a href="http://trac.sagemath.org/sage_trac/ticket/12827">Trac 12827</a> actually is about adding more types to the animate command, such as Tachyon-generated pictures.</p>
http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=19780#post-id-19780It looks like there would be a way to use the code in `animate??` to do this, but as it stands the `animate` command is for animating either 2-D graphics objects or something which can be 2-D plotted. Extending it to do what you want is probably not a bad idea, but would take some work.Thu, 17 May 2012 05:31:48 -0500http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=19780#post-id-19780Comment by Roctiv for <p>You say without ffmpeg, but <a href="http://ask.sagemath.org/question/99/animate-3d-plots?answer=243#243">apparently</a> that's the only obvious way to do it. You might also find <a href="http://trac.sagemath.org/sage_trac/ticket/7298">Trac 7298</a> helpful, though apparently that has unresolved issues.</p>
<p>Note that this "answer" is really just Marshall's from <a href="http://ask.sagemath.org/question/99/animate-3d-plots">the other ask.sagemath.org question</a>.</p>
<p>Edit: <a href="http://trac.sagemath.org/sage_trac/ticket/12827">Trac 12827</a> actually is about adding more types to the animate command, such as Tachyon-generated pictures.</p>
http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=19768#post-id-19768I wanted to aswer just ":)", but I need 10 chararcters :DFri, 18 May 2012 05:14:14 -0500http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=19768#post-id-19768Comment by Roctiv for <p>You say without ffmpeg, but <a href="http://ask.sagemath.org/question/99/animate-3d-plots?answer=243#243">apparently</a> that's the only obvious way to do it. You might also find <a href="http://trac.sagemath.org/sage_trac/ticket/7298">Trac 7298</a> helpful, though apparently that has unresolved issues.</p>
<p>Note that this "answer" is really just Marshall's from <a href="http://ask.sagemath.org/question/99/animate-3d-plots">the other ask.sagemath.org question</a>.</p>
<p>Edit: <a href="http://trac.sagemath.org/sage_trac/ticket/12827">Trac 12827</a> actually is about adding more types to the animate command, such as Tachyon-generated pictures.</p>
http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=19781#post-id-19781Thank you. I had already seen that answer. But I think, that what I want to do is too simple to attack it with a powerfull tool (that I don't know how to use). I mean, animate function should be enough to join a couple of photgrams... or not?Thu, 17 May 2012 05:04:56 -0500http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=19781#post-id-19781Comment by Roctiv for <p>You say without ffmpeg, but <a href="http://ask.sagemath.org/question/99/animate-3d-plots?answer=243#243">apparently</a> that's the only obvious way to do it. You might also find <a href="http://trac.sagemath.org/sage_trac/ticket/7298">Trac 7298</a> helpful, though apparently that has unresolved issues.</p>
<p>Note that this "answer" is really just Marshall's from <a href="http://ask.sagemath.org/question/99/animate-3d-plots">the other ask.sagemath.org question</a>.</p>
<p>Edit: <a href="http://trac.sagemath.org/sage_trac/ticket/12827">Trac 12827</a> actually is about adding more types to the animate command, such as Tachyon-generated pictures.</p>
http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=19778#post-id-19778I thought animate function had more freedom to choose the types :(Thu, 17 May 2012 06:41:16 -0500http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=19778#post-id-19778Comment by kcrisman for <p>You say without ffmpeg, but <a href="http://ask.sagemath.org/question/99/animate-3d-plots?answer=243#243">apparently</a> that's the only obvious way to do it. You might also find <a href="http://trac.sagemath.org/sage_trac/ticket/7298">Trac 7298</a> helpful, though apparently that has unresolved issues.</p>
<p>Note that this "answer" is really just Marshall's from <a href="http://ask.sagemath.org/question/99/animate-3d-plots">the other ask.sagemath.org question</a>.</p>
<p>Edit: <a href="http://trac.sagemath.org/sage_trac/ticket/12827">Trac 12827</a> actually is about adding more types to the animate command, such as Tachyon-generated pictures.</p>
http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=19775#post-id-19775No, it's pretty clear in the constructor what it does. Doesn't mean we couldn't add them! See my edit to this answer.Thu, 17 May 2012 07:49:58 -0500http://ask.sagemath.org/question/8947/3d-animation-with-tachyon/?comment=19775#post-id-19775