Verlet Integration Problem

Started by
31 comments, last by Kasya 15 years, 4 months ago
Quote:Original post by cannonicus
You shouldnt have 2*position when you use += operator. You were right in your first post.


Crap, you're right! Oops...wow, I made a mistake! Thank you for correcting it. I'll make a note in my other posts.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Advertisement
I DID THAT! :) Thank you very very much! It goes with very very small rate. Does it need to be like that? Or not:

sec pos0   50.0000001   49.9990012   49.9970023   49.9940034   49.9900055   49.9850086   49.979012


?
Well, its only 0.01 sec between each line, so its not surprising the value is changing so slowly. (Assuming you now have velocity = (0 0 0), else something is still rotten)

Congrats by the way and have fun with your verlet integrator :)

//Emil
Emil Jonssonvild
Now im going to write the calculation of timestep and Time Corrected Verlet Integration. Thank you very very much! :)

Good Luck!
Kasya
Hello,
I have finished the my Verlet Integration System:

My Verlet System

Please look at it and play with acceleration and tell me if that is correct please because i think there is a bug here.

The bug im thinking of:
When i change acceleration does it need to do before simulation thing:
prev_position = position - velocity*Integration timestep, or not?

Note: Timestep is 0.01 here

Thanks,
Kasya
Hi Kasya,

It's a bit hard to comment on the program when you don't know what it's supposed to do. If the downwards movement is caused by a continuous gravitational pull, then something is probably wrong, since the object doesn't seem to accelerate, just move downwards at a constant speed. If on the other hand you just apply one "knock" at the object on program startup, then the constant velocity is right.

Please add a few details, or maybe even the source code.

Cheers,
Mike
Thats the Integration

void Particle::startSimulation(real dt) {	prev_position = position - velocity * dt;}void Particle::Integrate(real time) {	real dt = 0.01;	Vector3 temp = position;	position += (position - prev_position) + acceleration * dt * dt;	prev_position = temp;}


And Thats the Test Code:

void InitOpenGL() {//OpenGL Functions like glEnable ...	particle.SetMass(10);	particle.SetPosition(Vector3(0,3,0));	particle.SetVelocity(Vector3(0,2,0));		Physics::ApplyForce(&particle, "Gravity"); //Just add -10 to y acceleration	particle.startSimulation(0.01);}void RenderOpenGL() {//Render Functions like LoadIdentity...	glPointSize(particle.getMass()/0.4); //For making object real :)	glBegin(GL_POINTS);	glColor3f(1,0,1);	glVertex3f(2,particle.getPosition().y,0);	glEnd();	if(simulate) {		particle.Integrate(0);	}      //The Texts Function (Mouse Position, Information, Simulation Button ...)}
I just Added the Position Difference between current and last position. It is decreasing. If it is accelerating downward it needs to decrease right?

*EDIT* Just Forgotten to add Absolute Value for difference. Its always increasing now. LoL.

Now the problem here is when i make acceleration positive, there comes a bug i guess so. It goes downward a little bit and then goes upward. Why? (Change the acceleration from -10 to 10 and see what happens)

Thanks,
Kasya

[Edited by - Kasya on December 6, 2008 10:24:35 AM]
So What you think?
Quote:
When i change acceleration does it need to do before simulation thing:
prev_position = position - velocity*Integration timestep, or not?


No, dont do that. You only need to do that before you start the simulation. When the simulation is running prev_position will always be the position of the particle in the last frame, you can apply any acceleration each simulation tick.

Honestly i cant see anything wrong with the simulation i downloaded. Seemed to work allright. But if you want to be sure you can always calculate the particles total energy each frame. As long as you dont change the acceleration the total energy should be constant.

Total energy = Kinetic energy + potential energy

Kinetic energy = 1/2*m*v^2
potential energy = -m*y-acceleration*y-coordinate

Quote:
Now the problem here is when i make acceleration positive, there comes a bug i guess so. It goes downward a little bit and then goes upward. Why? (Change the acceleration from -10 to 10 and see what happens)



I couldnt reproduce this.
Emil Jonssonvild

This topic is closed to new replies.

Advertisement