Which formula would you use for "velocity loss"

This topic is 5026 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

In my 2D engine, I have a relatively robust particle system which is controlled by objects called Emitters. These emitters have various properties. Anyway, I'm looking to add in a variable which I've called velocityLoss, for lack of a better name. This will simulate drag, slowing down particles. My first idea was to tie it linearly to velocity and do the following calculation every frame: velocity -= velocity * velocityLoss * timeStep; The idea would be that if velocityLoss is 1, then the deceleration for that frame would stop the particle in one second, if it wasn't changed every frame to account for the slower velocity, of course. Velocity is in units/sec and timeStep is in seconds. However, this is obviously not the case, as a graph would have a negative but increasing slope, and actually never quite reach 0. The inaccuracy of this linear estimation isn't really a concern. I suppose this might be a good model for drag, but is it . . how should I put it. . . straight forward enough? That is, are there more common formulas or values which are used for this type of thing? Or is "inventing" a new method acceptable. Usually these values will be set in a graphical program, so the user will be able to see what the value does in real-time. Keep in mind that there are times where there could be hundreds or thousands of particles, so keeping the formula simple is better. Any thoughts? --Vic--

Share on other sites
I believe its more common to damp by doing something like velocity *= damping_factor; at each timestep, where damping_factor is somewhat less than 1, for instance 0.95 or so.

Share on other sites
But I have a variable timestep (who wants to limit frame rate, yuck).

--Vic--

Share on other sites
drag force can be approximated with

Force = -Vel * k;

so then when you integrate

V += Force/mass * dt

so in essence, it's the same as

velocity -= velocity * velocityLoss * timeStep;

call it drag instead of "velocity loss" BTW, that should clear things up.

you can also add a squared magnitude of the velocity, something like

velocity -= velocity * (drag * timeStep) + velocity.Direction() * (velocity * velocity * drag2 * timestep);

ect...

a first order drag should be sufficient for a particle system. You want speed over accuracy, and that would create a realistic drag force on the particle (think explosions). Doing anything more complicated would probably be overkill.

Yes it would never reach zero and the particles will drift slowly, but is it that much of a problem for particle system...

you can also clamp the velocity components if their magnitude is below a given amount, for a quick hack example...

Particle.V += Particle.V * Particle.Drag * dt;

if (Particle.V.MagnitudeSquared() < fStaticFrictionSquared && Particle.IsOnFloor())
{
V = Vector(0, 0, 0);
}

Share on other sites
Great, drag it is, and the linear approximation it is too :) I'm not super concerned about accuracy for this, as you said. I just wanted to make sure I wasn't overlooking some obvious method that's used.

Thanks for the help,

--Vic--

Share on other sites
Bear in mind that velocity *= damping_factor;, where damping_factor is just under one, is equivalent to velocity -= velocity*drag, where drag = 1-damping_factor (i.e., where drag is just above zero). I suppose with a variable timestep, velocity *= damping_factor*timestep; should be a sufficient approximation too, but really, with explicit numerical integration, variable timestep is just Evil(tm).

Share on other sites
Quote:
 Original post by Roof Top Pew WeeBut I have a variable timestep (who wants to limit frame rate, yuck).--Vic--

almost everybody wants that, though im not sure i agree with them.

Share on other sites
Well, I know variable timestep is quite nice for my recursive collision detection routine. Things would look pretty ugly without it :)

Share on other sites
I just used linear dampening.

1. 1
Rutin
37
2. 2
3. 3
4. 4
5. 5

• 11
• 12
• 14
• 9
• 9
• Forum Statistics

• Total Topics
633348
• Total Posts
3011463
• Who's Online (See full list)

There are no registered users currently online

×