POV-Ray : Newsgroups : povray.advanced-users : Air resistance Server Time
29 Jul 2024 10:20:50 EDT (-0400)
  Air resistance (Message 11 to 20 of 22)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 2 Messages >>>
From: Lutz-Peter Hooge
Subject: Re: Quick Check...
Date: 2 Oct 2002 13:12:17
Message: <3d9b28f1$1@news.povray.org>
In article <3d9b157e@news.povray.org>, orp### [at] btinternetcom says...

> #declare TimeStep = clock_delta * TotalTime; // = seconds since prev frame??

What about Timestep=1/FPS? ;-)

Lutz-Peter


Post a reply to this message

From: Slime
Subject: Re: Quick Check...
Date: 2 Oct 2002 21:59:07
Message: <3d9ba46b$1@news.povray.org>
> #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

From: Andrew Coppin
Subject: Re: Quick Check...
Date: 3 Oct 2002 05:21:36
Message: <3d9c0c20@news.povray.org>
"Lutz-Peter Hooge" <lpv### [at] gmxde> wrote in message
news:3d9b28f1$1@news.povray.org...
> In article <3d9b157e@news.povray.org>, orp### [at] btinternetcom 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

From: Andrew Coppin
Subject: Re: Quick Check...
Date: 3 Oct 2002 05:23:20
Message: <3d9c0c88@news.povray.org>
> 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

From: Andrew Coppin
Subject: Re: Quick Check...
Date: 3 Oct 2002 09:26:11
Message: <3d9c4573@news.povray.org>
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

From: Slime
Subject: Re: Quick Check...
Date: 3 Oct 2002 19:08:11
Message: <3d9ccddb@news.povray.org>
> 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

From: Andrew Coppin
Subject: Re: Quick Check...
Date: 4 Oct 2002 05:55:13
Message: <3d9d6581@news.povray.org>
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

From: Micha Riser
Subject: Re: Quick Check...
Date: 4 Oct 2002 07:45:20
Message: <3d9d7f50$1@news.povray.org>
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

From: Andrew Coppin
Subject: Re: Quick Check...
Date: 4 Oct 2002 08:23:10
Message: <3d9d882e@news.povray.org>
> 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

From: Micha Riser
Subject: Re: Quick Check...
Date: 4 Oct 2002 08:41:40
Message: <3d9d8c82@news.povray.org>
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

<<< Previous 10 Messages Goto Latest 10 Messages Next 2 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.