Skip to main content
gamedev.net
🔒 Locked

Particle class parameters

Started by Silly_con Feb 22, 2005 at 1:39 PM 2 replies 1.4k views
Original Post
Silly_con
Silly_con
I have a particle class, it has position, velocity, acceleration and force parameters. I want to: - Set/(Add to) Total Force - Set/(Add to) Velocity - Set/(Add to) Acceleration My question is, when you integrate to obtain position, how do you know what to integrate if you can set any propertie directly ? ex. you set the particle acceleration, so you need to integrate to obtain velocity, and later to obtain position, but if you set the velocity directly, how you can skip the "acceleration to velocity" integration for not overwrite the setted velocity (and the same with forces, etc)? Thanks
Zakwayda
Zakwayda
Disclaimer: I'm not a physics expert, so take my input with a grain of salt.

Ideally, you shouldn't be setting or changing velocity, acceleration, or momentum directly. All you should be doing is applying forces, and maybe impulses, for each physics step. When you integrate, the accelerations, velocities and momenta will fall out naturally from the forces applied.

For a great discussion of the topic in general, and application to particle systems, check out Baraff's papers on the subject (you should be able to find them online). It's a series of papers that covers differential equations, physics in application to particles, particle systems, and rigid bodies, as well some info on collision detection and response.

There may be cases where you want to 'hack' the physics system and set accelerations or velocities directly. In those cases I'd think you'd have to bypass the integration steps preceding the 'hack'. Generally, though, this sort of thing is probably better accomplished through impulses.

Again, 'with a grain of salt'.
Silly_con
Silly_con
So all have to be based in forces and impulse, so if I want a particle to be at a velocity of 5 units/sec or a particle with an acceleration of 2 units/sec^2 I have to calculate the force necessary to get this vel or accel, and then apply this force ?
Zakwayda
Zakwayda
Quote:
So all have to be based in forces and impulse, so if I want a particle to be at a velocity of 5 units/sec or a particle with an acceleration of 2 units/sec^2 I have to calculate the force necessary to get this vel or accel, and then apply this force?
That's the general idea.

I'll give you some specifics, but again let me disclaim by saying that my formal math and physics background is pretty minimal (although I am learning). So I can't guarantee the correctness of the following, but it should at least get you going in the right direction.

First of all, F = ma, where F is force, m is mass and a is acceleration.

Assuming that you know the mass of your particle, you can then apply a change in acceleration like this:

void Particle::ApplyAccelerationChange(const Vector3& a)
{
ApplyForce(m_mass * a);
}

Furthermore, p = mv, where p is momentum, m is mass, and v is velocity. An impulse j is a change in momentum. So, you should be able to apply a change in velocity like this:

void Particle::ApplyVelocityChange(const Vector3& v)
{
ApplyImpulse(m_mass * v);
}

If your particle velocity is initially zeroed, you could then set its initial velocity with this function.

Again, don't take this as an authoritative answer, because my equations may or may not be correct. But you can use it as a point of departure. For references, I recommend again the Baraff papers, Chris Hecker's papers, and 'Physics for Game Developers' by David Bourg.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.