POV-Ray : Newsgroups : povray.advanced-users : Air resistance : Re: Quick Check... Server Time
29 Jul 2024 12:27:04 EDT (-0400)
  Re: Quick Check...  
From: Micha Riser
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

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