From: Gary S. <st...@nm...> - 2002-06-21 20:49:55
|
> These two numbers can be entirely different. Your program measures the > second, which is also what rate() controls. There is no way to change > the rendering frame rate in VPython (except to buy a faster computer :), Question: if you've re-computed a (or requested a new) frame before the previous one was done rendering, does the rendering re-start with the new frame? I presume they don't pile up in a buffer somewhere ... > Now, what rate() does is fairly simple. It could be written in Python (snip) > while (delay - (time.time() - origin) > 0): > pass > origin = time.time() (snip) > > The reason this can still have an effect when your "loop rate" is less > than N, because your loop will not execute in exactly the same wall > clock time each time, and rate() does not attempt to average across > iterations. > > For example, let's say N = 50, and your loop (without the call to > rate()) takes 10ms for every even iteration and 30ms for every odd > iteration. On each even iteration, rate() will sleep for 10ms, so that > that iteration takes 20ms. On odd iterations it will not sleep at all. > The net effect is that the frame rate changes from 50 (20ms average) to > 40 (25ms average). Interestingly, replacing the rate() call in my previous program with a spin-loop of the short you mentioned above (but based on time.clock(), which on Windows is supposed to be accurate down to microseconds), I still get the stair-stepping ... which I don't understand. I believe the above explanation will, at most, provide only a single plateau. Or perhaps I misunderstood something ... Gary strang-@at@-nmr.mgh.harvard.edu |