Verlet physics

Started by
2 comments, last by the_edd 11 years, 4 months ago
Hi guys!
I was read this article on this site
http://www.gamedev.n...e-physics-r2714

And I wondered, what if upgrade it for experiment?
i downloaded it and decided to add friction.

But I did not understand how to do it correctly. We can replace the speed of this [color=#ff0000]-k*N+OldVelocity[color=#ff0000];
[color=#000000]where N as I understood the normalized velocity (well, more multiplied by -1 is not?)

Well, add a small fix that would not work, that the infinite is force the body begins to move in the opposite direction
[color=#ff0000]VelNew = max(-k*N+OldVelocity, 0.0f)

how to modify this method (if not this one?) to get the friction?
[source lang="cpp"]void Physics::UpdateVerlet() { //????????? ????????? ??????
for( int I = 0; I < VertexCount; I++ ) {
Vertex& V = *Vertices[ I ];

Vec2 OldPosition = V.Position;
V.Position += V.Position-V.OldPosition + V.Acceleration*Timestep*Timestep;
V.OldPosition = OldPosition;

}
}[/source]
Advertisement
Hi,
Here you can add the damping, but friction is related to the contact between two bodies.
So you could add :
[source lang="java"]V.Position += (V.Position-V.OldPosition) * damping + V.Acceleration*Timestep*Timestep;[/source]

The friction will change the acceleration "V.Acceleration" in function of the contact normal.

Hope it can help...
Hi,
Here you can add the damping, but friction is related to the contact between two bodies.
So you could add :
[source lang="java"]V.Position += (V.Position-V.OldPosition) * damping + V.Acceleration*Timestep*Timestep;[/source]

The friction will change the acceleration "V.Acceleration" in function of the contact normal.

Hope it can help...

Thanks, but it's not work true

Once you have calculated the force due to friction, you divide by the mass to get the acceleration (a deceleration in this case) due to friction. This is then added to the acceleration before you perform an iteration of the verlet solver (or any other solver for the equations of motion). So your Physics::UpdateVerlet() method should not have to change. How you actually model friction is up to you. One simple model is to have the magnitude of friction be proportional to that of the perpendicular component of the contact force of the two bodies (so proportional to the weight -- the effect of mass due to gravity -- of a body if it is sitting on a flat surface). Any introductory book on Newtonian mechanics is likely to explain this model.

This topic is closed to new replies.

Advertisement