|
From: Lorenzo I. <lor...@gm...> - 2008-01-12 11:19:25
|
Hello,
and thanks for your help.
Probably I'd better make one step at the time.
I made some progress in creating an animation; say that I have n_part
particles and n_config stored configurations (i.e.snapshots of the
system), and that all the particles coordinates in a given configuration
are stored in x_list, y_list, z_list, then this is what I can do:
1) read the particle positions from tot_config and plot the initial
configuration
my_config=0
for i in xrange(0,n_part):
x_list[i]=tot_config[my_conf,3*i]
y_list[i]=tot_config[my_conf,(3*i+1)]
z_list[i]=tot_config[my_conf,(3*i+2)]
particles=[v.sphere(pos=loc,radius=my_rad,color=v.color.blue)\
for loc in zip(x_list,y_list,z_list)]
2) Then I can update the particle positions by reading the other
configurations and re-using x_list,y_list and z_list:
for my_conf in xrange(1,n_config):
for i in xrange(0,n_part):
x_list[i]=tot_config[my_conf,3*i]
y_list[i]=tot_config[my_conf,(3*i+1)]
z_list[i]=tot_config[my_conf,(3*i+2)]
v.rate(1000)
particles[i].pos=(x_list[i],y_list[i],z_list[i])
The problem of doing so is that I am "moving" only a particle at the
time, it takes quite some time and the resulting animations looks
somehow odd.
My idea would be: first generate the particles and locate them as in the
initial configuration, then read the second configuration and move all
the particles accordingly in a single go and so on and so forth.
However, whereas I can directly address e.g. particles[4].pos, I cannot
manipulate in one go all the particle positions directly via
particles.pos, which is why I am posting again.
I am sure that fixing this must be a one-liner, but so far I have not
achieved much.
Many thanks
Lorenzo
>
> Message: 3
> Date: Thu, 10 Jan 2008 17:52:30 -0800
> From: Scott David Daniels <Sco...@Ac...>
> Subject: Re: [Visualpython-users] Generating PDF and Movies in Visual
> Python
> To: vis...@li...
> Message-ID: <fm6hs4$rhj$1...@ge...>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Lorenzo Isella wrote:
>
>> ...
>> pos_list=s.zeros(3) # I initialize the array to contain the single
>> particle's coordinates
>> my_rad=1.06/2.
>> for i in xrange(0,n_part): #n_part is the number of particles in my system
>> pos_list[0]=x_list[i] #x_list contains a list of the x-coordinate
>> of all the particles in the system at a given time
>> pos_list[1]=y_list[i]
>> pos_list[2]=z_list[i]
>> particle=v.sphere(pos=pos_list,radius=my_rad,color=v.color.blue)
>>
> > In a sense, I have filled the space with the same particle repeated
> > many times, whereas I would like to have an array of particles
> > part[j] whose positions can be updated in time.
>
> Try this (to get all points in the frame):
> my_rad = 1.06 / 2.
> particles = [v.sphere(pos=loc, radius=my_rad, color=v.color.blue)
> for loc in zip(x_list, y_list, z_list)]
>
>
>> 1)zooming and selecting a part of the scene (i.e. some specific particle
>> configurations) and generating a pdf or eps or jpg or png file.
>>
> See Ruth Chabay's contributed program to go from Vpython to POV-Ray
> source, then use POV-Ray to go from source to .png image.
>
>
>> 2)generating a movie. I saw there is a contributed program which should
>> work only for MacOS and I wonder if there is anything similar available
>> for Linux (I am running Debian testing on my box).
>>
> First, you are not asking anything simple when you ask to go to a movie.
> Your head needs to get higher if you really want to do this. E-mail me
> separately if you have everything solved up through getting .png images,
> and I can provide you with "no redistribution; no comercial use" code to
> take a bunch of .png files to a .mng file (which is an obscure movie
> format, but there _are_ a few readers out there).
>
> --Scott David Daniels
> Sco...@Ac...
>
>
>
>
>
|