On Thu, Jan 15, 2009 at 7:43 PM, Marshall Hampton <[email protected]> wrote:
>
> ok, so this should work on sagenb:
For the record, I would be *very* happy if you made it so the
sage animate(...) command could do this automatically. It's
fine that ffmpeg would have to be installed -- just give a graceful
error message if it isn't. Is there a trac ticket for this yet?
It would probably be easy to implement, using the example below and
the current animate code (which does 2d plots and uses imagemagick to
make animated gifs).
>
> {{{
> %sh
> mkdir /tmp/username_temp
> }}}
>
> {{{
> c = polytopes.icosahedron()
> label = 'Ico_movie'
> DATA = '/tmp/mh_temp/'
> # Numerical pi predefined for some speed
> npi = RDF(pi)
>
> #A rotation matrix
> def rot(i,j,th):
> q = matrix(RDF,3)
> for k in range(3):
> q[k,k] = 1.0
> q[i,i] = cos(th)
> q[j,j] = cos(th)
> q[i,j] = sin(th)
> q[j,i] = -sin(th)
> return q
>
> index = 0
> for theta in srange(0,2*npi,npi/10):
> vs = c.vertices()[:]
> #rotate the vertices:
> vs = [rot(0,1,theta)*vector(v) for v in vs]
> edgedata = c.vertex_adjacencies()
> facedata = c.triangulated_facial_incidences()
>
> #Set up Tachyon.
> #use small xres, yres for speed.
> #antialiasing helps things lookbetter.
> t = Tachyon(xres = 250, yres = 250, antialiasing = True)
> t.texture('e1', color = (0,0,1))
> t.texture('f1',opacity = .5, color = (1,0,0))
> t.light((2,2,2), 0.1, (1,1,1))
>
> #Draw edges:
> edges = []
> for anedge in edgedata:
> v0 = anedge[0]
> for v1 in anedge[1]:
> if v1 > v0:
> edges.append([vs[v0],vs[v1]])
> for anedge in edges:
> t.fcylinder(anedge[0],anedge[1],.01,'e1')
>
> #Draw transparent faces:
> for atri in facedata:
> t.triangle(vs[atri[1][0]],vs[atri[1][1]],vs[atri[1][2]],'f1')
>
> #Make file names in order for ffmpeg
> str_index = '0'*(3-len(str(index)))+str(index)
> t.save(DATA+label+ str_index + '.png')
> index += 1
>
> #Add a black final frame,
> #since otherwise the compression in ffmpeggets confused.
> t = Tachyon(xres = 250, yres = 250, antialiasing = True)
> str_index = '0'*(3-len(str(index)))+str(index)
> t.save(DATA+label+ str_index + '.png')
>
> #Use ffmpeg to animate:
> os.system('ffmpeg -qmax 2 -i ' + DATA + label + '%3d.png ./test.mp4')
> }}}
>
>
> On Jan 15, 9:34 pm, mabshoff <[email protected]
> dortmund.de> wrote:
>> On Jan 15, 7:31 pm, "Justin C. Walker" <[email protected]> wrote:
>>
>> > On Jan 15, 2009, at 19:02 , mabshoff wrote:
>>
>> <SNIP>
>>
>> > > Just use /tmp or DOT_SAGE/tmp, but create a directory in it so you
>> > > don't clobber other jobs of the same kind. It might be a good idea to
>> > > add some create_tmpdir() command in Sage that is guaranteed to be
>> > > unique and is in a writable directory, i.e. it should first try
>> > > DOT_SAGE/tmp, then /tmp and so on. IIRC there is even some env
>> > > variable where we can point a per user tmp dir to. So you might want
>> > > to open a ticket for the above in order to avoid various people doing
>> > > the same thing in their own code over and over again.
>>
>> > Python has several calls to make temporary files that will not be
>> > clobbered by other users or uses. No need to make directories.
>>
>> Yes, but we are ending up calling command line tools which to not obey
>> Python's convention :)
>>
>> And having all the files in one directory makes debugging a lot easier
>> and it assures that you get rid of all files by just wiping the one
>> tmp directory.
>>
>> > Justin
>>
>> Cheers,
>>
>> Michael
>>
>> > --
>> > Justin C. Walker, Curmudgeon at Large
>> > Institute for the Absorption of Federal Funds
>> > --
>> > Democracy is two wolves and a lamb
>> > voting on what to have for lunch.
>> > Liberty is a well-armed lamb contesting
>> > the vote.
> >
>
--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---