![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
In article <3d9b157e@news.povray.org>, orp### [at] btinternet com says...
> #declare TimeStep = clock_delta * TotalTime; // = seconds since prev frame??
What about Timestep=1/FPS? ;-)
Lutz-Peter
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
> #declare Velocity = Velocity * (1 - (k * TimeStep));
This only works on the assumption that
Velocity * .8
is equal to
Velocity * .9 * .9
But that isn't true. Velocity * .9 * .9 is equal to Velocity * .81. This is
close to .8, but when you start cutting off larger amounts (like .4), the
difference becomes significant (Velocity * (1-.4-.4) = Velocity * .2 is very
different than Velocity*.4*.4 = Velocity*.16).
Over a large number of frames, though, even these small differences may
create large changes in the animation. The problem is that, while the
constant is related to the framerate, it's not *linearly* related.
- Slime
[ http://www.slimeland.com/ ]
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
"Lutz-Peter Hooge" <lpv### [at] gmx de> wrote in message
news:3d9b28f1$1@news.povray.org...
> In article <3d9b157e@news.povray.org>, orp### [at] btinternet com says...
>
> > #declare TimeStep = clock_delta * TotalTime; // = seconds since prev
frame??
>
> What about Timestep=1/FPS? ;-)
>
> Lutz-Peter
OK, why didn't _I_ think of that!!! :-S
Andrew.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
> The problem is that, while the
> constant is related to the framerate, it's not *linearly* related.
Grrr... what a pain in the head!
Will have to sift some more algebra offline...
Andrew.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Just a thought... Would this work like compound interest? I.e., if an
investment earns 30% per year, you can work out how much it earns in, say, 1
month, such that over 12 months the compounded figure still adds up to 30%
of the original. So a) is this analogy correct, and b) does anyone out there
know the compound interest formula? :-)
Andrew.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
> Just a thought... Would this work like compound interest? I.e., if an
> investment earns 30% per year, you can work out how much it earns in, say,
1
> month, such that over 12 months the compounded figure still adds up to 30%
> of the original. So a) is this analogy correct, and b) does anyone out
there
> know the compound interest formula? :-)
Yes, it's probably correct, since it's exponential, as is the simplified air
resistance model we've presented. But no I don't know the formula. =)
- Slime
[ http://www.slimeland.com/ ]
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Mmm... ok, well let's say I want my particle to loose 30% of it's velocity
every second (that's probably too much, but just for example). So, if a time
step is 1 second long, I want the damping to be 30%. If it's 2 seconds, I
want it to be 30% squared... So, I'm guessing something like 30 ^ (time step
in seconds). Seem reasonable? Once I know how much velocity the particle
should loose during this step, I can just use V = V * (1 - k) to remove it.
Opinions?
Andrew.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Andrew Coppin wrote:
> Mmm... ok, well let's say I want my particle to loose 30% of it's velocity
> every second (that's probably too much, but just for example). So, if a
> time step is 1 second long, I want the damping to be 30%. If it's 2
> seconds, I want it to be 30% squared... So, I'm guessing something like 30
> ^ (time step in seconds). Seem reasonable? Once I know how much velocity
> the particle should loose during this step, I can just use V = V * (1 - k)
> to remove it.
This is correct but you have a problem when you want to change the time
steps.
Let's see..
The decrease in velocity over time is to be constant. Therefore:
dv/dt = -k
for some positive k. This differential euqation has the solution:
v(t) = c0 * exp(-kt),
where c0 = v(0).
Now if you want to calculate v(T + deltaT) you need:
v(T + deltaT) = c0 * exp(-k*T -k*deltaT) = c0 * exp(-k*T) * exp(-k*deltaT)
= v(T) * exp(-k*deltaT)
This allows you to calcuate the sequence of v for any stepsize deltaT.
But what is k? Assume you want to have v(t + 1) = p*v(t), this means v
loses (1-p) of its velocity in 1 second. How to chose k?
v(t + 1) = c0*exp(-k*t -k) = c0*exp(-k*t) * exp(-k) = v(t)*exp(-k)
Therefore:
v(t)*exp(-k) = p*v(t) => p = exp(-k) => k = -ln(p)
E.g. if you want p = 0.3 (loses 70%/second) then
k = -ln(0.3) = 1.203...
Just a bit math ;)
- Micha
--
objects.povworld.org - The POV-Ray Objects Collection
book.povworld.org - The POV-Ray Book Project
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
> E.g. if you want p = 0.3 (loses 70%/second) then
>
> k = -ln(0.3) = 1.203...
>
> Just a bit math ;)
>
> - Micha
I seldom cease to be humbled by the skill of the folks on this news
Smooth move!
Andrew.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Andrew Coppin wrote:
>
> I seldom cease to be humbled by the skill of the folks on this news
>
I just see right now that my result is a bit more complicated than it needs
to be.. you can get rid of the exp/ln if you put k = -ln(p) back into the
equation:
v(T + deltaT) = v(T) * exp(-k*deltaT) = v(T) * exp(ln(p)*deltaT)
= v(T) * p^deltaT
That means, e.g. with p = 0.3 and deltaT = 0.01 you get
v(T+0.01) = v(T) * 0.3^0.01 = v(T) * 0.98803
But the calculation serves as justification for this formula (You wouldn't
want use something you didn't prove ;) )
- Micha
BTW: You should really get into differential equations... it's one of the
most interesting things in math.
--
objects.povworld.org - The POV-Ray Objects Collection
book.povworld.org - The POV-Ray Book Project
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |