Re: Move a clock pulse train, please help

liming xiu <[email protected]> Fri, 19 Oct 2012 11:35:15 -0500
Newsgroups gmane.comp.python.visualpython.user
Message-ID <CACEtLT3y704Q44QRdUJM5qUGSrEftK1rxK43+ofkO26xLEU5sw@mail.gmail.com>
Dear Bruce:

Thanks.  It looks great!

Can I ask you one more favor:

I want to create 8 of these clock pulse trains, from screen top to
bottom ( the screen can be made bigger).

1. All the 8 pulse trains have save frequency (same T).
2. Time-wise, each pulse trains is delayed from its previous one by
(1/8)T. In other words, the second one is (1/8)T behind the first one,
the third one is  (1/8)T behind the second one.
3. They all move from left to right.

Can you help me on this?

Thanks in advance!





On Fri, Oct 19, 2012 at 11:14 AM, Bruce Sherwood
<[email protected]> wrote:
> That's a clever way to make a pulse train; I wouldn't have thought of
> using the math ceil function. Here's one way to animate the pulse
> train, moving to the right. I set the range to 9 so that the pulses
> fill the screen. I move the display's center to the left until one
> period has elapsed, when I reset the center to the origin:
>
> from visual import *
>
> g = []
> g.append(display(x = 0, y = 100, width=1000, height=400, range=9))
>
> g[0].title="Second try"
>
> k = 5
> T = 2*pi/k
> c = curve( x = arange(-10,10,0.01),
>         display=g[0],radius=0.07,color=color.yellow  ) # Draw a pulse train
> c.y = ceil(sin( k*c.x ))
>
> t = 0
> dt = T/20
> while True:
>     rate(100)
>     g[0].center.x -= dt
>     t += dt
>     if t >= T:
>         g[0].center.x = 0
>         t = 0
>
> You might wish to disable userspin and userzoom to prevent the viewer
> from messing up the display.
>
> Just in case you hadn't noticed it, I'll comment that in your original
> program you don't need a loop at the end to keep the display alive.
> When you come to the end of a VPython program, the display remains on
> the screen and you can zoom and rotate.
>
> Bruce Sherwood
>
> On Fri, Oct 19, 2012 at 9:39 AM, liming xiu <[email protected]> wrote:
>> Hi,
>>
>> I am new to VPython. I want to use this tool to do a project for my work.
>>
>> I create a clock pulse train using the few lines below.
>>
>> ----------------------------------------------------
>> from visual import *
>>
>> g = []
>> g.append(display(x = 0, y = 100, width=1000, height=400))
>>
>> g[0].title="First try"
>>
>> c = curve( x = arange(-10,10,0.01),
>> display=g[0],radius=0.07,color=color.yellow  ) # Draw a helix
>> c.y = ceil(sin( 5.0*c.x ))
>>
>> while True:
>>     rate(5)

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct