POV-Ray : Newsgroups : povray.advanced-users : Air resistance Server Time
11 Oct 2026 05:22:31 EDT (-0400)
  Air resistance (Message 1 to 22 of 22)  
From: Andrew Coppin
Subject: Air resistance
Date: 1 Oct 2002 09:51:46
Message: <3d99a872@news.povray.org>
I now have a working Chaos Pendulum - yay!

But I was wondering... how would I go about modelling air resistance? All I
want is to have a system which doesn't go into a fixed oscilation that lasts
forever; I want air resistance to damp it down.

Let's say I have a vector V which represents the particle's velocity. I
could do something like
  #declare V = 0.9*V;
Or perhaps I could try
  #declare V = pow(V, 0.9);
(if that would actually work - POV-Ray's syntax won't allow it, but you get
the gist. Something like "pow(vlength(V), 0.9) * vnormalize(V)" would work -
or even "pow(vlength(V), -0.1) * V".)

The question is, does air resistence slow something down more at high speed?
Or is it roughly constant? (I know this depends on the shape of the object -
we're talking about a smallish sphere here.) Clearly a high-speed object
will encounter more drag. But it will also have more momentum. So which is
it? Multiply V by a constant 0 < k < 1? Or raise it to the power of a
similar constant? I'm not really interested in making this super-realistic,
I'd just like some opinions.

Thanks.
Andrew.


Post a reply to this message

From: Slime
Subject: Re: Air resistance
Date: 1 Oct 2002 13:54:21
Message: <3d99e14d@news.povray.org>
>   #declare V = 0.9*V;


This is physically accurate.

>   #declare V = pow(V, 0.9);

This is not.

The only difficulty with V=V*.99 is that the constant (.99) changes
depending on the framerate.

> The question is, does air resistence slow something down more at high
speed?

Well, yeah, but only because (1-.9)* a high speed is greater than (1-.9)* a
low speed.

 - Slime
[ http://www.slimeland.com/ ]


Post a reply to this message

From: Christoph Hormann
Subject: Re: Air resistance
Date: 1 Oct 2002 14:03:37
Message: <3D99E375.D3F91328@gmx.de>
Slime wrote:
> 
> >   #declare V = 0.9*V;
> 
> This is physically accurate.
> 
> >   #declare V = pow(V, 0.9);
> 
> This is not.
> 

In fact neither of them is.

In the general case the force generated by air resistance is a quite
complicated function of the speed.  At low speeds it can be approximated
by a force proportional to the speed (the first of the cited formulas).

Christoph

-- 
POV-Ray tutorials, IsoWood include,                 
TransSkin and more: http://www.tu-bs.de/~y0013390/  
Last updated 13 Aug. 2002 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: David Wallace
Subject: Re: Air resistance
Date: 1 Oct 2002 14:06:04
Message: <3d99e40c@news.povray.org>
I actually modeled air resistance in my TearPool IRTC entry:

    #local spd = vlength(vVel[cShot]); // Speed, m/s
    #local dir = vnormalize(vVel[cShot]); // Direction
    #local rdFlat = 1+pow(spd,0.25)*.2; // Drag stretching factor
    #local Cd = 1.3/rdFlat/rdFlat; // Drag coefficient
    #local sMass = 4/3*pi*rd*rd*rd*rhos; // Mass, kg
    #local sCross = pi*rd*rd/rdFlat; // Cross section, m^2

    #local sAcc = ag - dir*0.5*Cd*rhoa*sCross*spd*spd/sMass;
    #local vo = vVel[cShot];
    #declare vVel[cShot] = vVel[cShot] + deltat*sAcc;
    #declare vPos[cShot] = vPos[cShot] + deltat*(vo+vVel[cShot])/2;

This is the part of the lava creation section which calculates air
resistance.  Basically drag is a force calculated as follows:

    F = 0.5*m*v^2*A/V*Cd, directed against the velocity

The rdFlat variable in my setup was an attempt to take the viscous drag of
the molten lava into account by stretching the particle.

"Andrew Coppin" <orp### [at] btinternetcom> wrote in message
news:3d99a872@news.povray.org...
> I now have a working Chaos Pendulum - yay!
>
> But I was wondering... how would I go about modelling air resistance? All
I
> want is to have a system which doesn't go into a fixed oscilation that
lasts
> forever; I want air resistance to damp it down.
>
> Let's say I have a vector V which represents the particle's velocity. I
> could do something like
>   #declare V = 0.9*V;
> Or perhaps I could try
>   #declare V = pow(V, 0.9);
> (if that would actually work - POV-Ray's syntax won't allow it, but you
get
> the gist. Something like "pow(vlength(V), 0.9) * vnormalize(V)" would
work -
> or even "pow(vlength(V), -0.1) * V".)
>
> The question is, does air resistence slow something down more at high
speed?
> Or is it roughly constant? (I know this depends on the shape of the
object -
> we're talking about a smallish sphere here.) Clearly a high-speed object
> will encounter more drag. But it will also have more momentum. So which is
> it? Multiply V by a constant 0 < k < 1? Or raise it to the power of a
> similar constant? I'm not really interested in making this
super-realistic,
> I'd just like some opinions.
>
> Thanks.
> Andrew.
>
>
>


Post a reply to this message

From: Lutz-Peter Hooge
Subject: Re: Air resistance
Date: 1 Oct 2002 15:12:11
Message: <3d99f38b$1@news.povray.org>
In article <3d99e14d@news.povray.org>, slm### [at] slimelandcom says...
> >   #declare V = 0.9*V;
> 
> 
> This is physically accurate.

Only for relatively slow speeds.

Also "0.9" is not really a constant, but should be a function of the mass 
of the object, its geometry and the time-interval of course.

so "#declare V = V * (1 - delta_t * k/m)" would be better.

Lutz-Peter


Post a reply to this message

From: Slime
Subject: Re: Air resistance
Date: 1 Oct 2002 16:32:21
Message: <3d9a0655$1@news.povray.org>
> Only for relatively slow speeds.


Apparently I was misled in Physics class, or else I forgot about the
details. Sorry =)

> Also "0.9" is not really a constant, but should be a function of the mass
> of the object, its geometry and the time-interval of course.


Well, yeah, but I figured for the purposes of a POV-Ray animation, you could
just fudge the constant so that it looked alright. I rarely worry about the
actual calculation of constants in POV-Ray, I just use the ideas behind the
formulas. (For instance, for gravity, I just pull two objects towards each
other with force as a function of 1/r^2; I don't bother to calculate the
G*m*m to figure out what it should actually be. Rarely, at least.)

 - Slime
[ http://www.slimeland.com/ ]


Post a reply to this message

From: Andrew Coppin
Subject: Re: Air resistance
Date: 1 Oct 2002 17:12:40
Message: <3d9a0fc8@news.povray.org>
Right guys. So if I just want to damp my pendulum a bit, a can just multiply
the velocity vector by a sub-unital constant as a crude approximation. Cool.

Oh, and btw... BIG RESPECT due to Slime for pointing out that the damping
constant is inherently framerate-dependent. That coulda been nasty! [gulp]
Still, a quick flick with good old clock_delta should fix that ;-)

Thanks as always folks!
Andrew.


Post a reply to this message

From: Lutz-Peter Hooge
Subject: Re: Air resistance
Date: 1 Oct 2002 17:57:31
Message: <3d9a1a4b@news.povray.org>
In article <3d9a0655$1@news.povray.org>, slm### [at] slimelandcom says...

> Well, yeah, but I figured for the purposes of a POV-Ray animation, you could
> just fudge the constant so that it looked alright.

Yes, if you want to "simulate" only one or two bodies.
But if you have more of them with varying masses etc it will probably be 
better to use the more complicated formula.

Lutz-Peter


Post a reply to this message

From: Christopher James Huff
Subject: Re: Air resistance
Date: 1 Oct 2002 20:19:40
Message: <chrishuff-8AC9DA.20165501102002@netplex.aussie.org>
In article <3D99E375.D3F91328@gmx.de>,
 Christoph Hormann <chr### [at] gmxde> wrote:

> In the general case the force generated by air resistance is a quite
> complicated function of the speed.  At low speeds it can be approximated
> by a force proportional to the speed (the first of the cited formulas).

Air pressure, turbulence, surface material, object geometry, air and 
surface temperature...

A water drop will get a different amount of resistance than an 
equivalently sized hailstone, they have very different surfaces, one 
hard and rigid, the other smooth but deformable, rippling and flowing. A 
square piece of cloth stretched over a frame can fly high into the air, 
the same cloth without the frame will flutter and experience large 
amounts of drag. A golfball will have a very different trajectory than a 
perfectly smooth ball of identical size and weight. I don't want to 
think about a vaporizing meteor.

You just need to figure out how complex your simulation needs to be, how 
good of an approximation you want...a linear function might do the job 
just fine.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Andrew Coppin
Subject: Quick Check...
Date: 2 Oct 2002 11:49:18
Message: <3d9b157e@news.povray.org>
Hi there. Listen, would someone just like to check my maths? ;-)

#declare FPS = 25; // Simple enough...

#declare TotalTime = final_frame / FPS; // = total number of seconds?
#declare TimeStep = clock_delta * TotalTime; // = seconds since prev frame??

Assuming I got that much right, how about this for my air resistance damping
bit:

#declare Velocity = Velocity * (1 - (k * TimeStep));

(where k has already been defined as something like 1e-2 or so).

I just tried my simulation at two different frame rates and got different
results. However, this doesn't mean the formula is wrong (IMHO), since the
orbit I'm calculating is highly unstable; the result is probably different
with the original one too! (i.e., the one without air resistence.) Anyway,
the results _look_ fairly good - will post to the animations group as soon
as POV-Ray finishes drawing it ;-)

Andrew.


Post a reply to this message

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
server... 8¬0

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
> server... 8¬0
> 

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

From: Slime
Subject: Re: Quick Check...
Date: 4 Oct 2002 13:49:04
Message: <3d9dd490$1@news.povray.org>
> BTW: You should really get into differential equations... it's one of the
> most interesting things in math.


And applicable =)

Although I'm not sure what Andrew's math level or even age is. Calculus may
be in the future or the distant, forgotten past for him.

 - Slime
[ http://www.slimeland.com/ ]


Post a reply to this message

From: Andrew Coppin
Subject: Re: Quick Check...
Date: 4 Oct 2002 14:17:10
Message: <3d9ddb26@news.povray.org>
"Slime" <slm### [at] slimelandcom> wrote in message
news:3d9dd490$1@news.povray.org...
> > BTW: You should really get into differential equations... it's one of
the
> > most interesting things in math.

Naah - knot theory is *much* more interesting ;-D

> And applicable =)

OK, point taken...

> Although I'm not sure what Andrew's math level or even age is. Calculus
may
> be in the future or the distant, forgotten past for him.

For anyone who cares... I'm 22, and I've never had a "propper" algebra
lesson in my life; the only thing I learned at school (err... or rather, the
only thing I was *taught* at school ;-) as how to add and subtract, etc. As
far as "real maths" goes, what can I say? Libraries are beautiful things 8-D

I know a little differential calculus... I never really did get my head
round the notation used for integral calculus... I know roughly what a
derrivative is, but I have no idea what a "differential equation" is.
(Although I'm always hearing about them!) I didn't really read Micha's post
other than skimming through it and observing that the final result "seems"
to make good sense. I was going to read through again offline later - but I
ain't got round to it yet ;-)

Andrew.

PS. I _still_ don't know my times tables... THIS IS WHY COMPUTERS WERE
INVENTED 8^)


Post a reply to this message

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